@oakagentkit/core 0.3.5 → 0.3.7

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 (525) hide show
  1. package/build/dist/api/addresses.d.ts +14 -0
  2. package/build/dist/api/addresses.js +1 -1
  3. package/build/dist/api/chain.js +1 -1
  4. package/build/dist/api/history.d.ts +2 -0
  5. package/build/dist/api/history.js +1 -1
  6. package/build/dist/api/identity-link.js +1 -1
  7. package/build/dist/api/metadata.js +1 -1
  8. package/build/dist/api/modules/beefy/boosts.js +1 -1
  9. package/build/dist/api/modules/beefy/clm.js +1 -1
  10. package/build/dist/api/modules/beefy/guard.js +1 -1
  11. package/build/dist/api/modules/beefy/index.js +1 -1
  12. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  13. package/build/dist/api/modules/beefy/management.js +1 -1
  14. package/build/dist/api/modules/beefy/vaults.js +1 -1
  15. package/build/dist/api/modules/borro/actions.js +1 -1
  16. package/build/dist/api/modules/borro/index.js +1 -1
  17. package/build/dist/api/modules/borro/liquidity.js +1 -1
  18. package/build/dist/api/modules/borro/positions.js +1 -1
  19. package/build/dist/api/modules/borro/reader.js +1 -1
  20. package/build/dist/api/modules/chop/display.js +1 -1
  21. package/build/dist/api/modules/chop/guard.js +1 -1
  22. package/build/dist/api/modules/chop/index.js +1 -1
  23. package/build/dist/api/modules/clanker/extensions.js +1 -1
  24. package/build/dist/api/modules/clanker/index.js +1 -1
  25. package/build/dist/api/modules/clanker/manage.js +1 -1
  26. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  27. package/build/dist/api/modules/clanker/protocol.js +1 -1
  28. package/build/dist/api/modules/clanker/state.js +1 -1
  29. package/build/dist/api/modules/earn/index.js +1 -1
  30. package/build/dist/api/modules/erc8004/common.js +1 -1
  31. package/build/dist/api/modules/erc8004/domain.js +1 -1
  32. package/build/dist/api/modules/erc8004/index.js +1 -1
  33. package/build/dist/api/modules/erc8004/management.js +1 -1
  34. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  35. package/build/dist/api/modules/erc8004/services.js +1 -1
  36. package/build/dist/api/modules/erc8004/thesis.js +1 -1
  37. package/build/dist/api/modules/erc8004/validation.js +1 -1
  38. package/build/dist/api/modules/fobo/index.js +1 -1
  39. package/build/dist/api/modules/fobo/intent.js +1 -1
  40. package/build/dist/api/modules/fobo/steps.js +1 -1
  41. package/build/dist/api/modules/fobo/verify.js +1 -1
  42. package/build/dist/api/modules/grove/index.js +1 -1
  43. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  44. package/build/dist/api/modules/heyresearch/index.js +1 -1
  45. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  46. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  47. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  48. package/build/dist/api/modules/hoodag/index.js +1 -1
  49. package/build/dist/api/modules/hoodag/management.js +1 -1
  50. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  51. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  52. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  53. package/build/dist/api/modules/hoodlock/buyback.js +1 -1
  54. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  55. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  56. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  57. package/build/dist/api/modules/hoodlock/index.js +1 -1
  58. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  59. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  60. package/build/dist/api/modules/hoodlock/public.js +1 -1
  61. package/build/dist/api/modules/hookr/actions.d.ts +39 -2
  62. package/build/dist/api/modules/hookr/actions.js +1 -1
  63. package/build/dist/api/modules/hookr/addons.js +1 -1
  64. package/build/dist/api/modules/hookr/agent-gate.d.ts +14 -2
  65. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  66. package/build/dist/api/modules/hookr/agent-link.d.ts +17 -0
  67. package/build/dist/api/modules/hookr/agent-link.js +1 -0
  68. package/build/dist/api/modules/hookr/api-client.d.ts +9 -0
  69. package/build/dist/api/modules/hookr/api-client.js +1 -0
  70. package/build/dist/api/modules/hookr/blocks/advisory.d.ts +41 -0
  71. package/build/dist/api/modules/hookr/blocks/advisory.js +1 -0
  72. package/build/dist/api/modules/hookr/blocks/buy-sell-block.d.ts +7 -0
  73. package/build/dist/api/modules/hookr/blocks/buy-sell-block.js +1 -0
  74. package/build/dist/api/modules/hookr/blocks/core-settings.d.ts +6 -0
  75. package/build/dist/api/modules/hookr/blocks/core-settings.js +1 -0
  76. package/build/dist/api/modules/hookr/blocks/exit-clock.d.ts +14 -0
  77. package/build/dist/api/modules/hookr/blocks/exit-clock.js +1 -0
  78. package/build/dist/api/modules/hookr/blocks/holder-pot.d.ts +30 -0
  79. package/build/dist/api/modules/hookr/blocks/holder-pot.js +1 -0
  80. package/build/dist/api/modules/hookr/blocks/managed-fee.d.ts +96 -0
  81. package/build/dist/api/modules/hookr/blocks/managed-fee.js +1 -0
  82. package/build/dist/api/modules/hookr/blocks/market-guard.d.ts +116 -0
  83. package/build/dist/api/modules/hookr/blocks/market-guard.js +1 -0
  84. package/build/dist/api/modules/hookr/blocks/market-hours-fee.d.ts +87 -0
  85. package/build/dist/api/modules/hookr/blocks/market-hours-fee.js +1 -0
  86. package/build/dist/api/modules/hookr/blocks/pay-later.d.ts +199 -0
  87. package/build/dist/api/modules/hookr/blocks/pay-later.js +1 -0
  88. package/build/dist/api/modules/hookr/blocks/sandwich-guard.d.ts +3 -0
  89. package/build/dist/api/modules/hookr/blocks/sandwich-guard.js +1 -0
  90. package/build/dist/api/modules/hookr/blocks/storm-fee.d.ts +3 -0
  91. package/build/dist/api/modules/hookr/blocks/storm-fee.js +1 -0
  92. package/build/dist/api/modules/hookr/blocks/swap-cut.d.ts +3 -0
  93. package/build/dist/api/modules/hookr/blocks/swap-cut.js +1 -0
  94. package/build/dist/api/modules/hookr/blocks/swap-reward-mint.d.ts +125 -0
  95. package/build/dist/api/modules/hookr/blocks/swap-reward-mint.js +1 -0
  96. package/build/dist/api/modules/hookr/blocks/wallet-cap.d.ts +3 -0
  97. package/build/dist/api/modules/hookr/blocks/wallet-cap.js +1 -0
  98. package/build/dist/api/modules/hookr/blocks/zap-source.d.ts +161 -0
  99. package/build/dist/api/modules/hookr/blocks/zap-source.js +1 -0
  100. package/build/dist/api/modules/hookr/blocks/zap-target.d.ts +51 -0
  101. package/build/dist/api/modules/hookr/blocks/zap-target.js +1 -0
  102. package/build/dist/api/modules/hookr/claims.d.ts +53 -0
  103. package/build/dist/api/modules/hookr/claims.js +1 -0
  104. package/build/dist/api/modules/hookr/contracts.d.ts +3 -1
  105. package/build/dist/api/modules/hookr/contracts.js +1 -1
  106. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  107. package/build/dist/api/modules/hookr/discovery.d.ts +2 -2
  108. package/build/dist/api/modules/hookr/discovery.js +1 -1
  109. package/build/dist/api/modules/hookr/fill-bounty.d.ts +2 -0
  110. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  111. package/build/dist/api/modules/hookr/gas.d.ts +48 -0
  112. package/build/dist/api/modules/hookr/gas.js +1 -0
  113. package/build/dist/api/modules/hookr/gates.d.ts +51 -0
  114. package/build/dist/api/modules/hookr/gates.js +1 -0
  115. package/build/dist/api/modules/hookr/hook-blocks.d.ts +304 -0
  116. package/build/dist/api/modules/hookr/hook-blocks.js +1 -0
  117. package/build/dist/api/modules/hookr/index.d.ts +4 -2
  118. package/build/dist/api/modules/hookr/index.js +1 -1
  119. package/build/dist/api/modules/hookr/jobs.d.ts +7 -0
  120. package/build/dist/api/modules/hookr/jobs.js +1 -0
  121. package/build/dist/api/modules/hookr/launch-options.d.ts +52 -3
  122. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  123. package/build/dist/api/modules/hookr/launch-profile.d.ts +8 -0
  124. package/build/dist/api/modules/hookr/launch-profile.js +1 -1
  125. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  126. package/build/dist/api/modules/hookr/launch.d.ts +24 -0
  127. package/build/dist/api/modules/hookr/launch.js +1 -1
  128. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  129. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  130. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  131. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  132. package/build/dist/api/modules/hookr/lp-state.d.ts +90 -2
  133. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  134. package/build/dist/api/modules/hookr/pay-later-actions.d.ts +52 -0
  135. package/build/dist/api/modules/hookr/pay-later-actions.js +1 -0
  136. package/build/dist/api/modules/hookr/pins.d.ts +5 -0
  137. package/build/dist/api/modules/hookr/pins.js +1 -1
  138. package/build/dist/api/modules/hookr/pm-liquidity.d.ts +215 -0
  139. package/build/dist/api/modules/hookr/pm-liquidity.js +1 -0
  140. package/build/dist/api/modules/hookr/public-reads.d.ts +1 -1
  141. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  142. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  143. package/build/dist/api/modules/hookr/relay.js +1 -1
  144. package/build/dist/api/modules/hookr/revenue.d.ts +4 -1
  145. package/build/dist/api/modules/hookr/revenue.js +1 -1
  146. package/build/dist/api/modules/hookr/scan.d.ts +25 -0
  147. package/build/dist/api/modules/hookr/scan.js +1 -0
  148. package/build/dist/api/modules/hookr/swap.d.ts +161 -0
  149. package/build/dist/api/modules/hookr/swap.js +1 -0
  150. package/build/dist/api/modules/kyberswap/index.js +1 -1
  151. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  152. package/build/dist/api/modules/layerbank/abi.js +1 -1
  153. package/build/dist/api/modules/layerbank/actions.js +1 -1
  154. package/build/dist/api/modules/layerbank/checks.js +1 -1
  155. package/build/dist/api/modules/layerbank/index.js +1 -1
  156. package/build/dist/api/modules/layerbank/merkl.js +1 -1
  157. package/build/dist/api/modules/layerbank/reader.js +1 -1
  158. package/build/dist/api/modules/layerbank/reserve.js +1 -1
  159. package/build/dist/api/modules/lighter/index.js +1 -1
  160. package/build/dist/api/modules/longbow/administration.js +1 -1
  161. package/build/dist/api/modules/longbow/analytics.js +1 -1
  162. package/build/dist/api/modules/longbow/fixed.js +1 -1
  163. package/build/dist/api/modules/longbow/index.js +1 -1
  164. package/build/dist/api/modules/longbow/nft.js +1 -1
  165. package/build/dist/api/modules/longbow/rebates.js +1 -1
  166. package/build/dist/api/modules/longbow/staking.js +1 -1
  167. package/build/dist/api/modules/meridian/index.js +1 -1
  168. package/build/dist/api/modules/meridian/markets.js +1 -1
  169. package/build/dist/api/modules/meridian/rfq.js +1 -1
  170. package/build/dist/api/modules/merkl/discovery.js +1 -1
  171. package/build/dist/api/modules/merkl/index.js +1 -1
  172. package/build/dist/api/modules/merkl/manage.js +1 -1
  173. package/build/dist/api/modules/merkl/protocol.js +1 -1
  174. package/build/dist/api/modules/merkl/stock-lp.d.ts +51 -0
  175. package/build/dist/api/modules/merkl/stock-lp.js +1 -0
  176. package/build/dist/api/modules/morpho/allocator.js +1 -1
  177. package/build/dist/api/modules/morpho/bundles.js +1 -1
  178. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  179. package/build/dist/api/modules/morpho/index.js +1 -1
  180. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  181. package/build/dist/api/modules/morpho/midnight.js +1 -1
  182. package/build/dist/api/modules/morpho/protocol.js +1 -1
  183. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  184. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  185. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  186. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  187. package/build/dist/api/modules/netnet/card-read.js +1 -1
  188. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  189. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  190. package/build/dist/api/modules/netnet/desk-read.js +1 -1
  191. package/build/dist/api/modules/netnet/financial.js +1 -1
  192. package/build/dist/api/modules/netnet/index.js +1 -1
  193. package/build/dist/api/modules/netnet/staking.js +1 -1
  194. package/build/dist/api/modules/orbio/index.js +1 -1
  195. package/build/dist/api/modules/orbio/positions.js +1 -1
  196. package/build/dist/api/modules/pendle/costs.js +1 -1
  197. package/build/dist/api/modules/pendle/index.js +1 -1
  198. package/build/dist/api/modules/pendle/markets.js +1 -1
  199. package/build/dist/api/modules/pendle/positions.js +1 -1
  200. package/build/dist/api/modules/pendle/pricecheck.js +1 -1
  201. package/build/dist/api/modules/pendle/reader.js +1 -1
  202. package/build/dist/api/modules/pendle/redeem.js +1 -1
  203. package/build/dist/api/modules/pendle/trade.js +1 -1
  204. package/build/dist/api/modules/pendle/validate.js +1 -1
  205. package/build/dist/api/modules/pendle/verify.js +1 -1
  206. package/build/dist/api/modules/pons/claim.js +1 -1
  207. package/build/dist/api/modules/pons/index.js +1 -1
  208. package/build/dist/api/modules/pons/launch-status.js +1 -1
  209. package/build/dist/api/modules/pons/prices.js +1 -1
  210. package/build/dist/api/modules/pons/reads.js +1 -1
  211. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  212. package/build/dist/api/modules/pons/trade.js +1 -1
  213. package/build/dist/api/modules/poolstrade/index.js +1 -1
  214. package/build/dist/api/modules/priors/coverage.js +1 -1
  215. package/build/dist/api/modules/priors/discovery.js +1 -1
  216. package/build/dist/api/modules/priors/features.js +1 -1
  217. package/build/dist/api/modules/priors/holdings.js +1 -1
  218. package/build/dist/api/modules/priors/index.js +1 -1
  219. package/build/dist/api/modules/priors/integration.js +1 -1
  220. package/build/dist/api/modules/priors/market.js +1 -1
  221. package/build/dist/api/modules/priors/pt.js +1 -1
  222. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  223. package/build/dist/api/modules/priors/starter-line.js +1 -1
  224. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  225. package/build/dist/api/modules/raeto/index.js +1 -1
  226. package/build/dist/api/modules/relay/bootstrap.js +1 -1
  227. package/build/dist/api/modules/relay/discovery.js +1 -1
  228. package/build/dist/api/modules/relay/inbound.js +1 -1
  229. package/build/dist/api/modules/relay/index.js +1 -1
  230. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  231. package/build/dist/api/modules/relay/reads.js +1 -1
  232. package/build/dist/api/modules/spark/actions.js +1 -1
  233. package/build/dist/api/modules/spark/details.js +1 -1
  234. package/build/dist/api/modules/spark/index.js +1 -1
  235. package/build/dist/api/modules/spark/management.js +1 -1
  236. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  237. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  238. package/build/dist/api/modules/steakhouse/index.js +1 -1
  239. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  240. package/build/dist/api/modules/steakhouse/management.js +1 -1
  241. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  242. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  243. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  244. package/build/dist/api/modules/tickerspring/discovery.js +1 -1
  245. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  246. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  247. package/build/dist/api/modules/tickerspring/index.js +1 -1
  248. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  249. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  250. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  251. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  252. package/build/dist/api/modules/tickerspring/research.js +1 -1
  253. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  254. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  255. package/build/dist/api/modules/uniswap/auction.js +1 -1
  256. package/build/dist/api/modules/uniswap/batch.js +1 -1
  257. package/build/dist/api/modules/uniswap/common.js +1 -1
  258. package/build/dist/api/modules/uniswap/fees.js +1 -1
  259. package/build/dist/api/modules/uniswap/index.js +1 -1
  260. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  261. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  262. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  263. package/build/dist/api/modules/uniswap/pools.js +1 -1
  264. package/build/dist/api/modules/uniswap/position.js +1 -1
  265. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  266. package/build/dist/api/modules/uniswap/quote-guard.js +1 -1
  267. package/build/dist/api/modules/uniswap/stock-prices.d.ts +25 -0
  268. package/build/dist/api/modules/uniswap/stock-prices.js +1 -1
  269. package/build/dist/api/modules/uniswap/stocks.js +1 -1
  270. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  271. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  272. package/build/dist/api/modules/uniswap/trade.js +1 -1
  273. package/build/dist/api/modules/uniswap/v2.js +1 -1
  274. package/build/dist/api/modules/uniswap/v3.js +1 -1
  275. package/build/dist/api/modules/uniswap/v4.js +1 -1
  276. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  277. package/build/dist/api/modules/upoch/index.js +1 -1
  278. package/build/dist/api/modules/upoch/reads.js +1 -1
  279. package/build/dist/api/modules/velora/claims.js +1 -1
  280. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  281. package/build/dist/api/modules/velora/index.js +1 -1
  282. package/build/dist/api/modules/wormhole/index.js +1 -1
  283. package/build/dist/api/modules/wormhole/scan-text.d.ts +1 -1
  284. package/build/dist/api/positions.js +1 -1
  285. package/build/dist/api/pricenote.js +1 -1
  286. package/build/dist/api/prices.js +1 -1
  287. package/build/dist/api/rpc.js +1 -1
  288. package/build/dist/api/send.js +1 -1
  289. package/build/dist/api/signing-registry.js +1 -1
  290. package/build/dist/api/signing.js +1 -1
  291. package/build/dist/api/simulate.js +1 -1
  292. package/build/dist/api/swap.d.ts +2 -0
  293. package/build/dist/api/swap.js +1 -1
  294. package/build/dist/api/tokens.d.ts +9 -1
  295. package/build/dist/api/tokens.js +1 -1
  296. package/build/dist/api/tool-policy.d.ts +1 -0
  297. package/build/dist/api/tool-policy.js +1 -1
  298. package/build/dist/api/universal-router.js +1 -1
  299. package/build/dist/api/usd-estimate.js +1 -1
  300. package/build/dist/chunks/{DMDOSHV7.js → 266VIESP.js} +1 -1
  301. package/build/dist/chunks/{HFVXNKA5.js → 2BM2WX2G.js} +1 -1
  302. package/build/dist/chunks/{HDBZZOHJ.js → 2GYL3N2O.js} +1 -1
  303. package/build/dist/chunks/{OY5W7ZSL.js → 2H2OZE6X.js} +1 -1
  304. package/build/dist/chunks/{E76Z2TT4.js → 2QQ5CGQI.js} +1 -1
  305. package/build/dist/chunks/{4PLLS6CT.js → 2VYA6WIN.js} +1 -1
  306. package/build/dist/chunks/{FRT6AC6M.js → 2ZYFBBOE.js} +1 -1
  307. package/build/dist/chunks/{LCH6F5HT.js → 342OZP53.js} +1 -1
  308. package/build/dist/chunks/{XADHV2DT.js → 35DTANJW.js} +1 -1
  309. package/build/dist/chunks/{4IOHSX3Z.js → 37UBQQWL.js} +1 -1
  310. package/build/dist/chunks/3RGED2KO.js +1 -0
  311. package/build/dist/chunks/{4HQEJHCD.js → 3XIJCHT7.js} +1 -1
  312. package/build/dist/chunks/3XY44BP5.js +1 -0
  313. package/build/dist/chunks/3YNXQ3EZ.js +1 -0
  314. package/build/dist/chunks/{JDHPMS7X.js → 4JU23O3Z.js} +1 -1
  315. package/build/dist/chunks/{Y2QADJOB.js → 4P6DRKY3.js} +1 -1
  316. package/build/dist/chunks/{W3DGFMQE.js → 4RTXP2YP.js} +1 -1
  317. package/build/dist/chunks/{CNDIAF3P.js → 4WYTIM4T.js} +1 -1
  318. package/build/dist/chunks/{HPS4KOU4.js → 52AEVHKJ.js} +1 -1
  319. package/build/dist/chunks/{ZTKT3ZQK.js → 53VBLEYS.js} +1 -1
  320. package/build/dist/chunks/{ADIPEGNN.js → 5AO2QPWE.js} +1 -1
  321. package/build/dist/chunks/{GQITAJVF.js → 5BPFF7NX.js} +1 -1
  322. package/build/dist/chunks/5EQTOA5F.js +1 -0
  323. package/build/dist/chunks/{WAKZWSHB.js → 5KKAN7XQ.js} +1 -1
  324. package/build/dist/chunks/{VVAM3EAK.js → 5N6YJFFA.js} +1 -1
  325. package/build/dist/chunks/{QIB6OMQV.js → 5O67QQIY.js} +1 -1
  326. package/build/dist/chunks/{FAH7FKUT.js → 5UWVXEPD.js} +1 -1
  327. package/build/dist/chunks/{KKTOBXIT.js → 5VA66LFF.js} +1 -1
  328. package/build/dist/chunks/5VKVAUFQ.js +1 -0
  329. package/build/dist/chunks/5Y457HYC.js +1 -0
  330. package/build/dist/chunks/627SGCTU.js +1 -0
  331. package/build/dist/chunks/64LAWFBE.js +1 -0
  332. package/build/dist/chunks/{6F527FLN.js → 6HNQAYBM.js} +1 -1
  333. package/build/dist/chunks/{FUP53K6G.js → 6LDC5D2S.js} +1 -1
  334. package/build/dist/chunks/6RVAV6BB.js +1 -0
  335. package/build/dist/chunks/{WSILNJS2.js → 6STUQOFL.js} +1 -1
  336. package/build/dist/chunks/{4Z3IGMU6.js → 7AYP4ATZ.js} +1 -1
  337. package/build/dist/chunks/{YGW4ODAP.js → 7EPU3XGY.js} +1 -1
  338. package/build/dist/chunks/7GL547YZ.js +1 -0
  339. package/build/dist/chunks/{E47UYYK4.js → 7KK3OC7Q.js} +1 -1
  340. package/build/dist/chunks/{IZP3EKKS.js → 7PBCV7VS.js} +1 -1
  341. package/build/dist/chunks/{A3BJSQ23.js → 7VU5VCTL.js} +1 -1
  342. package/build/dist/chunks/{Z7FGEWO2.js → 7WXAS54T.js} +1 -1
  343. package/build/dist/chunks/{DRLBTB4E.js → A72ADVYF.js} +1 -1
  344. package/build/dist/chunks/{ANIF3JMV.js → AG66NM3J.js} +1 -1
  345. package/build/dist/chunks/AODUTN65.js +1 -0
  346. package/build/dist/chunks/{DBOGRUPS.js → AONO47JX.js} +1 -1
  347. package/build/dist/chunks/{2I7XHRTI.js → AOTTQPK7.js} +1 -1
  348. package/build/dist/chunks/{JTPHZCO3.js → AQJLEG6B.js} +1 -1
  349. package/build/dist/chunks/AZBTNUXF.js +1 -0
  350. package/build/dist/chunks/B4U43D5Z.js +1 -0
  351. package/build/dist/chunks/B5B7U3NZ.js +1 -0
  352. package/build/dist/chunks/{ZX43P4BK.js → B75SS7H6.js} +1 -1
  353. package/build/dist/chunks/{GBIBRYOV.js → B7HVPHSS.js} +1 -1
  354. package/build/dist/chunks/{LT5P6PZW.js → B7WZJHIJ.js} +1 -1
  355. package/build/dist/chunks/{3A2IKFTV.js → BIFANUTV.js} +1 -1
  356. package/build/dist/chunks/BM4KHOFB.js +1 -0
  357. package/build/dist/chunks/{ZVY7GGSP.js → BW755PNH.js} +1 -1
  358. package/build/dist/chunks/{VXCGMALF.js → BWE5PXRE.js} +1 -1
  359. package/build/dist/chunks/{7U62MMUQ.js → BY2OWKZB.js} +1 -1
  360. package/build/dist/chunks/{F7MGYRPU.js → CCPG6PRL.js} +1 -1
  361. package/build/dist/chunks/{OI3N4EW4.js → CG7ABZXH.js} +1 -1
  362. package/build/dist/chunks/{S37D7HOK.js → CITHH7NK.js} +1 -1
  363. package/build/dist/chunks/CJMVRV34.js +1 -0
  364. package/build/dist/chunks/{JJSCDDQO.js → CLHA557R.js} +1 -1
  365. package/build/dist/chunks/CQPIR6ER.js +1 -0
  366. package/build/dist/chunks/{MI5HZDMH.js → D6JOXK7Q.js} +1 -1
  367. package/build/dist/chunks/{IZFED3R2.js → DLNDJZR4.js} +1 -1
  368. package/build/dist/chunks/{UUF4Z6K6.js → DUTAMN3F.js} +1 -1
  369. package/build/dist/chunks/{NMJVQX5M.js → DWRRIFXS.js} +1 -1
  370. package/build/dist/chunks/{3ZH5SOC2.js → EFOC337C.js} +1 -1
  371. package/build/dist/chunks/{2PS4GCOZ.js → EKHNXPWO.js} +1 -1
  372. package/build/dist/chunks/EWZFZUVF.js +1 -0
  373. package/build/dist/chunks/EXKV6QJD.js +1 -0
  374. package/build/dist/chunks/{OB7BFDOV.js → EYE3ZAJB.js} +1 -1
  375. package/build/dist/chunks/{MQ5F2VOK.js → EZUQMTLE.js} +1 -1
  376. package/build/dist/chunks/FMEO7RX7.js +1 -0
  377. package/build/dist/chunks/{ZQPC54J5.js → FYWK3UK6.js} +1 -1
  378. package/build/dist/chunks/G53U6Y4L.js +1 -0
  379. package/build/dist/chunks/{O5QTITN6.js → GRHBE4MQ.js} +1 -1
  380. package/build/dist/chunks/GV6FZ6UG.js +1 -0
  381. package/build/dist/chunks/GV6Z3MET.js +1 -0
  382. package/build/dist/chunks/{GK3D7OKG.js → GVCNTGLC.js} +1 -1
  383. package/build/dist/chunks/H5J2LFPZ.js +1 -0
  384. package/build/dist/chunks/{DCGNVMKG.js → HC3QFA5I.js} +1 -1
  385. package/build/dist/chunks/{C76D54YG.js → HGSFRN57.js} +1 -1
  386. package/build/dist/chunks/HJI7KO6F.js +1 -0
  387. package/build/dist/chunks/{G5AMH4IP.js → HN5RBTNE.js} +1 -1
  388. package/build/dist/chunks/{MSRCJ2BS.js → HPBTSJW7.js} +1 -1
  389. package/build/dist/chunks/HPO673QQ.js +1 -0
  390. package/build/dist/chunks/{C57DITTF.js → HTOP2OKU.js} +1 -1
  391. package/build/dist/chunks/{DGDMRATN.js → ICHT3H3W.js} +1 -1
  392. package/build/dist/chunks/IJVBCEA2.js +1 -0
  393. package/build/dist/chunks/ILTGXU6G.js +1 -0
  394. package/build/dist/chunks/{I4473OC6.js → IMD33NQS.js} +1 -1
  395. package/build/dist/chunks/{X24YTJST.js → IY7FWTAL.js} +1 -1
  396. package/build/dist/chunks/{TOIKOIY6.js → J5624CVF.js} +1 -1
  397. package/build/dist/chunks/JCS24YBB.js +1 -0
  398. package/build/dist/chunks/JFYC2LVI.js +1 -0
  399. package/build/dist/chunks/JQVTHPUO.js +1 -0
  400. package/build/dist/chunks/{TGXEKBLV.js → JUVY6PCR.js} +1 -1
  401. package/build/dist/chunks/JYED2PZ3.js +1 -0
  402. package/build/dist/chunks/{KO7ANIKY.js → K3HCSCXE.js} +1 -1
  403. package/build/dist/chunks/{7VH6JQ2H.js → K5C6QBOO.js} +1 -1
  404. package/build/dist/chunks/{W7BFM6CK.js → KAXLZJU6.js} +1 -1
  405. package/build/dist/chunks/{YW4W3LPQ.js → KHLM6NIZ.js} +1 -1
  406. package/build/dist/chunks/{OIQTZOBN.js → KKGHXNM4.js} +1 -1
  407. package/build/dist/chunks/{TZ7S5KRB.js → KW5LJGNY.js} +1 -1
  408. package/build/dist/chunks/{SUNTJ6IU.js → KYANIEPX.js} +1 -1
  409. package/build/dist/chunks/{ZZ6FZGHF.js → L4UFGM7M.js} +1 -1
  410. package/build/dist/chunks/{YWVPK3DV.js → L76P6WIH.js} +1 -1
  411. package/build/dist/chunks/{QMNUB2GM.js → LBT6WR4U.js} +1 -1
  412. package/build/dist/chunks/LD3A2KLN.js +1 -0
  413. package/build/dist/chunks/{WRUTW6CG.js → LFSNAQ7V.js} +1 -1
  414. package/build/dist/chunks/LHC2YV2U.js +1 -0
  415. package/build/dist/chunks/{R66NSNNQ.js → LHVGWNMW.js} +1 -1
  416. package/build/dist/chunks/{RUHNLNVX.js → LOH6LUVT.js} +1 -1
  417. package/build/dist/chunks/{23HNDJ76.js → M2SWILNG.js} +1 -1
  418. package/build/dist/chunks/{IT2JLILU.js → MFKDNAHB.js} +1 -1
  419. package/build/dist/chunks/MFQTBUSD.js +1 -0
  420. package/build/dist/chunks/MFRKZOU4.js +1 -0
  421. package/build/dist/chunks/{V4UJMUIB.js → MLN5KTG7.js} +1 -1
  422. package/build/dist/chunks/{TJU644I7.js → MSIT5Q3M.js} +1 -1
  423. package/build/dist/chunks/{S4JUFCT4.js → MSQNOK3I.js} +1 -1
  424. package/build/dist/chunks/NCCKCGKL.js +1 -0
  425. package/build/dist/chunks/NGHRUNXO.js +1 -0
  426. package/build/dist/chunks/{N65J3L2H.js → NIGRNLNM.js} +1 -1
  427. package/build/dist/chunks/{DXAPKN7H.js → NLC36QHL.js} +1 -1
  428. package/build/dist/chunks/NUTTPUYJ.js +1 -0
  429. package/build/dist/chunks/{QMIH6HXH.js → NWW6GY5E.js} +1 -1
  430. package/build/dist/chunks/{O4S6XAYV.js → O7L55XM3.js} +1 -1
  431. package/build/dist/chunks/{NAO7VWZF.js → OCIEVYPR.js} +1 -1
  432. package/build/dist/chunks/{4NBXBKOX.js → OD7CY6BY.js} +1 -1
  433. package/build/dist/chunks/{RUTSEGGD.js → OHZHQSCA.js} +1 -1
  434. package/build/dist/chunks/{A4K5GXVO.js → ORKXBYVC.js} +1 -1
  435. package/build/dist/chunks/OUXPOFY2.js +1 -0
  436. package/build/dist/chunks/{NIWAVMDR.js → OWHXYE2G.js} +1 -1
  437. package/build/dist/chunks/PD5NXIRT.js +1 -0
  438. package/build/dist/chunks/{TXGZ6NWN.js → PG7HZIZL.js} +1 -1
  439. package/build/dist/chunks/PLEJPTTK.js +1 -0
  440. package/build/dist/chunks/{VREGY7E6.js → PMFR47H3.js} +1 -1
  441. package/build/dist/chunks/{ZXRIJG6H.js → PX2G2H6G.js} +1 -1
  442. package/build/dist/chunks/QAAKUIWE.js +1 -0
  443. package/build/dist/chunks/{YXXK6EPI.js → QBHY2QRC.js} +1 -1
  444. package/build/dist/chunks/{WQ2XTDHO.js → QCPJZBEO.js} +1 -1
  445. package/build/dist/chunks/{ELHRXA5U.js → QFK335LC.js} +1 -1
  446. package/build/dist/chunks/{3PHJUFU2.js → QFUSCK5C.js} +1 -1
  447. package/build/dist/chunks/QGO4EKXZ.js +1 -0
  448. package/build/dist/chunks/{IPU656WB.js → QKH7ED6B.js} +1 -1
  449. package/build/dist/chunks/{XW3VGWXK.js → QMWHQRYC.js} +1 -1
  450. package/build/dist/chunks/{USGMGKAG.js → QXBQ7WPB.js} +1 -1
  451. package/build/dist/chunks/{MQXSCNUL.js → R5UOFPDO.js} +1 -1
  452. package/build/dist/chunks/{MDLJFCT4.js → R5Z4HPCA.js} +1 -1
  453. package/build/dist/chunks/{A4FLWHLP.js → REXGROOD.js} +1 -1
  454. package/build/dist/chunks/RKJFSDGV.js +1 -0
  455. package/build/dist/chunks/RKS3M7L5.js +1 -0
  456. package/build/dist/chunks/{GDOHHXNH.js → RLX6YTNT.js} +1 -1
  457. package/build/dist/chunks/{PV7FEVBD.js → RWEA4SWP.js} +1 -1
  458. package/build/dist/chunks/{ZKBOPZH5.js → RWUF6T4I.js} +1 -1
  459. package/build/dist/chunks/{USEF3QKG.js → S432S6NA.js} +1 -1
  460. package/build/dist/chunks/{XTXXWRN2.js → SDDYM2H3.js} +1 -1
  461. package/build/dist/chunks/{2OVJ2BTJ.js → SEXKWYUM.js} +1 -1
  462. package/build/dist/chunks/TKJ4GFUP.js +1 -0
  463. package/build/dist/chunks/{BSX4LFYI.js → TNHU5UBQ.js} +1 -1
  464. package/build/dist/chunks/{PDPTJMTJ.js → TT2ST3Q3.js} +1 -1
  465. package/build/dist/chunks/TTBB6EFN.js +1 -0
  466. package/build/dist/chunks/{OVM4QIET.js → U4MSIH4G.js} +1 -1
  467. package/build/dist/chunks/{LKUZAJPZ.js → UCMOQAVD.js} +1 -1
  468. package/build/dist/chunks/{OB3YMTDI.js → UIVOYAO2.js} +1 -1
  469. package/build/dist/chunks/{3YH5B5NQ.js → UL4DY6GX.js} +1 -1
  470. package/build/dist/chunks/{XRDLMTBJ.js → UMY6SP7C.js} +1 -1
  471. package/build/dist/chunks/UNBRUWSV.js +1 -0
  472. package/build/dist/chunks/{LGLWEGPY.js → UPX3OWKA.js} +1 -1
  473. package/build/dist/chunks/{MJGEGNDU.js → UYYYSFMQ.js} +1 -1
  474. package/build/dist/chunks/{4RCYYN6O.js → V7HTGO23.js} +1 -1
  475. package/build/dist/chunks/{O2QBSINK.js → V7P4PCLL.js} +1 -1
  476. package/build/dist/chunks/{FRVCSDKU.js → VMSGNN3D.js} +1 -1
  477. package/build/dist/chunks/VQMBPY2P.js +1 -0
  478. package/build/dist/chunks/{HZSYMGJ2.js → VS7ZA4OF.js} +1 -1
  479. package/build/dist/chunks/{BJ2U2VXJ.js → VTWAVH74.js} +1 -1
  480. package/build/dist/chunks/W3M4KAPX.js +1 -0
  481. package/build/dist/chunks/{LZM3DO5Q.js → W5GWK72I.js} +1 -1
  482. package/build/dist/chunks/{65OITTDL.js → W73SLWBT.js} +1 -1
  483. package/build/dist/chunks/{2FOI2625.js → W7BTXU3F.js} +1 -1
  484. package/build/dist/chunks/{6LVHN33V.js → WADRRW3E.js} +1 -1
  485. package/build/dist/chunks/{ZXFJKW6H.js → WG7PMGTJ.js} +1 -1
  486. package/build/dist/chunks/{N742W5KX.js → WRNPYW47.js} +1 -1
  487. package/build/dist/chunks/{XL3W7DAQ.js → X3BB6WME.js} +1 -1
  488. package/build/dist/chunks/{SX5YNFHG.js → XD4JA43O.js} +1 -1
  489. package/build/dist/chunks/{GBPB7JIB.js → XSQJOOEY.js} +1 -1
  490. package/build/dist/chunks/{3BQ5XHDJ.js → Y7SKGRWC.js} +1 -1
  491. package/build/dist/chunks/{R73R4KN3.js → YBLJ2MCR.js} +1 -1
  492. package/build/dist/chunks/{6CKCZJ3F.js → YDJHXSS7.js} +1 -1
  493. package/build/dist/chunks/{GKUPC4DO.js → YLU5JVRI.js} +1 -1
  494. package/build/dist/chunks/YR6Y6UIR.js +1 -0
  495. package/build/dist/chunks/{FHB7QYJO.js → Z5WRTISY.js} +1 -1
  496. package/build/dist/chunks/ZB67QDN2.js +1 -0
  497. package/build/dist/chunks/{O4P5IQCP.js → ZRG34Y7Q.js} +1 -1
  498. package/build/dist/chunks/ZSGW2ZSO.js +1 -0
  499. package/build/dist/chunks/{HRAHGYNK.js → ZTNBX4VH.js} +1 -1
  500. package/package.json +1 -1
  501. package/build/dist/chunks/5H7NVE6O.js +0 -1
  502. package/build/dist/chunks/7OOCAZBE.js +0 -1
  503. package/build/dist/chunks/7TRO6MBQ.js +0 -1
  504. package/build/dist/chunks/DFM4T6ZE.js +0 -1
  505. package/build/dist/chunks/FCVH4FYH.js +0 -1
  506. package/build/dist/chunks/GDUKZYE2.js +0 -1
  507. package/build/dist/chunks/GYPMUYB5.js +0 -1
  508. package/build/dist/chunks/J7OZLXSG.js +0 -1
  509. package/build/dist/chunks/JFC2QCMW.js +0 -1
  510. package/build/dist/chunks/M267JEDO.js +0 -1
  511. package/build/dist/chunks/M6JNGU4E.js +0 -1
  512. package/build/dist/chunks/M7OVMIIE.js +0 -1
  513. package/build/dist/chunks/MQK6OP7S.js +0 -1
  514. package/build/dist/chunks/N624NR7Y.js +0 -1
  515. package/build/dist/chunks/OSMOBKRQ.js +0 -1
  516. package/build/dist/chunks/Q3Q3YHEX.js +0 -1
  517. package/build/dist/chunks/QBNASL3T.js +0 -1
  518. package/build/dist/chunks/QQD4PV64.js +0 -1
  519. package/build/dist/chunks/RN3WUJIO.js +0 -1
  520. package/build/dist/chunks/RP5VCG54.js +0 -1
  521. package/build/dist/chunks/TI727O2H.js +0 -1
  522. package/build/dist/chunks/UHIJMDD2.js +0 -1
  523. package/build/dist/chunks/W32UECOL.js +0 -1
  524. package/build/dist/chunks/WWNAGOCD.js +0 -1
  525. package/build/dist/chunks/XWC6IC5E.js +0 -1
@@ -1 +1 @@
1
- import{a as I,b as S,d as g,f as c,g as $,h as p,i as T,k as v,l as R,m as P}from"./TXGZ6NWN.js";import{c as f,g as y}from"./NWNYJ26T.js";import{b as h}from"./TI727O2H.js";import{a as d}from"./XSD5NL7J.js";import{a as N}from"./JXOEJPJ4.js";import{encodeFunctionData as l,erc20Abi as x,parseAbi as E}from"viem";var w=E(["function admin() view returns (address)","function originalAdmin() view returns (address)","function updateAdmin(address)","function updateImage(string)","function updateMetadata(string)","function verify()","function delegate(address)","function burn(uint256)"]),U=m=>{let u=()=>m.clientFor(h),k=(t,a,n,e)=>({name:`clanker_${t}`,inputSchema:{type:"object",properties:a,required:n,additionalProperties:!1},execute:async(r,i)=>{try{return T(r,Object.keys(a)),await e(r,c(i))}catch(o){throw new d(m.plainError(o))}}}),A=async(t,a,n,e)=>{let r=[m.unsignedTx({to:t,data:a,chainId:h,value:"0",description:n})],i=await m.preview(r,e);return{txs:r,preview:i,summary:`${n} ${i.summary}`}},C=async t=>{let[a,n]=await Promise.all([u().readContract({address:t,abi:x,functionName:"symbol"}),u().readContract({address:t,abi:x,functionName:"decimals"})]);if(typeof a!="string"||!a.trim())throw new d("Clanker returned invalid metadata.");return{address:t,symbol:N(a),decimals:p(n,0,255),chainId:h}};return{tools:[k("status",{token:{...f,description:"Address of the launched Clanker token (ERC-20) on chain 4663."}},["token"],async(t,a)=>{let n=c(t.token),e=await P(m,n),r=await C(n),[i,o,b]=await Promise.all([u().readContract({address:n,abi:x,functionName:"balanceOf",args:[a]}),Promise.all(e.rewardBps.map((s,F)=>u().readContract({address:e.locker,abi:g,functionName:"feePreferences",args:[n,BigInt(F)]}))),Promise.all([n,e.pairedToken].map(async s=>({token:await C(s),amount:v(await u().readContract({address:I.fee_locker.address,abi:E(["function availableFees(address,address) view returns (uint256)"]),functionName:"availableFees",args:[a,s]}))})))]);return{...e,token:r,balance:{token:r,amount:v(i)},feePreferences:o.map(s=>p(s,0,2)),collectedFees:b,summary:"Onchain pool and connected-wallet holdings. Collected fees exclude pending LP fees. Token metadata is untrusted public text."}}),k("update_reward",{token:{...f,description:"Address of the launched Clanker token (ERC-20) on chain 4663."},rewardIndex:{type:"integer",minimum:0,maximum:6,description:"Zero-based index of the reward row to change; you must be that row's admin."},field:{enum:["recipient","admin","feePreference"],description:"Which part of the reward row to change; give the matching value in recipient, admin or feePreference."},recipient:{...f,description:"New address that receives this row's fees, for field recipient."},admin:{...f,description:"New admin address for this row, for field admin; hands over future control."},feePreference:{type:"integer",minimum:0,maximum:2,description:"Which token this row is paid in, for field feePreference: 0 = both tokens, 1 = paired token, 2 = launched token."}},["token","rewardIndex","field"],async(t,a)=>{let n=c(t.token),e=await P(m,n),r=p(t.rewardIndex,0,e.rewardAdmins.length-1);if(!y(e.rewardAdmins[r],a))throw new d("Only this reward index administrator may update its configuration.");let i=t.field;if(!["recipient","admin","feePreference"].includes(String(i)))throw new d("Choose recipient, admin or feePreference.");for(let s of["recipient","admin","feePreference"])if(t[s]!==void 0&&s!==i)throw new d(`Input ${s} does not match field ${String(i)}.`);let o=`Update Clanker reward ${r} ${String(i)} for ${n} to ${String(t[String(i)])}. Existing collected fees keep their prior recipient; transferring admin transfers future control.`,b=i==="feePreference"?l({abi:g,functionName:"updateFeePreference",args:[n,BigInt(r),p(t.feePreference,0,2)]}):l({abi:g,functionName:i==="admin"?"updateRewardAdmin":"updateRewardRecipient",args:[n,BigInt(r),c(t[String(i)])]});return A(e.locker,b,o,a)}),k("update_token",{token:{...f,description:"Address of the launched Clanker token (ERC-20) on chain 4663."},field:{enum:["image","metadata","admin","verify","delegate","burn"],description:"Update to make: set image or metadata text, change admin, mark verified, delegate voting power, or burn tokens (irreversible)."},text:{type:"string",description:"New image URL or metadata text, for field image or metadata. Public."},recipient:{...f,description:"New admin address for field admin, or the delegate address for field delegate."},amount:{...S,description:'Amount of the token to burn, in base units (Clanker tokens have 18 decimals). Example: "1000000000000000000" = 1 token. For field burn.'}},["token","field"],async(t,a)=>{let n=c(t.token);await R(m,n);let e=t.field;if(!["image","metadata","admin","verify","delegate","burn"].includes(String(e)))throw new d("Choose a supported token update.");let r=e==="image"||e==="metadata"?"text":e==="admin"||e==="delegate"?"recipient":e==="burn"?"amount":void 0;for(let o of["text","recipient","amount"])if(t[o]!==void 0&&o!==r)throw new d(`Input ${o} does not match this token update.`);if(["image","metadata","admin","verify"].includes(String(e))){let o=await u().readContract({address:n,abi:w,functionName:e==="verify"?"originalAdmin":"admin"});if(!y(c(o),a))throw new d("The connected wallet is not the required token administrator.")}let i;if(e==="image"||e==="metadata"){if(typeof t.text!="string")throw new d("Provide public metadata text.");i=l({abi:w,functionName:e==="image"?"updateImage":"updateMetadata",args:[t.text]})}else if(e==="admin"||e==="delegate")i=l({abi:w,functionName:e==="admin"?"updateAdmin":"delegate",args:[c(t.recipient,e==="delegate")]});else if(e==="verify")i=l({abi:w,functionName:"verify"});else{let o=$(t.amount);if(!o)throw new d("Provide a positive burn amount.");i=l({abi:w,functionName:"burn",args:[o]})}return A(n,i,`Clanker token ${n}: ${String(e)} ${String(t.text??t.recipient??t.amount??"")}. Burns are irreversible; verification records original-admin approval, not an Oak safety review.`,a)})]}};export{U as a};
1
+ import{a as I,b as S,d as g,f as c,g as $,h as p,i as T,k as v,l as R,m as P}from"./PG7HZIZL.js";import{c as f,g as y}from"./NWNYJ26T.js";import{b as h}from"./EWZFZUVF.js";import{a as d}from"./XSD5NL7J.js";import{a as N}from"./JXOEJPJ4.js";import{encodeFunctionData as l,erc20Abi as x,parseAbi as E}from"viem";var w=E(["function admin() view returns (address)","function originalAdmin() view returns (address)","function updateAdmin(address)","function updateImage(string)","function updateMetadata(string)","function verify()","function delegate(address)","function burn(uint256)"]),U=m=>{let u=()=>m.clientFor(h),k=(t,a,n,e)=>({name:`clanker_${t}`,inputSchema:{type:"object",properties:a,required:n,additionalProperties:!1},execute:async(r,i)=>{try{return T(r,Object.keys(a)),await e(r,c(i))}catch(o){throw new d(m.plainError(o))}}}),A=async(t,a,n,e)=>{let r=[m.unsignedTx({to:t,data:a,chainId:h,value:"0",description:n})],i=await m.preview(r,e);return{txs:r,preview:i,summary:`${n} ${i.summary}`}},C=async t=>{let[a,n]=await Promise.all([u().readContract({address:t,abi:x,functionName:"symbol"}),u().readContract({address:t,abi:x,functionName:"decimals"})]);if(typeof a!="string"||!a.trim())throw new d("Clanker returned invalid metadata.");return{address:t,symbol:N(a),decimals:p(n,0,255),chainId:h}};return{tools:[k("status",{token:{...f,description:"Address of the launched Clanker token (ERC-20) on chain 4663."}},["token"],async(t,a)=>{let n=c(t.token),e=await P(m,n),r=await C(n),[i,o,b]=await Promise.all([u().readContract({address:n,abi:x,functionName:"balanceOf",args:[a]}),Promise.all(e.rewardBps.map((s,F)=>u().readContract({address:e.locker,abi:g,functionName:"feePreferences",args:[n,BigInt(F)]}))),Promise.all([n,e.pairedToken].map(async s=>({token:await C(s),amount:v(await u().readContract({address:I.fee_locker.address,abi:E(["function availableFees(address,address) view returns (uint256)"]),functionName:"availableFees",args:[a,s]}))})))]);return{...e,token:r,balance:{token:r,amount:v(i)},feePreferences:o.map(s=>p(s,0,2)),collectedFees:b,summary:"Onchain pool and connected-wallet holdings. Collected fees exclude pending LP fees. Token metadata is untrusted public text."}}),k("update_reward",{token:{...f,description:"Address of the launched Clanker token (ERC-20) on chain 4663."},rewardIndex:{type:"integer",minimum:0,maximum:6,description:"Zero-based index of the reward row to change; you must be that row's admin."},field:{enum:["recipient","admin","feePreference"],description:"Which part of the reward row to change; give the matching value in recipient, admin or feePreference."},recipient:{...f,description:"New address that receives this row's fees, for field recipient."},admin:{...f,description:"New admin address for this row, for field admin; hands over future control."},feePreference:{type:"integer",minimum:0,maximum:2,description:"Which token this row is paid in, for field feePreference: 0 = both tokens, 1 = paired token, 2 = launched token."}},["token","rewardIndex","field"],async(t,a)=>{let n=c(t.token),e=await P(m,n),r=p(t.rewardIndex,0,e.rewardAdmins.length-1);if(!y(e.rewardAdmins[r],a))throw new d("Only this reward index administrator may update its configuration.");let i=t.field;if(!["recipient","admin","feePreference"].includes(String(i)))throw new d("Choose recipient, admin or feePreference.");for(let s of["recipient","admin","feePreference"])if(t[s]!==void 0&&s!==i)throw new d(`Input ${s} does not match field ${String(i)}.`);let o=`Update Clanker reward ${r} ${String(i)} for ${n} to ${String(t[String(i)])}. Existing collected fees keep their prior recipient; transferring admin transfers future control.`,b=i==="feePreference"?l({abi:g,functionName:"updateFeePreference",args:[n,BigInt(r),p(t.feePreference,0,2)]}):l({abi:g,functionName:i==="admin"?"updateRewardAdmin":"updateRewardRecipient",args:[n,BigInt(r),c(t[String(i)])]});return A(e.locker,b,o,a)}),k("update_token",{token:{...f,description:"Address of the launched Clanker token (ERC-20) on chain 4663."},field:{enum:["image","metadata","admin","verify","delegate","burn"],description:"Update to make: set image or metadata text, change admin, mark verified, delegate voting power, or burn tokens (irreversible)."},text:{type:"string",description:"New image URL or metadata text, for field image or metadata. Public."},recipient:{...f,description:"New admin address for field admin, or the delegate address for field delegate."},amount:{...S,description:'Amount of the token to burn, in base units (Clanker tokens have 18 decimals). Example: "1000000000000000000" = 1 token. For field burn.'}},["token","field"],async(t,a)=>{let n=c(t.token);await R(m,n);let e=t.field;if(!["image","metadata","admin","verify","delegate","burn"].includes(String(e)))throw new d("Choose a supported token update.");let r=e==="image"||e==="metadata"?"text":e==="admin"||e==="delegate"?"recipient":e==="burn"?"amount":void 0;for(let o of["text","recipient","amount"])if(t[o]!==void 0&&o!==r)throw new d(`Input ${o} does not match this token update.`);if(["image","metadata","admin","verify"].includes(String(e))){let o=await u().readContract({address:n,abi:w,functionName:e==="verify"?"originalAdmin":"admin"});if(!y(c(o),a))throw new d("The connected wallet is not the required token administrator.")}let i;if(e==="image"||e==="metadata"){if(typeof t.text!="string")throw new d("Provide public metadata text.");i=l({abi:w,functionName:e==="image"?"updateImage":"updateMetadata",args:[t.text]})}else if(e==="admin"||e==="delegate")i=l({abi:w,functionName:e==="admin"?"updateAdmin":"delegate",args:[c(t.recipient,e==="delegate")]});else if(e==="verify")i=l({abi:w,functionName:"verify"});else{let o=$(t.amount);if(!o)throw new d("Provide a positive burn amount.");i=l({abi:w,functionName:"burn",args:[o]})}return A(n,i,`Clanker token ${n}: ${String(e)} ${String(t.text??t.recipient??t.amount??"")}. Burns are irreversible; verification records original-admin approval, not an Oak safety review.`,a)})]}};export{U as a};
@@ -1,3 +1,3 @@
1
- import{a as ke,b as Te}from"./HZSYMGJ2.js";import{b as be,o as we}from"./GYPMUYB5.js";import{a as ye}from"./Z7FGEWO2.js";import{c as ie}from"./SCG5HWMN.js";import{a as O}from"./66F5ZH34.js";import{b as re,c as R,d as fe,g as p,i as he,n as ge}from"./NWNYJ26T.js";import{b as l,j as oe,m as u}from"./TI727O2H.js";import{a as i}from"./XSD5NL7J.js";import{a as F}from"./JXOEJPJ4.js";import{decodeEventLog as qe,encodeAbiParameters as Ue,encodeFunctionData as M,erc20Abi as j,getAddress as Ie,keccak256 as Oe,parseAbi as D,parseAbiItem as Me,toHex as He,zeroAddress as S}from"viem";var ce=oe[l].pons.launchAndBuyRouter.address,Pe=oe[l].ponsTrade.state_view.address,J={address:S,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)"]),z=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))"]),ve=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"]),Fe=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,xe=2000n;function C(n){return he(n,"Provide a token or wallet address.",fe)}function H(n){return ge(n,"Amount exceeds the uint256 range.",{notString:"Amounts must be integer strings in base units."})}function Ce(n,e){if(typeof n!="string"||!n.trim())throw new i(`Provide ${e}.`);return n}function N(n,e){return{token:n,amount:e.toString()}}function Re(n,e,t,r,o){let a=n*BigInt(t)/10000n,s=r?(n-a)*BigInt(o)/10000n:0n;return{baseBps:n.toString(),creatorTaxBps:e.toString(),totalBps:(n+BigInt(e)).toString(),protocolBps:a.toString(),creatorBps:(n-a-s+BigInt(e)).toString(),buybackBps:s.toString(),buybackEnabled:r}}async function Q(n,e,t){if(p(e,S))return J;let r=n.clientFor(l),[o,a]=await Promise.all([r.readContract({address:e,abi:j,functionName:"symbol",blockNumber:t}),r.readContract({address:e,abi:j,functionName:"decimals",blockNumber:t})]);return{address:Ie(e),chainId:l,symbol:F(o),decimals:a}}async function X(n,e,t){let r=n.clientFor(l),[o,a]=await Promise.all([r.readContract({address:e,abi:je,functionName:"launchFactory",blockNumber:t}),r.readContract({address:u,abi:f,functionName:"getLaunchedToken",args:[e],blockNumber:t})]);if(!p(o,u)||!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 de(n,e,t){let r=n.clientFor(l),o=await X(n,e,t),[a,s,d,c,h,g,y]=await Promise.all([Q(n,e,t),Q(n,o.pairToken,t),r.readContract({address:e,abi:j,functionName:"totalSupply",blockNumber:t}),r.readContract({address:o.curve,abi:z,functionName:"factory",blockNumber:t}),r.readContract({address:o.curve,abi:z,functionName:"feeEscrow",blockNumber:t}),r.readContract({address:u,abi:f,functionName:"memeHook",blockNumber:t}),r.readContract({address:u,abi:f,functionName:"getLaunchFeePolicy",args:[e],blockNumber:t})]);if(!p(c,u))throw new i("The Pons curve does not belong to the supported factory.");let m=BigInt(y[3]),A=o.sweptQuote,b=null,T=null,_=null;if(o.phase===0){let[P,I,w]=await Promise.all([r.readContract({address:o.curve,abi:z,functionName:"getReserves",blockNumber:t}),r.readContract({address:o.curve,abi:z,functionName:"realQuoteReserve",blockNumber:t}),r.readContract({address:o.curve,abi:z,functionName:"feeBps",blockNumber:t})]);if(A=I,m=w,o.graduationThreshold<=0n||P[1]<=0n)throw new i("Pons returned unavailable curve reserves or threshold.");b=I*1000000n/o.graduationThreshold,b>1000000n&&(b=1000000n),T=N(s,P[0]*10n**BigInt(a.decimals)/P[1])}else if(o.phase===2){let P=[e,o.pairToken].sort(($,x)=>BigInt($)<BigInt(x)?-1:1),I=Oe(Ue([{type:"address"},{type:"address"},{type:"uint24"},{type:"int24"},{type:"address"}],[P[0],P[1],o.poolFee,o.tickSpacing,g])),[w,q]=await Promise.all([r.readContract({address:Pe,abi:ve,functionName:"getSlot0",args:[I],blockNumber:t}),r.readContract({address:Pe,abi:ve,functionName:"getLiquidity",args:[I],blockNumber:t})]);if(w[0]===0n)throw new i("The graduated Pons pool price is unavailable.");let E=w[0]**2n,U=10n**BigInt(a.decimals);T=N(s,p(P[0],e)?E*U/(1n<<192n):(1n<<192n)*U/E),_={id:I,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:t.toString(),factory:u,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:N(s,o.graduationThreshold),raised:N(s,A),sweptTokens:N(a,o.sweptTokens),sweptAt:o.sweptAt.toString(),progressPpm:b?.toString()??null,totalSupply:N(a,d),fees:Re(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 ze(n,e,t,r){let o=n.clientFor(l),[a,s]=await Promise.all([o.readContract({address:e.token.address,abi:j,functionName:"balanceOf",args:[t],blockNumber:r}),p(e.pairToken.address,S)?o.getBalance({address:t,blockNumber:r}):o.readContract({address:e.pairToken.address,abi:j,functionName:"balanceOf",args:[t],blockNumber:r})]),d;try{let c=await ke(n,e.token.address,t,!1,r),h=c.credited.some(g=>BigInt(g.amount)>0n)||BigInt(c.buybackVest.releasable.amount)>0n;d={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){d={unavailable:n.plainError(c)}}return{holder:t,holding:N(e.token,a),pairBalance:N(e.pairToken,s),creatorFees:d,note:"Sell the actual holding shown here, not a quoted output. Balances are read at the status block."}}async function Qe(n,e,t){try{let r=await n.clientFor(l).getBlockNumber({cacheTime:0}),o=await de(n,C(e),r);return t===void 0?o:{...o,account:await ze(n,o,C(t),r)}}catch(r){throw new i(n.plainError(r))}}var Ae="https://ponsfamily.com/api/launches",Ve=n=>{let e=n;return!!e&&Array.isArray(e.items)&&e.items.length<=100&&(e.nextCursor===null||e.nextCursor===void 0||typeof e.nextCursor=="string")&&e.items.every(t=>!!t&&typeof t.address=="string"&&re.test(t.address)&&typeof t.factory=="string"&&re.test(t.factory))};async function Je(n,e){let t=e.limit??20;if(typeof t!="number"||!Number.isInteger(t)||t<1||t>40)throw new i("Choose a search or listing limit from 1 to 40.");let r=new URL(Ae);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(t));let o=await ie(n.http,r,{method:"GET",redirect:"error"},Ve);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,u)),s=[...new Map(a.map(h=>[h.address.toLowerCase(),Ie(h.address)])).values()].slice(0,t),d=await n.clientFor(l).getBlockNumber({cacheTime:0});return{items:await Promise.all(s.map(h=>de(n,h,d))),statusBlock:d.toString(),source:Ae,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(n,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(n,e)}catch(t){throw new i(n.plainError(t))}return Ne(n,e)}async function Ne(n,e={}){try{let t=n.clientFor(l),r=await t.getBlockNumber({cacheTime:0}),o=e.toBlock===void 0?r:H(e.toBlock),a=e.fromBlock===void 0?o>=xe?o-xe+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 d=await t.getLogs({address:u,event:Fe,fromBlock:a,toBlock:o,strict:!0}),c=new Map;for(let y of d.filter(m=>p(m.address,u)&&!m.removed&&m.blockNumber!==null&&m.blockNumber>=a&&m.blockNumber<=o).sort((m,A)=>m.blockNumber===A.blockNumber?(A.logIndex??0)-(m.logIndex??0):m.blockNumber>A.blockNumber?-1:1)){let m=C(y.args.token);c.set(m.toLowerCase(),m)}let h=[...c.values()];return{items:await Promise.all(h.slice(0,s).map(y=>de(n,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(t){throw new i(n.plainError(t))}}async function K(n,e,t,r){let o=(Array.isArray(e)?e:[e]).map(n.unsignedTx),a=await n.preview(o,t),s=a.changes.map(d=>{let c=d.amount.startsWith("-");return`${c?"-":""}${n.formatAmount(c?d.amount.slice(1):d.amount,d.token.decimals)} ${d.token.symbol} (${d.token.chainId}:${d.token.address})`});return{txs:o,preview:a,summary:`${r} ${a.summary}${s.length?` Changes: ${s.join(", ")}.`:""}`}}var V=["twitter","telegram","discord","website","farcaster"],Be=5242880,$e="https://ponsfamily.com/api/ipfs/image";function se(n,e){if(n==="")return"";if(typeof n!="string"||n.length>2048)throw new i(`Provide a public HTTPS or IPFS ${e}.`);try{let t=new URL(n);if(!["https:","ipfs:"].includes(t.protocol)||!t.hostname||t.username||t.password)throw new Error}catch{throw new i(`Provide a public HTTPS or IPFS ${e}.`)}return n}function Xe(n){if(n===void 0)return;if(!n||typeof n!="object"||Array.isArray(n))throw new i("Provide image mimeType and base64.");let e=n,t={"image/png":"png","image/jpeg":"jpg","image/webp":"webp"};if(Object.keys(e).some(s=>!["mimeType","base64"].includes(s))||typeof e.mimeType!="string"||!t[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
1
+ import{a as ke,b as Te}from"./VS7ZA4OF.js";import{b as be,o as we}from"./TTBB6EFN.js";import{a as ye}from"./7WXAS54T.js";import{c as ie}from"./SCG5HWMN.js";import{a as O}from"./66F5ZH34.js";import{b as re,c as R,d as fe,g as p,i as he,n as ge}from"./NWNYJ26T.js";import{b as l,j as oe,m as u}from"./EWZFZUVF.js";import{a as i}from"./XSD5NL7J.js";import{a as F}from"./JXOEJPJ4.js";import{decodeEventLog as qe,encodeAbiParameters as Ue,encodeFunctionData as M,erc20Abi as j,getAddress as Ie,keccak256 as Oe,parseAbi as D,parseAbiItem as Me,toHex as He,zeroAddress as S}from"viem";var ce=oe[l].pons.launchAndBuyRouter.address,Pe=oe[l].ponsTrade.state_view.address,J={address:S,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)"]),z=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))"]),ve=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"]),Fe=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,xe=2000n;function C(n){return he(n,"Provide a token or wallet address.",fe)}function H(n){return ge(n,"Amount exceeds the uint256 range.",{notString:"Amounts must be integer strings in base units."})}function Ce(n,e){if(typeof n!="string"||!n.trim())throw new i(`Provide ${e}.`);return n}function N(n,e){return{token:n,amount:e.toString()}}function Re(n,e,t,r,o){let a=n*BigInt(t)/10000n,s=r?(n-a)*BigInt(o)/10000n:0n;return{baseBps:n.toString(),creatorTaxBps:e.toString(),totalBps:(n+BigInt(e)).toString(),protocolBps:a.toString(),creatorBps:(n-a-s+BigInt(e)).toString(),buybackBps:s.toString(),buybackEnabled:r}}async function Q(n,e,t){if(p(e,S))return J;let r=n.clientFor(l),[o,a]=await Promise.all([r.readContract({address:e,abi:j,functionName:"symbol",blockNumber:t}),r.readContract({address:e,abi:j,functionName:"decimals",blockNumber:t})]);return{address:Ie(e),chainId:l,symbol:F(o),decimals:a}}async function X(n,e,t){let r=n.clientFor(l),[o,a]=await Promise.all([r.readContract({address:e,abi:je,functionName:"launchFactory",blockNumber:t}),r.readContract({address:u,abi:f,functionName:"getLaunchedToken",args:[e],blockNumber:t})]);if(!p(o,u)||!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 de(n,e,t){let r=n.clientFor(l),o=await X(n,e,t),[a,s,d,c,h,g,y]=await Promise.all([Q(n,e,t),Q(n,o.pairToken,t),r.readContract({address:e,abi:j,functionName:"totalSupply",blockNumber:t}),r.readContract({address:o.curve,abi:z,functionName:"factory",blockNumber:t}),r.readContract({address:o.curve,abi:z,functionName:"feeEscrow",blockNumber:t}),r.readContract({address:u,abi:f,functionName:"memeHook",blockNumber:t}),r.readContract({address:u,abi:f,functionName:"getLaunchFeePolicy",args:[e],blockNumber:t})]);if(!p(c,u))throw new i("The Pons curve does not belong to the supported factory.");let m=BigInt(y[3]),A=o.sweptQuote,b=null,T=null,_=null;if(o.phase===0){let[P,I,w]=await Promise.all([r.readContract({address:o.curve,abi:z,functionName:"getReserves",blockNumber:t}),r.readContract({address:o.curve,abi:z,functionName:"realQuoteReserve",blockNumber:t}),r.readContract({address:o.curve,abi:z,functionName:"feeBps",blockNumber:t})]);if(A=I,m=w,o.graduationThreshold<=0n||P[1]<=0n)throw new i("Pons returned unavailable curve reserves or threshold.");b=I*1000000n/o.graduationThreshold,b>1000000n&&(b=1000000n),T=N(s,P[0]*10n**BigInt(a.decimals)/P[1])}else if(o.phase===2){let P=[e,o.pairToken].sort(($,x)=>BigInt($)<BigInt(x)?-1:1),I=Oe(Ue([{type:"address"},{type:"address"},{type:"uint24"},{type:"int24"},{type:"address"}],[P[0],P[1],o.poolFee,o.tickSpacing,g])),[w,q]=await Promise.all([r.readContract({address:Pe,abi:ve,functionName:"getSlot0",args:[I],blockNumber:t}),r.readContract({address:Pe,abi:ve,functionName:"getLiquidity",args:[I],blockNumber:t})]);if(w[0]===0n)throw new i("The graduated Pons pool price is unavailable.");let E=w[0]**2n,U=10n**BigInt(a.decimals);T=N(s,p(P[0],e)?E*U/(1n<<192n):(1n<<192n)*U/E),_={id:I,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:t.toString(),factory:u,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:N(s,o.graduationThreshold),raised:N(s,A),sweptTokens:N(a,o.sweptTokens),sweptAt:o.sweptAt.toString(),progressPpm:b?.toString()??null,totalSupply:N(a,d),fees:Re(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 ze(n,e,t,r){let o=n.clientFor(l),[a,s]=await Promise.all([o.readContract({address:e.token.address,abi:j,functionName:"balanceOf",args:[t],blockNumber:r}),p(e.pairToken.address,S)?o.getBalance({address:t,blockNumber:r}):o.readContract({address:e.pairToken.address,abi:j,functionName:"balanceOf",args:[t],blockNumber:r})]),d;try{let c=await ke(n,e.token.address,t,!1,r),h=c.credited.some(g=>BigInt(g.amount)>0n)||BigInt(c.buybackVest.releasable.amount)>0n;d={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){d={unavailable:n.plainError(c)}}return{holder:t,holding:N(e.token,a),pairBalance:N(e.pairToken,s),creatorFees:d,note:"Sell the actual holding shown here, not a quoted output. Balances are read at the status block."}}async function Qe(n,e,t){try{let r=await n.clientFor(l).getBlockNumber({cacheTime:0}),o=await de(n,C(e),r);return t===void 0?o:{...o,account:await ze(n,o,C(t),r)}}catch(r){throw new i(n.plainError(r))}}var Ae="https://ponsfamily.com/api/launches",Ve=n=>{let e=n;return!!e&&Array.isArray(e.items)&&e.items.length<=100&&(e.nextCursor===null||e.nextCursor===void 0||typeof e.nextCursor=="string")&&e.items.every(t=>!!t&&typeof t.address=="string"&&re.test(t.address)&&typeof t.factory=="string"&&re.test(t.factory))};async function Je(n,e){let t=e.limit??20;if(typeof t!="number"||!Number.isInteger(t)||t<1||t>40)throw new i("Choose a search or listing limit from 1 to 40.");let r=new URL(Ae);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(t));let o=await ie(n.http,r,{method:"GET",redirect:"error"},Ve);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,u)),s=[...new Map(a.map(h=>[h.address.toLowerCase(),Ie(h.address)])).values()].slice(0,t),d=await n.clientFor(l).getBlockNumber({cacheTime:0});return{items:await Promise.all(s.map(h=>de(n,h,d))),statusBlock:d.toString(),source:Ae,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(n,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(n,e)}catch(t){throw new i(n.plainError(t))}return Ne(n,e)}async function Ne(n,e={}){try{let t=n.clientFor(l),r=await t.getBlockNumber({cacheTime:0}),o=e.toBlock===void 0?r:H(e.toBlock),a=e.fromBlock===void 0?o>=xe?o-xe+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 d=await t.getLogs({address:u,event:Fe,fromBlock:a,toBlock:o,strict:!0}),c=new Map;for(let y of d.filter(m=>p(m.address,u)&&!m.removed&&m.blockNumber!==null&&m.blockNumber>=a&&m.blockNumber<=o).sort((m,A)=>m.blockNumber===A.blockNumber?(A.logIndex??0)-(m.logIndex??0):m.blockNumber>A.blockNumber?-1:1)){let m=C(y.args.token);c.set(m.toLowerCase(),m)}let h=[...c.values()];return{items:await Promise.all(h.slice(0,s).map(y=>de(n,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(t){throw new i(n.plainError(t))}}async function K(n,e,t,r){let o=(Array.isArray(e)?e:[e]).map(n.unsignedTx),a=await n.preview(o,t),s=a.changes.map(d=>{let c=d.amount.startsWith("-");return`${c?"-":""}${n.formatAmount(c?d.amount.slice(1):d.amount,d.token.decimals)} ${d.token.symbol} (${d.token.chainId}:${d.token.address})`});return{txs:o,preview:a,summary:`${r} ${a.summary}${s.length?` Changes: ${s.join(", ")}.`:""}`}}var V=["twitter","telegram","discord","website","farcaster"],Be=5242880,$e="https://ponsfamily.com/api/ipfs/image";function se(n,e){if(n==="")return"";if(typeof n!="string"||n.length>2048)throw new i(`Provide a public HTTPS or IPFS ${e}.`);try{let t=new URL(n);if(!["https:","ipfs:"].includes(t.protocol)||!t.hostname||t.username||t.password)throw new Error}catch{throw new i(`Provide a public HTTPS or IPFS ${e}.`)}return n}function Xe(n){if(n===void 0)return;if(!n||typeof n!="object"||Array.isArray(n))throw new i("Provide image mimeType and base64.");let e=n,t={"image/png":"png","image/jpeg":"jpg","image/webp":"webp"};if(Object.keys(e).some(s=>!["mimeType","base64"].includes(s))||typeof e.mimeType!="string"||!t[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
2
  
3
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:t[e.mimeType]}}async function Ye(n,e,t){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 n.clientFor(l).getTransactionReceipt({hash:e});if(o.status!=="success"||!p(o.from,t))throw new i("The Pons launch must be a successful transaction from this wallet.");let a=o.logs.flatMap(c=>{if(!p(c.address,u))return[];try{return[qe({abi:[Fe],data:c.data,topics:c.topics,strict:!0}).args]}catch{return[]}}).filter(c=>p(c.deployer,t));if(a.length!==1)throw new i("The receipt does not contain exactly one Pons launch for this wallet.");let s=a[0].token,d=await X(n,s,o.blockNumber);return{transactionHash:e,token:await Q(n,s,o.blockNumber),curve:d.curve,creator:d.deployer,creatorFeeRecipient:d.creatorFeeRecipient,chainId:l,summary:`Pons launch mined: ${s}. Creator fee recipient ${d.creatorFeeRecipient}. Use pons_status to inspect the launch and pons_claim to collect creator fees.`}}async function Ze(n,e,t){let r=Ce(e.name,"a coin name"),o=Ce(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=C(e.creatorFeeRecipient);if(p(a,S))throw new i("Provide a nonzero creator fee recipient.");if(!p(a,t))throw new i("Pons creator fee recipient must be the signing wallet.");let s=C(e.pairToken??S),d=H(e.launchConfigId??"0"),c=H(e.initialBuy??"0"),h=C(e.buyRecipient??t);if(p(h,S))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,t)&&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 A=e.metadata??["",""],b=e.links??["","","","",""];if(!Array.isArray(A)||A.length!==2||!A.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??A[0],"coin image URI"),_=e.description??A[1];if(typeof _!="string")throw new i("Provide a coin description string.");let P=e.socials;if(P!==void 0&&(!P||typeof P!="object"||Array.isArray(P)||Object.keys(P).some(k=>!V.includes(k))))throw new i("Provide twitter, telegram, discord, website and farcaster social links.");let I=V.map((k,v)=>se(P===void 0?b[v]:P[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(C),U=e.salt??He(crypto.getRandomValues(new Uint8Array(32)));if(typeof U!="string"||!/^0x[0-9a-fA-F]{64}$/.test(U))throw new i("Salt must be 32 hex-encoded bytes.");let $=n.clientFor(l),x=await $.getBlockNumber({cacheTime:0}),[ue,Ee]=await Promise.all([$.readContract({address:u,abi:f,functionName:"canLaunch",args:[t],blockNumber:x}),$.readContract({address:u,abi:f,functionName:"launchConfigCount",blockNumber:x})]);if(!ue)throw new i("This wallet cannot launch on Pons. Ask Pons for launch access and retry when canLaunch is true.");if(d>=Ee)throw new i("Choose an existing Pons launchConfigId using pons_launch_options.");let[Y,W,Le,_e]=await Promise.all([$.readContract({address:u,abi:f,functionName:"launchFee",blockNumber:x}),$.readContract({address:u,abi:f,functionName:"getLaunchConfig",args:[d],blockNumber:x}),$.readContract({address:u,abi:f,functionName:"maxCreatorTaxBps",blockNumber:x}),$.readContract({address:u,abi:f,functionName:"memeHook",blockNumber:x})]);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,S)){let[k,v]=await Promise.all([$.readContract({address:u,abi:f,functionName:"approvedPairTokens",args:[s],blockNumber:x}),$.readContract({address:u,abi:f,functionName:"pairTokenEconomics",args:[s],blockNumber:x})]);if(!k||v[0]<=0n||v[1]<=0n)throw new i("This pair token is not approved with usable Pons economics. Choose a supported pair.");if(L=await Q(n,s,x),v[2]!==L.decimals)throw new i("Pair token decimals disagree with Pons. Ask Pons to refresh pair economics.");[le,pe]=v}if(BigInt(y)>Le)throw new i("Creator tax exceeds the current Pons maximum.");let[Z,ee]=await Promise.all([$.readContract({address:u,abi:f,functionName:"previewLaunchEconomics",args:[d,s],blockNumber:x}),$.readContract({address:_e,abi:De,functionName:"currentFeePolicy",blockNumber:x})]);if(e.expectedEconomics!==void 0&&e.expectedEconomics!==Z)throw new i("Pons launch economics changed. Refresh the launch preview.");let G=Re(W.curveFeeBps,y,ee[1],m,ee[2]),te="";if(w){let k=new FormData;k.append("image",new Blob([w.bytes],{type:w.mimeType}),`coin.${w.extension}`);let v=await ie(n.http,$e,{method:"POST",body:k,redirect:"error"},B=>!!B&&typeof B=="object"&&typeof B.uri=="string");if(T=se(v.uri,"uploaded coin image URI"),!T)throw new i("Pons returned an empty image URI. Retry with a public image URI.");te=`Image (${w.bytes.length} bytes, ${w.mimeType}) uploaded via multipart POST to ${$e}; URI ${F(T)}. This off-chain upload persists even if launch is cancelled or fails; Pons retention/deletion is unknown.`}let ne=k=>{let v=[r,o,T,_,I,a,y,m,Z,U],B={to:c===0n?u:ce,chainId:l,value:(Y+(p(s,S)?c:0n)).toString(),data:c===0n?E.length?M({abi:ae,functionName:"launchToken",args:[v,d,s,E]}):M({abi:ae,functionName:"launchToken",args:[v,d,s]}):M({abi:ae,functionName:"launchAndBuy",args:[v,d,s,c,k,h,E]}),description:`Launch ${F(r)} through the Pons ${c===0n?"factory":"router"} from ${t}; creator fees to ${a}. ${te}`.trim()};return c>0n&&!p(s,S)?[n.approval(s,ce,c.toString(),l),B]:[B]};if(c>0n&&e.minTokensOut===void 0){let v=(await n.preview(ne(0n).map(n.unsignedTx),t)).changes.filter(B=>B.token.chainId===l&&!p(B.token.address,S)&&!p(B.token.address,ye)&&!p(B.token.address,s)&&B.token.decimals===18&&/^\d+$/.test(B.amount)&&BigInt(B.amount)>0n);if(v.length!==1)throw new i("Pons launch preview did not identify a unique initial buy token output.");if(g=BigInt(we(v[0].amount,be)),g<=1n)throw new i("Initial buy minimum must exceed one token base unit.")}let me=await K(n,ne(g),t,`Unsigned Pons launch from ${t}: ${F(r)} (${F(o)}), image ${T?F(T):"none"}, description ${F(_)}, links ${JSON.stringify(Object.fromEntries(V.map((k,v)=>[k,F(I[v])])))}. canLaunch=true at block ${x}; config ${d}, supply ${W.supply}, phantom quote ${le}, graduation threshold ${pe} pair base units. Pair ${L.symbol} (${l}:${L.address}, ${L.decimals} decimals). Initial buy ${n.formatAmount(c.toString(),L.decimals)} ${L.symbol} to ${h}; minimum ${g} token base units (18 decimals). Launch fee ${n.formatAmount(Y.toString(),18)} ETH plus gas; exact transaction value ${ne(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. ${te}`);return{...me,creatorFeeWarning:void 0,preview:{...me.preview,warnings:[]},canLaunch:ue,blockNumber:x.toString(),launchConfigId:d.toString(),pairToken:L,salt:U,logo:T&&F(T),economics:Z,launchFee:N(J,Y),initialBuy:N(L,c),minimum:{amount:g.toString(),decimals:18,token:{chainId:l,address:null,name:F(r),symbol:F(o)},addressStatus:"Read the mined token address with pons_launch transactionHash; the local bridge does this automatically."},fees:G}}async function et(n,e,t){let r=n.clientFor(l),o=await r.getBlockNumber({cacheTime:0}),a=C(e.pairToken??S),[s,d,c,h]=await Promise.all([r.readContract({address:u,abi:f,functionName:"canLaunch",args:[t],blockNumber:o}),r.readContract({address:u,abi:f,functionName:"launchConfigCount",blockNumber:o}),r.readContract({address:u,abi:f,functionName:"launchFee",blockNumber:o}),r.readContract({address:u,abi:f,functionName:"maxCreatorTaxBps",blockNumber:o})]),g=H(e.offset??"0"),y=await Promise.all(Array.from({length:Number(d>g?d-g>100n?100n:d-g:0n)},async(_,P)=>{let I=g+BigInt(P),w=await r.readContract({address:u,abi:f,functionName:"getLaunchConfig",args:[I],blockNumber:o});return{id:I.toString(),...Object.fromEntries(Object.entries(w).map(([q,E])=>[q,typeof E=="bigint"?E.toString():E]))}})),m=p(a,S),[A,b,T]=await Promise.all([m?!0:r.readContract({address:u,abi:f,functionName:"approvedPairTokens",args:[a],blockNumber:o}),m?void 0:r.readContract({address:u,abi:f,functionName:"pairTokenEconomics",args:[a],blockNumber:o}),Q(n,a,o)]);return{chainId:l,factory:u,router:ce,blockNumber:o.toString(),canLaunch:s,launchFee:N(J,c),maxCreatorTaxBps:h.toString(),configs:y,configCount:d.toString(),nextOffset:g+BigInt(y.length)<d?(g+BigInt(y.length)).toString():null,pairToken:T,pairApproved:A&&(!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 Se(n,e,t,r){let o=C(e.token),a=await X(n,o,await n.clientFor(l).getBlockNumber({cacheTime:0}));if(!p(a.creatorFeeRecipient,t))throw new i(`Only the current creator fee recipient ${a.creatorFeeRecipient} can change this setting. Use that wallet.`);if(r){let s=C(e.creatorFeeRecipient);if(p(s,S))throw new i("Provide a nonzero creator fee recipient.");return K(n,{to:u,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}.`},t,`Unsigned Pons fee recipient transfer to ${s}; previously credited fees stay with ${t}. 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(n,{to:u,chainId:l,value:"0",data:M({abi:f,functionName:"setBuybackEnabled",args:[o,e.enabled]}),description:`Turn Pons buybacks ${e.enabled?"on":"off"} for ${o}.`},t,`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 tt=n=>{function e(t,r,o,a){return{name:t,inputSchema:{type:"object",properties:r,required:o,additionalProperties:!1,...t==="pons_launch"?{anyOf:[{required:["transactionHash"]},{required:["name","symbol","creatorFeeRecipient"]}]}:{},...t==="pons_browse"?{allOf:[{if:{anyOf:[{required:["query"]},{required:["cursor"]},{properties:{complete:{description:"Request a complete paginated listing through the Pons index.",const:!0}},required:["complete"]}]},then:{properties:{limit:{description:"Maximum number of results to return, within the stated bounds.",maximum:40}}}}]}:{}},execute:async(s,d)=>{try{C(d);for(let c of Object.keys(s))if(!(c in r))throw new i(`Unknown ${t} input: ${c}.`);return await a(s,d)}catch(c){throw new i(n.plainError(c))}}}}return{tools:[e("pons_browse",{fromBlock:O("First block number of the scan, as a decimal string; inclusive."),toBlock:O("Last block number of the scan, as a decimal string; inclusive."),limit:{type:"integer",minimum:1,maximum:100,description:"At most 40 for query, cursor or complete listings; at most 100 for an on-chain block window."},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."}},[],t=>Ke(n,t)),e("pons_status",{token:{...R,description:"Address of the token to inspect or use."},holder:{...R,description:"Holder address to inspect; defaults to the signing wallet."}},["token"],(t,r)=>Qe(n,C(t.token),C(t.holder??r))),e("pons_launch_options",{pairToken:{...R,description:"Launch pair token address; the zero address means native ETH."},offset:O("Launch configuration list offset, as a decimal string; defaults to zero.")},[],(t,r)=>et(n,t,r)),e("pons_transfer_creator_fee_recipient",{token:{...R,description:"Address of the token to inspect or use."},creatorFeeRecipient:{...R,description:"New nonzero recipient address for future creator fees; use the intended recipient."}},["token","creatorFeeRecipient"],(t,r)=>Se(n,t,r,!0)),e("pons_set_buyback",{token:{...R,description:"Address of the token to inspect or use."},enabled:{description:"Whether to enable creator buybacks.",type:"boolean"}},["token","enabled"],(t,r)=>Se(n,t,r,!1)),e("pons_launch",{name:{description:"Name for the new launch token.",type:"string",minLength:1},symbol:{description:"Symbol for the new launch token.",type:"string",minLength:1},creatorFeeRecipient:{...R,description:"Creator-fee recipient address; must be the nonzero signing wallet."},pairToken:{...R,description:"Launch pair token address; the zero address means native ETH."},launchConfigId:O('Identifier of the Pons launch configuration, as a decimal string, from pons_launch_options. Example: "1".'),buyRecipient:{...R,description:"Recipient address for the initial buy; defaults to the signing wallet and requires initialBuy."},logo:{description:"Public HTTPS or IPFS logo URI, or empty; cannot combine a nonempty logo with image upload.",type:"string"},description:{description:"Plain-text description of the launch token.",type:"string"},socials:{description:"Social links keyed by twitter, telegram, discord, website or farcaster.",type:"object",properties:Object.fromEntries(V.map(t=>[t,{type:"string",description:`Public HTTPS or IPFS URI for the token's ${t} page, or empty.`}])),additionalProperties:!1},image:{description:"Launch image upload with its MIME type and base64-encoded content.",type:"object",properties:{mimeType:{description:"Image content type: PNG, JPEG or WebP.",type:"string",enum:["image/png","image/jpeg","image/webp"]},base64:{description:"Base64-encoded image bytes without a data URL prefix.",type:"string",minLength:1,maxLength:6990508}},required:["mimeType","base64"],additionalProperties:!1},snipeTaxExemptions:{description:"Up to 31 wallet addresses exempt from the launch snipe tax; use intended addresses.",type:"array",items:R,maxItems:31},transactionHash:{description:"Confirmed launch transaction hash as a 32-byte hex string; use to recover a submitted launch.",type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},initialBuy:O('Initial buy amount of pair token in base units; use pair token decimals. Example: "1000000" = 1 pair token at 6 decimals.'),minTokensOut:O('Minimum launch-token output in base units (18 decimals). Example: "1000000000000000000" = 1 launch token.'),creatorTaxBps:{description:"Creator tax in basis points (50 = 0.5%); cannot exceed the current maximum from pons_launch_options.",type:"integer",minimum:0,maximum:65535},buybackEnabled:{description:"Whether creator buybacks are enabled for this launch.",type:"boolean"},expectedEconomics:{description:"Economics hash from the prior pons_launch result, as a 32-byte hex string; confirms changed terms on retry.",type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},salt:{description:"Deployment salt as a 32-byte hex string; choose a fresh value for a new deployment.",type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},metadata:{description:"Legacy metadata tuple: [logo URL, token description].",type:"array",items:{type:"string"},minItems:2,maxItems:2},links:{description:"Legacy social URL tuple: [twitter, telegram, discord, website, farcaster].",type:"array",items:{type:"string"},minItems:5,maxItems:5}},[],(t,r)=>t.transactionHash===void 0?Ze(n,t,r):Ye(n,t.transactionHash,r)),e("pons_graduate",{token:{...R,description:"Address of the token to inspect or use."}},["token"],async(t,r)=>{let o=C(t.token);if((await X(n,o,await n.clientFor(l).getBlockNumber({cacheTime:0}))).phase!==1)throw new i("Graduation requires a launch pending pool creation (phase 1).");return K(n,{to:u,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 t=>{try{C(t);let r=await Ne(n,{limit:100}),o=r.items.filter(a=>p(a.creator,t)||p(a.creatorFeeRecipient,t));return await Promise.all(o.map(async a=>{let s=await n.clientFor(l).readContract({address:a.token.address,abi:j,functionName:"balanceOf",args:[t],blockNumber:BigInt(a.blockNumber)});return{module:"pons",id:`${l}:${a.token.address}`,chainId:l,assets:[N(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(n.plainError(r))}}}},pt=tt;export{X as a,de as b,Qe as c,Ke as d,tt as e,pt as f};
@@ -0,0 +1 @@
1
+ import{a as c,b as u,e as a}from"./ZB67QDN2.js";import{b as R}from"./3YNXQ3EZ.js";import{g as T}from"./627SGCTU.js";import{a as O,b as d,e as P}from"./JYED2PZ3.js";import{a as s,c as f,h as H}from"./LHC2YV2U.js";import{c as A}from"./6RVAV6BB.js";import{a as C}from"./ZTNBX4VH.js";import{d as L}from"./AZBTNUXF.js";import{a as h,b as m}from"./NUTTPUYJ.js";import{e as _}from"./3XY44BP5.js";import{m as n}from"./UMY6SP7C.js";import{a as k}from"./XSD5NL7J.js";var B=[...s,...O,"hookr_launch","hookr_action","hookr_revenue_action","hookr_addon_action","hookr_agent_link","hookr_reviewer_set","hookr_claim","hookr_swap",...c];async function F(o,r,i,p,e={}){if(f(o))return H(o,r,i,p);if(o==="hookr_swap")return _(r,i,p,e);if(u(o)){let t=await a(o,r,i,p,e);return{...t,terms:{...n(t.terms),gasLimits:t.txs.map(S=>S.gasLimit)}}}if(o==="hookr_agent_link")return h(r,i,p);if(o==="hookr_reviewer_set")return m(r,i,p);if(o==="hookr_claim")return A(r,i,p);if(d(o))return P(o,r,i,p);if(o==="hookr_launch")return T(r,i,p);if(o==="hookr_action")return L(r,i,p);if(o==="hookr_revenue_action")return R(r,i,p);if(o==="hookr_addon_action")return C(r,i,p);throw new k("This Hookr tool has no local action reconstruction.")}export{B as a,F as b};
@@ -1 +1 @@
1
- import{a as N}from"./A3PN3PK3.js";import{g as O,h as Y}from"./X24YTJST.js";import{a as j}from"./43LI5NKJ.js";import{b as s,k as S}from"./TI727O2H.js";import{a as n}from"./XSD5NL7J.js";import{getAddress as c}from"viem";var R=["one_hour","six_hours","one_day","seven_days","thirty_days","ninety_days","one_year","inception"],A=["one_day","seven_days","thirty_days","ninety_days","one_year","inception"],P={apy:["v1","apy-averages"],allocations:["v0","allocations"],history:["v0","state/history"],pending_governance:["v0","pending-governance-actions"]};function f(o){if(!o||typeof o!="object"||Array.isArray(o))throw new n("Morpho analytics returned an invalid object.");return o}function _(o){if(typeof o!="string"||!/^\d+$/.test(o)||BigInt(o)>=1n<<256n)throw new n("Morpho analytics returned an invalid decimal base-unit amount.");return o}function H(o,d){let r=f(o);if(![s,String(s)].includes(r.chain_id)||typeof r.vault_address!="string"||c(r.vault_address)!==c(d))throw new n("Morpho analytics returned another chain or vault.")}function b(o,d=0){if(d>12)throw new n("Morpho analytics response is too deeply nested.");if(Array.isArray(o))return o.map(r=>b(r,d+1));if(o&&typeof o=="object")return Object.fromEntries(Object.entries(o).map(([r,e])=>{if(e!==null&&/(?:_assets|_shares|_supply|_cap|_wad|_ray)$/.test(r)&&typeof e!="object")return[r,_(e)];if(e!==null&&/_address$/.test(r)){if(typeof e!="string")throw new n("Morpho analytics returned an invalid address.");return[r,c(e)]}return[r,b(e,d+1)]}));if(typeof o=="number"&&!Number.isFinite(o))throw new n("Morpho analytics returned a non-finite value.");return o}function G(o,d,r){return{name:d,inputSchema:{type:"object",additionalProperties:!1,required:["view"],properties:{view:{type:"string",enum:Object.keys(P),description:'Which analytics to read (required): "apy" realized yield over a lookback; "allocations" where the vault funds sit; "history" past totals and share price; "pending_governance" queued curator changes.'},lookback:{type:"string",enum:R,description:"APY window: one_hour through inception. History: one_day, seven_days, thirty_days, ninety_days, one_year or inception. Defaults to six_hours for APY or seven_days for history."},cursor:{type:"string",maxLength:4096,description:"Opaque cursor from pending_governance only."},limit:{type:"integer",minimum:1,maximum:100,description:"Rows per page, 1 to 100 (defaults to 100). Only for view pending_governance; use cursor for the next page."}},allOf:[{if:{properties:{view:{const:"history",description:'When view is "history".'}},required:["view"]},then:{properties:{lookback:{enum:A,description:"History window: one_day, seven_days, thirty_days, ninety_days, one_year or inception (no sub-day history)."}}}}]},execute:async(e,$)=>{try{if(j($),Object.keys(e).some(t=>!["view","lookback","cursor","limit"].includes(t))||typeof e.view!="string"||!Object.hasOwn(P,e.view))throw new n("Choose a documented Morpho analytics view.");let a=e.view,y=a==="history",w=a==="apy",k=a==="pending_governance";if(e.lookback!==void 0&&(!y&&!w||typeof e.lookback!="string"||!R.includes(e.lookback)))throw new n("lookback is available only for APY/history with a documented window.");if(y&&e.lookback!==void 0&&!A.includes(e.lookback))throw new n(`Choose a history lookback from ${A.join(", ")}; sub-day history is unavailable.`);if(!k&&(e.cursor!==void 0||e.limit!==void 0))throw new n("Pagination applies only to pending_governance.");if(e.cursor!==void 0&&(typeof e.cursor!="string"||e.cursor.length>4096))throw new n("Provide the opaque pending-governance cursor string.");let p=e.limit??100;if(typeof p!="number"||!Number.isInteger(p)||p<1||p>100)throw new n("Pagination limit must be an integer from 1 to 100.");let[q,D]=P[a],u=new URL(`https://api.morpho.org/${q}/vaults-v2/${s}:${c(r)}/${D}`);(y||w)&&u.searchParams.set("lookback",String(e.lookback??(y?"seven_days":"six_hours"))),k&&(u.searchParams.set("limit",String(p)),e.cursor!==void 0&&u.searchParams.set("cursor",e.cursor));let g=await o.http(u.toString(),{headers:{accept:"application/json"},signal:AbortSignal.timeout(15e3)});if(!g.ok)throw new n(`Morpho analytics HTTP ${g.status}. Retry when the service is reachable; no zero APY or empty book was inferred.`);let i=f(await g.json());H(w||a==="allocations"?i.data:i.params,r);let m,h=i.last_indexed_block,x=null,I=!1;if(w){let t=f(i.data);if(t.lookback!==(e.lookback??"six_hours")||t.apy!==null&&(typeof t.apy!="number"||!Number.isFinite(t.apy)||t.apy<-1))throw new n("Morpho analytics returned an invalid APY or lookback.");m={annualYieldFraction:t.apy===null?null:String(t.apy),...t.apy===null?{status:"unavailable",reason:"Not enough history for the requested APY window."}:{},lookback:t.lookback,basis:"Realized post-fee share-price APY, excluding rewards; historical observation, not a promised return."},h=t.last_indexed_block,I=t.apy===0}else if(a==="allocations"){let t=f(i.data);if(!Array.isArray(t.allocations))throw new n("Morpho analytics omitted adapter allocations.");m=b(t.allocations),h=t.last_indexed_block}else{if(!Array.isArray(i.data))throw new n("Morpho analytics omitted its record array.");if(y)for(let t of i.data){let l=f(t);if(typeof l.timestamp!="number"||!Number.isSafeInteger(l.timestamp)||l.timestamp<0)throw new n("Morpho history returned an invalid timestamp.");for(let C of["total_assets","total_supply","withdrawable_assets","allocated_assets","idle_assets"])_(l[C]);l.share_price_ray!==null&&_(l.share_price_ray)}if(k){if(i.cursor!==null&&typeof i.cursor!="string")throw new n("Morpho analytics returned an invalid pagination cursor.");x=i.cursor}m=b(i.data)}h!==void 0&&_(h);let v=o.clientFor(s);if(await v.getChainId()!==s)throw new n("Vault share metadata requires chain 4663.");let T=await N(v,c(r)),M=I&&await Y(v,c(r))===!0?O:void 0;return{vault:c(r),chainId:s,sourceUrl:u.toString(),view:a,lastIndexedBlock:h??null,cursor:x,data:m,...M?{note:M}:{},asset:{address:c(S),symbol:"USDG",decimals:6,chainId:s},shareToken:{address:c(r),symbol:T,decimals:18,chainId:s},scales:{sharePriceRay:"1000000000000000000000000000",capWad:"1000000000000000000"},caveat:"Indexer data may lag the chain. APY excludes rewards; empty records describe only this API window/page. Re-read onchain state and preview before any action. API book data is never executed as calldata automatically."}}catch(a){throw new n(o.plainError(a))}}}}export{G as a};
1
+ import{a as N}from"./A3PN3PK3.js";import{g as O,h as Y}from"./IY7FWTAL.js";import{a as j}from"./43LI5NKJ.js";import{b as s,k as S}from"./EWZFZUVF.js";import{a as n}from"./XSD5NL7J.js";import{getAddress as c}from"viem";var R=["one_hour","six_hours","one_day","seven_days","thirty_days","ninety_days","one_year","inception"],A=["one_day","seven_days","thirty_days","ninety_days","one_year","inception"],P={apy:["v1","apy-averages"],allocations:["v0","allocations"],history:["v0","state/history"],pending_governance:["v0","pending-governance-actions"]};function f(o){if(!o||typeof o!="object"||Array.isArray(o))throw new n("Morpho analytics returned an invalid object.");return o}function _(o){if(typeof o!="string"||!/^\d+$/.test(o)||BigInt(o)>=1n<<256n)throw new n("Morpho analytics returned an invalid decimal base-unit amount.");return o}function H(o,d){let r=f(o);if(![s,String(s)].includes(r.chain_id)||typeof r.vault_address!="string"||c(r.vault_address)!==c(d))throw new n("Morpho analytics returned another chain or vault.")}function b(o,d=0){if(d>12)throw new n("Morpho analytics response is too deeply nested.");if(Array.isArray(o))return o.map(r=>b(r,d+1));if(o&&typeof o=="object")return Object.fromEntries(Object.entries(o).map(([r,e])=>{if(e!==null&&/(?:_assets|_shares|_supply|_cap|_wad|_ray)$/.test(r)&&typeof e!="object")return[r,_(e)];if(e!==null&&/_address$/.test(r)){if(typeof e!="string")throw new n("Morpho analytics returned an invalid address.");return[r,c(e)]}return[r,b(e,d+1)]}));if(typeof o=="number"&&!Number.isFinite(o))throw new n("Morpho analytics returned a non-finite value.");return o}function G(o,d,r){return{name:d,inputSchema:{type:"object",additionalProperties:!1,required:["view"],properties:{view:{type:"string",enum:Object.keys(P),description:'Which analytics to read (required): "apy" realized yield over a lookback; "allocations" where the vault funds sit; "history" past totals and share price; "pending_governance" queued curator changes.'},lookback:{type:"string",enum:R,description:"APY window: one_hour through inception. History: one_day, seven_days, thirty_days, ninety_days, one_year or inception. Defaults to six_hours for APY or seven_days for history."},cursor:{type:"string",maxLength:4096,description:"Opaque cursor from pending_governance only."},limit:{type:"integer",minimum:1,maximum:100,description:"Rows per page, 1 to 100 (defaults to 100). Only for view pending_governance; use cursor for the next page."}},allOf:[{if:{properties:{view:{const:"history",description:'When view is "history".'}},required:["view"]},then:{properties:{lookback:{enum:A,description:"History window: one_day, seven_days, thirty_days, ninety_days, one_year or inception (no sub-day history)."}}}}]},execute:async(e,$)=>{try{if(j($),Object.keys(e).some(t=>!["view","lookback","cursor","limit"].includes(t))||typeof e.view!="string"||!Object.hasOwn(P,e.view))throw new n("Choose a documented Morpho analytics view.");let a=e.view,y=a==="history",w=a==="apy",k=a==="pending_governance";if(e.lookback!==void 0&&(!y&&!w||typeof e.lookback!="string"||!R.includes(e.lookback)))throw new n("lookback is available only for APY/history with a documented window.");if(y&&e.lookback!==void 0&&!A.includes(e.lookback))throw new n(`Choose a history lookback from ${A.join(", ")}; sub-day history is unavailable.`);if(!k&&(e.cursor!==void 0||e.limit!==void 0))throw new n("Pagination applies only to pending_governance.");if(e.cursor!==void 0&&(typeof e.cursor!="string"||e.cursor.length>4096))throw new n("Provide the opaque pending-governance cursor string.");let p=e.limit??100;if(typeof p!="number"||!Number.isInteger(p)||p<1||p>100)throw new n("Pagination limit must be an integer from 1 to 100.");let[q,D]=P[a],u=new URL(`https://api.morpho.org/${q}/vaults-v2/${s}:${c(r)}/${D}`);(y||w)&&u.searchParams.set("lookback",String(e.lookback??(y?"seven_days":"six_hours"))),k&&(u.searchParams.set("limit",String(p)),e.cursor!==void 0&&u.searchParams.set("cursor",e.cursor));let g=await o.http(u.toString(),{headers:{accept:"application/json"},signal:AbortSignal.timeout(15e3)});if(!g.ok)throw new n(`Morpho analytics HTTP ${g.status}. Retry when the service is reachable; no zero APY or empty book was inferred.`);let i=f(await g.json());H(w||a==="allocations"?i.data:i.params,r);let m,h=i.last_indexed_block,x=null,I=!1;if(w){let t=f(i.data);if(t.lookback!==(e.lookback??"six_hours")||t.apy!==null&&(typeof t.apy!="number"||!Number.isFinite(t.apy)||t.apy<-1))throw new n("Morpho analytics returned an invalid APY or lookback.");m={annualYieldFraction:t.apy===null?null:String(t.apy),...t.apy===null?{status:"unavailable",reason:"Not enough history for the requested APY window."}:{},lookback:t.lookback,basis:"Realized post-fee share-price APY, excluding rewards; historical observation, not a promised return."},h=t.last_indexed_block,I=t.apy===0}else if(a==="allocations"){let t=f(i.data);if(!Array.isArray(t.allocations))throw new n("Morpho analytics omitted adapter allocations.");m=b(t.allocations),h=t.last_indexed_block}else{if(!Array.isArray(i.data))throw new n("Morpho analytics omitted its record array.");if(y)for(let t of i.data){let l=f(t);if(typeof l.timestamp!="number"||!Number.isSafeInteger(l.timestamp)||l.timestamp<0)throw new n("Morpho history returned an invalid timestamp.");for(let C of["total_assets","total_supply","withdrawable_assets","allocated_assets","idle_assets"])_(l[C]);l.share_price_ray!==null&&_(l.share_price_ray)}if(k){if(i.cursor!==null&&typeof i.cursor!="string")throw new n("Morpho analytics returned an invalid pagination cursor.");x=i.cursor}m=b(i.data)}h!==void 0&&_(h);let v=o.clientFor(s);if(await v.getChainId()!==s)throw new n("Vault share metadata requires chain 4663.");let T=await N(v,c(r)),M=I&&await Y(v,c(r))===!0?O:void 0;return{vault:c(r),chainId:s,sourceUrl:u.toString(),view:a,lastIndexedBlock:h??null,cursor:x,data:m,...M?{note:M}:{},asset:{address:c(S),symbol:"USDG",decimals:6,chainId:s},shareToken:{address:c(r),symbol:T,decimals:18,chainId:s},scales:{sharePriceRay:"1000000000000000000000000000",capWad:"1000000000000000000"},caveat:"Indexer data may lag the chain. APY excludes rewards; empty records describe only this API window/page. Re-read onchain state and preview before any action. API book data is never executed as calldata automatically."}}catch(a){throw new n(o.plainError(a))}}}}export{G as a};
@@ -1 +1 @@
1
- import{a as g,b as p}from"./2OVJ2BTJ.js";import{a as y,b as D,c as m,d as T,e as I}from"./GQITAJVF.js";import{c as O,d as A,f as P,g as R}from"./OUROA7XR.js";import{b as k,c as x}from"./43LI5NKJ.js";import{b}from"./TI727O2H.js";import{a as f}from"./XSD5NL7J.js";import{encodeFunctionData as C,zeroAddress as N}from"viem";function v(t=10){if(!Number.isInteger(t)||t<0||t>50)throw new f("Oak won't accept a cash-out reduction that big. Use a whole number from 0 to 50 bps (0.5%).");return t}async function z(t,e,a,u=10,r){let l=v(u);p(a,!0),m(e.tokensOut.some(n=>T(n,e.inputToken)),"the market input token cannot be redeemed from SY");try{let n=await t.client.getBlock();m(e.expired&&n.timestamp>=BigInt(e.expiry),"this term has not ended; wait for its end date");let h=p((await t.client.simulateContract({address:e.yt,abi:g,functionName:"pyIndexCurrent",blockNumber:n.number})).result,!0);for(let o of[e.syDecimals,e.ptDecimals])m(Number.isInteger(o)&&o>=0&&o<=77,"unreadable token decimals");let d=a*10n**18n*10n**BigInt(e.syDecimals)/(h*10n**BigInt(e.ptDecimals));p(d,!0);let i=p(await t.client.readContract({address:e.sy,abi:g,functionName:"previewRedeem",args:[e.inputToken,d],blockNumber:n.number}),!0),s=I(i,l);if(m(s>0n,"this cash-out amount is too small"),r&&(r.apiAmountOut>i?r.apiAmountOut-i:i-r.apiAmountOut)*10000n>i*50n)try{r.note("Pendle\u2019s API cash-out estimate differs from the chain by over 0.5%. Oak kept the chain estimate.")}catch{}let c={tokenOut:e.inputToken,minTokenOut:s,tokenRedeemSy:e.inputToken,pendleSwap:N,swapData:{swapType:0,extRouter:N,extCalldata:"0x",needScale:!1}},w=k({to:y,data:C({abi:D,functionName:"redeemPyToToken",args:[t.wallet,e.yt,a,c]}),value:"0",chainId:b,description:"Cash out ended Pendle PT to its input token."});return{txs:[x(e.pt,y,a.toString(),b),w],expected:i,minOut:s,summary:"Approve the exact PT amount, then cash out the ended term to its input token."}}catch(n){throw n instanceof f?n:new f("Oak could not read the Pendle cash-out amount from the chain. Try again.")}}async function F(t,e,a,u,r){let l=new AbortController,n;try{let h=new Promise(o=>{n=setTimeout(()=>{l.abort(),o(void 0)},1500)}),d=await Promise.race([R((o,B)=>t.http(o,{...B,signal:l.signal}),{inputToken:e.pt,outputToken:e.inputToken,amount:a,wallet:t.wallet,slippageBps:r}),h]);if(!d)return;let i=P(d.body).outputs;if(i.length!==1)return;let s=O(i[0]);if(!T(s.token,e.inputToken))return;let c=A(s.amount);return(c>u?c-u:u-c)*10000n>u*50n?"Pendle\u2019s API cash-out estimate differs from the chain by over 0.5%. Oak kept the chain estimate.":void 0}catch{return}finally{n!==void 0&&clearTimeout(n)}}export{v as a,z as b,F as c};
1
+ import{a as g,b as p}from"./SEXKWYUM.js";import{a as y,b as D,c as m,d as T,e as I}from"./5BPFF7NX.js";import{c as O,d as A,f as P,g as R}from"./OUROA7XR.js";import{b as k,c as x}from"./43LI5NKJ.js";import{b}from"./EWZFZUVF.js";import{a as f}from"./XSD5NL7J.js";import{encodeFunctionData as C,zeroAddress as N}from"viem";function v(t=10){if(!Number.isInteger(t)||t<0||t>50)throw new f("Oak won't accept a cash-out reduction that big. Use a whole number from 0 to 50 bps (0.5%).");return t}async function z(t,e,a,u=10,r){let l=v(u);p(a,!0),m(e.tokensOut.some(n=>T(n,e.inputToken)),"the market input token cannot be redeemed from SY");try{let n=await t.client.getBlock();m(e.expired&&n.timestamp>=BigInt(e.expiry),"this term has not ended; wait for its end date");let h=p((await t.client.simulateContract({address:e.yt,abi:g,functionName:"pyIndexCurrent",blockNumber:n.number})).result,!0);for(let o of[e.syDecimals,e.ptDecimals])m(Number.isInteger(o)&&o>=0&&o<=77,"unreadable token decimals");let d=a*10n**18n*10n**BigInt(e.syDecimals)/(h*10n**BigInt(e.ptDecimals));p(d,!0);let i=p(await t.client.readContract({address:e.sy,abi:g,functionName:"previewRedeem",args:[e.inputToken,d],blockNumber:n.number}),!0),s=I(i,l);if(m(s>0n,"this cash-out amount is too small"),r&&(r.apiAmountOut>i?r.apiAmountOut-i:i-r.apiAmountOut)*10000n>i*50n)try{r.note("Pendle\u2019s API cash-out estimate differs from the chain by over 0.5%. Oak kept the chain estimate.")}catch{}let c={tokenOut:e.inputToken,minTokenOut:s,tokenRedeemSy:e.inputToken,pendleSwap:N,swapData:{swapType:0,extRouter:N,extCalldata:"0x",needScale:!1}},w=k({to:y,data:C({abi:D,functionName:"redeemPyToToken",args:[t.wallet,e.yt,a,c]}),value:"0",chainId:b,description:"Cash out ended Pendle PT to its input token."});return{txs:[x(e.pt,y,a.toString(),b),w],expected:i,minOut:s,summary:"Approve the exact PT amount, then cash out the ended term to its input token."}}catch(n){throw n instanceof f?n:new f("Oak could not read the Pendle cash-out amount from the chain. Try again.")}}async function F(t,e,a,u,r){let l=new AbortController,n;try{let h=new Promise(o=>{n=setTimeout(()=>{l.abort(),o(void 0)},1500)}),d=await Promise.race([R((o,B)=>t.http(o,{...B,signal:l.signal}),{inputToken:e.pt,outputToken:e.inputToken,amount:a,wallet:t.wallet,slippageBps:r}),h]);if(!d)return;let i=P(d.body).outputs;if(i.length!==1)return;let s=O(i[0]);if(!T(s.token,e.inputToken))return;let c=A(s.amount);return(c>u?c-u:u-c)*10000n>u*50n?"Pendle\u2019s API cash-out estimate differs from the chain by over 0.5%. Oak kept the chain estimate.":void 0}catch{return}finally{n!==void 0&&clearTimeout(n)}}export{v as a,z as b,F as c};
@@ -1 +1 @@
1
- import{o as s}from"./7OOCAZBE.js";import{formatUnits as c}from"viem";function l(e){return`HoodLock creation fee: ${e.eth} ETH (${e.amount} wei; ${e.usd===null?"USD unavailable: no fresh ETH/USD reference":`approximately $${e.usd} USD`}), not refundable after creation. Paid to ${e.contract}; separate from network gas.`}async function p(e,t,d,r){let o=r===0n?"0":null;if(r>0n)try{let a=await s("ETH",{client:e.clientFor(4663),chainId:4663});BigInt(a.usdE18)>0n&&(o=c(r*BigInt(a.usdE18)/10n**18n,18))}catch{}let n={contract:d,amount:r.toString(),eth:c(r,18),usd:o,refundable:!1},i=l(n);return{...t,summary:`${t.summary} ${i}`,preview:{...t.preview,summary:`${t.preview.summary} ${i}`},protocolFee:n}}export{l as a,p as b};
1
+ import{o as s}from"./OUXPOFY2.js";import{formatUnits as c}from"viem";function l(e){return`HoodLock creation fee: ${e.eth} ETH (${e.amount} wei; ${e.usd===null?"USD unavailable: no fresh ETH/USD reference":`approximately $${e.usd} USD`}), not refundable after creation. Paid to ${e.contract}; separate from network gas.`}async function p(e,t,d,r){let o=r===0n?"0":null;if(r>0n)try{let a=await s("ETH",{client:e.clientFor(4663),chainId:4663});BigInt(a.usdE18)>0n&&(o=c(r*BigInt(a.usdE18)/10n**18n,18))}catch{}let n={contract:d,amount:r.toString(),eth:c(r,18),usd:o,refundable:!1},i=l(n);return{...t,summary:`${t.summary} ${i}`,preview:{...t.preview,summary:`${t.preview.summary} ${i}`},protocolFee:n}}export{l as a,p as b};
@@ -1,4 +1,4 @@
1
- import{a as oe}from"./3CCBUYUM.js";import{a as xt,d as It,e as Tt}from"./ZTKT3ZQK.js";import{a as Ge}from"./7MR37STI.js";import{a as Ze,b as Ee,d as At}from"./X24YTJST.js";import{h as Je,i as St}from"./2GXHYI23.js";import{b as kt,c as yt,d as gt}from"./N624NR7Y.js";import{d as wt,e as te}from"./GYPMUYB5.js";import{a as ht}from"./Z7FGEWO2.js";import{b as bt}from"./SPJCSEKP.js";import{a as q}from"./43LI5NKJ.js";import{a as A,d as W}from"./66F5ZH34.js";import{d as Ne,g as R,i as Oe}from"./NWNYJ26T.js";import{b as Le}from"./IX3GZMTM.js";import{o as ft}from"./MQ5F2VOK.js";import{b as f,j as z}from"./TI727O2H.js";import{a as i,e as ie}from"./XSD5NL7J.js";import{a as Ye}from"./JXOEJPJ4.js";import{encodeFunctionData as be,erc20Abi as Xo,getAddress as ao,parseAbi as pt,zeroAddress as Yo}from"viem";import{decodeAbiParameters as mo,encodeFunctionData as po,getAddress as le,parseAbiParameters as fo,zeroAddress as he,zeroHash as Dt}from"viem";import{decodeAbiParameters as no,encodeFunctionData as so,erc20Abi as io,getAddress as Ct,parseAbi as lo,parseAbiParameters as co,zeroHash as Mt}from"viem";var et=Ct("0xCE29862924756584BBD0D75CA1249d22007E2813"),Lt="(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)",uo="(uint256 value,uint256 nonce,uint256 deadline,uint8 v,bytes32 r,bytes32 s)",vt=lo(["function BLUE() view returns (address)",`function vaultExitBundlesV1InKindRedemptionVaultV2(address vault,address adapter,${Lt}[] marketParamsList,uint256 exitAssets,${uo} sharesPermit,uint256 deadline)`]);function O(e,t=!1){if(typeof e!="string"||!/^\d{1,78}$/.test(e)||BigInt(e)>=1n<<256n||!t&&BigInt(e)===0n)throw new i("Provide a positive uint256 decimal base-unit string.");return BigInt(e)}var Pt=(e,t)=>e<t?e:t;async function la(e,t,s,r,n){q(n);let l=O(r.amount),o=O(r.maxShares),a=O(r.maxPenaltyAssets,!0),u=O(r.deadline),c=e.clientFor(f),m=await At(c,t,s),d=(S,N,Ce,ee=[])=>c.readContract({address:S,abi:N,functionName:Ce,args:ee,blockNumber:m.blockNumber}),[p,h,b,w]=await Promise.all([c.getBlock({blockNumber:m.blockNumber}),d(et,vt,"BLUE"),d(t,io,"balanceOf",[n]),d(t,Ze,"previewRedeem",[o])]);if(typeof h!="string"||Ct(h)!==B)throw new i("VaultExitBundlesV1 does not report the pinned Morpho Blue.");if(u<p.timestamp||u>p.timestamp+300n)throw new i("Use an absolute Unix deadline within the next five minutes.");if(o>Ee(b))throw new i("maxShares exceeds the wallet share balance.");let k=Pt(m.idle,l),y=m.markets.filter(S=>S.supplied>0n&&j(S.id)),g=l-k,I=y[0]?.penalty??0n,x=g*10n**18n/(10n**18n+I);if(g>0n&&x===0n)throw new i("The penalty-adjusted in-kind amount rounds to zero.");let T=[];for(let S of y){if(x===0n)break;let N=Pt(S.supplied,x);T.push({marketId:S.id,assets:N,penalty:(N*S.penalty+10n**18n-1n)/10n**18n}),x-=N}if(x>0n)throw new i("The supported adapter positions cannot cover the requested in-kind exit. Reduce the amount; unverified market positions are not transferred.");if(l+BigInt(T.length)>Ee(w))throw new i("maxShares cannot cover the exit and per-market rounding buffer.");if(T.some(S=>S.assets>m.blueCash))throw new i("Morpho Blue cannot fund the largest in-kind callback. Reduce the amount.");let P=T.reduce((S,N)=>S+N.penalty,0n);if(P>a)throw new i("In-kind penalty exceeds maxPenaltyAssets.");let C=[...k?[k]:[],...T.flatMap(S=>[S.assets,S.penalty].filter(N=>N>0n))],v=(await Promise.all(C.map(S=>d(t,Ze,"previewWithdraw",[S])))).reduce((S,N)=>S+Ee(N),0n);if(v===0n||v>o)throw new i("Separately rounded burns exceed maxShares.");let Z=T.map(S=>no(co(Lt),m.markets.find(N=>N.id===S.marketId).data)[0]),H=m.markets[0]?.adapter;if(!H)throw new i("In-kind exit requires a verified market adapter.");let F=`In-kind exit from ${t}: spend at most ${v} share base units; receive ${k} ${s.symbol} base units and Morpho Blue supply positions ${T.map(S=>`${S.marketId}: ${S.assets} ${s.symbol} base units`).join(", ")||"none"}. Penalty ${P} ${s.symbol} base units. Deadline ${u} (Unix seconds). Supply positions remain exposed to borrower default and can only be withdrawn when market liquidity returns. This is not a cash exit. The exact share allowance bounds drift; accrual can require a fresh preview.`,M=so({abi:vt,functionName:"vaultExitBundlesV1InKindRedemptionVaultV2",args:[t,H,Z,l,{value:0n,nonce:0n,deadline:0n,v:0,r:Mt,s:Mt},u]}),$=[e.approval(t,et,v.toString(),f),e.unsignedTx({to:et,data:M,value:"0",chainId:f,description:F})],U=await e.preview($,n),V=-U.changes.filter(S=>S.token.chainId===f&&R(S.token.address,t)).reduce((S,N)=>{if(N.token.decimals!==18||!/^-?\d+$/.test(N.amount))throw new i("Invalid in-kind share preview.");return S+BigInt(N.amount)},0n);if(V<=0n||V>v)throw new i("In-kind preview exceeds the exact share authorization or burns no shares.");return{txs:$,preview:U,summary:F,receipt:{idleAssets:k.toString(),positions:T.map(S=>({marketId:S.marketId,asset:s,assets:S.assets.toString()})),penaltyAssets:P.toString()}}}var we=le("0x53A1eB6589861F686af7c531211E35Aefe30210f"),Ut=["supply","withdraw","supplyCollateralAndBorrow","repayAndWithdrawCollateral","migrateBorrowPosition"],tt={kind:0,data:"0x"},Re={nonce:0n,deadline:0n,signature:{v:0,r:Dt,s:Dt}},bo=fo("(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)"),$t=e=>({tools:[{name:"morpho_bundle",inputSchema:{type:"object",additionalProperties:!1,required:["operation","marketId","deadline"],properties:{operation:{type:"string",enum:Ut,description:"Bundle: supply, withdraw, supplyCollateralAndBorrow, repayAndWithdrawCollateral, or migrateBorrowPosition (move debt to destinationMarketId)."},marketId:{type:"string",description:"Verified Morpho Blue market id (0x + 64 hex digits); the source market for migrateBorrowPosition."},destinationMarketId:{type:"string",description:"Only for migrateBorrowPosition: verified market id (0x + 64 hex) to move the borrow into; must share the same tokens."},assets:A(`Amount of the market's loan token in base units (read its decimals). Example: "1000000" = 1 USDG for a 6-decimal token.`),collateralAssets:A(`Collateral amount in base units of the market's collateral token (read its decimals). Example: "1000000" = 1 USDG for a 6-decimal token.`),shares:A("Market share amount in base units (supply or borrow shares, read the position), instead of assets. Give assets or shares, not both."),maxRepayAssets:A('Most loan token you accept paying to repay, in base units of the loan token (read its decimals). Example: "1000000" = 1 USDG.'),maxLtv:A("Highest loan-to-value allowed after the bundle, as an 18-decimal wad in base units (0.8e18 = 80 percent); cannot exceed the market LLTV."),deadline:A("Absolute Unix seconds deadline, no more than five minutes ahead. Example: 1800000000."),allocations:{type:"array",maxItems:4,description:"Up to four Public Allocator moves that add liquidity to the market before borrowing or withdrawing; one per vault.",items:{type:"object",additionalProperties:!1,required:["vault","assets","maxPenaltyAssets"],properties:{vault:{type:"string",description:"Pinned NetNet or Longbow V2 vault address (0x + 40 hex) to pull liquidity from; one entry per vault."},sourceMarketId:{type:"string",description:"Source market id (0x + 64 hex) to pull from; omit to allocate idle vault assets."},assets:A(`Amount to reallocate, in base units of the vault's asset (USDG 6 decimals, WETH 18). Example: "1000000" = 1 USDG.`),maxPenaltyAssets:A(`Highest allocator penalty you accept, in base units of the vault's asset. Example: "10000" = 0.01 USDG for a 6-decimal asset.`)}}}}},execute:async(t,s)=>{try{q(s);let r=t.operation,n=e.clientFor(f);if(await n.getChainId()!==f||typeof r!="string"||!Ut.includes(r))throw new i("Choose a supported Blue bundle on chain 4663.");let l=["operation","marketId","deadline",...r==="supply"?["assets"]:r==="withdraw"?["assets","shares","allocations"]:r==="supplyCollateralAndBorrow"?["collateralAssets","assets","maxLtv","allocations"]:r==="repayAndWithdrawCollateral"?["assets","shares","maxRepayAssets","collateralAssets","maxLtv"]:["destinationMarketId","maxLtv","allocations"]];if(Object.keys(t).some(M=>!l.includes(M)))throw new i("Unexpected argument for this Blue bundle.");let o=await n.getBlock(),a=O(t.deadline);if(a<o.timestamp||a>o.timestamp+300n)throw new i("Use an absolute Unix deadline within the next five minutes.");let[u,c]=await Promise.all([n.readContract({address:we,abi:Ge,functionName:"BLUE",blockNumber:o.number}),n.readContract({address:we,abi:Ge,functionName:"PUBLIC_ALLOCATOR",blockNumber:o.number})]);if(le(u)!==B||le(c)!==xt)throw new i("BlueBundlesV1 deployment does not match Oak\u2019s pinned Blue and Public Allocator.");let m=async M=>{if(typeof M!="string"||!j(M))throw new i("Choose a verified Morpho market with a supported exit.");let $=await n.readContract({address:B,abi:E,functionName:"idToMarketParams",args:[M],blockNumber:o.number}),U={loanToken:le($[0]),collateralToken:le($[1]),oracle:le($[2]),irm:le($[3]),lltv:$[4]};if(!R(ke({...U,lltv:String(U.lltv)}),M))throw new i("Blue bundle market identity mismatch.");return U},d=await m(t.marketId),p=r==="migrateBorrowPosition"?await m(t.destinationMarketId):d;if(d.loanToken!==p.loanToken||d.collateralToken!==p.collateralToken)throw new i("Migration requires the same loan and collateral tokens.");if(r==="migrateBorrowPosition"&&t.marketId===t.destinationMarketId)throw new i("Choose a different destination market.");if(r!=="supply"&&!await n.readContract({address:B,abi:E,functionName:"isAuthorized",args:[s,we],blockNumber:o.number}))throw new i(`Authorize the pinned Blue bundle explicitly with morpho_manage setAuthorization account ${we}, enabled true, then retry. That authority covers all Blue positions. Revoke it with enabled false after the bundle.`);let h=t.assets===void 0?0n:O(t.assets,!0),b=t.shares===void 0?0n:O(t.shares,!0),w=t.collateralAssets===void 0?0n:O(t.collateralAssets,!0),k=r==="supply"||r==="withdraw"?0n:O(t.maxLtv,!0);if(k>p.lltv)throw new i("maxLtv cannot exceed the verified destination market LLTV.");if(r==="supply"&&h===0n||r==="withdraw"&&h===0n==(b===0n)||r==="supplyCollateralAndBorrow"&&w===0n&&h===0n||r==="repayAndWithdrawCollateral"&&(h>0n&&b>0n||h===0n&&b===0n&&w===0n))throw new i("Choose a nonzero amount; assets and shares are mutually exclusive for repayment/withdrawal.");let y=t.allocations??[];if(!Array.isArray(y)||y.length>4||y.length&&r==="supplyCollateralAndBorrow"&&h===0n)throw new i("Provide at most four explicit allocations, only with a borrow or withdrawal.");let g=new Set,I=[],x=0n;for(let M of y){if(!M||typeof M!="object"||Array.isArray(M)||Object.keys(M).some(Xe=>!["vault","sourceMarketId","assets","maxPenaltyAssets"].includes(Xe)))throw new i("Unsupported bundled allocation input.");let $=M,U=await It(e,{vault:$.vault,marketId:r==="migrateBorrowPosition"?t.destinationMarketId:t.marketId});if(g.has(U.definition.vault.toLowerCase()))throw new i("Use each source vault at most once per bundle.");g.add(U.definition.vault.toLowerCase());let V=O($.assets),S=O($.maxPenaltyAssets,!0);if(!U.permission||V>=1n<<128n||V>U.headroom||U.penalty>10n**18n||U.asset.address!==p.loanToken)throw new i("Bundled allocation is disabled, unqualified or exceeds target capacity.");let N=(V*U.penalty+10n**18n-1n)/10n**18n;if(N>S)throw new i("Bundled allocation exceeds maxPenaltyAssets.");x+=N;let Ce=$.sourceMarketId===void 0,ee=Ce?void 0:U.sources.find(Xe=>R(Xe.id,String($.sourceMarketId)));if(Ce?!U.canIdle||V>U.data.idle:!ee||!ee.canPull||V>ee.capacity||V>U.data.blueCash)throw new i("Bundled allocation source cannot cover the requested amount.");I.push({vault:U.definition.vault,adapter:U.target.adapter,marketParams:U.params,sourceAdapter:ee?.adapter??he,sourceMarketParams:ee?mo(bo,ee.data)[0]:U.params,assets:V,penalty:U.penalty,fromIdle:Ce})}let T,P,C,L=0n;if(r==="supply")T="blueBundlesV1Supply",C=d.loanToken,L=h,P=[d,h,tt,0n,he,a];else if(r==="withdraw")T="blueBundlesV1Withdraw",P=[d,h,b,Re,I,0n,he,a];else if(r==="supplyCollateralAndBorrow"){if(T="blueBundlesV1SupplyCollateralAndBorrow",C=d.collateralToken,L=w,x>=h&&x>0n)throw new i("Allocation penalties would consume the borrow proceeds.");P=[d,w,h,k,tt,Re,I,0n,he,a]}else if(r==="repayAndWithdrawCollateral"){if(T="blueBundlesV1RepayAndWithdrawCollateral",C=d.loanToken,L=O(t.maxRepayAssets,!0),h>L||b>0n&&L===0n)throw new i("Repayment requires a sufficient maxRepayAssets budget.");P=[d,h,b,L,w,k,tt,Re,0n,he,a]}else T="blueBundlesV1MigrateBorrowPosition",P=[d,p,k,Re,I,0n,he,a];let v=`Morpho Blue atomic ${r}: ${JSON.stringify(t)}. Allocation penalties ${x} loan-token base units; zero referral fee. Max LTV ${k}; absolute deadline ${a}. Migration adds allocation penalties to destination debt; borrowing deducts them from proceeds. Exact input approval ${L}. Existing Blue bundle authorization remains until explicitly revoked with morpho_manage. No opaque callback, permit or signature is accepted.`,Z=[...C&&L?[e.approval(C,we,L.toString(),f)]:[],e.unsignedTx({to:we,data:po({abi:Ge,functionName:T,args:P}),value:"0",chainId:f,description:v})],H=await e.preview(Z,s),F=new Map;for(let M of H.changes)if(BigInt(M.amount)<0n){let $=M.token.address.toLowerCase();F.set($,(F.get($)??0n)-BigInt(M.amount))}if([...F].some(([M,$])=>!C||M!==C.toLowerCase()||$>L))throw new i("Bundle preview spends outside the exact input budget.");return{txs:Z,preview:H,summary:v}}catch(r){throw new i(e.plainError(r))}}}]});import{concatHex as Bt,decodeAbiParameters as ho,encodeAbiParameters as Rt,encodeFunctionData as ot,erc20Abi as Nt,getAddress as K,keccak256 as rt,zeroAddress as ye,zeroHash as wo}from"viem";var Y=K("0x6120765Ba5336150BbdDdD0Cd9108B5bFD369632"),ko=["0x90B800999e4ACd1bD20283BD450bBd2e06D91F7C","0x708d6Bf6F847202a0755bb5636bE663B174242ea"].map(e=>K(e)),nt=oe.find(e=>e.name==="take"),Ot=[nt.inputs[0]],yo=[nt.inputs[0].components[0]];function Et(e){let t=rt(Bt(["0x600b380380600b5f395ff3",Rt(yo,[e])]));return rt(Bt(["0xff",e.midnight,wo,t]))}var de=10n**18n,Gt=(e,t)=>(e+(t-1n)/2n)/t;function _t(e){if(e<0n)return 10n**36n/_t(-e);let t=693147180559945309n,s=(e+322611214989459870n)/t,r=e-s*t,n=r*r/(2n*de),l=n*r/(3n*de);return de+r+n+l<<s}function go(e){if(e<0n||e>6744n)throw new i("Midnight tick is outside 0..6744.");return Gt(Gt(10n**36n,de+_t(4987541511039073n*(3372n-e))),10n**11n)*10n**11n}function _e(e,t){if(typeof e!="string"||!/^0x([0-9a-f]{2})*$/i.test(e)||e.length>32770||t!==void 0&&e.length!==2+t*2)throw new i("Provide bounded canonical hex data.");return e}function at(e,t){if(!Array.isArray(e)||e.length!==t)throw new i("Invalid Midnight state tuple.");return e.map(s=>{if(typeof s=="number"&&Number.isSafeInteger(s)&&s>=0)return BigInt(s);if(typeof s=="bigint"&&s>=0n)return s;throw new i("Invalid Midnight integer state.")})}var So=e=>JSON.parse(JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s)),Ht=e=>{async function t(n,l){let o=_e(n,32),a=e.clientFor(f);if(await a.getChainId()!==f)throw new i("Midnight requires chain 4663.");let u=await a.getBlock(),c=(y,g=[])=>a.readContract({address:Y,abi:oe,functionName:y,args:g,blockNumber:u.number}),m=await c("toMarket",[o]);if(m.chainId!==BigInt(f)||K(m.midnight)!==Y||!R(Et(m),o))throw new i("Midnight market identity does not match the pinned chain and contract.");if(![z[f].tokens.USDG.address,z[f].tokens.WETH.address].some(y=>R(y,m.loanToken)))throw new i("This Midnight loan token needs a qualified transfer and exit fixture.");if(!m.collateralParams.length||m.collateralParams.length>128)throw new i("Invalid Midnight collateral inventory.");let[p,h,b,w]=await Promise.all([c("position",[o,l]),c("updatePositionView",[m,o,l]),c("marketState",[o]),c("isHealthy",[m,o,l])]),k=async y=>{let[g,I]=await Promise.all([a.readContract({address:y,abi:Nt,functionName:"decimals",blockNumber:u.number}),a.readContract({address:y,abi:Nt,functionName:"symbol",blockNumber:u.number})]);if(!Number.isInteger(g)||g>36||typeof I!="string")throw new i("Invalid Midnight token metadata.");return{address:K(y),decimals:g,symbol:I.replace(/[^a-zA-Z0-9.$_-]/g,"").slice(0,32),chainId:f}};return{id:o,rpc:a,block:u,market:m,read:c,token:k,loan:await k(m.loanToken),position:at(p,6),updated:at(h,3),state:at(b,13),healthy:w}}let s=(n,l,o,a)=>({name:n,inputSchema:{type:"object",properties:l,required:o,additionalProperties:!1},execute:async(u,c)=>{try{if(q(c),Object.keys(u).some(m=>!Object.hasOwn(l,m)))throw new i("Unsupported Midnight argument.");return await a(u,c)}catch(m){throw new i(e.plainError(m))}}});async function r(n,l,o){return{txs:n,preview:await e.preview(n,l),summary:o}}return{tools:[s("morpho_midnight_status",{marketId:{type:"string",description:"Midnight market id: 0x + 64 hex digits (bytes32)."}},["marketId"],async(n,l)=>{let o=await t(n.marketId,l),a=await Promise.all(o.market.collateralParams.map(async(m,d)=>({token:await o.token(m.token),lltvWad:m.lltv.toString(),oracle:m.oracle,assets:String(await o.read("collateral",[o.id,l,BigInt(d)]))}))),u=["configurator","feeSetter","feeClaimer","tickSpacingSetter"],c=await Promise.all(u.map(m=>o.read(m)));return{protocol:Object.fromEntries(u.map((m,d)=>[m,K(String(c[d]))])),continuousFeePerSecondWad:String(o.state[11]),tickSpacing:String(o.state[12]),settlementFeeCbps:o.state.slice(4,11).map(String),settlementFeeCbpWadScale:"1000000000000",chainId:f,midnight:Y,marketId:o.id,blockNumber:String(o.block.number),market:So(o.market),loanToken:o.loan,collaterals:a,debtUnits:String(o.position[4]),creditUnits:String(o.updated[0]),pendingFeeUnits:String(o.updated[1]),withdrawableUnits:String(o.state[2]),healthy:o.healthy,maturity:String(o.market.maturity),matured:o.block.timestamp>o.market.maturity,warning:"Maturity does not guarantee lender liquidity. Borrowers become liquidatable after maturity even when collateralized. Lender credit may absorb borrower default losses."}}),s("morpho_midnight_take",{offer:{type:"string",description:"ABI-encoded Offer struct, never transaction calldata."},ratifierData:{type:"string",description:"Hex proof data (0x...) that the offer's pinned ratifier uses to confirm the maker approved this offer."},units:A("Fixed debt units to trade, as a decimal string below 2^128. The asset cost or proceeds follow from the offer price; maxAssets and minAssets bound them."),maxAssets:A('Most loan token you will spend when buying credit, in base units of the market loan token (read its decimals). Example: "1000000" = 1 USDG.'),minAssets:A('Least loan token you must receive when selling credit or borrowing, in base units of the market loan token. Example: "1000000" = 1 USDG.')},["offer","ratifierData","units","maxAssets","minAssets"],async(n,l)=>{let o=_e(n.offer),[a]=ho(Ot,o);if(!R(Rt(Ot,[a]),o))throw new i("Offer encoding is not canonical.");let u=await t(Et(a.market),l),c=O(n.units),m=O(n.maxAssets,!0),d=O(n.minAssets,!0),p=_e(n.ratifierData);if(c>=1n<<128n||R(a.maker,l)||a.callback!==ye||a.callbackData!=="0x"||!ko.includes(K(a.ratifier)))throw new i("Use a non-self offer with a pinned ratifier and no maker callbacks. Callback routes need a separate qualified builder.");if(u.block.timestamp<a.start||u.block.timestamp>a.expiry||a.expiry<a.start)throw new i("The Midnight offer is not currently live.");if(a.buy&&a.receiverIfMakerIsSeller!==ye||!a.buy&&a.receiverIfMakerIsSeller===ye)throw new i("Invalid offer seller receiver.");if(a.buy&&u.block.timestamp>u.market.maturity&&c>u.updated[0])throw new i("Post-maturity sales cannot increase this wallet\u2019s debt.");let h=await u.read("settlementFee",[u.id,u.market.maturity>u.block.timestamp?u.market.maturity-u.block.timestamp:0n]),b=go(a.tick);if(h>b&&a.buy)throw new i("Settlement fee exceeds the offer price.");let w=a.buy?b-h:b,k=w+h,y=M=>a.buy?M/de:(M+de-1n)/de,g=y(c*k),I=y(c*w);if(a.buy?I<d||I===0n:g>m||g===0n)throw new i("Midnight proceeds/spend do not fit the requested bounds.");let x=await u.read("consumed",[a.maker,a.group]);if(a.maxAssets===0n==(a.maxUnits===0n)||x+(a.maxAssets?a.buy?g:I:c)>(a.maxAssets||a.maxUnits))throw new i("Midnight offer capacity is exhausted or invalid.");if(u.state[11]>a.continuousFeeCap||a.tick%u.state[12]!==0n)throw new i("Offer fee cap or market tick spacing no longer permits execution.");let T=await u.read("isAuthorized",[a.maker,a.ratifier]),P=[{type:"function",name:"isRatified",stateMutability:"view",inputs:[nt.inputs[0],{type:"bytes"},{type:"address"}],outputs:[{type:"bytes32"}]}],C=await u.rpc.readContract({address:a.ratifier,abi:P,functionName:"isRatified",args:[a,p,l],blockNumber:u.block.number});if(T!==!0||C!==rt(new TextEncoder().encode("morpho.midnight.callbackSuccess")))throw new i("The maker has not authorized and ratified this exact offer.");let L=ot({abi:oe,functionName:"take",args:[a,p,c,l,a.buy?l:ye,ye,"0x"]}),v=`Midnight ${a.buy?"sell credit or borrow":"buy credit or reduce debt"}: ${c} fixed debt units; ${a.buy?`receive ${I}`:`spend ${g}`} ${u.loan.symbol} base units (token ${u.loan.address}, decimals ${u.loan.decimals}). Maturity ${u.market.maturity} Unix seconds; offer expiry ${a.expiry}. A borrower can lose collateral after maturity; lender withdrawal depends on repayments and bears default losses. No lender signature or callback is created. Bounds are rechecked locally; the take calldata fixes the offer and units. Exact buyer approval caps wallet spending.`,Z=[...a.buy?[]:[e.approval(u.loan.address,Y,g.toString(),f)],e.unsignedTx({to:Y,data:L,value:"0",chainId:f,description:v})],H=await r(Z,l,v),F=H.preview.changes.filter(M=>M.token.chainId===f&&R(M.token.address,u.loan.address)).reduce((M,$)=>M+BigInt($.amount),0n);if(a.buy?F<I:F!==-g)throw new i("Midnight preview does not match the exact quoted cash flow.");return H}),s("morpho_midnight_action",{marketId:{type:"string",description:"Midnight market id: 0x + 64 hex digits (bytes32)."},operation:{enum:["supplyCollateral","withdrawCollateral","repay","withdraw","updatePosition","claimContinuousFee"],description:"Action: add or remove collateral, repay debt, withdraw matured credit, refresh the position, or claim continuous fees (fee claimer only)."},amount:A('Amount in base units of the relevant token: the collateral token for collateral operations, else the loan token (read decimals). Example: "1000000" = 1 USDG.'),collateralIndex:{type:"integer",minimum:0,maximum:127,description:"Zero-based position of the collateral in the market collateral list; required for supplyCollateral and withdrawCollateral only."}},["marketId","operation"],async(n,l)=>{let o=await t(n.marketId,l),a=n.operation;if(!["supplyCollateral","withdrawCollateral","repay","withdraw","updatePosition","claimContinuousFee"].includes(String(a)))throw new i("Choose a finite Midnight position operation.");let u,c,m=o.loan,d=0n;if(a==="updatePosition"){if(n.amount!==void 0||n.collateralIndex!==void 0)throw new i("Position update takes no amount or collateral index.");u=[o.market,l]}else if(a==="claimContinuousFee"){if(d=O(n.amount),n.collateralIndex!==void 0||K(String(await o.read("feeClaimer")))!==K(l))throw new i("This wallet lacks the Midnight fee claimer role or supplied an unused collateral index.");u=[o.market,d,l]}else{if(d=O(n.amount),d>=1n<<128n)throw new i("Midnight position amount exceeds uint128.");if(a==="supplyCollateral"||a==="withdrawCollateral"){if(!Number.isInteger(n.collateralIndex)||Number(n.collateralIndex)<0||Number(n.collateralIndex)>=o.market.collateralParams.length)throw new i("Choose a current collateral index.");let b=BigInt(String(n.collateralIndex)),w=await o.token(o.market.collateralParams[Number(b)].token);if(m=w,a==="withdrawCollateral"&&d>await o.read("collateral",[o.id,l,b]))throw new i("Insufficient Midnight collateral.");u=a==="supplyCollateral"?[o.market,b,d,l]:[o.market,b,d,l,l],a==="supplyCollateral"&&(c=w)}else{if(n.collateralIndex!==void 0)throw new i("This operation takes no collateral index.");if(a==="repay"&&d>o.position[4]||a==="withdraw"&&(d>o.updated[0]||d>o.state[2]))throw new i("Amount exceeds current debt, credit or available repayment liquidity.");u=a==="repay"?[o.market,d,l,ye,"0x"]:[o.market,d,l,l],a==="repay"&&(c=o.loan)}}let p=`Midnight ${a}: ${d} ${m.symbol} base units (token ${m.address}, decimals ${m.decimals}) on ${o.id}; beneficiary ${l}; maturity ${o.market.maturity} Unix seconds. No callbacks or delegation. Withdrawal can fail if collateral health or lender liquidity changes.`,h=[...c?[e.approval(c.address,Y,d.toString(),f)]:[],e.unsignedTx({to:Y,data:ot({abi:oe,functionName:String(a),args:u}),value:"0",chainId:f,description:p})];return r(h,l,p)}),s("morpho_midnight_manage",{operation:{type:"string",enum:["setConsumed","setIsAuthorized","setConfigurator","setFeeSetter","setFeeClaimer","setTickSpacingSetter","enableLltv","enableLiquidationCursor","setMarketTickSpacing","setMarketSettlementFee","setMarketContinuousFee","setDefaultSettlementFee","setDefaultContinuousFee","claimSettlementFee"],description:"Midnight management function name; role-gated except setConsumed and setIsAuthorized, which act on this wallet."},values:{type:"array",maxItems:3,description:"Ordered arguments for the chosen operation, as in the Midnight ABI: decimal strings for integers (base units), 0x addresses or bytes32, or booleans.",items:{oneOf:[{type:"string"},{type:"boolean"}]}}},["operation","values"],async(n,l)=>{let o={setConfigurator:"configurator",setFeeSetter:"configurator",setFeeClaimer:"configurator",setTickSpacingSetter:"configurator",enableLltv:"configurator",enableLiquidationCursor:"configurator",setMarketTickSpacing:"tickSpacingSetter",setMarketSettlementFee:"feeSetter",setMarketContinuousFee:"feeSetter",setDefaultSettlementFee:"feeSetter",setDefaultContinuousFee:"feeSetter",claimSettlementFee:"feeClaimer"};if(typeof n.operation!="string"||!["setConsumed","setIsAuthorized",...Object.keys(o)].includes(n.operation)||!Array.isArray(n.values))throw new i("Choose a finite Midnight management operation and ordered values.");let a=n.operation,u=oe.find(p=>p.name===a);if(n.values.length!==u.inputs.length)throw new i("Provide the exact ordered operation values.");let c=e.clientFor(f);if(await c.getChainId()!==f)throw new i("Midnight requires chain 4663.");let m=u.inputs.map((p,h)=>{let b=n.values[h];if(p.type==="bool"){if(typeof b!="boolean")throw new i("Use boolean management values.");return b}if(p.type==="address")return Oe(b,"Use explicit management addresses.",Ne);if(p.type==="bytes32")return _e(b,32);if(/^uint/.test(p.type)){let w=O(b,!0);if(w>=1n<<BigInt(p.type.slice(4)))throw new i("Management integer exceeds its ABI width.");return w}throw new i("Unsupported management argument type.")});if(a==="setConsumed"||a==="setIsAuthorized"){if(!R(String(m[2]),l))throw new i("Midnight management is bound to this wallet.")}else{let p=await c.readContract({address:Y,abi:oe,functionName:o[a]});if(typeof p!="string"||K(p)!==K(l))throw new i("This wallet lacks the Midnight configuration, fee or tick role.")}let d=`Midnight ${a}, ordered values ${JSON.stringify(n.values)}. ${a==="setIsAuthorized"&&m[1]?"This grants authority over all Midnight positions, cancellations and further delegation, without an amount cap. Revoke with false when done.":""}${a==="setConsumed"?"Consumption only increases; setting uint128 maximum permanently cancels this offer group.":""}`;return r([e.unsignedTx({to:Y,data:ot({abi:oe,functionName:a,args:m}),value:"0",chainId:f,description:d})],l,d)})]}};import{decodeAbiParameters as re,encodeAbiParameters as Ao,encodeFunctionData as G,erc20Abi as it,getAddress as D,isAddress as Fe,keccak256 as xo,parseAbi as Ve,parseAbiParameters as J}from"viem";var De="morpho",Io="https://api.morpho.org/graphql",B=D(z[f].morpho.morpho_blue.address),To=D(z[f].morpho.adaptive_curve_irm.address),Mo=D(z[f].morpho.USDG.address),me=D(z[f].morpho.WETH.address),vo=["0x7c820d6a09502d63be80bb8025ec479d29d7c06e70f8df65a92aaeed23a366e2","0x1fa5293f9f60059a7f6a4923022156fcdcc038bd3749be55897000c03afe92d8"],Po={"oak-recorded":"Oak recorded chain observations (block 100362239).","morpho-listed":"Morpho API (POST https://api.morpho.org/graphql, markets where chainId_in [4663]) returned listed: true, fetched 2026-10-31 UTC.",longbow:"Longbow market list: Longbow MCP list_markets/get_market (https://mcp.longbow.credit/mcp, named on https://longbow.cash/mcp) and the live market list on https://longbow.cash/earn, fetched 2026-10-31 UTC; each ID re-read on chain.",netnet:"NetNet Credit: six stock-token market IDs printed at https://docs.netnet.capital/credit, plus the Loopback wsNET/USDG market returned by NetNet's Turbo router marketId() and Credit adapter marketIds(6); fetched 2026-10-31 UTC."},lt=[{marketId:"0x7c820d6a09502d63be80bb8025ec479d29d7c06e70f8df65a92aaeed23a366e2",label:"WETH/USDG 77%",source:"oak-recorded"},{marketId:"0x1fa5293f9f60059a7f6a4923022156fcdcc038bd3749be55897000c03afe92d8",label:"USDG/WETH",source:"oak-recorded"},{marketId:"0x0309c02dabf0be02682af1a2bde9a457f4df0f0b6bc889cde3f948e5315e4114",label:"spUSDG/USDG 91.5%",source:"morpho-listed"},{marketId:"0x10151e2ac82a820153520d9d77d56de1c84775e23b79bdc11e2e34282d9afa10",label:"SPCX/USDG 62.5%",source:"morpho-listed"},{marketId:"0x127353ba63e08f74d8e9ce8a1c2b41b5f89c7167135b1c09fbed34a71b4cb06b",label:"WETH/USDG 86%",source:"morpho-listed"},{marketId:"0x1a31d1c8c05a98b94777663912e4166bf50f3fcdc9c3c3d29deb55634ac58239",label:"PONS/USDG 62.5%",source:"morpho-listed"},{marketId:"0x1efd13a2d1dc66a2466e7c25820537028e604791f00454d9c686fdfbf70f404d",label:"mGLO/USDG 91.5%",source:"morpho-listed"},{marketId:"0x21ea2a012b888120e328775c2a7bf6fb4619cf4c4c631ad1c9b6db51f8882d5a",label:"SPCX/USDG 62.5%",source:"morpho-listed"},{marketId:"0x22e4598e5cc16cff0056e72d61c5f1f2f8bf5bbffc22da5277ab196939c8a59e",label:"TSLA/USDG 62.5%",source:"morpho-listed"},{marketId:"0x66306c087add8907752320b309934abcc354d21626de8115c79df49d9c214edc",label:"NVDA/USDG 62.5%",source:"morpho-listed"},{marketId:"0x69400cfe81f2ae381b9a9f27076a4d637338379d999e9ffdfbde52f0876312ee",label:"META/USDG 62.5%",source:"morpho-listed"},{marketId:"0x7408b08b03e05ffd2d21c797489a0e77a28e4bb36acb4e827c69e805d06272b4",label:"GOOGL/USDG 77%",source:"morpho-listed"},{marketId:"0x7c1e38bf461da47df9805ae9b7e97a12ec023625a1f92d2a403b3b9a92260894",label:"CASHCAT/USDG 62.5%",source:"morpho-listed"},{marketId:"0x919a9b6b94dae7c86620eaf7a08e597aae8a4c3a9e9c7671771fbaf62b6b61c7",label:"syrupUSDG/USDG 91.5%",source:"morpho-listed"},{marketId:"0x93ed7865910b09f5a2e0dbfd4670c2d3bc1da9647f7c68e7975f37f497898cdb",label:"mGLO/USDG 91.5%",source:"morpho-listed"},{marketId:"0x947ae981cc823024ea00b602f6ea72d049cac05d66ef096198ceeb998651c175",label:"AAPL/USDG 62.5%",source:"morpho-listed"},{marketId:"0x95312f02c1dae8407b2c80468a5657a9bd19c45ac277f1a61aa52c11444c5314",label:"NVDA/USDG 62.5%",source:"morpho-listed"},{marketId:"0xba01f6625137b692c5dd86afb8e654b4016d7b64e36dfca4124e84bef98bc4d2",label:"GOOGL/USDG 62.5%",source:"morpho-listed"},{marketId:"0xc845da65a020ddca5f132efa8fea79676d8edfdea504226a4c01e7a9e34cddd6",label:"USDe/USDG 91.5%",source:"morpho-listed"},{marketId:"0xcaa167af7ba0422c76424fae56167b7db25bf19f4f435215e6dd7d06a943bdac",label:"AAPL/USDG 62.5%",source:"morpho-listed"},{marketId:"0xe29c7d3790037800101ecbad9c45de2067698d206cbcab7c25069a9f43c9eb98",label:"TSLA/USDG 62.5%",source:"morpho-listed"},{marketId:"0xe5a6d99c3721ef2ab00fb16f0ad226bc7c87a90394f82e27dc6bbca4b1d95c5d",label:"AI/USDG 62.5%",source:"morpho-listed"},{marketId:"0xeb1739b2a69dd22a4285d366a06698a01018b37c24d2994fefe19cc72f313613",label:"SPY/USDG 77%",source:"morpho-listed"},{marketId:"0xf5ff7d546af5e72f3912d2aa723088fd0bf66fddc158714995637714d9db6e4c",label:"NVDA/USDG 62.5%",source:"morpho-listed"},{marketId:"0xaa586d26a6fe62d9c0f0948fede6e2130500ac7a655587447e2d4a37e6330589",label:"wsNET/USDG 62.5% (NetNet Loopback)",source:"netnet"},{marketId:"0x8b16891f032a93b771347c9cb470a780e6699dd701553d3402aa3cdba6189c3e",label:"NVDA/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0x9b4b47cdf7e295341c6c6cdfd3efb9805c4a5b3d580dba0c0c39d3a4232b297b",label:"SPCX/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0xdeb4782d012d5fd3b24962538c2f6559049d70bda4dabd2e4212dacb96c28d45",label:"AAPL/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0x7fa81b10e5d21b2e4c571f862442bc11aff2ed14f02335868d0ff933fd40d0ba",label:"GOOGL/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0x2e1859aa8f143b7220088f80562c6dfe0bf8e52b87d9cedf8da8805f231994ce",label:"MSFT/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0x3ebd43d91c3960a9fac32bedd5c60428e0e414de5bdd67fda770207afb0eb615",label:"COIN/USDG 38.5% (NetNet Credit)",source:"netnet"},{marketId:"0x26f3bd5919ba0e6ea6f4bca1b8bd95ce29cbe3aad4ef824fb007570eac35103b",label:"cbBTC/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xb095654f06f4d17d4fc010c2d89a107649e3c5b58e53a3812d1736c95e63e3f8",label:"NVDAon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x947c05e7c0fa3ba187d57db710d04ba8be4fef53baba0cfbe71ce61b34a1367d",label:"SPCXon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf8f0b5badf06192908bc47af32b93742d9b4fb6072d388cb183ff7849ee6534c",label:"SPYon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x26c80a00f8facc6b081989965d89cedc274b90b81be660e69245a74e5384f5de",label:"METAon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xeefec6c3e5cb7df1f2366ea7cf96a583081205b9720e807d2868d9866a702229",label:"GOOGLon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf511a080dcb4d0a3b9d6aebb06e24afa011cda87f9f71ada70c60f8220e94f35",label:"AAPLon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xa87da1cc931faa945a41861cc9c90076772ceeae9a663836df6b265c4f30106d",label:"MSTRon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x0279ea145eff84ed2ffd3b1ed1f2aca333060d9cef6fdd48bd21073c13ec86bf",label:"CRCLon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xff2063ef18bc5f71867c56d6d3290b61f3da1d010c8a0552bdb7995cfad8cacc",label:"TSLAon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x83d542605940b5495ef38d4b62a39293766a486a24e5c67930f41acd919cf1d1",label:"QQQon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x9b01d5ad5ce8e477510854132cc47853f6e82a708c9c4723887550412f4ee522",label:"GMEon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x8b2af4d69ad861a4099b995b6279aeaf6a905225a0ee889bce424c7faf19b7d9",label:"AMZN/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x4edbd2f2f3b33bc5f80ab588def67fab8c10945fc99f855d80ff4bef2c4aa1f0",label:"SLV/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x7e6ebfdc58a893a5cddba0fba0483baf4fac2efece627ad50821dbe27d6f9738",label:"GOOGL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x30a2a5f1a098b23ed91eadc4529a8d1c967f2cdc2e40a709f3a5992004b01ac0",label:"AAPL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x14973a168cf6c6b1148309f5d567c255b292863ffe9cca59f4284e1426636f00",label:"RKLB/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf049167e6bf18a1b41b8e2acefcf7bc9b13ea013d8d65c7fbc7cbaeb3fe9b4e2",label:"NBIS/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x8114b65dfc5e64222103e5588de261eca9defd25f47ea4ae2f91d49fe4fa2993",label:"CLSK/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x96d3d5f9bc842e4c8a935c5628abd02fb0e10115560c35a9add768781434f471",label:"CRWV/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x1b3555f7c1273688f01ae82da7dc8e508e6a7841ec0038dbb15767154a277b86",label:"EWY/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x039503b6308d6d818d181e626d3fbc667d6e68393c3d74332a6124cd2dd6e755",label:"CASHCAT_LEGACY/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x597227ca652ea5e8afb6e4801ecd766a4d6eb9b3b9fafa9127ba88a8b1f19629",label:"SPCX/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x50bc39b5722fb5634c436d74c6787f3c125b879e7b73cf9e9ecc01bbb57b8e55",label:"SPY/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x315b99abb698487891243a84afd28a5ff56fe02143f203c03edd3f103936bf60",label:"QQQ/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x4979137c23c8fb519cd507adc290944c3c2120e8a3191547531fced28360e9c2",label:"GME/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x6b8a1f62d88d1cd1e8de609aef07cafc8226172ba703e57c52c3730350e61df1",label:"USO/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xafc86936af4f7edf083eb2550b8c42311b83c685982742b9271b309a58268855",label:"MSFT/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf6f3dbe0a19e948147e79e66502c6b05709d8dfde977fec7db1528fc8f0ebdfa",label:"SGOV/USDG 86% (Longbow)",source:"longbow"},{marketId:"0x2ab6a14c9f68d4216dcb3b4e6ed607cf82f2e6badfa2bd5618d7f69d012d7fab",label:"USAR/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xb41b34c5989420ad080e79363a9cfe3e23bec7459fcd2d88029250da370288df",label:"TSLA/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x4d2075836fd32183b10e5be1b383f6430de859df6d2bd5ec5b859970c4dd14e8",label:"AMD/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x9df4f54a2e46b35bd326cec97dbabc4203fa6c64a8e4182128f277adba8fefaf",label:"MU/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xb5ba72c0d55c353fa37c0bea104eb117afb2f4934473bcb736d2218ae5686746",label:"PLTR/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xda5584635e8b14ea18f674dbe4243365505910fefd8e3aa1ac9bfaac0eba74e8",label:"INTC/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x74fece475178af9e06d31fb64f405046a305f8f0abc588782f596d6f261c1fbb",label:"SNDK/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xee04847a312224d551d2267bb5c2c2695777af5fd1f05347bdcca397e8f54336",label:"ORCL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x508b47fb12dbb8747644d4436aae65489b5f2819936adefc8a591323f64a5b01",label:"COIN/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x243ac165f79a75a0590d2e994ffa9e260b70292fd1ca134ace95f3640895b19f",label:"TSM/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x01baec96478004fc7b74c8dfe38abef8d716fea59ffd481b6ec74db915d3bc80",label:"MSTR/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf0959f62e748938cf260ca6fe7cb21a412e0a6643913460f4a6770c3f4b90af6",label:"CRCL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xbe881499e682850931951c998e76cfbf38c7979b1beeae7cbbb97a39b3336a07",label:"ASML/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xdd578ca54b4ef6a7827c6e9fc06905699a577f6e2f00712853d8aab13383bc38",label:"BABA/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xd8b502d5c43f6e5cfff7f938c7ef18e684f114fb5b362611981144397e5d5aef",label:"DELL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x003390b057d753bd839981a0d45f9a567aa0b0ed6373fd42e951eac8ee86c2ba",label:"RGTI/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xc6e16cff2bcf185639562ab937b7a1c381522768ff16aefc85a25ff6ab1c45ea",label:"AI/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xaba3ac501ce4c6b80c08ed0dba19e1ac0de495f17af3ed692a38e92d176a6c9e",label:"PONS/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x8097c1d1000eb657e75265384137041ac92856c8dc0b72c99569c3681320a430",label:"DELTA/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x6e6762ae397a2b3f2500ea2f48f8adce0eadfbf54cbc37f6108602e907e844ad",label:"INDEX/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x378713071c58206c6a826287d0051bcae113d83d6e3d3b6370b7e73128d06162",label:"STONKBROKER/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x2695be2638c98241c887e4cad4eeba0f01137205f46b9e302edab04b5fee0570",label:"AVGO/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x6c12c02536aa27831f713d658b59f74e149cc62b48528cb74455e79fab32f772",label:"GLD/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x298e8ff9b31f22be90507bc61b55e66ab93e78b55a60593035e309ed93137cb8",label:"RDDT/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xb33399a677e1a21152fa9969f02c57a7a342e692ec45608a3fa0d3d92519c343",label:"COST/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x3be7fe1b6b439cfeb737d9921e9b83c92095a23a4f50aeee0d6d04f44446170f",label:"DJT/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x0066bc47b87597993af0bca6f526175c0abae011b764d4bf12a3def45e1f4e78",label:"NFLX/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x8c170f5c5df593791640ac9fbac297d59d08c2e92e86f38fe52d38e929e60fa3",label:"AMC/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x0f18d4fd8d86bd4d100b867b67e1fd38c80981fcd43e442313c2d5408da9352d",label:"LLY/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x7d4313cf1b0ede39395a2c7495dc1b1b47370caf51f70571d927f22e715e5f58",label:"LULU/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xa85928d77bd25cc348e13ea6587b8b3ca3793f4af5e5db8ca07d0f20fd5cfa99",label:"IBM/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x9d61e320efb766ce5c375032b399f08afe644b095a9cb0b2d6d1f6ab68399a6f",label:"F/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x43c51f6ff44ab406ab9c97cb5512c881f4a7498209f94bbcfd874d8f97fad79d",label:"HIMS/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xe6284cf12d0603aee18ff5ab412e262cf99f120e967579111d7a51f37f276f54",label:"TTWO/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xe8d9b45cdbedc4401a3145be7726c9f72b715e03c5399c961439f11636ee9fb6",label:"MRNA/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x46eea143d473cdb8587505f8886dad452037f285f7729a7763e8c233c63b2e8e",label:"RIVN/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x8338aed363a309039b2f271a83558831e7e445f2d13c6e72c576ec0b8a969415",label:"RBLX/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x4e92b336ecad6c842be20ae2ae27b28b3cf5ced6c5388a808167c03a8d75fdf8",label:"SPY/WETH 38.5% (Longbow)",source:"longbow"},{marketId:"0x141c2b1d2bbecf7f8a76563307d7e5bf586457e873c3d97c4bb1502e57b77952",label:"NVDA/WETH 38.5% (Longbow)",source:"longbow"}],Co=new Map(lt.map(e=>[e.marketId.toLowerCase(),e]));function j(e){return Co.get(e.toLowerCase())}function ct(e){let t=j(e);return t?{actions:"enabled",label:t.label,source:Po[t.source]}:{actions:"read-only",reason:"Not in Oak's verified Morpho market registry; Oak builds no transactions for it."}}var qt=20,qe=120n,ze=1000000n,We=1n,Se=10n**18n,Lo=10n**36n,jt=(1n<<128n)-1n,Do=(1n<<256n)-1n,X=Ve(["function idToMarketParams(bytes32 id) view returns (address loanToken, address collateralToken, address oracle, address irm, uint256 lltv)","function market(bytes32 id) view returns (uint128 totalSupplyAssets, uint128 totalSupplyShares, uint128 totalBorrowAssets, uint128 totalBorrowShares, uint128 lastUpdate, uint128 fee)","function position(bytes32 id, address user) view returns (uint256 supplyShares, uint128 borrowShares, uint128 collateral)","function supplyCollateral((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, bytes data)","function withdrawCollateral((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, address receiver)","function borrow((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, address receiver) returns (uint256 assetsBorrowed, uint256 sharesBorrowed)","function repay((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, bytes data) returns (uint256 assetsRepaid, uint256 sharesRepaid)","function supply((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, bytes data) returns (uint256 assetsSupplied, uint256 sharesSupplied)","function withdraw((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, address receiver) returns (uint256 assetsWithdrawn, uint256 sharesWithdrawn)"]),Uo=Ve(["function price() view returns (uint256)"]),$o=Ve(["function borrowRateView((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, (uint128 totalSupplyAssets, uint128 totalSupplyShares, uint128 totalBorrowAssets, uint128 totalBorrowShares, uint128 lastUpdate, uint128 fee) market) view returns (uint256)"]),Kt=Ve(["function deposit() payable"]);function pe(e){return{loanToken:e.loanToken,collateralToken:e.collateralToken,oracle:e.oracle,irm:e.irm,lltv:e.lltv.toString()}}function Ue(e,t){return e===0n?0n:(e+t-1n)/t}function Bo(e,t,s){return e*(s+ze)/(t+We)}function No(e,t,s){return Ue(e*(s+ze),t+We)}function ut(e,t,s){return e*(t+We)/(s+ze)}function se(e,t,s){return Ue(e*(t+We),s+ze)}function Ae(e,t,s){return e*t/Lo*s/Se}function Oo(e,t,s){return t.startsWith("-")?`-${e.formatAmount(t.slice(1),s)}`:e.formatAmount(t,s)}function xe(e,t){let s=[],r={};for(let n of t.changes){let l=Oo(e,n.amount,n.token.decimals);s.push({token:n.token,amount:n.amount,formattedAmount:l}),r[n.token.address.toLowerCase()]=l}return{formattedChanges:s,formattedNetOutflows:r}}function Qt(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new i("Morpho marketId must be a 32-byte hex string.");return e.toLowerCase()}function je(e){if(!e||typeof e!="object")throw new i("Morpho marketParams must be an object.");for(let o of[e.loanToken,e.collateralToken,e.oracle,e.irm])if(typeof o!="string"||!Fe(o,{strict:!1}))throw new i("Morpho marketParams contains an invalid address.");let t=D(e.loanToken),s=D(e.collateralToken),r=D(e.oracle),n=D(e.irm),l=typeof e.lltv=="bigint"?e.lltv:Le(String(e.lltv));if(t===te||s===te||r===te)throw new i("Morpho marketParams loan, collateral, and oracle addresses must be non-zero.");if(l<=0n||l>=Se)throw new i("Morpho marketParams LLTV must be between 0 and 1e18.");return{loanToken:t,collateralToken:s,oracle:r,irm:n,lltv:l}}function ke(e){let t=je(e),s=Ao(J("address, address, address, address, uint256"),[t.loanToken,t.collateralToken,t.oracle,t.irm,t.lltv]);return xo(s)}function dt(e){let t=e.toLowerCase();return t===ht.toLowerCase()||t===wt.toLowerCase()||t===te.toLowerCase()}function Ie(e,t){let s=t??e.wallet;if(!s)throw new i("Provide a valid wallet address.");return q(s),D(s)}async function ne(e,t,s){if(typeof e.call=="function"){let r=await e.call({to:t,data:s});if(r&&typeof r.data=="string")return r.data}if(typeof e.request=="function"){let r=await e.request({method:"eth_call",params:[{to:t,data:s},"latest"]});if(typeof r=="string")return r}throw new i(`Unable to execute eth_call on contract ${t}.`)}function Xt(e){return typeof e=="string"&&/^[A-Za-z0-9$._+-]{1,32}$/.test(e)?e:"UNKNOWN"}async function Q(e,t,s=f){if(q(t),dt(t))return{...kt,chainId:s};let r=D(t),n=r.toLowerCase();if(s===f){if(n===Mo.toLowerCase())return yt;if(n===me.toLowerCase())return gt}let[l,o]=await Promise.all([ne(e,r,G({abi:it,functionName:"symbol"})),ne(e,r,G({abi:it,functionName:"decimals"}))]),[a]=re(J("string"),l),[u]=re(J("uint8"),o);return{address:r,symbol:Xt(a),decimals:Number(u),chainId:s}}async function Yt(e,t){let s=await ne(e,B,G({abi:X,functionName:"idToMarketParams",args:[t]})),[r,n,l,o,a]=re(J("address, address, address, address, uint256"),s);return{loanToken:D(r),collateralToken:D(n),oracle:D(l),irm:D(o),lltv:a}}async function Jt(e,t){let s=await ne(e,B,G({abi:X,functionName:"market",args:[t]})),[r,n,l,o,a,u]=re(J("uint128, uint128, uint128, uint128, uint128, uint128"),s);return{totalSupplyAssets:r,totalSupplyShares:n,totalBorrowAssets:l,totalBorrowShares:o,lastUpdate:a,fee:u}}async function Te(e,t,s){let r=await ne(e,B,G({abi:X,functionName:"position",args:[t,D(s)]})),[n,l,o]=re(J("uint256, uint128, uint128"),r);return{supplyShares:n,borrowShares:l,collateral:o}}async function Ke(e,t){let s=await ne(e,D(t),G({abi:Uo,functionName:"price"})),[r]=re(J("uint256"),s);return r}async function Eo(e,t,s){if(t.irm===te)return 0n;let r=await ne(e,D(t.irm),G({abi:$o,functionName:"borrowRateView",args:[t,s]})),[n]=re(J("uint256"),r);return n}function Qe(e,t,s){let r=s>e.lastUpdate?s-e.lastUpdate:0n,n=t*r,l=Ue(n*n,2n*Se),o=Ue(l*n,3n*Se);return e.totalBorrowAssets+Ue(e.totalBorrowAssets*(n+l+o),Se)}async function $e(e,t,s,r=0n){let[n,l]=await Promise.all([e.getBlock({blockTag:"latest"}),Eo(e,t,s)]),o=BigInt(Math.ceil(Date.now()/1e3)),a=(n.timestamp>o?n.timestamp:o)+r;return{totalBorrowAssets:Qe(s,l,a),accruedThrough:a,rate:l}}async function Zt(e,t,s){let r=await ne(e,D(t),G({abi:it,functionName:"balanceOf",args:[D(s)]})),[n]=re(J("uint256"),r);return n}async function fe(e,t,s=!1){let r=t.marketId,n=t.marketParams;if(!r&&!n)throw new i("Provide either marketId or marketParams for the Morpho Blue market.");let l=n?je(n):void 0,o=l?ke(l):void 0,a=r!==void 0?Qt(r):void 0;if(a&&o&&a!==o.toLowerCase())throw new i(`MarketParams tuple hash (${o}) does not match marketId (${a}).`);let u=(a??o).toLowerCase();if(s&&!j(u))throw new i(`Morpho actions require a known market from Oak's verified registry, which pins its oracle. Find one with morpho_status {"discover":true}; other markets are read-only.`);let[c,m]=await Promise.all([Yt(e,u),Jt(e,u)]);if(c.loanToken===te||c.collateralToken===te||c.lltv===0n||m.lastUpdate===0n)throw new i(`Morpho market ${u} is not initialized on chain ${f}.`);let d=ke(c);if(d.toLowerCase()!==u.toLowerCase())throw new i(`On-chain idToMarketParams tuple hash (${d}) does not match marketId (${u}).`);if(l&&!(l.loanToken.toLowerCase()===c.loanToken.toLowerCase()&&l.collateralToken.toLowerCase()===c.collateralToken.toLowerCase()&&l.oracle.toLowerCase()===c.oracle.toLowerCase()&&l.irm.toLowerCase()===c.irm.toLowerCase()&&l.lltv===c.lltv))throw new i(`Provided marketParams tuple does not match on-chain idToMarketParams for ${u}.`);return{marketId:u,marketParams:c,marketState:m}}function Me(e){if(e.assets!==void 0&&e.amount!==void 0)throw new i("Specify either assets or amount, not both.");let t=e.assets??e.amount;if(typeof t!="string")throw new i("Provide an amount as a base-unit integer string.");let s=Le(t);if(s<=0n||s>jt)throw new i("Asset amount must be greater than zero and fit in uint128.");return s}function ve(e,t){for(let s of["onBehalf","receiver"])if(e[s]!==void 0&&(typeof e[s]!="string"||e[s].toLowerCase()!==t.toLowerCase()))throw new i(`Morpho ${s} must be the wallet; overrides are not supported.`);if(e.data!==void 0&&e.data!=="0x")throw new i("Morpho callback data must be empty (0x).")}async function Go(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=e.clientFor(f),{marketId:o,marketParams:a}=await fe(l,t,!0),u=await Q(l,a.collateralToken,f),c=a.collateralToken.toLowerCase()===me.toLowerCase(),m=typeof t.collateralToken=="string"?(q(t.collateralToken),D(t.collateralToken)):void 0,d=W("wrapNative",t.wrapNative)===!0||m!==void 0&&dt(m);if(m&&!dt(m)&&m.toLowerCase()!==a.collateralToken.toLowerCase())throw new i(`Collateral token ${m} does not match market collateral ${a.collateralToken}.`);if(d&&!c)throw new i("Native ETH wrapping is only supported when market collateralToken is WETH.");let p=Me(t),h=p.toString(),b=e.formatAmount(h,u.decimals),w=[];d&&w.push(e.unsignedTx({chainId:f,to:me,data:G({abi:Kt,functionName:"deposit"}),value:h,description:`Wrap ${b} ETH into WETH at ${me}.`})),w.push(e.approval(a.collateralToken,B,h,f)),w.push(e.unsignedTx({chainId:f,to:B,data:G({abi:X,functionName:"supplyCollateral",args:[a,p,n,"0x"]}),value:"0",description:`Supply ${b} ${u.symbol} (${h} base units) collateral to Morpho market ${o}.`}));let k=await e.preview(w,r),{formattedChanges:y,formattedNetOutflows:g}=xe(e,k);return{action:"morpho_supply_collateral",chainId:f,marketId:o,marketParams:pe(a),collateralToken:u,assets:h,formattedAssets:b,onBehalf:n,txs:w,summary:`${d?`Send ${b} ETH to wrap into WETH. `:""}Supply ${b} ${u.symbol} collateral to Morpho Blue market ${o}.`,preview:k,formattedChanges:y,formattedNetOutflows:g}}async function Ro(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=r,o=e.clientFor(f),{marketId:a,marketParams:u,marketState:c}=await fe(o,t,!0),[m,d,p,h]=await Promise.all([Q(o,u.loanToken,f),Te(o,a,n),Ke(o,u.oracle),$e(o,u,c,qe)]),b=Me(t),w=b.toString(),k=e.formatAmount(w,m.decimals),y=c.totalSupplyAssets>c.totalBorrowAssets?c.totalSupplyAssets-c.totalBorrowAssets:0n;if(b>y)throw new i(`Insufficient market liquidity: requested ${w} base units, available ${y.toString()} base units.`);let g=Ae(d.collateral,p,u.lltv),I=se(d.borrowShares,h.totalBorrowAssets,c.totalBorrowShares);if(d.collateral===0n||I+b>g)throw new i(`Insufficient collateral or unhealthy borrow: total debt ${(I+b).toString()} exceeds max borrow ${g.toString()} base units.`);let x=No(b,h.totalBorrowAssets,c.totalBorrowShares),P=[e.unsignedTx({chainId:f,to:B,data:G({abi:X,functionName:"borrow",args:[u,b,0n,n,l]}),value:"0",description:`Borrow ${k} ${m.symbol} (${w} base units) from Morpho market ${a}.`})],C=await e.preview(P,r),{formattedChanges:L,formattedNetOutflows:v}=xe(e,C);return{action:"morpho_borrow",chainId:f,marketId:a,marketParams:pe(u),loanToken:m,assets:w,formattedAssets:k,borrowShares:x.toString(),onBehalf:n,receiver:l,txs:P,summary:`Borrow ${k} ${m.symbol} from Morpho Blue market ${a}.`,preview:C,formattedChanges:L,formattedNetOutflows:v}}async function eo(e,t,s,r=qe){let n=Ie(t,s);ve(t,n);let l=n,o=e.clientFor(f);if(t.shares!==void 0){let v=Le(t.shares);if(v<=0n||v===Do||v>jt)throw new i("Morpho Blue core does not accept maxUint256 or out-of-range share sentinels; pass exact position.borrowShares.")}if(W("repayAll",t.repayAll)===!0&&(t.shares!==void 0||t.assets!==void 0||t.amount!==void 0))throw new i("Specify repayAll alone, without shares or assets/amount.");if(t.shares!==void 0&&(t.assets!==void 0||t.amount!==void 0))throw new i("Specify either assets/amount or shares for Morpho repay, not both.");let{marketId:a,marketParams:u,marketState:c}=await fe(o,t,!0),[m,d,p]=await Promise.all([Q(o,u.loanToken,f),Te(o,a,l),Zt(o,u.loanToken,n)]);if(d.borrowShares===0n)throw new i(`Position has no active borrow debt on Morpho market ${a}.`);let h=0n,b=0n;if(W("repayAll",t.repayAll)===!0)b=d.borrowShares;else if(t.shares!==void 0){let v=Le(t.shares);if(v>d.borrowShares)throw new i(`Repay shares (${v.toString()}) exceed current position borrowShares (${d.borrowShares.toString()}).`);b=v}else h=Me(t);let w=b>0n?await $e(o,u,c,r):void 0,k=b>0n?se(b,w.totalBorrowAssets,c.totalBorrowShares):h;if(p<k)throw new i(`Insufficient loan token balance for repayment: wallet holds ${p.toString()} base units, but ${k.toString()} base units are required (including accrued interest).`);let y=k.toString(),g=e.formatAmount(y,m.decimals),I=e.approval(u.loanToken,B,y,f),x=e.unsignedTx({chainId:f,to:B,data:G({abi:X,functionName:"repay",args:[u,h,b,l,"0x"]}),value:"0",description:b>0n?`Repay ${b.toString()} borrow shares (${g} ${m.symbol}) on Morpho market ${a}.`:`Repay ${g} ${m.symbol} (${h.toString()} base units) on Morpho market ${a}.`}),T=[I,x],P=await e.preview(T,n),{formattedChanges:C,formattedNetOutflows:L}=xe(e,P);return{action:"morpho_repay",chainId:f,marketId:a,marketParams:pe(u),loanToken:m,repayAssets:h.toString(),repayShares:b.toString(),requiredAssets:y,...w?{accruedThrough:w.accruedThrough.toString(),borrowRatePerSecond:w.rate.toString(),inclusionSeconds:r.toString()}:{},formattedRequiredAssets:g,onBehalf:l,txs:T,summary:b>0n?`Repay ${b.toString()} borrow shares (approval up to ${g} ${m.symbol}) on Morpho Blue market ${a}. Refresh if signing/inclusion takes more than ${qe} seconds.`:`Repay ${g} ${m.symbol} on Morpho Blue market ${a}.`,preview:P,formattedChanges:C,formattedNetOutflows:L}}function Ka(e,t,s){if(t.repayAll!==!0)throw new i("Reviewed debt reconstruction requires repayAll.");return eo(e,t,s,0n)}async function _o(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=r,o=e.clientFor(f),{marketId:a,marketParams:u,marketState:c}=await fe(o,t,!0),[m,d,p,h]=await Promise.all([Q(o,u.collateralToken,f),Te(o,a,n),Ke(o,u.oracle),$e(o,u,c,qe)]),b=W("withdrawAll",t.withdrawAll)===!0?d.collateral:Me(t);if(b<=0n||b>d.collateral)throw new i(`Insufficient collateral to withdraw: requested ${b.toString()} base units, position holds ${d.collateral.toString()} base units.`);if(d.borrowShares>0n){let P=d.collateral-b,C=Ae(P,p,u.lltv),L=se(d.borrowShares,h.totalBorrowAssets,c.totalBorrowShares);if(L>C)throw new i(`Unhealthy collateral withdrawal: remaining max borrow ${C.toString()} would fall below current debt ${L.toString()} base units.`)}let w=b.toString(),k=e.formatAmount(w,m.decimals),g=[e.unsignedTx({chainId:f,to:B,data:G({abi:X,functionName:"withdrawCollateral",args:[u,b,n,l]}),value:"0",description:`Withdraw ${k} ${m.symbol} (${w} base units) collateral from Morpho market ${a}.`})],I=await e.preview(g,r),{formattedChanges:x,formattedNetOutflows:T}=xe(e,I);return{action:"morpho_withdraw_collateral",chainId:f,marketId:a,marketParams:pe(u),collateralToken:m,assets:w,formattedAssets:k,onBehalf:n,receiver:l,txs:g,summary:`Withdraw ${k} ${m.symbol} collateral from Morpho Blue market ${a}.`,preview:I,formattedChanges:x,formattedNetOutflows:T}}async function Ho(e,t,s){let r=Ie(t,s);ve(t,r);let n=e.clientFor(f),{marketId:l,marketParams:o,marketState:a}=await fe(n,t,!0),u=W("wrapNative",t.wrapNative)===!0;if(u&&o.loanToken.toLowerCase()!==me.toLowerCase())throw new i("Native ETH wrapping is only supported when the market loanToken is WETH.");let c=Me(t),m=c.toString(),[d,p]=await Promise.all([Q(n,o.loanToken,f),u?Promise.resolve(c):Zt(n,o.loanToken,r)]);if(p<c)throw new i(`Insufficient ${d.symbol} balance to lend: wallet holds ${p.toString()} base units, requested ${m}.`);let h=e.formatAmount(m,d.decimals),b=[];u&&b.push(e.unsignedTx({chainId:f,to:me,data:G({abi:Kt,functionName:"deposit"}),value:m,description:`Wrap ${h} ETH into WETH at ${me}.`})),b.push(e.approval(o.loanToken,B,m,f)),b.push(e.unsignedTx({chainId:f,to:B,data:G({abi:X,functionName:"supply",args:[o,c,0n,r,"0x"]}),value:"0",description:`Lend ${h} ${d.symbol} (${m} base units) to Morpho market ${l}.`}));let w=Bo(c,a.totalSupplyAssets,a.totalSupplyShares),k=await e.preview(b,r),{formattedChanges:y,formattedNetOutflows:g}=xe(e,k);return{action:"morpho_supply",chainId:f,marketId:l,marketParams:pe(o),loanToken:d,assets:m,formattedAssets:h,supplySharesEstimated:w.toString(),onBehalf:r,oak:ct(l),txs:b,summary:`${u?`Send ${h} ETH to wrap into WETH. `:""}Lend ${h} ${d.symbol} to Morpho Blue market ${l}. It earns the market supply rate and is exposed to the market's collateral, oracle and liquidity risk.`,preview:k,formattedChanges:y,formattedNetOutflows:g}}async function qo(e,t,s){let r=Ie(t,s);ve(t,r);let n=e.clientFor(f),l=W("withdrawAll",t.withdrawAll)===!0;if(l&&(t.assets!==void 0||t.amount!==void 0))throw new i("Specify withdrawAll alone, without assets/amount.");let{marketId:o,marketParams:a,marketState:u}=await fe(n,t,!0),[c,m]=await Promise.all([Q(n,a.loanToken,f),Te(n,o,r)]);if(m.supplyShares===0n)throw new i(`This wallet has no lent ${c.symbol} on Morpho market ${o}.`);let d=ut(m.supplyShares,u.totalSupplyAssets,u.totalSupplyShares),p=l?0n:Me(t),h=l?m.supplyShares:0n;if(!l&&p>d)throw new i(`Withdrawal exceeds the lent balance: requested ${p.toString()} base units, position holds about ${d.toString()}. Use withdrawAll for a full exit.`);let b=u.totalSupplyAssets>u.totalBorrowAssets?u.totalSupplyAssets-u.totalBorrowAssets:0n,w=l?d:p;if(w>b)throw new i(`Insufficient market liquidity: withdrawing ${w.toString()} base units needs idle assets, but only ${b.toString()} are available until borrowers repay. Withdraw at most that amount, or retry later.`);let k=e.formatAmount(w.toString(),c.decimals),g=[e.unsignedTx({chainId:f,to:B,data:G({abi:X,functionName:"withdraw",args:[a,p,h,r,r]}),value:"0",description:l?`Withdraw all ${m.supplyShares.toString()} supply shares (about ${k} ${c.symbol}) from Morpho market ${o}.`:`Withdraw ${k} ${c.symbol} (${p.toString()} base units) of lent assets from Morpho market ${o}.`})],I=await e.preview(g,r),{formattedChanges:x,formattedNetOutflows:T}=xe(e,I);return{action:"morpho_withdraw",chainId:f,marketId:o,marketParams:pe(a),loanToken:c,withdrawAssets:p.toString(),withdrawShares:h.toString(),estimatedAssets:w.toString(),formattedAssets:k,receiver:r,txs:g,summary:l?`Withdraw all lent ${c.symbol} (about ${k}, including interest) from Morpho Blue market ${o}.`:`Withdraw ${k} lent ${c.symbol} from Morpho Blue market ${o}.`,preview:I,formattedChanges:x,formattedNetOutflows:T}}async function to(e,t,s){let r=await e.http(Io,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({query:t,variables:s})});if(!r.ok)throw new i(`Morpho GraphQL request failed (HTTP ${r.status}).`);let n=await r.json();if(n.errors?.length)throw new i("Morpho GraphQL returned query errors.");return n.data??{}}async function oo(e){let t=`query Markets($chainId: Int!) {
1
+ import{a as xt,d as It,e as Tt}from"./53VBLEYS.js";import{a as Ge}from"./7MR37STI.js";import{a as oe}from"./3CCBUYUM.js";import{a as Ze,b as Ee,d as At}from"./IY7FWTAL.js";import{h as Je,i as St}from"./2GXHYI23.js";import{b as kt,c as yt,d as gt}from"./GV6FZ6UG.js";import{d as wt,e as te}from"./TTBB6EFN.js";import{a as ht}from"./7WXAS54T.js";import{b as bt}from"./SPJCSEKP.js";import{a as q}from"./43LI5NKJ.js";import{a as A,d as W}from"./66F5ZH34.js";import{d as Ne,g as R,i as Oe}from"./NWNYJ26T.js";import{b as Le}from"./IX3GZMTM.js";import{o as ft}from"./EZUQMTLE.js";import{b as f,j as z}from"./EWZFZUVF.js";import{a as i,e as ie}from"./XSD5NL7J.js";import{a as Ye}from"./JXOEJPJ4.js";import{encodeFunctionData as be,erc20Abi as Xo,getAddress as ao,parseAbi as pt,zeroAddress as Yo}from"viem";import{decodeAbiParameters as mo,encodeFunctionData as po,getAddress as le,parseAbiParameters as fo,zeroAddress as he,zeroHash as Dt}from"viem";import{decodeAbiParameters as no,encodeFunctionData as so,erc20Abi as io,getAddress as Ct,parseAbi as lo,parseAbiParameters as co,zeroHash as Mt}from"viem";var et=Ct("0xCE29862924756584BBD0D75CA1249d22007E2813"),Lt="(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)",uo="(uint256 value,uint256 nonce,uint256 deadline,uint8 v,bytes32 r,bytes32 s)",vt=lo(["function BLUE() view returns (address)",`function vaultExitBundlesV1InKindRedemptionVaultV2(address vault,address adapter,${Lt}[] marketParamsList,uint256 exitAssets,${uo} sharesPermit,uint256 deadline)`]);function O(e,t=!1){if(typeof e!="string"||!/^\d{1,78}$/.test(e)||BigInt(e)>=1n<<256n||!t&&BigInt(e)===0n)throw new i("Provide a positive uint256 decimal base-unit string.");return BigInt(e)}var Pt=(e,t)=>e<t?e:t;async function la(e,t,s,r,n){q(n);let l=O(r.amount),o=O(r.maxShares),a=O(r.maxPenaltyAssets,!0),u=O(r.deadline),c=e.clientFor(f),m=await At(c,t,s),d=(S,N,Ce,ee=[])=>c.readContract({address:S,abi:N,functionName:Ce,args:ee,blockNumber:m.blockNumber}),[p,h,b,w]=await Promise.all([c.getBlock({blockNumber:m.blockNumber}),d(et,vt,"BLUE"),d(t,io,"balanceOf",[n]),d(t,Ze,"previewRedeem",[o])]);if(typeof h!="string"||Ct(h)!==B)throw new i("VaultExitBundlesV1 does not report the pinned Morpho Blue.");if(u<p.timestamp||u>p.timestamp+300n)throw new i("Use an absolute Unix deadline within the next five minutes.");if(o>Ee(b))throw new i("maxShares exceeds the wallet share balance.");let k=Pt(m.idle,l),y=m.markets.filter(S=>S.supplied>0n&&j(S.id)),g=l-k,I=y[0]?.penalty??0n,x=g*10n**18n/(10n**18n+I);if(g>0n&&x===0n)throw new i("The penalty-adjusted in-kind amount rounds to zero.");let T=[];for(let S of y){if(x===0n)break;let N=Pt(S.supplied,x);T.push({marketId:S.id,assets:N,penalty:(N*S.penalty+10n**18n-1n)/10n**18n}),x-=N}if(x>0n)throw new i("The supported adapter positions cannot cover the requested in-kind exit. Reduce the amount; unverified market positions are not transferred.");if(l+BigInt(T.length)>Ee(w))throw new i("maxShares cannot cover the exit and per-market rounding buffer.");if(T.some(S=>S.assets>m.blueCash))throw new i("Morpho Blue cannot fund the largest in-kind callback. Reduce the amount.");let P=T.reduce((S,N)=>S+N.penalty,0n);if(P>a)throw new i("In-kind penalty exceeds maxPenaltyAssets.");let C=[...k?[k]:[],...T.flatMap(S=>[S.assets,S.penalty].filter(N=>N>0n))],v=(await Promise.all(C.map(S=>d(t,Ze,"previewWithdraw",[S])))).reduce((S,N)=>S+Ee(N),0n);if(v===0n||v>o)throw new i("Separately rounded burns exceed maxShares.");let Z=T.map(S=>no(co(Lt),m.markets.find(N=>N.id===S.marketId).data)[0]),H=m.markets[0]?.adapter;if(!H)throw new i("In-kind exit requires a verified market adapter.");let F=`In-kind exit from ${t}: spend at most ${v} share base units; receive ${k} ${s.symbol} base units and Morpho Blue supply positions ${T.map(S=>`${S.marketId}: ${S.assets} ${s.symbol} base units`).join(", ")||"none"}. Penalty ${P} ${s.symbol} base units. Deadline ${u} (Unix seconds). Supply positions remain exposed to borrower default and can only be withdrawn when market liquidity returns. This is not a cash exit. The exact share allowance bounds drift; accrual can require a fresh preview.`,M=so({abi:vt,functionName:"vaultExitBundlesV1InKindRedemptionVaultV2",args:[t,H,Z,l,{value:0n,nonce:0n,deadline:0n,v:0,r:Mt,s:Mt},u]}),$=[e.approval(t,et,v.toString(),f),e.unsignedTx({to:et,data:M,value:"0",chainId:f,description:F})],U=await e.preview($,n),V=-U.changes.filter(S=>S.token.chainId===f&&R(S.token.address,t)).reduce((S,N)=>{if(N.token.decimals!==18||!/^-?\d+$/.test(N.amount))throw new i("Invalid in-kind share preview.");return S+BigInt(N.amount)},0n);if(V<=0n||V>v)throw new i("In-kind preview exceeds the exact share authorization or burns no shares.");return{txs:$,preview:U,summary:F,receipt:{idleAssets:k.toString(),positions:T.map(S=>({marketId:S.marketId,asset:s,assets:S.assets.toString()})),penaltyAssets:P.toString()}}}var we=le("0x53A1eB6589861F686af7c531211E35Aefe30210f"),Ut=["supply","withdraw","supplyCollateralAndBorrow","repayAndWithdrawCollateral","migrateBorrowPosition"],tt={kind:0,data:"0x"},Re={nonce:0n,deadline:0n,signature:{v:0,r:Dt,s:Dt}},bo=fo("(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)"),$t=e=>({tools:[{name:"morpho_bundle",inputSchema:{type:"object",additionalProperties:!1,required:["operation","marketId","deadline"],properties:{operation:{type:"string",enum:Ut,description:"Bundle: supply, withdraw, supplyCollateralAndBorrow, repayAndWithdrawCollateral, or migrateBorrowPosition (move debt to destinationMarketId)."},marketId:{type:"string",description:"Verified Morpho Blue market id (0x + 64 hex digits); the source market for migrateBorrowPosition."},destinationMarketId:{type:"string",description:"Only for migrateBorrowPosition: verified market id (0x + 64 hex) to move the borrow into; must share the same tokens."},assets:A(`Amount of the market's loan token in base units (read its decimals). Example: "1000000" = 1 USDG for a 6-decimal token.`),collateralAssets:A(`Collateral amount in base units of the market's collateral token (read its decimals). Example: "1000000" = 1 USDG for a 6-decimal token.`),shares:A("Market share amount in base units (supply or borrow shares, read the position), instead of assets. Give assets or shares, not both."),maxRepayAssets:A('Most loan token you accept paying to repay, in base units of the loan token (read its decimals). Example: "1000000" = 1 USDG.'),maxLtv:A("Highest loan-to-value allowed after the bundle, as an 18-decimal wad in base units (0.8e18 = 80 percent); cannot exceed the market LLTV."),deadline:A("Absolute Unix seconds deadline, no more than five minutes ahead. Example: 1800000000."),allocations:{type:"array",maxItems:4,description:"Up to four Public Allocator moves that add liquidity to the market before borrowing or withdrawing; one per vault.",items:{type:"object",additionalProperties:!1,required:["vault","assets","maxPenaltyAssets"],properties:{vault:{type:"string",description:"Pinned NetNet or Longbow V2 vault address (0x + 40 hex) to pull liquidity from; one entry per vault."},sourceMarketId:{type:"string",description:"Source market id (0x + 64 hex) to pull from; omit to allocate idle vault assets."},assets:A(`Amount to reallocate, in base units of the vault's asset (USDG 6 decimals, WETH 18). Example: "1000000" = 1 USDG.`),maxPenaltyAssets:A(`Highest allocator penalty you accept, in base units of the vault's asset. Example: "10000" = 0.01 USDG for a 6-decimal asset.`)}}}}},execute:async(t,s)=>{try{q(s);let r=t.operation,n=e.clientFor(f);if(await n.getChainId()!==f||typeof r!="string"||!Ut.includes(r))throw new i("Choose a supported Blue bundle on chain 4663.");let l=["operation","marketId","deadline",...r==="supply"?["assets"]:r==="withdraw"?["assets","shares","allocations"]:r==="supplyCollateralAndBorrow"?["collateralAssets","assets","maxLtv","allocations"]:r==="repayAndWithdrawCollateral"?["assets","shares","maxRepayAssets","collateralAssets","maxLtv"]:["destinationMarketId","maxLtv","allocations"]];if(Object.keys(t).some(M=>!l.includes(M)))throw new i("Unexpected argument for this Blue bundle.");let o=await n.getBlock(),a=O(t.deadline);if(a<o.timestamp||a>o.timestamp+300n)throw new i("Use an absolute Unix deadline within the next five minutes.");let[u,c]=await Promise.all([n.readContract({address:we,abi:Ge,functionName:"BLUE",blockNumber:o.number}),n.readContract({address:we,abi:Ge,functionName:"PUBLIC_ALLOCATOR",blockNumber:o.number})]);if(le(u)!==B||le(c)!==xt)throw new i("BlueBundlesV1 deployment does not match Oak\u2019s pinned Blue and Public Allocator.");let m=async M=>{if(typeof M!="string"||!j(M))throw new i("Choose a verified Morpho market with a supported exit.");let $=await n.readContract({address:B,abi:E,functionName:"idToMarketParams",args:[M],blockNumber:o.number}),U={loanToken:le($[0]),collateralToken:le($[1]),oracle:le($[2]),irm:le($[3]),lltv:$[4]};if(!R(ke({...U,lltv:String(U.lltv)}),M))throw new i("Blue bundle market identity mismatch.");return U},d=await m(t.marketId),p=r==="migrateBorrowPosition"?await m(t.destinationMarketId):d;if(d.loanToken!==p.loanToken||d.collateralToken!==p.collateralToken)throw new i("Migration requires the same loan and collateral tokens.");if(r==="migrateBorrowPosition"&&t.marketId===t.destinationMarketId)throw new i("Choose a different destination market.");if(r!=="supply"&&!await n.readContract({address:B,abi:E,functionName:"isAuthorized",args:[s,we],blockNumber:o.number}))throw new i(`Authorize the pinned Blue bundle explicitly with morpho_manage setAuthorization account ${we}, enabled true, then retry. That authority covers all Blue positions. Revoke it with enabled false after the bundle.`);let h=t.assets===void 0?0n:O(t.assets,!0),b=t.shares===void 0?0n:O(t.shares,!0),w=t.collateralAssets===void 0?0n:O(t.collateralAssets,!0),k=r==="supply"||r==="withdraw"?0n:O(t.maxLtv,!0);if(k>p.lltv)throw new i("maxLtv cannot exceed the verified destination market LLTV.");if(r==="supply"&&h===0n||r==="withdraw"&&h===0n==(b===0n)||r==="supplyCollateralAndBorrow"&&w===0n&&h===0n||r==="repayAndWithdrawCollateral"&&(h>0n&&b>0n||h===0n&&b===0n&&w===0n))throw new i("Choose a nonzero amount; assets and shares are mutually exclusive for repayment/withdrawal.");let y=t.allocations??[];if(!Array.isArray(y)||y.length>4||y.length&&r==="supplyCollateralAndBorrow"&&h===0n)throw new i("Provide at most four explicit allocations, only with a borrow or withdrawal.");let g=new Set,I=[],x=0n;for(let M of y){if(!M||typeof M!="object"||Array.isArray(M)||Object.keys(M).some(Xe=>!["vault","sourceMarketId","assets","maxPenaltyAssets"].includes(Xe)))throw new i("Unsupported bundled allocation input.");let $=M,U=await It(e,{vault:$.vault,marketId:r==="migrateBorrowPosition"?t.destinationMarketId:t.marketId});if(g.has(U.definition.vault.toLowerCase()))throw new i("Use each source vault at most once per bundle.");g.add(U.definition.vault.toLowerCase());let V=O($.assets),S=O($.maxPenaltyAssets,!0);if(!U.permission||V>=1n<<128n||V>U.headroom||U.penalty>10n**18n||U.asset.address!==p.loanToken)throw new i("Bundled allocation is disabled, unqualified or exceeds target capacity.");let N=(V*U.penalty+10n**18n-1n)/10n**18n;if(N>S)throw new i("Bundled allocation exceeds maxPenaltyAssets.");x+=N;let Ce=$.sourceMarketId===void 0,ee=Ce?void 0:U.sources.find(Xe=>R(Xe.id,String($.sourceMarketId)));if(Ce?!U.canIdle||V>U.data.idle:!ee||!ee.canPull||V>ee.capacity||V>U.data.blueCash)throw new i("Bundled allocation source cannot cover the requested amount.");I.push({vault:U.definition.vault,adapter:U.target.adapter,marketParams:U.params,sourceAdapter:ee?.adapter??he,sourceMarketParams:ee?mo(bo,ee.data)[0]:U.params,assets:V,penalty:U.penalty,fromIdle:Ce})}let T,P,C,L=0n;if(r==="supply")T="blueBundlesV1Supply",C=d.loanToken,L=h,P=[d,h,tt,0n,he,a];else if(r==="withdraw")T="blueBundlesV1Withdraw",P=[d,h,b,Re,I,0n,he,a];else if(r==="supplyCollateralAndBorrow"){if(T="blueBundlesV1SupplyCollateralAndBorrow",C=d.collateralToken,L=w,x>=h&&x>0n)throw new i("Allocation penalties would consume the borrow proceeds.");P=[d,w,h,k,tt,Re,I,0n,he,a]}else if(r==="repayAndWithdrawCollateral"){if(T="blueBundlesV1RepayAndWithdrawCollateral",C=d.loanToken,L=O(t.maxRepayAssets,!0),h>L||b>0n&&L===0n)throw new i("Repayment requires a sufficient maxRepayAssets budget.");P=[d,h,b,L,w,k,tt,Re,0n,he,a]}else T="blueBundlesV1MigrateBorrowPosition",P=[d,p,k,Re,I,0n,he,a];let v=`Morpho Blue atomic ${r}: ${JSON.stringify(t)}. Allocation penalties ${x} loan-token base units; zero referral fee. Max LTV ${k}; absolute deadline ${a}. Migration adds allocation penalties to destination debt; borrowing deducts them from proceeds. Exact input approval ${L}. Existing Blue bundle authorization remains until explicitly revoked with morpho_manage. No opaque callback, permit or signature is accepted.`,Z=[...C&&L?[e.approval(C,we,L.toString(),f)]:[],e.unsignedTx({to:we,data:po({abi:Ge,functionName:T,args:P}),value:"0",chainId:f,description:v})],H=await e.preview(Z,s),F=new Map;for(let M of H.changes)if(BigInt(M.amount)<0n){let $=M.token.address.toLowerCase();F.set($,(F.get($)??0n)-BigInt(M.amount))}if([...F].some(([M,$])=>!C||M!==C.toLowerCase()||$>L))throw new i("Bundle preview spends outside the exact input budget.");return{txs:Z,preview:H,summary:v}}catch(r){throw new i(e.plainError(r))}}}]});import{concatHex as Bt,decodeAbiParameters as ho,encodeAbiParameters as Rt,encodeFunctionData as ot,erc20Abi as Nt,getAddress as K,keccak256 as rt,zeroAddress as ye,zeroHash as wo}from"viem";var Y=K("0x6120765Ba5336150BbdDdD0Cd9108B5bFD369632"),ko=["0x90B800999e4ACd1bD20283BD450bBd2e06D91F7C","0x708d6Bf6F847202a0755bb5636bE663B174242ea"].map(e=>K(e)),nt=oe.find(e=>e.name==="take"),Ot=[nt.inputs[0]],yo=[nt.inputs[0].components[0]];function Et(e){let t=rt(Bt(["0x600b380380600b5f395ff3",Rt(yo,[e])]));return rt(Bt(["0xff",e.midnight,wo,t]))}var de=10n**18n,Gt=(e,t)=>(e+(t-1n)/2n)/t;function _t(e){if(e<0n)return 10n**36n/_t(-e);let t=693147180559945309n,s=(e+322611214989459870n)/t,r=e-s*t,n=r*r/(2n*de),l=n*r/(3n*de);return de+r+n+l<<s}function go(e){if(e<0n||e>6744n)throw new i("Midnight tick is outside 0..6744.");return Gt(Gt(10n**36n,de+_t(4987541511039073n*(3372n-e))),10n**11n)*10n**11n}function _e(e,t){if(typeof e!="string"||!/^0x([0-9a-f]{2})*$/i.test(e)||e.length>32770||t!==void 0&&e.length!==2+t*2)throw new i("Provide bounded canonical hex data.");return e}function at(e,t){if(!Array.isArray(e)||e.length!==t)throw new i("Invalid Midnight state tuple.");return e.map(s=>{if(typeof s=="number"&&Number.isSafeInteger(s)&&s>=0)return BigInt(s);if(typeof s=="bigint"&&s>=0n)return s;throw new i("Invalid Midnight integer state.")})}var So=e=>JSON.parse(JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s)),Ht=e=>{async function t(n,l){let o=_e(n,32),a=e.clientFor(f);if(await a.getChainId()!==f)throw new i("Midnight requires chain 4663.");let u=await a.getBlock(),c=(y,g=[])=>a.readContract({address:Y,abi:oe,functionName:y,args:g,blockNumber:u.number}),m=await c("toMarket",[o]);if(m.chainId!==BigInt(f)||K(m.midnight)!==Y||!R(Et(m),o))throw new i("Midnight market identity does not match the pinned chain and contract.");if(![z[f].tokens.USDG.address,z[f].tokens.WETH.address].some(y=>R(y,m.loanToken)))throw new i("This Midnight loan token needs a qualified transfer and exit fixture.");if(!m.collateralParams.length||m.collateralParams.length>128)throw new i("Invalid Midnight collateral inventory.");let[p,h,b,w]=await Promise.all([c("position",[o,l]),c("updatePositionView",[m,o,l]),c("marketState",[o]),c("isHealthy",[m,o,l])]),k=async y=>{let[g,I]=await Promise.all([a.readContract({address:y,abi:Nt,functionName:"decimals",blockNumber:u.number}),a.readContract({address:y,abi:Nt,functionName:"symbol",blockNumber:u.number})]);if(!Number.isInteger(g)||g>36||typeof I!="string")throw new i("Invalid Midnight token metadata.");return{address:K(y),decimals:g,symbol:I.replace(/[^a-zA-Z0-9.$_-]/g,"").slice(0,32),chainId:f}};return{id:o,rpc:a,block:u,market:m,read:c,token:k,loan:await k(m.loanToken),position:at(p,6),updated:at(h,3),state:at(b,13),healthy:w}}let s=(n,l,o,a)=>({name:n,inputSchema:{type:"object",properties:l,required:o,additionalProperties:!1},execute:async(u,c)=>{try{if(q(c),Object.keys(u).some(m=>!Object.hasOwn(l,m)))throw new i("Unsupported Midnight argument.");return await a(u,c)}catch(m){throw new i(e.plainError(m))}}});async function r(n,l,o){return{txs:n,preview:await e.preview(n,l),summary:o}}return{tools:[s("morpho_midnight_status",{marketId:{type:"string",description:"Midnight market id: 0x + 64 hex digits (bytes32)."}},["marketId"],async(n,l)=>{let o=await t(n.marketId,l),a=await Promise.all(o.market.collateralParams.map(async(m,d)=>({token:await o.token(m.token),lltvWad:m.lltv.toString(),oracle:m.oracle,assets:String(await o.read("collateral",[o.id,l,BigInt(d)]))}))),u=["configurator","feeSetter","feeClaimer","tickSpacingSetter"],c=await Promise.all(u.map(m=>o.read(m)));return{protocol:Object.fromEntries(u.map((m,d)=>[m,K(String(c[d]))])),continuousFeePerSecondWad:String(o.state[11]),tickSpacing:String(o.state[12]),settlementFeeCbps:o.state.slice(4,11).map(String),settlementFeeCbpWadScale:"1000000000000",chainId:f,midnight:Y,marketId:o.id,blockNumber:String(o.block.number),market:So(o.market),loanToken:o.loan,collaterals:a,debtUnits:String(o.position[4]),creditUnits:String(o.updated[0]),pendingFeeUnits:String(o.updated[1]),withdrawableUnits:String(o.state[2]),healthy:o.healthy,maturity:String(o.market.maturity),matured:o.block.timestamp>o.market.maturity,warning:"Maturity does not guarantee lender liquidity. Borrowers become liquidatable after maturity even when collateralized. Lender credit may absorb borrower default losses."}}),s("morpho_midnight_take",{offer:{type:"string",description:"ABI-encoded Offer struct, never transaction calldata."},ratifierData:{type:"string",description:"Hex proof data (0x...) that the offer's pinned ratifier uses to confirm the maker approved this offer."},units:A("Fixed debt units to trade, as a decimal string below 2^128. The asset cost or proceeds follow from the offer price; maxAssets and minAssets bound them."),maxAssets:A('Most loan token you will spend when buying credit, in base units of the market loan token (read its decimals). Example: "1000000" = 1 USDG.'),minAssets:A('Least loan token you must receive when selling credit or borrowing, in base units of the market loan token. Example: "1000000" = 1 USDG.')},["offer","ratifierData","units","maxAssets","minAssets"],async(n,l)=>{let o=_e(n.offer),[a]=ho(Ot,o);if(!R(Rt(Ot,[a]),o))throw new i("Offer encoding is not canonical.");let u=await t(Et(a.market),l),c=O(n.units),m=O(n.maxAssets,!0),d=O(n.minAssets,!0),p=_e(n.ratifierData);if(c>=1n<<128n||R(a.maker,l)||a.callback!==ye||a.callbackData!=="0x"||!ko.includes(K(a.ratifier)))throw new i("Use a non-self offer with a pinned ratifier and no maker callbacks. Callback routes need a separate qualified builder.");if(u.block.timestamp<a.start||u.block.timestamp>a.expiry||a.expiry<a.start)throw new i("The Midnight offer is not currently live.");if(a.buy&&a.receiverIfMakerIsSeller!==ye||!a.buy&&a.receiverIfMakerIsSeller===ye)throw new i("Invalid offer seller receiver.");if(a.buy&&u.block.timestamp>u.market.maturity&&c>u.updated[0])throw new i("Post-maturity sales cannot increase this wallet\u2019s debt.");let h=await u.read("settlementFee",[u.id,u.market.maturity>u.block.timestamp?u.market.maturity-u.block.timestamp:0n]),b=go(a.tick);if(h>b&&a.buy)throw new i("Settlement fee exceeds the offer price.");let w=a.buy?b-h:b,k=w+h,y=M=>a.buy?M/de:(M+de-1n)/de,g=y(c*k),I=y(c*w);if(a.buy?I<d||I===0n:g>m||g===0n)throw new i("Midnight proceeds/spend do not fit the requested bounds.");let x=await u.read("consumed",[a.maker,a.group]);if(a.maxAssets===0n==(a.maxUnits===0n)||x+(a.maxAssets?a.buy?g:I:c)>(a.maxAssets||a.maxUnits))throw new i("Midnight offer capacity is exhausted or invalid.");if(u.state[11]>a.continuousFeeCap||a.tick%u.state[12]!==0n)throw new i("Offer fee cap or market tick spacing no longer permits execution.");let T=await u.read("isAuthorized",[a.maker,a.ratifier]),P=[{type:"function",name:"isRatified",stateMutability:"view",inputs:[nt.inputs[0],{type:"bytes"},{type:"address"}],outputs:[{type:"bytes32"}]}],C=await u.rpc.readContract({address:a.ratifier,abi:P,functionName:"isRatified",args:[a,p,l],blockNumber:u.block.number});if(T!==!0||C!==rt(new TextEncoder().encode("morpho.midnight.callbackSuccess")))throw new i("The maker has not authorized and ratified this exact offer.");let L=ot({abi:oe,functionName:"take",args:[a,p,c,l,a.buy?l:ye,ye,"0x"]}),v=`Midnight ${a.buy?"sell credit or borrow":"buy credit or reduce debt"}: ${c} fixed debt units; ${a.buy?`receive ${I}`:`spend ${g}`} ${u.loan.symbol} base units (token ${u.loan.address}, decimals ${u.loan.decimals}). Maturity ${u.market.maturity} Unix seconds; offer expiry ${a.expiry}. A borrower can lose collateral after maturity; lender withdrawal depends on repayments and bears default losses. No lender signature or callback is created. Bounds are rechecked locally; the take calldata fixes the offer and units. Exact buyer approval caps wallet spending.`,Z=[...a.buy?[]:[e.approval(u.loan.address,Y,g.toString(),f)],e.unsignedTx({to:Y,data:L,value:"0",chainId:f,description:v})],H=await r(Z,l,v),F=H.preview.changes.filter(M=>M.token.chainId===f&&R(M.token.address,u.loan.address)).reduce((M,$)=>M+BigInt($.amount),0n);if(a.buy?F<I:F!==-g)throw new i("Midnight preview does not match the exact quoted cash flow.");return H}),s("morpho_midnight_action",{marketId:{type:"string",description:"Midnight market id: 0x + 64 hex digits (bytes32)."},operation:{enum:["supplyCollateral","withdrawCollateral","repay","withdraw","updatePosition","claimContinuousFee"],description:"Action: add or remove collateral, repay debt, withdraw matured credit, refresh the position, or claim continuous fees (fee claimer only)."},amount:A('Amount in base units of the relevant token: the collateral token for collateral operations, else the loan token (read decimals). Example: "1000000" = 1 USDG.'),collateralIndex:{type:"integer",minimum:0,maximum:127,description:"Zero-based position of the collateral in the market collateral list; required for supplyCollateral and withdrawCollateral only."}},["marketId","operation"],async(n,l)=>{let o=await t(n.marketId,l),a=n.operation;if(!["supplyCollateral","withdrawCollateral","repay","withdraw","updatePosition","claimContinuousFee"].includes(String(a)))throw new i("Choose a finite Midnight position operation.");let u,c,m=o.loan,d=0n;if(a==="updatePosition"){if(n.amount!==void 0||n.collateralIndex!==void 0)throw new i("Position update takes no amount or collateral index.");u=[o.market,l]}else if(a==="claimContinuousFee"){if(d=O(n.amount),n.collateralIndex!==void 0||K(String(await o.read("feeClaimer")))!==K(l))throw new i("This wallet lacks the Midnight fee claimer role or supplied an unused collateral index.");u=[o.market,d,l]}else{if(d=O(n.amount),d>=1n<<128n)throw new i("Midnight position amount exceeds uint128.");if(a==="supplyCollateral"||a==="withdrawCollateral"){if(!Number.isInteger(n.collateralIndex)||Number(n.collateralIndex)<0||Number(n.collateralIndex)>=o.market.collateralParams.length)throw new i("Choose a current collateral index.");let b=BigInt(String(n.collateralIndex)),w=await o.token(o.market.collateralParams[Number(b)].token);if(m=w,a==="withdrawCollateral"&&d>await o.read("collateral",[o.id,l,b]))throw new i("Insufficient Midnight collateral.");u=a==="supplyCollateral"?[o.market,b,d,l]:[o.market,b,d,l,l],a==="supplyCollateral"&&(c=w)}else{if(n.collateralIndex!==void 0)throw new i("This operation takes no collateral index.");if(a==="repay"&&d>o.position[4]||a==="withdraw"&&(d>o.updated[0]||d>o.state[2]))throw new i("Amount exceeds current debt, credit or available repayment liquidity.");u=a==="repay"?[o.market,d,l,ye,"0x"]:[o.market,d,l,l],a==="repay"&&(c=o.loan)}}let p=`Midnight ${a}: ${d} ${m.symbol} base units (token ${m.address}, decimals ${m.decimals}) on ${o.id}; beneficiary ${l}; maturity ${o.market.maturity} Unix seconds. No callbacks or delegation. Withdrawal can fail if collateral health or lender liquidity changes.`,h=[...c?[e.approval(c.address,Y,d.toString(),f)]:[],e.unsignedTx({to:Y,data:ot({abi:oe,functionName:String(a),args:u}),value:"0",chainId:f,description:p})];return r(h,l,p)}),s("morpho_midnight_manage",{operation:{type:"string",enum:["setConsumed","setIsAuthorized","setConfigurator","setFeeSetter","setFeeClaimer","setTickSpacingSetter","enableLltv","enableLiquidationCursor","setMarketTickSpacing","setMarketSettlementFee","setMarketContinuousFee","setDefaultSettlementFee","setDefaultContinuousFee","claimSettlementFee"],description:"Midnight management function name; role-gated except setConsumed and setIsAuthorized, which act on this wallet."},values:{type:"array",maxItems:3,description:"Ordered arguments for the chosen operation, as in the Midnight ABI: decimal strings for integers (base units), 0x addresses or bytes32, or booleans.",items:{oneOf:[{type:"string"},{type:"boolean"}]}}},["operation","values"],async(n,l)=>{let o={setConfigurator:"configurator",setFeeSetter:"configurator",setFeeClaimer:"configurator",setTickSpacingSetter:"configurator",enableLltv:"configurator",enableLiquidationCursor:"configurator",setMarketTickSpacing:"tickSpacingSetter",setMarketSettlementFee:"feeSetter",setMarketContinuousFee:"feeSetter",setDefaultSettlementFee:"feeSetter",setDefaultContinuousFee:"feeSetter",claimSettlementFee:"feeClaimer"};if(typeof n.operation!="string"||!["setConsumed","setIsAuthorized",...Object.keys(o)].includes(n.operation)||!Array.isArray(n.values))throw new i("Choose a finite Midnight management operation and ordered values.");let a=n.operation,u=oe.find(p=>p.name===a);if(n.values.length!==u.inputs.length)throw new i("Provide the exact ordered operation values.");let c=e.clientFor(f);if(await c.getChainId()!==f)throw new i("Midnight requires chain 4663.");let m=u.inputs.map((p,h)=>{let b=n.values[h];if(p.type==="bool"){if(typeof b!="boolean")throw new i("Use boolean management values.");return b}if(p.type==="address")return Oe(b,"Use explicit management addresses.",Ne);if(p.type==="bytes32")return _e(b,32);if(/^uint/.test(p.type)){let w=O(b,!0);if(w>=1n<<BigInt(p.type.slice(4)))throw new i("Management integer exceeds its ABI width.");return w}throw new i("Unsupported management argument type.")});if(a==="setConsumed"||a==="setIsAuthorized"){if(!R(String(m[2]),l))throw new i("Midnight management is bound to this wallet.")}else{let p=await c.readContract({address:Y,abi:oe,functionName:o[a]});if(typeof p!="string"||K(p)!==K(l))throw new i("This wallet lacks the Midnight configuration, fee or tick role.")}let d=`Midnight ${a}, ordered values ${JSON.stringify(n.values)}. ${a==="setIsAuthorized"&&m[1]?"This grants authority over all Midnight positions, cancellations and further delegation, without an amount cap. Revoke with false when done.":""}${a==="setConsumed"?"Consumption only increases; setting uint128 maximum permanently cancels this offer group.":""}`;return r([e.unsignedTx({to:Y,data:ot({abi:oe,functionName:a,args:m}),value:"0",chainId:f,description:d})],l,d)})]}};import{decodeAbiParameters as re,encodeAbiParameters as Ao,encodeFunctionData as G,erc20Abi as it,getAddress as D,isAddress as Fe,keccak256 as xo,parseAbi as Ve,parseAbiParameters as J}from"viem";var De="morpho",Io="https://api.morpho.org/graphql",B=D(z[f].morpho.morpho_blue.address),To=D(z[f].morpho.adaptive_curve_irm.address),Mo=D(z[f].morpho.USDG.address),me=D(z[f].morpho.WETH.address),vo=["0x7c820d6a09502d63be80bb8025ec479d29d7c06e70f8df65a92aaeed23a366e2","0x1fa5293f9f60059a7f6a4923022156fcdcc038bd3749be55897000c03afe92d8"],Po={"oak-recorded":"Oak recorded chain observations (block 100362239).","morpho-listed":"Morpho API (POST https://api.morpho.org/graphql, markets where chainId_in [4663]) returned listed: true, fetched 2026-10-31 UTC.",longbow:"Longbow market list: Longbow MCP list_markets/get_market (https://mcp.longbow.credit/mcp, named on https://longbow.cash/mcp) and the live market list on https://longbow.cash/earn, fetched 2026-10-31 UTC; each ID re-read on chain.",netnet:"NetNet Credit: six stock-token market IDs printed at https://docs.netnet.capital/credit, plus the Loopback wsNET/USDG market returned by NetNet's Turbo router marketId() and Credit adapter marketIds(6); fetched 2026-10-31 UTC."},lt=[{marketId:"0x7c820d6a09502d63be80bb8025ec479d29d7c06e70f8df65a92aaeed23a366e2",label:"WETH/USDG 77%",source:"oak-recorded"},{marketId:"0x1fa5293f9f60059a7f6a4923022156fcdcc038bd3749be55897000c03afe92d8",label:"USDG/WETH",source:"oak-recorded"},{marketId:"0x0309c02dabf0be02682af1a2bde9a457f4df0f0b6bc889cde3f948e5315e4114",label:"spUSDG/USDG 91.5%",source:"morpho-listed"},{marketId:"0x10151e2ac82a820153520d9d77d56de1c84775e23b79bdc11e2e34282d9afa10",label:"SPCX/USDG 62.5%",source:"morpho-listed"},{marketId:"0x127353ba63e08f74d8e9ce8a1c2b41b5f89c7167135b1c09fbed34a71b4cb06b",label:"WETH/USDG 86%",source:"morpho-listed"},{marketId:"0x1a31d1c8c05a98b94777663912e4166bf50f3fcdc9c3c3d29deb55634ac58239",label:"PONS/USDG 62.5%",source:"morpho-listed"},{marketId:"0x1efd13a2d1dc66a2466e7c25820537028e604791f00454d9c686fdfbf70f404d",label:"mGLO/USDG 91.5%",source:"morpho-listed"},{marketId:"0x21ea2a012b888120e328775c2a7bf6fb4619cf4c4c631ad1c9b6db51f8882d5a",label:"SPCX/USDG 62.5%",source:"morpho-listed"},{marketId:"0x22e4598e5cc16cff0056e72d61c5f1f2f8bf5bbffc22da5277ab196939c8a59e",label:"TSLA/USDG 62.5%",source:"morpho-listed"},{marketId:"0x66306c087add8907752320b309934abcc354d21626de8115c79df49d9c214edc",label:"NVDA/USDG 62.5%",source:"morpho-listed"},{marketId:"0x69400cfe81f2ae381b9a9f27076a4d637338379d999e9ffdfbde52f0876312ee",label:"META/USDG 62.5%",source:"morpho-listed"},{marketId:"0x7408b08b03e05ffd2d21c797489a0e77a28e4bb36acb4e827c69e805d06272b4",label:"GOOGL/USDG 77%",source:"morpho-listed"},{marketId:"0x7c1e38bf461da47df9805ae9b7e97a12ec023625a1f92d2a403b3b9a92260894",label:"CASHCAT/USDG 62.5%",source:"morpho-listed"},{marketId:"0x919a9b6b94dae7c86620eaf7a08e597aae8a4c3a9e9c7671771fbaf62b6b61c7",label:"syrupUSDG/USDG 91.5%",source:"morpho-listed"},{marketId:"0x93ed7865910b09f5a2e0dbfd4670c2d3bc1da9647f7c68e7975f37f497898cdb",label:"mGLO/USDG 91.5%",source:"morpho-listed"},{marketId:"0x947ae981cc823024ea00b602f6ea72d049cac05d66ef096198ceeb998651c175",label:"AAPL/USDG 62.5%",source:"morpho-listed"},{marketId:"0x95312f02c1dae8407b2c80468a5657a9bd19c45ac277f1a61aa52c11444c5314",label:"NVDA/USDG 62.5%",source:"morpho-listed"},{marketId:"0xba01f6625137b692c5dd86afb8e654b4016d7b64e36dfca4124e84bef98bc4d2",label:"GOOGL/USDG 62.5%",source:"morpho-listed"},{marketId:"0xc845da65a020ddca5f132efa8fea79676d8edfdea504226a4c01e7a9e34cddd6",label:"USDe/USDG 91.5%",source:"morpho-listed"},{marketId:"0xcaa167af7ba0422c76424fae56167b7db25bf19f4f435215e6dd7d06a943bdac",label:"AAPL/USDG 62.5%",source:"morpho-listed"},{marketId:"0xe29c7d3790037800101ecbad9c45de2067698d206cbcab7c25069a9f43c9eb98",label:"TSLA/USDG 62.5%",source:"morpho-listed"},{marketId:"0xe5a6d99c3721ef2ab00fb16f0ad226bc7c87a90394f82e27dc6bbca4b1d95c5d",label:"AI/USDG 62.5%",source:"morpho-listed"},{marketId:"0xeb1739b2a69dd22a4285d366a06698a01018b37c24d2994fefe19cc72f313613",label:"SPY/USDG 77%",source:"morpho-listed"},{marketId:"0xf5ff7d546af5e72f3912d2aa723088fd0bf66fddc158714995637714d9db6e4c",label:"NVDA/USDG 62.5%",source:"morpho-listed"},{marketId:"0xaa586d26a6fe62d9c0f0948fede6e2130500ac7a655587447e2d4a37e6330589",label:"wsNET/USDG 62.5% (NetNet Loopback)",source:"netnet"},{marketId:"0x8b16891f032a93b771347c9cb470a780e6699dd701553d3402aa3cdba6189c3e",label:"NVDA/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0x9b4b47cdf7e295341c6c6cdfd3efb9805c4a5b3d580dba0c0c39d3a4232b297b",label:"SPCX/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0xdeb4782d012d5fd3b24962538c2f6559049d70bda4dabd2e4212dacb96c28d45",label:"AAPL/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0x7fa81b10e5d21b2e4c571f862442bc11aff2ed14f02335868d0ff933fd40d0ba",label:"GOOGL/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0x2e1859aa8f143b7220088f80562c6dfe0bf8e52b87d9cedf8da8805f231994ce",label:"MSFT/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0x3ebd43d91c3960a9fac32bedd5c60428e0e414de5bdd67fda770207afb0eb615",label:"COIN/USDG 38.5% (NetNet Credit)",source:"netnet"},{marketId:"0x26f3bd5919ba0e6ea6f4bca1b8bd95ce29cbe3aad4ef824fb007570eac35103b",label:"cbBTC/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xb095654f06f4d17d4fc010c2d89a107649e3c5b58e53a3812d1736c95e63e3f8",label:"NVDAon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x947c05e7c0fa3ba187d57db710d04ba8be4fef53baba0cfbe71ce61b34a1367d",label:"SPCXon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf8f0b5badf06192908bc47af32b93742d9b4fb6072d388cb183ff7849ee6534c",label:"SPYon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x26c80a00f8facc6b081989965d89cedc274b90b81be660e69245a74e5384f5de",label:"METAon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xeefec6c3e5cb7df1f2366ea7cf96a583081205b9720e807d2868d9866a702229",label:"GOOGLon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf511a080dcb4d0a3b9d6aebb06e24afa011cda87f9f71ada70c60f8220e94f35",label:"AAPLon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xa87da1cc931faa945a41861cc9c90076772ceeae9a663836df6b265c4f30106d",label:"MSTRon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x0279ea145eff84ed2ffd3b1ed1f2aca333060d9cef6fdd48bd21073c13ec86bf",label:"CRCLon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xff2063ef18bc5f71867c56d6d3290b61f3da1d010c8a0552bdb7995cfad8cacc",label:"TSLAon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x83d542605940b5495ef38d4b62a39293766a486a24e5c67930f41acd919cf1d1",label:"QQQon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x9b01d5ad5ce8e477510854132cc47853f6e82a708c9c4723887550412f4ee522",label:"GMEon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x8b2af4d69ad861a4099b995b6279aeaf6a905225a0ee889bce424c7faf19b7d9",label:"AMZN/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x4edbd2f2f3b33bc5f80ab588def67fab8c10945fc99f855d80ff4bef2c4aa1f0",label:"SLV/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x7e6ebfdc58a893a5cddba0fba0483baf4fac2efece627ad50821dbe27d6f9738",label:"GOOGL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x30a2a5f1a098b23ed91eadc4529a8d1c967f2cdc2e40a709f3a5992004b01ac0",label:"AAPL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x14973a168cf6c6b1148309f5d567c255b292863ffe9cca59f4284e1426636f00",label:"RKLB/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf049167e6bf18a1b41b8e2acefcf7bc9b13ea013d8d65c7fbc7cbaeb3fe9b4e2",label:"NBIS/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x8114b65dfc5e64222103e5588de261eca9defd25f47ea4ae2f91d49fe4fa2993",label:"CLSK/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x96d3d5f9bc842e4c8a935c5628abd02fb0e10115560c35a9add768781434f471",label:"CRWV/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x1b3555f7c1273688f01ae82da7dc8e508e6a7841ec0038dbb15767154a277b86",label:"EWY/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x039503b6308d6d818d181e626d3fbc667d6e68393c3d74332a6124cd2dd6e755",label:"CASHCAT_LEGACY/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x597227ca652ea5e8afb6e4801ecd766a4d6eb9b3b9fafa9127ba88a8b1f19629",label:"SPCX/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x50bc39b5722fb5634c436d74c6787f3c125b879e7b73cf9e9ecc01bbb57b8e55",label:"SPY/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x315b99abb698487891243a84afd28a5ff56fe02143f203c03edd3f103936bf60",label:"QQQ/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x4979137c23c8fb519cd507adc290944c3c2120e8a3191547531fced28360e9c2",label:"GME/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x6b8a1f62d88d1cd1e8de609aef07cafc8226172ba703e57c52c3730350e61df1",label:"USO/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xafc86936af4f7edf083eb2550b8c42311b83c685982742b9271b309a58268855",label:"MSFT/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf6f3dbe0a19e948147e79e66502c6b05709d8dfde977fec7db1528fc8f0ebdfa",label:"SGOV/USDG 86% (Longbow)",source:"longbow"},{marketId:"0x2ab6a14c9f68d4216dcb3b4e6ed607cf82f2e6badfa2bd5618d7f69d012d7fab",label:"USAR/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xb41b34c5989420ad080e79363a9cfe3e23bec7459fcd2d88029250da370288df",label:"TSLA/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x4d2075836fd32183b10e5be1b383f6430de859df6d2bd5ec5b859970c4dd14e8",label:"AMD/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x9df4f54a2e46b35bd326cec97dbabc4203fa6c64a8e4182128f277adba8fefaf",label:"MU/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xb5ba72c0d55c353fa37c0bea104eb117afb2f4934473bcb736d2218ae5686746",label:"PLTR/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xda5584635e8b14ea18f674dbe4243365505910fefd8e3aa1ac9bfaac0eba74e8",label:"INTC/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x74fece475178af9e06d31fb64f405046a305f8f0abc588782f596d6f261c1fbb",label:"SNDK/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xee04847a312224d551d2267bb5c2c2695777af5fd1f05347bdcca397e8f54336",label:"ORCL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x508b47fb12dbb8747644d4436aae65489b5f2819936adefc8a591323f64a5b01",label:"COIN/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x243ac165f79a75a0590d2e994ffa9e260b70292fd1ca134ace95f3640895b19f",label:"TSM/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x01baec96478004fc7b74c8dfe38abef8d716fea59ffd481b6ec74db915d3bc80",label:"MSTR/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf0959f62e748938cf260ca6fe7cb21a412e0a6643913460f4a6770c3f4b90af6",label:"CRCL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xbe881499e682850931951c998e76cfbf38c7979b1beeae7cbbb97a39b3336a07",label:"ASML/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xdd578ca54b4ef6a7827c6e9fc06905699a577f6e2f00712853d8aab13383bc38",label:"BABA/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xd8b502d5c43f6e5cfff7f938c7ef18e684f114fb5b362611981144397e5d5aef",label:"DELL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x003390b057d753bd839981a0d45f9a567aa0b0ed6373fd42e951eac8ee86c2ba",label:"RGTI/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xc6e16cff2bcf185639562ab937b7a1c381522768ff16aefc85a25ff6ab1c45ea",label:"AI/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xaba3ac501ce4c6b80c08ed0dba19e1ac0de495f17af3ed692a38e92d176a6c9e",label:"PONS/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x8097c1d1000eb657e75265384137041ac92856c8dc0b72c99569c3681320a430",label:"DELTA/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x6e6762ae397a2b3f2500ea2f48f8adce0eadfbf54cbc37f6108602e907e844ad",label:"INDEX/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x378713071c58206c6a826287d0051bcae113d83d6e3d3b6370b7e73128d06162",label:"STONKBROKER/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x2695be2638c98241c887e4cad4eeba0f01137205f46b9e302edab04b5fee0570",label:"AVGO/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x6c12c02536aa27831f713d658b59f74e149cc62b48528cb74455e79fab32f772",label:"GLD/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x298e8ff9b31f22be90507bc61b55e66ab93e78b55a60593035e309ed93137cb8",label:"RDDT/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xb33399a677e1a21152fa9969f02c57a7a342e692ec45608a3fa0d3d92519c343",label:"COST/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x3be7fe1b6b439cfeb737d9921e9b83c92095a23a4f50aeee0d6d04f44446170f",label:"DJT/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x0066bc47b87597993af0bca6f526175c0abae011b764d4bf12a3def45e1f4e78",label:"NFLX/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x8c170f5c5df593791640ac9fbac297d59d08c2e92e86f38fe52d38e929e60fa3",label:"AMC/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x0f18d4fd8d86bd4d100b867b67e1fd38c80981fcd43e442313c2d5408da9352d",label:"LLY/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x7d4313cf1b0ede39395a2c7495dc1b1b47370caf51f70571d927f22e715e5f58",label:"LULU/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xa85928d77bd25cc348e13ea6587b8b3ca3793f4af5e5db8ca07d0f20fd5cfa99",label:"IBM/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x9d61e320efb766ce5c375032b399f08afe644b095a9cb0b2d6d1f6ab68399a6f",label:"F/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x43c51f6ff44ab406ab9c97cb5512c881f4a7498209f94bbcfd874d8f97fad79d",label:"HIMS/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xe6284cf12d0603aee18ff5ab412e262cf99f120e967579111d7a51f37f276f54",label:"TTWO/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xe8d9b45cdbedc4401a3145be7726c9f72b715e03c5399c961439f11636ee9fb6",label:"MRNA/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x46eea143d473cdb8587505f8886dad452037f285f7729a7763e8c233c63b2e8e",label:"RIVN/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x8338aed363a309039b2f271a83558831e7e445f2d13c6e72c576ec0b8a969415",label:"RBLX/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x4e92b336ecad6c842be20ae2ae27b28b3cf5ced6c5388a808167c03a8d75fdf8",label:"SPY/WETH 38.5% (Longbow)",source:"longbow"},{marketId:"0x141c2b1d2bbecf7f8a76563307d7e5bf586457e873c3d97c4bb1502e57b77952",label:"NVDA/WETH 38.5% (Longbow)",source:"longbow"}],Co=new Map(lt.map(e=>[e.marketId.toLowerCase(),e]));function j(e){return Co.get(e.toLowerCase())}function ct(e){let t=j(e);return t?{actions:"enabled",label:t.label,source:Po[t.source]}:{actions:"read-only",reason:"Not in Oak's verified Morpho market registry; Oak builds no transactions for it."}}var qt=20,qe=120n,ze=1000000n,We=1n,Se=10n**18n,Lo=10n**36n,jt=(1n<<128n)-1n,Do=(1n<<256n)-1n,X=Ve(["function idToMarketParams(bytes32 id) view returns (address loanToken, address collateralToken, address oracle, address irm, uint256 lltv)","function market(bytes32 id) view returns (uint128 totalSupplyAssets, uint128 totalSupplyShares, uint128 totalBorrowAssets, uint128 totalBorrowShares, uint128 lastUpdate, uint128 fee)","function position(bytes32 id, address user) view returns (uint256 supplyShares, uint128 borrowShares, uint128 collateral)","function supplyCollateral((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, bytes data)","function withdrawCollateral((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, address receiver)","function borrow((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, address receiver) returns (uint256 assetsBorrowed, uint256 sharesBorrowed)","function repay((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, bytes data) returns (uint256 assetsRepaid, uint256 sharesRepaid)","function supply((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, bytes data) returns (uint256 assetsSupplied, uint256 sharesSupplied)","function withdraw((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, address receiver) returns (uint256 assetsWithdrawn, uint256 sharesWithdrawn)"]),Uo=Ve(["function price() view returns (uint256)"]),$o=Ve(["function borrowRateView((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, (uint128 totalSupplyAssets, uint128 totalSupplyShares, uint128 totalBorrowAssets, uint128 totalBorrowShares, uint128 lastUpdate, uint128 fee) market) view returns (uint256)"]),Kt=Ve(["function deposit() payable"]);function pe(e){return{loanToken:e.loanToken,collateralToken:e.collateralToken,oracle:e.oracle,irm:e.irm,lltv:e.lltv.toString()}}function Ue(e,t){return e===0n?0n:(e+t-1n)/t}function Bo(e,t,s){return e*(s+ze)/(t+We)}function No(e,t,s){return Ue(e*(s+ze),t+We)}function ut(e,t,s){return e*(t+We)/(s+ze)}function se(e,t,s){return Ue(e*(t+We),s+ze)}function Ae(e,t,s){return e*t/Lo*s/Se}function Oo(e,t,s){return t.startsWith("-")?`-${e.formatAmount(t.slice(1),s)}`:e.formatAmount(t,s)}function xe(e,t){let s=[],r={};for(let n of t.changes){let l=Oo(e,n.amount,n.token.decimals);s.push({token:n.token,amount:n.amount,formattedAmount:l}),r[n.token.address.toLowerCase()]=l}return{formattedChanges:s,formattedNetOutflows:r}}function Qt(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new i("Morpho marketId must be a 32-byte hex string.");return e.toLowerCase()}function je(e){if(!e||typeof e!="object")throw new i("Morpho marketParams must be an object.");for(let o of[e.loanToken,e.collateralToken,e.oracle,e.irm])if(typeof o!="string"||!Fe(o,{strict:!1}))throw new i("Morpho marketParams contains an invalid address.");let t=D(e.loanToken),s=D(e.collateralToken),r=D(e.oracle),n=D(e.irm),l=typeof e.lltv=="bigint"?e.lltv:Le(String(e.lltv));if(t===te||s===te||r===te)throw new i("Morpho marketParams loan, collateral, and oracle addresses must be non-zero.");if(l<=0n||l>=Se)throw new i("Morpho marketParams LLTV must be between 0 and 1e18.");return{loanToken:t,collateralToken:s,oracle:r,irm:n,lltv:l}}function ke(e){let t=je(e),s=Ao(J("address, address, address, address, uint256"),[t.loanToken,t.collateralToken,t.oracle,t.irm,t.lltv]);return xo(s)}function dt(e){let t=e.toLowerCase();return t===ht.toLowerCase()||t===wt.toLowerCase()||t===te.toLowerCase()}function Ie(e,t){let s=t??e.wallet;if(!s)throw new i("Provide a valid wallet address.");return q(s),D(s)}async function ne(e,t,s){if(typeof e.call=="function"){let r=await e.call({to:t,data:s});if(r&&typeof r.data=="string")return r.data}if(typeof e.request=="function"){let r=await e.request({method:"eth_call",params:[{to:t,data:s},"latest"]});if(typeof r=="string")return r}throw new i(`Unable to execute eth_call on contract ${t}.`)}function Xt(e){return typeof e=="string"&&/^[A-Za-z0-9$._+-]{1,32}$/.test(e)?e:"UNKNOWN"}async function Q(e,t,s=f){if(q(t),dt(t))return{...kt,chainId:s};let r=D(t),n=r.toLowerCase();if(s===f){if(n===Mo.toLowerCase())return yt;if(n===me.toLowerCase())return gt}let[l,o]=await Promise.all([ne(e,r,G({abi:it,functionName:"symbol"})),ne(e,r,G({abi:it,functionName:"decimals"}))]),[a]=re(J("string"),l),[u]=re(J("uint8"),o);return{address:r,symbol:Xt(a),decimals:Number(u),chainId:s}}async function Yt(e,t){let s=await ne(e,B,G({abi:X,functionName:"idToMarketParams",args:[t]})),[r,n,l,o,a]=re(J("address, address, address, address, uint256"),s);return{loanToken:D(r),collateralToken:D(n),oracle:D(l),irm:D(o),lltv:a}}async function Jt(e,t){let s=await ne(e,B,G({abi:X,functionName:"market",args:[t]})),[r,n,l,o,a,u]=re(J("uint128, uint128, uint128, uint128, uint128, uint128"),s);return{totalSupplyAssets:r,totalSupplyShares:n,totalBorrowAssets:l,totalBorrowShares:o,lastUpdate:a,fee:u}}async function Te(e,t,s){let r=await ne(e,B,G({abi:X,functionName:"position",args:[t,D(s)]})),[n,l,o]=re(J("uint256, uint128, uint128"),r);return{supplyShares:n,borrowShares:l,collateral:o}}async function Ke(e,t){let s=await ne(e,D(t),G({abi:Uo,functionName:"price"})),[r]=re(J("uint256"),s);return r}async function Eo(e,t,s){if(t.irm===te)return 0n;let r=await ne(e,D(t.irm),G({abi:$o,functionName:"borrowRateView",args:[t,s]})),[n]=re(J("uint256"),r);return n}function Qe(e,t,s){let r=s>e.lastUpdate?s-e.lastUpdate:0n,n=t*r,l=Ue(n*n,2n*Se),o=Ue(l*n,3n*Se);return e.totalBorrowAssets+Ue(e.totalBorrowAssets*(n+l+o),Se)}async function $e(e,t,s,r=0n){let[n,l]=await Promise.all([e.getBlock({blockTag:"latest"}),Eo(e,t,s)]),o=BigInt(Math.ceil(Date.now()/1e3)),a=(n.timestamp>o?n.timestamp:o)+r;return{totalBorrowAssets:Qe(s,l,a),accruedThrough:a,rate:l}}async function Zt(e,t,s){let r=await ne(e,D(t),G({abi:it,functionName:"balanceOf",args:[D(s)]})),[n]=re(J("uint256"),r);return n}async function fe(e,t,s=!1){let r=t.marketId,n=t.marketParams;if(!r&&!n)throw new i("Provide either marketId or marketParams for the Morpho Blue market.");let l=n?je(n):void 0,o=l?ke(l):void 0,a=r!==void 0?Qt(r):void 0;if(a&&o&&a!==o.toLowerCase())throw new i(`MarketParams tuple hash (${o}) does not match marketId (${a}).`);let u=(a??o).toLowerCase();if(s&&!j(u))throw new i(`Morpho actions require a known market from Oak's verified registry, which pins its oracle. Find one with morpho_status {"discover":true}; other markets are read-only.`);let[c,m]=await Promise.all([Yt(e,u),Jt(e,u)]);if(c.loanToken===te||c.collateralToken===te||c.lltv===0n||m.lastUpdate===0n)throw new i(`Morpho market ${u} is not initialized on chain ${f}.`);let d=ke(c);if(d.toLowerCase()!==u.toLowerCase())throw new i(`On-chain idToMarketParams tuple hash (${d}) does not match marketId (${u}).`);if(l&&!(l.loanToken.toLowerCase()===c.loanToken.toLowerCase()&&l.collateralToken.toLowerCase()===c.collateralToken.toLowerCase()&&l.oracle.toLowerCase()===c.oracle.toLowerCase()&&l.irm.toLowerCase()===c.irm.toLowerCase()&&l.lltv===c.lltv))throw new i(`Provided marketParams tuple does not match on-chain idToMarketParams for ${u}.`);return{marketId:u,marketParams:c,marketState:m}}function Me(e){if(e.assets!==void 0&&e.amount!==void 0)throw new i("Specify either assets or amount, not both.");let t=e.assets??e.amount;if(typeof t!="string")throw new i("Provide an amount as a base-unit integer string.");let s=Le(t);if(s<=0n||s>jt)throw new i("Asset amount must be greater than zero and fit in uint128.");return s}function ve(e,t){for(let s of["onBehalf","receiver"])if(e[s]!==void 0&&(typeof e[s]!="string"||e[s].toLowerCase()!==t.toLowerCase()))throw new i(`Morpho ${s} must be the wallet; overrides are not supported.`);if(e.data!==void 0&&e.data!=="0x")throw new i("Morpho callback data must be empty (0x).")}async function Go(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=e.clientFor(f),{marketId:o,marketParams:a}=await fe(l,t,!0),u=await Q(l,a.collateralToken,f),c=a.collateralToken.toLowerCase()===me.toLowerCase(),m=typeof t.collateralToken=="string"?(q(t.collateralToken),D(t.collateralToken)):void 0,d=W("wrapNative",t.wrapNative)===!0||m!==void 0&&dt(m);if(m&&!dt(m)&&m.toLowerCase()!==a.collateralToken.toLowerCase())throw new i(`Collateral token ${m} does not match market collateral ${a.collateralToken}.`);if(d&&!c)throw new i("Native ETH wrapping is only supported when market collateralToken is WETH.");let p=Me(t),h=p.toString(),b=e.formatAmount(h,u.decimals),w=[];d&&w.push(e.unsignedTx({chainId:f,to:me,data:G({abi:Kt,functionName:"deposit"}),value:h,description:`Wrap ${b} ETH into WETH at ${me}.`})),w.push(e.approval(a.collateralToken,B,h,f)),w.push(e.unsignedTx({chainId:f,to:B,data:G({abi:X,functionName:"supplyCollateral",args:[a,p,n,"0x"]}),value:"0",description:`Supply ${b} ${u.symbol} (${h} base units) collateral to Morpho market ${o}.`}));let k=await e.preview(w,r),{formattedChanges:y,formattedNetOutflows:g}=xe(e,k);return{action:"morpho_supply_collateral",chainId:f,marketId:o,marketParams:pe(a),collateralToken:u,assets:h,formattedAssets:b,onBehalf:n,txs:w,summary:`${d?`Send ${b} ETH to wrap into WETH. `:""}Supply ${b} ${u.symbol} collateral to Morpho Blue market ${o}.`,preview:k,formattedChanges:y,formattedNetOutflows:g}}async function Ro(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=r,o=e.clientFor(f),{marketId:a,marketParams:u,marketState:c}=await fe(o,t,!0),[m,d,p,h]=await Promise.all([Q(o,u.loanToken,f),Te(o,a,n),Ke(o,u.oracle),$e(o,u,c,qe)]),b=Me(t),w=b.toString(),k=e.formatAmount(w,m.decimals),y=c.totalSupplyAssets>c.totalBorrowAssets?c.totalSupplyAssets-c.totalBorrowAssets:0n;if(b>y)throw new i(`Insufficient market liquidity: requested ${w} base units, available ${y.toString()} base units.`);let g=Ae(d.collateral,p,u.lltv),I=se(d.borrowShares,h.totalBorrowAssets,c.totalBorrowShares);if(d.collateral===0n||I+b>g)throw new i(`Insufficient collateral or unhealthy borrow: total debt ${(I+b).toString()} exceeds max borrow ${g.toString()} base units.`);let x=No(b,h.totalBorrowAssets,c.totalBorrowShares),P=[e.unsignedTx({chainId:f,to:B,data:G({abi:X,functionName:"borrow",args:[u,b,0n,n,l]}),value:"0",description:`Borrow ${k} ${m.symbol} (${w} base units) from Morpho market ${a}.`})],C=await e.preview(P,r),{formattedChanges:L,formattedNetOutflows:v}=xe(e,C);return{action:"morpho_borrow",chainId:f,marketId:a,marketParams:pe(u),loanToken:m,assets:w,formattedAssets:k,borrowShares:x.toString(),onBehalf:n,receiver:l,txs:P,summary:`Borrow ${k} ${m.symbol} from Morpho Blue market ${a}.`,preview:C,formattedChanges:L,formattedNetOutflows:v}}async function eo(e,t,s,r=qe){let n=Ie(t,s);ve(t,n);let l=n,o=e.clientFor(f);if(t.shares!==void 0){let v=Le(t.shares);if(v<=0n||v===Do||v>jt)throw new i("Morpho Blue core does not accept maxUint256 or out-of-range share sentinels; pass exact position.borrowShares.")}if(W("repayAll",t.repayAll)===!0&&(t.shares!==void 0||t.assets!==void 0||t.amount!==void 0))throw new i("Specify repayAll alone, without shares or assets/amount.");if(t.shares!==void 0&&(t.assets!==void 0||t.amount!==void 0))throw new i("Specify either assets/amount or shares for Morpho repay, not both.");let{marketId:a,marketParams:u,marketState:c}=await fe(o,t,!0),[m,d,p]=await Promise.all([Q(o,u.loanToken,f),Te(o,a,l),Zt(o,u.loanToken,n)]);if(d.borrowShares===0n)throw new i(`Position has no active borrow debt on Morpho market ${a}.`);let h=0n,b=0n;if(W("repayAll",t.repayAll)===!0)b=d.borrowShares;else if(t.shares!==void 0){let v=Le(t.shares);if(v>d.borrowShares)throw new i(`Repay shares (${v.toString()}) exceed current position borrowShares (${d.borrowShares.toString()}).`);b=v}else h=Me(t);let w=b>0n?await $e(o,u,c,r):void 0,k=b>0n?se(b,w.totalBorrowAssets,c.totalBorrowShares):h;if(p<k)throw new i(`Insufficient loan token balance for repayment: wallet holds ${p.toString()} base units, but ${k.toString()} base units are required (including accrued interest).`);let y=k.toString(),g=e.formatAmount(y,m.decimals),I=e.approval(u.loanToken,B,y,f),x=e.unsignedTx({chainId:f,to:B,data:G({abi:X,functionName:"repay",args:[u,h,b,l,"0x"]}),value:"0",description:b>0n?`Repay ${b.toString()} borrow shares (${g} ${m.symbol}) on Morpho market ${a}.`:`Repay ${g} ${m.symbol} (${h.toString()} base units) on Morpho market ${a}.`}),T=[I,x],P=await e.preview(T,n),{formattedChanges:C,formattedNetOutflows:L}=xe(e,P);return{action:"morpho_repay",chainId:f,marketId:a,marketParams:pe(u),loanToken:m,repayAssets:h.toString(),repayShares:b.toString(),requiredAssets:y,...w?{accruedThrough:w.accruedThrough.toString(),borrowRatePerSecond:w.rate.toString(),inclusionSeconds:r.toString()}:{},formattedRequiredAssets:g,onBehalf:l,txs:T,summary:b>0n?`Repay ${b.toString()} borrow shares (approval up to ${g} ${m.symbol}) on Morpho Blue market ${a}. Refresh if signing/inclusion takes more than ${qe} seconds.`:`Repay ${g} ${m.symbol} on Morpho Blue market ${a}.`,preview:P,formattedChanges:C,formattedNetOutflows:L}}function Ka(e,t,s){if(t.repayAll!==!0)throw new i("Reviewed debt reconstruction requires repayAll.");return eo(e,t,s,0n)}async function _o(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=r,o=e.clientFor(f),{marketId:a,marketParams:u,marketState:c}=await fe(o,t,!0),[m,d,p,h]=await Promise.all([Q(o,u.collateralToken,f),Te(o,a,n),Ke(o,u.oracle),$e(o,u,c,qe)]),b=W("withdrawAll",t.withdrawAll)===!0?d.collateral:Me(t);if(b<=0n||b>d.collateral)throw new i(`Insufficient collateral to withdraw: requested ${b.toString()} base units, position holds ${d.collateral.toString()} base units.`);if(d.borrowShares>0n){let P=d.collateral-b,C=Ae(P,p,u.lltv),L=se(d.borrowShares,h.totalBorrowAssets,c.totalBorrowShares);if(L>C)throw new i(`Unhealthy collateral withdrawal: remaining max borrow ${C.toString()} would fall below current debt ${L.toString()} base units.`)}let w=b.toString(),k=e.formatAmount(w,m.decimals),g=[e.unsignedTx({chainId:f,to:B,data:G({abi:X,functionName:"withdrawCollateral",args:[u,b,n,l]}),value:"0",description:`Withdraw ${k} ${m.symbol} (${w} base units) collateral from Morpho market ${a}.`})],I=await e.preview(g,r),{formattedChanges:x,formattedNetOutflows:T}=xe(e,I);return{action:"morpho_withdraw_collateral",chainId:f,marketId:a,marketParams:pe(u),collateralToken:m,assets:w,formattedAssets:k,onBehalf:n,receiver:l,txs:g,summary:`Withdraw ${k} ${m.symbol} collateral from Morpho Blue market ${a}.`,preview:I,formattedChanges:x,formattedNetOutflows:T}}async function Ho(e,t,s){let r=Ie(t,s);ve(t,r);let n=e.clientFor(f),{marketId:l,marketParams:o,marketState:a}=await fe(n,t,!0),u=W("wrapNative",t.wrapNative)===!0;if(u&&o.loanToken.toLowerCase()!==me.toLowerCase())throw new i("Native ETH wrapping is only supported when the market loanToken is WETH.");let c=Me(t),m=c.toString(),[d,p]=await Promise.all([Q(n,o.loanToken,f),u?Promise.resolve(c):Zt(n,o.loanToken,r)]);if(p<c)throw new i(`Insufficient ${d.symbol} balance to lend: wallet holds ${p.toString()} base units, requested ${m}.`);let h=e.formatAmount(m,d.decimals),b=[];u&&b.push(e.unsignedTx({chainId:f,to:me,data:G({abi:Kt,functionName:"deposit"}),value:m,description:`Wrap ${h} ETH into WETH at ${me}.`})),b.push(e.approval(o.loanToken,B,m,f)),b.push(e.unsignedTx({chainId:f,to:B,data:G({abi:X,functionName:"supply",args:[o,c,0n,r,"0x"]}),value:"0",description:`Lend ${h} ${d.symbol} (${m} base units) to Morpho market ${l}.`}));let w=Bo(c,a.totalSupplyAssets,a.totalSupplyShares),k=await e.preview(b,r),{formattedChanges:y,formattedNetOutflows:g}=xe(e,k);return{action:"morpho_supply",chainId:f,marketId:l,marketParams:pe(o),loanToken:d,assets:m,formattedAssets:h,supplySharesEstimated:w.toString(),onBehalf:r,oak:ct(l),txs:b,summary:`${u?`Send ${h} ETH to wrap into WETH. `:""}Lend ${h} ${d.symbol} to Morpho Blue market ${l}. It earns the market supply rate and is exposed to the market's collateral, oracle and liquidity risk.`,preview:k,formattedChanges:y,formattedNetOutflows:g}}async function qo(e,t,s){let r=Ie(t,s);ve(t,r);let n=e.clientFor(f),l=W("withdrawAll",t.withdrawAll)===!0;if(l&&(t.assets!==void 0||t.amount!==void 0))throw new i("Specify withdrawAll alone, without assets/amount.");let{marketId:o,marketParams:a,marketState:u}=await fe(n,t,!0),[c,m]=await Promise.all([Q(n,a.loanToken,f),Te(n,o,r)]);if(m.supplyShares===0n)throw new i(`This wallet has no lent ${c.symbol} on Morpho market ${o}.`);let d=ut(m.supplyShares,u.totalSupplyAssets,u.totalSupplyShares),p=l?0n:Me(t),h=l?m.supplyShares:0n;if(!l&&p>d)throw new i(`Withdrawal exceeds the lent balance: requested ${p.toString()} base units, position holds about ${d.toString()}. Use withdrawAll for a full exit.`);let b=u.totalSupplyAssets>u.totalBorrowAssets?u.totalSupplyAssets-u.totalBorrowAssets:0n,w=l?d:p;if(w>b)throw new i(`Insufficient market liquidity: withdrawing ${w.toString()} base units needs idle assets, but only ${b.toString()} are available until borrowers repay. Withdraw at most that amount, or retry later.`);let k=e.formatAmount(w.toString(),c.decimals),g=[e.unsignedTx({chainId:f,to:B,data:G({abi:X,functionName:"withdraw",args:[a,p,h,r,r]}),value:"0",description:l?`Withdraw all ${m.supplyShares.toString()} supply shares (about ${k} ${c.symbol}) from Morpho market ${o}.`:`Withdraw ${k} ${c.symbol} (${p.toString()} base units) of lent assets from Morpho market ${o}.`})],I=await e.preview(g,r),{formattedChanges:x,formattedNetOutflows:T}=xe(e,I);return{action:"morpho_withdraw",chainId:f,marketId:o,marketParams:pe(a),loanToken:c,withdrawAssets:p.toString(),withdrawShares:h.toString(),estimatedAssets:w.toString(),formattedAssets:k,receiver:r,txs:g,summary:l?`Withdraw all lent ${c.symbol} (about ${k}, including interest) from Morpho Blue market ${o}.`:`Withdraw ${k} lent ${c.symbol} from Morpho Blue market ${o}.`,preview:I,formattedChanges:x,formattedNetOutflows:T}}async function to(e,t,s){let r=await e.http(Io,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({query:t,variables:s})});if(!r.ok)throw new i(`Morpho GraphQL request failed (HTTP ${r.status}).`);let n=await r.json();if(n.errors?.length)throw new i("Morpho GraphQL returned query errors.");return n.data??{}}async function oo(e){let t=`query Markets($chainId: Int!) {
2
2
  markets(first: 1000, where: { chainId_in: [$chainId] }) {
3
3
  items {
4
4
  marketId chain { id } lltv listed