@oakagentkit/core 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (576) hide show
  1. package/build/dist/api/addresses.d.ts +112 -0
  2. package/build/dist/api/addresses.js +1 -1
  3. package/build/dist/api/amounts.d.ts +2 -0
  4. package/build/dist/api/amounts.js +1 -1
  5. package/build/dist/api/args.js +1 -1
  6. package/build/dist/api/cache.js +1 -1
  7. package/build/dist/api/canonical.js +1 -1
  8. package/build/dist/api/chain.js +1 -1
  9. package/build/dist/api/deployments.js +1 -1
  10. package/build/dist/api/errors.d.ts +1 -0
  11. package/build/dist/api/errors.js +1 -1
  12. package/build/dist/api/gas.js +1 -1
  13. package/build/dist/api/grandfather.js +1 -1
  14. package/build/dist/api/guards.js +1 -1
  15. package/build/dist/api/history.js +1 -1
  16. package/build/dist/api/http.js +1 -1
  17. package/build/dist/api/identity-link.d.ts +1 -0
  18. package/build/dist/api/identity-link.js +1 -1
  19. package/build/dist/api/launch.js +1 -1
  20. package/build/dist/api/merkle.js +1 -1
  21. package/build/dist/api/metadata.js +1 -1
  22. package/build/dist/api/module.js +1 -1
  23. package/build/dist/api/modules/beefy/boosts.js +1 -1
  24. package/build/dist/api/modules/beefy/clm.js +1 -1
  25. package/build/dist/api/modules/beefy/guard.js +1 -1
  26. package/build/dist/api/modules/beefy/index.js +1 -1
  27. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  28. package/build/dist/api/modules/beefy/management.js +1 -1
  29. package/build/dist/api/modules/beefy/vaults.js +1 -1
  30. package/build/dist/api/modules/borro/abi.d.ts +149 -0
  31. package/build/dist/api/modules/borro/abi.js +1 -0
  32. package/build/dist/api/modules/borro/actions.d.ts +2 -0
  33. package/build/dist/api/modules/borro/actions.js +1 -0
  34. package/build/dist/api/modules/borro/checks.d.ts +151 -0
  35. package/build/dist/api/modules/borro/checks.js +1 -0
  36. package/build/dist/api/modules/borro/copy.d.ts +174 -0
  37. package/build/dist/api/modules/borro/copy.js +1 -0
  38. package/build/dist/api/modules/borro/index.d.ts +13 -0
  39. package/build/dist/api/modules/borro/index.js +1 -0
  40. package/build/dist/api/modules/borro/liquidity.d.ts +4 -0
  41. package/build/dist/api/modules/borro/liquidity.js +1 -0
  42. package/build/dist/api/modules/borro/pins.d.ts +264 -0
  43. package/build/dist/api/modules/borro/pins.js +1 -0
  44. package/build/dist/api/modules/borro/positions.d.ts +8 -0
  45. package/build/dist/api/modules/borro/positions.js +1 -0
  46. package/build/dist/api/modules/borro/rates.d.ts +20 -0
  47. package/build/dist/api/modules/borro/rates.js +1 -0
  48. package/build/dist/api/modules/borro/reader.d.ts +32 -0
  49. package/build/dist/api/modules/borro/reader.js +1 -0
  50. package/build/dist/api/modules/borro/types.d.ts +120 -0
  51. package/build/dist/api/modules/borro/types.js +0 -0
  52. package/build/dist/api/modules/clanker/extensions.js +1 -1
  53. package/build/dist/api/modules/clanker/index.js +1 -1
  54. package/build/dist/api/modules/clanker/manage.js +1 -1
  55. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  56. package/build/dist/api/modules/clanker/protocol.js +1 -1
  57. package/build/dist/api/modules/clanker/state.js +1 -1
  58. package/build/dist/api/modules/earn/copy.d.ts +114 -0
  59. package/build/dist/api/modules/earn/copy.js +1 -0
  60. package/build/dist/api/modules/earn/cost.d.ts +47 -0
  61. package/build/dist/api/modules/earn/cost.js +1 -0
  62. package/build/dist/api/modules/earn/index.d.ts +8 -0
  63. package/build/dist/api/modules/earn/index.js +1 -0
  64. package/build/dist/api/modules/earn/lp.d.ts +17 -0
  65. package/build/dist/api/modules/earn/lp.js +1 -0
  66. package/build/dist/api/modules/earn/options.d.ts +36 -0
  67. package/build/dist/api/modules/earn/options.js +1 -0
  68. package/build/dist/api/modules/earn/types.d.ts +39 -0
  69. package/build/dist/api/modules/earn/types.js +0 -0
  70. package/build/dist/api/modules/erc8004/abi.js +1 -1
  71. package/build/dist/api/modules/erc8004/common.js +1 -1
  72. package/build/dist/api/modules/erc8004/domain.js +1 -1
  73. package/build/dist/api/modules/erc8004/index.js +1 -1
  74. package/build/dist/api/modules/erc8004/management.js +1 -1
  75. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  76. package/build/dist/api/modules/erc8004/services.js +1 -1
  77. package/build/dist/api/modules/erc8004/validation.js +1 -1
  78. package/build/dist/api/modules/grove/index.js +1 -1
  79. package/build/dist/api/modules/heyresearch/backoff.js +1 -1
  80. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  81. package/build/dist/api/modules/heyresearch/freshness.js +1 -1
  82. package/build/dist/api/modules/heyresearch/index.js +1 -1
  83. package/build/dist/api/modules/heyresearch/proof-reads.js +1 -1
  84. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  85. package/build/dist/api/modules/heyresearch/scan.js +1 -1
  86. package/build/dist/api/modules/heyresearch/status-labels.d.ts +1 -1
  87. package/build/dist/api/modules/heyresearch/status-labels.js +1 -1
  88. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  89. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  90. package/build/dist/api/modules/hoodag/index.js +1 -1
  91. package/build/dist/api/modules/hoodag/management.js +1 -1
  92. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  93. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  94. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  95. package/build/dist/api/modules/hoodlock/buyback.js +1 -1
  96. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  97. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  98. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  99. package/build/dist/api/modules/hoodlock/index.js +1 -1
  100. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  101. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  102. package/build/dist/api/modules/hoodlock/public.js +1 -1
  103. package/build/dist/api/modules/hookr/actions.js +1 -1
  104. package/build/dist/api/modules/hookr/addons.js +1 -1
  105. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  106. package/build/dist/api/modules/hookr/contracts.js +1 -1
  107. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  108. package/build/dist/api/modules/hookr/discovery.js +1 -1
  109. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  110. package/build/dist/api/modules/hookr/index.js +1 -1
  111. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  112. package/build/dist/api/modules/hookr/launch-profile.js +1 -1
  113. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  114. package/build/dist/api/modules/hookr/launch.js +1 -1
  115. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  116. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  117. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  118. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  119. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  120. package/build/dist/api/modules/hookr/pins.js +1 -1
  121. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  122. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  123. package/build/dist/api/modules/hookr/relay.js +1 -1
  124. package/build/dist/api/modules/hookr/revenue.js +1 -1
  125. package/build/dist/api/modules/kyberswap/index.js +1 -1
  126. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  127. package/build/dist/api/modules/layerbank/abi.d.ts +165 -0
  128. package/build/dist/api/modules/layerbank/abi.js +1 -0
  129. package/build/dist/api/modules/layerbank/actions.d.ts +2 -0
  130. package/build/dist/api/modules/layerbank/actions.js +1 -0
  131. package/build/dist/api/modules/layerbank/checks.d.ts +21 -0
  132. package/build/dist/api/modules/layerbank/checks.js +1 -0
  133. package/build/dist/api/modules/layerbank/index.d.ts +2 -0
  134. package/build/dist/api/modules/layerbank/index.js +1 -0
  135. package/build/dist/api/modules/layerbank/merkl.d.ts +6 -0
  136. package/build/dist/api/modules/layerbank/merkl.js +1 -0
  137. package/build/dist/api/modules/layerbank/reader.d.ts +15 -0
  138. package/build/dist/api/modules/layerbank/reader.js +1 -0
  139. package/build/dist/api/modules/layerbank/reserve.d.ts +13 -0
  140. package/build/dist/api/modules/layerbank/reserve.js +1 -0
  141. package/build/dist/api/modules/lighter/index.js +1 -1
  142. package/build/dist/api/modules/longbow/administration.js +1 -1
  143. package/build/dist/api/modules/longbow/analytics.js +1 -1
  144. package/build/dist/api/modules/longbow/fixed.js +1 -1
  145. package/build/dist/api/modules/longbow/index.js +1 -1
  146. package/build/dist/api/modules/longbow/nft.js +1 -1
  147. package/build/dist/api/modules/longbow/rebates.js +1 -1
  148. package/build/dist/api/modules/longbow/staking.js +1 -1
  149. package/build/dist/api/modules/meridian/index.js +1 -1
  150. package/build/dist/api/modules/meridian/markets.js +1 -1
  151. package/build/dist/api/modules/meridian/perps-batch.js +1 -1
  152. package/build/dist/api/modules/meridian/perps-common.js +1 -1
  153. package/build/dist/api/modules/meridian/perps-guards.js +1 -1
  154. package/build/dist/api/modules/meridian/perps-intents.js +1 -1
  155. package/build/dist/api/modules/meridian/perps-stream.js +1 -1
  156. package/build/dist/api/modules/meridian/perps.d.ts +1 -0
  157. package/build/dist/api/modules/meridian/perps.js +1 -1
  158. package/build/dist/api/modules/meridian/predict-read.js +1 -1
  159. package/build/dist/api/modules/meridian/rfq.js +1 -1
  160. package/build/dist/api/modules/merkl/discovery.js +1 -1
  161. package/build/dist/api/modules/merkl/index.js +1 -1
  162. package/build/dist/api/modules/merkl/manage.js +1 -1
  163. package/build/dist/api/modules/merkl/protocol.js +1 -1
  164. package/build/dist/api/modules/morpho/allocator.js +1 -1
  165. package/build/dist/api/modules/morpho/bundles-abi.js +1 -1
  166. package/build/dist/api/modules/morpho/bundles.js +1 -1
  167. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  168. package/build/dist/api/modules/morpho/index.js +1 -1
  169. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  170. package/build/dist/api/modules/morpho/midnight-abi.js +1 -1
  171. package/build/dist/api/modules/morpho/midnight.js +1 -1
  172. package/build/dist/api/modules/morpho/protocol.js +1 -1
  173. package/build/dist/api/modules/morpho/surface.js +1 -1
  174. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  175. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  176. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  177. package/build/dist/api/modules/netnet/blackjack-hashes.js +1 -1
  178. package/build/dist/api/modules/netnet/card-abi.js +1 -1
  179. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  180. package/build/dist/api/modules/netnet/card-policy.js +1 -1
  181. package/build/dist/api/modules/netnet/card-read.js +1 -1
  182. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  183. package/build/dist/api/modules/netnet/desk-action-abi.js +1 -1
  184. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  185. package/build/dist/api/modules/netnet/desk-read.js +1 -1
  186. package/build/dist/api/modules/netnet/desk-registry.js +1 -1
  187. package/build/dist/api/modules/netnet/financial-abi.js +1 -1
  188. package/build/dist/api/modules/netnet/financial.js +1 -1
  189. package/build/dist/api/modules/netnet/index.js +1 -1
  190. package/build/dist/api/modules/netnet/staking.js +1 -1
  191. package/build/dist/api/modules/orbio/gateway.js +1 -1
  192. package/build/dist/api/modules/orbio/index.js +1 -1
  193. package/build/dist/api/modules/orbio/pins.js +1 -1
  194. package/build/dist/api/modules/orbio/positions.d.ts +2 -0
  195. package/build/dist/api/modules/orbio/positions.js +1 -0
  196. package/build/dist/api/modules/pendle/abi.d.ts +205 -0
  197. package/build/dist/api/modules/pendle/abi.js +1 -0
  198. package/build/dist/api/modules/pendle/convert.d.ts +24 -0
  199. package/build/dist/api/modules/pendle/convert.js +1 -0
  200. package/build/dist/api/modules/pendle/costs.d.ts +3 -0
  201. package/build/dist/api/modules/pendle/costs.js +1 -0
  202. package/build/dist/api/modules/pendle/index.d.ts +11 -0
  203. package/build/dist/api/modules/pendle/index.js +1 -0
  204. package/build/dist/api/modules/pendle/markets.d.ts +37 -0
  205. package/build/dist/api/modules/pendle/markets.js +1 -0
  206. package/build/dist/api/modules/pendle/positions.d.ts +18 -0
  207. package/build/dist/api/modules/pendle/positions.js +1 -0
  208. package/build/dist/api/modules/pendle/pricecheck.d.ts +95 -0
  209. package/build/dist/api/modules/pendle/pricecheck.js +1 -0
  210. package/build/dist/api/modules/pendle/reader.d.ts +17 -0
  211. package/build/dist/api/modules/pendle/reader.js +1 -0
  212. package/build/dist/api/modules/pendle/redeem.d.ts +15 -0
  213. package/build/dist/api/modules/pendle/redeem.js +1 -0
  214. package/build/dist/api/modules/pendle/trade.d.ts +2 -0
  215. package/build/dist/api/modules/pendle/trade.js +1 -0
  216. package/build/dist/api/modules/pendle/types.d.ts +41 -0
  217. package/build/dist/api/modules/pendle/types.js +0 -0
  218. package/build/dist/api/modules/pendle/validate.d.ts +424 -0
  219. package/build/dist/api/modules/pendle/validate.js +1 -0
  220. package/build/dist/api/modules/pendle/verify.d.ts +22 -0
  221. package/build/dist/api/modules/pendle/verify.js +1 -0
  222. package/build/dist/api/modules/pons/claim.js +1 -1
  223. package/build/dist/api/modules/pons/holder-directory.js +1 -1
  224. package/build/dist/api/modules/pons/index.js +1 -1
  225. package/build/dist/api/modules/pons/launch-status.js +1 -1
  226. package/build/dist/api/modules/pons/prices.js +1 -1
  227. package/build/dist/api/modules/pons/reads.d.ts +38 -2
  228. package/build/dist/api/modules/pons/reads.js +1 -1
  229. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  230. package/build/dist/api/modules/pons/trade.js +1 -1
  231. package/build/dist/api/modules/poolstrade/index.js +1 -1
  232. package/build/dist/api/modules/priors/coverage.js +1 -1
  233. package/build/dist/api/modules/priors/discovery.js +1 -1
  234. package/build/dist/api/modules/priors/features.js +1 -1
  235. package/build/dist/api/modules/priors/holdings.d.ts +4 -0
  236. package/build/dist/api/modules/priors/holdings.js +1 -0
  237. package/build/dist/api/modules/priors/index.js +1 -1
  238. package/build/dist/api/modules/priors/integration.js +1 -1
  239. package/build/dist/api/modules/priors/market.js +1 -1
  240. package/build/dist/api/modules/priors/pt.js +1 -1
  241. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  242. package/build/dist/api/modules/priors/starter-line.js +1 -1
  243. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  244. package/build/dist/api/modules/relay/api.js +1 -1
  245. package/build/dist/api/modules/relay/bootstrap.js +1 -1
  246. package/build/dist/api/modules/relay/discovery.js +1 -1
  247. package/build/dist/api/modules/relay/inbound.d.ts +2 -0
  248. package/build/dist/api/modules/relay/inbound.js +1 -1
  249. package/build/dist/api/modules/relay/index.js +1 -1
  250. package/build/dist/api/modules/relay/order.js +1 -1
  251. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  252. package/build/dist/api/modules/relay/readiness.js +1 -1
  253. package/build/dist/api/modules/relay/reads.js +1 -1
  254. package/build/dist/api/modules/relay/vaults.js +1 -1
  255. package/build/dist/api/modules/spark/actions.js +1 -1
  256. package/build/dist/api/modules/spark/details.js +1 -1
  257. package/build/dist/api/modules/spark/index.js +1 -1
  258. package/build/dist/api/modules/spark/management.js +1 -1
  259. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  260. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  261. package/build/dist/api/modules/steakhouse/index.js +1 -1
  262. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  263. package/build/dist/api/modules/steakhouse/management.js +1 -1
  264. package/build/dist/api/modules/steakhouse/share-symbol.d.ts +3 -0
  265. package/build/dist/api/modules/steakhouse/share-symbol.js +1 -0
  266. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  267. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  268. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  269. package/build/dist/api/modules/tickerspring/discovery.js +1 -1
  270. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  271. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  272. package/build/dist/api/modules/tickerspring/index.js +1 -1
  273. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  274. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  275. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  276. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  277. package/build/dist/api/modules/tickerspring/research.js +1 -1
  278. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  279. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  280. package/build/dist/api/modules/uniswap/auction.js +1 -1
  281. package/build/dist/api/modules/uniswap/batch.js +1 -1
  282. package/build/dist/api/modules/uniswap/common.js +1 -1
  283. package/build/dist/api/modules/uniswap/fees.js +1 -1
  284. package/build/dist/api/modules/uniswap/index.js +1 -1
  285. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  286. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  287. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  288. package/build/dist/api/modules/uniswap/pools.js +1 -1
  289. package/build/dist/api/modules/uniswap/position.js +1 -1
  290. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  291. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  292. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  293. package/build/dist/api/modules/uniswap/trade.js +1 -1
  294. package/build/dist/api/modules/uniswap/v2.js +1 -1
  295. package/build/dist/api/modules/uniswap/v3.d.ts +11 -0
  296. package/build/dist/api/modules/uniswap/v3.js +1 -1
  297. package/build/dist/api/modules/uniswap/v4.js +1 -1
  298. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  299. package/build/dist/api/modules/velora/claims.js +1 -1
  300. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  301. package/build/dist/api/modules/velora/index.js +1 -1
  302. package/build/dist/api/modules/wormhole/index.js +1 -1
  303. package/build/dist/api/modules/wormhole/license.js +1 -1
  304. package/build/dist/api/modules/wormhole/quotetext.js +1 -1
  305. package/build/dist/api/modules/wormhole/scan-text.js +1 -1
  306. package/build/dist/api/modules/wormhole/token-check.js +1 -1
  307. package/build/dist/api/owner-signature.js +1 -1
  308. package/build/dist/api/positions.d.ts +5 -5
  309. package/build/dist/api/positions.js +1 -1
  310. package/build/dist/api/pricenote.js +1 -1
  311. package/build/dist/api/prices.js +1 -1
  312. package/build/dist/api/pricing.js +1 -1
  313. package/build/dist/api/reads.js +1 -1
  314. package/build/dist/api/routes.js +1 -1
  315. package/build/dist/api/rpc.js +1 -1
  316. package/build/dist/api/secret-fields.js +1 -1
  317. package/build/dist/api/send.js +1 -1
  318. package/build/dist/api/signing-registry.js +1 -1
  319. package/build/dist/api/signing.js +1 -1
  320. package/build/dist/api/simulate.js +1 -1
  321. package/build/dist/api/swap.js +1 -1
  322. package/build/dist/api/token-output.js +1 -1
  323. package/build/dist/api/tokens.d.ts +1 -0
  324. package/build/dist/api/tokens.js +1 -1
  325. package/build/dist/api/tool-policy.js +1 -1
  326. package/build/dist/api/tx.js +1 -1
  327. package/build/dist/api/types.d.ts +7 -2
  328. package/build/dist/api/untrusted.js +1 -1
  329. package/build/dist/api/vendor-limits.js +1 -1
  330. package/build/dist/chunks/{PEA32CWB.js → 2KYAMXTS.js} +1 -1
  331. package/build/dist/chunks/2MAMJJJC.js +1 -0
  332. package/build/dist/chunks/2MZXTOZU.js +1 -0
  333. package/build/dist/chunks/{VC2RCYQE.js → 2TK3ETUO.js} +1 -1
  334. package/build/dist/chunks/{LKJBMHCE.js → 326QMOTR.js} +1 -1
  335. package/build/dist/chunks/{OE3CLZHR.js → 3FUVMSCF.js} +1 -1
  336. package/build/dist/chunks/{3EFV4FQF.js → 3GOHSYHW.js} +1 -1
  337. package/build/dist/chunks/{CY75R4FK.js → 3MLUCYCB.js} +1 -1
  338. package/build/dist/chunks/{5O5ZE3ZV.js → 3NJ5KQ3Q.js} +1 -1
  339. package/build/dist/chunks/{EVANKNJV.js → 3XNZUIRU.js} +1 -1
  340. package/build/dist/chunks/3XXBLNEX.js +1 -0
  341. package/build/dist/chunks/{6IM6A5VA.js → 43LI5NKJ.js} +1 -1
  342. package/build/dist/chunks/{YZSTP2E6.js → 45BRW2ZF.js} +1 -1
  343. package/build/dist/chunks/46547QT3.js +1 -0
  344. package/build/dist/chunks/{C3TJLARP.js → 46KWRAYK.js} +1 -1
  345. package/build/dist/chunks/{SOYQOE5P.js → 4BVP652W.js} +1 -1
  346. package/build/dist/chunks/4HG6FRVH.js +1 -0
  347. package/build/dist/chunks/4MXM6Q4W.js +1 -0
  348. package/build/dist/chunks/{NWSPC3NH.js → 4PY3UFNR.js} +1 -1
  349. package/build/dist/chunks/52ELWNXJ.js +2 -0
  350. package/build/dist/chunks/{O5IVZHHP.js → 553UE2ZQ.js} +1 -1
  351. package/build/dist/chunks/{FUXT7GRK.js → 57MEFFCU.js} +1 -1
  352. package/build/dist/chunks/{XWEFKXKA.js → 5APS4T2D.js} +1 -1
  353. package/build/dist/chunks/{3RFSGU2Y.js → 5CAAFU7R.js} +1 -1
  354. package/build/dist/chunks/{6AWTAE4Q.js → 5SMVQCAP.js} +1 -1
  355. package/build/dist/chunks/63YRSLDK.js +1 -0
  356. package/build/dist/chunks/{53N7PNJH.js → 64GOINYS.js} +1 -1
  357. package/build/dist/chunks/66F5ZH34.js +1 -0
  358. package/build/dist/chunks/{6ZYLNB2B.js → 6B3VVISQ.js} +1 -1
  359. package/build/dist/chunks/6D5DJA5B.js +1 -0
  360. package/build/dist/chunks/{DZGEQBO7.js → 6I4NTKB2.js} +1 -1
  361. package/build/dist/chunks/{DCTUYDWF.js → 6OGDTEGH.js} +1 -1
  362. package/build/dist/chunks/6PBGEPUK.js +20 -0
  363. package/build/dist/chunks/{E7R3J4H7.js → 6WD4HHID.js} +1 -1
  364. package/build/dist/chunks/{RAKUK5VR.js → 6WZX7C4T.js} +1 -1
  365. package/build/dist/chunks/{MKQVS3IO.js → 74Y2KDNR.js} +1 -1
  366. package/build/dist/chunks/{AMICUXS6.js → 7WSHW7KW.js} +1 -1
  367. package/build/dist/chunks/A3PN3PK3.js +1 -0
  368. package/build/dist/chunks/{CXLEQCP3.js → ABPL3ZZI.js} +1 -1
  369. package/build/dist/chunks/{YQUKU2LS.js → AFBEZXNV.js} +1 -1
  370. package/build/dist/chunks/AKYF5264.js +7 -0
  371. package/build/dist/chunks/{ASDKY5NX.js → APGLZXIW.js} +1 -1
  372. package/build/dist/chunks/{UNZRE3YU.js → AVG4W3Y7.js} +1 -1
  373. package/build/dist/chunks/{VFKNXQXI.js → B3RXD5ET.js} +1 -1
  374. package/build/dist/chunks/{V5LTA42G.js → BBS3ODWZ.js} +1 -1
  375. package/build/dist/chunks/{U3F6DDML.js → BJ2VGRF4.js} +1 -1
  376. package/build/dist/chunks/{VFSRRDLY.js → BTD5SMOW.js} +1 -1
  377. package/build/dist/chunks/{PTAWEHKB.js → BTPXJAUX.js} +1 -1
  378. package/build/dist/chunks/{R53P2K3C.js → C36BFZH6.js} +1 -1
  379. package/build/dist/chunks/{L62M7LOB.js → C5ZZAYXD.js} +1 -1
  380. package/build/dist/chunks/{VVEUJ36E.js → C7AXJHBT.js} +1 -1
  381. package/build/dist/chunks/CBG5HARQ.js +2 -0
  382. package/build/dist/chunks/{ELZNT5Q3.js → CCTXCMH4.js} +1 -1
  383. package/build/dist/chunks/{AJP5LDM2.js → CHXBOXOD.js} +1 -1
  384. package/build/dist/chunks/D3YLXQPW.js +1 -0
  385. package/build/dist/chunks/DFM4T6ZE.js +1 -0
  386. package/build/dist/chunks/{GGUEKSR4.js → DJN3JAWB.js} +1 -1
  387. package/build/dist/chunks/{52DHGSG4.js → DW4V5PUY.js} +1 -1
  388. package/build/dist/chunks/E3RACZUY.js +1 -0
  389. package/build/dist/chunks/{VCLPOU7T.js → E674J2MD.js} +1 -1
  390. package/build/dist/chunks/EE64JSLY.js +1 -0
  391. package/build/dist/chunks/EJ7O75A7.js +1 -0
  392. package/build/dist/chunks/{ZXQMF56D.js → ELSXLZN5.js} +1 -1
  393. package/build/dist/chunks/ER47KGRM.js +1 -0
  394. package/build/dist/chunks/FQ6UZCM6.js +1 -0
  395. package/build/dist/chunks/FWD4L3CJ.js +1 -0
  396. package/build/dist/chunks/GEIFITAQ.js +1 -0
  397. package/build/dist/chunks/{S3HNPTXA.js → GGSAKCND.js} +1 -1
  398. package/build/dist/chunks/GL4NCUMH.js +1 -0
  399. package/build/dist/chunks/GNC6RXLT.js +1 -0
  400. package/build/dist/chunks/{YA5WWDEW.js → GQ5GYUEH.js} +1 -1
  401. package/build/dist/chunks/{TLJPVYRJ.js → GW5IXLKU.js} +1 -1
  402. package/build/dist/chunks/{57HAXNQV.js → GW626GG2.js} +1 -1
  403. package/build/dist/chunks/{CE7D6MUS.js → H2XDMFQQ.js} +1 -1
  404. package/build/dist/chunks/H43RNCX2.js +1 -0
  405. package/build/dist/chunks/HAQPIBYR.js +1 -0
  406. package/build/dist/chunks/HCUHMCBW.js +1 -0
  407. package/build/dist/chunks/HKEMQBFA.js +1 -0
  408. package/build/dist/chunks/{WTSMPDT5.js → HM72DH4V.js} +1 -1
  409. package/build/dist/chunks/HSCQZ66A.js +1 -0
  410. package/build/dist/chunks/{4KQZTPMS.js → I26DMNJG.js} +1 -1
  411. package/build/dist/chunks/{YHPOXAKA.js → IMO3GDA5.js} +1 -1
  412. package/build/dist/chunks/INOZIE55.js +1 -0
  413. package/build/dist/chunks/IOYRL6AY.js +1 -0
  414. package/build/dist/chunks/IX3GZMTM.js +1 -0
  415. package/build/dist/chunks/IY7BXLT4.js +1 -0
  416. package/build/dist/chunks/J2OT4KAH.js +1 -0
  417. package/build/dist/chunks/JKD2B6OX.js +1 -0
  418. package/build/dist/chunks/JUZ5JU6D.js +70 -0
  419. package/build/dist/chunks/{5OEHZJ6X.js → JVLLVNF2.js} +1 -1
  420. package/build/dist/chunks/K3RDPI5J.js +1 -0
  421. package/build/dist/chunks/{WCKMQFGS.js → K4DHHQBI.js} +1 -1
  422. package/build/dist/chunks/KBKK7UNY.js +1 -0
  423. package/build/dist/chunks/KIFSRO5K.js +1 -0
  424. package/build/dist/chunks/KIFZ5ZSK.js +1 -0
  425. package/build/dist/chunks/{4AKIXLXH.js → KPCY5V35.js} +1 -1
  426. package/build/dist/chunks/L4N2RSK2.js +1 -0
  427. package/build/dist/chunks/{2W46IRX6.js → L5BLHY34.js} +1 -1
  428. package/build/dist/chunks/{ZT47KN7A.js → LSXUAHOE.js} +1 -1
  429. package/build/dist/chunks/{NATG6YA6.js → M37654RL.js} +1 -1
  430. package/build/dist/chunks/MJ6WEWMI.js +3 -0
  431. package/build/dist/chunks/{ACN2BFMA.js → MQK6OP7S.js} +1 -1
  432. package/build/dist/chunks/{XV2HQKND.js → MR5L7V6Z.js} +1 -1
  433. package/build/dist/chunks/MRMR4QHA.js +1 -0
  434. package/build/dist/chunks/{TWSTOFN3.js → N4Q6GN65.js} +1 -1
  435. package/build/dist/chunks/{H4S2ZCWK.js → NAZPDRIF.js} +1 -1
  436. package/build/dist/chunks/{FBSUTF3B.js → NDCLTVIU.js} +1 -1
  437. package/build/dist/chunks/NEEZBJBC.js +1 -0
  438. package/build/dist/chunks/{MRWCFTMS.js → NKX3FE34.js} +1 -1
  439. package/build/dist/chunks/{J3GFCBZZ.js → NKZKKCK2.js} +1 -1
  440. package/build/dist/chunks/{73N3TOJL.js → NWNYJ26T.js} +1 -1
  441. package/build/dist/chunks/{LBEMCOND.js → O7HCEPQY.js} +1 -1
  442. package/build/dist/chunks/{F6WBPPBN.js → OJ4WJUPP.js} +1 -1
  443. package/build/dist/chunks/OJPG45AC.js +1 -0
  444. package/build/dist/chunks/{SKQGLGES.js → OKUO3BVM.js} +1 -1
  445. package/build/dist/chunks/OTXSKFUD.js +1 -0
  446. package/build/dist/chunks/{AAGDMH54.js → P3S4BR5G.js} +1 -1
  447. package/build/dist/chunks/P56RZC2M.js +1 -0
  448. package/build/dist/chunks/{EA6IYKIB.js → P5PYFK7L.js} +1 -1
  449. package/build/dist/chunks/{JST5JGAP.js → P7I62KFR.js} +1 -1
  450. package/build/dist/chunks/{5IIR3GIN.js → PK66GCDT.js} +1 -1
  451. package/build/dist/chunks/PSBQWDYI.js +1 -0
  452. package/build/dist/chunks/{WQ6H62DM.js → PV5FDT6O.js} +1 -1
  453. package/build/dist/chunks/{TQL7UDFL.js → PXT5YTWU.js} +1 -1
  454. package/build/dist/chunks/Q42YI3EP.js +1 -0
  455. package/build/dist/chunks/{SQ5BNSXR.js → QA3UHEO3.js} +1 -1
  456. package/build/dist/chunks/QC3HH5UD.js +3 -0
  457. package/build/dist/chunks/{TWCSCRFS.js → QF52OIBS.js} +1 -1
  458. package/build/dist/chunks/{LQUDJCAR.js → QO3KCJMP.js} +1 -1
  459. package/build/dist/chunks/QQECG3WP.js +1 -0
  460. package/build/dist/chunks/QSHCBASA.js +1 -0
  461. package/build/dist/chunks/QU5XKRGK.js +1 -0
  462. package/build/dist/chunks/{TPDOUL4N.js → QZZ4O34L.js} +1 -1
  463. package/build/dist/chunks/RQ4GHJXE.js +1 -0
  464. package/build/dist/chunks/{ALK6NKFP.js → RUC7KH7A.js} +1 -1
  465. package/build/dist/chunks/RUX3RY7Y.js +1 -0
  466. package/build/dist/chunks/{GIV5JMTE.js → RVDUSNWW.js} +1 -1
  467. package/build/dist/chunks/S47VUTHM.js +1 -0
  468. package/build/dist/chunks/{2LM7U4S7.js → S7IFAQPG.js} +1 -1
  469. package/build/dist/chunks/{XQUPZ3GU.js → SIYUNOLI.js} +1 -1
  470. package/build/dist/chunks/{7XLEYOZH.js → SJJR4ZBZ.js} +1 -1
  471. package/build/dist/chunks/SK2VBNAU.js +1 -0
  472. package/build/dist/chunks/SMYWWIE6.js +1 -0
  473. package/build/dist/chunks/SPJCSEKP.js +1 -0
  474. package/build/dist/chunks/{L3ZM77SJ.js → SSHCD6RZ.js} +1 -1
  475. package/build/dist/chunks/{3NDVXEBR.js → T2WHOZXM.js} +1 -1
  476. package/build/dist/chunks/T3AJSQYT.js +1 -0
  477. package/build/dist/chunks/TAEZTP4L.js +1 -0
  478. package/build/dist/chunks/TEJ7W534.js +1 -0
  479. package/build/dist/chunks/TFDPEAVZ.js +1 -0
  480. package/build/dist/chunks/TM2XCRU7.js +1 -0
  481. package/build/dist/chunks/{XQXLFF7Y.js → TMVO2DAK.js} +1 -1
  482. package/build/dist/chunks/{2UU5TBBB.js → TVWMTMEF.js} +1 -1
  483. package/build/dist/chunks/{AFHHRDPJ.js → TX2EOIRS.js} +1 -1
  484. package/build/dist/chunks/{QRDDKA4I.js → U4JGEMKT.js} +1 -1
  485. package/build/dist/chunks/{PARWLWXW.js → U5PMVP56.js} +1 -1
  486. package/build/dist/chunks/U67J4BCH.js +1 -0
  487. package/build/dist/chunks/{SSTROLQM.js → UHTRW2R6.js} +1 -1
  488. package/build/dist/chunks/{XUYHMOHS.js → UHVSINR5.js} +1 -1
  489. package/build/dist/chunks/{NRBIXV7V.js → UMIZMJWW.js} +1 -1
  490. package/build/dist/chunks/{VXLJRRKV.js → UNJJRQIU.js} +1 -1
  491. package/build/dist/chunks/V74F6IDY.js +1 -0
  492. package/build/dist/chunks/VEQBHI6O.js +1 -0
  493. package/build/dist/chunks/VHV6WQ5F.js +1 -0
  494. package/build/dist/chunks/{DRWWPBOQ.js → VJS4DHQQ.js} +1 -1
  495. package/build/dist/chunks/{R7FXNZRM.js → VOMGT5SG.js} +1 -1
  496. package/build/dist/chunks/{QXNPPCOU.js → VY7XRHZQ.js} +1 -1
  497. package/build/dist/chunks/{TCPPYBGQ.js → VYAJXLND.js} +1 -1
  498. package/build/dist/chunks/{WWFOYZT2.js → VYN2NRAP.js} +1 -1
  499. package/build/dist/chunks/{OVK4EEOD.js → VYYSL557.js} +1 -1
  500. package/build/dist/chunks/W2BYU5JQ.js +2 -0
  501. package/build/dist/chunks/W6BS3T7S.js +1 -0
  502. package/build/dist/chunks/WCNHZYQQ.js +1 -0
  503. package/build/dist/chunks/{BX7XQANB.js → WDK6VOG4.js} +1 -1
  504. package/build/dist/chunks/{QYYFRAWY.js → WIRBCS4W.js} +1 -1
  505. package/build/dist/chunks/{3WBDHUV2.js → WLMWWEP7.js} +1 -1
  506. package/build/dist/chunks/{TNSKEHPC.js → WP6RHXGN.js} +1 -1
  507. package/build/dist/chunks/WTXC3XKW.js +1 -0
  508. package/build/dist/chunks/{R7QPJQP6.js → WU7XIAXB.js} +1 -1
  509. package/build/dist/chunks/{OQVZVR2S.js → WV3A3OUU.js} +1 -1
  510. package/build/dist/chunks/{GCWA4Z3W.js → X2KFXCVD.js} +1 -1
  511. package/build/dist/chunks/X3BYCOWS.js +1 -0
  512. package/build/dist/chunks/{L7YBCMZU.js → X3PQMS4N.js} +1 -1
  513. package/build/dist/chunks/{WVXW6VL3.js → XBE3B6Y2.js} +1 -1
  514. package/build/dist/chunks/XLOYBLFI.js +1 -0
  515. package/build/dist/chunks/XR7VK24E.js +1 -0
  516. package/build/dist/chunks/XSD5NL7J.js +1 -0
  517. package/build/dist/chunks/{NU4K3TEZ.js → XSRIJUFU.js} +1 -1
  518. package/build/dist/chunks/{WQQJ7UPJ.js → Y25EXZCO.js} +1 -1
  519. package/build/dist/chunks/{2FSX7MMR.js → YCZPSMZ5.js} +1 -1
  520. package/build/dist/chunks/YDNTY67T.js +1 -0
  521. package/build/dist/chunks/YN56C7PN.js +1 -0
  522. package/build/dist/chunks/YWRDZQI6.js +1 -0
  523. package/build/dist/chunks/{SJPM5ST4.js → YXTSWRV5.js} +1 -1
  524. package/build/dist/chunks/Z43BTOTE.js +1 -0
  525. package/build/dist/chunks/{PWBL4WKB.js → Z4FZVJ5Z.js} +1 -1
  526. package/build/dist/chunks/ZMFRMWHR.js +1 -0
  527. package/build/dist/chunks/{KSZMMNXK.js → ZQAFFWDK.js} +1 -1
  528. package/build/dist/chunks/{LMVB3B6T.js → ZSN4IRI5.js} +1 -1
  529. package/build/dist/chunks/{CQCVFRQ5.js → ZV5HIQXC.js} +1 -1
  530. package/package.json +2 -2
  531. package/build/dist/chunks/2MSQ6JII.js +0 -1
  532. package/build/dist/chunks/3SC5UI35.js +0 -1
  533. package/build/dist/chunks/4GHVIBL5.js +0 -1
  534. package/build/dist/chunks/4X2JOQ2L.js +0 -1
  535. package/build/dist/chunks/5VHH5PW3.js +0 -1
  536. package/build/dist/chunks/5YS5V2LK.js +0 -1
  537. package/build/dist/chunks/6UPPUHCL.js +0 -1
  538. package/build/dist/chunks/7YU6DELJ.js +0 -1
  539. package/build/dist/chunks/AXYOJBX6.js +0 -1
  540. package/build/dist/chunks/CEIPDEXZ.js +0 -1
  541. package/build/dist/chunks/CUNQ5RG5.js +0 -1
  542. package/build/dist/chunks/EG6M6SSO.js +0 -1
  543. package/build/dist/chunks/EGUMOD3A.js +0 -1
  544. package/build/dist/chunks/EXRKBBX2.js +0 -1
  545. package/build/dist/chunks/G3MHDTGT.js +0 -1
  546. package/build/dist/chunks/G6HCV67X.js +0 -1
  547. package/build/dist/chunks/GJY3P6OG.js +0 -1
  548. package/build/dist/chunks/HIMVOTIU.js +0 -1
  549. package/build/dist/chunks/IBXYIN7Q.js +0 -1
  550. package/build/dist/chunks/IUE6RASI.js +0 -1
  551. package/build/dist/chunks/JPOYTTTW.js +0 -1
  552. package/build/dist/chunks/JWCOXLYA.js +0 -1
  553. package/build/dist/chunks/KHJFXJBU.js +0 -1
  554. package/build/dist/chunks/LLM5WDM3.js +0 -1
  555. package/build/dist/chunks/LQGPMOD2.js +0 -1
  556. package/build/dist/chunks/MYBDO5SA.js +0 -1
  557. package/build/dist/chunks/NAYRD43N.js +0 -1
  558. package/build/dist/chunks/NMYGNJIJ.js +0 -1
  559. package/build/dist/chunks/NSOEDRBU.js +0 -3
  560. package/build/dist/chunks/PZHR4ITH.js +0 -1
  561. package/build/dist/chunks/R7SXC74O.js +0 -1
  562. package/build/dist/chunks/RETS2ZEK.js +0 -1
  563. package/build/dist/chunks/SJPYXNOK.js +0 -1
  564. package/build/dist/chunks/SQZRVIVF.js +0 -1
  565. package/build/dist/chunks/SXAIXD56.js +0 -1
  566. package/build/dist/chunks/SXX3VTBP.js +0 -1
  567. package/build/dist/chunks/TMGWXDCZ.js +0 -1
  568. package/build/dist/chunks/TNLHMDWL.js +0 -1
  569. package/build/dist/chunks/UFS2RVEZ.js +0 -1
  570. package/build/dist/chunks/USSOVTD5.js +0 -1
  571. package/build/dist/chunks/UWOFA6GV.js +0 -1
  572. package/build/dist/chunks/V2OOOV6B.js +0 -1
  573. package/build/dist/chunks/XVFLT275.js +0 -1
  574. package/build/dist/chunks/YHB55C5T.js +0 -1
  575. package/build/dist/chunks/YOENHHKI.js +0 -1
  576. package/build/dist/chunks/Z7RL4NGX.js +0 -1
@@ -1,3 +0,0 @@
1
- import{a as ke,b as Te}from"./3EFV4FQF.js";import{b as be,o as we}from"./5O5ZE3ZV.js";import{a as ye}from"./CY75R4FK.js";import{c as ie}from"./MYBDO5SA.js";import{a as U}from"./UWOFA6GV.js";import{b as re,c as N,d as fe,g as p,i as he,n as ge}from"./73N3TOJL.js";import{a as l,i as oe,l as d}from"./G6HCV67X.js";import{a as i}from"./5YS5V2LK.js";import{a as I}from"./JXOEJPJ4.js";import{decodeEventLog as qe,encodeAbiParameters as Oe,encodeFunctionData as M,erc20Abi as j,getAddress as Se,keccak256 as Ue,parseAbi as D,parseAbiItem as Me,toHex as He,zeroAddress as F}from"viem";var ce=oe[l].pons.launchAndBuyRouter.address,ve=oe[l].ponsTrade.state_view.address,J={address:F,chainId:l,symbol:"ETH",decimals:18},f=D(["function getLaunchedToken(address) view returns ((address token,address curve,address deployer,address creatorFeeRecipient,address pairToken,uint256 graduationThreshold,uint24 poolFee,int24 tickSpacing,uint16 creatorTaxBps,bool buybackEnabled,uint8 phase,uint256 sweptQuote,uint256 sweptTokens,uint256 sweptAt,bool exists))","function previewLaunchEconomics(uint256,address) view returns (bytes32)","function launchFee() view returns (uint256)","function canLaunch(address) view returns (bool)","function launchConfigCount() view returns (uint256)","function approvedPairTokens(address) view returns (bool)","function pairTokenEconomics(address) view returns (uint256 phantomQuote,uint256 graduationThreshold,uint8 decimals)","function transferCreatorFeeRecipient(address token,address newRecipient)","function setBuybackEnabled(address token,bool enabled)","function getLaunchConfig(uint256) view returns ((uint256 supply,uint256 curveFeeBps,uint256 phantomQuote,uint256 graduationThreshold,uint24 poolFee,int24 tickSpacing,bool enabled))","function maxCreatorTaxBps() view returns (uint256)","function getLaunchFeePolicy(address) view returns ((address,uint16,uint16,uint16,uint16))","function memeHook() view returns (address)","function createGraduatedPool(address)"]),Q=D(["function factory() view returns (address)","function feeEscrow() view returns (address)","function getReserves() view returns (uint256,uint256)","function realQuoteReserve() view returns (uint256)","function feeBps() view returns (uint256)"]),je=D(["function launchFactory() view returns (address)"]),De=D(["function currentFeePolicy() view returns ((address,uint16,uint16,uint16,uint16))"]),Pe=D(["function getSlot0(bytes32) view returns (uint160,int24,uint24,uint24)","function getLiquidity(bytes32) view returns (uint128)"]),ae=D(["function launchToken((string,string,string,string,(string,string,string,string,string),address,uint16,bool,bytes32,bytes32),uint256,address) payable","function launchToken((string,string,string,string,(string,string,string,string,string),address,uint16,bool,bytes32,bytes32),uint256,address,address[]) payable","function launchAndBuy((string,string,string,string,(string,string,string,string,string),address,uint16,bool,bytes32,bytes32),uint256,address,uint256,uint256,address,address[]) payable"]),Ie=Me("event TokenLaunched(address indexed token,address indexed curve,address indexed deployer,address pairToken,uint256 launchConfigId,uint256 graduationThreshold)"),We=["curve","pending pool creation","graduated","rescued"],Ge=10000n,Ce=2000n;function A(t){return he(t,"Provide a token or wallet address.",fe)}function H(t){return ge(t,"Amount exceeds the uint256 range.",{notString:"Amounts must be integer strings in base units."})}function Ae(t,e){if(typeof t!="string"||!t.trim())throw new i(`Provide ${e}.`);return t}function R(t,e){return{token:t,amount:e.toString()}}function Ne(t,e,n,r,o){let a=t*BigInt(n)/10000n,s=r?(t-a)*BigInt(o)/10000n:0n;return{baseBps:t.toString(),creatorTaxBps:e.toString(),totalBps:(t+BigInt(e)).toString(),protocolBps:a.toString(),creatorBps:(t-a-s+BigInt(e)).toString(),buybackBps:s.toString(),buybackEnabled:r}}async function V(t,e,n){if(p(e,F))return J;let r=t.clientFor(l),[o,a]=await Promise.all([r.readContract({address:e,abi:j,functionName:"symbol",blockNumber:n}),r.readContract({address:e,abi:j,functionName:"decimals",blockNumber:n})]);return{address:Se(e),chainId:l,symbol:I(o),decimals:a}}async function X(t,e,n){let r=t.clientFor(l),[o,a]=await Promise.all([r.readContract({address:e,abi:je,functionName:"launchFactory",blockNumber:n}),r.readContract({address:d,abi:f,functionName:"getLaunchedToken",args:[e],blockNumber:n})]);if(!p(o,d)||!a.exists||!p(a.token,e))throw new i("This token is not a launch from the supported Pons factory.");if(a.phase>3)throw new i("Pons returned an unknown launch phase.");return a}async function ue(t,e,n){let r=t.clientFor(l),o=await X(t,e,n),[a,s,u,c,h,g,y]=await Promise.all([V(t,e,n),V(t,o.pairToken,n),r.readContract({address:e,abi:j,functionName:"totalSupply",blockNumber:n}),r.readContract({address:o.curve,abi:Q,functionName:"factory",blockNumber:n}),r.readContract({address:o.curve,abi:Q,functionName:"feeEscrow",blockNumber:n}),r.readContract({address:d,abi:f,functionName:"memeHook",blockNumber:n}),r.readContract({address:d,abi:f,functionName:"getLaunchFeePolicy",args:[e],blockNumber:n})]);if(!p(c,d))throw new i("The Pons curve does not belong to the supported factory.");let m=BigInt(y[3]),x=o.sweptQuote,b=null,T=null,_=null;if(o.phase===0){let[v,S,w]=await Promise.all([r.readContract({address:o.curve,abi:Q,functionName:"getReserves",blockNumber:n}),r.readContract({address:o.curve,abi:Q,functionName:"realQuoteReserve",blockNumber:n}),r.readContract({address:o.curve,abi:Q,functionName:"feeBps",blockNumber:n})]);if(x=S,m=w,o.graduationThreshold<=0n||v[1]<=0n)throw new i("Pons returned unavailable curve reserves or threshold.");b=S*1000000n/o.graduationThreshold,b>1000000n&&(b=1000000n),T=R(s,v[0]*10n**BigInt(a.decimals)/v[1])}else if(o.phase===2){let v=[e,o.pairToken].sort(($,C)=>BigInt($)<BigInt(C)?-1:1),S=Ue(Oe([{type:"address"},{type:"address"},{type:"uint24"},{type:"int24"},{type:"address"}],[v[0],v[1],o.poolFee,o.tickSpacing,g])),[w,q]=await Promise.all([r.readContract({address:ve,abi:Pe,functionName:"getSlot0",args:[S],blockNumber:n}),r.readContract({address:ve,abi:Pe,functionName:"getLiquidity",args:[S],blockNumber:n})]);if(w[0]===0n)throw new i("The graduated Pons pool price is unavailable.");let E=w[0]**2n,O=10n**BigInt(a.decimals);T=R(s,p(v[0],e)?E*O/(1n<<192n):(1n<<192n)*O/E),_={id:S,sqrtPriceX96:w[0].toString(),tick:w[1],protocolFee:w[2],lpFee:w[3],liquidity:q.toString()},b=1000000n}else o.phase===1&&(b=1000000n);return{token:a,pairToken:s,blockNumber:n.toString(),factory:d,curve:o.curve,hook:g,escrow:h,creator:o.deployer,creatorFeeRecipient:o.creatorFeeRecipient,phase:o.phase,phaseName:We[o.phase],tradable:o.phase===0||o.phase===2,graduationThreshold:R(s,o.graduationThreshold),raised:R(s,x),sweptTokens:R(a,o.sweptTokens),sweptAt:o.sweptAt.toString(),progressPpm:b?.toString()??null,totalSupply:R(a,u),fees:Ne(m,o.creatorTaxBps,y[1],o.buybackEnabled,y[2]),pool:_,spot:T,priceKind:"Marginal spot per whole token; not an execution quote or time average."}}async function Qe(t,e,n,r){let o=t.clientFor(l),[a,s]=await Promise.all([o.readContract({address:e.token.address,abi:j,functionName:"balanceOf",args:[n],blockNumber:r}),p(e.pairToken.address,F)?o.getBalance({address:n,blockNumber:r}):o.readContract({address:e.pairToken.address,abi:j,functionName:"balanceOf",args:[n],blockNumber:r})]),u;try{let c=await ke(t,e.token.address,n,!1,r),h=c.credited.some(g=>BigInt(g.amount)>0n)||BigInt(c.buybackVest.releasable.amount)>0n;u={isRecipient:c.isRecipient,recipient:c.recipient,escrow:c.escrow,credited:c.credited,pendingBeforeSweep:c.pendingBeforeSweep,operatorWait:c.operatorWait??null,buybackVest:c.buybackVest,nextStep:[c.isRecipient&&(h||c.txs.length||c.pendingBeforeSweep.length&&!c.operatorWait)?"pons_claim builds the sweep, vest release and escrow claims for this wallet.":"",!c.isRecipient&&h?"Escrow credits belong to this holder; only the current creator fee recipient can sweep or release this coin.":"",c.operatorWait?`${Te(c.operatorWait)} Oak cannot run it; credited amounts stay claimable.`:""].filter(Boolean).join(" ")||"Nothing to sweep or claim for this holder."}}catch(c){u={unavailable:t.plainError(c)}}return{holder:n,holding:R(e.token,a),pairBalance:R(e.pairToken,s),creatorFees:u,note:"Sell the actual holding shown here, not a quoted output. Balances are read at the status block."}}async function Ve(t,e,n){try{let r=await t.clientFor(l).getBlockNumber({cacheTime:0}),o=await ue(t,A(e),r);return n===void 0?o:{...o,account:await Qe(t,o,A(n),r)}}catch(r){throw new i(t.plainError(r))}}var xe="https://ponsfamily.com/api/launches",ze=t=>{let e=t;return!!e&&Array.isArray(e.items)&&e.items.length<=100&&(e.nextCursor===null||e.nextCursor===void 0||typeof e.nextCursor=="string")&&e.items.every(n=>!!n&&typeof n.address=="string"&&re.test(n.address)&&typeof n.factory=="string"&&re.test(n.factory))};async function Je(t,e){let n=e.limit??20;if(typeof n!="number"||!Number.isInteger(n)||n<1||n>40)throw new i("Choose a search or listing limit from 1 to 40.");let r=new URL(xe);if(e.query!==void 0){if(typeof e.query!="string"||!e.query.trim()||e.query.length>100)throw new i("Provide a name, symbol or address query of 1 to 100 characters.");r.searchParams.set("q",e.query.trim())}else r.searchParams.set("sort","newest");if(e.cursor!==void 0){if(e.query!==void 0)throw new i("Search returns one page; use cursor only for the newest-first listing.");if(typeof e.cursor!="string"||!/^[0-9]{1,20}(\.0x[0-9a-fA-F]{40})?$/.test(e.cursor))throw new i("Use the nextCursor returned by the previous pons_browse page.");r.searchParams.set("cursor",e.cursor)}r.searchParams.set("limit",String(n));let o=await ie(t.http,r,{method:"GET",redirect:"error"},ze);if(o.nextCursor&&!/^[0-9]{1,20}(\.0x[0-9a-fA-F]{40})?$/.test(o.nextCursor))throw new i("Pons returned a malformed listing cursor.");let a=o.items.filter(h=>p(h.factory,d)),s=[...new Map(a.map(h=>[h.address.toLowerCase(),Se(h.address)])).values()].slice(0,n),u=await t.clientFor(l).getBlockNumber({cacheTime:0});return{items:await Promise.all(s.map(h=>ue(t,h,u))),statusBlock:u.toString(),source:xe,nextCursor:e.query===void 0?o.nextCursor??null:null,excludedOtherFactories:o.items.length-a.length,coverage:e.query!==void 0?"Pons index search over every launch (one page, at most 40). Results are discovery only; each one was re-read on chain from the pinned factory.":"Newest-first page of Pons's complete launch index; pass nextCursor to continue until it is null. Each item was re-read on chain; launches from other Pons factories are dropped."}}async function Ke(t,e={}){if(e.query!==void 0||e.cursor!==void 0||e.complete===!0)try{if(e.fromBlock!==void 0||e.toBlock!==void 0)throw new i("Use block bounds for an on-chain window, or query/cursor for the Pons index, not both.");return await Je(t,e)}catch(n){throw new i(t.plainError(n))}return Re(t,e)}async function Re(t,e={}){try{let n=t.clientFor(l),r=await n.getBlockNumber({cacheTime:0}),o=e.toBlock===void 0?r:H(e.toBlock),a=e.fromBlock===void 0?o>=Ce?o-Ce+1n:0n:H(e.fromBlock),s=e.limit??20;if(typeof s!="number"||!Number.isInteger(s)||s<1||s>100)throw new i("Choose a launch limit from 1 to 100.");if(a>o||o>r||o-a+1n>Ge)throw new i("Choose an ordered range of at most 10000 mined blocks.");let u=await n.getLogs({address:d,event:Ie,fromBlock:a,toBlock:o,strict:!0}),c=new Map;for(let y of u.filter(m=>p(m.address,d)&&!m.removed&&m.blockNumber!==null&&m.blockNumber>=a&&m.blockNumber<=o).sort((m,x)=>m.blockNumber===x.blockNumber?(x.logIndex??0)-(m.logIndex??0):m.blockNumber>x.blockNumber?-1:1)){let m=A(y.args.token);c.set(m.toLowerCase(),m)}let h=[...c.values()];return{items:await Promise.all(h.slice(0,s).map(y=>ue(t,y,r))),fromBlock:a.toString(),toBlock:o.toString(),statusBlock:r.toString(),truncated:h.length>s,coverage:"Only launches in the requested block range; this is not a complete launch history."}}catch(n){throw new i(t.plainError(n))}}async function K(t,e,n,r){let o=(Array.isArray(e)?e:[e]).map(t.unsignedTx),a=await t.preview(o,n),s=a.changes.map(u=>{let c=u.amount.startsWith("-");return`${c?"-":""}${t.formatAmount(c?u.amount.slice(1):u.amount,u.token.decimals)} ${u.token.symbol} (${u.token.chainId}:${u.token.address})`});return{txs:o,preview:a,summary:`${r} ${a.summary}${s.length?` Changes: ${s.join(", ")}.`:""}`}}var z=["twitter","telegram","discord","website","farcaster"],Be=5242880,$e="https://ponsfamily.com/api/ipfs/image";function se(t,e){if(t==="")return"";if(typeof t!="string"||t.length>2048)throw new i(`Provide a public HTTPS or IPFS ${e}.`);try{let n=new URL(t);if(!["https:","ipfs:"].includes(n.protocol)||!n.hostname||n.username||n.password)throw new Error}catch{throw new i(`Provide a public HTTPS or IPFS ${e}.`)}return t}function Xe(t){if(t===void 0)return;if(!t||typeof t!="object"||Array.isArray(t))throw new i("Provide image mimeType and base64.");let e=t,n={"image/png":"png","image/jpeg":"jpg","image/webp":"webp"};if(Object.keys(e).some(s=>!["mimeType","base64"].includes(s))||typeof e.mimeType!="string"||!n[e.mimeType])throw new i("Use a PNG, JPEG, or WebP image.");if(typeof e.base64!="string"||!e.base64.length||e.base64.length>4*Math.ceil(Be/3)||e.base64.length%4!==0||!/^[A-Za-z0-9+/]*={0,2}$/.test(e.base64))throw new i("Provide a base64 image of 1 to 5242880 bytes.");let r=atob(e.base64);if(!r.length||r.length>Be||btoa(r)!==e.base64)throw new i("Provide a base64 image of 1 to 5242880 bytes.");let o=Uint8Array.from(r,s=>s.charCodeAt(0));if(!(e.mimeType==="image/png"?r.startsWith(`\x89PNG\r
2
- 
3
- `):e.mimeType==="image/jpeg"?o[0]===255&&o[1]===216&&o[2]===255:r.startsWith("RIFF")&&r.slice(8,12)==="WEBP"))throw new i("Image bytes do not match the declared PNG, JPEG, or WebP type.");return{bytes:o,mimeType:e.mimeType,extension:n[e.mimeType]}}async function Ye(t,e,n){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new i("Provide a mined Pons launch transaction hash.");let o=await t.clientFor(l).getTransactionReceipt({hash:e});if(o.status!=="success"||!p(o.from,n))throw new i("The Pons launch must be a successful transaction from this wallet.");let a=o.logs.flatMap(c=>{if(!p(c.address,d))return[];try{return[qe({abi:[Ie],data:c.data,topics:c.topics,strict:!0}).args]}catch{return[]}}).filter(c=>p(c.deployer,n));if(a.length!==1)throw new i("The receipt does not contain exactly one Pons launch for this wallet.");let s=a[0].token,u=await X(t,s,o.blockNumber);return{transactionHash:e,token:await V(t,s,o.blockNumber),curve:u.curve,creator:u.deployer,creatorFeeRecipient:u.creatorFeeRecipient,chainId:l,summary:`Pons launch mined: ${s}. Creator fee recipient ${u.creatorFeeRecipient}.`}}async function Ze(t,e,n){let r=Ae(e.name,"a coin name"),o=Ae(e.symbol,"a coin symbol");if(e.creatorFeeRecipient===void 0)throw new i("Provide an explicit nonzero creatorFeeRecipient; it is never defaulted to the agent wallet.");let a=A(e.creatorFeeRecipient);if(p(a,F))throw new i("Provide a nonzero creator fee recipient.");if(!p(a,n))throw new i("Pons creator fee recipient must be the signing wallet.");let s=A(e.pairToken??F),u=H(e.launchConfigId??"0"),c=H(e.initialBuy??"0"),h=A(e.buyRecipient??n);if(p(h,F))throw new i("Provide a nonzero initial buy recipient.");if(c===0n&&e.buyRecipient!==void 0)throw new i("A buy recipient requires an initial buy.");let g=H(e.minTokensOut??"0");if(c>0n&&e.minTokensOut!==void 0&&g<=1n)throw new i("Initial buy minimum must exceed one token base unit.");if(c>0n&&!p(h,n)&&e.minTokensOut===void 0)throw new i("Provide minTokensOut for an initial buy sent to another wallet.");if(c===0n&&g!==0n)throw new i("A launch without an initial buy must have a zero token minimum.");let y=e.creatorTaxBps??100;if(typeof y!="number"||!Number.isInteger(y)||y<0||y>65535)throw new i("Creator tax must be an integer number of basis points.");let m=e.buybackEnabled??!1;if(typeof m!="boolean")throw new i("Buyback enabled must be true or false.");let x=e.metadata??["",""],b=e.links??["","","","",""];if(!Array.isArray(x)||x.length!==2||!x.every(k=>typeof k=="string")||!Array.isArray(b)||b.length!==5||!b.every(k=>typeof k=="string"))throw new i("Provide two metadata strings and five link strings in ABI order.");if(e.metadata!==void 0&&(e.logo!==void 0||e.description!==void 0||e.image!==void 0))throw new i("Use named logo, description and image inputs or legacy metadata, not both.");if(e.links!==void 0&&e.socials!==void 0)throw new i("Use named socials or legacy links, not both.");let T=se(e.logo??x[0],"coin image URI"),_=e.description??x[1];if(typeof _!="string")throw new i("Provide a coin description string.");let v=e.socials;if(v!==void 0&&(!v||typeof v!="object"||Array.isArray(v)||Object.keys(v).some(k=>!z.includes(k))))throw new i("Provide twitter, telegram, discord, website and farcaster social links.");let S=z.map((k,P)=>se(v===void 0?b[P]:v[k]??"",`${k} link`)),w=Xe(e.image);if(w&&T)throw new i("Provide an image upload or an existing logo URI, not both.");let q=e.snipeTaxExemptions??[];if(!Array.isArray(q)||q.length>31)throw new i("Provide at most 31 snipe tax exemption addresses.");let E=q.map(A),O=e.salt??He(crypto.getRandomValues(new Uint8Array(32)));if(typeof O!="string"||!/^0x[0-9a-fA-F]{64}$/.test(O))throw new i("Salt must be 32 hex-encoded bytes.");let $=t.clientFor(l),C=await $.getBlockNumber({cacheTime:0}),[de,Ee]=await Promise.all([$.readContract({address:d,abi:f,functionName:"canLaunch",args:[n],blockNumber:C}),$.readContract({address:d,abi:f,functionName:"launchConfigCount",blockNumber:C})]);if(!de)throw new i("This wallet cannot launch on Pons. Ask Pons for launch access and retry when canLaunch is true.");if(u>=Ee)throw new i("Choose an existing Pons launchConfigId using pons_launch_options.");let[Y,W,Le,_e]=await Promise.all([$.readContract({address:d,abi:f,functionName:"launchFee",blockNumber:C}),$.readContract({address:d,abi:f,functionName:"getLaunchConfig",args:[u],blockNumber:C}),$.readContract({address:d,abi:f,functionName:"maxCreatorTaxBps",blockNumber:C}),$.readContract({address:d,abi:f,functionName:"memeHook",blockNumber:C})]);if(!W.enabled)throw new i("This Pons launch configuration is disabled. Choose an enabled launchConfigId.");let L=J,le=W.phantomQuote,pe=W.graduationThreshold;if(!p(s,F)){let[k,P]=await Promise.all([$.readContract({address:d,abi:f,functionName:"approvedPairTokens",args:[s],blockNumber:C}),$.readContract({address:d,abi:f,functionName:"pairTokenEconomics",args:[s],blockNumber:C})]);if(!k||P[0]<=0n||P[1]<=0n)throw new i("This pair token is not approved with usable Pons economics. Choose a supported pair.");if(L=await V(t,s,C),P[2]!==L.decimals)throw new i("Pair token decimals disagree with Pons. Ask Pons to refresh pair economics.");[le,pe]=P}if(BigInt(y)>Le)throw new i("Creator tax exceeds the current Pons maximum.");let[Z,ee]=await Promise.all([$.readContract({address:d,abi:f,functionName:"previewLaunchEconomics",args:[u,s],blockNumber:C}),$.readContract({address:_e,abi:De,functionName:"currentFeePolicy",blockNumber:C})]);if(e.expectedEconomics!==void 0&&e.expectedEconomics!==Z)throw new i("Pons launch economics changed. Refresh the launch preview.");let G=Ne(W.curveFeeBps,y,ee[1],m,ee[2]),ne="";if(w){let k=new FormData;k.append("image",new Blob([w.bytes],{type:w.mimeType}),`coin.${w.extension}`);let P=await ie(t.http,$e,{method:"POST",body:k,redirect:"error"},B=>!!B&&typeof B=="object"&&typeof B.uri=="string");if(T=se(P.uri,"uploaded coin image URI"),!T)throw new i("Pons returned an empty image URI. Retry with a public image URI.");ne=`Image (${w.bytes.length} bytes, ${w.mimeType}) uploaded via multipart POST to ${$e}; URI ${I(T)}. This off-chain upload persists even if launch is cancelled or fails; Pons retention/deletion is unknown.`}let te=k=>{let P=[r,o,T,_,S,a,y,m,Z,O],B={to:c===0n?d:ce,chainId:l,value:(Y+(p(s,F)?c:0n)).toString(),data:c===0n?E.length?M({abi:ae,functionName:"launchToken",args:[P,u,s,E]}):M({abi:ae,functionName:"launchToken",args:[P,u,s]}):M({abi:ae,functionName:"launchAndBuy",args:[P,u,s,c,k,h,E]}),description:`Launch ${I(r)} through the Pons ${c===0n?"factory":"router"} from ${n}; creator fees to ${a}. ${ne}`.trim()};return c>0n&&!p(s,F)?[t.approval(s,ce,c.toString(),l),B]:[B]};if(c>0n&&e.minTokensOut===void 0){let P=(await t.preview(te(0n).map(t.unsignedTx),n)).changes.filter(B=>B.token.chainId===l&&!p(B.token.address,F)&&!p(B.token.address,ye)&&!p(B.token.address,s)&&B.token.decimals===18&&/^\d+$/.test(B.amount)&&BigInt(B.amount)>0n);if(P.length!==1)throw new i("Pons launch preview did not identify a unique initial buy token output.");if(g=BigInt(we(P[0].amount,be)),g<=1n)throw new i("Initial buy minimum must exceed one token base unit.")}let me=await K(t,te(g),n,`Unsigned Pons launch from ${n}: ${I(r)} (${I(o)}), image ${T?I(T):"none"}, description ${I(_)}, links ${JSON.stringify(Object.fromEntries(z.map((k,P)=>[k,I(S[P])])))}. canLaunch=true at block ${C}; config ${u}, supply ${W.supply}, phantom quote ${le}, graduation threshold ${pe} pair base units. Pair ${L.symbol} (${l}:${L.address}, ${L.decimals} decimals). Initial buy ${t.formatAmount(c.toString(),L.decimals)} ${L.symbol} to ${h}; minimum ${g} token base units (18 decimals). Launch fee ${t.formatAmount(Y.toString(),18)} ETH plus gas; exact transaction value ${te(g).at(-1).value} wei. Curve fees ${G.totalBps} bps total, ${G.protocolBps} bps protocol, ${G.creatorBps} bps creator, ${G.buybackBps} bps buyback; creator tax ${y} bps, buybacks ${m?"on":"off"}, graduated hook fee ${ee[3]} bps plus creator tax. Creator fee recipient ${a}. Extra opening-tax exemptions ${JSON.stringify(E)}. Name, metadata, pair, tax and launch economics are fixed after launch. ${ne}`);return{...me,creatorFeeWarning:void 0,preview:{...me.preview,warnings:[]},canLaunch:de,blockNumber:C.toString(),launchConfigId:u.toString(),pairToken:L,salt:O,logo:T&&I(T),economics:Z,launchFee:R(J,Y),initialBuy:R(L,c),minimum:{amount:g.toString(),decimals:18,token:{chainId:l,address:null,name:I(r),symbol:I(o)},addressStatus:"Read the mined token address with pons_launch transactionHash; the local bridge does this automatically."},fees:G}}async function en(t,e,n){let r=t.clientFor(l),o=await r.getBlockNumber({cacheTime:0}),a=A(e.pairToken??F),[s,u,c,h]=await Promise.all([r.readContract({address:d,abi:f,functionName:"canLaunch",args:[n],blockNumber:o}),r.readContract({address:d,abi:f,functionName:"launchConfigCount",blockNumber:o}),r.readContract({address:d,abi:f,functionName:"launchFee",blockNumber:o}),r.readContract({address:d,abi:f,functionName:"maxCreatorTaxBps",blockNumber:o})]),g=H(e.offset??"0"),y=await Promise.all(Array.from({length:Number(u>g?u-g>100n?100n:u-g:0n)},async(_,v)=>{let S=g+BigInt(v),w=await r.readContract({address:d,abi:f,functionName:"getLaunchConfig",args:[S],blockNumber:o});return{id:S.toString(),...Object.fromEntries(Object.entries(w).map(([q,E])=>[q,typeof E=="bigint"?E.toString():E]))}})),m=p(a,F),[x,b,T]=await Promise.all([m?!0:r.readContract({address:d,abi:f,functionName:"approvedPairTokens",args:[a],blockNumber:o}),m?void 0:r.readContract({address:d,abi:f,functionName:"pairTokenEconomics",args:[a],blockNumber:o}),V(t,a,o)]);return{chainId:l,factory:d,router:ce,blockNumber:o.toString(),canLaunch:s,launchFee:R(J,c),maxCreatorTaxBps:h.toString(),configs:y,configCount:u.toString(),nextOffset:g+BigInt(y.length)<u?(g+BigInt(y.length)).toString():null,pairToken:T,pairApproved:x&&(!b||b[0]>0n&&b[1]>0n&&b[2]===T.decimals),pairEconomics:b?{phantomQuote:b[0].toString(),graduationThreshold:b[1].toString(),decimals:b[2]}:null,pairDiscovery:"Native ETH or any approved ERC-20 address with usable pairTokenEconomics; query each candidate address. The factory has no pair enumeration read."}}async function Fe(t,e,n,r){let o=A(e.token),a=await X(t,o,await t.clientFor(l).getBlockNumber({cacheTime:0}));if(!p(a.creatorFeeRecipient,n))throw new i(`Only the current creator fee recipient ${a.creatorFeeRecipient} can change this setting. Use that wallet.`);if(r){let s=A(e.creatorFeeRecipient);if(p(s,F))throw new i("Provide a nonzero creator fee recipient.");return K(t,{to:d,chainId:l,value:"0",data:M({abi:f,functionName:"transferCreatorFeeRecipient",args:[o,s]}),description:`Transfer future creator fees and the buyback vest beneficiary for ${o} to ${s}.`},n,`Unsigned Pons fee recipient transfer to ${s}; previously credited fees stay with ${n}. This wallet loses future fee controls. Cost: gas only.`)}if(typeof e.enabled!="boolean")throw new i("Buyback enabled must be true or false.");return K(t,{to:d,chainId:l,value:"0",data:M({abi:f,functionName:"setBuybackEnabled",args:[o,e.enabled]}),description:`Turn Pons buybacks ${e.enabled?"on":"off"} for ${o}.`},n,`Unsigned Pons buyback change: ${e.enabled?"on; funded from the creator fee share, tokens vest over five years":"off; existing vest stays locked on its schedule"}. Cost: gas only.`)}var nn=t=>{function e(n,r,o,a){return{name:n,inputSchema:{type:"object",properties:r,required:o,additionalProperties:!1,...n==="pons_launch"?{anyOf:[{required:["transactionHash"]},{required:["name","symbol","creatorFeeRecipient"]}]}:{}},execute:async(s,u)=>{try{A(u);for(let c of Object.keys(s))if(!(c in r))throw new i(`Unknown ${n} input: ${c}.`);return await a(s,u)}catch(c){throw new i(t.plainError(c))}}}}return{tools:[e("pons_browse",{fromBlock:U(),toBlock:U(),limit:{type:"integer",minimum:1,maximum:100},query:{type:"string",minLength:1,maxLength:100,description:"Name, symbol or address search over every Pons launch (Pons index; results re-read on chain)."},cursor:{type:"string",maxLength:64,description:"nextCursor from a previous newest-first page."},complete:{type:"boolean",description:"List every launch newest first through the Pons index, paginated with cursor."}},[],n=>Ke(t,n)),e("pons_status",{token:N,holder:N},["token"],(n,r)=>Ve(t,A(n.token),A(n.holder??r))),e("pons_launch_options",{pairToken:N,offset:U()},[],(n,r)=>en(t,n,r)),e("pons_transfer_creator_fee_recipient",{token:N,creatorFeeRecipient:N},["token","creatorFeeRecipient"],(n,r)=>Fe(t,n,r,!0)),e("pons_set_buyback",{token:N,enabled:{type:"boolean"}},["token","enabled"],(n,r)=>Fe(t,n,r,!1)),e("pons_launch",{name:{type:"string",minLength:1},symbol:{type:"string",minLength:1},creatorFeeRecipient:N,pairToken:N,launchConfigId:U(),buyRecipient:N,logo:{type:"string"},description:{type:"string"},socials:{type:"object",properties:Object.fromEntries(z.map(n=>[n,{type:"string"}])),additionalProperties:!1},image:{type:"object",properties:{mimeType:{type:"string",enum:["image/png","image/jpeg","image/webp"]},base64:{type:"string",minLength:1,maxLength:6990508}},required:["mimeType","base64"],additionalProperties:!1},snipeTaxExemptions:{type:"array",items:N,maxItems:31},transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},initialBuy:U(),minTokensOut:U(),creatorTaxBps:{type:"integer",minimum:0,maximum:65535},buybackEnabled:{type:"boolean"},expectedEconomics:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},salt:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},metadata:{type:"array",items:{type:"string"},minItems:2,maxItems:2},links:{type:"array",items:{type:"string"},minItems:5,maxItems:5}},[],(n,r)=>n.transactionHash===void 0?Ze(t,n,r):Ye(t,n.transactionHash,r)),e("pons_graduate",{token:N},["token"],async(n,r)=>{let o=A(n.token);if((await X(t,o,await t.clientFor(l).getBlockNumber({cacheTime:0}))).phase!==1)throw new i("Graduation requires a launch pending pool creation (phase 1).");return K(t,{to:d,chainId:l,value:"0",data:M({abi:f,functionName:"createGraduatedPool",args:[o]}),description:`Create the graduated Pons pool for ${o}.`},r,"Unsigned permissionless graduation retry; recheck status after the transaction is mined.")})],positions:async n=>{try{A(n);let r=await Re(t,{limit:100}),o=r.items.filter(a=>p(a.creator,n)||p(a.creatorFeeRecipient,n));return await Promise.all(o.map(async a=>{let s=await t.clientFor(l).readContract({address:a.token.address,abi:j,functionName:"balanceOf",args:[n],blockNumber:BigInt(a.blockNumber)});return{module:"pons",id:`${l}:${a.token.address}`,chainId:l,assets:[R(a.token,s)],description:`Pons ${a.phaseName}; creator fee recipient ${a.creatorFeeRecipient}. Discovery covers recent launches only (${r.fromBlock}-${r.toBlock}${r.truncated?", truncated":""}).`}}))}catch(r){throw new i(t.plainError(r))}}}},mn=nn;export{X as a,ue as b,Ve as c,Ke as d,nn as e,mn as f};
@@ -1 +0,0 @@
1
- import{a as M}from"./NCQFWPAW.js";import{a as v}from"./DCTUYDWF.js";import{K as A}from"./L3ZM77SJ.js";import{c as k}from"./JPOYTTTW.js";import{a as $}from"./6IM6A5VA.js";import{a as x}from"./UWOFA6GV.js";import{d as F,g as U,i as _}from"./73N3TOJL.js";import{a as N}from"./G6HCV67X.js";import{a as n}from"./5YS5V2LK.js";import{encodeFunctionData as H,erc20Abi as P,getAddress as y,zeroAddress as q}from"viem";var B={genesis:y("0x575b7B7c97Ef3E21C82DAeB427899d583e1E913f"),bond:y("0xff32a969A0c567129eECD926D04657728E1980C1"),inverse:y("0x92166e94Eea5B7799b761653881692f881dFC4C9"),treasury:y("0x04822Ea321A0DEE6F40656172F29312104855d66"),pteam:y("0x650F58079dAa17ee28928c2F92d22291d038B2B0"),rwa:y("0x99B6eE6eDe47d9a8a9bfd03F728a99B789df1961"),premium:y("0x346e1a31171A0f7aC73909010b5435768d3B5462"),tax:y("0x086C58400b8708Ef993f256E12e752dcF0AC918e")},j=y("0x59F95461E68e0c77605299791E1449f175165B54"),D={genesis:["purchase","finalize","refund","claim"],bond:["deposit","redeem"],inverse:["swap"],treasury:["rebalanceToMorpho","rebalanceFromMorpho","mintNet","spendUsdg"],pteam:["exercise"],rwa:["redeem","depositInventory","pokeHwm","setDiscount","setInventoryMax","setHalt","setMenu","skim"],premium:["execute"],tax:["convert"]},G={genesis:["wired","finalized","finalizeTime","saleStart","saleDeadline","raisedRaw","totalRaised","registryLength"],bond:["wired","enabled","startTime","marketCount"],inverse:["active","price","capacityRemaining","spreadBps"],treasury:["wired","rfv","backingPerToken","liquidUsdg","morphoAssets","polRfv","morphoCapBps","morphoVault","canonicalPair"],pteam:["wired","holder","vestedFraction","exercisableNow","exercised","strikeWad","capBps","circulatingSupply","excludedFromFloat"],rwa:["manager","halted","inventory","inventoryMax","owedNet","bHwm","deskDiscountBps","VEST","MAX_DISCOUNT_BPS","INVENTORY_HARD_CAP","menu","routerSource","sleeve"],premium:["active","clipSize","lastExecuteAt","premiumThresholdWad","router","pairContract"],tax:["wired","pendingNet","teamBps","treasuryBps","teamWallet","router","pairContract"]},T=b=>JSON.parse(JSON.stringify(b,(S,I)=>typeof I=="bigint"?I.toString():I));function h(b){return _(b,"Provide a checksummed address.",F)}var ne=b=>{async function S(t){if(typeof t!="string"||!Object.hasOwn(B,t))throw new n("Choose a published NetNet financial product.");let c=t,e=B[c],d=M[c],m=b.clientFor(N);if(await m.getChainId()!==N)throw new n("NetNet requires chain 4663.");let a=await m.getBlock(),s=(g,E=[])=>m.readContract({address:e,abi:d,functionName:g,args:E,blockNumber:a.number}),[i,o,p,f]=await Promise.all([s("net"),s("usdg"),m.readContract({address:v.address,abi:P,functionName:"decimals",blockNumber:a.number}),m.readContract({address:k.address,abi:P,functionName:"decimals",blockNumber:a.number})]);if(h(i)!==v.address||h(o)!==k.address||p!==v.decimals||f!==k.decimals)throw new n("NetNet financial token pins or decimals do not match the deployment.");return{product:c,contract:e,abi:d,rpc:m,block:a,read:s}}let I=(t,c,e,d)=>({name:t,inputSchema:{type:"object",properties:c,required:e,additionalProperties:!1},execute:async(m,a)=>{try{if($(a),Object.keys(m).some(s=>!Object.hasOwn(c,s)))throw new n("Unsupported NetNet financial argument.");return await d(m,a)}catch(s){throw new n(b.plainError(s))}}}),C={type:"string",enum:Object.keys(B)};return{tools:[I("netnet_financial_status",{product:C,offset:{type:"integer",minimum:0},limit:{type:"integer",minimum:1,maximum:50}},["product"],async(t,c)=>{let e=await S(t.product),d=G[e.product],m=t.offset??0,a=t.limit??20;if(!Number.isSafeInteger(m)||Number(m)<0||!Number.isSafeInteger(a)||Number(a)<1||Number(a)>50)throw new n("Use a nonnegative offset and limit 1..50.");let s=await Promise.all(d.map(async o=>{try{return[o,{value:T(await e.read(o))}]}catch(p){return[o,{unavailable:b.plainError(p)}]}})),i={};if(e.product==="genesis")for(let o of["purchasedRaw","purchasedNetOf","claimedNet","claimableNetOf"])i[o]=T(await e.read(o,[c]));if(e.product==="bond"||e.product==="rwa"){i.pending=T(await e.read("pendingFor",[c]));let o=await e.read("noteCount",[c]);if(typeof o!="bigint"||o<0n)throw new n("Invalid NetNet note count.");let p=o<BigInt(Number(m)+Number(a))?o:BigInt(Number(m)+Number(a));i.noteCount=o.toString(),i.notes=await Promise.all(Array.from({length:Math.max(0,Number(p-BigInt(Number(m))))},async(f,g)=>({id:String(Number(m)+g),note:T(await e.read(e.product==="bond"?"notes":"noteAt",[c,BigInt(Number(m)+g)]))}))),i.nextOffset=p<o?p.toString():null,e.product==="bond"&&(i.markets=await Promise.all([0n,1n].map(async f=>{try{return{id:f.toString(),quoteToken:h(await e.read("quoteToken",[f])),priceWad:String(await e.read("bondPrice",[f]))}}catch(g){return{id:f.toString(),unavailable:b.plainError(g)}}})))}return e.product==="treasury"&&(i.isMinter=await e.read("isMinter",[c]),i.isSpender=await e.read("isSpender",[c])),{chainId:N,contract:e.contract,product:e.product,blockNumber:String(e.block.number),tokens:[v,k],metrics:Object.fromEntries(s),wallet:i,units:"Raw token amounts use each token\u2019s decimals. Prices, NAV, reserve values and capacityRemaining use 18-decimal USDG WAD. Note timestamps are Unix seconds.",operations:D[e.product],caveat:"An unavailable metric is not zero. Formulaic eligibility, oracle liveness, caps and vesting are checked by the action preview. RWA entry/router calldata and initial deployment wiring remain unsupported."}}),I("netnet_financial_action",{product:C,operation:{type:"string",enum:[...new Set(Object.values(D).flat())]},amount:x(),minAmountOut:x(),maxPriceWad:x(),maxPayment:x(),marketId:{type:"integer",enum:[0,1]},recipient:{type:"string"},halted:{type:"boolean"},token:{type:"string"},noteIds:{type:"array",maxItems:50,items:x()},menu:{type:"array",maxItems:32,items:{type:"object"}}},["product","operation"],async(t,c)=>{let e=await S(t.product),d=t.operation;if(typeof d!="string"||!D[e.product].includes(d))throw new n("This operation is not supported by the selected financial product.");let m=new Set(["product","operation"]),a=[],s,i=0n,o="",p=(...r)=>r.forEach(u=>m.add(u)),f=()=>(p("amount"),A(t.amount)),g=()=>(p("minAmountOut"),A(t.minAmountOut));if(e.product==="genesis"){if(d==="purchase"&&(i=f(),s=k,a=[i],o="Founding subscription; NET is claimable only after successful finalization and vesting. A failed sale requires refund."),d==="claim"&&await e.read("claimableNetOf",[c])===0n)throw new n("No vested founding NET is claimable by this wallet.")}else if(e.product==="bond")if(d==="deposit"){if(p("marketId","maxPriceWad"),t.marketId!==0&&t.marketId!==1)throw new n("Bond marketId must be 0 (USDG) or 1 (canonical LP).");let r=BigInt(t.marketId);if(h(await e.read("quoteToken",[r]))!==(r===0n?k.address:j))throw new n("Bond quote token is not the pinned USDG or canonical LP.");i=f(),s=r===0n?k:{address:j,decimals:18,symbol:"NET/USDG LP",chainId:N};let l=A(t.maxPriceWad),w=await e.read("bondPrice",[r]);if(typeof w!="bigint"||w===0n||w>l)throw new n("Bond price exceeds maxPriceWad or is invalid.");a=[r,i,l,c],o="Payment is exchanged for a non-transferable NET note with two-day linear vesting. Redeem vested NET with the same product; payment cannot be withdrawn."}else a=[c];else if(e.product==="inverse"){if(i=f(),s=v,a=[i,g()],o="Purchased NET is burned permanently; USDG pays directly to this wallet. Capacity is denominated in USDG WAD, not raw USDG.",await e.read("active")!==!0)throw new n("NetNet buyback is inactive: oracle, finalization or capacity is unavailable.")}else if(e.product==="pteam"){if(h(await e.read("holder"))!==y(c))throw new n("This wallet is not the immutable pTEAM holder.");let r=f();if(p("maxPayment"),r>await e.read("exercisableNow"))throw new n("The NET exercise amount exceeds the vested cap.");let u=await e.read("strikeWad");if(i=(r*u/10n**BigInt(v.decimals)+10n**12n-1n)/10n**12n,i===0n||i>A(t.maxPayment))throw new n("The exercise payment exceeds maxPayment or rounds to zero.");s=k,a=[r],o=`Exercise pays ${i} USDG base units into treasury reserves and mints ${r} NET base units to the immutable holder. No withdrawal or exercise reversal exists.`}else if(e.product==="treasury"){let r=f();if(d==="mintNet"||d==="spendUsdg"){p("recipient");let u=h(t.recipient);if(await e.read(d==="mintNet"?"isMinter":"isSpender",[c])!==!0)throw new n("This wallet lacks the fixed NetNet treasury minter/spender role.");a=[u,r],o=`Protocol treasury operation sends ${r} base units to ${u}; it does not deposit into this wallet\u2019s savings.`}else a=[r],o="Permissionless protocol reserve rebalance; assets remain owned by the NetNet treasury. The deployed fraction is constrained by the immutable cap."}else if(e.product==="rwa"){if(["depositInventory","setDiscount","setInventoryMax","setHalt","setMenu"].includes(d)&&h(await e.read("manager"))!==y(c))throw new n("This wallet lacks the immutable RWA manager role.");if(d==="redeem")if(p("noteIds"),t.noteIds===void 0)a=[c];else{if(!Array.isArray(t.noteIds)||!t.noteIds.length||t.noteIds.length>50)throw new n("Provide 1..50 unique note IDs.");let u=t.noteIds.map(w=>A(w,!0));if(new Set(u.map(String)).size!==u.length)throw new n("Note IDs must be unique.");let l=await e.read("noteCount",[c]);if(u.some(w=>w>=l))throw new n("RWA note ID is out of range.");a=[c,u]}else if(d==="setHalt"){if(p("halted"),typeof t.halted!="boolean")throw new n("Provide halted as a boolean.");a=[t.halted]}else if(d==="setMenu"){if(p("menu"),!Array.isArray(t.menu)||!t.menu.length||t.menu.length>32)throw new n("Provide 1..32 explicit RWA menu entries.");let u=t.menu.map(l=>{if(!l||typeof l!="object"||Array.isArray(l)||Object.keys(l).some(z=>!["token","feed","targetWeightBps","active"].includes(z)))throw new n("Invalid RWA menu fields.");let w=l;if(typeof w.active!="boolean")throw new n("RWA active must be boolean.");return{token:h(w.token),feed:h(w.feed),targetWeightBps:A(w.targetWeightBps,!0),active:w.active}});if(new Set(u.map(l=>l.token)).size!==u.length||u.reduce((l,w)=>l+w.targetWeightBps,0n)!==10000n||u.some(l=>l.active&&(l.token===q||l.feed===q)))throw new n("RWA menu tokens must be unique, weights sum to 10000, active feeds/tokens nonzero.");a=[u],o=`Replace the complete RWA equity menu: ${JSON.stringify(T(u))}.`}else if(d==="skim")p("token"),a=[h(t.token)],o=`Sweep eligible stray assets to sleeve ${h(await e.read("sleeve"))}, not to this wallet.`;else if(d!=="pokeHwm"){let u=f();if(a=[u],d==="depositInventory"&&(s=v,i=u,o="Inventory funding is one-way. The manager cannot withdraw these NET; they are committed to bond obligations."),d==="setDiscount"&&u>await e.read("MAX_DISCOUNT_BPS")||d==="setInventoryMax"&&u>await e.read("INVENTORY_HARD_CAP"))throw new n("RWA setting exceeds its immutable maximum.")}}else e.product==="premium"?(a=[g()],o="Permissionless mint-and-sell keeper operation; all sale proceeds go to NetNet treasury. The caller receives no reward."):(a=[f(),g()],o="Convert NET already owned by the tax collector. Proceeds split to treasury and team; the caller receives no reward and supplies no NET.");if(Object.keys(t).some(r=>!m.has(r)))throw new n("Unexpected fields for this NetNet operation.");if(s&&await e.rpc.readContract({address:s.address,abi:P,functionName:"balanceOf",args:[c],blockNumber:e.block.number})<i)throw new n(`Top up ${s.symbol}: needs ${i} base units.`);let E=`NetNet ${e.product}.${d}, contract ${e.contract}, chain ${N}, values ${JSON.stringify(T(a))}. ${s?`Approve exactly ${i} ${s.symbol} base units (${s.address}, decimals ${s.decimals}). `:""}${o}`,O=[...s?[b.approval(s.address,e.contract,i.toString(),N)]:[],b.unsignedTx({to:e.contract,data:H({abi:e.abi,functionName:d,args:a}),value:"0",chainId:N,description:E})],R=await b.preview(O,c),W=0n;for(let r of R.changes){if(!/^-?\d+$/.test(r.amount))throw new n("Invalid NetNet preview amount.");if(BigInt(r.amount)<0n&&(W-=BigInt(r.amount)),BigInt(r.amount)<0n&&(!s||r.token.chainId!==N||!U(r.token.address,s.address)||r.token.decimals!==s.decimals||-BigInt(r.amount)>i))throw new n("NetNet preview spends outside the exact input budget.")}if(W>i)throw new n("NetNet preview exceeds the aggregate input budget.");return{txs:O,preview:R,summary:E}})]}};export{B as a,j as b,ne as c};
@@ -1 +0,0 @@
1
- import{d as Z}from"./VC2RCYQE.js";import{e as ne}from"./NATG6YA6.js";import{a as te,k as ae}from"./5VHH5PW3.js";import{b as O,c as D}from"./OQVZVR2S.js";import{e as ee}from"./XQUPZ3GU.js";import{b as X}from"./AXYOJBX6.js";import{a as C}from"./6IM6A5VA.js";import{c as $}from"./MYBDO5SA.js";import{b as K}from"./UWOFA6GV.js";import{c as k,d as G,e as b,g as F,j as z,m as J,n as Q}from"./73N3TOJL.js";import{a as l,i as N}from"./G6HCV67X.js";import{a as d}from"./5YS5V2LK.js";import{encodeFunctionData as se,erc20Abi as R,parseAbi as oe}from"viem";var B="https://api.beefy.finance/vaults",re="https://api.beefy.finance/fees",de="https://api.beefy.finance/apy/breakdown",ue="https://api.beefy.finance/tvl",ce="https://databarn.beefy.finance/api/v1/price",j=N[l].vaults.beefyTestedLpVault,M=oe(["function want() view returns (address)","function balance() view returns (uint256)","function getPricePerFullShare() view returns (uint256)","function strategy() view returns (address)","function paused() view returns (bool)","function deposit(uint256 amount)","function withdraw(uint256 shares)"]),q=K("Positive integer string in base units. Send quoted digits, never a JSON number.");function v(s){return z(s,"Provide a valid contract or wallet address.",G)}function _(s){return J(s,"The contract returned an invalid integer.")}function T(s){return Q(s,"Amount must be positive and fit in uint256.",{notString:"Amount must be a positive integer string in base units.",positive:!0})}function ie(s){if(typeof s!="number"||!Number.isInteger(s)||s<0||s>255)throw new d("Invalid token decimals.");return s}function I(s){return F(s,j.address)}function U(s){return te.some(f=>F(f.vault,s))}function L(s){return U(s)?"Use beefy_withdraw to exchange vault shares for CLM shares, redeem them into pair tokens with beefy_clm_withdraw, then convert the tokens to USDG with beefy_clm_swap.":"Use beefy_withdraw to exchange vault shares for the want token. Redeem that want into its pair tokens through a qualified Oak route or the Beefy app, then swap the received tokens to USDG."}function le(s){return!b(s)||!b(s.performance)?!1:[s.deposit,s.withdraw,s.performance.total].every(f=>typeof f=="number"&&Number.isFinite(f)&&f>=0&&f<=1)&&typeof s.lastUpdated=="number"&&Number.isSafeInteger(s.lastUpdated)&&s.lastUpdated>=0}var me=s=>{async function f(a){try{return await a()}catch(o){throw new d(s.plainError(o))}}function A(a,o){if(a.chainId!==void 0&&a.chainId!==l)throw new d("Beefy requires chain 4663.");for(let i of Object.keys(a))if(!["chainId",...o].includes(i))throw new d(`Unsupported Beefy input: ${i}.`)}async function P(){let a=await $(s.http,B,{headers:{"User-Agent":"Oak-Beefy/1.0"}},e=>Array.isArray(e)&&e.every(t=>b(t)&&typeof t.chain=="string")),o=new Set,i=new Set;return a.filter(e=>e.chain==="robinhood").map(e=>{if(typeof e.id!="string"||!e.id||typeof e.name!="string"||!e.name||e.type!=="standard"||!["active","paused","eol"].includes(String(e.status)))throw new d("The Beefy API returned an unexpected vault record.");let t=v(e.earnContractAddress);if(o.has(e.id)||i.has(t))throw new d("The Beefy API returned duplicate vault records.");return o.add(e.id),i.add(t),{id:e.id,name:e.name,type:"standard",chain:"robinhood",status:e.status,tokenAddress:v(e.tokenAddress),tokenDecimals:ie(e.tokenDecimals),earnContractAddress:t,assets:Array.isArray(e.assets)&&e.assets.every(r=>typeof r=="string")?e.assets:[],strategyType:typeof e.strategyTypeId=="string"?e.strategyTypeId:null,risks:b(e.risks)?Object.fromEntries(Object.entries(e.risks).filter(r=>typeof r[1]=="boolean")):{},lastHarvest:typeof e.lastHarvest=="number"&&Number.isSafeInteger(e.lastHarvest)&&e.lastHarvest>=0?e.lastHarvest:null}})}async function E(){return $(s.http,re,{headers:{"User-Agent":"Oak-Beefy/1.0"}},b)}function H(a,o){let i=a[o.id];if(!le(i))throw new d(`Beefy fees are unavailable for ${o.id}.`);return i}async function g(){let a=s.clientFor(l);if(await a.getChainId()!==l)throw new d("The Beefy endpoint must report chain 4663.");let o=_(await a.getBlockNumber()),i=(n,u)=>a.readContract({address:n,abi:M,functionName:u,blockNumber:o}),e=async(n,u)=>_(await a.readContract({address:n,abi:R,functionName:"balanceOf",args:[u],blockNumber:o}));async function t(n){let[u,p]=await Promise.all([a.readContract({address:n,abi:R,functionName:"symbol",blockNumber:o}),a.readContract({address:n,abi:R,functionName:"decimals",blockNumber:o})]);if(typeof u!="string"||!u.trim())throw new d("The contract returned invalid token metadata.");return{address:n,chainId:l,symbol:u,decimals:ie(p)}}async function r(n){let u=n.earnContractAddress,p=v(await i(u,"want"));if(p!==n.tokenAddress)throw new d(`Beefy API token and want() disagree for ${n.id}.`);let[h,y,m,c,w]=await Promise.all([t(p),t(u),i(u,"strategy"),i(u,"balance"),i(u,"getPricePerFullShare")]);if(h.decimals!==n.tokenDecimals)throw new d(`Beefy API and want decimals disagree for ${n.id}.`);let S=v(m),W=await i(S,"paused");if(typeof W!="boolean")throw new d("The strategy returned an invalid pause flag.");let x=_(w);if(x===0n)throw new d("The Beefy share price is zero.");return{want:h,shares:y,strategy:S,paused:W,managed:_(c),pricePerFullShare:x}}return{blockNumber:o,balanceOf:e,vaultState:r}}async function V(a){let o=v(a.vault),i=O(o),t=(await P()).find(r=>r.earnContractAddress===o);if(!t)throw new d("The selected vault is missing from the current Beefy inventory.");if(t.id!==i.id||t.tokenAddress!==i.tokenAddress.toLowerCase()||t.tokenDecimals!==i.tokenDecimals||t.type!==i.type)throw new d("The Beefy API and pinned vault type or want disagree.");return t}async function Y(a,o,i,e){let t=H(await E(),e),r=await s.preview(a,o),n=r.changes.map(u=>{let p=u.amount.startsWith("-"),h=p?u.amount.slice(1):u.amount;return`${p?"-":"+"}${s.formatAmount(h,u.token.decimals)} ${u.token.symbol} (${u.token.address}, chain ${u.token.chainId})`}).join("; ");return{txs:a,preview:r,summary:`${i} ${e.name}. ${n}. ${r.summary} Beefy API fees: deposit ${t.deposit*100}%, withdrawal ${t.withdraw*100}%, performance ${t.performance.total*100}% (updated ${t.lastUpdated} ms). These calls have no on-chain minimum output parameter; preview is an estimate, not a guaranteed amount. LP acquisition and conversion to USDG are separate.`}}return{tools:[{name:"beefy_list",inputSchema:{type:"object",properties:{chainId:{const:l}},additionalProperties:!1},execute:a=>f(async()=>{A(a,[]);let[o,i,e]=await Promise.all([P(),E(),g()]),t=[];for(let r of o){let n=await e.vaultState(r);t.push({id:r.id,name:r.name,vault:r.earnContractAddress,chainId:l,want:n.want,shares:n.shares,balance:{token:n.want,amount:n.managed.toString()},pricePerFullShare:{token:n.want,amount:n.pricePerFullShare.toString(),scale:"1000000000000000000",source:"getPricePerFullShare()"},apiStatus:{value:r.status,source:B},strategyPaused:{value:n.paused,source:"strategy.paused()",address:n.strategy,block:e.blockNumber.toString()},fees:{...H(i,r),source:re},forkQualified:I(r.earnContractAddress),qualification:I(r.earnContractAddress)?{source:j.source,block:j.block}:null,depositAvailable:O(r.earnContractAddress,!1)!==void 0&&r.status==="active"&&!n.paused,underlyingRoute:U(r.earnContractAddress)?{kind:"clm",read:"beefy_lp",acquire:"beefy_clm_deposit",redeem:"beefy_clm_withdraw",swap:"beefy_clm_swap"}:null,exitPath:L(r.earnContractAddress),block:e.blockNumber.toString()})}return{vaults:t,summary:"Direct want/LP vaults, not ERC-4626 or direct USDG. All pinned standard vaults support direct want deposits and share withdrawals after local code/type checks. For the seven active pinned CLM wants, start with beefy_lp and use the CLM acquisition/redemption tools. Fork qualification, API status and strategy pause are separate observations."}})},{name:"beefy_vault_info",inputSchema:{type:"object",properties:{vault:k,chainId:{const:l},historyBucket:{enum:["1h_1d","1h_1w","1h_1M","1d_1M","1d_1Y","1d_all"]}},required:["vault"],additionalProperties:!1},execute:a=>f(async()=>{A(a,["vault","historyBucket"]);let o=a.historyBucket??"1d_1M";if(!["1h_1d","1h_1w","1h_1M","1d_1M","1d_1Y","1d_all"].includes(String(o)))throw new d("Provide a supported Beefy historyBucket.");let i=v(a.vault),e=(await P()).find(m=>m.earnContractAddress===i);if(!e)throw new d("The selected vault is missing from the current Beefy inventory.");let t=new URL(ce);t.searchParams.set("product_key",`beefy:vault:robinhood:${i}`),t.searchParams.set("price_type","share_to_underlying"),t.searchParams.set("time_bucket",String(o));async function r(m,c){try{let w=await $(s.http,m,{headers:{"User-Agent":"Oak-Beefy/1.0"}},S=>S!==void 0);return{status:"available",source:m,value:c(w)}}catch(w){return{status:"unavailable",source:m,error:s.plainError(w)}}}let[n,u,p,h]=await Promise.all([r(de,m=>{if(!b(m))throw new d("Beefy APY is unavailable for this vault.");let c=m[e.id];if(!b(c))throw new d("Beefy APY is unavailable for this vault.");if(!Object.hasOwn(c,"totalApy")||Object.values(c).some(w=>typeof w!="number"||!Number.isFinite(w)||w<0))throw new d("Beefy returned invalid APY data.");return c}),r(ue,m=>{let c=b(m)?m[e.id]:void 0;if(typeof c!="number"||!Number.isFinite(c)||c<0)throw new d("Beefy TVL is unavailable for this vault.");return c}),r(t.toString(),m=>{if(!Array.isArray(m)||m.some(c=>!Array.isArray(c)||c.length<2||typeof c[0]!="string"||!Number.isFinite(Date.parse(c[0]))||typeof c[1]!="string"||!/^\d+(\.\d+)?$/.test(c[1])))throw new d("Beefy returned invalid share-price history.");return m.map(c=>({timestamp:c[0],shareToUnderlying:c[1]}))}),g()]),y=await h.vaultState(e);return{id:e.id,name:e.name,vault:e.earnContractAddress,chainId:l,want:y.want,strategy:{address:y.strategy,type:e.strategyType,assets:e.assets,paused:y.paused,lastHarvest:e.lastHarvest,source:B},risk:{status:Object.keys(e.risks).length?"available":"unavailable",flags:e.risks,source:B,guide:"https://docs.beefy.finance/safety/risk-checklist",summary:"API risk flags are assessments, not guarantees. Uncorrelated LP assets can suffer impermanent loss; vaults also expose strategy, token and contract risks."},apy:n,tvl:{...u,currency:"USD"},history:p,forkQualified:I(e.earnContractAddress),block:h.blockNumber.toString(),app:`https://app.beefy.finance/vault/${encodeURIComponent(e.id)}`,summary:"APY is a fractional annual estimate, not a promised return. Share-price history is not a wallet profit calculation. Missing analytics remain unavailable."}})},{name:"beefy_deposit",inputSchema:{type:"object",properties:{vault:k,token:k,amount:q,minSharesOut:q,slippageBps:{type:"integer",minimum:0,maximum:9999},chainId:{const:l}},required:["vault","token","amount"],additionalProperties:!1},execute:(a,o)=>f(async()=>{if(A(a,["vault","token","amount","minSharesOut","slippageBps"]),C(o),a.slippageBps!==void 0&&(!Number.isInteger(a.slippageBps)||Number(a.slippageBps)<0||Number(a.slippageBps)>9999))throw new d("slippageBps must be an integer from 0 to 9999.");a.minSharesOut!==void 0&&T(a.minSharesOut);let i=T(a.amount),e=v(a.token),t=await V(a),r=await g();await D(s.clientFor(l),t.earnContractAddress,r.blockNumber);let n=await r.vaultState(t);if(t.status!=="active")throw new d(`The Beefy API marks this vault ${t.status}; deposits are unavailable. ${L(t.earnContractAddress)}`);if(n.paused)throw new d(`The Beefy strategy is paused; deposits are unavailable. ${L(t.earnContractAddress)}`);if(e!==n.want.address)throw new d(`This vault needs ${n.want.symbol} (${n.want.address}, chain 4663), not the supplied token. ${U(t.earnContractAddress)?"Read beefy_lp, acquire the pair tokens with beefy_clm_swap and mint the want with beefy_clm_deposit first.":"No USDG zap is provided."}`);if(await r.balanceOf(n.want.address,o)<i)throw new d(`Insufficient ${n.want.symbol} want balance.`);let u=[s.approval(n.want.address,t.earnContractAddress,i.toString(),l),s.unsignedTx({to:t.earnContractAddress,data:se({abi:M,functionName:"deposit",args:[i]}),value:"0",chainId:l,description:`Deposit ${i} want base units into ${t.name}.`})],p=await Y(u,o,"Deposit into",t),h=i*10n**18n/n.pricePerFullShare,y=a.minSharesOut===void 0?h*BigInt(1e4-Number(a.slippageBps??50))/10000n:T(a.minSharesOut);if(y<=0n||y>h)throw new d("Minimum shares must be positive and no greater than the current forecast.");let m={token:{address:N[l].tokens.WETH.address,symbol:"WETH",decimals:18,chainId:l},from:n.strategy,recipient:o,optional:!0,includedInMinimumShares:!1},c=`Share forecast ${h}; minimum ${y} share base units (local pre-sign simulation check only; deposit(uint256) has no on-chain minimum). Optional WETH harvest rewards from strategy ${n.strategy} may vary or be zero and are not part of that floor.`;return{...p,harvestReward:m,minimumShares:y.toString(),summary:`${p.summary} ${c}`,preview:{...p.preview,summary:`${p.preview.summary} ${c}`}}})},{name:"beefy_withdraw",inputSchema:{type:"object",properties:{vault:k,shares:{anyOf:[q,{const:"all"}]},chainId:{const:l}},required:["vault","shares"],additionalProperties:!1},execute:(a,o)=>f(async()=>{A(a,["vault","shares"]),C(o);let i=a.shares==="all"?void 0:T(a.shares),e=await V(a),t=await g();await D(s.clientFor(l),e.earnContractAddress,t.blockNumber),await t.vaultState(e);let r=await t.balanceOf(e.earnContractAddress,o),n=i??r;if(n===0n||n>r)throw new d("Provide a positive share amount no greater than your current Beefy share balance.");let u=[s.unsignedTx({to:e.earnContractAddress,data:se({abi:M,functionName:"withdraw",args:[n]}),value:"0",chainId:l,description:`Withdraw ${n} share base units from ${e.name} to the calling wallet.`})];return Y(u,o,"Withdraw from",e)})}],positions:a=>f(async()=>{C(a);let[o,i]=await Promise.all([P(),g()]),e=[];for(let t of o){let r=await i.balanceOf(t.earnContractAddress,a);if(r===0n)continue;let n=await i.vaultState(t);e.push({module:"beefy",id:t.earnContractAddress,chainId:l,assets:[{token:n.want,amount:(r*n.pricePerFullShare/10n**18n).toString()}],description:`${t.name}: ${s.formatAmount(r.toString(),n.shares.decimals)} ${n.shares.symbol} shares (${t.earnContractAddress}); want estimate before withdrawal fees at block ${i.blockNumber}. API ${t.status}; strategy paused ${n.paused}. ${I(t.earnContractAddress)?"Recorded fork-qualified vault.":U(t.earnContractAddress)?"Direct want/share writes supported; CLM acquisition and redemption have separate qualification.":"Direct want/share writes supported after code/type checks; no recorded fork round trip yet."}`})}return e})}};function Be(s){return X("beefy",[me(s),ne(s),ae(s),Z(s),ee(s)])}export{me as a,Be as b};
@@ -1 +0,0 @@
1
- import{a as e}from"./5YS5V2LK.js";function s(t){if(typeof t!="string"||!/^\d+$/.test(t))throw new e("Amount must be a non-negative integer string in base units.");return BigInt(t)}function u(t){if(!Number.isInteger(t)||t<0||t>255)throw new e("Token decimals must be an integer from 0 to 255.");return 10n**BigInt(t)}function f(t,i,n){if(i<=0n)throw new e("The denominator must be positive.");if(n!=="floor"&&n!=="ceil")throw new e("Choose floor or ceil rounding.");return t/i+(n==="ceil"&&t%i!==0n?1n:0n)}function p(t,i,n){let o=u(i);if(typeof t!="string"||!/^\d+(\.\d+)?$/.test(t))throw new e("Amount must be a non-negative decimal string.");let[r="0",c=""]=t.split("."),g=c.slice(i);if(n===void 0&&/[1-9]/.test(g))throw new e("Amount exceeds the token precision. Choose floor or ceil rounding.");if(n!==void 0&&n!=="floor"&&n!=="ceil")throw new e("Choose floor or ceil rounding.");return(BigInt(r)*o+BigInt(c.slice(0,i).padEnd(i,"0")||"0")+(n==="ceil"&&/[1-9]/.test(g)?1n:0n)).toString()}function a(t,i){let n=s(t),o=u(i),r=(n%o).toString().padStart(i,"0").replace(/0+$/,"");return`${n/o}${r?`.${r}`:""}`}function b(t,i,n,o){return f(s(t)*s(i),s(n),o).toString()}export{s as a,p as b,a as c,b as d};
@@ -1 +0,0 @@
1
- import{b as k,c as D,d as x}from"./JPOYTTTW.js";import{a as Q}from"./CY75R4FK.js";import{a as T}from"./6IM6A5VA.js";import{g as V,i as G}from"./73N3TOJL.js";import{a as X,b as W}from"./RETS2ZEK.js";import{a as c,d as j,i as O}from"./G6HCV67X.js";import{a as u}from"./5YS5V2LK.js";import{encodeFunctionData as tt,erc20Abi as Z,getAddress as a,parseAbi as kt}from"viem";var gt="hookr",y=a(O[4663].hookr.HookrLimitOrders.address),At=a(O[4663].hookr.HookrRoot.address),wt=a(O[4663].hookr.HookrRouter.address),Ot=a(O[4663].hookr.HookrForwarder.address),Bt=a(O[4663].hookr.PoolManager.address),ht=a(O[4663].hookr.HOOKR_Token.address),L="0x0000000000000000000000000000000000000000",It="0x000000000000000000000000000000000000dEaD",J=(1n<<128n)-1n,St=new Set([L.toLowerCase(),It.toLowerCase(),y.toLowerCase(),wt.toLowerCase(),Ot.toLowerCase(),Bt.toLowerCase(),At.toLowerCase()]),B=kt(["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 Tt(t){let n=t.toLowerCase();return n===L.toLowerCase()||n===Q.toLowerCase()}function Ht(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 jt(t,n,i){return W(t,n,i)}function nt(t,n){return!t.changes||t.changes.length===0?"no net ERC-20/native transfer delta on caller":t.changes.map(i=>`${Ht(n,i.amount,i.token.decimals)} ${i.token.symbol} (${i.token.address})`).join(", ")}function $t(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 et(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 xt(t){switch(t){case 0:return"None";case 1:return"Open";case 2:return"Filled";case 3:return"Cancelled";default:return"Unknown"}}function Rt(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 Ct(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 Dt(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 Y(t,n,i=c){if(i!==c)throw new u(`Unsupported token chain ${i}; Hookr requires chain ${c}.`);if(Tt(n))return{...k,chainId:i};T(n);let o=a(n),s=o.toLowerCase();if(s===D.address.toLowerCase())return{address:o,symbol:D.symbol,decimals:j,chainId:i};if(s===x.address.toLowerCase())return{address:o,symbol:x.symbol,decimals:x.decimals,chainId:i};if(s===ht.toLowerCase())return{address:o,symbol:"HOOKR",decimals:18,chainId:i};let[r,d]=await Promise.all([t.readContract({address:o,abi:Z,functionName:"symbol"}),t.readContract({address:o,abi:Z,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 Pt(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 P(t,n=[]){let i=G(t,"Provide a valid recipient wallet address."),o=i.toLowerCase();if(St.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 ot(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 E(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 X(t)}}function Et(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{ot(n),T(i);let o=a(i),s=et(n.chainId),r=$t(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]}),Pt(d)]),e=Rt(g),l=Number(e.status),h=xt(l);if(l===0||V(e.owner,L))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),H=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>J)throw new u(`Hookr order #${r} has an invalid amountIn (${e.amountIn}).`);if(e.minAmountOut<=0n||e.minAmountOut>J)throw new u(`Hookr order #${r} has an invalid minAmountOut (${e.minAmountOut}).`);let R=a(e.key.hooks);P(e.recipient,[R]);let rt=await d.readContract({address:y,abi:B,functionName:"bountyBounds",args:[{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:H,tickSpacing:f,hooks:R},e.zeroForOne,e.amountIn,e.minAmountOut]}),w=Dt(rt),C=E(n.minBounty,"minBounty"),_=C!==void 0&&C>w.minBounty?C:w.minBounty;if(e.bounty<_)throw new u(`Hookr order #${r} is underbounty: order bounty (${e.bounty} wei) is below the required keeper bounty (${_} 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=Ct(m),it=e.zeroForOne?e.key.currency0:e.key.currency1,ut=e.zeroForOne?e.key.currency1:e.key.currency0,[$,p]=await Promise.all([Y(d,it,s),Y(d,ut,s)]),S=E(n.minAmountOut,"minAmountOut"),F=S!==void 0&&S>e.minAmountOut?S:e.minAmountOut;if(!I.fillable||I.amountOut<=0n||I.amountOut<F)throw new u(`Hookr order #${r} is not executable: quoted output (${I.amountOut} base units of ${p.address}) does not meet minimum output (${F} base units).`);let st=tt({abi:B,functionName:"fill",args:[r]}),at=t.formatAmount(e.amountIn.toString(),$.decimals),mt=t.formatAmount(I.amountOut.toString(),p.decimals),dt=t.formatAmount(e.minAmountOut.toString(),p.decimals),ct=t.formatAmount(e.bounty.toString(),18),lt=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.`,v=`Fill Hookr order #${r}: maker's escrow pays ${at} ${$.symbol} (${e.amountIn} base units of ${$.address}); net output goes to ${a(e.recipient)} (quoted ${mt} ${p.symbol}, order minimum ${dt} ${p.symbol}, ${e.minAmountOut} base units of ${p.address}). The filler sends no tokens or ETH (value 0), pays gas, and accrues ${ct} ETH (${e.bounty} wei) bounty to ${o}, payable only via claimBounty. Pool tickSpacing ${f}; expiry ${A} inclusive.${lt}`,q=t.unsignedTx({to:y,data:st,value:"0",chainId:s,description:v}),M=await t.preview([q],o),yt=nt(M,t.formatAmount),z={token:$,amount:e.amountIn.toString()},K={token:p,amount:e.minAmountOut.toString()},bt={token:p,amount:I.amountOut.toString()},U={token:{...k,chainId:s},amount:e.bounty.toString()},ft={orderId:r.toString(),key:{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:H,tickSpacing:f,hooks:R},owner:a(e.owner),recipient:a(e.recipient),createdAt:BigInt(e.createdAt).toString(),expiry:A.toString(),zeroForOne:e.zeroForOne,status:l,statusLabel:h,amountIn:z,minAmountOut:K,bounty:U,sqrtPriceLimitX96:e.sqrtPriceLimitX96.toString()},pt={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:[q],summary:`${v} Preview deltas: ${yt}.`,preview:M,orderId:r.toString(),fillable:!0,amountIn:z,minAmountOut:K,quotedAmountOut:bt,bounty:U,bountyBounds:pt,order:ft}}catch(o){throw new u(t.plainError(o))}}}}function Lt(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{ot(n),T(i);let o=a(i),s=et(n.chainId),r=n.to!==void 0&&n.to!==null?P(String(n.to)):P(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=E(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=tt({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=nt(A,t.formatAmount),H={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:H}}catch(o){throw new u(t.plainError(o))}}}}async function Nt(t,n){T(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:gt,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 N=t=>({tools:[Et(t),Lt(t)],positions:n=>Nt(t,n)}),Xt=N,Wt=N,Vt=N;export{gt as a,y as b,At as c,wt as d,Ot as e,Bt as f,ht as g,B as h,Ht as i,jt as j,Et as k,Lt as l,Nt as m,N as n,Xt as o,Wt as p,Vt as q};
@@ -1 +0,0 @@
1
- import{a as V}from"./YHB55C5T.js";import{b as H,c as Z,d as z,e as J}from"./PWBL4WKB.js";import{a as j}from"./VVEUJ36E.js";import{a as L}from"./6UPPUHCL.js";import{c as W}from"./AMICUXS6.js";import{b as $,o as q}from"./5O5ZE3ZV.js";import{b as _}from"./AXYOJBX6.js";import{a as x,d as B,e as E}from"./6IM6A5VA.js";import{a as D}from"./UWOFA6GV.js";import{g as A,m as R,n as U}from"./73N3TOJL.js";import{a as h,d as N,i as I,j as S}from"./G6HCV67X.js";import{a as o}from"./5YS5V2LK.js";import{getAddress as F,parseAbi as ee}from"viem";var a=F(I[4663].vaults.groveAlm.address),te="0x29626c2d8ca49a51e4deceec5499e52983c42bd5",d=ee(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)","function maxDeposit(address) view returns (uint256)","function maxWithdraw(address) view returns (uint256)","function previewDeposit(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)"]),T=D("Positive integer in token base units."),M={type:"string",description:`Public Grove vault only: ${a}. Defaults to this vault.`},K={type:"integer",minimum:0,maximum:9999,default:$};function C(t){return U(t,"Amount must be positive and within the uint256 range.",{notString:"Amount must be a positive integer string in base units.",positive:!0})}function v(t){return R(t,"Grove returned an invalid integer read.")}function O(t,m,l){if(x(m),Object.keys(t).some(u=>!["vault",...l].includes(u)))throw new o("Unsupported Grove argument.");if(t.vault!==void 0){if(typeof t.vault!="string")throw new o("Provide the public Grove vault address.");if(t.vault.toLowerCase()===te)throw new o("The Grove ALM proxy is allocator infrastructure, not the public ERC-4626 vault.");if(x(t.vault),!A(t.vault,a))throw new o("Only the public Grove ERC-4626 vault is supported.")}}function Q(t,m,l){let u=l===void 0?$:l;if(typeof u!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");let e=BigInt(q(t.toString(),u)),n=m===void 0?e:C(m);if(n<=0n||n>t)throw new o("The minimum output must be positive and no greater than the quoted output.");return n}function X(t,m){let l=0n;for(let u of t.changes)if(!(u.token.chainId!==m.chainId||!A(u.token.address,m.address))){if(u.token.decimals!==m.decimals||typeof u.amount!="string"||!/^-?\d+$/.test(u.amount))throw new o("Grove preview returned invalid token metadata or amounts.");l+=BigInt(u.amount)}return l}var ne=t=>{async function m(e){try{return await e()}catch(n){throw new o(t.plainError(n))}}async function l(){let e=t.clientFor(h);if(await e.getChainId()!==h)throw new o("Grove requires an RPC endpoint on chain 4663.");let n=await e.readContract({address:a,abi:d,functionName:"asset"});if(typeof n!="string"||!A(n,S))throw new o("The public Grove vault must use canonical USDG on chain 4663.");let[i,s]=await Promise.all([e.readContract({address:F(S),abi:d,functionName:"decimals"}),e.readContract({address:a,abi:d,functionName:"decimals"})]);if(i!==N||s!==18)throw new o("Grove token decimals differ from the evidenced USDG/share interface.");let r={address:F(S),chainId:h,decimals:i,symbol:"USDG"};return{client:e,asset:r,shareToken:{address:a,chainId:h,decimals:s,symbol:"Grove shares"}}}async function u(e,n,i,s,r,p){let f=await t.preview(e,n);if(X(f,i)!==-s)throw new o("Grove simulation did not show the exact requested token outflow.");if(X(f,r)<p)throw new o("Grove simulated output is below the minimum.");let g=f.changes.map(({token:w,amount:b})=>{let y=b.startsWith("-");return`${y?"-":"+"}${t.formatAmount(y?b.slice(1):b,w.decimals)} ${w.symbol} (${w.address}, chain ${w.chainId})`}).join("; ");return{txs:e,summary:`${f.summary} ${g}. Minimum ${p} base units of ${r.address} is a preview check, not enforced on-chain by standard ERC-4626. Re-preview before signing; execution output can change.`}}return{tools:[Z(t,"grove_details",a),L(t,"grove_analytics",a),V(t,"grove_manage",a),...j(t,"grove",a),{name:"grove_list",inputSchema:{type:"object",properties:{vault:M},additionalProperties:!1},execute:(e,n)=>m(async()=>{O(e,n,[]);let{client:i,asset:s,shareToken:r}=await l(),[p,f,c,g,w,b]=await Promise.all([i.readContract({address:a,abi:d,functionName:"totalAssets"}),i.readContract({address:a,abi:d,functionName:"totalSupply"}),i.readContract({address:a,abi:d,functionName:"maxDeposit",args:[n]}),i.readContract({address:a,abi:d,functionName:"maxWithdraw",args:[n]}),i.readContract({address:a,abi:d,functionName:"performanceFee"}),i.readContract({address:a,abi:d,functionName:"managementFee"})]);return[{vault:a,chainId:h,name:"Grove x Steakhouse USDG",asset:s,shareToken:r,totalAssets:{token:s,amount:v(p).toString()},totalSupply:{token:r,amount:v(f).toString()},maxDeposit:v(c)===0n?null:c.toString(),maxWithdraw:v(g)===0n?null:g.toString(),maxViewCaveat:"Zero Morpho V2 maximum views mean unknown capacity. Simulate the requested action; full exits use the fresh share balance.",fees:{performanceFeeRaw:v(w).toString(),managementFeeRaw:v(b).toString(),scale:"1000000000000000000",managementFeeTimeUnit:"second",performanceFeeBasis:"accrued interest"}}]})},{name:"grove_deposit",inputSchema:{type:"object",properties:{vault:M,amount:T,minSharesOut:T,slippageBps:K},required:["amount"],additionalProperties:!1},execute:(e,n)=>m(async()=>{O(e,n,["amount","minSharesOut","slippageBps"]);let i=C(e.amount),{client:s,asset:r,shareToken:p}=await l(),f=v(await s.readContract({address:a,abi:d,functionName:"previewDeposit",args:[i]})),c=Q(f,e.minSharesOut,e.slippageBps),g=B(a,r.address,i.toString(),n,h),w=[t.approval(r.address,a,i.toString(),h),t.unsignedTx(g.txs[1])];return u(w,n,r,i,p,c)})},{name:"grove_withdraw",inputSchema:{type:"object",properties:{vault:M,shares:{oneOf:[T,{const:"all",description:"Redeem the fresh full share balance."}]},minAmountOut:T,slippageBps:K,force:{type:"boolean"},maxPenaltyAssets:D()},required:["shares"],additionalProperties:!1},execute:(e,n)=>m(async()=>{O(e,n,["shares","minAmountOut","slippageBps","force","maxPenaltyAssets"]);let i=e.shares==="all"?void 0:C(e.shares),{client:s,asset:r,shareToken:p}=await l(),f=v(await s.readContract({address:a,abi:d,functionName:"balanceOf",args:[n]})),c=i??f;if(c===0n||c>f)throw new o("The Grove share balance is insufficient for this withdrawal.");if(e.force!==void 0&&typeof e.force!="boolean")throw new o("force must be a boolean.");if(e.force===!0){if(e.shares!=="all"||e.slippageBps!==void 0)throw new o("Force exit requires shares all and an explicit minAmountOut; omit slippageBps.");let k=W(e.maxPenaltyAssets),Y=C(e.minAmountOut),G=await H(t,s,a,n,c,k),P=await t.preview([G.tx],n);return J(P.changes,a,c,Y),{txs:[G.tx],preview:P,summary:`${z(G.plan)} ${P.summary}`}}if(e.maxPenaltyAssets!==void 0)throw new o("maxPenaltyAssets requires force true.");let g=v(await s.readContract({address:a,abi:d,functionName:"previewRedeem",args:[c]})),w=Q(g,e.minAmountOut,e.slippageBps),y=E(a,c.toString(),n,h).txs.map(k=>t.unsignedTx({...k,description:`Redeem ${c} Grove share base units to the wallet.`}));return u(y,n,p,c,r,w)})}],positions:e=>m(async()=>{x(e);let{client:n,asset:i,shareToken:s}=await l(),r=v(await n.readContract({address:a,abi:d,functionName:"balanceOf",args:[e]}));if(r===0n)return[];let p=v(await n.readContract({address:a,abi:d,functionName:"previewRedeem",args:[r]}));return[{module:"grove",id:`${h}:${a.toLowerCase()}`,chainId:h,assets:[{token:i,amount:p.toString()}],description:`${t.formatAmount(r.toString(),s.decimals)} Grove shares (${r} base units, ${s.decimals} decimals, ${a}); estimated USDG redemption, subject to simulation.`}]})}},he=t=>_("grove",[ne(t)]);export{ne as a,he as b};
@@ -1 +0,0 @@
1
- import{a as B}from"./UFS2RVEZ.js";import{b as M}from"./ZT47KN7A.js";import{c as _}from"./R7FXNZRM.js";import{c as V}from"./DZGEQBO7.js";import{k as R}from"./NAYRD43N.js";import{c as P}from"./2UU5TBBB.js";import{b as H,o as F}from"./5O5ZE3ZV.js";import{b as W}from"./AXYOJBX6.js";import{a as k}from"./6IM6A5VA.js";import{a as G}from"./UWOFA6GV.js";import{g as A,m as I,n as O}from"./73N3TOJL.js";import{a as m,i as U}from"./G6HCV67X.js";import{a as u}from"./5YS5V2LK.js";import{encodeFunctionData as C,getAddress as b,parseAbi as q}from"viem";var c=q(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)","function balanceOf(address) view returns (uint256)","function previewDeposit(uint256 assets) view returns (uint256)","function previewRedeem(uint256 shares) view returns (uint256)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),J=q(["function deposit() payable"]),f=U[m],T=[{key:"core",name:"Longbow Core USDG",vault:f.vaults.longbowCore.address,asset:f.tokens.USDG.address,symbol:"USDG",decimals:6},{key:"frontier",name:"Longbow Frontier USDG",vault:f.vaults.longbowFrontier.address,asset:f.tokens.USDG.address,symbol:"USDG",decimals:6},{key:"eth",name:"Longbow ETH",vault:f.vaults.longbowEth.address,asset:f.tokens.WETH.address,symbol:"WETH",decimals:18}],D=[{key:"v1-usdg",name:"Longbow USDG Core V1 (legacy)",vault:b("0x8cb8AA35228c96C1C4E956E69AbAEBCc2aA7Dcfe"),asset:f.tokens.USDG.address,symbol:"USDG",decimals:6},{key:"v1-weth",name:"Longbow WETH Core V1 (legacy)",vault:b("0x93777a9b917be3c8259c84456222f43a01dd6492"),asset:f.tokens.WETH.address,symbol:"WETH",decimals:18}];function x(a,i){return O(a,`${i} must be positive and within the uint256 range.`,{notString:`${i} must be a positive integer string in base units.`,positive:!0})}function h(a){return I(a,"Longbow returned an invalid integer response.")}function j(a,i=!1){if(typeof a!="string")throw new u("Provide the address of a current Longbow vault.");let p=D.find(y=>A(y.vault,a));if(p&&!i)throw new u("Longbow V1 vaults are withdraw-only; deposit into a current V2 vault from longbow_list instead.");let g=p??T.find(y=>A(y.vault,a));if(!g)throw new u("Provide the address of a current Longbow vault, or a Longbow V1 vault to withdraw from. Other vaults are not supported.");return g}function L(a,i){if(Object.keys(a).some(p=>!i.includes(p)))throw new u("Unsupported Longbow input. Use the fields in the tool schema.")}var Q=a=>{async function i(t){try{return await t()}catch(e){throw new u(a.plainError(e))}}async function p(){let t=a.clientFor(m);if(await t.getChainId()!==m)throw new u("Longbow requires a client on chain 4663.");return t}async function g(t,e){let[o,r,s]=await Promise.all([t.readContract({address:e.vault,abi:c,functionName:"asset"}),t.readContract({address:e.vault,abi:c,functionName:"decimals"}),t.readContract({address:e.asset,abi:c,functionName:"decimals"})]);if(typeof o!="string"||!A(o,e.asset))throw new u("Longbow vault asset does not match the recorded deployment.");if(r!==18||s!==e.decimals)throw new u("Longbow token decimals do not match the recorded deployment.");return{vault:e.vault,key:e.key,name:e.name,asset:{address:b(e.asset),symbol:e.symbol,decimals:s,chainId:m},share:{address:e.vault,symbol:`${e.key} shares`,decimals:r,chainId:m}}}async function y(t,e,o,r){let s=F(o.amount,H);if(BigInt(s)===0n)throw new u("The expected output is too small for a nonzero simulation minimum.");let n=await a.preview(t,e);if(n.changes.filter(l=>l.token.chainId===o.token.chainId&&A(l.token.address,o.token.address)&&l.token.decimals===o.token.decimals).reduce((l,v)=>l+BigInt(v.amount),0n)<BigInt(s))throw new u("Longbow simulated output is below the expected minimum.");let d=n.changes.map(({token:l,amount:v})=>{let N=v.startsWith("-");return`${N?"-":"+"}${a.formatAmount(N?v.slice(1):v,l.decimals)} ${l.symbol} (${l.address}, chain ${l.chainId})`}).join("; ");return{txs:t,preview:n,expectedOutput:o,minimumOutput:{token:o.token,amount:s},minimumEnforcedOnchain:!1,summary:`${r} ${d}. Simulation only; no on-chain minimum is enforced by these ERC-4626 calls. ${n.summary}`}}async function z(t){L(t,[]);let e=await p();return Promise.all(T.map(async o=>{let[r,s,n,w]=await Promise.all([g(e,o),e.readContract({address:o.vault,abi:c,functionName:"totalAssets"}),e.readContract({address:o.vault,abi:c,functionName:"performanceFee"}),e.readContract({address:o.vault,abi:c,functionName:"managementFee"})]);return{...r,totalAssets:{token:r.asset,amount:h(s).toString()},fees:{performanceFeeE18:h(n).toString(),managementFeeE18:h(w).toString()},caveat:"Morpho V2 max views can be zero even when writes succeed. Simulate the requested action; listing does not prove availability."}}))}async function Y(t,e){L(t,["vault","amount","wrapEth"]),k(e);let o=j(t.vault),r=x(t.amount,"Deposit amount");if(t.wrapEth!==void 0&&typeof t.wrapEth!="boolean")throw new u("wrapEth must be a boolean.");if(t.wrapEth&&!A(o.asset,f.tokens.WETH.address))throw new u("Only a WETH vault accepts explicit ETH wrapping.");let s=await p(),n=await g(s,o),w=h(await s.readContract({address:n.vault,abi:c,functionName:"previewDeposit",args:[r]})),d=[];return t.wrapEth&&d.push(a.unsignedTx({to:n.asset.address,data:C({abi:J,functionName:"deposit"}),value:r.toString(),chainId:m,description:`Wrap ${a.formatAmount(r.toString(),18)} ETH into WETH for ${n.name}.`})),d.push(a.approval(n.asset.address,n.vault,r.toString(),m)),d.push(a.unsignedTx({to:n.vault,data:C({abi:c,functionName:"deposit",args:[r,b(e)]}),value:"0",chainId:m,description:`Deposit ${a.formatAmount(r.toString(),n.asset.decimals)} ${n.asset.symbol} into ${n.name}.`})),y(d,e,{token:n.share,amount:w.toString()},`Deposit into ${n.name}.`)}async function K(t,e){L(t,["vault","shares"]),k(e);let o=j(t.vault,!0),r=t.shares==="all"?void 0:x(t.shares,"Redeem shares"),s=await p(),n=await g(s,o),w=h(await s.readContract({address:n.vault,abi:c,functionName:"balanceOf",args:[e]})),d=r??w;if(d===0n||d>w)throw new u("The wallet has insufficient Longbow shares for this redemption.");let l=h(await s.readContract({address:n.vault,abi:c,functionName:"previewRedeem",args:[d]})),v=[a.unsignedTx({to:n.vault,data:C({abi:c,functionName:"redeem",args:[d,b(e),b(e)]}),value:"0",chainId:m,description:`Redeem ${a.formatAmount(d.toString(),n.share.decimals)} shares from ${n.name} into ${n.asset.symbol}.`})];return y(v,e,{token:n.asset,amount:l.toString()},`Redeem from ${n.name}.`)}let E={type:"string",enum:T.map(t=>t.vault),description:"Current vault address on chain 4663."},$=G("Positive integer base units, never a human-unit decimal."),S=(t,e,o,r)=>({name:t,inputSchema:{type:"object",properties:e,required:o,additionalProperties:!1},execute:(s,n)=>i(()=>r(s,n))});return{tools:[S("longbow_list",{},[],z),S("longbow_deposit",{vault:E,amount:$,wrapEth:{type:"boolean",default:!1,description:"Explicitly wrap this amount of native ETH before depositing into the WETH vault."}},["vault","amount"],Y),S("longbow_withdraw",{vault:{...E,enum:[...E.enum,...D.map(t=>t.vault)],description:"Current vault address, or a Longbow V1 vault (withdraw-only) on chain 4663."},shares:{anyOf:[$,{const:"all"}],description:"Share base units (18 decimals), or all for the fresh wallet share balance. Returns the underlying asset, including WETH."}},["vault","shares"],K)],positions:t=>i(async()=>{k(t);let e=await p();return(await Promise.all([...T,...D].map(async r=>{let s=await g(e,r),n=h(await e.readContract({address:s.vault,abi:c,functionName:"balanceOf",args:[t]}));if(n===0n)return[];let w=h(await e.readContract({address:s.vault,abi:c,functionName:"previewRedeem",args:[n]}));return[{module:"longbow",id:`${m}:${s.vault.toLowerCase()}`,chainId:m,assets:[{token:s.asset,amount:w.toString()}],description:`${s.name}: ${a.formatAmount(n.toString(),s.share.decimals)} shares (${s.share.address}, ${s.share.decimals} decimals). Underlying is a preview, not a guaranteed redemption.`}]}))).flat()})}};function we(a){return W("longbow",[Q(a),P(a),R(a),V(a),M(a),_(a),{tools:B(a,"longbow",T.map(i=>({vault:i.vault,asset:{address:b(i.asset),symbol:i.symbol,decimals:i.decimals,chainId:m}})))}])}export{D as a,Q as b,we as c};
@@ -1 +0,0 @@
1
- import{b as mt}from"./4KQZTPMS.js";import{c as pt}from"./2W46IRX6.js";import{b as gt}from"./LMVB3B6T.js";import{b as ft}from"./JWCOXLYA.js";import{b as ut}from"./TWCSCRFS.js";import{c as ct}from"./NMYGNJIJ.js";import{h as lt}from"./GGUEKSR4.js";import{a as C,b as x,c as Ie,d as me,e as Ge,g as it,h as Ve,j as U,l as E,o as Fe,p as rt,q as st,r as Me,s as at,t as qe,u as dt}from"./3WBDHUV2.js";import{b as nt,o as ot}from"./5O5ZE3ZV.js";import{b as Qe}from"./AXYOJBX6.js";import{a as z}from"./6IM6A5VA.js";import{a as et,c as tt}from"./MYBDO5SA.js";import{a as Pe}from"./UWOFA6GV.js";import{a as ee}from"./RETS2ZEK.js";import{a as $,d as N,i as le}from"./G6HCV67X.js";import{a}from"./5YS5V2LK.js";import{a as Ee}from"./JXOEJPJ4.js";import{BaseError as Ht,ContractFunctionRevertedError as ht,decodeEventLog as Wt,decodeFunctionResult as jt,encodeFunctionData as X,erc20Abi as zt,getAddress as B,parseAbi as ke,parseAbiItem as Jt,recoverAddress as Xt,recoverMessageAddress as Yt,recoverTypedDataAddress as Zt}from"viem";var Kt="https://priors.trade/api/check",He=604800n,bt=50n,wt=10000n,We=5000000n,yt=500000000n,je=86400n,$t=2592000n,Ye=`Register one with oak_setup {"mode":"register"}, then open Priors' 5 USDG starter line with priors_starter_line (a refundable 5 USDG bond, an invite from Priors' invite bot, your pool consent; each transaction and signature is confirmed).`,Qt="0x6982e39521a070a3c40782548bfbed6dc8f566ef",en=["0xcbb95bbf36099d34da091dc6fa6f49efa257cee3","0x284358abc07f9359f19f4b5b4ac91901be2597ba"],c={pool:B(le[4663].priors.pool.address),lens:B(le[4663].priors.lens.address),usdg:B(le[4663].priors.usdg.address),registry:B(le[4663].priors.registry.address),stockVault:B(le[4663].priors.stockVault.address)},ce={address:c.usdg,symbol:"USDG",decimals:N,chainId:$},S=ke(["function deposit(uint256 assets, address receiver, uint256 minShares) returns (uint256 minted)","function withdraw(uint256 shares_, address receiver) returns (uint256 out)","function quoteFee(uint256 agentId, uint256 principal, uint64 term) view returns (uint256 fee, uint256 sponsorCut, uint256 reserveCut, uint256 premium)","function borrow(uint256 agentId, uint256 amount, uint64 term, address to, uint256 maxFee) returns (uint256 loanId)","function repay(uint256 loanId, uint256 expectedAgentId, uint256 maxDue)","function shares(address lender) view returns (uint256)","function convertToAssets(uint256 shares_) view returns (uint256)","function lastDepositAt(address lender) view returns (uint64)","function isController(uint256 id, address who) view returns (bool)","function delegateOf(uint256 id) view returns (address)","function getAgent(uint256 id) view returns (bool enrolled, bool isRoot, bool defaulted, bool frozen, bool importedFromV1, uint64 enrolledAt, uint64 lastBorrowAt, uint64 lastRepayAt, uint256 sponsor, uint256 delegatedIn, uint256 delegatedOut, uint256 principalOut, uint256 activeLoans, uint256 premiumBps, uint256 premiumCap, uint256 loansRepaid, uint256 volumeRepaid, uint256 feesPaid, uint256 recourseHonored, uint256 childrenDefaulted, uint256 qualifiedRepaid, uint256 dollarSecondsRepaid)","function nonces(uint256 id) view returns (uint256)","function consentDigest((uint256 agentId, uint256 sponsorId, address owner, uint256 maxPremiumBps, uint256 nonce, uint256 deadline) c) view returns (bytes32)","function leave(uint256 agentId)","function loansOf(uint256 id) view returns (uint256[])","function getLoan(uint256 loanId) view returns (uint256 agentId, uint256 sponsorId, uint256 principal, uint256 fee, uint256 sponsorCut, uint256 reserveCut, uint256 premium, address owner, uint64 issuedAt, uint64 dueAt, uint64 defaultableAt, uint64 minScoreTerm, uint64 closedAt, uint8 status)","event Borrowed(uint256 indexed loanId, uint256 indexed agentId, uint256 indexed sponsorId, uint256 principal, uint256 fee, uint64 dueAt, address to)"]),St=ke(["function available(uint256 agentId) view returns (uint256)","function score(uint256 id) view returns (uint256)"]),Ct=ke(["function ownerOf(uint256 agentId) view returns (address)","function balanceOf(address owner) view returns (uint256)","function getAgentWallet(uint256 agentId) view returns (address)"]),At=ke(["function borrowRoom(uint256 agentId) view returns (uint256)","function assetList() view returns (address[])","function assets(address token) view returns (address feed, uint32 heartbeat, uint8 tokenDecimals, uint8 feedDecimals, bool enabled, uint16 ltvBps, uint256 lineCap)"]);function Y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function tn(e){return e.chainId===$&&e.address.toLowerCase()===c.usdg.toLowerCase()}function nn(e,i){let g=i.amount.trim(),u=g.startsWith("-"),f=u||g.startsWith("+")?g.slice(1):g,R=e.formatAmount(f,i.token.decimals),A=tn(i.token)?"USDG":i.token.address;return`${u?"-":"+"}${R} ${A}`}function te(e,i,g){if(!g.length)return i;let u=g.map(f=>nn(e,f)).join(", ");return`${i} Preview changes: ${u}.`}function vt(e,i,g,u){let f=e[i]===void 0?void 0:ee(e[i]),R=e[g]===void 0?void 0:ee(e[g]);if(f!==void 0)return f;if(R!==void 0)return R;throw new a(`Provide ${u} as an integer string in base units ("${i}" or "${g}").`)}async function De(e,i,g){try{return B(await e.clientFor($).readContract({address:c.registry,abi:Ct,functionName:"ownerOf",args:[i],blockNumber:g}))}catch{throw new a(`Could not read the owner of ERC-8004 agent ${i} from registry ${c.registry}. Check the agent ID and retry when the registry is available.`)}}function pe(e,i){if(typeof e=="bigint"&&e>0n)return e;if(typeof e=="number"&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if(typeof e=="string"&&/^\d+$/.test(e.trim())){let g=BigInt(e.trim());if(g>0n)return g}throw new a(`Provide a positive integer ${i}.`)}function on(e,i){let g=i!==void 0?pe(i,"agentId"):void 0,u=[];for(let f of e)if(!(!f||typeof f.address!="string")&&f.address.toLowerCase()===c.pool.toLowerCase()&&!(!Array.isArray(f.topics)||f.topics.length===0))try{let R=Wt({abi:S,eventName:"Borrowed",data:f.data,topics:f.topics});if(g!==void 0&&R.args.agentId!==g)continue;u.push(R.args.loanId)}catch{continue}return u.length===0?null:u[u.length-1].toString()}function we(e){return{enrolled:!!e[0],isRoot:!!e[1],defaulted:!!e[2],frozen:!!e[3],importedFromV1:!!e[4],enrolledAt:BigInt(e[5]),lastBorrowAt:BigInt(e[6]),lastRepayAt:BigInt(e[7]),sponsor:BigInt(e[8]),delegatedIn:BigInt(e[9]),delegatedOut:BigInt(e[10]),principalOut:BigInt(e[11]),activeLoans:BigInt(e[12]),premiumBps:BigInt(e[13]),premiumCap:BigInt(e[14]),loansRepaid:BigInt(e[15]),volumeRepaid:BigInt(e[16]),feesPaid:BigInt(e[17]),recourseHonored:BigInt(e[18]),childrenDefaulted:BigInt(e[19]),qualifiedRepaid:BigInt(e[20]),dollarSecondsRepaid:BigInt(e[21])}}function Ce(e,i){return{loanId:e,agentId:BigInt(i[0]),sponsorId:BigInt(i[1]),principal:BigInt(i[2]),fee:BigInt(i[3]),sponsorCut:BigInt(i[4]),reserveCut:BigInt(i[5]),premium:BigInt(i[6]),owner:B(String(i[7])),issuedAt:BigInt(i[8]),dueAt:BigInt(i[9]),defaultableAt:BigInt(i[10]),minScoreTerm:BigInt(i[11]),closedAt:BigInt(i[12]),status:Number(i[13])}}async function _e(e,i){let g=e.clientFor($),u=await g.getBlockNumber({cacheTime:0}),f=await g.readContract({address:c.registry,abi:Ct,functionName:"balanceOf",args:[i],blockNumber:u});if(f===0n)return[];if(typeof f!="bigint"||f<0n)throw new a("Registry balance is unavailable. Retry or provide an explicit agentId.");let R=[],A=new Set,L=u;for(;;){let H=L>9999999n?L-9999999n:0n,ne=await g.getLogs({address:c.registry,event:Jt("event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"),args:{to:i},fromBlock:H,toBlock:L,strict:!0});for(let O of ne){let J=O.args.tokenId;if(O.removed||A.has(J))continue;if(A.add(J),(await De(e,J,u)).toLowerCase()===i.toLowerCase()&&R.push(J),BigInt(R.length)===f)return R.sort((Z,re)=>Z<re?-1:Z>re?1:0)}if(H===0n)throw new a("Owned identities could not all be located. Retry or provide an explicit agentId.");L=H-1n}}async function Re(e,i,g){if(i.agentId!==void 0&&i.agentId!==null&&String(i.agentId).trim()!=="")return pe(i.agentId,"agentId");let u=await _e(e,g);if(u.length===0)throw new a(`Priors borrowing needs an ERC-8004 agent identity with a Priors credit line, and this wallet owns no identity. ${Ye}`);return u[0]}async function ze(e,i,g){let u=e.clientFor($),f=await De(e,i),[R,A]=await Promise.all([u.readContract({address:c.pool,abi:S,functionName:"delegateOf",args:[i]}),u.readContract({address:c.pool,abi:S,functionName:"isController",args:[i,g]})]),L=B(R);if(!A)throw new a(`Wallet ${g} is not an on-chain controller for ERC-8004 agent ${i} (ownerOf=${f}, delegateOf=${L}). An off-chain /api/check paymentWallet match alone does not grant CreditPoolV2 control.`);return{owner:f,delegate:L}}function rn(e,i){if(!i.enrolled||i.isRoot||i.sponsor===0n)throw new a(`ERC-8004 agent ${e} has no sponsor-backed Priors credit line on CreditPoolV2 yet (enrolled=${i.enrolled}, sponsor=${i.sponsor}, isRoot=${i.isRoot}). For an agent with no Priors record, priors_starter_line opens Priors' 5 USDG treasury line (a refundable 5 USDG bond, an invite from Priors' invite bot, your pool consent), then borrow.`);if(i.defaulted||i.frozen)throw new a(`ERC-8004 agent ${e} is not eligible to borrow on CreditPoolV2 (defaulted=${i.defaulted}, frozen=${i.frozen}).`);let g=i.delegatedIn>i.principalOut?i.delegatedIn-i.principalOut:0n;if(g<=0n)throw new a(`ERC-8004 agent ${e} has 0 USDG remaining credit capacity (delegatedIn=${i.delegatedIn}, principalOut=${i.principalOut}).`);return g}function sn(e){let i=e.borrowReceiptLogs??(Y(e.borrowReceipt)?e.borrowReceipt.logs:void 0);if(!Array.isArray(i))return[];let g=[];for(let u of i)Y(u)&&(typeof u.address!="string"||!Array.isArray(u.topics)||typeof u.data!="string"||g.push({address:u.address,topics:u.topics,data:u.data}));return g}var Je="0x0000000000000000000000000000000000000000",ue=()=>Math.floor(Date.now()/1e3),G=e=>new Date(Number(e)*1e3).toISOString(),V=(e,i)=>e.toLowerCase()===i.toLowerCase();function ye(e){let i=(g,u)=>Array.isArray(e)?e[u]:e[g];return{depositor:B(String(i("depositor",0))),at:BigInt(i("at",1)),amount:BigInt(i("amount",2))}}async function he(e,i,g){let u=e.clientFor($),f=await u.getBlockNumber({cacheTime:0}),[R,A,L,H,ne,O,J,ge,Z,re,Te]=await Promise.all([De(e,i,f),u.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[i],blockNumber:f}),u.readContract({address:x,abi:E,functionName:"firstLined",args:[i],blockNumber:f}),u.readContract({address:x,abi:E,functionName:"agentId",blockNumber:f}),u.readContract({address:x,abi:E,functionName:"rules",blockNumber:f}),u.readContract({address:x,abi:E,functionName:"epochRoom",blockNumber:f}),u.readContract({address:C,abi:U,functionName:"bonds",args:[i],blockNumber:f}),u.readContract({address:C,abi:U,functionName:"amount",blockNumber:f}),u.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[i],blockNumber:f}),u.readContract({address:C,abi:U,functionName:"unusedAfter",blockNumber:f}),u.readContract({address:c.usdg,abi:zt,functionName:"balanceOf",args:[g],blockNumber:f})]);return{owner:R,agent:we(A),firstLined:L===!0,root:BigInt(H),firstLineAmount:BigInt(ne[1]),epochRoom:BigInt(O),bond:ye(J),bondAmount:BigInt(ge),releaseAt:BigInt(Z),unusedAfter:BigInt(re),usdg:BigInt(Te)}}function Pt(e,i){return e.enrolled||e.enrolledAt>0n||e.isRoot||e.defaulted||e.importedFromV1||e.loansRepaid>0n||e.sponsor!==0n||i}function It(e,i,g,u){let f=R=>`${e.formatAmount(R.toString(),N)} USDG`;if(i.defaulted)return"it defaulted: the pool marks it, and Priors never lends to it again";if(i.isRoot)return"it is a root: it backs other agents' lines";if(i.delegatedIn>0n){let R=i.sponsor===g?`Priors' treasury (root #${g})`:`root #${i.sponsor}`;return`it has a ${f(i.delegatedIn)} line from ${R}${i.activeLoans>0n?` with ${i.activeLoans} loan(s) open`:""}`}return`it has no line now${i.enrolledAt>0n?` (it enrolled at ${G(i.enrolledAt)})`:""}${u?`; Priors' treasury opened a line for it once, and another needs a person at ${Ge}`:""}`}async function Xe(e,i){let g;try{g=await e.http(me,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify(i)})}catch(f){if(!(f instanceof et))throw new a(`Priors' invite bot (${me}) could not be reached: ${e.plainError(f)}`);g=f.response}let u;try{u=JSON.parse(await g.text())}catch{u=void 0}if(!Y(u))throw new a(`Priors' invite bot (${me}) answered HTTP ${g.status} without a readable JSON object.`);return u}var be=e=>Ee(typeof e=="string"&&e?e:"no reason given");function an(e,i){let g=i instanceof Ht?i.walk(L=>L instanceof ht):void 0,u=g instanceof ht?g.data:void 0,f=u?.args??[],R=L=>`${e.formatAmount(String(L),N)} USDG`,A=u?.errorName;switch(A){case"EpochCapReached":return`Priors' treasury has no room for a new line this week (wanted ${R(f[0])}, ${R(f[1])} left); the treasury caps new lines each week, so ask again next week.`;case"InsufficientBacking":return`Priors' treasury root lacks free backing for the line now (requested ${R(f[1])}, free ${R(f[2])}); try again later.`;case"InviteExpired":return"the invite expired; call priors_starter_line again for a new one.";case"InviteUsed":return"the invite was already used.";case"NotInvited":return`the invite's signer ${String(f[1])} is not an inviter TreasurySponsorV4 names.`;case"AlreadyLined":return"the agent is already on a treasury line.";case"OwnerDefaulted":return"a default on this wallet's Priors record stops new treasury lines.";case"BadConsent":return"the pool refused the consent (its owner, nonce or signature no longer matches); call priors_starter_line again.";case"ConsentExpired":return"the consent expired; call priors_starter_line again.";case"Paused":return"the Priors pool is paused for new risk; try again later.";case void 0:return e.plainError(i);default:return`${A}(${f.map(String).join(", ")}).`}}var dn=e=>{let i={name:"priors_lend",inputSchema:{type:"object",properties:{assets:{type:"string",pattern:"^[0-9]+$",description:'USDG deposit amount in 6-decimal base units (e.g. "1000000" for 1 USDG).'},amount:{type:"string",pattern:"^[0-9]+$",description:'Alias for assets: USDG base-unit integer string (e.g. "1000000" for 1 USDG).'},receiver:{type:"string",description:"Optional share receiver address (must be the signing wallet)."},minShares:{type:"string",pattern:"^[0-9]+$",description:"Minimum pool shares in base units; defaults to simulated minted shares less slippage."},slippageBps:{type:"integer",minimum:0,maximum:9999,description:"Slippage in basis points for the simulated share minimum (defaults to 50)."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.receiver!==void 0&&(typeof n.receiver!="string"||n.receiver.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors receiver must be the signing wallet.");let r=vt(n,"assets","amount","USDG deposit amount");if(r<=0n)throw new a("Deposit amount must be greater than zero.");let p=n.minShares===void 0?void 0:ee(n.minShares),d=e.approval(c.usdg,c.pool,r.toString(),$);if(p===void 0){let l;try{let v=await e.clientFor($).simulateCalls({account:o,calls:[{to:d.to,data:d.data},{to:c.pool,data:X({abi:S,functionName:"deposit",args:[r,t,0n]})}]}),[P,_]=v.results;if(P?.status!=="success"||_?.status!=="success")throw new a("Approval or deposit simulation failed.");l=jt({abi:S,functionName:"deposit",data:_.data})}catch(v){throw new a(`Could not simulate Priors deposit shares: ${e.plainError(v)}`)}if(p=ee(ot(l.toString(),n.slippageBps??nt)),p===0n)throw new a("The simulated deposit cannot provide a positive minimum share amount.")}let w=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"deposit",args:[r,t,p]}),value:"0",chainId:$,description:`Deposit ${r} USDG base units into Priors CreditPoolV2 (${c.pool}) for ${t}.`}),b=[d,w],m=await e.preview(b,o),I=`Approve ${e.formatAmount(r.toString(),N)} USDG and deposit into Priors CreditPoolV2 (${c.pool}) for ${t} (minShares=${p}; 7-day MIN_HOLD applies a 0.5% early-exit fee on early withdrawals).`;return{txs:b,summary:te(e,I,m.changes)}}},g={name:"priors_withdraw",inputSchema:{type:"object",properties:{shares:{type:"string",pattern:"^[0-9]+$",description:"Pool share count in base units to redeem (not USDG amount; omit to redeem full wallet share balance)."},receiver:{type:"string",description:"Optional USDG receiver address (must be the signing wallet)."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.receiver!==void 0&&(typeof n.receiver!="string"||n.receiver.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors receiver must be the signing wallet.");let r=e.clientFor($),p=n.shares!==void 0?ee(n.shares):await r.readContract({address:c.pool,abi:S,functionName:"shares",args:[o]});if(p<=0n)throw new a(`Wallet ${o} has no Priors CreditPoolV2 shares to withdraw.`);let[d,w,b]=await Promise.all([r.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[p]}),r.readContract({address:c.pool,abi:S,functionName:"lastDepositAt",args:[o]}),r.getBlock()]),m=w>0n&&b.timestamp<w+He,h=m?d*bt/wt:0n,I=d-h,v=[e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"withdraw",args:[p,t]}),value:"0",chainId:$,description:`Withdraw ${p} shares from Priors CreditPoolV2 (${c.pool}) to ${t}.`})],P=await e.preview(v,o),_=e.formatAmount(I.toString(),N),F=e.formatAmount(d.toString(),N),k=e.formatAmount(h.toString(),N),D=m?`inside 7-day MIN_HOLD: ${k} USDG (0.5%) early-exit fee stays in pool, net payout ${_} USDG from ${F} USDG gross`:`outside 7-day MIN_HOLD: no early-exit fee, net payout ${_} USDG`,M=`Withdraw ${p} shares from Priors CreditPoolV2 (${c.pool}) to ${t} (${D}).`;return{txs:v,summary:te(e,M,P.changes)}}},u={name:"priors_borrow",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"ERC-8004 agent token ID with an already-funded Priors credit line."},principal:{type:"string",pattern:"^[0-9]+$",description:'Borrow principal in 6-decimal USDG base units (min "5000000" = 5 USDG).'},amount:{type:"string",pattern:"^[0-9]+$",description:'Alias for principal: USDG base-unit integer string (e.g. "5000000" for 5 USDG).'},term:{type:"string",description:'Loan term in seconds (between 86400 and 2592000; defaults to "86400"). The origination fee is pro-rated by term, so a longer term costs more.'},recipient:{type:"string",description:"Optional USDG recipient address (must be the signing wallet)."},maxFee:{type:"string",description:"Optional ceiling on the origination fee, USDG base units; must equal the pool's current quote for this principal and term. Omit to use that quote. The fee is pro-rated by term, not flat: 1666 for 5 USDG over 1 day on the first live run (2026-10-31)."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.recipient!==void 0&&(typeof n.recipient!="string"||n.recipient.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors recipient must be the signing wallet.");let r=await Re(e,n,o);await ze(e,r,o);let p=e.clientFor($),d=await p.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[r]}),w=we(d),b=rn(r,w),m=vt(n,"principal","amount","USDG borrow principal");if(m<We||m>yt)throw new a(`Borrow principal must be between ${We} (5 USDG) and ${yt} (500 USDG) base units.`);if(m>b)throw new a(`Borrow principal ${m} exceeds available credit line capacity ${b} USDG base units for agent ${r}.`);let h=n.term!==void 0&&String(n.term).trim()!==""?pe(n.term,"term"):je;if(h<je||h>$t)throw new a(`Loan term must be between ${je} (1 day) and ${$t} (30 days) seconds.`);let I=await p.readContract({address:c.pool,abi:S,functionName:"quoteFee",args:[r,m,h]}),l=I[0],v=n.maxFee!==void 0?ee(n.maxFee):l;if(v<l)throw new a(`Provided maxFee ${v} is below the origination fee the pool quotes for this term, ${l} USDG base units.`);if(v>l)throw new a(`Provided maxFee ${v} is above the quoted origination fee ${l} USDG base units. Use the quoted fee or omit maxFee.`);let P=m+l,_=m+v,k=[e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"borrow",args:[r,m,h,t,v]}),value:"0",chainId:$,description:`Borrow ${m} USDG base units on Priors CreditPoolV2 for agent ${r} to ${t} (quoted fee ${l}, expected debt ${P}, maxFee ${v}, debt ceiling ${_}).`})],D=await e.preview(k,o),M=e.formatAmount(m.toString(),N),W=e.formatAmount(l.toString(),N),se=e.formatAmount(P.toString(),N),j=e.formatAmount(v.toString(),N),$e=e.formatAmount(_.toString(),N),q=I[1]+I[3],K=I[2],ae=l-q-K,oe=`Borrow ${M} USDG for ERC-8004 agent ${r} to recipient ${t} on Priors CreditPoolV2 (${c.pool}) for ${h}s: expected origination fee ${W} USDG (${l} base units; pro-rated by term, set when the loan opens, none refunded on early repayment), expected total repayment due ${se} USDG (${P} base units); fee ceiling ${j} USDG (${v} base units), debt ceiling ${$e} USDG (${_} base units). Fee recipient on repayment: CreditPoolV2 (${c.pool}), allocating the quoted fee to sponsor ${w.sponsor} (${q} base units including premium), reserve (${K} base units), and lenders (${ae} base units).`;return{txs:k,summary:te(e,oe,D.changes)}}},f={name:"priors_repay",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"ERC-8004 agent token ID that owns the active loan."},loanId:{type:"string",description:"Optional explicit per-agent loan ID (otherwise recovered from Borrowed receipt logs or loansOf(agentId))."},borrowReceiptLogs:{type:"array",description:"Optional receipt logs array from the borrow transaction to decode the exact Borrowed(loanId, agentId, ...) event."},maxDue:{type:"string",description:"Optional maximum USDG base units to repay; must equal the exact fixed principal + fee. Omit to use that debt."}}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o);await ze(e,t,o);let r=e.clientFor($),p;if(n.loanId!==void 0&&n.loanId!==null&&String(n.loanId).trim()!=="")p=pe(n.loanId,"loanId");else{let k=sn(n);if(k.length>0){let D=on(k,t);D!==null&&(p=BigInt(D))}}let d;if(p!==void 0){let k=await r.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[p]}),D=Ce(p,k);if(D.agentId!==t)throw new a(`Loan ${p} belongs to agent ${D.agentId}, not agent ${t}. Recover loan IDs from the Borrowed receipt or loansOf(agentId), never global loanCount().`);if(D.status!==1)throw new a(`Loan ${p} for agent ${t} is not active (status=${D.status}).`);d=D}else{let k=await r.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[t]});if(k.length===0)throw new a(`ERC-8004 agent ${t} has no recorded loans on Priors CreditPoolV2.`);let M=(await Promise.all(k.map(async W=>{let se=await r.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[W]});return Ce(W,se)}))).filter(W=>W.agentId===t&&W.status===1);if(M.length===0)throw new a(`ERC-8004 agent ${t} has no active loans to repay.`);d=M[M.length-1]}let w=d.principal+d.fee,b=n.maxDue!==void 0?ee(n.maxDue):w;if(b<w)throw new a(`Provided maxDue ${b} is below the exact fixed loan debt ${w} USDG base units (principal ${d.principal} + fixed fee ${d.fee}).`);if(b>w)throw new a(`Provided maxDue ${b} is above the exact fixed loan debt ${w} USDG base units. Use the fixed debt or omit maxDue.`);let m=e.approval(c.usdg,c.pool,w.toString(),$),h=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"repay",args:[d.loanId,t,b]}),value:"0",chainId:$,description:`Repay fixed debt ${w} USDG base units (principal ${d.principal} + fee ${d.fee}) for loan ${d.loanId} (agent ${t}).`}),I=[m,h],l=await e.preview(I,o),v=e.formatAmount(w.toString(),N),P=e.formatAmount(d.principal.toString(),N),_=e.formatAmount(d.fee.toString(),N),F=`Approve and repay ${v} USDG (${w} base units: ${P} USDG principal + ${_} USDG fixed fee) for Priors loan ${d.loanId} (agent ${t}).`;return{txs:I,summary:te(e,F,l.changes)}}},R={name:"priors_status",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"Optional ERC-8004 agent ID to inspect on CreditPoolV2, PriorsLens, and StockVault."},includeApiCheck:{type:"boolean",description:"Optional flag to query https://priors.trade/api/check for supplemental off-chain metadata."}}},async execute(n,s){z(s);let o=B(s),t=e.clientFor($),[r,p,d,w]=await Promise.all([t.readContract({address:c.pool,abi:S,functionName:"shares",args:[o]}),t.readContract({address:c.pool,abi:S,functionName:"lastDepositAt",args:[o]}),t.getBlock(),t.readContract({address:c.stockVault,abi:At,functionName:"assetList"})]),b=r>0n?await t.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[r]}):0n,m=r>0n&&p>0n&&d.timestamp<p+He,h=m?b*bt/wt:0n,I=b-h,l=null;if(n.agentId!==void 0&&n.agentId!==null&&String(n.agentId).trim()!=="")l=pe(n.agentId,"agentId");else{let q=await _e(e,o);q.length>0&&(l=q[0])}let v=null,P=!1,_=[],F=null,k=null,D=null,M=null,W=null,se=null,j=`This wallet owns no ERC-8004 agent identity. ${Ye}`;if(l!==null){let[q,K,ae,oe,Lt,xt,Be,Ne,Le]=await Promise.all([t.readContract({address:c.lens,abi:St,functionName:"score",args:[l]}),t.readContract({address:x,abi:E,functionName:"firstLined",args:[l]}),t.readContract({address:x,abi:E,functionName:"agentId"}),t.readContract({address:x,abi:E,functionName:"rules"}),t.readContract({address:x,abi:E,functionName:"epochRoom"}),t.readContract({address:C,abi:U,functionName:"bonds",args:[l]}),t.readContract({address:C,abi:U,functionName:"amount"}),t.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[l]}),t.readContract({address:C,abi:U,functionName:"releasable",args:[l]})]),[Ot,Ut,Et,Gt,Vt,Ft]=await Promise.all([t.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[l]}),t.readContract({address:c.lens,abi:St,functionName:"available",args:[l]}),t.readContract({address:c.stockVault,abi:At,functionName:"borrowRoom",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"delegateOf",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"isController",args:[l,o]})]),xe=await De(e,l),Mt=B(Vt),Ze=Ft,y=we(Ot),Se=y.delegatedIn>y.principalOut?y.delegatedIn-y.principalOut:0n;P=y.enrolled&&!y.isRoot&&!y.defaulted&&!y.frozen&&y.sponsor>0n&&y.delegatedIn>0n,F=Et.toString(),k=Gt.toString();let qt=await Promise.all(Ut.map(async T=>{let de=await t.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[T]});return Ce(T,de)}));for(let T of qt)if(T.agentId===l&&T.status===1){let de=T.principal+T.fee;_.push({loanId:T.loanId.toString(),agentId:T.agentId.toString(),sponsorId:T.sponsorId.toString(),principal:T.principal.toString(),fee:T.fee.toString(),due:de.toString(),dueAt:T.dueAt.toString(),issuedAt:T.issuedAt.toString(),owner:T.owner,token:ce})}v={agentId:l.toString(),owner:xe,delegate:Mt,isAuthorizedController:Ze,enrolled:y.enrolled,isRoot:y.isRoot,defaulted:y.defaulted,frozen:y.frozen,sponsorId:y.sponsor.toString(),delegatedIn:y.delegatedIn.toString(),delegatedOut:y.delegatedOut.toString(),principalOut:y.principalOut.toString(),availableCapacity:Se.toString(),activeLoansCount:y.activeLoans.toString(),loansRepaid:y.loansRepaid.toString(),volumeRepaid:y.volumeRepaid.toString(),feesPaid:y.feesPaid.toString(),importedFromV1:y.importedFromV1,qualifiedRepaid:y.qualifiedRepaid.toString(),dollarSecondsRepaid:y.dollarSecondsRepaid.toString()};let Ae=BigInt(ae),Oe=K===!0,Q=ye(xt),ie=Q.depositor!==Je,ve=ie&&V(Q.depositor,o),Ke=Pt(y,Oe),Ue=V(xe,o);D={onchain:BigInt(q).toString(),scale:"0-1000",source:`CreditLensV2.score(${l}) at ${c.lens}, the score the pool computes on chain`,scoreV2:null},M={open:y.sponsor!==0n&&y.delegatedIn>0n,amount:y.delegatedIn.toString(),drawn:y.principalOut.toString(),available:Se.toString(),sponsorId:y.sponsor.toString(),backer:y.sponsor===0n?null:y.sponsor===Ae?`Priors' treasury v4 (root #${Ae})`:`root #${y.sponsor}`,token:ce},W={contract:C,posted:ie,depositor:ie?Q.depositor:null,postedByWallet:ve,postedAt:ie?Q.at.toString():null,amount:(ie?Q.amount:BigInt(Be)).toString(),releasable:ie&&Le===!0,releaseAt:ie?BigInt(Ne).toString():null,rule:"Back to its depositor once the agent holds no line and has no loan open, from 4 days after it was posted (close a line first with priors_close_line); a default forfeits it to Priors' Safe."},se={eligible:Ue&&!Ke,firstLined:Oe,lineAmount:BigInt(oe[1]).toString(),bondAmount:BigInt(Be).toString(),treasuryRoot:Ae.toString(),treasuryRoomThisWeek:BigInt(Lt).toString(),note:"Not instant: Priors' invite bot decides each invite, and the treasury caps new lines each week."};let fe=_.map(T=>({id:String(T.loanId),dueAt:BigInt(String(T.dueAt))})).sort((T,de)=>T.dueAt<de.dueAt?-1:T.dueAt>de.dueAt?1:0);y.defaulted?j=`Agent #${l} defaulted; Priors never lends to it again${ve?" and its bond is forfeited":""}.`:!Ze&&!Ue?j=`This wallet does not control agent #${l} on CreditPoolV2 (owner ${xe}); act from its owner or delegate.`:fe.length?j=`Repay loan ${fe[0].id} with priors_repay before it is due at ${G(fe[0].dueAt)}${fe.length>1?` (${fe.length} loans open)`:""}.`:P&&Se>=We?j=`Borrow with priors_borrow (5 USDG minimum, up to ${A(Se)}; the fee is pro-rated by term); Priors counts loans held 7 days or more toward the score.`:!Ke&&Ue?j=ve?`Call priors_starter_line again: the ${A(Q.amount)} bond is posted, and it goes on with the invite bot's ownership proof and the invite's redemption${Le===!0?", or priors_release_bond returns the bond":""}.`:`Call priors_starter_line: a refundable ${A(BigInt(Be))} bond, an invite from Priors' invite bot and your pool consent open a ${A(BigInt(oe[1]))} line from Priors' treasury (each transaction and signature is confirmed).`:ve?j=Le===!0?`Release the ${A(Q.amount)} invite bond with priors_release_bond.`:y.delegatedIn>0n?`The line is open with nothing to draw; to take the bond back, close it with priors_close_line, then priors_release_bond from ${G(BigInt(Ne))}.`:`The ${A(Q.amount)} invite bond comes back with priors_release_bond from ${G(BigInt(Ne))}.`:j=`Agent #${l} has a Priors record but no line to draw now; ${It(e,y,Ae,Oe)}.`}let $e=null;if(n.includeApiCheck){let q=l!==null?`agent=${l.toString()}`:`address=${o}`,K=await tt(e.http,`${Kt}?${q}`,{method:"GET"},Y),ae=Array.isArray(K.agents)?K.agents.find(oe=>Y(oe)&&String(oe.agentId)===String(l)):void 0;D&&Y(ae)&&(D.scoreV2=ae.scoreV2??null),$e={...K,grantsPoolControl:!1,controlRule:"Off-chain /api/check identity or paymentWallet match never grants CreditPoolV2 control; on-chain isController(agentId, wallet) must authorize the caller; stale delegates do not qualify."}}return{chainId:$,blockNumber:d.number?.toString()??null,blockTimestamp:d.timestamp.toString(),wallet:o,token:ce,contracts:c,lender:{shares:r.toString(),grossAssets:b.toString(),earlyExitFeeAssets:h.toString(),netWithdrawAssets:I.toString(),lastDepositAt:p.toString(),withinMinHoldWindow:m,minHoldSeconds:He.toString()},hasFundedLine:P,agentId:l!==null?l.toString():null,nextStep:j,score:D,line:M,bond:W,starterLine:se,agent:v,activeLoans:_,lens:{address:c.lens,available:F,caveat:"PriorsLens.available(agentId) is a status capacity hint for already-funded lines; backer hooks may still refuse borrows."},stockVault:{address:c.stockVault,borrowRoom:k,onchainAssetCount:w.length,hostedMcpStockCount:35,extraNonStockAsset:B(Qt),zeroCapAssets:en.map(q=>B(q)),caveat:"Use priors_stock_assets and priors_stock_asset_state for current collateral rules, then priors_stock_open. This summary is an observed asset-count snapshot, not a fixed allowlist; live caps, lending holds and prices control admission."},apiCheck:$e,limitations:["Borrowing and repayment require a sponsor-backed ERC-8004 credit line (enrolled && !isRoot && sponsor != 0) authorized on-chain by isController(agentId, wallet).","Priors line routes are exposed by priors_line_options and priors_capabilities: treasury starter, V5 move/raise, direct sponsor, stock and owner PRIORS backing. Ethos execution uses Priors own owner workflow because its worker supplies no unsigned final transaction.","score.onchain is the pool's on-chain score (CreditLensV2); score.scoreV2 is Priors Score v2 from /api/check, present only with includeApiCheck.","Loan debt is the principal plus the origination fee the pool quotes for the term. The fee is pro-rated by term, not flat (1666 base units for 5 USDG over 1 day, observed live 2026-10-31; priors_borrow shows the exact quote), and is fixed once the loan opens: variable interest is never invented, and early repayment refunds none of it.","Loan IDs are recovered from decoded Borrowed receipts or per-agent loansOf(agentId), never global loanCount().","Historical archive event queries and zero-position StockVault lines on public RPCs remain subject to archive retention and live backer state."]}}},A=n=>`${e.formatAmount(n.toString(),N)} USDG`;function L(n){let s=V(n.bond.depositor,n.owner)&&n.bond.amount>0n?n.bond.amount:n.bondAmount;return`Bond first: ${A(s)} is locked in Priors' InviteBond for at least ${n.unusedAfter} seconds (${Number(n.unusedAfter)/86400} days) after posting${n.releaseAt>0n?`; unusedReleaseAt is ${G(n.releaseAt)}`:"; 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. `}function H(n,s,o){if(!V(o.owner,s))throw new a(`This wallet (${s}) does not own ERC-8004 agent ${n} (its owner is ${o.owner}). The bond, the ownership proof and the pool consent are the owner's. Nothing was signed.`);if(o.root!==Ie)throw new a(`TreasurySponsorV4 (${x}) answers root #${o.root}, not the pinned #${Ie}. Nothing was signed; update Oak.`);if(Pt(o.agent,o.firstLined))throw new a(`Agent #${n} already has a Priors record, so priors_starter_line posts no bond and signs nothing: ${It(e,o.agent,o.root,o.firstLined)}; ${o.agent.loansRepaid} loan(s) repaid. The starter line is only for an identity with no record; priors_status shows this one.`)}let ne="stays posted in InviteBond";function O(n){let s=n.agent.delegatedIn>0n?`with a line open it comes back only after priors_close_line (no loan open), then priors_release_bond from ${G(n.releaseAt)} at the earliest`:`while the agent holds no line it comes back with priors_release_bond from ${G(n.releaseAt)} (${Number(n.unusedAfter)/86400} days after it was posted)`;return`The ${A(n.bond.amount>0n?n.bond.amount:n.bondAmount)} bond ${ne} (${C}), posted from this wallet; ${s}, and priors_starter_line never posts a second bond.`}async function J(n,s,o){try{return await o()}catch(t){let r=t instanceof a?t.message:e.plainError(t);if(r.includes(ne)||n===void 0||!/^[0-9]{1,78}$/.test(n))throw t;let p;try{let d=await he(e,BigInt(n),s);p=V(d.bond.depositor,s)?O(d):""}catch{p=`If the bond transactions mined, the invite bond ${ne} (${C}) remains locked until its on-chain release conditions are met; priors_status shows the exact amount and time (its state could not be read just now).`}throw p?new a(`${r} ${p}`):t}}async function ge(n,s,o){let t=at(await Xe(e,{agentId:n}),{agentId:n,owner:s,now:ue()});if(!t.ok&&t.refused)throw new a(`Priors' invite bot gave no ownership proof to sign for agent #${n}: ${be(t.why)}. Nothing was signed. ${o}`.trim());if(!t.ok)throw new a(`Not signed: the invite bot's answer for agent #${n} is not one Oak signs: ${t.why}. Oak signs only the bot's own start-page text, rebuilt locally for this agent and this wallet. ${o}`.trim());if(t.exp-ue()<120)throw new a(`Not signed: the invite bot's proof for agent #${n} expires in under 2 minutes; call priors_starter_line again for a new one. ${o}`.trim());return t}function Z(n,s,o,t){return{steps:[{kind:"message",message:o.message}],continuation:{stage:"proof",wallet:s,chainId:$,agentId:n,n:o.n,exp:o.exp},summary:`${L(t)}Priors starter line for ERC-8004 agent ${n}, step 2 of 3: sign Priors' invite-bot ownership proof. It is a message signature (EIP-191) only: it sends no transaction and moves no funds. The text is the bot's own form, rebuilt locally for agent #${n} and this wallet, request ${o.n}, expiring ${G(o.exp)}. Oak then sends the signature to ${me}, and the bot decides the invite. ${O(t)}`}}function re(n,s,o){if(n.chainId!==$||typeof n.wallet!="string"||!V(n.wallet,s)||typeof n.agentId!="string"||!/^[1-9][0-9]{0,29}$/.test(n.agentId))throw new a("Priors starter-line continuation does not match this wallet or chain 4663; start priors_starter_line again.");if(o.agentId!==void 0&&String(o.agentId)!==n.agentId)throw new a("Priors starter-line continuation is for another agent; start priors_starter_line again.");return BigInt(n.agentId)}async function Te(n,s){let o;if(n.agentId!==void 0&&n.agentId!==null&&String(n.agentId).trim()!=="")o=pe(n.agentId,"agentId");else{let l=await _e(e,s);if(!l.length)throw new a(`Priors' starter line needs an ERC-8004 agent identity, and this wallet owns none. ${Ye}`);o=l[0]}let t=await he(e,o,s);H(o,s,t);let r=o.toString(),p=V(t.bond.depositor,s);if(!p){if(t.usdg<t.bondAmount)throw new a(`This wallet holds ${A(t.usdg)} on Robinhood Chain, and Priors' treasury invite asks a ${A(t.bondAmount)} bond first (InviteBond ${C}), posted from this wallet. Nothing was signed: add USDG, then call priors_starter_line again.`);if(t.epochRoom<t.firstLineAmount)return{summary:`${L(t)}Not submitted. Priors' treasury has ${A(t.epochRoom)} of room left this week and a first line is ${A(t.firstLineAmount)}, so priors_starter_line posted no bond and signed nothing. The treasury caps new lines each week: ask again next week.`,starterLine:{agentId:r,open:!1,reason:"room",epochRoom:t.epochRoom.toString()}};let l=await Xe(e,{check:!0,owner:s.toLowerCase()});if(l.check!==!0)throw new a("Priors' invite bot did not answer its check, so whether an invite is open cannot be told. Nothing was signed.");if(l.ok!==!0)throw new a(`Whether an automatic invite is open could not be told: Priors' invite bot says ${be(l.error)}. Nothing was signed; try again later.`);if(l.open!==!0){let v=typeof l.reason=="string"?l.reason.replace(/[^a-z-]/g,"").slice(0,24):"",P=typeof l.reopensAt=="number"&&Number.isSafeInteger(l.reopensAt)&&l.reopensAt>0?l.reopensAt:null;return{summary:`${L(t)}Not submitted. No automatic invite is open to this wallet right now, so priors_starter_line posted no bond and signed nothing. Priors' invite bot answers: closed, reason ${Ee(v||"none given")}${P?`, reopens ${G(P)}`:""}. ${dt({...l,reason:v})} Priors lists its other ways to a first line (the Ethos lane, a stock line, the owner's $PRIORS stake) at https://priors.trade/skill.md.`,starterLine:{agentId:r,open:!1,reason:v||null,reopensAt:P}}}}let d=await ge(r,s,p?O(t):"");if(p)return Z(r,s,d,t);let w=[e.approval(c.usdg,C,t.bondAmount.toString(),$),e.unsignedTx({to:C,data:X({abi:U,functionName:"deposit",args:[o]}),value:"0",chainId:$,description:`Post the ${t.bondAmount} USDG base-unit Priors invite bond for agent ${r} in InviteBond (${C}).`})],b=await e.preview(w,s),m=t.bond.depositor!==Je?` This deposit replaces the bond ${t.bond.depositor} posted for this agent; InviteBond returns that bond to it in the same transaction.`:"",h=`${L(t)}Priors starter line for ERC-8004 agent ${r}, step 1 of 3: approve exactly ${A(t.bondAmount)} to Priors' InviteBond (${C}) and post it as the agent's refundable invite bond (InviteBond.deposit).${m} Priors' invite bot says an automatic invite is open now and gave the ownership proof to sign next. Step 2 signs that proof (a message, no transaction); step 3 signs your pool consent and redeems the invite (TreasurySponsorV4.firstLine, ${x}) for a ${A(t.firstLineAmount)} line from Priors' treasury (root #${t.root}). The invite is the bot's decision, not a promise: if it refuses, or any later step fails, the bond stays posted and comes back with priors_release_bond after the on-chain lock and release conditions are met. With a line, the bond comes back only once the line is closed with no loan open (priors_close_line, then priors_release_bond); a default forfeits it to Priors' Safe.`;return{steps:w.map(l=>({kind:"tx",tx:l})),continuation:{stage:"bond",wallet:s,chainId:$,agentId:r,n:d.n,exp:d.exp},summary:te(e,h,b.changes)}}async function Rt(n,s,o){let t=await he(e,n,s);H(n,s,t);let r=n.toString();if(!V(t.bond.depositor,s))throw new a(`The invite bond for agent #${r} is not on chain from this wallet, so nothing more was signed. Check the deposit transaction, then call priors_starter_line again.`);return typeof o.n=="string"&&Ve.test(o.n)&&typeof o.exp=="number"&&Number.isSafeInteger(o.exp)&&o.exp-ue()>=300?Z(r,s,{n:o.n,exp:o.exp,message:Me(r,o.n,o.exp)},t):Z(r,s,await ge(r,s,O(t)),t)}async function _t(n,s,o,t){let r=n.toString();if(typeof o.n!="string"||!Ve.test(o.n)||typeof o.exp!="number"||!Number.isSafeInteger(o.exp))throw new a("Invalid Priors starter-line proof continuation; start priors_starter_line again.");if(typeof t!="string"||!/^0x[0-9a-fA-F]{130}$/.test(t))throw new a("Provide this wallet's signature of the invite bot's ownership proof.");if(o.exp<=ue())throw new a(`The invite bot's proof for agent #${r} expired before it reached the bot; nothing was sent to it. Call priors_starter_line again for a fresh proof (the bond is not posted again).`);let p=Me(r,o.n,o.exp);if(!V(await Yt({message:p,signature:t}),s))throw new a("The ownership-proof signature is not this wallet's; nothing was sent to the invite bot.");let d=await he(e,n,s);if(H(n,s,d),!V(d.bond.depositor,s))throw new a(`The invite bond for agent #${r} is not on chain from this wallet; nothing was sent to the invite bot. Call priors_starter_line again.`);let w=await Xe(e,{n:o.n,signature:t});if(w.ok!==!0)throw new a(`Priors' invite bot gave no invite for agent #${r}: ${be(w.error)}. ${O(d)}`);if(typeof w.code!="string")throw new a(`Priors' invite bot gave no invite for agent #${r}${w.reason?`: ${be(w.reason)}`:""}${typeof w.decided=="string"?` (its decision: ${be(w.decided)})`:""}. ${O(d)}`);let b=qe(w.code,r,ue()+60);if(!b.ok)throw new a(`Priors' invite bot's code for agent #${r} is not one Oak redeems: ${b.why}. Nothing more was signed. ${O(d)}`);let m=e.clientFor($),h=await m.readContract({address:x,abi:E,functionName:"inviteDigest",args:[n,b.expiry]});if(h.toLowerCase()!==st(n,b.expiry).toLowerCase())throw new a("TreasurySponsorV4's invite digest differs from its pinned EIP-712 domain; nothing more was signed. Update Oak.");let I=await Xt({hash:h,signature:b.signature}),[l,v]=await Promise.all([m.readContract({address:x,abi:E,functionName:"inviters",args:[I]}),m.readContract({address:x,abi:E,functionName:"inviteUsed",args:[h]})]);if(l!==!0)throw new a(`Priors' invite for agent #${r} was signed by ${I}, which TreasurySponsorV4 does not name an inviter, so the treasury would refuse it. Nothing more was signed. ${O(d)}`);if(v===!0)throw new a(`Priors' invite for agent #${r} was already used. Nothing more was signed. ${O(d)}`);let[P,_]=await Promise.all([m.readContract({address:c.pool,abi:S,functionName:"nonces",args:[n]}),m.getBlock()]),F=_.timestamp+BigInt(it),k=Fe({agentId:r,owner:s,nonce:P.toString(),deadline:F.toString()}),D=await m.readContract({address:c.pool,abi:S,functionName:"consentDigest",args:[{agentId:n,sponsorId:d.root,owner:s,maxPremiumBps:0n,nonce:P,deadline:F}]});if(D.toLowerCase()!==rt(k).toLowerCase())throw new a(`The pool's consentDigest (${D}) differs from the consent Oak builds for CreditPoolV2 (${c.pool}), so the pool would refuse it. Nothing more was signed. ${O(d)}`);return{steps:[{kind:"typedData",request:k}],continuation:{stage:"consent",wallet:s,chainId:$,agentId:r,invite:w.code,request:k},summary:`Priors starter line for ERC-8004 agent ${r}, step 3 of 3: Priors' invite bot gave an invite (signed by ${I}, an inviter TreasurySponsorV4 names; it expires ${G(b.expiry)}). Sign your pool consent (EIP-712 "Priors Credit" version 2 on CreditPoolV2 ${c.pool}): it lets Priors' treasury (root #${d.root}) back a line for agent #${r} with premium 0, nonce ${P}, valid until ${G(F)}. A transaction redeeming the invite (TreasurySponsorV4.firstLine) follows for your confirmation. ${O(d)}`}}async function kt(n,s,o,t){let r=n.toString();if(typeof t!="string"||!/^0x[0-9a-fA-F]{130}$/.test(t))throw new a("Provide this wallet's signature of the Priors pool consent.");let p=qe(o.invite,r,ue()+60);if(!p.ok)throw new a(`The invite for agent #${r} is not one Oak redeems now: ${p.why}. Call priors_starter_line again for a new one.`);let d=Y(o.request)&&Y(o.request.message)?o.request.message:void 0;if(!d||typeof d.nonce!="string"||!/^[0-9]{1,78}$/.test(d.nonce)||typeof d.deadline!="string"||!/^[0-9]{1,20}$/.test(d.deadline))throw new a("Invalid Priors starter-line consent continuation; start priors_starter_line again.");let w=Fe({agentId:r,owner:s,nonce:d.nonce,deadline:d.deadline});if(!V(await Zt({...w,signature:t}),s))throw new a("The pool-consent signature is not this wallet's for the consent Oak built; nothing was offered.");let b=await he(e,n,s);H(n,s,b);let m=e.clientFor($),[h,I]=await Promise.all([m.readContract({address:c.pool,abi:S,functionName:"nonces",args:[n]}),m.getBlock()]);if(h.toString()!==d.nonce)throw new a(`Agent #${r}'s consent nonce moved on chain since it was signed; nothing was offered. Call priors_starter_line again.`);if(I.timestamp>=BigInt(d.deadline))throw new a(`The pool consent for agent #${r} expired at ${G(BigInt(d.deadline))}; nothing was offered. Call priors_starter_line again.`);let l={agentId:n,sponsorId:Ie,owner:s,maxPremiumBps:0n,nonce:h,deadline:BigInt(d.deadline)},v=[n,p.expiry,p.signature,l,t];try{await m.simulateContract({address:x,abi:E,functionName:"firstLine",args:v,account:s})}catch(k){throw new a(`TreasurySponsorV4.firstLine for agent #${r} would be refused: ${an(e,k)} Nothing was offered. ${O(b)}`)}let P=e.unsignedTx({to:x,data:X({abi:E,functionName:"firstLine",args:v}),value:"0",chainId:$,description:`Redeem Priors' invite for agent ${r}: TreasurySponsorV4.firstLine opens a ${b.firstLineAmount} USDG base-unit line from root ${b.root} with the owner's consent.`}),_=await e.preview([P],s),F=`Redeem agent #${r}'s Priors invite: TreasurySponsorV4.firstLine (${x}) opens a ${A(b.firstLineAmount)} line from Priors' treasury (root #${b.root}) with your signed consent. No USDG moves in this transaction. Then priors_status shows the line and priors_borrow draws it (5 USDG minimum; the fee is pro-rated by term; Priors counts loans held 7 days or more toward the score). The ${A(b.bondAmount)} bond stays in InviteBond until the line is closed with no loan open (priors_close_line, then priors_release_bond, from ${G(b.releaseAt)} at the earliest); a default forfeits it.`;return{txs:[P],summary:te(e,F,_.changes)}}let Dt={name:"priors_starter_line",inputSchema:{description:"Bond first: the launch bond is 5 USDG, locked at least 4 days. The first result reads amount(), unusedAfter() and unusedReleaseAt(agentId) for current terms before any approval. Invites are not guaranteed; the credit score can lag. Release needs no line or open loan; default can forfeit the bond.",type:"object",additionalProperties:!1,properties:{agentId:Pe("ERC-8004 agent ID this wallet owns, with no Priors record yet (default: the first identity this wallet owns)."),continuation:{type:"object"},signature:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$"}}},async execute(n,s){z(s);let o=B(s);if(n.continuation===void 0){if(n.signature!==void 0)throw new a("A signature needs its Priors starter-line continuation; start priors_starter_line again.");return J(typeof n.agentId=="string"?n.agentId:void 0,o,()=>Te(n,o))}if(!Y(n.continuation))throw new a("Invalid Priors starter-line continuation; start priors_starter_line again.");let t=n.continuation,r=re(t,o,n),p=d=>J(r.toString(),o,d);if(t.stage==="bond"){if(n.signature!==void 0)throw new a("The bond stage takes no signature; start priors_starter_line again.");return p(()=>Rt(r,o,t))}if(t.stage==="proof")return p(()=>_t(r,o,t,n.signature));if(t.stage==="consent")return p(()=>kt(r,o,t,n.signature));throw new a("Unknown Priors starter-line stage; start priors_starter_line again.")}},Tt={name:"priors_close_line",inputSchema:{type:"object",properties:{agentId:Pe("ERC-8004 agent ID whose Priors line to close (default: the first identity this wallet owns).")}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o);await ze(e,t,o);let r=e.clientFor($),[p,d,w,b]=await Promise.all([r.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[t]}),r.readContract({address:C,abi:U,functionName:"bonds",args:[t]}),r.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[t]}),r.readContract({address:x,abi:E,functionName:"agentId"})]),m=we(p);if(m.sponsor===0n)throw new a(`Agent #${t} has no Priors line to close (no sponsor on CreditPoolV2).`);if(m.activeLoans>0n)throw new a(`Agent #${t} has ${m.activeLoans} loan(s) open; repay them with priors_repay first. The pool's leave refuses while a loan is open.`);let h=ye(d),I=m.sponsor===BigInt(b),l=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"leave",args:[t]}),value:"0",chainId:$,description:`Close agent ${t}'s Priors line on CreditPoolV2 (leave): the ${m.delegatedIn} USDG base-unit line returns to root ${m.sponsor}.`}),v=await e.preview([l],o),P=V(h.depositor,o)?` Its ${A(h.amount)} invite bond can then come back with priors_release_bond from ${G(w)} (4 days after it was posted).`:"",_=`Close agent #${t}'s Priors line (CreditPoolV2.leave, ${c.pool}): the whole ${A(m.delegatedIn)} line goes back to its backer (${I?`Priors' treasury, root #${b}`:`root #${m.sponsor}`}) and the agent can no longer borrow on it. This does not reopen: ${I?`priors_starter_line opens no second treasury line for an agent with a Priors record; another needs a person at ${Ge}.`:"a new line needs a backer's new consent."}${P} No USDG moves in this transaction.`;return{txs:[l],summary:te(e,_,v.changes)}}},Bt={name:"priors_release_bond",inputSchema:{type:"object",properties:{agentId:Pe("ERC-8004 agent ID whose InviteBond bond this wallet posted (default: the first identity this wallet owns).")}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o),r=e.clientFor($),[p,d,w,b,m]=await Promise.all([r.readContract({address:C,abi:U,functionName:"bonds",args:[t]}),r.readContract({address:C,abi:U,functionName:"releasable",args:[t]}),r.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[t]}),r.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[t]}),r.getBlock()]),h=ye(p);if(h.depositor===Je)throw new a(`Agent #${t} has no bond in Priors' InviteBond (${C}).`);if(!V(h.depositor,o))throw new a(`Agent #${t}'s InviteBond bond was posted by ${h.depositor}, not this wallet, and InviteBond.release pays the depositor. Oak releases only a bond this wallet posted.`);if(d!==!0){let P=we(b),_=P.defaulted?"the agent defaulted, so the bond is forfeited to Priors' Safe (InviteBond.slash)":P.activeLoans>0n?`the agent has ${P.activeLoans} loan(s) open: repay with priors_repay, close the line with priors_close_line, then release`:P.delegatedIn>0n?`the agent still holds a ${A(P.delegatedIn)} line: close it with priors_close_line (no loan may be open), then release`:m.timestamp<w?`it comes back 4 days after it was posted, from ${G(w)}`:"InviteBond does not release it yet";throw new a(`Agent #${t}'s ${A(h.amount)} invite bond cannot be released now: ${_}. Nothing was signed.`)}let I=e.unsignedTx({to:C,data:X({abi:U,functionName:"release",args:[t]}),value:"0",chainId:$,description:`Release agent ${t}'s ${h.amount} USDG base-unit Priors invite bond from InviteBond (${C}) to its depositor ${h.depositor}.`}),l=await e.preview([I],o),v=`Release agent #${t}'s ${A(h.amount)} invite bond from Priors' InviteBond (${C}): InviteBond.release returns it to its depositor, this wallet (${o}).`;return{txs:[I],summary:te(e,v,l.changes)}}};async function Nt(n){z(n);let s=B(n),o=e.clientFor($),[t,r]=await Promise.all([o.readContract({address:c.pool,abi:S,functionName:"shares",args:[s]}),_e(e,s)]),p=[];if(t>0n){let d=await o.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[t]});p.push({module:"priors",id:`priors:lender:${s.toLowerCase()}`,chainId:$,assets:[{token:ce,amount:d.toString()}],description:`Priors CreditPoolV2 lender position (${t} shares = ${e.formatAmount(d.toString(),N)} USDG gross).`})}for(let d of r){let w=await o.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[d]}),b=await Promise.all(w.map(async h=>{let I=await o.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[h]});return Ce(h,I)}));for(let h of b)if(h.agentId===d&&h.status===1){let I=h.principal+h.fee;p.push({module:"priors",id:`priors:loan:${h.loanId.toString()}`,chainId:$,assets:[{token:ce,amount:I.toString()}],description:`Priors CreditPoolV2 active loan ${h.loanId} for agent ${d} (fixed due ${e.formatAmount(I.toString(),N)} USDG = ${h.principal} principal + ${h.fee} fee).`})}let m=ye(await o.readContract({address:C,abi:U,functionName:"bonds",args:[d]}));m.amount>0n&&V(m.depositor,s)&&p.push({module:"priors",id:`priors:bond:${d.toString()}`,chainId:$,assets:[{token:ce,amount:m.amount.toString()}],description:`Priors invite bond for agent ${d} in InviteBond (${C}): ${A(m.amount)}, back with priors_release_bond once the agent holds no line and no loan, from 4 days after posting; a default forfeits it.`})}return p}return{tools:[i,g,u,f,R,Dt,Tt,Bt],positions:Nt}},ln=e=>{let i=dn(e),g=[i,lt(e),ct(e),pt(e),gt(e),ft(e),mt(e),ut()];return{...i,tools:g.flatMap(u=>u.tools)}},_n=e=>Qe("priors",[ln(e)]);export{Kt as a,He as b,bt as c,wt as d,We as e,yt as f,je as g,$t as h,c as i,ce as j,on as k,ln as l,_n as m};
@@ -1 +0,0 @@
1
- import{i as G}from"./FUXT7GRK.js";import{b as j,c as V,d as W}from"./JPOYTTTW.js";import{d as ae,e as L}from"./5O5ZE3ZV.js";import{a as N}from"./CY75R4FK.js";import{a as v}from"./6IM6A5VA.js";import{a as R,b as ie,c as se,d as U}from"./RETS2ZEK.js";import{a as S,i as x}from"./G6HCV67X.js";import{a as o}from"./5YS5V2LK.js";import{decodeEventLog as He,encodeAbiParameters as fe,encodeFunctionData as ye,erc20Abi as Q,getAddress as l,isAddress as $,keccak256 as $e,parseAbi as Ee,parseAbiParameters as pe,toEventSelector as we}from"viem";var A=l(x[4663].hookr.HookrLimitOrders.address),_e=l(x[4663].hookr.HookrRoot.address),ve=l(x[4663].hookr.HookrRouter.address),kt=l(x[4663].hookr.HookrRegistry.address),Ne=l(x[4663].hookr.HookrForwarder.address),Be=l(x[4663].hookr.PoolManager.address),Ot=l(x[4663].hookr.HOOKR_Token.address),Fe=l("0x000000000000000000000000000000000000dEaD"),Me=8388608,ze=200,de=60n,qe=604800n,ce=31536000n,It=10,At=100,ht="500000000000000",St="10000000000000000",ue=4096n,Y=32n,Xe=1e4,Ke=(1n<<127n)-1n,me=(1n<<128n)-1n,Ue=(1n<<160n)-1n,je=(1n<<40n)-1n,Ve=16777215,We=8388607,le=1n<<192n,J=0,F=1,Ge=2,Ye=3,Qe=we("OrderCreated(uint256,address,bytes32,bool,uint128,uint128,uint128,uint40,address)"),Ct=we("OrderCancelled(uint256,address,address,uint256,uint256)"),D=Ee(["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 createOrder(((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut, uint160 sqrtPriceLimitX96, address recipient, uint40 expiry, uint128 bounty) params) payable returns (uint256 orderId)","function cancel(uint256 orderId, address to)","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 lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)","function router() view returns (address)","function registry() view returns (address)","function poolManager() view returns (address)","function forwarder() view returns (address)","event OrderCreated(uint256 indexed orderId, address indexed owner, bytes32 indexed poolId, bool zeroForOne, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint40 expiry, address recipient)","event OrderCancelled(uint256 indexed orderId, address indexed owner, address indexed to, uint256 amountIn, uint256 bounty)"]);function B(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ge(e){let t=e.toLowerCase();return t===L.toLowerCase()||t===N.toLowerCase()||t===ae.toLowerCase()}function H(e,t){if(typeof e!="string"||!e.trim())throw new o(`Provide a valid contract address for ${t}. Identify tokens by chain and address, never by symbol.`);let n=e.trim();if(!$(n,{strict:!1}))throw new o(`Invalid token address "${n}" for ${t}. Identify tokens by chain and address, never by symbol.`);return ge(n)?L:l(n)}function be(e){let t=e===void 0?S:Number(e);if(!Number.isSafeInteger(t)||t!==S)throw new o(`Hookr limit orders are only supported on Robinhood Chain (${S}).`);return S}function Ze(e){switch(e){case J:return"None";case F:return"Open";case Ge:return"Filled";case Ye:return"Cancelled";default:return"Unknown"}}function Je(e,t,n=se){if(typeof e!="string"||!/^-?\d+$/.test(e.trim()))throw new o("Signed amount must be an integer string in base units.");let r=e.trim();if(r.startsWith("-")){let i=r.slice(1),u=n(i,t);return u==="0"?"0":`-${u}`}return n(r,t)}function xt(e,t,n="floor"){return ie(e,t,n)}function ke(e){return $e(fe(pe("address, address, uint24, int24, address"),[l(e.currency0),l(e.currency1),e.fee,e.tickSpacing,l(e.hooks)]))}function Oe(e,t){let n=e.toLowerCase();if(new Set([L.toLowerCase(),Fe.toLowerCase(),A.toLowerCase(),ve.toLowerCase(),Ne.toLowerCase(),Be.toLowerCase(),t.toLowerCase()]).has(n))throw new o(`Recipient ${e} is a reserved address and cannot receive Hookr limit order funds.`)}async function Z(e,t,n,r){if(ge(e))return{address:N,symbol:j.symbol,decimals:j.decimals,chainId:t};let i=l(e),u=i.toLowerCase();if(B(r)){let s=typeof r.decimals=="number"&&Number.isInteger(r.decimals)&&r.decimals>=0&&r.decimals<=255?r.decimals:void 0,a=typeof r.symbol=="string"&&r.symbol.trim()?r.symbol.trim():void 0;if(s!==void 0&&a!==void 0)return{address:i,symbol:a,decimals:s,chainId:t}}if(u===V.address.toLowerCase())return{...V,chainId:t};if(u===W.address.toLowerCase())return{...W,chainId:t};try{let[s,a]=await Promise.all([n.readContract({address:i,abi:Q,functionName:"symbol"}),n.readContract({address:i,abi:Q,functionName:"decimals"})]);if(typeof s!="string"||!s.trim()||typeof a!="number"||!Number.isInteger(a)||a<0||a>255)throw new o(`Invalid token metadata for ${i}.`);return{address:i,symbol:s.trim(),decimals:a,chainId:t}}catch{throw new o(`Could not read valid token metadata for ${i}. Refusing to guess token decimals.`)}}function et(e){let t=B(e.key)?e.key:B(e.poolKey)?e.poolKey:void 0,n=t?.fee??e.fee??Me,r=(typeof n=="string"&&/^\d+$/.test(n),Number(n));if(!Number.isInteger(r)||r<0||r>Ve)throw new o("Pool fee must be a valid uint24 integer (default 8388608 for Hookr dynamic fee pools).");let i=t?.tickSpacing??e.tickSpacing??ze,u=(typeof i=="string"&&/^-?\d+$/.test(i),Number(i));if(!Number.isInteger(u)||u<=0||u>We)throw new o("Pool tickSpacing must be a positive int24 integer.");let s=t?.hooks??e.hooks??_e;if(typeof s!="string"||!$(s,{strict:!1}))throw new o("Provide a valid Hookr root contract address for hooks.");let a=l(s);if(t?.currency0!==void 0&&t?.currency1!==void 0||e.currency0!==void 0&&e.currency1!==void 0){let m=H(t?.currency0??e.currency0,"currency0"),I=H(t?.currency1??e.currency1,"currency1");if(m.toLowerCase()===I.toLowerCase())throw new o("Pool currency0 and currency1 must be distinct token addresses.");if(BigInt(m)>=BigInt(I))throw new o("Pool currency0 must sort strictly before currency1 by address.");let k;if(typeof e.zeroForOne=="boolean")k=e.zeroForOne;else if(e.tokenIn!==void 0||e.from!==void 0){let C=H(e.tokenIn??e.from,"tokenIn");if(C.toLowerCase()===m.toLowerCase())k=!0;else if(C.toLowerCase()===I.toLowerCase())k=!1;else throw new o("tokenIn does not match currency0 or currency1 of the pool key.")}else throw new o("Provide zeroForOne (boolean) or tokenIn when specifying a pool key.");return{key:{currency0:m,currency1:I,fee:r,tickSpacing:u,hooks:a},zeroForOne:k}}let w=e.tokenIn??e.from,f=e.tokenOut??e.to;if(w===void 0||f===void 0)throw new o("Provide either key ({ currency0, currency1, fee, tickSpacing, hooks }) with zeroForOne or tokenIn and tokenOut addresses.");let g=H(w,"tokenIn"),b=H(f,"tokenOut");if(g.toLowerCase()===b.toLowerCase())throw new o("Input and output tokens must have distinct addresses.");let y=BigInt(g)<BigInt(b),p=y?g:b,d=y?b:g;if(typeof e.zeroForOne=="boolean"&&e.zeroForOne!==y)throw new o("zeroForOne conflicts with the canonical sorting of tokenIn and tokenOut.");return{key:{currency0:p,currency1:d,fee:r,tickSpacing:u,hooks:a},zeroForOne:y}}function tt(e,t,n){let r=G(t),i=r*r;if(n){let s=U(e.toString(),i.toString(),le.toString(),"ceil");return BigInt(s)}let u=U(e.toString(),le.toString(),i.toString(),"ceil");return BigInt(u)}function T(e,t){if(typeof e=="bigint"){if(e<0n)throw new o(`${t} must be a non-negative integer.`);return e}if(typeof e=="number"){if(!Number.isSafeInteger(e)||e<0)throw new o(`${t} must be a non-negative safe integer.`);return BigInt(e)}if(typeof e=="string")return R(e.trim());throw new o(`Provide ${t} as a decimal base-unit string.`)}async function nt(e,t){if(t!==void 0)return T(t,"now");if(typeof e.getBlock=="function"){let n=await e.getBlock().catch(()=>{throw new o("Could not read the chain timestamp for Hookr order expiry.")});return BigInt(n.timestamp)}throw new o("Could not read the chain timestamp for Hookr order expiry.")}function Ie(e,t){return!e.changes||e.changes.length===0?"no net ERC-20 transfer deltas":e.changes.map(n=>`${Je(n.amount,n.token.decimals,t.formatAmount)} ${n.token.symbol}`).join(", ")}function ot(e,t,n,r){if(!e||!Array.isArray(e.logs))throw new o("Provide a transaction receipt with a logs array.");for(let i of e.logs){if(!i||typeof i.address!="string"||!$(i.address,{strict:!1})||!Array.isArray(i.topics)||typeof i.data!="string"||i.topics.some(u=>typeof u!="string"||!/^0x[0-9a-fA-F]{64}$/.test(u)))throw new o(`Malformed Hookr ${t} receipt log.`);if(i.address.toLowerCase()===A.toLowerCase()&&i.topics[0]?.toLowerCase()===n.toLowerCase()){if(i.topics.length!==4||!/^0x0{24}/i.test(i.topics[2])||t==="OrderCancelled"&&!/^0x0{24}/i.test(i.topics[3])||!/^0x[0-9a-fA-F]*$/.test(i.data)||i.data.length!==2+r*64)throw new o(`Malformed Hookr ${t} receipt log.`);return{topics:i.topics,data:i.data}}}throw new o(`Could not find Hookr ${t} event in transaction receipt logs.`)}function Ae(e){if(e.receipt!==void 0){if(!B(e.receipt)||!Array.isArray(e.receipt.logs))throw new o("Provide a transaction receipt with a logs array.");return it({logs:e.receipt.logs})}if(e.logs!==void 0){if(!Array.isArray(e.logs))throw new o("Provide receipt logs as an array.");return rt(e.logs)}}function he(e){let t=ot(e,"OrderCreated",Qe,6);try{let n=He({abi:D,eventName:"OrderCreated",...t,strict:!0});if(fe(pe("bool, uint128, uint128, uint128, uint40, address"),[n.args.zeroForOne,n.args.amountIn,n.args.minAmountOut,n.args.bounty,n.args.expiry,n.args.recipient]).toLowerCase()!==t.data.toLowerCase())throw new o("Noncanonical Hookr OrderCreated event data.");return{orderId:n.args.orderId.toString(),owner:l(n.args.owner),poolId:n.args.poolId,zeroForOne:n.args.zeroForOne,amountIn:n.args.amountIn.toString(),minAmountOut:n.args.minAmountOut.toString(),bounty:n.args.bounty.toString(),expiry:n.args.expiry.toString(),recipient:l(n.args.recipient)}}catch{throw new o("Malformed Hookr OrderCreated receipt log.")}}function rt(e){return he({logs:e}).orderId}function it(e){return he(e).orderId}function Se(e){if(Array.isArray(e)){let[n,r,i,u,s,a,c,w,f,g,b]=e;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:r,createdAt:i,expiry:u,zeroForOne:s,status:a,recipient:c,amountIn:BigInt(w),minAmountOut:BigInt(f),bounty:BigInt(g),sqrtPriceLimitX96:BigInt(b)}}let t=e;return{key:{currency0:t.key.currency0,currency1:t.key.currency1,fee:Number(t.key.fee),tickSpacing:Number(t.key.tickSpacing),hooks:t.key.hooks},owner:t.owner,createdAt:t.createdAt,expiry:t.expiry,zeroForOne:!!t.zeroForOne,status:Number(t.status),recipient:t.recipient,amountIn:BigInt(t.amountIn),minAmountOut:BigInt(t.minAmountOut),bounty:BigInt(t.bounty),sqrtPriceLimitX96:BigInt(t.sqrtPriceLimitX96)}}async function Ce(e,t,n){let r=T(t,"orderId");if(r<=0n)throw new o("Order ID must be a positive integer.");let i=e.clientFor(S),u=n?.order??await i.readContract({address:A,abi:D,functionName:"getOrder",args:[r]}).catch(()=>{throw new o(`Could not read Hookr order #${r}. Order coverage is incomplete.`)}),s=Se(u),a=Number(s.status);if(s.owner.toLowerCase()===L.toLowerCase()||a===J)throw new o(`Hookr order #${r} does not exist.`);let c={currency0:l(s.key.currency0),currency1:l(s.key.currency1),fee:Number(s.key.fee),tickSpacing:Number(s.key.tickSpacing),hooks:l(s.key.hooks)},w=s.zeroForOne?c.currency0:c.currency1,f=s.zeroForOne?c.currency1:c.currency0,g=m=>{let I=m.toLowerCase(),k=n?.tokens.get(I);if(k)return k;let C=Z(m,S,i);return n?.tokens.set(I,C),C},[b,y]=await Promise.all([g(w),g(f)]),p=!1,d=0n;if(a===F)try{let m=await i.readContract({address:A,abi:D,functionName:"quoteFill",args:[r]});if(typeof m[0]!="boolean"||typeof m[1]!="bigint"||m[1]<0n)throw new o(`Invalid quote for Hookr order #${r}.`);p=m[0],d=m[1]}catch{throw new o(`Could not quote Hookr order #${r}. Fillability and output amount are unknown.`)}return{orderId:r.toString(),poolId:ke(c),key:c,owner:l(s.owner),recipient:l(s.recipient),createdAt:BigInt(s.createdAt).toString(),expiry:BigInt(s.expiry).toString(),zeroForOne:s.zeroForOne,status:a,statusLabel:Ze(a),amountIn:s.amountIn.toString(),minAmountOut:s.minAmountOut.toString(),bounty:s.bounty.toString(),sqrtPriceLimitX96:s.sqrtPriceLimitX96.toString(),tokenIn:b,tokenOut:y,fillable:p,quotedAmountOut:d.toString()}}function st(e){return{name:"hookr_create",inputSchema:{type:"object",properties:{key:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},tokenIn:{type:"string",description:"Input token address on chain 4663."},tokenOut:{type:"string",description:"Output token address on chain 4663."},zeroForOne:{type:"boolean",description:"True when selling currency0 for currency1."},amountIn:{type:"string",description:"Input amount in base units (uint128)."},minAmountOut:{type:"string",description:"Minimum net output amount in base units (uint128)."},tick:{type:"number",description:"Optional limit tick in [-887272, 887272]."},expiry:{type:"string",description:"Order expiry unix timestamp in seconds (uint40)."},deadline:{type:"string",description:"Alias for expiry unix timestamp in seconds."},bounty:{type:"string",description:"Keeper bounty in native ETH wei (uint128)."},recipient:{type:"string",description:"Order output recipient address (must be the signing wallet)."},sqrtPriceLimitX96:{type:"string",description:"Optional sqrtPriceLimitX96 (defaults to 0)."},chainId:{type:"number",description:"Must be 4663 (Robinhood Chain)."}},required:["amountIn"]},async execute(t,n){v(n);let r=l(n),i=be(t.chainId),u=e.clientFor(i),s=Ae(t),{key:a,zeroForOne:c}=et(t),w=c?a.currency0:a.currency1,f=c?a.currency1:a.currency0,[g,b]=await Promise.all([Z(w,i,u,t.tokenInMeta),Z(f,i,u,t.tokenOutMeta)]),y=t.recipient??r;if(typeof y!="string"||!$(y,{strict:!1}))throw new o("Provide a valid recipient address for the Hookr limit order.");let p=l(y);if(Oe(p,a.hooks),p!==r)throw new o("Hookr recipient must be the signing wallet.");if(typeof t.amountIn!="string")throw new o("Provide amountIn as an integer string in base units.");let d=R(t.amountIn);if(d<=0n||d>Ke)throw new o("amountIn must be between 1 and int128.max base units.");if(t.tick!==void 0){let P=Number(t.tick);G(P)}let m;if(t.minAmountOut!==void 0){if(typeof t.minAmountOut!="string")throw new o("Provide minAmountOut as an integer string in base units.");m=R(t.minAmountOut)}else if(t.tick!==void 0)m=tt(d,Number(t.tick),c);else throw new o("Provide minAmountOut in base units (or tick to derive minAmountOut).");if(m<=0n||m>me)throw new o("minAmountOut must be between 1 and uint128.max base units.");let I=t.sqrtPriceLimitX96!==void 0?T(t.sqrtPriceLimitX96,"sqrtPriceLimitX96"):0n;if(I>Ue)throw new o("sqrtPriceLimitX96 exceeds uint160 bounds.");let k=await nt(u,t.now),C=t.expiry??t.deadline,O;if(C!==void 0)O=T(C,"expiry");else if(t.lifetime!==void 0||t.ttlSeconds!==void 0){let P=T(t.lifetime??t.ttlSeconds,"lifetime");O=k+P}else O=k+qe;if(O<k+de)throw new o(`Order expiry (${O}) is expired or below the minimum lifetime of ${de} seconds from block timestamp ${k}.`);if(O>k+ce||O>je)throw new o(`Order expiry (${O}) exceeds the maximum lifetime of ${ce} seconds (365 days).`);let M=await u.readContract({address:A,abi:D,functionName:"bountyBounds",args:[a,c,d,m]}).catch(()=>{throw new o("Could not read Hookr bounty bounds.")}),E=BigInt(M[0]),z=BigInt(M[1]),q=BigInt(M[2]);if(t.bounty!==void 0&&typeof t.bounty!="string")throw new o("Provide bounty as an integer string in base units.");let h=t.bounty!==void 0?R(t.bounty):z,X=E>0n?E:z;if(h<E||X>0n&&h<X)throw new o(`Order keeper bounty (${h} wei) is underbounty: must be at least ${X} wei (default keeper bounty floor).`);if(h>q||h>me)throw new o(`Order keeper bounty (${h} wei) exceeds the maximum allowed bounty of ${q} wei.`);let ee=w.toLowerCase()===L.toLowerCase(),_=[];if(!ee){let P;try{let K=await u.readContract({address:w,abi:Q,functionName:"allowance",args:[r,A]});if(typeof K!="bigint"||K<0n)throw new o("Invalid token allowance.");P=K}catch{throw new o(`Could not read token allowance for ${w}. No approval was prepared.`)}P<d&&_.push(e.approval(w,A,d.toString(),i))}let De=ee?d+h:h,Le=ye({abi:D,functionName:"createOrder",args:[{key:a,zeroForOne:c,amountIn:d,minAmountOut:m,sqrtPriceLimitX96:I,recipient:p,expiry:Number(O),bounty:h}]}),te=e.formatAmount(d.toString(),g.decimals),ne=e.formatAmount(m.toString(),b.decimals),oe=e.formatAmount(h.toString(),18),Pe=e.unsignedTx({to:A,data:Le,value:De.toString(),chainId:i,description:`Create Hookr limit order on ${A}: sell ${te} ${g.symbol} (${g.address}) for at least ${ne} ${b.symbol} (${b.address}) with ${oe} ETH keeper bounty (fee=${a.fee}, tickSpacing=${a.tickSpacing}, expiry=${O}).`});_.push(Pe);let re=await e.preview(_,r),Te=Ie(re,e),Re=ke(a);return{txs:_,summary:`Hookr limit order prepared: sell ${te} ${g.symbol} for at least ${ne} ${b.symbol} (bounty ${oe} ETH, expiry ${O}; preview deltas: ${Te}).`,preview:re,poolId:Re,key:a,zeroForOne:c,amountIn:d.toString(),minAmountOut:m.toString(),bounty:h.toString(),bountyBounds:{minBounty:E.toString(),defaultBounty:z.toString(),maxBounty:q.toString()},expiry:O.toString(),recipient:p,sqrtPriceLimitX96:I.toString(),tokenIn:g,tokenOut:b,...s!==void 0?{orderId:s}:{}}}}}function at(e){return{name:"hookr_cancel",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"Hookr order ID to cancel (uint256 decimal string)."},to:{type:"string",description:"Recipient address for the refunded principal and bounty (must be the signing wallet)."},chainId:{type:"number",description:"Must be 4663 (Robinhood Chain)."}},required:["orderId"]},async execute(t,n){v(n);let r=l(n),i=be(t.chainId),u=Ae(t),s=t.orderId??t.id??u;if(s===void 0)throw new o("Provide orderId to cancel a Hookr limit order.");let a=T(s,"orderId");if(a<=0n)throw new o("orderId must be a positive integer.");let c=await Ce(e,a);if(c.owner.toLowerCase()!==r.toLowerCase())throw new o(`Unauthorized cancellation: only the order owner (${c.owner}) can cancel Hookr order #${a} (caller is ${r}).`);if(c.status!==F)throw new o(`Hookr order #${a} is not open (current status: ${c.statusLabel}).`);let w=t.to??r;if(typeof w!="string"||!$(w,{strict:!1}))throw new o("Provide a valid refund recipient address for cancel.");let f=l(w);if(Oe(f,c.key.hooks),f!==r)throw new o("Hookr refund recipient must be the signing wallet.");let g=ye({abi:D,functionName:"cancel",args:[a,f]}),b=e.formatAmount(c.amountIn,c.tokenIn.decimals),y=e.formatAmount(c.bounty,18),p=e.unsignedTx({to:A,data:g,value:"0",chainId:i,description:`Cancel Hookr limit order #${a} on ${A} and refund ${b} ${c.tokenIn.symbol} plus ${y} ETH bounty to ${f}.`}),d=await e.preview([p],r),m=Ie(d,e);return{txs:[p],summary:`Cancel Hookr limit order #${a}: refund ${b} ${c.tokenIn.symbol} and ${y} ETH bounty to ${f} (preview deltas: ${m}).`,preview:d,orderId:a.toString(),to:f,refundedAmountIn:c.amountIn,refundedBounty:c.bounty,tokenIn:c.tokenIn,tokenOut:c.tokenOut}}}}function dt(e){let t=performance.now()+Xe;return new Proxy(e,{get(n,r,i){return r!=="readContract"?Reflect.get(n,r,i):async(...u)=>{let s=t-performance.now(),a=()=>new o("Hookr scan deadline exceeded. Order coverage is incomplete; retry later.");if(s<=0)throw a();let c;try{return await Promise.race([n.readContract(...u),new Promise((w,f)=>{c=setTimeout(()=>f(a()),s)})])}finally{c!==void 0&&clearTimeout(c)}}}})}function ct(e){return async t=>{v(t);let n=l(t),r=dt(e.clientFor(S)),i={...e,clientFor:()=>r},u=await r.readContract({address:A,abi:D,functionName:"lastOrderId"}).catch(()=>{throw new o("Could not read the last Hookr order ID. Order coverage is incomplete.")});if(typeof u!="bigint"||u<0n)throw new o("Could not read a valid last Hookr order ID. Order coverage is incomplete.");let s=u,a=s>ue?s-ue+1n:1n;if(s<=0n)return[];let c=[],w=new Map;for(let f=a;f<=s;f+=Y){let g=Array.from({length:Number(s-f+1n<Y?s-f+1n:Y)},(y,p)=>f+BigInt(p)),b=await Promise.all(g.map(async y=>{let p=await r.readContract({address:A,abi:D,functionName:"getOrder",args:[y]}).catch(()=>{throw new o(`Could not read Hookr order #${y}. Order coverage is incomplete.`)}),d=Se(p);if(d.owner.toLowerCase()===L||Number(d.status)===J)throw new o(`Hookr order #${y} does not exist. Order coverage is incomplete.`);return{id:y,order:d}}));for(let{id:y,order:p}of b){if(p.owner.toLowerCase()!==n.toLowerCase()||Number(p.status)!==F)continue;let d=await Ce(i,y,{order:p,tokens:w}),m=[{token:d.tokenIn,amount:d.amountIn}];BigInt(d.bounty)>0n&&m.push({token:{address:N,symbol:"ETH",decimals:18,chainId:S},amount:d.bounty});let I=e.formatAmount(d.amountIn,d.tokenIn.decimals),k=e.formatAmount(d.minAmountOut,d.tokenOut.decimals),C=e.formatAmount(d.bounty,18),O=e.formatAmount(d.quotedAmountOut,d.tokenOut.decimals);c.push({module:"hookr",id:d.orderId,chainId:S,assets:m,description:`Hookr open limit order #${d.orderId}: sell ${I} ${d.tokenIn.symbol} (${d.tokenIn.address}) for at least ${k} ${d.tokenOut.symbol} (${d.tokenOut.address}), bounty ${C} ETH, expiry ${d.expiry}, fillable=${d.fillable} (quoted output ${O} ${d.tokenOut.symbol}).`})}}return a>1n&&c.push({module:"hookr",id:"coverage",chainId:S,assets:[],description:`Hookr order coverage is incomplete: scanned IDs ${a}-${s}. Older orders require an explicit order ID.`}),c}}var xe=e=>{let t=[st(e),at(e)],n=ct(e);return{tools:t,positions:n}},Dt=xe,Lt=xe;export{A as a,_e as b,ve as c,kt as d,Ne as e,Be as f,Ot as g,Fe as h,Me as i,ze as j,de as k,qe as l,ce as m,It as n,At as o,ht as p,St as q,ue as r,Xe as s,J as t,F as u,Ge as v,Ye as w,Qe as x,Ct as y,D as z,Je as A,xt as B,ke as C,ot as D,he as E,rt as F,it as G,Se as H,Ce as I,st as J,at as K,dt as L,ct as M,xe as N,Dt as O,Lt as P};
@@ -1 +0,0 @@
1
- import{c as _}from"./MYBDO5SA.js";import{e as y}from"./73N3TOJL.js";import{a as c,i as x}from"./G6HCV67X.js";import{a}from"./5YS5V2LK.js";import{getAddress as A,isAddress as b}from"viem";function I(p){if(typeof p!="string"||!p.trim()||p.length>200)throw new a("Provide nonempty filter text of at most 200 characters.");return p}function P(p,f){if(typeof p!="number"||!Number.isSafeInteger(p)||p<0||p>f)throw new a(`Choose a pagination integer from 0 to ${f}.`);return p}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"}},M=p=>{let f=(e,i,n)=>({name:`merkl_${e}`,inputSchema:{type:"object",properties:i,additionalProperties:!1},execute:async(d,t)=>{try{let o=Object.keys(d).find(s=>!Object.hasOwn(i,s));if(o)throw new a(`Unsupported Merkl input: ${o}.`);return await n(d,t)}catch(o){throw new a(p.plainError(o))}}}),g={page:{type:"integer",minimum:0,maximum:1e4},items:{type:"integer",minimum:1,maximum:100}},k=async(e,i)=>{let n=new URL(`https://api.merkl.xyz/v4/${e}`);for(let[d,t]of Object.entries(i))n.searchParams.set(d,t);return _(p.http,n.toString(),{method:"GET",headers:{"User-Agent":"oak-core/merkl"}},d=>Array.isArray(d)||y(d))},h=e=>{let i=P(e.items??20,100);if(!i)throw new a("Choose at least one item per page.");return{page:String(P(e.page??0,1e4)),items:String(i)}};return{tools:[f("opportunities",{...g,protocol:{type:"string"},name:{type:"string"},explorerAddress:{type:"string"}},async e=>{let i={chainId:String(c),campaigns:"true",...h(e)};if(e.protocol!==void 0&&(i.mainProtocolId=I(e.protocol)),e.name!==void 0&&(i.name=I(e.name)),e.explorerAddress!==void 0){if(typeof e.explorerAddress!="string"||!b(e.explorerAddress,{strict:!1}))throw new a("Provide a pool or market explorer address.");i.explorerAddress=A(e.explorerAddress)}let n=await k("opportunities",i);if(!Array.isArray(n)||!n.every(t=>y(t)&&typeof t.id=="string"&&Number.isSafeInteger(t.chainId)))throw new a("Merkl returned unexpected opportunities.");return{opportunities:n.filter(t=>t.chainId===c).map(t=>{let o=(y(t.protocol)?t.protocol.id:void 0)??t.mainProtocolId??t.mainProtocol,s=typeof o=="string"?o.toLowerCase():"",r;return s==="morpho"&&t.action==="LEND"?t.type==="MORPHOCOLLATERAL"?r=w.morpho:typeof t.type=="string"&&(t.type==="ERC20LOGPROCESSOR"||t.type.includes("MORPHOVAULT"))&&typeof t.explorerAddress=="string"&&b(t.explorerAddress,{strict:!1})&&A(t.explorerAddress)===x[c].vaults.steakhouse.address&&(r=w.steakhouse):s==="uniswap"?t.type==="UNISWAP_V4"&&t.action==="POOL"&&(r=w.uniswap):s!=="morpho"&&Object.hasOwn(w,s)&&(t.action==="LEND"||t.action==="STAKE")&&(r=w[s]),{...t,oak:{...r?{candidateTools:r}:{},destinationVerificationRequired:!0,eligibility:"Read campaign conditions; no wallet eligibility has been verified."}}}),...h(e),hasMore:n.length===Number(i.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."}}),f("campaigns",{...g,creator:{type:"string"},tokenSymbol:{type:"string"},opportunityId:{type:"string",pattern:"^\\d{1,30}$"}},async e=>{if(e.opportunityId!==void 0&&(e.creator!==void 0||e.tokenSymbol!==void 0))throw new a("Use creator and tokenSymbol without opportunityId; the opportunity endpoint does not support those filters.");if(e.opportunityId!==void 0&&(typeof e.opportunityId!="string"||!/^\d{1,30}$/.test(e.opportunityId)||e.opportunityId.trim()!==e.opportunityId))throw new a("Provide an opportunityId as a decimal string of 1 to 30 digits.");let i={chainId:String(c),withOpportunity:"true",...h(e)};if(e.creator!==void 0){if(typeof e.creator!="string"||!b(e.creator,{strict:!1}))throw new a("Provide a creator address.");i.creatorAddress=A(e.creator)}e.tokenSymbol!==void 0&&(i.tokenSymbol=I(e.tokenSymbol));let n=e.opportunityId===void 0?"campaigns":`opportunities/${e.opportunityId}/campaigns`,d=await k(n,e.opportunityId===void 0?i:{}),t=e.opportunityId!==void 0&&y(d)?d:void 0;if(t&&t.chainId!==c)throw new a(`Merkl opportunity must be on chain ${c}.`);let o=e.opportunityId===void 0?d:t?.campaigns;if(!Array.isArray(o)||!o.every(l=>y(l)&&(typeof l.id=="string"||typeof l.id=="number")))throw new a("Merkl returned unexpected campaigns.");let s=t?o.filter(l=>l.distributionChainId===c):o,r=Number(i.page)*Number(i.items),u=e.opportunityId===void 0?s:s.slice(r,r+Number(i.items)),m=e.opportunityId===void 0?s.length===Number(i.items):r+Number(i.items)<s.length;return{campaigns:u,...t?{opportunity:{id:t.id,name:t.name,chainId:t.chainId,protocol:t.protocol,explorerAddress:t.explorerAddress,identifier:t.identifier}}:{},chainId:c,...h(e),hasMore:m,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."}}),f("earning_status",{view:{enum:["active","breakdowns","stats","claims"]},...g},async(e,i)=>{if(!b(i,{strict:!1}))throw new a("Provide a valid connected wallet address.");let n=e.view??"active";if(!["active","breakdowns","stats","claims"].includes(String(n)))throw new a("Choose active, breakdowns, stats or claims.");let d=n==="claims"?"claims":n==="breakdowns"?`users/${i}/rewards/chains/${c}/breakdowns`:`users/${i}/rewards/${n==="active"?"active-opportunities":"stats"}`,{page:t,items:o}=h(e),s=n==="breakdowns"?{}:{chainId:String(c)};n==="claims"&&(s.recipient=i);let r=await k(d,s),u=Number(t)*Number(o),m=Array.isArray(r)?r:n==="breakdowns"&&y(r)&&Array.isArray(r.opportunities)?r.opportunities:void 0,l=m?Array.isArray(r)?m.slice(u,u+Number(o)):{...r,opportunities:m.slice(u,u+Number(o))}:r;return{view:n,chainId:c,wallet:i,data:l,...m?{page:t,items:o,hasMore:u+Number(o)<m.length}:{},summary:"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{M as a};
@@ -1 +0,0 @@
1
- import{b as K,c as U}from"./CUNQ5RG5.js";import{L as z}from"./L3ZM77SJ.js";import{a as T}from"./6UPPUHCL.js";import{c as N}from"./TCPPYBGQ.js";import{c as F,f as R,g as L,h as H,i as W}from"./AMICUXS6.js";import{a as M}from"./6IM6A5VA.js";import{a as u}from"./UWOFA6GV.js";import{g as I}from"./73N3TOJL.js";import{a as y}from"./G6HCV67X.js";import{a as o}from"./5YS5V2LK.js";import{encodeFunctionData as P,erc20Abi as j,getAddress as q,parseAbi as k}from"viem";var w=k(["function asset() view returns (address)","function decimals() view returns (uint8)","function balanceOf(address) view returns (uint256)","function previewMint(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function mint(uint256 shares,address receiver) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256)"]);function S(t,i=!1){if(typeof t!="string"||!/^\d+$/.test(t)||t.length>78||BigInt(t)>=1n<<256n||!i&&BigInt(t)===0n)throw new o("Provide a positive uint256 decimal base-unit string.");return BigInt(t)}function le(t,i,g){return["details","analytics","manage","mint",i==="netnet"?"redeem":"withdraw_assets","force_exit","in_kind_exit"].map(e=>{let $=[...i==="longbow"?["vault"]:[],...e==="mint"?["shares","maxAssets"]:e==="redeem"?["shares"]:e==="withdraw_assets"?["amount"]:e==="force_exit"?["maxPenaltyAssets","minAmountOut"]:[]],m={...i==="longbow"?{vault:{type:"string",enum:g.map(s=>s.vault)}}:{}};e==="in_kind_exit"&&(Object.assign(m,{amount:u(),maxShares:u(),maxPenaltyAssets:u(),deadline:u()}),$.push("amount","maxShares","maxPenaltyAssets","deadline")),e==="mint"&&Object.assign(m,{shares:u(),maxAssets:u()}),e==="redeem"&&(m.shares=u()),e==="withdraw_assets"&&(m.amount=u()),e==="force_exit"&&Object.assign(m,{maxPenaltyAssets:u(),minAmountOut:u()});let G=N(t,`${i}_manage`,g[0].vault,g[0].asset),J=T(t,`${i}_analytics`,g[0].vault);if(e==="manage"||e==="analytics"){let s=e==="manage"?G.inputSchema:J.inputSchema;Object.assign(m,s.properties),e==="analytics"&&i==="longbow"&&(m.view={type:"string",enum:["apy","published_apy","allocations","history","pending_governance"]}),$.push(...s.required)}return{name:`${i}_${e}`,inputSchema:{type:"object",properties:m,required:$,additionalProperties:!1},execute:async(s,r)=>{try{if(M(r),Object.keys(s).some(l=>!Object.hasOwn(m,l)))throw new o("Unsupported vault feature argument.");let A=i==="netnet"?g[0]:g.find(l=>typeof s.vault=="string"&&I(l.vault,s.vault));if(!A)throw new o("Choose a current vault returned by the project list tool.");let{vault:n,asset:a}=A,b={...s};if(delete b.vault,e==="details")return L(t,`${i}_details`,n,a).execute(b,r);if(e==="manage")return N(t,`${i}_manage`,n,a).execute(b,r);if(e==="analytics")return i==="longbow"&&s.view==="published_apy"?U(t,n,a,b):i==="longbow"&&s.view==="apy"?K(t,n,a,b):{...await T(t,`${i}_analytics`,n).execute(b,r),asset:{...a,address:q(a.address)},shareToken:{address:n,symbol:`${i} shares`,decimals:18,chainId:y}};if(e==="in_kind_exit")return z(t,n,a,s,r);let f=t.clientFor(y);if(await f.getChainId()!==y)throw new o("Vault actions require chain 4663.");let[Q,X,Y]=await Promise.all([f.readContract({address:n,abi:w,functionName:"asset"}),f.readContract({address:n,abi:w,functionName:"decimals"}),f.readContract({address:a.address,abi:j,functionName:"decimals"})]);if(q(Q)!==q(a.address)||X!==18||Y!==a.decimals)throw new o("Vault metadata does not match the pinned asset and shares.");let E=e==="force_exit"?await f.readContract({address:n,abi:w,functionName:"balanceOf",args:[r]}):void 0;if(e==="force_exit"){let l=await R(t,f,n,r,E,F(s.maxPenaltyAssets),a),C=S(s.minAmountOut),p=[l.tx],v=await t.preview(p,r);return W(v.changes,n,E,C,a),{txs:p,preview:v,summary:`${H(l.plan,a.symbol)} ${v.summary}`}}let d=e==="mint",x=e==="redeem",c=S(d||x?s.shares:s.amount),_=await f.readContract({address:n,abi:w,functionName:d?"previewMint":x?"previewRedeem":"previewWithdraw",args:[c]});if(_<=0n||d&&_>S(s.maxAssets))throw new o("Vault quote is zero or exceeds maxAssets.");let V=d?void 0:await f.readContract({address:n,abi:w,functionName:"balanceOf",args:[r]});if(!d&&(x?c:_)>V)throw new o("The wallet share balance cannot cover this exit.");let Z=d?P({abi:w,functionName:"mint",args:[c,r]}):x?P({abi:w,functionName:"redeem",args:[c,r,r]}):P({abi:w,functionName:"withdraw",args:[c,r,r]}),B=`${e} ${c} ${d||x?"18-decimal share":`${a.decimals}-decimal ${a.symbol}`} base units on ${n}; beneficiary ${r}.`,D=[...d?[t.approval(a.address,n,_.toString(),y)]:[],t.unsignedTx({to:n,data:Z,value:"0",chainId:y,description:B})],O=await t.preview(D,r),h=(l,C)=>O.changes.filter(p=>p.token.chainId===y&&I(p.token.address,l)).reduce((p,v)=>{if(v.token.decimals!==C||!/^-?\d+$/.test(v.amount))throw new o("Invalid vault preview metadata.");return p+BigInt(v.amount)},0n);if(d?h(a.address,a.decimals)!==-_||h(n,18)!==c:x?h(n,18)!==-c||h(a.address,a.decimals)<=0n:h(a.address,a.decimals)!==c||-h(n,18)<=0n||-h(n,18)>V)throw new o("Vault preview does not match the requested amount and beneficiary.");return{txs:D,preview:O,summary:`${B} Counterpart quote ${_} base units. Mint approval is exact; accrual may require a fresh quote. Standard ERC-4626 calls encode no minimum receipt. ${O.summary}`}}catch(A){throw new o(t.plainError(A))}}}})}export{le as a};
@@ -1 +0,0 @@
1
- import{b as I}from"./U3F6DDML.js";import{c as k}from"./PZHR4ITH.js";import{g as S}from"./DCTUYDWF.js";import{a as $}from"./AAGDMH54.js";import{a as U}from"./LQUDJCAR.js";import{c as G}from"./NU4K3TEZ.js";import{a as b}from"./UFS2RVEZ.js";import{b as E}from"./AXYOJBX6.js";import{a as h}from"./6IM6A5VA.js";import{a as D}from"./UWOFA6GV.js";import{g as y,n as C}from"./73N3TOJL.js";import{a as s,d as P,i as w}from"./G6HCV67X.js";import{a as m}from"./5YS5V2LK.js";import{encodeFunctionData as v,parseAbi as j}from"viem";var a=w[s].vaults.netnet.address,d={address:w[s].tokens.USDG.address,chainId:s,decimals:P,symbol:"USDG"},N={address:a,chainId:s,decimals:18,symbol:"nnUSDG"},o=j(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function balanceOf(address owner) view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),_=D("Positive USDG amount in integer base units (6 decimals)."),O="Preview amounts are estimates; these ERC-4626 calls have no on-chain minimum output argument. No transaction was sent.";function M(e){return C(e,"Amount must be positive and fit in uint256.",{notString:"Provide an integer amount string in base units.",positive:!0})}function g(e,f){if(Object.keys(e).some(l=>!f.includes(l)))throw new m("Unsupported NetNet argument.")}var q=e=>{async function f(t){try{return await t()}catch(n){throw new m(e.plainError(n))}}async function l(){let t=e.clientFor(s);if(await t.getChainId()!==s)throw new m("NetNet requires chain 4663.");let[n,r]=await Promise.all([t.readContract({address:a,abi:o,functionName:"asset"}),t.readContract({address:a,abi:o,functionName:"decimals"})]);if(!y(n,d.address))throw new m("NetNet does not report the pinned USDG asset.");if(r!==N.decimals)throw new m("NetNet share decimals do not match the pinned metadata.");return t}async function A(t,n,r){let i=await e.preview(t,n),p=i.changes.map(({token:u,amount:c})=>{let T=c.startsWith("-");return`${T?"-":"+"}${e.formatAmount(T?c.slice(1):c,u.decimals)} ${u.symbol}`}).join(", ");return{txs:t,preview:i,summary:`${r} ${i.summary} ${p?`Estimated changes: ${p}. `:""}${O}`}}async function R(t){return f(async()=>{h(t);let n=await l(),r=await n.readContract({address:a,abi:o,functionName:"balanceOf",args:[t]});if(r===0n)return[];let i=await n.readContract({address:a,abi:o,functionName:"convertToAssets",args:[r]});return[{module:"netnet",id:`${s}:${a}`,chainId:s,assets:[{token:{...d},amount:i.toString()}],description:`${e.formatAmount(r.toString(),N.decimals)} nnUSDG shares in NetNet Credit (${a}); underlying USDG is an estimate, not a liquidity guarantee.`}]})}return{positions:R,tools:[{name:"netnet_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:t=>f(async()=>{g(t,[]);let r=await(await l()).readContract({address:a,abi:o,functionName:"totalAssets"});return[{address:a,name:"NetNet Credit",chainId:s,asset:{...d},shares:{...N},totalAssets:{token:{...d},amount:r.toString()}}]})},{name:"netnet_deposit",inputSchema:{type:"object",properties:{amount:_},required:["amount"],additionalProperties:!1},execute:(t,n)=>f(async()=>{g(t,["amount"]),h(n);let r=M(t.amount);await l();let i=[e.approval(d.address,a,r.toString(),s),e.unsignedTx({to:a,data:v({abi:o,functionName:"deposit",args:[r,n]}),value:"0",chainId:s,description:`Deposit ${e.formatAmount(r.toString(),d.decimals)} USDG into NetNet Credit.`})];return A(i,n,"Approve the exact USDG amount, then deposit into NetNet Credit.")})},{name:"netnet_withdraw",inputSchema:{type:"object",properties:{amount:{anyOf:[_,{const:"max",description:"Redeem the fresh full nnUSDG share balance."}]}},required:["amount"],additionalProperties:!1},execute:(t,n)=>f(async()=>{g(t,["amount"]),h(n);let r=t.amount==="max"?void 0:M(t.amount),i=await l(),p,u;if(r===void 0){let c=await i.readContract({address:a,abi:o,functionName:"balanceOf",args:[n]});if(c===0n)throw new m("This wallet has no NetNet shares to redeem.");p=v({abi:o,functionName:"redeem",args:[c,n,n]}),u=`Redeem all ${e.formatAmount(c.toString(),N.decimals)} nnUSDG shares for USDG.`}else p=v({abi:o,functionName:"withdraw",args:[r,n,n]}),u=`Withdraw ${e.formatAmount(r.toString(),d.decimals)} USDG from NetNet Credit (unmeasured on the recorded fork; full exit uses amount "max" redeem).`;return A([e.unsignedTx({to:a,data:p,value:"0",chainId:s,description:u})],n,u)})}]}};function ie(e){return E("netnet",[q(e),S(e),k(e),G(e),$(e),U(e),I(e),{tools:b(e,"netnet",[{vault:a,asset:d}])}])}export{q as a,ie as b};
@@ -1 +0,0 @@
1
- import{a as A,b}from"./73N3TOJL.js";import{a as u}from"./5YS5V2LK.js";import{getAddress as E,isAddress as I}from"viem";var j=/^[0-9]+$/,D=new Set(["^[0-9]+$","^\\d+$"]),h=new Set(["all","max"]),p={ETH:18,WETH:18,USDE:18,USDG:6},x=new WeakSet,$=new WeakMap;function R(e){return{type:"string",pattern:"^[0-9]+$",...e?{description:e}:{}}}function H(e){let n=R(e);return x.add(n),n}function f(e){let n;try{n=e===void 0?"nothing":JSON.stringify(e)??String(e)}catch{n=String(e)}return n.length>80?`${n.slice(0,77)}...`:n}function _(e,n){if(n===void 0||typeof n=="boolean")return n;if(n==="true")return!0;if(n==="false")return!1;throw new u(`${e} must be true or false; received ${f(n)}. Send the JSON boolean true or false (the strings "true" and "false" are also accepted).`)}function J(e,n,i={}){if(n===void 0)return;let r=typeof n=="number"?n:typeof n=="string"&&/^-?[0-9]{1,16}$/.test(n)?Number(n):Number.NaN,{minimum:t,maximum:s}=i;if(Number.isSafeInteger(r)&&(t===void 0||r>=t)&&(s===void 0||r<=s))return r;let d=t!==void 0&&s!==void 0?t===s?` equal to ${t}`:` from ${t} to ${s}`:t!==void 0?` of at least ${t}`:s!==void 0?` of at most ${s}`:"";throw new u(`${e} must be a whole number${d}; received ${f(n)}. Send a JSON number such as ${t!==void 0&&t===s?t:s!==void 0&&s>=50&&(t??0)<=50?50:t??1} (a string of digits is also accepted).`)}function l(e,n){let[i="",r=""]=e.split(".");if(!(r.length>n))return(BigInt(i||"0")*10n**BigInt(n)+BigInt(r.padEnd(n,"0")||"0")).toString()}function K(e){let i=(typeof e=="number"&&Number.isFinite(e)&&e>=0&&!/e/i.test(String(e))?String(e):typeof e=="string"?e.trim():void 0)?.match(/^(\d+\.?\d*|\.\d+)\s*\$?([A-Za-z]{2,10})?$/);if(!i||!i[1].includes(".")&&!i[2])return;let r=i[1].startsWith(".")?`0${i[1]}`:i[1].replace(/\.$/,""),t=i[2]?.toUpperCase();if(t&&p[t]!==void 0){let o=l(r,p[t]);return o===void 0?`${r} ${t} has more than ${p[t]} decimal places.`:`${r} ${t} = "${o}" (${p[t]} decimals). Send "${o}".`}let d=[[18,"ETH or WETH"],[6,"USDG"]].flatMap(([o,c])=>{let a=l(r,o);return a===void 0?[]:[`${r} ${c} (${o} decimals) = "${a}"`]});return`${d.length?`${d.join("; ")}. `:""}Multiply by 10^decimals of the token and send the whole-number string.`}function L(e,n,i={}){if(n===void 0)return;let{keyword:r,numbers:t=!0}=i;if(typeof n=="string"&&j.test(n))return n;if(r&&typeof n=="string"&&h.has(n))return r;let s=`a decimal integer string of base units such as "1000000"${t?" (a JSON whole number up to 9007199254740991 is also accepted)":""}${r?`, or "${r}" for the full balance`:""}`;if(typeof n=="number"&&Number.isInteger(n)&&n>=0){if(!Number.isSafeInteger(n))throw new u(`${e} received the JSON number ${f(n)}, which is above 9007199254740991 (2^53 - 1) and cannot be represented exactly. Send the exact value as a decimal integer string.`);if(!t)throw new u(`${e} must be a decimal integer string; received the JSON number ${n}. Send "${n}".`);return String(n)}let d=K(n);if(d)throw new u(`${e} must be base units, a whole number with no decimal point; received ${f(n)}. ${d}`);let o=typeof n=="string"&&h.has(n.toLowerCase())&&!r?" This field has no full-balance keyword; use the tool's separate full-exit option if it has one.":"";throw new u(`${e} must be ${s}; received ${f(n)}.${o}`)}function U(e,n){if(n===void 0)return;if(typeof n=="string"&&I(n,{strict:!1}))return E(n);let i=typeof n=="string"&&/^\$?[A-Za-z][A-Za-z0-9.]{0,15}$/.test(n)?" Token symbols are not accepted here; look up the address with find_token.":"";throw new u(`${e} must be a 0x address (0x followed by 40 hex digits, any letter case); received ${f(n)}.${i}`)}function W(e,n,i){if(typeof n=="string"){if(i.includes(n))return n;let r=i.filter(t=>b.test(t)&&t.toLowerCase()===n.toLowerCase());if(r.length===1)return r[0]}throw new u(`${e} must be one of ${i.map(r=>`"${r}"`).join(", ")} (addresses in any letter case); received ${f(n)}.`)}function S(e){return(e.type==="string"||e.type===void 0)&&D.has(e.pattern)}function w(e){if(!e||typeof e!="object"||Array.isArray(e))return;let n=e;if(n.type==="boolean")return{kind:"boolean"};if(n.type==="integer")return{kind:"integer",...typeof n.minimum=="number"?{minimum:n.minimum}:{},...typeof n.maximum=="number"?{maximum:n.maximum}:{}};if(typeof n.const=="number"&&Number.isSafeInteger(n.const))return{kind:"integer",minimum:n.const,maximum:n.const};if(S(n))return{kind:"uint",numbers:!x.has(n)};let i=typeof n.pattern=="string"?n.pattern.match(/^\^\(\?:\[0-9\]\+\|(all|max)\)\$$/):null;if(n.type==="string"&&i)return{kind:"uint",keyword:i[1],numbers:!0};let r=n.anyOf??n.oneOf;if(Array.isArray(r)&&r.length===2){let t=r.find(d=>d&&S(d)),s=r.find(d=>d&&typeof d.const=="string"&&h.has(d.const));if(t&&s)return{kind:"uint",keyword:s.const,numbers:!0}}if(n.type==="string"&&n.pattern===A)return{kind:"address"};if(n.type==="string"&&Array.isArray(n.enum)&&n.enum.every(t=>typeof t=="string")&&n.enum.some(t=>b.test(t)))return{kind:"enum",values:n.enum};if(n.type==="array"){let t=w(n.items);if(t&&(t.kind==="uint"||t.kind==="address"))return{kind:"array",item:t}}}function N(e,n,i){switch(n.kind){case"boolean":return _(e,i);case"integer":return J(e,i,n);case"uint":return L(e,i,n);case"address":return U(e,i);case"enum":return W(e,i,n.values);case"array":return Array.isArray(i)?i.map((r,t)=>N(`${e}[${t}]`,n.item,r)):i}}function O(e,n){let{pattern:i,anyOf:r,oneOf:t,enum:s,const:d,...o}=e;switch(n.kind){case"boolean":return{...e,type:["boolean","string"]};case"integer":return{...o,...Array.isArray(s)?{enum:[...s,...s.map(String)]}:{},type:["integer","string"]};case"uint":{let c=r??t,a=Array.isArray(c)?c:[],g=a.find(y=>S(y)),m=a.find(y=>typeof y.const=="string"),k=o.description??[g?.description,m?`Or "${m.const}"${m.description?`: ${m.description}`:"."}`:void 0].filter(Boolean).join(" ");return{...o,...k?{description:k}:{},type:n.numbers?["string","integer"]:"string"}}case"address":return{...o,type:"string",description:o.description??"A 0x address (any letter case)."};case"enum":return{...o,type:"string",description:`${o.description?`${o.description} `:""}One of: ${s.join(", ")} (any letter case).`};case"array":return{...e,items:O(e.items,n.item)}}}function T(e){let n=e.properties;return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function M(e){let n=T(e);if(!n||$.has(e))return e;let i=!1,r={};for(let[s,d]of Object.entries(n)){let o=w(d);r[s]=o?O(d,o):d,i||=r[s]!==d}if(!i)return e;let t={...e,properties:r};return $.set(t,e),t}function z(e){return $.get(e)??e}function P(e,n){let i=T(z(e));if(!i||!n||typeof n!="object"||Array.isArray(n))return n;let r;for(let[t,s]of Object.entries(i)){if(!Object.hasOwn(n,t))continue;let d=w(s);if(!d)continue;let o=n[t],c=N(t,d,o);c!==o&&!(Array.isArray(c)&&Array.isArray(o)&&c.every((a,g)=>a===o[g]))&&(r??={...n},r[t]=c)}return r??n}export{R as a,H as b,f as c,_ as d,J as e,L as f,U as g,M as h,z as i,P as j};
@@ -1 +0,0 @@
1
- var n=/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u,r=/\b(?:unsafe|safe|safety|risks?|risky|recommend\w*|buy\w*)\b/i,i=/(?:[a-z][a-z0-9+.-]*:\/\/|(?:https?|ftp|file|mailto|javascript|data):|www\.|\/\/|\b[a-z0-9-]+(?:\.[a-z0-9-]+)+\b)/i,a="HEY Research Lab context unavailable",o="Project names this contract",c="Builder evidence, not a trading signal.",E="Not tracked by HEY Research Lab yet";function s(t,e){return typeof t=="string"&&!!t.trim()&&t.length<=e&&!n.test(t)&&!/[<>[\]`]/.test(t)&&!r.test(t)&&!i.test(t)}function p(t,e){return!s(t,80)||!s(e,300)?a:`HEY Research Lab: ${t}. ${e}`}export{o as a,c as b,E as c,s as d,p as e};
@@ -1 +0,0 @@
1
- import{b as H,o as q}from"./5O5ZE3ZV.js";import{a as de,b as ce,c as le}from"./CQCVFRQ5.js";import{a as ae}from"./KHJFXJBU.js";import{a as ue,b as me}from"./WVXW6VL3.js";import{a as pe}from"./GIV5JMTE.js";import{e as U,h as B,m as re}from"./WQ6H62DM.js";import{b as ie}from"./AXYOJBX6.js";import{a as E}from"./EG6M6SSO.js";import{c as se}from"./MYBDO5SA.js";import{c as M,e as x,g as w,k as ee,l as ne,m as te,n as oe}from"./73N3TOJL.js";import{a as h,i as Y}from"./G6HCV67X.js";import{a as s}from"./5YS5V2LK.js";import{decodeFunctionResult as Ce,encodeAbiParameters as F,encodeFunctionData as N,erc20Abi as V,isAddress as Ie,parseAbi as we,parseAbiParameters as j,toHex as J,zeroAddress as W}from"viem";var k=Y[h].clanker,fe=we(["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[]))"]),C=we(["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)"]),I={address:k.paired_weth.address,symbol:"WETH",decimals:18,chainId:h},Pe="https://www.clanker.world/api/tokens",ye={type:"string",pattern:"^\\d+$"},he={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"};function P(n){return ne(ee(n,U),U)}function ge(n,t){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new s(`Provide an explicit bytes32 ${t}.`);return n}function T(n,t,a=!1){if(n===void 0&&!a)return"";if(typeof n!="string"||a&&!n.trim())throw new s(`Provide ${t} as text.`);return n}function z(n,t=256){return oe(n,`Amount exceeds the uint${t} range.`,{bits:t})}function G(n){return te(n,"The contract returned an invalid amount.").toString()}function O(n,t){let a=Object.keys(n).find(p=>!t.includes(p));if(a)throw new s(`Unsupported Clanker input: ${a}.`)}function be(n,t){return t.changes.map(({token:a,amount:p})=>{let b=p.startsWith("-");return`${b?"-":"+"}${n.formatAmount(b?p.slice(1):p,a.decimals)} ${a.symbol} (${a.address}, chain ${a.chainId})`}).join("; ")}function Te(n){return x(n)&&Array.isArray(n.data)&&Number.isSafeInteger(n.total)&&Number(n.total)>=0&&Number.isSafeInteger(n.tokensDeployed)&&Number(n.tokensDeployed)>=0&&(n.cursor===null||typeof n.cursor=="string"||n.cursor===void 0&&n.data.length===0&&n.total===0&&n.tokensDeployed===0)&&n.data.every(t=>x(t)&&typeof t.name=="string"&&typeof t.symbol=="string"&&Number.isSafeInteger(t.chain_id)&&["contract_address","admin","msg_sender","factory_address"].every(a=>typeof t[a]=="string"&&Ie(t[a],{strict:!1})))}async function ve(n,t={}){O(t,["q","limit","cursor","deployer"]);let a=t.limit??10;if(typeof a!="number"||!Number.isInteger(a)||a<1||a>20)throw new s("Choose an indexer limit from 1 to 20.");let p=new URL(Pe);p.searchParams.set("chainId",String(h)),p.searchParams.set("limit",String(a)),t.q!==void 0&&p.searchParams.set("q",T(t.q,"search")),t.cursor!==void 0&&p.searchParams.set("cursor",T(t.cursor,"cursor",!0)),t.deployer!==void 0&&p.searchParams.set("msgSender",P(t.deployer));let b=await se(n.http,p.toString(),{headers:{"User-Agent":"Oak-Clanker/1.0"}},Te);return{tokens:b.data.filter(v=>v.chain_id===h&&w(v.factory_address,k.factory.address)),total:b.total,cursor:b.cursor||null,tokensDeployed:b.tokensDeployed}}var Se=n=>{let t=()=>n.clientFor(h),a=async e=>{try{return await e()}catch(i){throw new s(n.plainError(i))}},p=(e,i,l,d="0")=>n.unsignedTx({to:e,data:i,value:d,chainId:h,description:l}),b=async(e,i)=>G(await t().readContract({address:k.fee_locker.address,abi:C,functionName:"availableFees",args:[e,i]})),v=async e=>{if(w(e,I.address))return I;let[i,l]=await Promise.all([t().readContract({address:e,abi:V,functionName:"symbol"}),t().readContract({address:e,abi:V,functionName:"decimals"})]);if(typeof i!="string"||!i.trim()||!Number.isInteger(l)||l<0||l>255)throw new s("The contract returned invalid token metadata.");return{address:e,chainId:h,symbol:i,decimals:l}},Z=e=>ve(n,e),ke=async(e,i)=>{if(O(e,["name","symbol","salt","image","metadata","context","vanity","initialBuy","minAmountOut","slippageBps","rewards","vault","airdrop","feeBps","pool"]),e.vanity!==void 0&&e.vanity!==!1)throw new s("Clanker launches use vanity false and an explicit salt.");let l=T(e.name,"token name",!0),d=T(e.symbol,"token symbol",!0),g=ge(e.salt,"salt"),f=z(e.initialBuy??"0"),u=e.slippageBps??H;if(typeof u!="number")throw new s("Slippage must be an integer from 0 to 9999 bps.");q("0",u);let o=e.minAmountOut===void 0?void 0:z(e.minAmountOut,128);if(o!==void 0&&o<=1n)throw new s("Initial-buy minimum must exceed one base unit.");if(!f&&o!==void 0)throw new s("A minimum requires a positive initial buy.");let c=ce(e,i);B(e.feeBps??100,0,1e3);let y=me(e);if(f&&!w(y.poolConfig.pairedToken,I.address))throw new s("An initial ETH buy currently requires a WETH-paired pool. Launch without an initial buy and obtain a protected swap quote separately.");let r=e.rewards??[{admin:i,recipient:i,bps:1e4,feePreference:0}];if(!Array.isArray(r)||!r.length||r.length>7)throw new s("Provide one to seven reward allocations.");let A=r.map(m=>{if(!x(m))throw new s("Provide reward allocations as objects.");return O(m,["admin","recipient","bps","feePreference"]),{admin:P(m.admin),recipient:P(m.recipient),bps:B(m.bps,1,1e4),feePreference:B(m.feePreference??0,0,2)}});if(A.reduce((m,S)=>m+S.bps,0)!==1e4)throw new s("Reward allocations must total 10000 bps.");let $={tokenConfig:{tokenAdmin:i,name:l,symbol:d,salt:g,image:T(e.image,"image"),metadata:T(e.metadata,"metadata"),context:e.context===void 0?JSON.stringify({interface:"Oak",platform:"robinhood"}):T(e.context,"context"),originatingChainId:BigInt(h)},poolConfig:y.poolConfig,lockerConfig:{locker:k.locker.address,rewardAdmins:A.map(m=>m.admin),rewardRecipients:A.map(m=>m.recipient),rewardBps:A.map(m=>m.bps),tickLower:y.tickLower,tickUpper:y.tickUpper,positionBps:y.positionBps,lockerData:F(j("(uint8[])"),[[A.map(m=>m.feePreference)]])},mevModuleConfig:{mevModule:k.mev_module.address,mevModuleData:F(j("(uint24,uint24,uint256)"),[[666777,41673,15n]])},extensionConfigs:c},xe=await t().simulateContract({address:k.factory.address,abi:fe,functionName:"deployToken",args:[$],account:i,value:0n,gas:E}),_=P(xe.result),K=m=>{let S=[...c,...f?[{extension:k.devbuy.address,msgValue:f,extensionBps:0,extensionData:F(j("(address,address,uint24,int24,address),uint128,address"),[[W,W,0,0,W],m,i])}]:[]];return p(k.factory.address,N({abi:fe,functionName:"deployToken",args:[{...$,extensionConfigs:S}]}),`Launch ${l} (${d}); initial buy ${f} native ETH base units.`,f.toString())};if(f&&o===void 0){let S=(await n.preview([K(0n)],i)).changes.filter(D=>D.token.chainId===h&&w(D.token.address,_)&&D.token.decimals===18).reduce((D,X)=>D+(/^-?\d+$/.test(X.amount)?BigInt(X.amount):(()=>{throw new s("Invalid initial-buy simulation amount.")})()),0n);if(S<=0n)throw new s("Initial-buy simulation returned no token output.");if(o=z(q(S.toString(),u),128),o<=1n)throw new s("Initial-buy output is too small for a protected minimum.")}let Q=[K(o??0n)],R=await n.preview(Q,i);return{txs:Q,preview:R,predictedToken:_,token:{address:_,chainId:h,symbol:d,decimals:18},...o!==void 0?{minAmountOut:o.toString()}:{},summary:`Launch ${d} at ${_} (CREATE2 address predicted from simulation); vanity false; salt ${g}. Supply 100000000000000000000000000000 base units (18 decimals). ${y.feeSummary}; protocol adds 20% of LP fees. Pool and LP allocations: ${JSON.stringify(y)}. Reward allocations: ${JSON.stringify(A)}. Extensions: ${JSON.stringify({vault:e.vault,airdrop:e.airdrop})}. Sniper fees 666777 to 41673 over 15 seconds. ${R.summary} ${be(n,R)}`}},Ae=async(e,i)=>{if(O(e,["token","poolId","collect"]),e.collect!==void 0&&typeof e.collect!="boolean")throw new s("collect must be boolean.");if(e.collect===!1&&e.poolId!==void 0)throw new s("poolId requires collection.");if(e.collect===!0&&e.token===void 0)throw new s("Collection requires a Clanker token.");if(e.poolId!==void 0&&e.token===void 0)throw new s("A pool ID requires its Clanker token.");let l=[I],d=[];if(e.token!==void 0){let o=P(e.token);if(w(o,I.address))throw new s("Provide the launched Clanker token, not WETH.");if(e.collect!==!1){let c=await re(n,o),{poolId:y,hook:r,locker:A}=c;if(e.poolId!==void 0&&!w(ge(e.poolId,"pool ID for fee collection"),y))throw new s("The supplied pool ID does not match the onchain Clanker pool.");w(c.pairedToken,I.address)||l.splice(0,1,await v(c.pairedToken));let $=await t().readContract({address:r,abi:C,functionName:"mevModuleEnabled",args:[y]});if(typeof $!="boolean")throw new s("The hook returned an invalid MEV guard state.");$&&d.push(p(r,N({abi:C,functionName:"mevModuleOperational",args:[y]}),"Update the Clanker pool MEV guard before collection.")),d.push(p(A,N({abi:C,functionName:"collectRewards",args:[o]}),"Collect pending LP fees into the fee locker."))}l.push(await v(o))}let g;if(d.length){if(await t().getChainId()!==h)throw new s("Fee simulation endpoint is on the wrong chain.");let o=[...d.map(r=>({from:i,gas:J(E),to:r.to,data:r.data,value:J(BigInt(r.value))})),...l.map(r=>({from:i,gas:J(E),to:k.fee_locker.address,data:N({abi:C,functionName:"availableFees",args:[i,r.address]}),value:"0x0"}))],c=await t().request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:o}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(c)||c.length!==1||!x(c[0])||!Array.isArray(c[0].calls)||c[0].calls.length!==o.length)throw new s("The endpoint returned an unexpected fee simulation response.");let y=c[0].calls;if(!y.every(r=>x(r)&&r.status==="0x1"&&!r.error))throw new s("Clanker fee collection simulation failed.");g=y.slice(d.length).map(r=>{if(!x(r)||typeof r.returnData!="string"||!/^0x[0-9a-fA-F]{64}$/.test(r.returnData))throw new s("The endpoint returned an invalid fee balance.");return G(Ce({abi:C,functionName:"availableFees",data:r.returnData}))})}else g=await Promise.all(l.map(o=>b(i,o.address)));let f=l.flatMap((o,c)=>BigInt(g[c])>0n?[{token:o,amount:g[c]}]:[]);if(!f.length)throw new s("No claimable fees for this wallet; pending LP fees may require the MEV window to end.");for(let{token:o}of f)d.push(p(k.fee_locker.address,N({abi:C,functionName:"claim",args:[i,o.address]}),`Claim ${o.symbol} fees to ${i}.`));let u=await n.preview(d,i);return{txs:d,preview:u,fees:f,summary:`Claim fees to ${i}. WETH fees aggregate across all Clanker launches for this recipient. ${u.summary} ${be(n,u)}`}},L=(e,i,l,d)=>({name:`clanker_${e}`,inputSchema:{type:"object",properties:i,required:l,additionalProperties:!1},execute:(g,f)=>a(async()=>d(g,P(f)))});return{tools:[L("launch",{name:{type:"string"},symbol:{type:"string"},salt:he,image:{type:"string"},metadata:{type:"string"},context:{type:"string"},vanity:{const:!1},initialBuy:{...ye,description:"Native ETH base units, 18 decimals."},minAmountOut:{...ye,description:"Minimum new token base units, 18 decimals; derived from simulation when omitted."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:H},feeBps:{type:"integer",minimum:0,maximum:1e3,default:100},pool:ue,rewards:{type:"array",minItems:1,maxItems:7,items:{type:"object",properties:{admin:M,recipient:M,bps:{type:"integer",minimum:1,maximum:1e4},feePreference:{type:"integer",minimum:0,maximum:2}},required:["admin","recipient","bps"],additionalProperties:!1}},...de},["name","symbol","salt"],ke),L("claim",{token:{...M,description:"Launched token; derives its onchain pool and collects pending LP fees before claiming."},poolId:{...he,description:"Optional assertion against the derived pool ID."},collect:{type:"boolean",default:!0,description:"Set false to claim only already-collected fees."}},[],Ae),L("browse",{q:{type:"string"},limit:{type:"integer",minimum:1,maximum:20},cursor:{type:"string"},deployer:M},[],Z)],positions:e=>a(async()=>{P(e);let i=new Map,l=new Set,d;do{let u=await Z({deployer:e,limit:20,...d?{cursor:d}:{}});for(let o of u.tokens)w(o.msg_sender,e)&&i.set(o.contract_address.toLowerCase(),o);if(u.cursor&&l.has(u.cursor))throw new s("The Clanker indexer repeated a pagination cursor.");u.cursor&&l.add(u.cursor),d=u.cursor??void 0}while(d);let g=[],f=[I];for(let[u,o]of i){let c=await v(o.contract_address),y=G(await t().readContract({address:c.address,abi:V,functionName:"balanceOf",args:[e]}));g.push({module:"clanker",id:`launch:${u}`,chainId:h,assets:[{token:c,amount:y}],description:`Indexed launch ${o.name}; wallet token balance, not locked LP principal.`}),f.some(r=>w(r.address,c.address))||f.push(c)}for(let u of f){let o=await b(e,u.address);BigInt(o)>0n&&g.push({module:"clanker",id:`fees:${u.address.toLowerCase()}`,chainId:h,assets:[{token:u,amount:o}],description:"Collected fees across launches for this recipient. Pending LP fees excluded; token-side discovery covers indexed launches by this wallet."})}return g})}},Fe=n=>ie("clanker",[Se(n),ae(n),le(n),pe(n)]);export{ve as a,Se as b,Fe as c};
@@ -1 +0,0 @@
1
- import{c as t}from"./TCPPYBGQ.js";import{c as o}from"./JPOYTTTW.js";function s(e,n,a){return t(e,n,a,o)}export{s as a};