@oakagentkit/core 0.2.7 → 0.3.1

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 (508) hide show
  1. package/build/dist/api/addresses.d.ts +9 -0
  2. package/build/dist/api/addresses.js +1 -1
  3. package/build/dist/api/chain.d.ts +4 -0
  4. package/build/dist/api/chain.js +1 -1
  5. package/build/dist/api/history.js +1 -1
  6. package/build/dist/api/identity-link.js +1 -1
  7. package/build/dist/api/metadata.js +1 -1
  8. package/build/dist/api/modules/beefy/boosts.js +1 -1
  9. package/build/dist/api/modules/beefy/clm.d.ts +9 -0
  10. package/build/dist/api/modules/beefy/clm.js +1 -1
  11. package/build/dist/api/modules/beefy/guard.js +1 -1
  12. package/build/dist/api/modules/beefy/index.js +1 -1
  13. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  14. package/build/dist/api/modules/beefy/management.js +1 -1
  15. package/build/dist/api/modules/beefy/vaults.js +1 -1
  16. package/build/dist/api/modules/borro/abi.d.ts +54 -0
  17. package/build/dist/api/modules/borro/abi.js +1 -1
  18. package/build/dist/api/modules/borro/actions.d.ts +14 -1
  19. package/build/dist/api/modules/borro/actions.js +1 -1
  20. package/build/dist/api/modules/borro/checks.js +1 -1
  21. package/build/dist/api/modules/borro/copy.d.ts +10 -2
  22. package/build/dist/api/modules/borro/copy.js +1 -1
  23. package/build/dist/api/modules/borro/index.js +1 -1
  24. package/build/dist/api/modules/borro/liquidity.js +1 -1
  25. package/build/dist/api/modules/borro/pins.d.ts +30 -14
  26. package/build/dist/api/modules/borro/pins.js +1 -1
  27. package/build/dist/api/modules/borro/positions.js +1 -1
  28. package/build/dist/api/modules/borro/reader.js +1 -1
  29. package/build/dist/api/modules/borro/types.d.ts +1 -0
  30. package/build/dist/api/modules/chop/actions.js +1 -1
  31. package/build/dist/api/modules/chop/checks.js +1 -1
  32. package/build/dist/api/modules/chop/copy.js +1 -1
  33. package/build/dist/api/modules/chop/guard.js +1 -1
  34. package/build/dist/api/modules/chop/index.js +1 -1
  35. package/build/dist/api/modules/chop/pins.d.ts +13 -0
  36. package/build/dist/api/modules/chop/pins.js +1 -1
  37. package/build/dist/api/modules/chop/positions.js +1 -1
  38. package/build/dist/api/modules/chop/reader.js +1 -1
  39. package/build/dist/api/modules/clanker/extensions.js +1 -1
  40. package/build/dist/api/modules/clanker/index.js +1 -1
  41. package/build/dist/api/modules/clanker/manage.js +1 -1
  42. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  43. package/build/dist/api/modules/clanker/protocol.js +1 -1
  44. package/build/dist/api/modules/clanker/state.js +1 -1
  45. package/build/dist/api/modules/earn/copy.d.ts +6 -6
  46. package/build/dist/api/modules/earn/copy.js +1 -1
  47. package/build/dist/api/modules/earn/cost.d.ts +1 -1
  48. package/build/dist/api/modules/earn/cost.js +1 -1
  49. package/build/dist/api/modules/earn/index.js +1 -1
  50. package/build/dist/api/modules/earn/lp.js +1 -1
  51. package/build/dist/api/modules/earn/options.js +1 -1
  52. package/build/dist/api/modules/erc8004/common.js +1 -1
  53. package/build/dist/api/modules/erc8004/domain.js +1 -1
  54. package/build/dist/api/modules/erc8004/index.js +1 -1
  55. package/build/dist/api/modules/erc8004/management.js +1 -1
  56. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  57. package/build/dist/api/modules/erc8004/services.js +1 -1
  58. package/build/dist/api/modules/erc8004/thesis.d.ts +61 -0
  59. package/build/dist/api/modules/erc8004/thesis.js +1 -0
  60. package/build/dist/api/modules/erc8004/validation.js +1 -1
  61. package/build/dist/api/modules/fobo/client.d.ts +9 -0
  62. package/build/dist/api/modules/fobo/client.js +1 -0
  63. package/build/dist/api/modules/fobo/index.d.ts +16 -0
  64. package/build/dist/api/modules/fobo/index.js +1 -0
  65. package/build/dist/api/modules/fobo/intent.d.ts +243 -0
  66. package/build/dist/api/modules/fobo/intent.js +1 -0
  67. package/build/dist/api/modules/fobo/pins.d.ts +178 -0
  68. package/build/dist/api/modules/fobo/pins.js +1 -0
  69. package/build/dist/api/modules/fobo/steps.d.ts +25 -0
  70. package/build/dist/api/modules/fobo/steps.js +1 -0
  71. package/build/dist/api/modules/fobo/verify.d.ts +89 -0
  72. package/build/dist/api/modules/fobo/verify.js +1 -0
  73. package/build/dist/api/modules/gloam/copy.d.ts +1 -1
  74. package/build/dist/api/modules/gloam/copy.js +1 -1
  75. package/build/dist/api/modules/gloam/index.js +1 -1
  76. package/build/dist/api/modules/grove/index.js +1 -1
  77. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  78. package/build/dist/api/modules/heyresearch/index.js +1 -1
  79. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  80. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  81. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  82. package/build/dist/api/modules/hoodag/index.d.ts +12 -1
  83. package/build/dist/api/modules/hoodag/index.js +1 -1
  84. package/build/dist/api/modules/hoodag/management.js +1 -1
  85. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  86. package/build/dist/api/modules/hoodag/reconstruct.d.ts +14 -0
  87. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  88. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  89. package/build/dist/api/modules/hoodlock/buyback.js +1 -1
  90. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  91. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  92. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  93. package/build/dist/api/modules/hoodlock/index.js +1 -1
  94. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  95. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  96. package/build/dist/api/modules/hoodlock/public.js +1 -1
  97. package/build/dist/api/modules/hookr/actions.js +1 -1
  98. package/build/dist/api/modules/hookr/addons.js +1 -1
  99. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  100. package/build/dist/api/modules/hookr/contracts.js +1 -1
  101. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  102. package/build/dist/api/modules/hookr/discovery.js +1 -1
  103. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  104. package/build/dist/api/modules/hookr/index.js +1 -1
  105. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  106. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  107. package/build/dist/api/modules/hookr/launch.js +1 -1
  108. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  109. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  110. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  111. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  112. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  113. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  114. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  115. package/build/dist/api/modules/hookr/relay.js +1 -1
  116. package/build/dist/api/modules/hookr/revenue.js +1 -1
  117. package/build/dist/api/modules/kyberswap/index.d.ts +2 -1
  118. package/build/dist/api/modules/kyberswap/index.js +1 -1
  119. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  120. package/build/dist/api/modules/layerbank/abi.js +1 -1
  121. package/build/dist/api/modules/layerbank/actions.js +1 -1
  122. package/build/dist/api/modules/layerbank/checks.js +1 -1
  123. package/build/dist/api/modules/layerbank/index.js +1 -1
  124. package/build/dist/api/modules/layerbank/merkl.js +1 -1
  125. package/build/dist/api/modules/layerbank/reader.js +1 -1
  126. package/build/dist/api/modules/layerbank/reserve.js +1 -1
  127. package/build/dist/api/modules/lighter/index.js +1 -1
  128. package/build/dist/api/modules/longbow/administration.js +1 -1
  129. package/build/dist/api/modules/longbow/analytics.js +1 -1
  130. package/build/dist/api/modules/longbow/fixed.js +1 -1
  131. package/build/dist/api/modules/longbow/index.js +1 -1
  132. package/build/dist/api/modules/longbow/nft.js +1 -1
  133. package/build/dist/api/modules/longbow/rebates.js +1 -1
  134. package/build/dist/api/modules/longbow/staking.js +1 -1
  135. package/build/dist/api/modules/meridian/index.js +1 -1
  136. package/build/dist/api/modules/meridian/markets.js +1 -1
  137. package/build/dist/api/modules/meridian/predict-read.js +1 -1
  138. package/build/dist/api/modules/meridian/rfq.js +1 -1
  139. package/build/dist/api/modules/merkl/discovery.js +1 -1
  140. package/build/dist/api/modules/merkl/index.js +1 -1
  141. package/build/dist/api/modules/merkl/manage.js +1 -1
  142. package/build/dist/api/modules/merkl/protocol.js +1 -1
  143. package/build/dist/api/modules/morpho/allocator.js +1 -1
  144. package/build/dist/api/modules/morpho/bundles.js +1 -1
  145. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  146. package/build/dist/api/modules/morpho/index.js +1 -1
  147. package/build/dist/api/modules/morpho/local-guard.d.ts +2 -1
  148. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  149. package/build/dist/api/modules/morpho/midnight.js +1 -1
  150. package/build/dist/api/modules/morpho/protocol.js +1 -1
  151. package/build/dist/api/modules/morpho/surface.js +1 -1
  152. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  153. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  154. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  155. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  156. package/build/dist/api/modules/netnet/card-policy.d.ts +1 -0
  157. package/build/dist/api/modules/netnet/card-policy.js +1 -1
  158. package/build/dist/api/modules/netnet/card-read.js +1 -1
  159. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  160. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  161. package/build/dist/api/modules/netnet/desk-read.js +1 -1
  162. package/build/dist/api/modules/netnet/financial.js +1 -1
  163. package/build/dist/api/modules/netnet/index.js +1 -1
  164. package/build/dist/api/modules/netnet/staking.js +1 -1
  165. package/build/dist/api/modules/orbio/index.d.ts +6 -0
  166. package/build/dist/api/modules/orbio/index.js +1 -1
  167. package/build/dist/api/modules/orbio/positions.js +1 -1
  168. package/build/dist/api/modules/pendle/costs.js +1 -1
  169. package/build/dist/api/modules/pendle/index.js +1 -1
  170. package/build/dist/api/modules/pendle/markets.js +1 -1
  171. package/build/dist/api/modules/pendle/positions.js +1 -1
  172. package/build/dist/api/modules/pendle/pricecheck.js +1 -1
  173. package/build/dist/api/modules/pendle/reader.js +1 -1
  174. package/build/dist/api/modules/pendle/redeem.js +1 -1
  175. package/build/dist/api/modules/pendle/trade.js +1 -1
  176. package/build/dist/api/modules/pendle/validate.js +1 -1
  177. package/build/dist/api/modules/pendle/verify.js +1 -1
  178. package/build/dist/api/modules/pons/claim.js +1 -1
  179. package/build/dist/api/modules/pons/index.js +1 -1
  180. package/build/dist/api/modules/pons/launch-status.js +1 -1
  181. package/build/dist/api/modules/pons/prices.js +1 -1
  182. package/build/dist/api/modules/pons/reads.js +1 -1
  183. package/build/dist/api/modules/pons/swap-terms.d.ts +2 -8
  184. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  185. package/build/dist/api/modules/pons/trade.js +1 -1
  186. package/build/dist/api/modules/poolstrade/index.js +1 -1
  187. package/build/dist/api/modules/priors/coverage.js +1 -1
  188. package/build/dist/api/modules/priors/discovery.js +1 -1
  189. package/build/dist/api/modules/priors/features.js +1 -1
  190. package/build/dist/api/modules/priors/holdings.js +1 -1
  191. package/build/dist/api/modules/priors/index.js +1 -1
  192. package/build/dist/api/modules/priors/integration.js +1 -1
  193. package/build/dist/api/modules/priors/market.js +1 -1
  194. package/build/dist/api/modules/priors/pt.js +1 -1
  195. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  196. package/build/dist/api/modules/priors/starter-line.js +1 -1
  197. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  198. package/build/dist/api/modules/relay/api.js +1 -1
  199. package/build/dist/api/modules/relay/bootstrap.js +1 -1
  200. package/build/dist/api/modules/relay/discovery.js +1 -1
  201. package/build/dist/api/modules/relay/inbound.js +1 -1
  202. package/build/dist/api/modules/relay/index.js +1 -1
  203. package/build/dist/api/modules/relay/order.js +1 -1
  204. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  205. package/build/dist/api/modules/relay/readiness.js +1 -1
  206. package/build/dist/api/modules/relay/reads.js +1 -1
  207. package/build/dist/api/modules/relay/vaults.js +1 -1
  208. package/build/dist/api/modules/spark/actions.js +1 -1
  209. package/build/dist/api/modules/spark/details.js +1 -1
  210. package/build/dist/api/modules/spark/index.js +1 -1
  211. package/build/dist/api/modules/spark/management.js +1 -1
  212. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  213. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  214. package/build/dist/api/modules/steakhouse/index.js +1 -1
  215. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  216. package/build/dist/api/modules/steakhouse/management.js +1 -1
  217. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  218. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  219. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  220. package/build/dist/api/modules/tickerspring/discovery.js +1 -1
  221. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  222. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  223. package/build/dist/api/modules/tickerspring/index.js +1 -1
  224. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  225. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  226. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  227. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  228. package/build/dist/api/modules/tickerspring/research.js +1 -1
  229. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  230. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  231. package/build/dist/api/modules/uniswap/auction.js +1 -1
  232. package/build/dist/api/modules/uniswap/batch.js +1 -1
  233. package/build/dist/api/modules/uniswap/common.js +1 -1
  234. package/build/dist/api/modules/uniswap/fees.js +1 -1
  235. package/build/dist/api/modules/uniswap/index.js +1 -1
  236. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  237. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  238. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  239. package/build/dist/api/modules/uniswap/pools.js +1 -1
  240. package/build/dist/api/modules/uniswap/position.js +1 -1
  241. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  242. package/build/dist/api/modules/uniswap/quote-guard.js +1 -1
  243. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  244. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  245. package/build/dist/api/modules/uniswap/trade.js +1 -1
  246. package/build/dist/api/modules/uniswap/v2.js +1 -1
  247. package/build/dist/api/modules/uniswap/v3.js +1 -1
  248. package/build/dist/api/modules/uniswap/v4.js +1 -1
  249. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  250. package/build/dist/api/modules/upoch/copy.d.ts +5 -0
  251. package/build/dist/api/modules/upoch/copy.js +1 -0
  252. package/build/dist/api/modules/upoch/index.d.ts +8 -0
  253. package/build/dist/api/modules/upoch/index.js +1 -0
  254. package/build/dist/api/modules/upoch/pins.d.ts +8 -0
  255. package/build/dist/api/modules/upoch/pins.js +1 -0
  256. package/build/dist/api/modules/upoch/reads.d.ts +509 -0
  257. package/build/dist/api/modules/upoch/reads.js +1 -0
  258. package/build/dist/api/modules/velora/claims.js +1 -1
  259. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  260. package/build/dist/api/modules/velora/index.js +1 -1
  261. package/build/dist/api/modules/wormhole/index.js +1 -1
  262. package/build/dist/api/modules/wormhole/x402-client.d.ts +17 -1
  263. package/build/dist/api/modules/wormhole/x402-client.js +1 -1
  264. package/build/dist/api/positions.js +1 -1
  265. package/build/dist/api/pricenote.js +1 -1
  266. package/build/dist/api/prices.d.ts +5 -0
  267. package/build/dist/api/prices.js +1 -1
  268. package/build/dist/api/pricing.js +1 -1
  269. package/build/dist/api/rpc.js +1 -1
  270. package/build/dist/api/secret-fields.d.ts +2 -0
  271. package/build/dist/api/secret-fields.js +1 -1
  272. package/build/dist/api/send.js +1 -1
  273. package/build/dist/api/signing-registry.js +1 -1
  274. package/build/dist/api/signing.js +1 -1
  275. package/build/dist/api/simulate.js +1 -1
  276. package/build/dist/api/swap.d.ts +1 -0
  277. package/build/dist/api/swap.js +1 -1
  278. package/build/dist/api/tokens.js +1 -1
  279. package/build/dist/api/tool-policy.d.ts +1 -0
  280. package/build/dist/api/tool-policy.js +1 -1
  281. package/build/dist/api/universal-router.d.ts +45 -0
  282. package/build/dist/api/universal-router.js +1 -0
  283. package/build/dist/api/usd-estimate.js +1 -1
  284. package/build/dist/chunks/{ZOMFHTB2.js → 22TU5PFT.js} +1 -1
  285. package/build/dist/chunks/23HNDJ76.js +2 -0
  286. package/build/dist/chunks/{ZFU65MB4.js → 257N7343.js} +1 -1
  287. package/build/dist/chunks/{F3VDVTMS.js → 27PVS6BU.js} +1 -1
  288. package/build/dist/chunks/{N245WC5R.js → 2JWAFLJU.js} +1 -1
  289. package/build/dist/chunks/{GQYV4TFO.js → 2OVJ2BTJ.js} +1 -1
  290. package/build/dist/chunks/{JS53DQVT.js → 35LXCSHY.js} +1 -1
  291. package/build/dist/chunks/{V37L4DU4.js → 3A2IKFTV.js} +1 -1
  292. package/build/dist/chunks/{OYPAVXGQ.js → 3BMM3V4P.js} +1 -1
  293. package/build/dist/chunks/{ZKZUS3QU.js → 3FU6XP6S.js} +1 -1
  294. package/build/dist/chunks/{BB765L75.js → 3PHJUFU2.js} +1 -1
  295. package/build/dist/chunks/{FWIFTPSE.js → 3PU2SD3U.js} +1 -1
  296. package/build/dist/chunks/{SBY4RJ7I.js → 3ZH5SOC2.js} +1 -1
  297. package/build/dist/chunks/43BG2JRB.js +1 -0
  298. package/build/dist/chunks/{YTLH4M4Y.js → 47HSRR7G.js} +1 -1
  299. package/build/dist/chunks/4NBXBKOX.js +2 -0
  300. package/build/dist/chunks/{EZZM2GQT.js → 4NDIYRH5.js} +1 -1
  301. package/build/dist/chunks/{FOKEFXGP.js → 4PLLS6CT.js} +1 -1
  302. package/build/dist/chunks/4RCYYN6O.js +1 -0
  303. package/build/dist/chunks/{XHYFISVV.js → 4Z3IGMU6.js} +1 -1
  304. package/build/dist/chunks/4ZD5D2UP.js +1 -0
  305. package/build/dist/chunks/{CSDN4MYP.js → 5GQJVKVY.js} +1 -1
  306. package/build/dist/chunks/{QFSBDPLN.js → 65OITTDL.js} +1 -1
  307. package/build/dist/chunks/{4FPV4CRC.js → 6D3XNCOX.js} +1 -1
  308. package/build/dist/chunks/{DSTMEY5F.js → 6F527FLN.js} +1 -1
  309. package/build/dist/chunks/{O3JWCJIF.js → 6GWXPQZ6.js} +1 -1
  310. package/build/dist/chunks/{32RXFUOH.js → 73BZPPRS.js} +1 -1
  311. package/build/dist/chunks/75SULXNT.js +1 -0
  312. package/build/dist/chunks/{WU7XIAXB.js → 7EACRKFV.js} +1 -1
  313. package/build/dist/chunks/{SKEKXEUU.js → 7FIEBJOZ.js} +1 -1
  314. package/build/dist/chunks/{4GNUXN4K.js → 7FZXSYFD.js} +1 -1
  315. package/build/dist/chunks/{ZP36DSOD.js → 7TSIF3F4.js} +1 -1
  316. package/build/dist/chunks/{AMTRDPVO.js → 7U62MMUQ.js} +1 -1
  317. package/build/dist/chunks/{DW4V5PUY.js → 7VH6JQ2H.js} +1 -1
  318. package/build/dist/chunks/A3BJSQ23.js +1 -0
  319. package/build/dist/chunks/{YSMWCKIX.js → ADIPEGNN.js} +1 -1
  320. package/build/dist/chunks/AG2G7BHH.js +6 -0
  321. package/build/dist/chunks/AIYNFIG6.js +1 -0
  322. package/build/dist/chunks/ANIF3JMV.js +4 -0
  323. package/build/dist/chunks/{4JTTA3BX.js → AWV24X7F.js} +1 -1
  324. package/build/dist/chunks/{7QKYDNF6.js → AXHFNE6L.js} +1 -1
  325. package/build/dist/chunks/{WOGWLFAL.js → BGVC5NI6.js} +1 -1
  326. package/build/dist/chunks/BJK75C7G.js +1 -0
  327. package/build/dist/chunks/BSX4LFYI.js +1 -0
  328. package/build/dist/chunks/{OYJFXEDU.js → BZPFPQ2I.js} +1 -1
  329. package/build/dist/chunks/{5PI57UC2.js → C76D54YG.js} +1 -1
  330. package/build/dist/chunks/{TDZTC5WR.js → DBOGRUPS.js} +1 -1
  331. package/build/dist/chunks/{HHO5ISMM.js → DCGNVMKG.js} +1 -1
  332. package/build/dist/chunks/{Y77EVVT4.js → DGDMRATN.js} +1 -1
  333. package/build/dist/chunks/{EGZREEG2.js → DLNA5272.js} +1 -1
  334. package/build/dist/chunks/{TM7Z5SA4.js → DMDOSHV7.js} +1 -1
  335. package/build/dist/chunks/{WHVZ372B.js → DRLBTB4E.js} +1 -1
  336. package/build/dist/chunks/DXAPKN7H.js +1 -0
  337. package/build/dist/chunks/{FZ6IJZZM.js → E76Z2TT4.js} +1 -1
  338. package/build/dist/chunks/{67BWOVET.js → EHGH646D.js} +1 -1
  339. package/build/dist/chunks/{KKPMOAVI.js → ELHRXA5U.js} +1 -1
  340. package/build/dist/chunks/{PZEF5LBL.js → ETMD747Y.js} +1 -1
  341. package/build/dist/chunks/{XCKTE4ON.js → F7MGYRPU.js} +1 -1
  342. package/build/dist/chunks/{MRMR4QHA.js → FAH7FKUT.js} +1 -1
  343. package/build/dist/chunks/FXOFR432.js +1 -0
  344. package/build/dist/chunks/{VHV6WQ5F.js → G2AA73ZE.js} +1 -1
  345. package/build/dist/chunks/{JWR5XVP2.js → GBIBRYOV.js} +1 -1
  346. package/build/dist/chunks/{FNGIJKMZ.js → GDOHHXNH.js} +1 -1
  347. package/build/dist/chunks/{BZ34ZR65.js → GGMVT5A6.js} +1 -1
  348. package/build/dist/chunks/GK3D7OKG.js +1 -0
  349. package/build/dist/chunks/{2OKYXT25.js → GQITAJVF.js} +1 -1
  350. package/build/dist/chunks/GYPMUYB5.js +1 -0
  351. package/build/dist/chunks/H3E7UD2X.js +1 -0
  352. package/build/dist/chunks/{GDRQ2ANN.js → H64QC4QR.js} +1 -1
  353. package/build/dist/chunks/HFVXNKA5.js +1 -0
  354. package/build/dist/chunks/HHYE42JG.js +21 -0
  355. package/build/dist/chunks/{U363GQTF.js → HIG7JY3J.js} +1 -1
  356. package/build/dist/chunks/{XWKK75TO.js → HOBIXKGO.js} +1 -1
  357. package/build/dist/chunks/HQIS3QI7.js +3 -0
  358. package/build/dist/chunks/{UOCRYXAB.js → HRAHGYNK.js} +1 -1
  359. package/build/dist/chunks/{GLF7WEY2.js → HUKDISRE.js} +1 -1
  360. package/build/dist/chunks/{GSFHM5L3.js → HZSYMGJ2.js} +1 -1
  361. package/build/dist/chunks/{FJLJ7ZQ5.js → I4473OC6.js} +1 -1
  362. package/build/dist/chunks/IBL6TL2Q.js +1 -0
  363. package/build/dist/chunks/{3DNJTJ2X.js → IJ4HZIDG.js} +1 -1
  364. package/build/dist/chunks/{OARVU3RC.js → IPU656WB.js} +1 -1
  365. package/build/dist/chunks/{HCBX4NFM.js → IT2JLILU.js} +1 -1
  366. package/build/dist/chunks/{REWXG6X6.js → JDSSYT6R.js} +1 -1
  367. package/build/dist/chunks/{XRDXFHIK.js → JFWJBZ7M.js} +1 -1
  368. package/build/dist/chunks/{TPEKCXVE.js → JTPHZCO3.js} +1 -1
  369. package/build/dist/chunks/{CSOO4SW7.js → K4GUZ5QS.js} +1 -1
  370. package/build/dist/chunks/{BAIY32AV.js → KLEJ3W4T.js} +1 -1
  371. package/build/dist/chunks/{ACH4BSME.js → KOKLM63Q.js} +1 -1
  372. package/build/dist/chunks/{7D73A6KS.js → KVVBT43U.js} +1 -1
  373. package/build/dist/chunks/{CO4GCF4L.js → KXX7ZBFY.js} +1 -1
  374. package/build/dist/chunks/{I6PQW2JI.js → L2AE32SL.js} +1 -1
  375. package/build/dist/chunks/{WUT7TZYM.js → LCH6F5HT.js} +1 -1
  376. package/build/dist/chunks/LEV5SNNC.js +3 -0
  377. package/build/dist/chunks/{SPRVVJXI.js → LFSJDFMY.js} +1 -1
  378. package/build/dist/chunks/{6UVGQYZ3.js → LGLWEGPY.js} +1 -1
  379. package/build/dist/chunks/{PV4AK32X.js → LQSPWRHN.js} +1 -1
  380. package/build/dist/chunks/{C3WBHFLX.js → LTDF2LNP.js} +1 -1
  381. package/build/dist/chunks/{5HIHUYA4.js → M4AGEGWW.js} +1 -1
  382. package/build/dist/chunks/{ARI72OYT.js → M6SQPOOL.js} +1 -1
  383. package/build/dist/chunks/{SOTYQGPT.js → M7CQPTRK.js} +1 -1
  384. package/build/dist/chunks/{XPEDQBLI.js → MGVX5EUH.js} +1 -1
  385. package/build/dist/chunks/{C5ZZAYXD.js → MI5HZDMH.js} +1 -1
  386. package/build/dist/chunks/{APHNOGNS.js → MQ37QX6U.js} +1 -1
  387. package/build/dist/chunks/MQ5F2VOK.js +1 -0
  388. package/build/dist/chunks/{JKD2B6OX.js → MSRCJ2BS.js} +1 -1
  389. package/build/dist/chunks/{JKRBGAX2.js → NAO7VWZF.js} +1 -1
  390. package/build/dist/chunks/{RLMVA575.js → NDSNE6PS.js} +1 -1
  391. package/build/dist/chunks/{RT7IU6TI.js → NMJVQX5M.js} +1 -1
  392. package/build/dist/chunks/NQ4MTIU3.js +1 -0
  393. package/build/dist/chunks/{IEG6GLFR.js → NTUXDIY6.js} +1 -1
  394. package/build/dist/chunks/{F4UQEPJT.js → NUERUFH7.js} +1 -1
  395. package/build/dist/chunks/NV6FDIYT.js +1 -0
  396. package/build/dist/chunks/O2J5I4VA.js +1 -0
  397. package/build/dist/chunks/{XVJ7ILKK.js → O3CC5SRM.js} +1 -1
  398. package/build/dist/chunks/{2SUHQWND.js → O4S6XAYV.js} +1 -1
  399. package/build/dist/chunks/{TAEZTP4L.js → O5QTITN6.js} +1 -1
  400. package/build/dist/chunks/{NA424YAL.js → OB7BFDOV.js} +1 -1
  401. package/build/dist/chunks/{523ZIR3J.js → ODV3XT5U.js} +1 -1
  402. package/build/dist/chunks/{GW5IXLKU.js → OI3N4EW4.js} +1 -1
  403. package/build/dist/chunks/{FL5SSHUL.js → OIQTZOBN.js} +1 -1
  404. package/build/dist/chunks/OLDQV43V.js +1 -0
  405. package/build/dist/chunks/OOPMZIG7.js +1 -0
  406. package/build/dist/chunks/{XYPGLG6A.js → OSMOBKRQ.js} +1 -1
  407. package/build/dist/chunks/{OZ5MDUD2.js → OVM4QIET.js} +1 -1
  408. package/build/dist/chunks/{N4XNNXOJ.js → OY5W7ZSL.js} +1 -1
  409. package/build/dist/chunks/{GRSXWQWD.js → PDGYM2WG.js} +1 -1
  410. package/build/dist/chunks/{UQEEF5W5.js → PDPTJMTJ.js} +1 -1
  411. package/build/dist/chunks/PEHXHQVA.js +1 -0
  412. package/build/dist/chunks/{JOKL5L6X.js → PKYQ3XVA.js} +1 -1
  413. package/build/dist/chunks/PMFR47H3.js +1 -0
  414. package/build/dist/chunks/{N6GIC7HJ.js → PWJVC2FV.js} +1 -1
  415. package/build/dist/chunks/{753HZZTY.js → QBYV7NXH.js} +1 -1
  416. package/build/dist/chunks/QHV5GORV.js +1 -0
  417. package/build/dist/chunks/{2LWBN35N.js → QIB6OMQV.js} +1 -1
  418. package/build/dist/chunks/{TK55VASJ.js → QMNUB2GM.js} +1 -1
  419. package/build/dist/chunks/{HKVQ646Q.js → QN45T4N3.js} +1 -1
  420. package/build/dist/chunks/{J73ATSEQ.js → QPY6UTLU.js} +1 -1
  421. package/build/dist/chunks/{YUHNPUNK.js → R73R4KN3.js} +1 -1
  422. package/build/dist/chunks/{RLI4JDOL.js → RA7DOR7F.js} +1 -1
  423. package/build/dist/chunks/{VR344DAZ.js → RN3WUJIO.js} +1 -1
  424. package/build/dist/chunks/RUSXMQSJ.js +1 -0
  425. package/build/dist/chunks/{D742AYEV.js → RUTSEGGD.js} +1 -1
  426. package/build/dist/chunks/{4Q2ZBZXM.js → RXP7ZUPY.js} +1 -1
  427. package/build/dist/chunks/{TFDPEAVZ.js → S4JUFCT4.js} +1 -1
  428. package/build/dist/chunks/{DYYEA5HB.js → SMKO7GKX.js} +1 -1
  429. package/build/dist/chunks/{C75MT5SD.js → SNCV6HV7.js} +1 -1
  430. package/build/dist/chunks/{HIX5N25Z.js → SOJHYMD7.js} +1 -1
  431. package/build/dist/chunks/{JLRHM2DQ.js → SUNTJ6IU.js} +1 -1
  432. package/build/dist/chunks/{4JRXEN7C.js → THL4TMQW.js} +2 -2
  433. package/build/dist/chunks/TI727O2H.js +1 -0
  434. package/build/dist/chunks/{PV5FDT6O.js → TXGZ6NWN.js} +1 -1
  435. package/build/dist/chunks/{Q2ACLVWR.js → UBI3HBXD.js} +1 -1
  436. package/build/dist/chunks/{YMV5TL5C.js → UEHN2IDF.js} +1 -1
  437. package/build/dist/chunks/{ZF2VPDRQ.js → UHIJMDD2.js} +1 -1
  438. package/build/dist/chunks/UJQYOTO5.js +1 -0
  439. package/build/dist/chunks/{VTPT5544.js → USEF3QKG.js} +1 -1
  440. package/build/dist/chunks/{LR4XTZ37.js → UYULQHZJ.js} +1 -1
  441. package/build/dist/chunks/{YWZQJJYY.js → V4UJMUIB.js} +1 -1
  442. package/build/dist/chunks/{7VC53B5X.js → V5YSJKRH.js} +13 -13
  443. package/build/dist/chunks/{INOYMBWE.js → VC5ZCQYZ.js} +1 -1
  444. package/build/dist/chunks/{M7ZXDLKM.js → VDJPDIBV.js} +1 -1
  445. package/build/dist/chunks/{2FHELZ7Y.js → VFM2BICB.js} +1 -1
  446. package/build/dist/chunks/{TE6D3OIX.js → VOJULRNU.js} +1 -1
  447. package/build/dist/chunks/{UEDGYZOC.js → VVAM3EAK.js} +1 -1
  448. package/build/dist/chunks/VVJO6OYK.js +1 -0
  449. package/build/dist/chunks/{JESMX2UC.js → VXCGMALF.js} +1 -1
  450. package/build/dist/chunks/{NUFZUKYS.js → W32UECOL.js} +1 -1
  451. package/build/dist/chunks/{UUID2E22.js → W3DGFMQE.js} +1 -1
  452. package/build/dist/chunks/W7OCS4AM.js +6 -0
  453. package/build/dist/chunks/{DNNFKDZR.js → W7QNSNOH.js} +1 -1
  454. package/build/dist/chunks/{2MZXTOZU.js → WAKZWSHB.js} +1 -1
  455. package/build/dist/chunks/{HM72DH4V.js → WRUTW6CG.js} +1 -1
  456. package/build/dist/chunks/{VYYSL557.js → WSILNJS2.js} +1 -1
  457. package/build/dist/chunks/{L646YWDP.js → X24YTJST.js} +1 -1
  458. package/build/dist/chunks/{FOD34G2H.js → XL3W7DAQ.js} +1 -1
  459. package/build/dist/chunks/{2E4I7CJ7.js → XRDLMTBJ.js} +1 -1
  460. package/build/dist/chunks/{GG24LO2R.js → XVOW6UCI.js} +1 -1
  461. package/build/dist/chunks/XW3VGWXK.js +1 -0
  462. package/build/dist/chunks/{6WD4HHID.js → Y2QADJOB.js} +1 -1
  463. package/build/dist/chunks/Y64GFBTA.js +1 -0
  464. package/build/dist/chunks/Y7HBFQYG.js +1 -0
  465. package/build/dist/chunks/{ARLGF5MU.js → YGW4ODAP.js} +1 -1
  466. package/build/dist/chunks/YRSAZTTC.js +7 -0
  467. package/build/dist/chunks/YW4W3LPQ.js +1 -0
  468. package/build/dist/chunks/{3VBIRLU3.js → YXXK6EPI.js} +1 -1
  469. package/build/dist/chunks/{EH5G4O3U.js → Z2QV6EZY.js} +1 -1
  470. package/build/dist/chunks/Z3IBPCY4.js +2 -0
  471. package/build/dist/chunks/{H5DY7CNB.js → Z7FGEWO2.js} +1 -1
  472. package/build/dist/chunks/{KDGSYNOP.js → ZDCCFEVL.js} +1 -1
  473. package/build/dist/chunks/{4RQAOOO2.js → ZOLHVZDK.js} +1 -1
  474. package/build/dist/chunks/{AI3VAPA3.js → ZSVAGOF2.js} +1 -1
  475. package/build/dist/chunks/{EVBHQQQG.js → ZTKT3ZQK.js} +1 -1
  476. package/build/dist/chunks/{4BVP652W.js → ZZ6FZGHF.js} +1 -1
  477. package/package.json +1 -1
  478. package/build/dist/chunks/3K2N5VFH.js +0 -1
  479. package/build/dist/chunks/3ZABD6ZF.js +0 -2
  480. package/build/dist/chunks/44MB6SA6.js +0 -1
  481. package/build/dist/chunks/4D4ZRZUW.js +0 -1
  482. package/build/dist/chunks/4OVIMYNH.js +0 -2
  483. package/build/dist/chunks/6NUNCD5J.js +0 -1
  484. package/build/dist/chunks/6PZGDVHV.js +0 -1
  485. package/build/dist/chunks/7MBVTNLU.js +0 -1
  486. package/build/dist/chunks/7VNO46LV.js +0 -1
  487. package/build/dist/chunks/CAWTAR5V.js +0 -1
  488. package/build/dist/chunks/DPE7SPW7.js +0 -1
  489. package/build/dist/chunks/E3RACZUY.js +0 -1
  490. package/build/dist/chunks/EI6GGPDS.js +0 -20
  491. package/build/dist/chunks/FV4WZOTD.js +0 -1
  492. package/build/dist/chunks/FWD4L3CJ.js +0 -1
  493. package/build/dist/chunks/JBTOZ6IH.js +0 -1
  494. package/build/dist/chunks/KREBNL2D.js +0 -1
  495. package/build/dist/chunks/MVD3KWPP.js +0 -1
  496. package/build/dist/chunks/P6OMKZMR.js +0 -3
  497. package/build/dist/chunks/PXVREXCS.js +0 -1
  498. package/build/dist/chunks/QJNLLI6N.js +0 -1
  499. package/build/dist/chunks/RPB46QAC.js +0 -1
  500. package/build/dist/chunks/TID4C2KC.js +0 -1
  501. package/build/dist/chunks/U2YCQWZK.js +0 -1
  502. package/build/dist/chunks/UWBKAWX3.js +0 -7
  503. package/build/dist/chunks/V6SDKPZS.js +0 -1
  504. package/build/dist/chunks/WHTRPRRD.js +0 -1
  505. package/build/dist/chunks/WLMWWEP7.js +0 -2
  506. package/build/dist/chunks/XQ24RSEI.js +0 -1
  507. package/build/dist/chunks/YDNTY67T.js +0 -1
  508. package/build/dist/chunks/ZQAFFWDK.js +0 -1
@@ -1 +1 @@
1
- import{b as Z,c as z,d as J,e as K}from"./M7ZXDLKM.js";import{a as W}from"./DSTMEY5F.js";import{a as H}from"./FV4WZOTD.js";import{a as V}from"./OARVU3RC.js";import{a as L}from"./A3PN3PK3.js";import{c as j}from"./L646YWDP.js";import{b as T,o as q}from"./CAWTAR5V.js";import{b as _}from"./SPJCSEKP.js";import{a as A,d as I,e as B}from"./43LI5NKJ.js";import{a as $}from"./66F5ZH34.js";import{g as x,m as E,n as R}from"./NWNYJ26T.js";import{a as h,d as F,i as N,j as S}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{getAddress as O,parseAbi as te}from"viem";var n=O(N[4663].vaults.groveAlm.address),ne="0x29626c2d8ca49a51e4deceec5499e52983c42bd5",m=te(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)","function maxDeposit(address) view returns (uint256)","function maxWithdraw(address) view returns (uint256)","function previewDeposit(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)"]),C=$("Positive integer in token base units."),U={type:"string",description:`Public Grove vault only: ${n}. Defaults to this vault.`},Q={type:"integer",minimum:0,maximum:9999,default:T,description:`Allowed slippage in basis points (50 = 0.5%), 0 to 9999. Sets the minimum output unless you pass it explicitly. Defaults to ${T}.`};function D(t){return R(t,"Amount must be positive and within the uint256 range.",{notString:"Amount must be a positive integer string in base units.",positive:!0})}function v(t){return E(t,"Grove returned an invalid integer read.")}function M(t,d,l){if(A(d),Object.keys(t).some(u=>!["vault",...l].includes(u)))throw new o("Unsupported Grove argument.");if(t.vault!==void 0){if(typeof t.vault!="string")throw new o("Provide the public Grove vault address.");if(t.vault.toLowerCase()===ne)throw new o("The Grove ALM proxy is allocator infrastructure, not the public ERC-4626 vault.");if(A(t.vault),!x(t.vault,n))throw new o("Only the public Grove ERC-4626 vault is supported.")}}function X(t,d,l){let u=l===void 0?T:l;if(typeof u!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");let e=BigInt(q(t.toString(),u)),a=d===void 0?e:D(d);if(a<=0n||a>t)throw new o("The minimum output must be positive and no greater than the quoted output.");return a}function Y(t,d){let l=0n;for(let u of t.changes)if(!(u.token.chainId!==d.chainId||!x(u.token.address,d.address))){if(u.token.decimals!==d.decimals||typeof u.amount!="string"||!/^-?\d+$/.test(u.amount))throw new o("Grove preview returned invalid token metadata or amounts.");l+=BigInt(u.amount)}return l}var ae=t=>{async function d(e){try{return await e()}catch(a){throw new o(t.plainError(a))}}async function l(){let e=t.clientFor(h);if(await e.getChainId()!==h)throw new o("Grove requires an RPC endpoint on chain 4663.");let a=await e.readContract({address:n,abi:m,functionName:"asset"});if(typeof a!="string"||!x(a,S))throw new o("The public Grove vault must use canonical USDG on chain 4663.");let[i,r,s]=await Promise.all([e.readContract({address:O(S),abi:m,functionName:"decimals"}),e.readContract({address:n,abi:m,functionName:"decimals"}),L(e,n)]);if(i!==F||r!==18)throw new o("Grove token decimals differ from the evidenced USDG/share interface.");let p={address:O(S),chainId:h,decimals:i,symbol:"USDG"};return{client:e,asset:p,shareToken:{address:n,chainId:h,decimals:r,symbol:s}}}async function u(e,a,i,r,s,p){let f=await t.preview(e,a);if(Y(f,i)!==-r)throw new o("Grove simulation did not show the exact requested token outflow.");if(Y(f,s)<p)throw new o("Grove simulated output is below the minimum.");let g=f.changes.map(({token:w,amount:b})=>{let y=b.startsWith("-");return`${y?"-":"+"}${t.formatAmount(y?b.slice(1):b,w.decimals)} ${w.symbol} (${w.address}, chain ${w.chainId})`}).join("; ");return{txs:e,summary:`${f.summary} ${g}. Minimum ${p} base units of ${s.address} is a preview check, not enforced on-chain by standard ERC-4626. Re-preview before signing; execution output can change.`}}return{tools:[z(t,"grove_details",n),V(t,"grove_analytics",n),H(t,"grove_manage",n),...W(t,"grove",n),{name:"grove_list",inputSchema:{type:"object",properties:{vault:U},additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,[]);let{client:i,asset:r,shareToken:s}=await l(),[p,f,c,g,w,b]=await Promise.all([i.readContract({address:n,abi:m,functionName:"totalAssets"}),i.readContract({address:n,abi:m,functionName:"totalSupply"}),i.readContract({address:n,abi:m,functionName:"maxDeposit",args:[a]}),i.readContract({address:n,abi:m,functionName:"maxWithdraw",args:[a]}),i.readContract({address:n,abi:m,functionName:"performanceFee"}),i.readContract({address:n,abi:m,functionName:"managementFee"})]);return[{vault:n,chainId:h,name:"Grove x Steakhouse USDG",asset:r,shareToken:s,totalAssets:{token:r,amount:v(p).toString()},totalSupply:{token:s,amount:v(f).toString()},maxDeposit:v(c)===0n?null:c.toString(),maxWithdraw:v(g)===0n?null:g.toString(),maxViewCaveat:"Zero Morpho V2 maximum views mean unknown capacity. Simulate the requested action; full exits use the fresh share balance.",fees:{performanceFeeRaw:v(w).toString(),managementFeeRaw:v(b).toString(),scale:"1000000000000000000",managementFeeTimeUnit:"second",performanceFeeBasis:"accrued interest"}}]})},{name:"grove_deposit",inputSchema:{type:"object",description:"Deposit USDG in base units (1 USDG = 1000000) for 18-decimal vault shares. Exit with grove_withdraw; check positions after confirmation.",properties:{vault:U,amount:C,minSharesOut:C,slippageBps:Q},required:["amount"],additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,["amount","minSharesOut","slippageBps"]);let i=D(e.amount),{client:r,asset:s,shareToken:p}=await l(),f=v(await r.readContract({address:n,abi:m,functionName:"previewDeposit",args:[i]})),c=X(f,e.minSharesOut,e.slippageBps),g=I(n,s.address,i.toString(),a,h),w=[t.approval(s.address,n,i.toString(),h),t.unsignedTx(g.txs[1])];return u(w,a,s,i,p,c)})},{name:"grove_withdraw",inputSchema:{type:"object",description:"Redeem shares in 18-decimal base units, or shares all for a full exit to USDG. Check positions after confirmation.",properties:{vault:U,shares:{oneOf:[C,{const:"all",description:"Redeem the fresh full share balance."}],description:'Vault shares to redeem, in base units (shares have 18 decimals; "1000000000000000000" = 1 share), or "all" for the full balance.'},minAmountOut:C,slippageBps:Q,force:{type:"boolean",description:'True plans a full Morpho V2 force exit with penalty disclosure. Needs shares "all", minAmountOut and maxPenaltyAssets.'},maxPenaltyAssets:$('Force exit only: most USDG, in base units (6 decimals), you accept losing to the exit penalty. Example: "1000000" = 1 USDG.')},required:["shares"],additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,["shares","minAmountOut","slippageBps","force","maxPenaltyAssets"]);let i=e.shares==="all"?void 0:D(e.shares),{client:r,asset:s,shareToken:p}=await l(),f=v(await r.readContract({address:n,abi:m,functionName:"balanceOf",args:[a]})),c=i??f;if(c===0n||c>f)throw new o("The Grove share balance is insufficient for this withdrawal.");if(e.force!==void 0&&typeof e.force!="boolean")throw new o("force must be a boolean.");if(e.force===!0){if(e.shares!=="all"||e.slippageBps!==void 0)throw new o("Force exit requires shares all and an explicit minAmountOut; omit slippageBps.");let G=j(e.maxPenaltyAssets),ee=D(e.minAmountOut),k=await Z(t,r,n,a,c,G),P=await t.preview([k.tx],a);return K(P.changes,n,c,ee),{txs:[k.tx],preview:P,summary:`${J(k.plan)} ${P.summary}`}}if(e.maxPenaltyAssets!==void 0)throw new o("maxPenaltyAssets requires force true.");let g=v(await r.readContract({address:n,abi:m,functionName:"previewRedeem",args:[c]})),w=X(g,e.minAmountOut,e.slippageBps),y=B(n,c.toString(),a,h).txs.map(G=>t.unsignedTx({...G,description:`Redeem ${c} Grove share base units to the wallet.`}));return u(y,a,p,c,s,w)})}],positions:e=>d(async()=>{A(e);let{client:a,asset:i,shareToken:r}=await l(),s=v(await a.readContract({address:n,abi:m,functionName:"balanceOf",args:[e]}));if(s===0n)return[];let p=v(await a.readContract({address:n,abi:m,functionName:"previewRedeem",args:[s]}));return[{module:"grove",id:`${h}:${n.toLowerCase()}`,chainId:h,assets:[{token:i,amount:p.toString()}],description:`${t.formatAmount(s.toString(),r.decimals)} Grove shares (${s} base units, ${r.decimals} decimals, ${n}); estimated USDG redemption, subject to simulation.`}]})}},we=t=>_("grove",[ae(t)]);export{ae as a,we as b};
1
+ import{a as W}from"./6F527FLN.js";import{a as H}from"./BJK75C7G.js";import{b as Z,c as z,d as J,e as K}from"./VDJPDIBV.js";import{a as V}from"./IPU656WB.js";import{a as L}from"./A3PN3PK3.js";import{c as j}from"./X24YTJST.js";import{b as T,o as q}from"./GYPMUYB5.js";import{b as _}from"./SPJCSEKP.js";import{a as A,d as I,e as B}from"./43LI5NKJ.js";import{a as $}from"./66F5ZH34.js";import{g as x,m as E,n as R}from"./NWNYJ26T.js";import{b as h,e as F,j as N,k as S}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{getAddress as O,parseAbi as te}from"viem";var n=O(N[4663].vaults.groveAlm.address),ne="0x29626c2d8ca49a51e4deceec5499e52983c42bd5",m=te(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)","function maxDeposit(address) view returns (uint256)","function maxWithdraw(address) view returns (uint256)","function previewDeposit(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)"]),C=$("Positive integer in token base units."),U={type:"string",description:`Public Grove vault only: ${n}. Defaults to this vault.`},Q={type:"integer",minimum:0,maximum:9999,default:T,description:`Allowed slippage in basis points (50 = 0.5%), 0 to 9999. Sets the minimum output unless you pass it explicitly. Defaults to ${T}.`};function D(t){return R(t,"Amount must be positive and within the uint256 range.",{notString:"Amount must be a positive integer string in base units.",positive:!0})}function v(t){return E(t,"Grove returned an invalid integer read.")}function M(t,d,l){if(A(d),Object.keys(t).some(u=>!["vault",...l].includes(u)))throw new o("Unsupported Grove argument.");if(t.vault!==void 0){if(typeof t.vault!="string")throw new o("Provide the public Grove vault address.");if(t.vault.toLowerCase()===ne)throw new o("The Grove ALM proxy is allocator infrastructure, not the public ERC-4626 vault.");if(A(t.vault),!x(t.vault,n))throw new o("Only the public Grove ERC-4626 vault is supported.")}}function X(t,d,l){let u=l===void 0?T:l;if(typeof u!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");let e=BigInt(q(t.toString(),u)),a=d===void 0?e:D(d);if(a<=0n||a>t)throw new o("The minimum output must be positive and no greater than the quoted output.");return a}function Y(t,d){let l=0n;for(let u of t.changes)if(!(u.token.chainId!==d.chainId||!x(u.token.address,d.address))){if(u.token.decimals!==d.decimals||typeof u.amount!="string"||!/^-?\d+$/.test(u.amount))throw new o("Grove preview returned invalid token metadata or amounts.");l+=BigInt(u.amount)}return l}var ae=t=>{async function d(e){try{return await e()}catch(a){throw new o(t.plainError(a))}}async function l(){let e=t.clientFor(h);if(await e.getChainId()!==h)throw new o("Grove requires an RPC endpoint on chain 4663.");let a=await e.readContract({address:n,abi:m,functionName:"asset"});if(typeof a!="string"||!x(a,S))throw new o("The public Grove vault must use canonical USDG on chain 4663.");let[i,r,s]=await Promise.all([e.readContract({address:O(S),abi:m,functionName:"decimals"}),e.readContract({address:n,abi:m,functionName:"decimals"}),L(e,n)]);if(i!==F||r!==18)throw new o("Grove token decimals differ from the evidenced USDG/share interface.");let p={address:O(S),chainId:h,decimals:i,symbol:"USDG"};return{client:e,asset:p,shareToken:{address:n,chainId:h,decimals:r,symbol:s}}}async function u(e,a,i,r,s,p){let f=await t.preview(e,a);if(Y(f,i)!==-r)throw new o("Grove simulation did not show the exact requested token outflow.");if(Y(f,s)<p)throw new o("Grove simulated output is below the minimum.");let g=f.changes.map(({token:w,amount:b})=>{let y=b.startsWith("-");return`${y?"-":"+"}${t.formatAmount(y?b.slice(1):b,w.decimals)} ${w.symbol} (${w.address}, chain ${w.chainId})`}).join("; ");return{txs:e,summary:`${f.summary} ${g}. Minimum ${p} base units of ${s.address} is a preview check, not enforced on-chain by standard ERC-4626. Re-preview before signing; execution output can change.`}}return{tools:[z(t,"grove_details",n),V(t,"grove_analytics",n),H(t,"grove_manage",n),...W(t,"grove",n),{name:"grove_list",inputSchema:{type:"object",properties:{vault:U},additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,[]);let{client:i,asset:r,shareToken:s}=await l(),[p,f,c,g,w,b]=await Promise.all([i.readContract({address:n,abi:m,functionName:"totalAssets"}),i.readContract({address:n,abi:m,functionName:"totalSupply"}),i.readContract({address:n,abi:m,functionName:"maxDeposit",args:[a]}),i.readContract({address:n,abi:m,functionName:"maxWithdraw",args:[a]}),i.readContract({address:n,abi:m,functionName:"performanceFee"}),i.readContract({address:n,abi:m,functionName:"managementFee"})]);return[{vault:n,chainId:h,name:"Grove x Steakhouse USDG",asset:r,shareToken:s,totalAssets:{token:r,amount:v(p).toString()},totalSupply:{token:s,amount:v(f).toString()},maxDeposit:v(c)===0n?null:c.toString(),maxWithdraw:v(g)===0n?null:g.toString(),maxViewCaveat:"Zero Morpho V2 maximum views mean unknown capacity. Simulate the requested action; full exits use the fresh share balance.",fees:{performanceFeeRaw:v(w).toString(),managementFeeRaw:v(b).toString(),scale:"1000000000000000000",managementFeeTimeUnit:"second",performanceFeeBasis:"accrued interest"}}]})},{name:"grove_deposit",inputSchema:{type:"object",description:"Deposit USDG in base units (1 USDG = 1000000) for 18-decimal vault shares. Exit with grove_withdraw; check positions after confirmation.",properties:{vault:U,amount:C,minSharesOut:C,slippageBps:Q},required:["amount"],additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,["amount","minSharesOut","slippageBps"]);let i=D(e.amount),{client:r,asset:s,shareToken:p}=await l(),f=v(await r.readContract({address:n,abi:m,functionName:"previewDeposit",args:[i]})),c=X(f,e.minSharesOut,e.slippageBps),g=I(n,s.address,i.toString(),a,h),w=[t.approval(s.address,n,i.toString(),h),t.unsignedTx(g.txs[1])];return u(w,a,s,i,p,c)})},{name:"grove_withdraw",inputSchema:{type:"object",description:"Redeem shares in 18-decimal base units, or shares all for a full exit to USDG. Check positions after confirmation.",properties:{vault:U,shares:{oneOf:[C,{const:"all",description:"Redeem the fresh full share balance."}],description:'Vault shares to redeem, in base units (shares have 18 decimals; "1000000000000000000" = 1 share), or "all" for the full balance.'},minAmountOut:C,slippageBps:Q,force:{type:"boolean",description:'True plans a full Morpho V2 force exit with penalty disclosure. Needs shares "all", minAmountOut and maxPenaltyAssets.'},maxPenaltyAssets:$('Force exit only: most USDG, in base units (6 decimals), you accept losing to the exit penalty. Example: "1000000" = 1 USDG.')},required:["shares"],additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,["shares","minAmountOut","slippageBps","force","maxPenaltyAssets"]);let i=e.shares==="all"?void 0:D(e.shares),{client:r,asset:s,shareToken:p}=await l(),f=v(await r.readContract({address:n,abi:m,functionName:"balanceOf",args:[a]})),c=i??f;if(c===0n||c>f)throw new o("The Grove share balance is insufficient for this withdrawal.");if(e.force!==void 0&&typeof e.force!="boolean")throw new o("force must be a boolean.");if(e.force===!0){if(e.shares!=="all"||e.slippageBps!==void 0)throw new o("Force exit requires shares all and an explicit minAmountOut; omit slippageBps.");let G=j(e.maxPenaltyAssets),ee=D(e.minAmountOut),k=await Z(t,r,n,a,c,G),P=await t.preview([k.tx],a);return K(P.changes,n,c,ee),{txs:[k.tx],preview:P,summary:`${J(k.plan)} ${P.summary}`}}if(e.maxPenaltyAssets!==void 0)throw new o("maxPenaltyAssets requires force true.");let g=v(await r.readContract({address:n,abi:m,functionName:"previewRedeem",args:[c]})),w=X(g,e.minAmountOut,e.slippageBps),y=B(n,c.toString(),a,h).txs.map(G=>t.unsignedTx({...G,description:`Redeem ${c} Grove share base units to the wallet.`}));return u(y,a,p,c,s,w)})}],positions:e=>d(async()=>{A(e);let{client:a,asset:i,shareToken:r}=await l(),s=v(await a.readContract({address:n,abi:m,functionName:"balanceOf",args:[e]}));if(s===0n)return[];let p=v(await a.readContract({address:n,abi:m,functionName:"previewRedeem",args:[s]}));return[{module:"grove",id:`${h}:${n.toLowerCase()}`,chainId:h,assets:[{token:i,amount:p.toString()}],description:`${t.formatAmount(s.toString(),r.decimals)} Grove shares (${s} base units, ${r.decimals} decimals, ${n}); estimated USDG redemption, subject to simulation.`}]})}},we=t=>_("grove",[ae(t)]);export{ae as a,we as b};
@@ -1,4 +1,4 @@
1
- import{a as ae}from"./3CCBUYUM.js";import{a as xt,d as It,e as Tt}from"./EVBHQQQG.js";import{a as Re}from"./7MR37STI.js";import{a as Ze,b as Ge,d as At}from"./L646YWDP.js";import{h as Je,i as St}from"./2GXHYI23.js";import{b as kt,c as yt,d as gt}from"./DNNFKDZR.js";import{d as wt,e as te}from"./CAWTAR5V.js";import{a as ht}from"./H5DY7CNB.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 Oe,g as R,i as Ee}from"./NWNYJ26T.js";import{b as Le}from"./IX3GZMTM.js";import{k as ft}from"./6NUNCD5J.js";import{a as f,i as z}from"./FWD4L3CJ.js";import{a as i,e as ie}from"./XSD5NL7J.js";import{a as Ye}from"./JXOEJPJ4.js";import{encodeFunctionData as be,erc20Abi as Qa,getAddress as aa,parseAbi as pt,zeroAddress as Xa}from"viem";import{decodeAbiParameters as ca,encodeFunctionData as ua,getAddress as le,parseAbiParameters as ma,zeroAddress as he,zeroHash as Dt}from"viem";import{decodeAbiParameters as ra,encodeFunctionData as na,erc20Abi as sa,getAddress as Ct,parseAbi as ia,parseAbiParameters as la,zeroHash as Mt}from"viem";var et=Ct("0xCE29862924756584BBD0D75CA1249d22007E2813"),Lt="(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)",da="(uint256 value,uint256 nonce,uint256 deadline,uint8 v,bytes32 r,bytes32 s)",vt=ia(["function BLUE() view returns (address)",`function vaultExitBundlesV1InKindRedemptionVaultV2(address vault,address adapter,${Lt}[] marketParamsList,uint256 exitAssets,${da} sharesPermit,uint256 deadline)`]);function N(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 io(e,t,s,r,n){q(n);let l=N(r.amount),a=N(r.maxShares),o=N(r.maxPenaltyAssets,!0),u=N(r.deadline),c=e.clientFor(f),m=await At(c,t,s),d=(S,B,Ce,ee=[])=>c.readContract({address:S,abi:B,functionName:Ce,args:ee,blockNumber:m.blockNumber}),[p,b,h,w]=await Promise.all([c.getBlock({blockNumber:m.blockNumber}),d(et,vt,"BLUE"),d(t,sa,"balanceOf",[n]),d(t,Ze,"previewRedeem",[a])]);if(typeof b!="string"||Ct(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(a>Ge(h))throw new i("maxShares exceeds the wallet share balance.");let y=Pt(m.idle,l),k=m.markets.filter(S=>S.supplied>0n&&j(S.id)),g=l-y,T=k[0]?.penalty??0n,x=g*10n**18n/(10n**18n+T);if(g>0n&&x===0n)throw new i("The penalty-adjusted in-kind amount rounds to zero.");let M=[];for(let S of k){if(x===0n)break;let B=Pt(S.supplied,x);M.push({marketId:S.id,assets:B,penalty:(B*S.penalty+10n**18n-1n)/10n**18n}),x-=B}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(M.length)>Ge(w))throw new i("maxShares cannot cover the exit and per-market rounding buffer.");if(M.some(S=>S.assets>m.blueCash))throw new i("Morpho Blue cannot fund the largest in-kind callback. Reduce the amount.");let C=M.reduce((S,B)=>S+B.penalty,0n);if(C>o)throw new i("In-kind penalty exceeds maxPenaltyAssets.");let P=[...y?[y]:[],...M.flatMap(S=>[S.assets,S.penalty].filter(B=>B>0n))],E=(await Promise.all(P.map(S=>d(t,Ze,"previewWithdraw",[S])))).reduce((S,B)=>S+Ge(B),0n);if(E===0n||E>a)throw new i("Separately rounded burns exceed maxShares.");let Z=M.map(S=>ra(la(Lt),m.markets.find(B=>B.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 ${E} share base units; receive ${y} ${s.symbol} base units and Morpho Blue supply positions ${M.map(S=>`${S.marketId}: ${S.assets} ${s.symbol} base units`).join(", ")||"none"}. Penalty ${C} ${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.`,v=na({abi:vt,functionName:"vaultExitBundlesV1InKindRedemptionVaultV2",args:[t,H,Z,l,{value:0n,nonce:0n,deadline:0n,v:0,r:Mt,s:Mt},u]}),U=[e.approval(t,et,E.toString(),f),e.unsignedTx({to:et,data:v,value:"0",chainId:f,description:F})],D=await e.preview(U,n),V=-D.changes.filter(S=>S.token.chainId===f&&R(S.token.address,t)).reduce((S,B)=>{if(B.token.decimals!==18||!/^-?\d+$/.test(B.amount))throw new i("Invalid in-kind share preview.");return S+BigInt(B.amount)},0n);if(V<=0n||V>E)throw new i("In-kind preview exceeds the exact share authorization or burns no shares.");return{txs:U,preview:D,summary:F,receipt:{idleAssets:y.toString(),positions:M.map(S=>({marketId:S.marketId,asset:s,assets:S.assets.toString()})),penaltyAssets:C.toString()}}}var we=le("0x53A1eB6589861F686af7c531211E35Aefe30210f"),Ut=["supply","withdraw","supplyCollateralAndBorrow","repayAndWithdrawCollateral","migrateBorrowPosition"],tt={kind:0,data:"0x"},_e={nonce:0n,deadline:0n,signature:{v:0,r:Dt,s:Dt}},pa=ma("(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(v=>!l.includes(v)))throw new i("Unexpected argument for this Blue bundle.");let a=await n.getBlock(),o=N(t.deadline);if(o<a.timestamp||o>a.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:Re,functionName:"BLUE",blockNumber:a.number}),n.readContract({address:we,abi:Re,functionName:"PUBLIC_ALLOCATOR",blockNumber:a.number})]);if(le(u)!==$||le(c)!==xt)throw new i("BlueBundlesV1 deployment does not match Oak\u2019s pinned Blue and Public Allocator.");let m=async v=>{if(typeof v!="string"||!j(v))throw new i("Choose a verified Morpho market with a supported exit.");let U=await n.readContract({address:$,abi:O,functionName:"idToMarketParams",args:[v],blockNumber:a.number}),D={loanToken:le(U[0]),collateralToken:le(U[1]),oracle:le(U[2]),irm:le(U[3]),lltv:U[4]};if(!R(ke({...D,lltv:String(D.lltv)}),v))throw new i("Blue bundle market identity mismatch.");return D},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:$,abi:O,functionName:"isAuthorized",args:[s,we],blockNumber:a.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 b=t.assets===void 0?0n:N(t.assets,!0),h=t.shares===void 0?0n:N(t.shares,!0),w=t.collateralAssets===void 0?0n:N(t.collateralAssets,!0),y=r==="supply"||r==="withdraw"?0n:N(t.maxLtv,!0);if(y>p.lltv)throw new i("maxLtv cannot exceed the verified destination market LLTV.");if(r==="supply"&&b===0n||r==="withdraw"&&b===0n==(h===0n)||r==="supplyCollateralAndBorrow"&&w===0n&&b===0n||r==="repayAndWithdrawCollateral"&&(b>0n&&h>0n||b===0n&&h===0n&&w===0n))throw new i("Choose a nonzero amount; assets and shares are mutually exclusive for repayment/withdrawal.");let k=t.allocations??[];if(!Array.isArray(k)||k.length>4||k.length&&r==="supplyCollateralAndBorrow"&&b===0n)throw new i("Provide at most four explicit allocations, only with a borrow or withdrawal.");let g=new Set,T=[],x=0n;for(let v of k){if(!v||typeof v!="object"||Array.isArray(v)||Object.keys(v).some(Xe=>!["vault","sourceMarketId","assets","maxPenaltyAssets"].includes(Xe)))throw new i("Unsupported bundled allocation input.");let U=v,D=await It(e,{vault:U.vault,marketId:r==="migrateBorrowPosition"?t.destinationMarketId:t.marketId});if(g.has(D.definition.vault.toLowerCase()))throw new i("Use each source vault at most once per bundle.");g.add(D.definition.vault.toLowerCase());let V=N(U.assets),S=N(U.maxPenaltyAssets,!0);if(!D.permission||V>=1n<<128n||V>D.headroom||D.penalty>10n**18n||D.asset.address!==p.loanToken)throw new i("Bundled allocation is disabled, unqualified or exceeds target capacity.");let B=(V*D.penalty+10n**18n-1n)/10n**18n;if(B>S)throw new i("Bundled allocation exceeds maxPenaltyAssets.");x+=B;let Ce=U.sourceMarketId===void 0,ee=Ce?void 0:D.sources.find(Xe=>R(Xe.id,String(U.sourceMarketId)));if(Ce?!D.canIdle||V>D.data.idle:!ee||!ee.canPull||V>ee.capacity||V>D.data.blueCash)throw new i("Bundled allocation source cannot cover the requested amount.");T.push({vault:D.definition.vault,adapter:D.target.adapter,marketParams:D.params,sourceAdapter:ee?.adapter??he,sourceMarketParams:ee?ca(pa,ee.data)[0]:D.params,assets:V,penalty:D.penalty,fromIdle:Ce})}let M,C,P,I=0n;if(r==="supply")M="blueBundlesV1Supply",P=d.loanToken,I=b,C=[d,b,tt,0n,he,o];else if(r==="withdraw")M="blueBundlesV1Withdraw",C=[d,b,h,_e,T,0n,he,o];else if(r==="supplyCollateralAndBorrow"){if(M="blueBundlesV1SupplyCollateralAndBorrow",P=d.collateralToken,I=w,x>=b&&x>0n)throw new i("Allocation penalties would consume the borrow proceeds.");C=[d,w,b,y,tt,_e,T,0n,he,o]}else if(r==="repayAndWithdrawCollateral"){if(M="blueBundlesV1RepayAndWithdrawCollateral",P=d.loanToken,I=N(t.maxRepayAssets,!0),b>I||h>0n&&I===0n)throw new i("Repayment requires a sufficient maxRepayAssets budget.");C=[d,b,h,I,w,y,tt,_e,0n,he,o]}else M="blueBundlesV1MigrateBorrowPosition",C=[d,p,y,_e,T,0n,he,o];let E=`Morpho Blue atomic ${r}: ${JSON.stringify(t)}. Allocation penalties ${x} loan-token base units; zero referral fee. Max LTV ${y}; absolute deadline ${o}. Migration adds allocation penalties to destination debt; borrowing deducts them from proceeds. Exact input approval ${I}. Existing Blue bundle authorization remains until explicitly revoked with morpho_manage. No opaque callback, permit or signature is accepted.`,Z=[...P&&I?[e.approval(P,we,I.toString(),f)]:[],e.unsignedTx({to:we,data:ua({abi:Re,functionName:M,args:C}),value:"0",chainId:f,description:E})],H=await e.preview(Z,s),F=new Map;for(let v of H.changes)if(BigInt(v.amount)<0n){let U=v.token.address.toLowerCase();F.set(U,(F.get(U)??0n)-BigInt(v.amount))}if([...F].some(([v,U])=>!P||v!==P.toLowerCase()||U>I))throw new i("Bundle preview spends outside the exact input budget.");return{txs:Z,preview:H,summary:E}}catch(r){throw new i(e.plainError(r))}}}]});import{concatHex as Bt,decodeAbiParameters as fa,encodeAbiParameters as Rt,encodeFunctionData as at,erc20Abi as Nt,getAddress as K,keccak256 as rt,zeroAddress as ye,zeroHash as ba}from"viem";var Y=K("0x6120765Ba5336150BbdDdD0Cd9108B5bFD369632"),ha=["0x90B800999e4ACd1bD20283BD450bBd2e06D91F7C","0x708d6Bf6F847202a0755bb5636bE663B174242ea"].map(e=>K(e)),nt=ae.find(e=>e.name==="take"),Ot=[nt.inputs[0]],wa=[nt.inputs[0].components[0]];function Et(e){let t=rt(Bt(["0x600b380380600b5f395ff3",Rt(wa,[e])]));return rt(Bt(["0xff",e.midnight,ba,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 ka(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 He(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 ot(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 ya=e=>JSON.parse(JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s)),Ht=e=>{async function t(n,l){let a=He(n,32),o=e.clientFor(f);if(await o.getChainId()!==f)throw new i("Midnight requires chain 4663.");let u=await o.getBlock(),c=(k,g=[])=>o.readContract({address:Y,abi:ae,functionName:k,args:g,blockNumber:u.number}),m=await c("toMarket",[a]);if(m.chainId!==BigInt(f)||K(m.midnight)!==Y||!R(Et(m),a))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(k=>R(k,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,b,h,w]=await Promise.all([c("position",[a,l]),c("updatePositionView",[m,a,l]),c("marketState",[a]),c("isHealthy",[m,a,l])]),y=async k=>{let[g,T]=await Promise.all([o.readContract({address:k,abi:Nt,functionName:"decimals",blockNumber:u.number}),o.readContract({address:k,abi:Nt,functionName:"symbol",blockNumber:u.number})]);if(!Number.isInteger(g)||g>36||typeof T!="string")throw new i("Invalid Midnight token metadata.");return{address:K(k),decimals:g,symbol:T.replace(/[^a-zA-Z0-9.$_-]/g,"").slice(0,32),chainId:f}};return{id:a,rpc:o,block:u,market:m,read:c,token:y,loan:await y(m.loanToken),position:ot(p,6),updated:ot(b,3),state:ot(h,13),healthy:w}}let s=(n,l,a,o)=>({name:n,inputSchema:{type:"object",properties:l,required:a,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 o(u,c)}catch(m){throw new i(e.plainError(m))}}});async function r(n,l,a){return{txs:n,preview:await e.preview(n,l),summary:a}}return{tools:[s("morpho_midnight_status",{marketId:{type:"string",description:"Midnight market id: 0x + 64 hex digits (bytes32)."}},["marketId"],async(n,l)=>{let a=await t(n.marketId,l),o=await Promise.all(a.market.collateralParams.map(async(m,d)=>({token:await a.token(m.token),lltvWad:m.lltv.toString(),oracle:m.oracle,assets:String(await a.read("collateral",[a.id,l,BigInt(d)]))}))),u=["configurator","feeSetter","feeClaimer","tickSpacingSetter"],c=await Promise.all(u.map(m=>a.read(m)));return{protocol:Object.fromEntries(u.map((m,d)=>[m,K(String(c[d]))])),continuousFeePerSecondWad:String(a.state[11]),tickSpacing:String(a.state[12]),settlementFeeCbps:a.state.slice(4,11).map(String),settlementFeeCbpWadScale:"1000000000000",chainId:f,midnight:Y,marketId:a.id,blockNumber:String(a.block.number),market:ya(a.market),loanToken:a.loan,collaterals:o,debtUnits:String(a.position[4]),creditUnits:String(a.updated[0]),pendingFeeUnits:String(a.updated[1]),withdrawableUnits:String(a.state[2]),healthy:a.healthy,maturity:String(a.market.maturity),matured:a.block.timestamp>a.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 a=He(n.offer),[o]=fa(Ot,a);if(!R(Rt(Ot,[o]),a))throw new i("Offer encoding is not canonical.");let u=await t(Et(o.market),l),c=N(n.units),m=N(n.maxAssets,!0),d=N(n.minAssets,!0),p=He(n.ratifierData);if(c>=1n<<128n||R(o.maker,l)||o.callback!==ye||o.callbackData!=="0x"||!ha.includes(K(o.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<o.start||u.block.timestamp>o.expiry||o.expiry<o.start)throw new i("The Midnight offer is not currently live.");if(o.buy&&o.receiverIfMakerIsSeller!==ye||!o.buy&&o.receiverIfMakerIsSeller===ye)throw new i("Invalid offer seller receiver.");if(o.buy&&u.block.timestamp>u.market.maturity&&c>u.updated[0])throw new i("Post-maturity sales cannot increase this wallet\u2019s debt.");let b=await u.read("settlementFee",[u.id,u.market.maturity>u.block.timestamp?u.market.maturity-u.block.timestamp:0n]),h=ka(o.tick);if(b>h&&o.buy)throw new i("Settlement fee exceeds the offer price.");let w=o.buy?h-b:h,y=w+b,k=v=>o.buy?v/de:(v+de-1n)/de,g=k(c*y),T=k(c*w);if(o.buy?T<d||T===0n:g>m||g===0n)throw new i("Midnight proceeds/spend do not fit the requested bounds.");let x=await u.read("consumed",[o.maker,o.group]);if(o.maxAssets===0n==(o.maxUnits===0n)||x+(o.maxAssets?o.buy?g:T:c)>(o.maxAssets||o.maxUnits))throw new i("Midnight offer capacity is exhausted or invalid.");if(u.state[11]>o.continuousFeeCap||o.tick%u.state[12]!==0n)throw new i("Offer fee cap or market tick spacing no longer permits execution.");let M=await u.read("isAuthorized",[o.maker,o.ratifier]),C=[{type:"function",name:"isRatified",stateMutability:"view",inputs:[nt.inputs[0],{type:"bytes"},{type:"address"}],outputs:[{type:"bytes32"}]}],P=await u.rpc.readContract({address:o.ratifier,abi:C,functionName:"isRatified",args:[o,p,l],blockNumber:u.block.number});if(M!==!0||P!==rt(new TextEncoder().encode("morpho.midnight.callbackSuccess")))throw new i("The maker has not authorized and ratified this exact offer.");let I=at({abi:ae,functionName:"take",args:[o,p,c,l,o.buy?l:ye,ye,"0x"]}),E=`Midnight ${o.buy?"sell credit or borrow":"buy credit or reduce debt"}: ${c} fixed debt units; ${o.buy?`receive ${T}`:`spend ${g}`} ${u.loan.symbol} base units (token ${u.loan.address}, decimals ${u.loan.decimals}). Maturity ${u.market.maturity} Unix seconds; offer expiry ${o.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=[...o.buy?[]:[e.approval(u.loan.address,Y,g.toString(),f)],e.unsignedTx({to:Y,data:I,value:"0",chainId:f,description:E})],H=await r(Z,l,E),F=H.preview.changes.filter(v=>v.token.chainId===f&&R(v.token.address,u.loan.address)).reduce((v,U)=>v+BigInt(U.amount),0n);if(o.buy?F<T: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 a=await t(n.marketId,l),o=n.operation;if(!["supplyCollateral","withdrawCollateral","repay","withdraw","updatePosition","claimContinuousFee"].includes(String(o)))throw new i("Choose a finite Midnight position operation.");let u,c,m=a.loan,d=0n;if(o==="updatePosition"){if(n.amount!==void 0||n.collateralIndex!==void 0)throw new i("Position update takes no amount or collateral index.");u=[a.market,l]}else if(o==="claimContinuousFee"){if(d=N(n.amount),n.collateralIndex!==void 0||K(String(await a.read("feeClaimer")))!==K(l))throw new i("This wallet lacks the Midnight fee claimer role or supplied an unused collateral index.");u=[a.market,d,l]}else{if(d=N(n.amount),d>=1n<<128n)throw new i("Midnight position amount exceeds uint128.");if(o==="supplyCollateral"||o==="withdrawCollateral"){if(!Number.isInteger(n.collateralIndex)||Number(n.collateralIndex)<0||Number(n.collateralIndex)>=a.market.collateralParams.length)throw new i("Choose a current collateral index.");let h=BigInt(String(n.collateralIndex)),w=await a.token(a.market.collateralParams[Number(h)].token);if(m=w,o==="withdrawCollateral"&&d>await a.read("collateral",[a.id,l,h]))throw new i("Insufficient Midnight collateral.");u=o==="supplyCollateral"?[a.market,h,d,l]:[a.market,h,d,l,l],o==="supplyCollateral"&&(c=w)}else{if(n.collateralIndex!==void 0)throw new i("This operation takes no collateral index.");if(o==="repay"&&d>a.position[4]||o==="withdraw"&&(d>a.updated[0]||d>a.state[2]))throw new i("Amount exceeds current debt, credit or available repayment liquidity.");u=o==="repay"?[a.market,d,l,ye,"0x"]:[a.market,d,l,l],o==="repay"&&(c=a.loan)}}let p=`Midnight ${o}: ${d} ${m.symbol} base units (token ${m.address}, decimals ${m.decimals}) on ${a.id}; beneficiary ${l}; maturity ${a.market.maturity} Unix seconds. No callbacks or delegation. Withdrawal can fail if collateral health or lender liquidity changes.`,b=[...c?[e.approval(c.address,Y,d.toString(),f)]:[],e.unsignedTx({to:Y,data:at({abi:ae,functionName:String(o),args:u}),value:"0",chainId:f,description:p})];return r(b,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 a={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(a)].includes(n.operation)||!Array.isArray(n.values))throw new i("Choose a finite Midnight management operation and ordered values.");let o=n.operation,u=ae.find(p=>p.name===o);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,b)=>{let h=n.values[b];if(p.type==="bool"){if(typeof h!="boolean")throw new i("Use boolean management values.");return h}if(p.type==="address")return Ee(h,"Use explicit management addresses.",Oe);if(p.type==="bytes32")return He(h,32);if(/^uint/.test(p.type)){let w=N(h,!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(o==="setConsumed"||o==="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:ae,functionName:a[o]});if(typeof p!="string"||K(p)!==K(l))throw new i("This wallet lacks the Midnight configuration, fee or tick role.")}let d=`Midnight ${o}, ordered values ${JSON.stringify(n.values)}. ${o==="setIsAuthorized"&&m[1]?"This grants authority over all Midnight positions, cancellations and further delegation, without an amount cap. Revoke with false when done.":""}${o==="setConsumed"?"Consumption only increases; setting uint128 maximum permanently cancels this offer group.":""}`;return r([e.unsignedTx({to:Y,data:at({abi:ae,functionName:o,args:m}),value:"0",chainId:f,description:d})],l,d)})]}};import{decodeAbiParameters as re,encodeAbiParameters as ga,encodeFunctionData as G,erc20Abi as it,getAddress as L,isAddress as Fe,keccak256 as Sa,parseAbi as Ve,parseAbiParameters as J}from"viem";var De="morpho",Aa="https://api.morpho.org/graphql",$=L(z[f].morpho.morpho_blue.address),xa=L(z[f].morpho.adaptive_curve_irm.address),Ia=L(z[f].morpho.USDG.address),me=L(z[f].morpho.WETH.address),Ta=["0x7c820d6a09502d63be80bb8025ec479d29d7c06e70f8df65a92aaeed23a366e2","0x1fa5293f9f60059a7f6a4923022156fcdcc038bd3749be55897000c03afe92d8"],Ma={"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"}],va=new Map(lt.map(e=>[e.marketId.toLowerCase(),e]));function j(e){return va.get(e.toLowerCase())}function ct(e){let t=j(e);return t?{actions:"enabled",label:t.label,source:Ma[t.source]}:{actions:"read-only",reason:"Not in Oak's verified Morpho market registry; Oak builds no transactions for it."}}var qt=20,Ue=120n,ze=1000000n,We=1n,Se=10n**18n,Pa=10n**36n,jt=(1n<<128n)-1n,Ca=(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)"]),La=Ve(["function price() view returns (uint256)"]),Da=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 $e(e,t){return e===0n?0n:(e+t-1n)/t}function Ua(e,t,s){return e*(s+ze)/(t+We)}function $a(e,t,s){return $e(e*(s+ze),t+We)}function ut(e,t,s){return e*(t+We)/(s+ze)}function se(e,t,s){return $e(e*(t+We),s+ze)}function Ae(e,t,s){return e*t/Pa*s/Se}function Ba(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=Ba(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 a of[e.loanToken,e.collateralToken,e.oracle,e.irm])if(typeof a!="string"||!Fe(a,{strict:!1}))throw new i("Morpho marketParams contains an invalid address.");let t=L(e.loanToken),s=L(e.collateralToken),r=L(e.oracle),n=L(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=ga(J("address, address, address, address, uint256"),[t.loanToken,t.collateralToken,t.oracle,t.irm,t.lltv]);return Sa(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),L(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=L(t),n=r.toLowerCase();if(s===f){if(n===Ia.toLowerCase())return yt;if(n===me.toLowerCase())return gt}let[l,a]=await Promise.all([ne(e,r,G({abi:it,functionName:"symbol"})),ne(e,r,G({abi:it,functionName:"decimals"}))]),[o]=re(J("string"),l),[u]=re(J("uint8"),a);return{address:r,symbol:Xt(o),decimals:Number(u),chainId:s}}async function Yt(e,t){let s=await ne(e,$,G({abi:X,functionName:"idToMarketParams",args:[t]})),[r,n,l,a,o]=re(J("address, address, address, address, uint256"),s);return{loanToken:L(r),collateralToken:L(n),oracle:L(l),irm:L(a),lltv:o}}async function Jt(e,t){let s=await ne(e,$,G({abi:X,functionName:"market",args:[t]})),[r,n,l,a,o,u]=re(J("uint128, uint128, uint128, uint128, uint128, uint128"),s);return{totalSupplyAssets:r,totalSupplyShares:n,totalBorrowAssets:l,totalBorrowShares:a,lastUpdate:o,fee:u}}async function Te(e,t,s){let r=await ne(e,$,G({abi:X,functionName:"position",args:[t,L(s)]})),[n,l,a]=re(J("uint256, uint128, uint128"),r);return{supplyShares:n,borrowShares:l,collateral:a}}async function Ke(e,t){let s=await ne(e,L(t),G({abi:La,functionName:"price"})),[r]=re(J("uint256"),s);return r}async function Na(e,t,s){if(t.irm===te)return 0n;let r=await ne(e,L(t.irm),G({abi:Da,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=$e(n*n,2n*Se),a=$e(l*n,3n*Se);return e.totalBorrowAssets+$e(e.totalBorrowAssets*(n+l+a),Se)}async function Be(e,t,s,r=0n){let[n,l]=await Promise.all([e.getBlock({blockTag:"latest"}),Na(e,t,s)]),a=BigInt(Math.ceil(Date.now()/1e3)),o=(n.timestamp>a?n.timestamp:a)+r;return{totalBorrowAssets:Qe(s,l,o),accruedThrough:o,rate:l}}async function Zt(e,t,s){let r=await ne(e,L(t),G({abi:it,functionName:"balanceOf",args:[L(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,a=l?ke(l):void 0,o=r!==void 0?Qt(r):void 0;if(o&&a&&o!==a.toLowerCase())throw new i(`MarketParams tuple hash (${a}) does not match marketId (${o}).`);let u=(o??a).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 Oa(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=e.clientFor(f),{marketId:a,marketParams:o}=await fe(l,t,!0),u=await Q(l,o.collateralToken,f),c=o.collateralToken.toLowerCase()===me.toLowerCase(),m=typeof t.collateralToken=="string"?(q(t.collateralToken),L(t.collateralToken)):void 0,d=W("wrapNative",t.wrapNative)===!0||m!==void 0&&dt(m);if(m&&!dt(m)&&m.toLowerCase()!==o.collateralToken.toLowerCase())throw new i(`Collateral token ${m} does not match market collateral ${o.collateralToken}.`);if(d&&!c)throw new i("Native ETH wrapping is only supported when market collateralToken is WETH.");let p=Me(t),b=p.toString(),h=e.formatAmount(b,u.decimals),w=[];d&&w.push(e.unsignedTx({chainId:f,to:me,data:G({abi:Kt,functionName:"deposit"}),value:b,description:`Wrap ${h} ETH into WETH at ${me}.`})),w.push(e.approval(o.collateralToken,$,b,f)),w.push(e.unsignedTx({chainId:f,to:$,data:G({abi:X,functionName:"supplyCollateral",args:[o,p,n,"0x"]}),value:"0",description:`Supply ${h} ${u.symbol} (${b} base units) collateral to Morpho market ${a}.`}));let y=await e.preview(w,r),{formattedChanges:k,formattedNetOutflows:g}=xe(e,y);return{action:"morpho_supply_collateral",chainId:f,marketId:a,marketParams:pe(o),collateralToken:u,assets:b,formattedAssets:h,onBehalf:n,txs:w,summary:`${d?`Send ${h} ETH to wrap into WETH. `:""}Supply ${h} ${u.symbol} collateral to Morpho Blue market ${a}.`,preview:y,formattedChanges:k,formattedNetOutflows:g}}async function Ea(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=r,a=e.clientFor(f),{marketId:o,marketParams:u,marketState:c}=await fe(a,t,!0),[m,d,p,b]=await Promise.all([Q(a,u.loanToken,f),Te(a,o,n),Ke(a,u.oracle),Be(a,u,c,Ue)]),h=Me(t),w=h.toString(),y=e.formatAmount(w,m.decimals),k=c.totalSupplyAssets>c.totalBorrowAssets?c.totalSupplyAssets-c.totalBorrowAssets:0n;if(h>k)throw new i(`Insufficient market liquidity: requested ${w} base units, available ${k.toString()} base units.`);let g=Ae(d.collateral,p,u.lltv),T=se(d.borrowShares,b.totalBorrowAssets,c.totalBorrowShares);if(d.collateral===0n||T+h>g)throw new i(`Insufficient collateral or unhealthy borrow: total debt ${(T+h).toString()} exceeds max borrow ${g.toString()} base units.`);let x=$a(h,b.totalBorrowAssets,c.totalBorrowShares),C=[e.unsignedTx({chainId:f,to:$,data:G({abi:X,functionName:"borrow",args:[u,h,0n,n,l]}),value:"0",description:`Borrow ${y} ${m.symbol} (${w} base units) from Morpho market ${o}.`})],P=await e.preview(C,r),{formattedChanges:I,formattedNetOutflows:E}=xe(e,P);return{action:"morpho_borrow",chainId:f,marketId:o,marketParams:pe(u),loanToken:m,assets:w,formattedAssets:y,borrowShares:x.toString(),onBehalf:n,receiver:l,txs:C,summary:`Borrow ${y} ${m.symbol} from Morpho Blue market ${o}.`,preview:P,formattedChanges:I,formattedNetOutflows:E}}async function Ga(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=e.clientFor(f);if(t.shares!==void 0){let I=Le(t.shares);if(I<=0n||I===Ca||I>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:o,marketState:u}=await fe(l,t,!0),[c,m,d]=await Promise.all([Q(l,o.loanToken,f),Te(l,a,n),Zt(l,o.loanToken,r)]);if(m.borrowShares===0n)throw new i(`Position has no active borrow debt on Morpho market ${a}.`);let p=0n,b=0n;if(W("repayAll",t.repayAll)===!0)b=m.borrowShares;else if(t.shares!==void 0){let I=Le(t.shares);if(I>m.borrowShares)throw new i(`Repay shares (${I.toString()}) exceed current position borrowShares (${m.borrowShares.toString()}).`);b=I}else p=Me(t);let h=b>0n?await Be(l,o,u,Ue):void 0,w=b>0n?se(b,h.totalBorrowAssets,u.totalBorrowShares):p;if(d<w)throw new i(`Insufficient loan token balance for repayment: wallet holds ${d.toString()} base units, but ${w.toString()} base units are required (including accrued interest).`);let y=w.toString(),k=e.formatAmount(y,c.decimals),g=e.approval(o.loanToken,$,y,f),T=e.unsignedTx({chainId:f,to:$,data:G({abi:X,functionName:"repay",args:[o,p,b,n,"0x"]}),value:"0",description:b>0n?`Repay ${b.toString()} borrow shares (${k} ${c.symbol}) on Morpho market ${a}.`:`Repay ${k} ${c.symbol} (${p.toString()} base units) on Morpho market ${a}.`}),x=[g,T],M=await e.preview(x,r),{formattedChanges:C,formattedNetOutflows:P}=xe(e,M);return{action:"morpho_repay",chainId:f,marketId:a,marketParams:pe(o),loanToken:c,repayAssets:p.toString(),repayShares:b.toString(),requiredAssets:y,...h?{accruedThrough:h.accruedThrough.toString(),borrowRatePerSecond:h.rate.toString(),inclusionSeconds:Ue.toString()}:{},formattedRequiredAssets:k,onBehalf:n,txs:x,summary:b>0n?`Repay ${b.toString()} borrow shares (approval up to ${k} ${c.symbol}) on Morpho Blue market ${a}. Refresh if signing/inclusion takes more than ${Ue} seconds.`:`Repay ${k} ${c.symbol} on Morpho Blue market ${a}.`,preview:M,formattedChanges:C,formattedNetOutflows:P}}async function Ra(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=r,a=e.clientFor(f),{marketId:o,marketParams:u,marketState:c}=await fe(a,t,!0),[m,d,p,b]=await Promise.all([Q(a,u.collateralToken,f),Te(a,o,n),Ke(a,u.oracle),Be(a,u,c,Ue)]),h=W("withdrawAll",t.withdrawAll)===!0?d.collateral:Me(t);if(h<=0n||h>d.collateral)throw new i(`Insufficient collateral to withdraw: requested ${h.toString()} base units, position holds ${d.collateral.toString()} base units.`);if(d.borrowShares>0n){let C=d.collateral-h,P=Ae(C,p,u.lltv),I=se(d.borrowShares,b.totalBorrowAssets,c.totalBorrowShares);if(I>P)throw new i(`Unhealthy collateral withdrawal: remaining max borrow ${P.toString()} would fall below current debt ${I.toString()} base units.`)}let w=h.toString(),y=e.formatAmount(w,m.decimals),g=[e.unsignedTx({chainId:f,to:$,data:G({abi:X,functionName:"withdrawCollateral",args:[u,h,n,l]}),value:"0",description:`Withdraw ${y} ${m.symbol} (${w} base units) collateral from Morpho market ${o}.`})],T=await e.preview(g,r),{formattedChanges:x,formattedNetOutflows:M}=xe(e,T);return{action:"morpho_withdraw_collateral",chainId:f,marketId:o,marketParams:pe(u),collateralToken:m,assets:w,formattedAssets:y,onBehalf:n,receiver:l,txs:g,summary:`Withdraw ${y} ${m.symbol} collateral from Morpho Blue market ${o}.`,preview:T,formattedChanges:x,formattedNetOutflows:M}}async function _a(e,t,s){let r=Ie(t,s);ve(t,r);let n=e.clientFor(f),{marketId:l,marketParams:a,marketState:o}=await fe(n,t,!0),u=W("wrapNative",t.wrapNative)===!0;if(u&&a.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,a.loanToken,f),u?Promise.resolve(c):Zt(n,a.loanToken,r)]);if(p<c)throw new i(`Insufficient ${d.symbol} balance to lend: wallet holds ${p.toString()} base units, requested ${m}.`);let b=e.formatAmount(m,d.decimals),h=[];u&&h.push(e.unsignedTx({chainId:f,to:me,data:G({abi:Kt,functionName:"deposit"}),value:m,description:`Wrap ${b} ETH into WETH at ${me}.`})),h.push(e.approval(a.loanToken,$,m,f)),h.push(e.unsignedTx({chainId:f,to:$,data:G({abi:X,functionName:"supply",args:[a,c,0n,r,"0x"]}),value:"0",description:`Lend ${b} ${d.symbol} (${m} base units) to Morpho market ${l}.`}));let w=Ua(c,o.totalSupplyAssets,o.totalSupplyShares),y=await e.preview(h,r),{formattedChanges:k,formattedNetOutflows:g}=xe(e,y);return{action:"morpho_supply",chainId:f,marketId:l,marketParams:pe(a),loanToken:d,assets:m,formattedAssets:b,supplySharesEstimated:w.toString(),onBehalf:r,oak:ct(l),txs:h,summary:`${u?`Send ${b} ETH to wrap into WETH. `:""}Lend ${b} ${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:y,formattedChanges:k,formattedNetOutflows:g}}async function Ha(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:a,marketParams:o,marketState:u}=await fe(n,t,!0),[c,m]=await Promise.all([Q(n,o.loanToken,f),Te(n,a,r)]);if(m.supplyShares===0n)throw new i(`This wallet has no lent ${c.symbol} on Morpho market ${a}.`);let d=ut(m.supplyShares,u.totalSupplyAssets,u.totalSupplyShares),p=l?0n:Me(t),b=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 h=u.totalSupplyAssets>u.totalBorrowAssets?u.totalSupplyAssets-u.totalBorrowAssets:0n,w=l?d:p;if(w>h)throw new i(`Insufficient market liquidity: withdrawing ${w.toString()} base units needs idle assets, but only ${h.toString()} are available until borrowers repay. Withdraw at most that amount, or retry later.`);let y=e.formatAmount(w.toString(),c.decimals),g=[e.unsignedTx({chainId:f,to:$,data:G({abi:X,functionName:"withdraw",args:[o,p,b,r,r]}),value:"0",description:l?`Withdraw all ${m.supplyShares.toString()} supply shares (about ${y} ${c.symbol}) from Morpho market ${a}.`:`Withdraw ${y} ${c.symbol} (${p.toString()} base units) of lent assets from Morpho market ${a}.`})],T=await e.preview(g,r),{formattedChanges:x,formattedNetOutflows:M}=xe(e,T);return{action:"morpho_withdraw",chainId:f,marketId:a,marketParams:pe(o),loanToken:c,withdrawAssets:p.toString(),withdrawShares:b.toString(),estimatedAssets:w.toString(),formattedAssets:y,receiver:r,txs:g,summary:l?`Withdraw all lent ${c.symbol} (about ${y}, including interest) from Morpho Blue market ${a}.`:`Withdraw ${y} lent ${c.symbol} from Morpho Blue market ${a}.`,preview:T,formattedChanges:x,formattedNetOutflows:M}}async function ea(e,t,s){let r=await e.http(Aa,{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 ta(e){let t=`query Markets($chainId: Int!) {
1
+ import{a as xt,d as It,e as Tt}from"./ZTKT3ZQK.js";import{a as Re}from"./7MR37STI.js";import{a as ae}from"./3CCBUYUM.js";import{a as Ze,b as Ge,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"./W7QNSNOH.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 Oe,g as R,i as Ee}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 Qa,getAddress as aa,parseAbi as pt,zeroAddress as Xa}from"viem";import{decodeAbiParameters as ca,encodeFunctionData as ua,getAddress as le,parseAbiParameters as ma,zeroAddress as he,zeroHash as Dt}from"viem";import{decodeAbiParameters as ra,encodeFunctionData as na,erc20Abi as sa,getAddress as Ct,parseAbi as ia,parseAbiParameters as la,zeroHash as Mt}from"viem";var et=Ct("0xCE29862924756584BBD0D75CA1249d22007E2813"),Lt="(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)",da="(uint256 value,uint256 nonce,uint256 deadline,uint8 v,bytes32 r,bytes32 s)",vt=ia(["function BLUE() view returns (address)",`function vaultExitBundlesV1InKindRedemptionVaultV2(address vault,address adapter,${Lt}[] marketParamsList,uint256 exitAssets,${da} sharesPermit,uint256 deadline)`]);function N(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 io(e,t,s,r,n){q(n);let l=N(r.amount),a=N(r.maxShares),o=N(r.maxPenaltyAssets,!0),u=N(r.deadline),c=e.clientFor(f),m=await At(c,t,s),d=(S,B,Ce,ee=[])=>c.readContract({address:S,abi:B,functionName:Ce,args:ee,blockNumber:m.blockNumber}),[p,b,h,w]=await Promise.all([c.getBlock({blockNumber:m.blockNumber}),d(et,vt,"BLUE"),d(t,sa,"balanceOf",[n]),d(t,Ze,"previewRedeem",[a])]);if(typeof b!="string"||Ct(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(a>Ge(h))throw new i("maxShares exceeds the wallet share balance.");let y=Pt(m.idle,l),k=m.markets.filter(S=>S.supplied>0n&&j(S.id)),g=l-y,T=k[0]?.penalty??0n,x=g*10n**18n/(10n**18n+T);if(g>0n&&x===0n)throw new i("The penalty-adjusted in-kind amount rounds to zero.");let M=[];for(let S of k){if(x===0n)break;let B=Pt(S.supplied,x);M.push({marketId:S.id,assets:B,penalty:(B*S.penalty+10n**18n-1n)/10n**18n}),x-=B}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(M.length)>Ge(w))throw new i("maxShares cannot cover the exit and per-market rounding buffer.");if(M.some(S=>S.assets>m.blueCash))throw new i("Morpho Blue cannot fund the largest in-kind callback. Reduce the amount.");let C=M.reduce((S,B)=>S+B.penalty,0n);if(C>o)throw new i("In-kind penalty exceeds maxPenaltyAssets.");let P=[...y?[y]:[],...M.flatMap(S=>[S.assets,S.penalty].filter(B=>B>0n))],E=(await Promise.all(P.map(S=>d(t,Ze,"previewWithdraw",[S])))).reduce((S,B)=>S+Ge(B),0n);if(E===0n||E>a)throw new i("Separately rounded burns exceed maxShares.");let Z=M.map(S=>ra(la(Lt),m.markets.find(B=>B.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 ${E} share base units; receive ${y} ${s.symbol} base units and Morpho Blue supply positions ${M.map(S=>`${S.marketId}: ${S.assets} ${s.symbol} base units`).join(", ")||"none"}. Penalty ${C} ${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.`,v=na({abi:vt,functionName:"vaultExitBundlesV1InKindRedemptionVaultV2",args:[t,H,Z,l,{value:0n,nonce:0n,deadline:0n,v:0,r:Mt,s:Mt},u]}),U=[e.approval(t,et,E.toString(),f),e.unsignedTx({to:et,data:v,value:"0",chainId:f,description:F})],D=await e.preview(U,n),V=-D.changes.filter(S=>S.token.chainId===f&&R(S.token.address,t)).reduce((S,B)=>{if(B.token.decimals!==18||!/^-?\d+$/.test(B.amount))throw new i("Invalid in-kind share preview.");return S+BigInt(B.amount)},0n);if(V<=0n||V>E)throw new i("In-kind preview exceeds the exact share authorization or burns no shares.");return{txs:U,preview:D,summary:F,receipt:{idleAssets:y.toString(),positions:M.map(S=>({marketId:S.marketId,asset:s,assets:S.assets.toString()})),penaltyAssets:C.toString()}}}var we=le("0x53A1eB6589861F686af7c531211E35Aefe30210f"),Ut=["supply","withdraw","supplyCollateralAndBorrow","repayAndWithdrawCollateral","migrateBorrowPosition"],tt={kind:0,data:"0x"},_e={nonce:0n,deadline:0n,signature:{v:0,r:Dt,s:Dt}},pa=ma("(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(v=>!l.includes(v)))throw new i("Unexpected argument for this Blue bundle.");let a=await n.getBlock(),o=N(t.deadline);if(o<a.timestamp||o>a.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:Re,functionName:"BLUE",blockNumber:a.number}),n.readContract({address:we,abi:Re,functionName:"PUBLIC_ALLOCATOR",blockNumber:a.number})]);if(le(u)!==$||le(c)!==xt)throw new i("BlueBundlesV1 deployment does not match Oak\u2019s pinned Blue and Public Allocator.");let m=async v=>{if(typeof v!="string"||!j(v))throw new i("Choose a verified Morpho market with a supported exit.");let U=await n.readContract({address:$,abi:O,functionName:"idToMarketParams",args:[v],blockNumber:a.number}),D={loanToken:le(U[0]),collateralToken:le(U[1]),oracle:le(U[2]),irm:le(U[3]),lltv:U[4]};if(!R(ke({...D,lltv:String(D.lltv)}),v))throw new i("Blue bundle market identity mismatch.");return D},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:$,abi:O,functionName:"isAuthorized",args:[s,we],blockNumber:a.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 b=t.assets===void 0?0n:N(t.assets,!0),h=t.shares===void 0?0n:N(t.shares,!0),w=t.collateralAssets===void 0?0n:N(t.collateralAssets,!0),y=r==="supply"||r==="withdraw"?0n:N(t.maxLtv,!0);if(y>p.lltv)throw new i("maxLtv cannot exceed the verified destination market LLTV.");if(r==="supply"&&b===0n||r==="withdraw"&&b===0n==(h===0n)||r==="supplyCollateralAndBorrow"&&w===0n&&b===0n||r==="repayAndWithdrawCollateral"&&(b>0n&&h>0n||b===0n&&h===0n&&w===0n))throw new i("Choose a nonzero amount; assets and shares are mutually exclusive for repayment/withdrawal.");let k=t.allocations??[];if(!Array.isArray(k)||k.length>4||k.length&&r==="supplyCollateralAndBorrow"&&b===0n)throw new i("Provide at most four explicit allocations, only with a borrow or withdrawal.");let g=new Set,T=[],x=0n;for(let v of k){if(!v||typeof v!="object"||Array.isArray(v)||Object.keys(v).some(Xe=>!["vault","sourceMarketId","assets","maxPenaltyAssets"].includes(Xe)))throw new i("Unsupported bundled allocation input.");let U=v,D=await It(e,{vault:U.vault,marketId:r==="migrateBorrowPosition"?t.destinationMarketId:t.marketId});if(g.has(D.definition.vault.toLowerCase()))throw new i("Use each source vault at most once per bundle.");g.add(D.definition.vault.toLowerCase());let V=N(U.assets),S=N(U.maxPenaltyAssets,!0);if(!D.permission||V>=1n<<128n||V>D.headroom||D.penalty>10n**18n||D.asset.address!==p.loanToken)throw new i("Bundled allocation is disabled, unqualified or exceeds target capacity.");let B=(V*D.penalty+10n**18n-1n)/10n**18n;if(B>S)throw new i("Bundled allocation exceeds maxPenaltyAssets.");x+=B;let Ce=U.sourceMarketId===void 0,ee=Ce?void 0:D.sources.find(Xe=>R(Xe.id,String(U.sourceMarketId)));if(Ce?!D.canIdle||V>D.data.idle:!ee||!ee.canPull||V>ee.capacity||V>D.data.blueCash)throw new i("Bundled allocation source cannot cover the requested amount.");T.push({vault:D.definition.vault,adapter:D.target.adapter,marketParams:D.params,sourceAdapter:ee?.adapter??he,sourceMarketParams:ee?ca(pa,ee.data)[0]:D.params,assets:V,penalty:D.penalty,fromIdle:Ce})}let M,C,P,I=0n;if(r==="supply")M="blueBundlesV1Supply",P=d.loanToken,I=b,C=[d,b,tt,0n,he,o];else if(r==="withdraw")M="blueBundlesV1Withdraw",C=[d,b,h,_e,T,0n,he,o];else if(r==="supplyCollateralAndBorrow"){if(M="blueBundlesV1SupplyCollateralAndBorrow",P=d.collateralToken,I=w,x>=b&&x>0n)throw new i("Allocation penalties would consume the borrow proceeds.");C=[d,w,b,y,tt,_e,T,0n,he,o]}else if(r==="repayAndWithdrawCollateral"){if(M="blueBundlesV1RepayAndWithdrawCollateral",P=d.loanToken,I=N(t.maxRepayAssets,!0),b>I||h>0n&&I===0n)throw new i("Repayment requires a sufficient maxRepayAssets budget.");C=[d,b,h,I,w,y,tt,_e,0n,he,o]}else M="blueBundlesV1MigrateBorrowPosition",C=[d,p,y,_e,T,0n,he,o];let E=`Morpho Blue atomic ${r}: ${JSON.stringify(t)}. Allocation penalties ${x} loan-token base units; zero referral fee. Max LTV ${y}; absolute deadline ${o}. Migration adds allocation penalties to destination debt; borrowing deducts them from proceeds. Exact input approval ${I}. Existing Blue bundle authorization remains until explicitly revoked with morpho_manage. No opaque callback, permit or signature is accepted.`,Z=[...P&&I?[e.approval(P,we,I.toString(),f)]:[],e.unsignedTx({to:we,data:ua({abi:Re,functionName:M,args:C}),value:"0",chainId:f,description:E})],H=await e.preview(Z,s),F=new Map;for(let v of H.changes)if(BigInt(v.amount)<0n){let U=v.token.address.toLowerCase();F.set(U,(F.get(U)??0n)-BigInt(v.amount))}if([...F].some(([v,U])=>!P||v!==P.toLowerCase()||U>I))throw new i("Bundle preview spends outside the exact input budget.");return{txs:Z,preview:H,summary:E}}catch(r){throw new i(e.plainError(r))}}}]});import{concatHex as Bt,decodeAbiParameters as fa,encodeAbiParameters as Rt,encodeFunctionData as at,erc20Abi as Nt,getAddress as K,keccak256 as rt,zeroAddress as ye,zeroHash as ba}from"viem";var Y=K("0x6120765Ba5336150BbdDdD0Cd9108B5bFD369632"),ha=["0x90B800999e4ACd1bD20283BD450bBd2e06D91F7C","0x708d6Bf6F847202a0755bb5636bE663B174242ea"].map(e=>K(e)),nt=ae.find(e=>e.name==="take"),Ot=[nt.inputs[0]],wa=[nt.inputs[0].components[0]];function Et(e){let t=rt(Bt(["0x600b380380600b5f395ff3",Rt(wa,[e])]));return rt(Bt(["0xff",e.midnight,ba,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 ka(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 He(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 ot(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 ya=e=>JSON.parse(JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s)),Ht=e=>{async function t(n,l){let a=He(n,32),o=e.clientFor(f);if(await o.getChainId()!==f)throw new i("Midnight requires chain 4663.");let u=await o.getBlock(),c=(k,g=[])=>o.readContract({address:Y,abi:ae,functionName:k,args:g,blockNumber:u.number}),m=await c("toMarket",[a]);if(m.chainId!==BigInt(f)||K(m.midnight)!==Y||!R(Et(m),a))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(k=>R(k,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,b,h,w]=await Promise.all([c("position",[a,l]),c("updatePositionView",[m,a,l]),c("marketState",[a]),c("isHealthy",[m,a,l])]),y=async k=>{let[g,T]=await Promise.all([o.readContract({address:k,abi:Nt,functionName:"decimals",blockNumber:u.number}),o.readContract({address:k,abi:Nt,functionName:"symbol",blockNumber:u.number})]);if(!Number.isInteger(g)||g>36||typeof T!="string")throw new i("Invalid Midnight token metadata.");return{address:K(k),decimals:g,symbol:T.replace(/[^a-zA-Z0-9.$_-]/g,"").slice(0,32),chainId:f}};return{id:a,rpc:o,block:u,market:m,read:c,token:y,loan:await y(m.loanToken),position:ot(p,6),updated:ot(b,3),state:ot(h,13),healthy:w}}let s=(n,l,a,o)=>({name:n,inputSchema:{type:"object",properties:l,required:a,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 o(u,c)}catch(m){throw new i(e.plainError(m))}}});async function r(n,l,a){return{txs:n,preview:await e.preview(n,l),summary:a}}return{tools:[s("morpho_midnight_status",{marketId:{type:"string",description:"Midnight market id: 0x + 64 hex digits (bytes32)."}},["marketId"],async(n,l)=>{let a=await t(n.marketId,l),o=await Promise.all(a.market.collateralParams.map(async(m,d)=>({token:await a.token(m.token),lltvWad:m.lltv.toString(),oracle:m.oracle,assets:String(await a.read("collateral",[a.id,l,BigInt(d)]))}))),u=["configurator","feeSetter","feeClaimer","tickSpacingSetter"],c=await Promise.all(u.map(m=>a.read(m)));return{protocol:Object.fromEntries(u.map((m,d)=>[m,K(String(c[d]))])),continuousFeePerSecondWad:String(a.state[11]),tickSpacing:String(a.state[12]),settlementFeeCbps:a.state.slice(4,11).map(String),settlementFeeCbpWadScale:"1000000000000",chainId:f,midnight:Y,marketId:a.id,blockNumber:String(a.block.number),market:ya(a.market),loanToken:a.loan,collaterals:o,debtUnits:String(a.position[4]),creditUnits:String(a.updated[0]),pendingFeeUnits:String(a.updated[1]),withdrawableUnits:String(a.state[2]),healthy:a.healthy,maturity:String(a.market.maturity),matured:a.block.timestamp>a.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 a=He(n.offer),[o]=fa(Ot,a);if(!R(Rt(Ot,[o]),a))throw new i("Offer encoding is not canonical.");let u=await t(Et(o.market),l),c=N(n.units),m=N(n.maxAssets,!0),d=N(n.minAssets,!0),p=He(n.ratifierData);if(c>=1n<<128n||R(o.maker,l)||o.callback!==ye||o.callbackData!=="0x"||!ha.includes(K(o.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<o.start||u.block.timestamp>o.expiry||o.expiry<o.start)throw new i("The Midnight offer is not currently live.");if(o.buy&&o.receiverIfMakerIsSeller!==ye||!o.buy&&o.receiverIfMakerIsSeller===ye)throw new i("Invalid offer seller receiver.");if(o.buy&&u.block.timestamp>u.market.maturity&&c>u.updated[0])throw new i("Post-maturity sales cannot increase this wallet\u2019s debt.");let b=await u.read("settlementFee",[u.id,u.market.maturity>u.block.timestamp?u.market.maturity-u.block.timestamp:0n]),h=ka(o.tick);if(b>h&&o.buy)throw new i("Settlement fee exceeds the offer price.");let w=o.buy?h-b:h,y=w+b,k=v=>o.buy?v/de:(v+de-1n)/de,g=k(c*y),T=k(c*w);if(o.buy?T<d||T===0n:g>m||g===0n)throw new i("Midnight proceeds/spend do not fit the requested bounds.");let x=await u.read("consumed",[o.maker,o.group]);if(o.maxAssets===0n==(o.maxUnits===0n)||x+(o.maxAssets?o.buy?g:T:c)>(o.maxAssets||o.maxUnits))throw new i("Midnight offer capacity is exhausted or invalid.");if(u.state[11]>o.continuousFeeCap||o.tick%u.state[12]!==0n)throw new i("Offer fee cap or market tick spacing no longer permits execution.");let M=await u.read("isAuthorized",[o.maker,o.ratifier]),C=[{type:"function",name:"isRatified",stateMutability:"view",inputs:[nt.inputs[0],{type:"bytes"},{type:"address"}],outputs:[{type:"bytes32"}]}],P=await u.rpc.readContract({address:o.ratifier,abi:C,functionName:"isRatified",args:[o,p,l],blockNumber:u.block.number});if(M!==!0||P!==rt(new TextEncoder().encode("morpho.midnight.callbackSuccess")))throw new i("The maker has not authorized and ratified this exact offer.");let I=at({abi:ae,functionName:"take",args:[o,p,c,l,o.buy?l:ye,ye,"0x"]}),E=`Midnight ${o.buy?"sell credit or borrow":"buy credit or reduce debt"}: ${c} fixed debt units; ${o.buy?`receive ${T}`:`spend ${g}`} ${u.loan.symbol} base units (token ${u.loan.address}, decimals ${u.loan.decimals}). Maturity ${u.market.maturity} Unix seconds; offer expiry ${o.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=[...o.buy?[]:[e.approval(u.loan.address,Y,g.toString(),f)],e.unsignedTx({to:Y,data:I,value:"0",chainId:f,description:E})],H=await r(Z,l,E),F=H.preview.changes.filter(v=>v.token.chainId===f&&R(v.token.address,u.loan.address)).reduce((v,U)=>v+BigInt(U.amount),0n);if(o.buy?F<T: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 a=await t(n.marketId,l),o=n.operation;if(!["supplyCollateral","withdrawCollateral","repay","withdraw","updatePosition","claimContinuousFee"].includes(String(o)))throw new i("Choose a finite Midnight position operation.");let u,c,m=a.loan,d=0n;if(o==="updatePosition"){if(n.amount!==void 0||n.collateralIndex!==void 0)throw new i("Position update takes no amount or collateral index.");u=[a.market,l]}else if(o==="claimContinuousFee"){if(d=N(n.amount),n.collateralIndex!==void 0||K(String(await a.read("feeClaimer")))!==K(l))throw new i("This wallet lacks the Midnight fee claimer role or supplied an unused collateral index.");u=[a.market,d,l]}else{if(d=N(n.amount),d>=1n<<128n)throw new i("Midnight position amount exceeds uint128.");if(o==="supplyCollateral"||o==="withdrawCollateral"){if(!Number.isInteger(n.collateralIndex)||Number(n.collateralIndex)<0||Number(n.collateralIndex)>=a.market.collateralParams.length)throw new i("Choose a current collateral index.");let h=BigInt(String(n.collateralIndex)),w=await a.token(a.market.collateralParams[Number(h)].token);if(m=w,o==="withdrawCollateral"&&d>await a.read("collateral",[a.id,l,h]))throw new i("Insufficient Midnight collateral.");u=o==="supplyCollateral"?[a.market,h,d,l]:[a.market,h,d,l,l],o==="supplyCollateral"&&(c=w)}else{if(n.collateralIndex!==void 0)throw new i("This operation takes no collateral index.");if(o==="repay"&&d>a.position[4]||o==="withdraw"&&(d>a.updated[0]||d>a.state[2]))throw new i("Amount exceeds current debt, credit or available repayment liquidity.");u=o==="repay"?[a.market,d,l,ye,"0x"]:[a.market,d,l,l],o==="repay"&&(c=a.loan)}}let p=`Midnight ${o}: ${d} ${m.symbol} base units (token ${m.address}, decimals ${m.decimals}) on ${a.id}; beneficiary ${l}; maturity ${a.market.maturity} Unix seconds. No callbacks or delegation. Withdrawal can fail if collateral health or lender liquidity changes.`,b=[...c?[e.approval(c.address,Y,d.toString(),f)]:[],e.unsignedTx({to:Y,data:at({abi:ae,functionName:String(o),args:u}),value:"0",chainId:f,description:p})];return r(b,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 a={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(a)].includes(n.operation)||!Array.isArray(n.values))throw new i("Choose a finite Midnight management operation and ordered values.");let o=n.operation,u=ae.find(p=>p.name===o);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,b)=>{let h=n.values[b];if(p.type==="bool"){if(typeof h!="boolean")throw new i("Use boolean management values.");return h}if(p.type==="address")return Ee(h,"Use explicit management addresses.",Oe);if(p.type==="bytes32")return He(h,32);if(/^uint/.test(p.type)){let w=N(h,!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(o==="setConsumed"||o==="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:ae,functionName:a[o]});if(typeof p!="string"||K(p)!==K(l))throw new i("This wallet lacks the Midnight configuration, fee or tick role.")}let d=`Midnight ${o}, ordered values ${JSON.stringify(n.values)}. ${o==="setIsAuthorized"&&m[1]?"This grants authority over all Midnight positions, cancellations and further delegation, without an amount cap. Revoke with false when done.":""}${o==="setConsumed"?"Consumption only increases; setting uint128 maximum permanently cancels this offer group.":""}`;return r([e.unsignedTx({to:Y,data:at({abi:ae,functionName:o,args:m}),value:"0",chainId:f,description:d})],l,d)})]}};import{decodeAbiParameters as re,encodeAbiParameters as ga,encodeFunctionData as G,erc20Abi as it,getAddress as L,isAddress as Fe,keccak256 as Sa,parseAbi as Ve,parseAbiParameters as J}from"viem";var De="morpho",Aa="https://api.morpho.org/graphql",$=L(z[f].morpho.morpho_blue.address),xa=L(z[f].morpho.adaptive_curve_irm.address),Ia=L(z[f].morpho.USDG.address),me=L(z[f].morpho.WETH.address),Ta=["0x7c820d6a09502d63be80bb8025ec479d29d7c06e70f8df65a92aaeed23a366e2","0x1fa5293f9f60059a7f6a4923022156fcdcc038bd3749be55897000c03afe92d8"],Ma={"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"}],va=new Map(lt.map(e=>[e.marketId.toLowerCase(),e]));function j(e){return va.get(e.toLowerCase())}function ct(e){let t=j(e);return t?{actions:"enabled",label:t.label,source:Ma[t.source]}:{actions:"read-only",reason:"Not in Oak's verified Morpho market registry; Oak builds no transactions for it."}}var qt=20,Ue=120n,ze=1000000n,We=1n,Se=10n**18n,Pa=10n**36n,jt=(1n<<128n)-1n,Ca=(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)"]),La=Ve(["function price() view returns (uint256)"]),Da=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 $e(e,t){return e===0n?0n:(e+t-1n)/t}function Ua(e,t,s){return e*(s+ze)/(t+We)}function $a(e,t,s){return $e(e*(s+ze),t+We)}function ut(e,t,s){return e*(t+We)/(s+ze)}function se(e,t,s){return $e(e*(t+We),s+ze)}function Ae(e,t,s){return e*t/Pa*s/Se}function Ba(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=Ba(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 a of[e.loanToken,e.collateralToken,e.oracle,e.irm])if(typeof a!="string"||!Fe(a,{strict:!1}))throw new i("Morpho marketParams contains an invalid address.");let t=L(e.loanToken),s=L(e.collateralToken),r=L(e.oracle),n=L(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=ga(J("address, address, address, address, uint256"),[t.loanToken,t.collateralToken,t.oracle,t.irm,t.lltv]);return Sa(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),L(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=L(t),n=r.toLowerCase();if(s===f){if(n===Ia.toLowerCase())return yt;if(n===me.toLowerCase())return gt}let[l,a]=await Promise.all([ne(e,r,G({abi:it,functionName:"symbol"})),ne(e,r,G({abi:it,functionName:"decimals"}))]),[o]=re(J("string"),l),[u]=re(J("uint8"),a);return{address:r,symbol:Xt(o),decimals:Number(u),chainId:s}}async function Yt(e,t){let s=await ne(e,$,G({abi:X,functionName:"idToMarketParams",args:[t]})),[r,n,l,a,o]=re(J("address, address, address, address, uint256"),s);return{loanToken:L(r),collateralToken:L(n),oracle:L(l),irm:L(a),lltv:o}}async function Jt(e,t){let s=await ne(e,$,G({abi:X,functionName:"market",args:[t]})),[r,n,l,a,o,u]=re(J("uint128, uint128, uint128, uint128, uint128, uint128"),s);return{totalSupplyAssets:r,totalSupplyShares:n,totalBorrowAssets:l,totalBorrowShares:a,lastUpdate:o,fee:u}}async function Te(e,t,s){let r=await ne(e,$,G({abi:X,functionName:"position",args:[t,L(s)]})),[n,l,a]=re(J("uint256, uint128, uint128"),r);return{supplyShares:n,borrowShares:l,collateral:a}}async function Ke(e,t){let s=await ne(e,L(t),G({abi:La,functionName:"price"})),[r]=re(J("uint256"),s);return r}async function Na(e,t,s){if(t.irm===te)return 0n;let r=await ne(e,L(t.irm),G({abi:Da,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=$e(n*n,2n*Se),a=$e(l*n,3n*Se);return e.totalBorrowAssets+$e(e.totalBorrowAssets*(n+l+a),Se)}async function Be(e,t,s,r=0n){let[n,l]=await Promise.all([e.getBlock({blockTag:"latest"}),Na(e,t,s)]),a=BigInt(Math.ceil(Date.now()/1e3)),o=(n.timestamp>a?n.timestamp:a)+r;return{totalBorrowAssets:Qe(s,l,o),accruedThrough:o,rate:l}}async function Zt(e,t,s){let r=await ne(e,L(t),G({abi:it,functionName:"balanceOf",args:[L(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,a=l?ke(l):void 0,o=r!==void 0?Qt(r):void 0;if(o&&a&&o!==a.toLowerCase())throw new i(`MarketParams tuple hash (${a}) does not match marketId (${o}).`);let u=(o??a).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 Oa(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=e.clientFor(f),{marketId:a,marketParams:o}=await fe(l,t,!0),u=await Q(l,o.collateralToken,f),c=o.collateralToken.toLowerCase()===me.toLowerCase(),m=typeof t.collateralToken=="string"?(q(t.collateralToken),L(t.collateralToken)):void 0,d=W("wrapNative",t.wrapNative)===!0||m!==void 0&&dt(m);if(m&&!dt(m)&&m.toLowerCase()!==o.collateralToken.toLowerCase())throw new i(`Collateral token ${m} does not match market collateral ${o.collateralToken}.`);if(d&&!c)throw new i("Native ETH wrapping is only supported when market collateralToken is WETH.");let p=Me(t),b=p.toString(),h=e.formatAmount(b,u.decimals),w=[];d&&w.push(e.unsignedTx({chainId:f,to:me,data:G({abi:Kt,functionName:"deposit"}),value:b,description:`Wrap ${h} ETH into WETH at ${me}.`})),w.push(e.approval(o.collateralToken,$,b,f)),w.push(e.unsignedTx({chainId:f,to:$,data:G({abi:X,functionName:"supplyCollateral",args:[o,p,n,"0x"]}),value:"0",description:`Supply ${h} ${u.symbol} (${b} base units) collateral to Morpho market ${a}.`}));let y=await e.preview(w,r),{formattedChanges:k,formattedNetOutflows:g}=xe(e,y);return{action:"morpho_supply_collateral",chainId:f,marketId:a,marketParams:pe(o),collateralToken:u,assets:b,formattedAssets:h,onBehalf:n,txs:w,summary:`${d?`Send ${h} ETH to wrap into WETH. `:""}Supply ${h} ${u.symbol} collateral to Morpho Blue market ${a}.`,preview:y,formattedChanges:k,formattedNetOutflows:g}}async function Ea(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=r,a=e.clientFor(f),{marketId:o,marketParams:u,marketState:c}=await fe(a,t,!0),[m,d,p,b]=await Promise.all([Q(a,u.loanToken,f),Te(a,o,n),Ke(a,u.oracle),Be(a,u,c,Ue)]),h=Me(t),w=h.toString(),y=e.formatAmount(w,m.decimals),k=c.totalSupplyAssets>c.totalBorrowAssets?c.totalSupplyAssets-c.totalBorrowAssets:0n;if(h>k)throw new i(`Insufficient market liquidity: requested ${w} base units, available ${k.toString()} base units.`);let g=Ae(d.collateral,p,u.lltv),T=se(d.borrowShares,b.totalBorrowAssets,c.totalBorrowShares);if(d.collateral===0n||T+h>g)throw new i(`Insufficient collateral or unhealthy borrow: total debt ${(T+h).toString()} exceeds max borrow ${g.toString()} base units.`);let x=$a(h,b.totalBorrowAssets,c.totalBorrowShares),C=[e.unsignedTx({chainId:f,to:$,data:G({abi:X,functionName:"borrow",args:[u,h,0n,n,l]}),value:"0",description:`Borrow ${y} ${m.symbol} (${w} base units) from Morpho market ${o}.`})],P=await e.preview(C,r),{formattedChanges:I,formattedNetOutflows:E}=xe(e,P);return{action:"morpho_borrow",chainId:f,marketId:o,marketParams:pe(u),loanToken:m,assets:w,formattedAssets:y,borrowShares:x.toString(),onBehalf:n,receiver:l,txs:C,summary:`Borrow ${y} ${m.symbol} from Morpho Blue market ${o}.`,preview:P,formattedChanges:I,formattedNetOutflows:E}}async function Ga(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=e.clientFor(f);if(t.shares!==void 0){let I=Le(t.shares);if(I<=0n||I===Ca||I>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:o,marketState:u}=await fe(l,t,!0),[c,m,d]=await Promise.all([Q(l,o.loanToken,f),Te(l,a,n),Zt(l,o.loanToken,r)]);if(m.borrowShares===0n)throw new i(`Position has no active borrow debt on Morpho market ${a}.`);let p=0n,b=0n;if(W("repayAll",t.repayAll)===!0)b=m.borrowShares;else if(t.shares!==void 0){let I=Le(t.shares);if(I>m.borrowShares)throw new i(`Repay shares (${I.toString()}) exceed current position borrowShares (${m.borrowShares.toString()}).`);b=I}else p=Me(t);let h=b>0n?await Be(l,o,u,Ue):void 0,w=b>0n?se(b,h.totalBorrowAssets,u.totalBorrowShares):p;if(d<w)throw new i(`Insufficient loan token balance for repayment: wallet holds ${d.toString()} base units, but ${w.toString()} base units are required (including accrued interest).`);let y=w.toString(),k=e.formatAmount(y,c.decimals),g=e.approval(o.loanToken,$,y,f),T=e.unsignedTx({chainId:f,to:$,data:G({abi:X,functionName:"repay",args:[o,p,b,n,"0x"]}),value:"0",description:b>0n?`Repay ${b.toString()} borrow shares (${k} ${c.symbol}) on Morpho market ${a}.`:`Repay ${k} ${c.symbol} (${p.toString()} base units) on Morpho market ${a}.`}),x=[g,T],M=await e.preview(x,r),{formattedChanges:C,formattedNetOutflows:P}=xe(e,M);return{action:"morpho_repay",chainId:f,marketId:a,marketParams:pe(o),loanToken:c,repayAssets:p.toString(),repayShares:b.toString(),requiredAssets:y,...h?{accruedThrough:h.accruedThrough.toString(),borrowRatePerSecond:h.rate.toString(),inclusionSeconds:Ue.toString()}:{},formattedRequiredAssets:k,onBehalf:n,txs:x,summary:b>0n?`Repay ${b.toString()} borrow shares (approval up to ${k} ${c.symbol}) on Morpho Blue market ${a}. Refresh if signing/inclusion takes more than ${Ue} seconds.`:`Repay ${k} ${c.symbol} on Morpho Blue market ${a}.`,preview:M,formattedChanges:C,formattedNetOutflows:P}}async function Ra(e,t,s){let r=Ie(t,s);ve(t,r);let n=r,l=r,a=e.clientFor(f),{marketId:o,marketParams:u,marketState:c}=await fe(a,t,!0),[m,d,p,b]=await Promise.all([Q(a,u.collateralToken,f),Te(a,o,n),Ke(a,u.oracle),Be(a,u,c,Ue)]),h=W("withdrawAll",t.withdrawAll)===!0?d.collateral:Me(t);if(h<=0n||h>d.collateral)throw new i(`Insufficient collateral to withdraw: requested ${h.toString()} base units, position holds ${d.collateral.toString()} base units.`);if(d.borrowShares>0n){let C=d.collateral-h,P=Ae(C,p,u.lltv),I=se(d.borrowShares,b.totalBorrowAssets,c.totalBorrowShares);if(I>P)throw new i(`Unhealthy collateral withdrawal: remaining max borrow ${P.toString()} would fall below current debt ${I.toString()} base units.`)}let w=h.toString(),y=e.formatAmount(w,m.decimals),g=[e.unsignedTx({chainId:f,to:$,data:G({abi:X,functionName:"withdrawCollateral",args:[u,h,n,l]}),value:"0",description:`Withdraw ${y} ${m.symbol} (${w} base units) collateral from Morpho market ${o}.`})],T=await e.preview(g,r),{formattedChanges:x,formattedNetOutflows:M}=xe(e,T);return{action:"morpho_withdraw_collateral",chainId:f,marketId:o,marketParams:pe(u),collateralToken:m,assets:w,formattedAssets:y,onBehalf:n,receiver:l,txs:g,summary:`Withdraw ${y} ${m.symbol} collateral from Morpho Blue market ${o}.`,preview:T,formattedChanges:x,formattedNetOutflows:M}}async function _a(e,t,s){let r=Ie(t,s);ve(t,r);let n=e.clientFor(f),{marketId:l,marketParams:a,marketState:o}=await fe(n,t,!0),u=W("wrapNative",t.wrapNative)===!0;if(u&&a.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,a.loanToken,f),u?Promise.resolve(c):Zt(n,a.loanToken,r)]);if(p<c)throw new i(`Insufficient ${d.symbol} balance to lend: wallet holds ${p.toString()} base units, requested ${m}.`);let b=e.formatAmount(m,d.decimals),h=[];u&&h.push(e.unsignedTx({chainId:f,to:me,data:G({abi:Kt,functionName:"deposit"}),value:m,description:`Wrap ${b} ETH into WETH at ${me}.`})),h.push(e.approval(a.loanToken,$,m,f)),h.push(e.unsignedTx({chainId:f,to:$,data:G({abi:X,functionName:"supply",args:[a,c,0n,r,"0x"]}),value:"0",description:`Lend ${b} ${d.symbol} (${m} base units) to Morpho market ${l}.`}));let w=Ua(c,o.totalSupplyAssets,o.totalSupplyShares),y=await e.preview(h,r),{formattedChanges:k,formattedNetOutflows:g}=xe(e,y);return{action:"morpho_supply",chainId:f,marketId:l,marketParams:pe(a),loanToken:d,assets:m,formattedAssets:b,supplySharesEstimated:w.toString(),onBehalf:r,oak:ct(l),txs:h,summary:`${u?`Send ${b} ETH to wrap into WETH. `:""}Lend ${b} ${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:y,formattedChanges:k,formattedNetOutflows:g}}async function Ha(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:a,marketParams:o,marketState:u}=await fe(n,t,!0),[c,m]=await Promise.all([Q(n,o.loanToken,f),Te(n,a,r)]);if(m.supplyShares===0n)throw new i(`This wallet has no lent ${c.symbol} on Morpho market ${a}.`);let d=ut(m.supplyShares,u.totalSupplyAssets,u.totalSupplyShares),p=l?0n:Me(t),b=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 h=u.totalSupplyAssets>u.totalBorrowAssets?u.totalSupplyAssets-u.totalBorrowAssets:0n,w=l?d:p;if(w>h)throw new i(`Insufficient market liquidity: withdrawing ${w.toString()} base units needs idle assets, but only ${h.toString()} are available until borrowers repay. Withdraw at most that amount, or retry later.`);let y=e.formatAmount(w.toString(),c.decimals),g=[e.unsignedTx({chainId:f,to:$,data:G({abi:X,functionName:"withdraw",args:[o,p,b,r,r]}),value:"0",description:l?`Withdraw all ${m.supplyShares.toString()} supply shares (about ${y} ${c.symbol}) from Morpho market ${a}.`:`Withdraw ${y} ${c.symbol} (${p.toString()} base units) of lent assets from Morpho market ${a}.`})],T=await e.preview(g,r),{formattedChanges:x,formattedNetOutflows:M}=xe(e,T);return{action:"morpho_withdraw",chainId:f,marketId:a,marketParams:pe(o),loanToken:c,withdrawAssets:p.toString(),withdrawShares:b.toString(),estimatedAssets:w.toString(),formattedAssets:y,receiver:r,txs:g,summary:l?`Withdraw all lent ${c.symbol} (about ${y}, including interest) from Morpho Blue market ${a}.`:`Withdraw ${y} lent ${c.symbol} from Morpho Blue market ${a}.`,preview:T,formattedChanges:x,formattedNetOutflows:M}}async function ea(e,t,s){let r=await e.http(Aa,{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 ta(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
@@ -1,3 +1,3 @@
1
- import{d as F,e as M}from"./ACH4BSME.js";import{g as H,j as R}from"./PZEF5LBL.js";import{a as y,b as x,c,f as $,j as L,l as S,m as O,n as U}from"./CSOO4SW7.js";import{a as r}from"./I6PQW2JI.js";import{a as N}from"./K6D6SDIG.js";import{c as q}from"./43LI5NKJ.js";import{g as _}from"./NWNYJ26T.js";import{a as h}from"./XSD5NL7J.js";import{encodeFunctionData as W}from"viem";var j={chop_wrap:["log","underlying","amount","minLogOut"],chop_unwrap:["log","amount","quotedNet"],chop_farm:["log","amount","pairedAmount","minPaired","minStakedLp","slippageBps","deadline"],chop_unfarm:["log","amount","minLogOut","minPairedOut","deadline"],chop_harvest:["log"]};function z(l,o){if(Object.keys(l).some(n=>!o.includes(n)))throw new h("Unexpected Chop argument.");if(o.some(n=>l[n]===void 0))throw new h("Provide every required Chop input.")}async function V(l,o,n){let d=c(o),p=await l.getBlock({blockNumber:BigInt(n.measuredAtBlock)});if(p.number!==BigInt(n.measuredAtBlock)||d<=x(p.timestamp)||d>p.timestamp+1200n)throw new h("Chop deadline must be in the next 20 minutes.");return d}async function D(l,o,n,d){if(z(n,j[o]),y(d),l.network==="testnet")throw new h("Chop requires chain 4663.");let p=y(n.log),u=l.clientFor(4663),i=await S(u,p,o==="chop_wrap"||o==="chop_farm"?"enter":"exit"),s=BigInt(i.measuredAtBlock),f=[],g=[],C=(e,t,a)=>{f.push(q(e.address,t,a.toString(),4663)),g.push(l.approval(e.address,t,a.toString(),4663))},P=(e,t,a)=>{let m={to:e,data:W({abi:N,functionName:t,args:a}),value:"0",chainId:4663,description:`${o} on verified log ${p}.`,...o==="chop_harvest"?{gasLimit:"1000000"}:{}};f.push(m),g.push({...l.unsignedTx(m),...m.gasLimit===void 0?{}:{gasLimit:m.gasLimit}})},A=[],v=(e,t,a=!0)=>A.push({token:e,min:-t,max:a?-t:-1n}),w=(e,t)=>A.push({token:e,min:t}),T=async(e,t)=>{if(x(await $(u,e.address,"balanceOf",[d],s))<t)throw new h("This wallet does not hold enough tokens for the Chop action.")},k;if(o==="chop_wrap"){let e=c(n.amount),t=c(n.minLogOut);if(!_(y(n.underlying),i.underlying.address))throw new h("The underlying token does not match the verified Chop log.");await T(i.underlying,e),C(i.underlying,p,e),P(p,"bond",[i.underlying.address,e,t]),v(i.underlying,e,!1),w(i.log,t),k=`Wrap at most ${e} underlying base units; on-chain minimum ${t} log base units.`}else if(o==="chop_unwrap"){let e=c(n.amount),t=c(n.quotedNet);await T(i.log,e);let a=await M(u,i,d,e);if(BigInt(a.net.amount)<t)throw new h("Chop unwrap no longer meets the quoted net amount. Request a fresh quote.");let m=F(i,e);f.push(m),g.push(l.unsignedTx(m)),v(i.log,e),w(i.underlying,t),k=`Unwrap ${e} log base units; preview must return at least quoted ${t} underlying base units.`}else if(o==="chop_farm"){await L(u,r.helper,s);let e=c(n.amount),t=c(n.pairedAmount),a=c(n.minPaired),m=c(n.minStakedLp),I=await V(u,n.deadline,i),b=n.slippageBps;if(typeof b!="number"||!Number.isInteger(b)||b<0||b>1e3||b%10!==0||a>t)throw new h("Chop LP slippage must be 0\u20131000 basis points in multiples of 10; the paired minimum cannot exceed its input.");await Promise.all([T(i.log,e),T(i.paired,t)]),C(i.log,r.helper.address,e),C(i.paired,r.helper.address,t),P(r.helper.address,"addLPAndStake",[p,e,i.paired.address,t,a,BigInt(b/10),I]),v(i.log,e,!1),A.push({token:i.paired,min:-t,max:-a}),w(i.staking,m),k=`Farm up to ${e} log + ${t} paired base units; slippage ${b} bps; deadline ${I}. Staked LP minimum ${m} is checked in simulation; two-sided token minimums from slippage are enforced on chain. Paired consumption must also meet ${a} base units in the preview. This tool does not zap; the helper's paired minimum alone has no on-chain effect for a direct pair.`}else if(o==="chop_unfarm"){await L(u,r.helper,s);let e=c(n.amount),t=c(n.minLogOut),a=c(n.minPairedOut),m=await V(u,n.deadline,i);if(x(await $(u,i.staking.address,"withdrawableStake",[d],s))<e)throw new h("Chop stake is still locked or too small. Wait at least 10 minutes after staking.");C(i.staking,r.helper.address,e),P(r.helper.address,"unstakeAndRemoveLP",[p,e,t,a,m]),v(i.staking,e),w(i.log,t),w(i.paired,a),k=`Unfarm ${e} staked LP base units; on-chain minimums ${t} log and ${a} paired base units; deadline ${m}.`}else{if(await L(u,r.whitelist,s),await $(u,r.whitelist.address,"paused",[r.chop],s)!==!1)throw new h("Chop rewards are paused or their pause state is unavailable.");let e=x(await $(u,i.rewards,"getClaimable",[r.chop,d],s));if(e===0n)throw new h("No CHOP is claimable now. Rewards may still be inside the 10-minute maturity lock.");P(i.rewards,"claimReward",[d]),w({address:y(r.chop),symbol:"CHOP",decimals:18,chainId:4663},e),k=`Harvest at least ${e} CHOP base units to ${d} in the preview. ${H} Allow at least 1,000,000 gas for this call.`}return(o==="chop_farm"||o==="chop_unfarm")&&!A.some(e=>_(e.token.address,r.chop))&&w({address:y(r.chop),symbol:"CHOP",decimals:18,chainId:4663},0n),O(g,f),{built:g,expected:f,rules:A,details:k,facts:i,log:p}}async function ie(l,o,n,d){let{built:p,expected:u,rules:B,details:i,facts:s,log:f}=await D(l,o,n,d),g=await l.preview(p,d);return O(g.txs,u,!0),U(g,B),{txs:p,preview:g,log:f,measuredAtBlock:s.measuredAtBlock,summary:`${R(s)}
1
+ import{d as F,e as M}from"./KOKLM63Q.js";import{g as H,j as R}from"./ETMD747Y.js";import{a as y,b as x,c,f as $,j as L,l as S,m as O,n as U}from"./K4GUZ5QS.js";import{a as N}from"./K6D6SDIG.js";import{a as r}from"./L2AE32SL.js";import{c as q}from"./43LI5NKJ.js";import{g as _}from"./NWNYJ26T.js";import{a as h}from"./XSD5NL7J.js";import{encodeFunctionData as W}from"viem";var j={chop_wrap:["log","underlying","amount","minLogOut"],chop_unwrap:["log","amount","quotedNet"],chop_farm:["log","amount","pairedAmount","minPaired","minStakedLp","slippageBps","deadline"],chop_unfarm:["log","amount","minLogOut","minPairedOut","deadline"],chop_harvest:["log"]};function z(l,o){if(Object.keys(l).some(n=>!o.includes(n)))throw new h("Unexpected Chop argument.");if(o.some(n=>l[n]===void 0))throw new h("Provide every required Chop input.")}async function V(l,o,n){let d=c(o),p=await l.getBlock({blockNumber:BigInt(n.measuredAtBlock)});if(p.number!==BigInt(n.measuredAtBlock)||d<=x(p.timestamp)||d>p.timestamp+1200n)throw new h("Chop deadline must be in the next 20 minutes.");return d}async function D(l,o,n,d){if(z(n,j[o]),y(d),l.network==="testnet")throw new h("Chop requires chain 4663.");let p=y(n.log),u=l.clientFor(4663),i=await S(u,p,o==="chop_wrap"||o==="chop_farm"?"enter":"exit"),s=BigInt(i.measuredAtBlock),f=[],g=[],C=(e,t,a)=>{f.push(q(e.address,t,a.toString(),4663)),g.push(l.approval(e.address,t,a.toString(),4663))},P=(e,t,a)=>{let m={to:e,data:W({abi:N,functionName:t,args:a}),value:"0",chainId:4663,description:`${o} on verified log ${p}.`,...o==="chop_harvest"?{gasLimit:"1000000"}:{}};f.push(m),g.push({...l.unsignedTx(m),...m.gasLimit===void 0?{}:{gasLimit:m.gasLimit}})},A=[],v=(e,t,a=!0)=>A.push({token:e,min:-t,max:a?-t:-1n}),w=(e,t)=>A.push({token:e,min:t}),T=async(e,t)=>{if(x(await $(u,e.address,"balanceOf",[d],s))<t)throw new h("This wallet does not hold enough tokens for the Chop action.")},k;if(o==="chop_wrap"){let e=c(n.amount),t=c(n.minLogOut);if(!_(y(n.underlying),i.underlying.address))throw new h("The underlying token does not match the verified Chop log.");await T(i.underlying,e),C(i.underlying,p,e),P(p,"bond",[i.underlying.address,e,t]),v(i.underlying,e,!1),w(i.log,t),k=`Wrap at most ${e} underlying base units; on-chain minimum ${t} log base units.`}else if(o==="chop_unwrap"){let e=c(n.amount),t=c(n.quotedNet);await T(i.log,e);let a=await M(u,i,d,e);if(BigInt(a.net.amount)<t)throw new h("Chop unwrap no longer meets the quoted net amount. Request a fresh quote.");let m=F(i,e);f.push(m),g.push(l.unsignedTx(m)),v(i.log,e),w(i.underlying,t),k=`Unwrap ${e} log base units; preview must return at least quoted ${t} underlying base units.`}else if(o==="chop_farm"){await L(u,r.helper,s);let e=c(n.amount),t=c(n.pairedAmount),a=c(n.minPaired),m=c(n.minStakedLp),I=await V(u,n.deadline,i),b=n.slippageBps;if(typeof b!="number"||!Number.isInteger(b)||b<0||b>1e3||b%10!==0||a>t)throw new h("Chop LP slippage must be 0\u20131000 basis points in multiples of 10; the paired minimum cannot exceed its input.");await Promise.all([T(i.log,e),T(i.paired,t)]),C(i.log,r.helper.address,e),C(i.paired,r.helper.address,t),P(r.helper.address,"addLPAndStake",[p,e,i.paired.address,t,a,BigInt(b/10),I]),v(i.log,e,!1),A.push({token:i.paired,min:-t,max:-a}),w(i.staking,m),k=`Farm up to ${e} log + ${t} paired base units; slippage ${b} bps; deadline ${I}. Staked LP minimum ${m} is checked in simulation; two-sided token minimums from slippage are enforced on chain. Paired consumption must also meet ${a} base units in the preview. This tool does not zap; the helper's paired minimum alone has no on-chain effect for a direct pair.`}else if(o==="chop_unfarm"){await L(u,r.helper,s);let e=c(n.amount),t=c(n.minLogOut),a=c(n.minPairedOut),m=await V(u,n.deadline,i);if(x(await $(u,i.staking.address,"withdrawableStake",[d],s))<e)throw new h("Chop stake is still locked or too small. Wait at least 10 minutes after staking.");C(i.staking,r.helper.address,e),P(r.helper.address,"unstakeAndRemoveLP",[p,e,t,a,m]),v(i.staking,e),w(i.log,t),w(i.paired,a),k=`Unfarm ${e} staked LP base units; on-chain minimums ${t} log and ${a} paired base units; deadline ${m}.`}else{if(await L(u,r.whitelist,s),await $(u,r.whitelist.address,"paused",[r.chop],s)!==!1)throw new h("Chop rewards are paused or their pause state is unavailable.");let e=x(await $(u,i.rewards,"getClaimable",[r.chop,d],s));if(e===0n)throw new h("No CHOP is claimable now. Rewards may still be inside the 10-minute maturity lock.");P(i.rewards,"claimReward",[d]),w({address:y(r.chop),symbol:"CHOP",decimals:18,chainId:4663},e),k=`Harvest at least ${e} CHOP base units to ${d} in the preview. ${H} Allow at least 1,000,000 gas for this call.`}return(o==="chop_farm"||o==="chop_unfarm")&&!A.some(e=>_(e.token.address,r.chop))&&w({address:y(r.chop),symbol:"CHOP",decimals:18,chainId:4663},0n),O(g,f),{built:g,expected:f,rules:A,details:k,facts:i,log:p}}async function ie(l,o,n,d){let{built:p,expected:u,rules:B,details:i,facts:s,log:f}=await D(l,o,n,d),g=await l.preview(p,d);return O(g.txs,u,!0),U(g,B),{txs:p,preview:g,log:f,measuredAtBlock:s.measuredAtBlock,summary:`${R(s)}
2
2
  ${i}
3
3
  Underlying ${s.underlying.address} (decimals ${s.underlying.decimals}); log ${f} (decimals ${s.log.decimals}); paired ${s.paired.address} (decimals ${s.paired.decimals}).`}}export{j as a,z as b,D as c,ie as d};
@@ -0,0 +1 @@
1
+ import{c as t}from"./LCH6F5HT.js";import{c as o}from"./W7QNSNOH.js";function s(e,n,a){return t(e,n,a,o)}export{s as a};
@@ -0,0 +1 @@
1
+ import{g as t}from"./NWNYJ26T.js";import{b as x,j as b,n as C}from"./TI727O2H.js";import{a as s}from"./XSD5NL7J.js";import{decodeAbiParameters as y,decodeFunctionData as q,encodeAbiParameters as f,encodeFunctionData as J,getAddress as U,parseAbi as Q,parseAbiParameters as A,zeroAddress as g}from"viem";var Y=U(b[x].ponsTrade.universal_router.address),ie=U(b[x].ponsTrade.permit2.address),H="0x0Af57F62982D03066ef917AcAd87F771c06528Ec",ae=Object.freeze({pons:U(C),fobo:H}),Z=Object.freeze({currency0:g,currency1:U(b[x].tokens.USDG.address),fee:500,tickSpacing:10,hooks:g}),ce=Object.freeze([H,g]),M=Q(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),L=A("bytes,bytes[]"),X=A("((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 amountIn,uint128 amountOutMinimum,uint256 minHopPriceX36,bytes hookData)"),j=A("(address currencyIn,(address intermediateCurrency,uint24 fee,int24 tickSpacing,address hooks,bytes hookData)[] path,uint256[] minHopPriceX36,uint128 amountIn,uint128 amountOutMinimum)"),R=A("address,uint256"),G=A("((address token,uint160 amount,uint48 expiration,uint48 nonce) details,address spender,uint256 sigDeadline),bytes"),ee="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",I="Universal Router calldata must be one canonical v4 swap command, optionally after one Permit2 permit.",h="Universal Router actions must swap an exact input, settle it and take all output to the sender.",E="Universal Router settlement and receipt must match the swap.",W="Universal Router swap must carry no hook data or per-hop price limit.",te="Universal Router permit must cover the swap input token and name the Universal Router as spender.";function ue(o){return t(o,ee)?g:o}function m(o,n,a,l){let u;try{if(u=o(),t(n(u),a))return u}catch{}throw new s(l)}function le(o,n){let a=m(()=>q({abi:M,data:o}),e=>J({abi:M,...e}),o,I),[l,u,$]=a.args,P=t(l,"0x0a10");if(!P&&!t(l,"0x10")||u.length!==(P?2:1))throw new s(I);let K=u.at(-1),[T,c]=m(()=>y(L,K),e=>f(L,e),K,h),_=t(T,"0x060c0f");if(!_&&!t(T,"0x070c0f")||c.length!==3)throw new s(h);let S,d,O,w,k;if(_){let[e]=m(()=>y(X,c[0]),F=>f(X,F),c[0],h);if(e.hookData!=="0x"||e.minHopPriceX36!==0n)throw new s(W);let{currency0:r,currency1:i,fee:p,tickSpacing:v,hooks:D}=e.poolKey;S=[{poolKey:{currency0:r,currency1:i,fee:p,tickSpacing:v,hooks:D},zeroForOne:e.zeroForOne}],[d,O]=e.zeroForOne?[r,i]:[i,r],{amountIn:w,amountOutMinimum:k}=e}else{let[e]=m(()=>y(j,c[0]),i=>f(j,i),c[0],h);if(e.path.length<2)throw new s(h);if(e.minHopPriceX36.length!==0||e.path.some(i=>i.hookData!=="0x"))throw new s(W);let r=e.currencyIn;S=e.path.map(i=>{let p=i.intermediateCurrency;if(t(r,p))throw new s(h);let[v,D]=BigInt(r)<BigInt(p)?[r,p]:[p,r],F={poolKey:{currency0:v,currency1:D,fee:i.fee,tickSpacing:i.tickSpacing,hooks:i.hooks},zeroForOne:t(r,v)};return r=p,F}),d=e.currencyIn,O=r,{amountIn:w,amountOutMinimum:k}=e}if(w<=0n)throw new s("Universal Router swap input must be a positive exact amount.");if(t(d,O))throw new s("Universal Router swap must end in a different currency than it starts.");for(let{poolKey:e}of S)if(!n.some(r=>t(r,e.hooks)))throw new s(`Universal Router swap uses pool hook ${e.hooks}, which this route does not allow.`);let N=m(()=>y(R,c[1]),e=>f(R,e),c[1],E),z=m(()=>y(R,c[2]),e=>f(R,e),c[2],E);if(!t(N[0],d)||N[1]!==w||!t(z[0],O)||z[1]!==k)throw new s(E);let B={legs:S,currencyIn:d,currencyOut:O,amountIn:w,amountOutMinimum:k,deadline:$};if(P){let[e,r]=m(()=>y(G,u[0]),i=>f(G,i),u[0],I);if(t(d,g)||!t(e.details.token,d)||!t(e.spender,Y))throw new s(te);B.permit={...e.details,spender:e.spender,sigDeadline:e.sigDeadline,signature:r}}return B}function V(o,n){return t(o.currency0,n.currency0)&&t(o.currency1,n.currency1)&&o.fee===n.fee&&o.tickSpacing===n.tickSpacing&&t(o.hooks,n.hooks)}function de(o,n){return o.length===n.length&&o.every((a,l)=>V(a.poolKey,n[l].poolKey)&&a.zeroForOne===n[l].zeroForOne)}var pe=1200,me=1800;function ye(o){let n=0;for(let{poolKey:a}of o.legs)if(t(a.hooks,H))n++;else if(!V(a,Z))throw new s("Swap leaves the FOBO route: every pool must be a FoboHook pool or FOBO's ETH/USDG pool.");if(n===0)throw new s("Swap is not a FOBO route: it uses no FoboHook pool.")}export{Y as a,ie as b,H as c,ae as d,Z as e,ce as f,ue as g,le as h,V as i,de as j,pe as k,me as l,ye as m};
@@ -1 +1 @@
1
- import{k as s}from"./U2YCQWZK.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{m as s}from"./NV6FDIYT.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 +1 @@
1
- import{a as y,b as R,c as S,f as d,g as b,h as O,i as $,j as T,k,l as V}from"./PV5FDT6O.js";import{c as j}from"./SCG5HWMN.js";import{c as h,e as C,g as A}from"./NWNYJ26T.js";import{a as P}from"./FWD4L3CJ.js";import{a as r}from"./XSD5NL7J.js";import{concat as U,encodeAbiParameters as H,encodeFunctionData as E,keccak256 as M,parseAbi as F,parseAbiParameters as q}from"viem";var _=F(["function allocation(address) view returns (address token,uint256 amountTotal,uint256 amountClaimed,uint256 lockupEndTime,uint256 vestingEndTime,address admin)","function amountAvailableToClaim(address) view returns (uint256)","function claim(address)","function editAllocationAdmin(address,address)"]),D=F(["function airdrops(address) view returns (address admin,bytes32 merkleRoot,uint256 totalSupply,uint256 totalClaimed,uint256 lockupEndTime,uint256 vestingEndTime,uint256 adminClaimTime,bool adminClaimed)","function amountAvailableToClaim(address,address,uint256) view returns (uint256)","function claim(address,address,uint256,bytes32[])","function updateAdmin(address,address)","function updateMerkleRoot(address,bytes32)","function adminClaim(address,address)"]),L={bps:{type:"integer",minimum:1,maximum:9e3,description:"Share of the token supply sent to this extension, in basis points (1000 = 10%). Vault and airdrop together may not exceed 9000."},admin:{...h,description:"Address that administers this allocation. Defaults to the launching wallet."},lockupDuration:{...R,description:"Lockup before anything can be claimed, in seconds, as a decimal string (604800 = 7 days; airdrop minimum 86400 = 1 day)."},vestingDuration:{...R,description:"Linear vesting period after the lockup ends, in seconds, as a decimal string (0 = fully unlocked at lockup end)."}},W={vault:{type:"object",properties:L,required:["bps","lockupDuration","vestingDuration"],additionalProperties:!1},airdrop:{type:"object",properties:{...L,merkleRoot:{...S,description:"Merkle root of the airdrop allocations, as 0x followed by 64 hex digits (from clanker_airdrop_tree)."}},required:["bps","lockupDuration","vestingDuration","merkleRoot"],additionalProperties:!1}};function X(m,f){let g=[];for(let p of["vault","airdrop"]){let l=m[p];if(l===void 0)continue;if(!C(l))throw new r(`Provide ${p} configuration as an object.`);$(l,["bps","admin","lockupDuration","vestingDuration",...p==="airdrop"?["merkleRoot"]:[]]);let w=d(l.admin??f),v=b(l.lockupDuration),e=b(l.vestingDuration);if(v<BigInt(p==="vault"?604800:86400))throw new r(`${p} lockup is below the contract minimum.`);if(v+e+1209600n>=1n<<256n)throw new r("Extension duration exceeds uint256.");g.push({extension:y[p].address,msgValue:0n,extensionBps:O(l.bps,1,9e3),extensionData:p==="vault"?H(q("(address,uint256,uint256)"),[[w,v,e]]):H(q("(address,bytes32,uint256,uint256)"),[[w,T(l.merkleRoot),v,e]])})}if(g.reduce((p,l)=>p+l.extensionBps,0)>9e3)throw new r("Extensions must leave at least 10% of supply for liquidity.");return g}function N(m,f){return M(M(H(q("address,uint256"),[m,f])))}function I(m,f){return M(U(BigInt(m)<BigInt(f)?[m,f]:[f,m]))}var Z=m=>{let f=()=>m.clientFor(P),g=async(e,t)=>{if(!(await V(m,e)).extensions.some(a=>A(a,y[t].address)))throw new r(`This token has no verified Clanker ${t} extension.`)},p=async e=>{await g(e,"vault");let t=await f().readContract({address:y.vault.address,abi:_,functionName:"allocation",args:[e]});if(!Array.isArray(t)||t.length!==6||!A(d(t[0]),e))throw new r("Clanker returned an invalid vault allocation.");return{token:e,amountTotal:k(t[1]),amountClaimed:k(t[2]),lockupEndTime:k(t[3]),vestingEndTime:k(t[4]),admin:d(t[5]),claimable:k(await f().readContract({address:y.vault.address,abi:_,functionName:"amountAvailableToClaim",args:[e]}))}},l=async e=>{await g(e,"airdrop");let t=await f().readContract({address:y.airdrop.address,abi:D,functionName:"airdrops",args:[e]});if(!Array.isArray(t)||t.length!==8||typeof t[7]!="boolean")throw new r("Clanker returned invalid airdrop state.");return{token:e,admin:d(t[0]),merkleRoot:T(t[1]),totalSupply:k(t[2]),totalClaimed:k(t[3]),lockupEndTime:k(t[4]),vestingEndTime:k(t[5]),adminClaimTime:k(t[6]),adminClaimed:t[7]}},w=(e,t,o,a)=>({name:`clanker_${e}`,inputSchema:{type:"object",properties:t,required:o,additionalProperties:!1},execute:async(s,n)=>{try{return $(s,Object.keys(t)),await a(s,d(n))}catch(i){throw new r(m.plainError(i))}}}),v=async(e,t,o,a)=>{let s=[m.unsignedTx({to:e,data:t,chainId:P,value:"0",description:o})],n=await m.preview(s,a);return{txs:s,preview:n,summary:`${o} ${n.summary}`}};return{tools:[w("airdrop_proofs",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."}},["token"],async(e,t)=>{let o=d(e.token),a=await l(o),s=new URL("https://www.clanker.world/api/airdrops/claim");s.searchParams.set("tokenAddress",o),s.searchParams.set("claimerAddress",t);let i=(await j(m.http,s.toString(),{method:"GET"},u=>C(u)&&Array.isArray(u.proofs))).proofs;if(i.length>200)throw new r("Clanker returned too many airdrop proofs.");let c=i.map(u=>{if(!C(u)||!C(u.entry)||!Array.isArray(u.proof)||u.proof.length>64||!A(d(u.entry.account),t))throw new r("Clanker returned invalid airdrop proofs.");let x=b(u.entry.amount),B=u.proof.map(T);if(!x||!A(B.reduce(I,N(t,x)),a.merkleRoot))throw new r("The indexed airdrop proof does not match the active onchain root.");return{allocatedAmount:x.toString(),proof:B}});return{token:o,chainId:P,recipient:t,proofs:c,summary:"Verified against the onchain airdrop root. An empty indexer response does not prove ineligibility; use saved allocation proofs if the tree was not published."}}),w("vault_status",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."}},["token"],e=>p(d(e.token))),w("vault_claim",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."}},["token"],async(e,t)=>{let o=d(e.token),a=await p(o);if(a.claimable==="0")throw new r("No vested Clanker tokens are available to claim.");return v(y.vault.address,E({abi:_,functionName:"claim",args:[o]}),`Claim ${a.claimable} base units of ${o} (18 decimals) to vault admin ${a.admin}.`,t)}),w("vault_update_admin",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."},admin:{...h,description:"Address of the new vault administrator, who then receives all future claims."}},["token","admin"],async(e,t)=>{let o=d(e.token),a=await p(o);if(!A(a.admin,t))throw new r("Only the vault administrator can transfer its allocation.");return v(y.vault.address,E({abi:_,functionName:"editAllocationAdmin",args:[o,d(e.admin)]}),`Transfer all future Clanker vault claims for ${o} to ${d(e.admin)}.`,t)}),w("airdrop_tree",{allocations:{type:"array",minItems:1,maxItems:200,description:"Airdrop recipients and amounts, 1 to 200 rows with unique recipients. Returns the Merkle root and each proof.",items:{type:"object",properties:{recipient:{...h,description:"Address of the wallet eligible to claim this allocation."},amount:{...R,description:'Amount of the launched token allocated to this recipient, in base units (Clanker tokens have 18 decimals). Example: "1000000000000000000" = 1 token.'}},required:["recipient","amount"],additionalProperties:!1}}},["allocations"],async e=>{if(!Array.isArray(e.allocations)||!e.allocations.length||e.allocations.length>200)throw new r("Provide 1 to 200 airdrop allocations.");let t=new Set,o=e.allocations.map(n=>{if(!C(n))throw new r("Provide allocation objects.");$(n,["recipient","amount"]);let i=d(n.recipient),c=b(n.amount);if(!c||t.has(i))throw new r("Airdrop allocations require positive amounts and unique recipients.");return t.add(i),{recipient:i,amount:c.toString(),hash:N(i,c)}}).sort((n,i)=>n.hash.localeCompare(i.hash)),a=[o.map(n=>n.hash)];for(;a.at(-1).length>1;){let n=a.at(-1),i=[];for(let c=0;c<n.length;c+=2)i.push(c+1<n.length?I(n[c],n[c+1]):n[c]);a.push(i)}let s=o.reduce((n,i)=>n+BigInt(i.amount),0n);if(s>=1n<<256n)throw new r("Airdrop total exceeds uint256.");return{merkleRoot:a.at(-1)[0],total:s.toString(),allocations:o.map((n,i)=>{let c=[],u=i;for(let x of a.slice(0,-1))x[u^1]&&c.push(x[u^1]),u=Math.floor(u/2);return{recipient:n.recipient,amount:n.amount,proof:c}}),summary:"Double-hashed ABI(address,uint256) leaves; sorted hash pairs. Save these public proofs. Allocations are token base units, 18 decimals; match their total to the launch extension supply."}}),w("airdrop_status",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."},allocatedAmount:{...R,description:'Optional: your allocation in the airdrop tree, in base units (Clanker tokens have 18 decimals). Example: "1000000000000000000" = 1 token. Adds the claimable amount to the result.'}},["token"],async(e,t)=>{let o=d(e.token);return{...await l(o),...e.allocatedAmount===void 0?{}:{claimable:k(await f().readContract({address:y.airdrop.address,abi:D,functionName:"amountAvailableToClaim",args:[o,t,b(e.allocatedAmount)]}))}}}),w("airdrop_claim",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."},allocatedAmount:{...R,description:'Your full allocation in the airdrop tree, in base units (Clanker tokens have 18 decimals). Example: "1000000000000000000" = 1 token.'},proof:{type:"array",maxItems:64,description:"Merkle proof for your wallet and allocation, as 0x-prefixed 32-byte hex strings (from clanker_airdrop_proofs).",items:S}},["token","allocatedAmount","proof"],async(e,t)=>{let o=d(e.token),a=await l(o),s=b(e.allocatedAmount);if(!s||!Array.isArray(e.proof)||e.proof.length>64)throw new r("Provide a positive allocation and Merkle proof.");let n=e.proof.map(T),i=n.reduce(I,N(t,s));if(!A(i,a.merkleRoot))throw new r("The airdrop proof does not match the active root for this wallet and allocation.");return v(y.airdrop.address,E({abi:D,functionName:"claim",args:[o,t,s,n]}),`Claim vested allocation of ${s} base units of ${o} (18 decimals) to ${t}. Preview determines currently unlocked receipts.`,t)}),w("airdrop_manage",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."},operation:{enum:["admin","root","reclaim"],description:"admin: hand administration to a new address (give admin); root: replace the Merkle root (give merkleRoot); reclaim: send unclaimed tokens to recipient and close claims."},admin:{...h,description:"New airdrop administrator address, for operation admin."},merkleRoot:{...S,description:"New Merkle root as 0x followed by 64 hex digits, for operation root."},recipient:{...h,description:"Address that receives the reclaimed tokens, for operation reclaim."}},["token","operation"],async(e,t)=>{let o=d(e.token),a=await l(o);if(!A(a.admin,t))throw new r("Only the airdrop administrator may manage it.");let s=e.operation==="admin"?"admin":e.operation==="root"?"merkleRoot":"recipient";for(let i of["admin","merkleRoot","recipient"])if(e[i]!==void 0&&i!==s)throw new r(`Input ${i} does not match this airdrop operation.`);let n;if(e.operation==="admin")n=E({abi:D,functionName:"updateAdmin",args:[o,d(e.admin)]});else if(e.operation==="root")n=E({abi:D,functionName:"updateMerkleRoot",args:[o,T(e.merkleRoot)]});else if(e.operation==="reclaim")n=E({abi:D,functionName:"adminClaim",args:[o,d(e.recipient)]});else throw new r("Choose admin, root or reclaim.");return v(y.airdrop.address,n,`Clanker airdrop ${String(e.operation)} for ${o}; ${String(e.admin??e.merkleRoot??e.recipient)}. Reclaim permanently closes recipient claims; contract timing and zero-claim guards apply.`,t)})]}};export{W as a,X as b,Z as c};
1
+ import{a as y,b as R,c as S,f as d,g as b,h as O,i as $,j as T,k,l as V}from"./TXGZ6NWN.js";import{c as j}from"./SCG5HWMN.js";import{c as h,e as C,g as A}from"./NWNYJ26T.js";import{b as P}from"./TI727O2H.js";import{a as r}from"./XSD5NL7J.js";import{concat as U,encodeAbiParameters as H,encodeFunctionData as E,keccak256 as M,parseAbi as F,parseAbiParameters as q}from"viem";var _=F(["function allocation(address) view returns (address token,uint256 amountTotal,uint256 amountClaimed,uint256 lockupEndTime,uint256 vestingEndTime,address admin)","function amountAvailableToClaim(address) view returns (uint256)","function claim(address)","function editAllocationAdmin(address,address)"]),D=F(["function airdrops(address) view returns (address admin,bytes32 merkleRoot,uint256 totalSupply,uint256 totalClaimed,uint256 lockupEndTime,uint256 vestingEndTime,uint256 adminClaimTime,bool adminClaimed)","function amountAvailableToClaim(address,address,uint256) view returns (uint256)","function claim(address,address,uint256,bytes32[])","function updateAdmin(address,address)","function updateMerkleRoot(address,bytes32)","function adminClaim(address,address)"]),L={bps:{type:"integer",minimum:1,maximum:9e3,description:"Share of the token supply sent to this extension, in basis points (1000 = 10%). Vault and airdrop together may not exceed 9000."},admin:{...h,description:"Address that administers this allocation. Defaults to the launching wallet."},lockupDuration:{...R,description:"Lockup before anything can be claimed, in seconds, as a decimal string (604800 = 7 days; airdrop minimum 86400 = 1 day)."},vestingDuration:{...R,description:"Linear vesting period after the lockup ends, in seconds, as a decimal string (0 = fully unlocked at lockup end)."}},W={vault:{type:"object",properties:L,required:["bps","lockupDuration","vestingDuration"],additionalProperties:!1},airdrop:{type:"object",properties:{...L,merkleRoot:{...S,description:"Merkle root of the airdrop allocations, as 0x followed by 64 hex digits (from clanker_airdrop_tree)."}},required:["bps","lockupDuration","vestingDuration","merkleRoot"],additionalProperties:!1}};function X(m,f){let g=[];for(let p of["vault","airdrop"]){let l=m[p];if(l===void 0)continue;if(!C(l))throw new r(`Provide ${p} configuration as an object.`);$(l,["bps","admin","lockupDuration","vestingDuration",...p==="airdrop"?["merkleRoot"]:[]]);let w=d(l.admin??f),v=b(l.lockupDuration),e=b(l.vestingDuration);if(v<BigInt(p==="vault"?604800:86400))throw new r(`${p} lockup is below the contract minimum.`);if(v+e+1209600n>=1n<<256n)throw new r("Extension duration exceeds uint256.");g.push({extension:y[p].address,msgValue:0n,extensionBps:O(l.bps,1,9e3),extensionData:p==="vault"?H(q("(address,uint256,uint256)"),[[w,v,e]]):H(q("(address,bytes32,uint256,uint256)"),[[w,T(l.merkleRoot),v,e]])})}if(g.reduce((p,l)=>p+l.extensionBps,0)>9e3)throw new r("Extensions must leave at least 10% of supply for liquidity.");return g}function N(m,f){return M(M(H(q("address,uint256"),[m,f])))}function I(m,f){return M(U(BigInt(m)<BigInt(f)?[m,f]:[f,m]))}var Z=m=>{let f=()=>m.clientFor(P),g=async(e,t)=>{if(!(await V(m,e)).extensions.some(a=>A(a,y[t].address)))throw new r(`This token has no verified Clanker ${t} extension.`)},p=async e=>{await g(e,"vault");let t=await f().readContract({address:y.vault.address,abi:_,functionName:"allocation",args:[e]});if(!Array.isArray(t)||t.length!==6||!A(d(t[0]),e))throw new r("Clanker returned an invalid vault allocation.");return{token:e,amountTotal:k(t[1]),amountClaimed:k(t[2]),lockupEndTime:k(t[3]),vestingEndTime:k(t[4]),admin:d(t[5]),claimable:k(await f().readContract({address:y.vault.address,abi:_,functionName:"amountAvailableToClaim",args:[e]}))}},l=async e=>{await g(e,"airdrop");let t=await f().readContract({address:y.airdrop.address,abi:D,functionName:"airdrops",args:[e]});if(!Array.isArray(t)||t.length!==8||typeof t[7]!="boolean")throw new r("Clanker returned invalid airdrop state.");return{token:e,admin:d(t[0]),merkleRoot:T(t[1]),totalSupply:k(t[2]),totalClaimed:k(t[3]),lockupEndTime:k(t[4]),vestingEndTime:k(t[5]),adminClaimTime:k(t[6]),adminClaimed:t[7]}},w=(e,t,o,a)=>({name:`clanker_${e}`,inputSchema:{type:"object",properties:t,required:o,additionalProperties:!1},execute:async(s,n)=>{try{return $(s,Object.keys(t)),await a(s,d(n))}catch(i){throw new r(m.plainError(i))}}}),v=async(e,t,o,a)=>{let s=[m.unsignedTx({to:e,data:t,chainId:P,value:"0",description:o})],n=await m.preview(s,a);return{txs:s,preview:n,summary:`${o} ${n.summary}`}};return{tools:[w("airdrop_proofs",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."}},["token"],async(e,t)=>{let o=d(e.token),a=await l(o),s=new URL("https://www.clanker.world/api/airdrops/claim");s.searchParams.set("tokenAddress",o),s.searchParams.set("claimerAddress",t);let i=(await j(m.http,s.toString(),{method:"GET"},u=>C(u)&&Array.isArray(u.proofs))).proofs;if(i.length>200)throw new r("Clanker returned too many airdrop proofs.");let c=i.map(u=>{if(!C(u)||!C(u.entry)||!Array.isArray(u.proof)||u.proof.length>64||!A(d(u.entry.account),t))throw new r("Clanker returned invalid airdrop proofs.");let x=b(u.entry.amount),B=u.proof.map(T);if(!x||!A(B.reduce(I,N(t,x)),a.merkleRoot))throw new r("The indexed airdrop proof does not match the active onchain root.");return{allocatedAmount:x.toString(),proof:B}});return{token:o,chainId:P,recipient:t,proofs:c,summary:"Verified against the onchain airdrop root. An empty indexer response does not prove ineligibility; use saved allocation proofs if the tree was not published."}}),w("vault_status",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."}},["token"],e=>p(d(e.token))),w("vault_claim",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."}},["token"],async(e,t)=>{let o=d(e.token),a=await p(o);if(a.claimable==="0")throw new r("No vested Clanker tokens are available to claim.");return v(y.vault.address,E({abi:_,functionName:"claim",args:[o]}),`Claim ${a.claimable} base units of ${o} (18 decimals) to vault admin ${a.admin}.`,t)}),w("vault_update_admin",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."},admin:{...h,description:"Address of the new vault administrator, who then receives all future claims."}},["token","admin"],async(e,t)=>{let o=d(e.token),a=await p(o);if(!A(a.admin,t))throw new r("Only the vault administrator can transfer its allocation.");return v(y.vault.address,E({abi:_,functionName:"editAllocationAdmin",args:[o,d(e.admin)]}),`Transfer all future Clanker vault claims for ${o} to ${d(e.admin)}.`,t)}),w("airdrop_tree",{allocations:{type:"array",minItems:1,maxItems:200,description:"Airdrop recipients and amounts, 1 to 200 rows with unique recipients. Returns the Merkle root and each proof.",items:{type:"object",properties:{recipient:{...h,description:"Address of the wallet eligible to claim this allocation."},amount:{...R,description:'Amount of the launched token allocated to this recipient, in base units (Clanker tokens have 18 decimals). Example: "1000000000000000000" = 1 token.'}},required:["recipient","amount"],additionalProperties:!1}}},["allocations"],async e=>{if(!Array.isArray(e.allocations)||!e.allocations.length||e.allocations.length>200)throw new r("Provide 1 to 200 airdrop allocations.");let t=new Set,o=e.allocations.map(n=>{if(!C(n))throw new r("Provide allocation objects.");$(n,["recipient","amount"]);let i=d(n.recipient),c=b(n.amount);if(!c||t.has(i))throw new r("Airdrop allocations require positive amounts and unique recipients.");return t.add(i),{recipient:i,amount:c.toString(),hash:N(i,c)}}).sort((n,i)=>n.hash.localeCompare(i.hash)),a=[o.map(n=>n.hash)];for(;a.at(-1).length>1;){let n=a.at(-1),i=[];for(let c=0;c<n.length;c+=2)i.push(c+1<n.length?I(n[c],n[c+1]):n[c]);a.push(i)}let s=o.reduce((n,i)=>n+BigInt(i.amount),0n);if(s>=1n<<256n)throw new r("Airdrop total exceeds uint256.");return{merkleRoot:a.at(-1)[0],total:s.toString(),allocations:o.map((n,i)=>{let c=[],u=i;for(let x of a.slice(0,-1))x[u^1]&&c.push(x[u^1]),u=Math.floor(u/2);return{recipient:n.recipient,amount:n.amount,proof:c}}),summary:"Double-hashed ABI(address,uint256) leaves; sorted hash pairs. Save these public proofs. Allocations are token base units, 18 decimals; match their total to the launch extension supply."}}),w("airdrop_status",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."},allocatedAmount:{...R,description:'Optional: your allocation in the airdrop tree, in base units (Clanker tokens have 18 decimals). Example: "1000000000000000000" = 1 token. Adds the claimable amount to the result.'}},["token"],async(e,t)=>{let o=d(e.token);return{...await l(o),...e.allocatedAmount===void 0?{}:{claimable:k(await f().readContract({address:y.airdrop.address,abi:D,functionName:"amountAvailableToClaim",args:[o,t,b(e.allocatedAmount)]}))}}}),w("airdrop_claim",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."},allocatedAmount:{...R,description:'Your full allocation in the airdrop tree, in base units (Clanker tokens have 18 decimals). Example: "1000000000000000000" = 1 token.'},proof:{type:"array",maxItems:64,description:"Merkle proof for your wallet and allocation, as 0x-prefixed 32-byte hex strings (from clanker_airdrop_proofs).",items:S}},["token","allocatedAmount","proof"],async(e,t)=>{let o=d(e.token),a=await l(o),s=b(e.allocatedAmount);if(!s||!Array.isArray(e.proof)||e.proof.length>64)throw new r("Provide a positive allocation and Merkle proof.");let n=e.proof.map(T),i=n.reduce(I,N(t,s));if(!A(i,a.merkleRoot))throw new r("The airdrop proof does not match the active root for this wallet and allocation.");return v(y.airdrop.address,E({abi:D,functionName:"claim",args:[o,t,s,n]}),`Claim vested allocation of ${s} base units of ${o} (18 decimals) to ${t}. Preview determines currently unlocked receipts.`,t)}),w("airdrop_manage",{token:{...h,description:"Address of the launched Clanker token (ERC-20) on chain 4663."},operation:{enum:["admin","root","reclaim"],description:"admin: hand administration to a new address (give admin); root: replace the Merkle root (give merkleRoot); reclaim: send unclaimed tokens to recipient and close claims."},admin:{...h,description:"New airdrop administrator address, for operation admin."},merkleRoot:{...S,description:"New Merkle root as 0x followed by 64 hex digits, for operation root."},recipient:{...h,description:"Address that receives the reclaimed tokens, for operation reclaim."}},["token","operation"],async(e,t)=>{let o=d(e.token),a=await l(o);if(!A(a.admin,t))throw new r("Only the airdrop administrator may manage it.");let s=e.operation==="admin"?"admin":e.operation==="root"?"merkleRoot":"recipient";for(let i of["admin","merkleRoot","recipient"])if(e[i]!==void 0&&i!==s)throw new r(`Input ${i} does not match this airdrop operation.`);let n;if(e.operation==="admin")n=E({abi:D,functionName:"updateAdmin",args:[o,d(e.admin)]});else if(e.operation==="root")n=E({abi:D,functionName:"updateMerkleRoot",args:[o,T(e.merkleRoot)]});else if(e.operation==="reclaim")n=E({abi:D,functionName:"adminClaim",args:[o,d(e.recipient)]});else throw new r("Choose admin, root or reclaim.");return v(y.airdrop.address,n,`Clanker airdrop ${String(e.operation)} for ${o}; ${String(e.admin??e.merkleRoot??e.recipient)}. Reclaim permanently closes recipient claims; contract timing and zero-claim guards apply.`,t)})]}};export{W as a,X as b,Z as c};
@@ -1 +1 @@
1
- import{a as U,b as N,c as _}from"./PXVREXCS.js";import{e as S}from"./RT7IU6TI.js";import{b as k,c as R}from"./GQYV4TFO.js";import{a as q,c as f,d as h,f as I,g as D}from"./2OKYXT25.js";import{g as B}from"./OUROA7XR.js";import{a as b,c as O}from"./43LI5NKJ.js";import{b as v}from"./66F5ZH34.js";import{a as A}from"./FWD4L3CJ.js";import{a as s}from"./XSD5NL7J.js";import{erc20Abi as $}from"viem";var K=a=>{function w(e,n){if(Object.keys(e).some(m=>!n.includes(m)))throw new s("Use only the inputs shown for this Pendle tool. YT and LP actions are not supported.")}function j(e){if(typeof e!="string"||!/^[0-9]+$/.test(e)||e.length>78)throw new s("Provide a positive decimal base-unit amount as a string.");return k(BigInt(e),!0)}function C(e,n){let m=e==="stable"?100:200,r=n===void 0?e==="stable"?50:100:n;if(typeof r!="number"||!Number.isInteger(r)||r<0)throw new s("Slippage must be a whole number of basis points.");if(r>m)throw new s(`Oak won't accept a price move that big. The most it allows is ${m/100}%.`);return r}async function y(e,n,m){w(n,["market","amount","slippageBps"]),f(h(m,a.wallet),"wallet does not match this request"),b(n.market);for(let r=0;r<2;r++){let t=await a.verify(n.market);f(h(t.market,n.market),"verified market does not match the request");let d=await a.client.getBlock();if(t.expired||d.timestamp>=BigInt(t.expiry))throw new s("This Pendle term has ended. Use pendle_redeem to cash out.");let p=C(t.kind,n.slippageBps),o=e==="sell"&&n.amount==="max"?k(await a.client.readContract({address:t.pt,abi:$,functionName:"balanceOf",args:[a.wallet],blockNumber:d.number}),!0):j(n.amount),i=e==="buy"?t.inputToken:t.pt,l=e==="buy"?t.pt:t.inputToken,u=await B(a.http,{inputToken:i,outputToken:l,amount:o,wallet:a.wallet,slippageBps:p}),c=(e==="buy"?I:D)(u.body,{market:t,wallet:a.wallet,amount:o,slippageBps:p});if(Math.abs(c.priceImpact)>.03)throw new s("This is a thin market and your size moves the price too much. Try a smaller amount.");if(Date.now()-u.receivedAt>3e4)continue;await R(a.client,t,e,o,c.amountOut,c.priceImpact);let T=Date.now()-u.receivedAt;if(T<0||T>3e4)continue;let x=e==="sell"?{wallet:a.wallet,market:t.market,pt:t.pt,outputToken:l,amountIn:o.toString(),amountOut:c.amountOut.toString(),minOut:c.minOut.toString(),ptDecimals:t.ptDecimals,outputDecimals:t.inputDecimals,endsAt:t.expiry,feeUsd:c.feeUsd,receivedAt:u.receivedAt,data:c.tx.data}:void 0;return{txs:[O(i,q,o.toString(),A),c.tx],...x?{pendleSellQuote:x}:{},summary:e==="buy"?"Approve the exact input amount, then buy Pendle PT.":"Approve the exact PT amount, then sell early at today\u2019s market price."}}throw new s("Pendle\u2019s quote became too old. Try again for a fresh price.")}async function M(e,n){w(e,["market","minOutBps"]),f(h(n,a.wallet),"wallet does not match this request");let m=U(e.minOutBps),r;if(e.market==="all")try{r=await S(a.client)}catch{throw new s("Oak could not read ended Pendle markets from the chain. Provide one ended market address to cash it out.")}else b(e.market),r=[e.market];let t=[];for(let o of r){let i=await a.verify(o);if(f(h(i.market,o),"verified market does not match the request"),e.market==="all"&&!i.expired)continue;let l=k(await a.client.readContract({address:i.pt,abi:$,functionName:"balanceOf",args:[a.wallet]}));l!==0n&&t.push({verified:i,balance:l})}if(t.length>1)throw new s(`Ended Pendle terms are cashed out one at a time. Run pendle_redeem with one of these market addresses: ${t.map(({verified:o})=>o.market).join(", ")}.`);let d=[],p=[];for(let{verified:o,balance:i}of t){let l=await N(a,o,i,m);d.push(...l.txs);let u=await _(a,o,i,l.expected,m);u&&p.push(u)}return{txs:d,summary:d.length?["Cash out ended Pendle PT balances to each market\u2019s input token.",...p].join(" "):"No PT balance in the selected ended Pendle terms."}}let g={type:"string",pattern:"^0x[0-9a-fA-F]{40}$",description:"Pendle market address returned by pendle_list."},P={type:"integer",minimum:0,maximum:200,description:"USDG: default 50, cap 100 bps. Stock tokens: default 100, cap 200 bps; the verified market determines the cap."};return[{name:"pendle_buy",inputSchema:{type:"object",properties:{market:g,amount:v("Positive decimal base units of the market input token; read its decimals first."),slippageBps:P},required:["market","amount"],additionalProperties:!1},execute:(e,n)=>y("buy",e,n)},{name:"pendle_sell",inputSchema:{type:"object",properties:{market:g,amount:{type:"string",anyOf:[{pattern:"^[0-9]+$"},{const:"max"}],description:"PT decimal base units, or max for the full PT balance."},slippageBps:P},required:["market","amount"],additionalProperties:!1},execute:(e,n)=>y("sell",e,n)},{name:"pendle_redeem",inputSchema:{type:"object",properties:{market:{type:"string",anyOf:[{pattern:"^0x[0-9a-fA-F]{40}$"},{const:"all"}],description:"Ended market address, or all ended markets held by this wallet."},minOutBps:{type:"integer",minimum:0,maximum:50,default:10,description:"Maximum reduction from the on-chain redemption estimate, in basis points."}},required:["market"],additionalProperties:!1},execute:M}]};export{K as a};
1
+ import{a as U,b as N,c as _}from"./XW3VGWXK.js";import{b as k,c as R}from"./2OVJ2BTJ.js";import{a as q,c as f,d as h,f as I,g as D}from"./GQITAJVF.js";import{g as B}from"./OUROA7XR.js";import{e as S}from"./NMJVQX5M.js";import{a as b,c as O}from"./43LI5NKJ.js";import{b as v}from"./66F5ZH34.js";import{b as A}from"./TI727O2H.js";import{a as s}from"./XSD5NL7J.js";import{erc20Abi as $}from"viem";var K=a=>{function w(e,n){if(Object.keys(e).some(m=>!n.includes(m)))throw new s("Use only the inputs shown for this Pendle tool. YT and LP actions are not supported.")}function j(e){if(typeof e!="string"||!/^[0-9]+$/.test(e)||e.length>78)throw new s("Provide a positive decimal base-unit amount as a string.");return k(BigInt(e),!0)}function C(e,n){let m=e==="stable"?100:200,r=n===void 0?e==="stable"?50:100:n;if(typeof r!="number"||!Number.isInteger(r)||r<0)throw new s("Slippage must be a whole number of basis points.");if(r>m)throw new s(`Oak won't accept a price move that big. The most it allows is ${m/100}%.`);return r}async function y(e,n,m){w(n,["market","amount","slippageBps"]),f(h(m,a.wallet),"wallet does not match this request"),b(n.market);for(let r=0;r<2;r++){let t=await a.verify(n.market);f(h(t.market,n.market),"verified market does not match the request");let d=await a.client.getBlock();if(t.expired||d.timestamp>=BigInt(t.expiry))throw new s("This Pendle term has ended. Use pendle_redeem to cash out.");let p=C(t.kind,n.slippageBps),o=e==="sell"&&n.amount==="max"?k(await a.client.readContract({address:t.pt,abi:$,functionName:"balanceOf",args:[a.wallet],blockNumber:d.number}),!0):j(n.amount),i=e==="buy"?t.inputToken:t.pt,l=e==="buy"?t.pt:t.inputToken,u=await B(a.http,{inputToken:i,outputToken:l,amount:o,wallet:a.wallet,slippageBps:p}),c=(e==="buy"?I:D)(u.body,{market:t,wallet:a.wallet,amount:o,slippageBps:p});if(Math.abs(c.priceImpact)>.03)throw new s("This is a thin market and your size moves the price too much. Try a smaller amount.");if(Date.now()-u.receivedAt>3e4)continue;await R(a.client,t,e,o,c.amountOut,c.priceImpact);let T=Date.now()-u.receivedAt;if(T<0||T>3e4)continue;let x=e==="sell"?{wallet:a.wallet,market:t.market,pt:t.pt,outputToken:l,amountIn:o.toString(),amountOut:c.amountOut.toString(),minOut:c.minOut.toString(),ptDecimals:t.ptDecimals,outputDecimals:t.inputDecimals,endsAt:t.expiry,feeUsd:c.feeUsd,receivedAt:u.receivedAt,data:c.tx.data}:void 0;return{txs:[O(i,q,o.toString(),A),c.tx],...x?{pendleSellQuote:x}:{},summary:e==="buy"?"Approve the exact input amount, then buy Pendle PT.":"Approve the exact PT amount, then sell early at today\u2019s market price."}}throw new s("Pendle\u2019s quote became too old. Try again for a fresh price.")}async function M(e,n){w(e,["market","minOutBps"]),f(h(n,a.wallet),"wallet does not match this request");let m=U(e.minOutBps),r;if(e.market==="all")try{r=await S(a.client)}catch{throw new s("Oak could not read ended Pendle markets from the chain. Provide one ended market address to cash it out.")}else b(e.market),r=[e.market];let t=[];for(let o of r){let i=await a.verify(o);if(f(h(i.market,o),"verified market does not match the request"),e.market==="all"&&!i.expired)continue;let l=k(await a.client.readContract({address:i.pt,abi:$,functionName:"balanceOf",args:[a.wallet]}));l!==0n&&t.push({verified:i,balance:l})}if(t.length>1)throw new s(`Ended Pendle terms are cashed out one at a time. Run pendle_redeem with one of these market addresses: ${t.map(({verified:o})=>o.market).join(", ")}.`);let d=[],p=[];for(let{verified:o,balance:i}of t){let l=await N(a,o,i,m);d.push(...l.txs);let u=await _(a,o,i,l.expected,m);u&&p.push(u)}return{txs:d,summary:d.length?["Cash out ended Pendle PT balances to each market\u2019s input token.",...p].join(" "):"No PT balance in the selected ended Pendle terms."}}let g={type:"string",pattern:"^0x[0-9a-fA-F]{40}$",description:"Pendle market address returned by pendle_list."},P={type:"integer",minimum:0,maximum:200,description:"USDG: default 50, cap 100 bps. Stock tokens: default 100, cap 200 bps; the verified market determines the cap."};return[{name:"pendle_buy",inputSchema:{type:"object",properties:{market:g,amount:v("Positive decimal base units of the market input token; read its decimals first."),slippageBps:P},required:["market","amount"],additionalProperties:!1},execute:(e,n)=>y("buy",e,n)},{name:"pendle_sell",inputSchema:{type:"object",properties:{market:g,amount:{type:"string",anyOf:[{pattern:"^[0-9]+$"},{const:"max"}],description:"PT decimal base units, or max for the full PT balance."},slippageBps:P},required:["market","amount"],additionalProperties:!1},execute:(e,n)=>y("sell",e,n)},{name:"pendle_redeem",inputSchema:{type:"object",properties:{market:{type:"string",anyOf:[{pattern:"^0x[0-9a-fA-F]{40}$"},{const:"all"}],description:"Ended market address, or all ended markets held by this wallet."},minOutBps:{type:"integer",minimum:0,maximum:50,default:10,description:"Maximum reduction from the on-chain redemption estimate, in basis points."}},required:["market"],additionalProperties:!1},execute:M}]};export{K as a};