@oakagentkit/core 0.1.2 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (576) hide show
  1. package/build/dist/api/addresses.d.ts +0 -1219
  2. package/build/dist/api/addresses.js +1 -1
  3. package/build/dist/api/amounts.d.ts +0 -1
  4. package/build/dist/api/amounts.js +1 -1
  5. package/build/dist/api/args.js +1 -1
  6. package/build/dist/api/canonical.d.ts +0 -1
  7. package/build/dist/api/canonical.js +1 -1
  8. package/build/dist/api/chain.d.ts +2 -0
  9. package/build/dist/api/chain.js +1 -1
  10. package/build/dist/api/errors.js +1 -1
  11. package/build/dist/api/gas.js +1 -1
  12. package/build/dist/api/grandfather.js +1 -1
  13. package/build/dist/api/guards.d.ts +23 -0
  14. package/build/dist/api/guards.js +1 -0
  15. package/build/dist/api/history.js +1 -1
  16. package/build/dist/api/http.js +1 -1
  17. package/build/dist/api/identity-link.js +1 -1
  18. package/build/dist/api/launch.d.ts +1 -0
  19. package/build/dist/api/launch.js +1 -1
  20. package/build/dist/api/merkle.js +1 -1
  21. package/build/dist/api/metadata.js +1 -1
  22. package/build/dist/api/module.js +1 -1
  23. package/build/dist/api/modules/beefy/boosts.d.ts +132 -0
  24. package/build/dist/api/modules/beefy/boosts.js +1 -0
  25. package/build/dist/api/modules/beefy/clm.d.ts +282 -0
  26. package/build/dist/api/modules/beefy/clm.js +1 -0
  27. package/build/dist/api/modules/beefy/guard.d.ts +5 -0
  28. package/build/dist/api/modules/beefy/guard.js +1 -0
  29. package/build/dist/api/modules/beefy/index.js +1 -1
  30. package/build/dist/api/modules/beefy/liquidity.d.ts +237 -0
  31. package/build/dist/api/modules/beefy/liquidity.js +1 -0
  32. package/build/dist/api/modules/beefy/management.d.ts +100 -0
  33. package/build/dist/api/modules/beefy/management.js +1 -0
  34. package/build/dist/api/modules/beefy/vaults.d.ts +14 -0
  35. package/build/dist/api/modules/beefy/vaults.js +1 -0
  36. package/build/dist/api/modules/clanker/extensions.d.ts +62 -0
  37. package/build/dist/api/modules/clanker/extensions.js +1 -0
  38. package/build/dist/api/modules/clanker/index.js +1 -1
  39. package/build/dist/api/modules/clanker/manage.d.ts +2 -0
  40. package/build/dist/api/modules/clanker/manage.js +1 -0
  41. package/build/dist/api/modules/clanker/pool-config.d.ts +96 -0
  42. package/build/dist/api/modules/clanker/pool-config.js +1 -0
  43. package/build/dist/api/modules/clanker/protocol.d.ts +2 -0
  44. package/build/dist/api/modules/clanker/protocol.js +1 -0
  45. package/build/dist/api/modules/clanker/state.d.ts +246 -0
  46. package/build/dist/api/modules/clanker/state.js +1 -0
  47. package/build/dist/api/modules/erc8004/abi.d.ts +808 -0
  48. package/build/dist/api/modules/erc8004/abi.js +1 -0
  49. package/build/dist/api/modules/erc8004/common.d.ts +69 -0
  50. package/build/dist/api/modules/erc8004/common.js +1 -0
  51. package/build/dist/api/modules/erc8004/domain.d.ts +3 -0
  52. package/build/dist/api/modules/erc8004/domain.js +1 -0
  53. package/build/dist/api/modules/erc8004/index.d.ts +3 -171
  54. package/build/dist/api/modules/erc8004/index.js +1 -1
  55. package/build/dist/api/modules/erc8004/management.d.ts +4 -0
  56. package/build/dist/api/modules/erc8004/management.js +1 -0
  57. package/build/dist/api/modules/erc8004/reputation.d.ts +3 -0
  58. package/build/dist/api/modules/erc8004/reputation.js +1 -0
  59. package/build/dist/api/modules/erc8004/services.d.ts +2 -0
  60. package/build/dist/api/modules/erc8004/services.js +1 -0
  61. package/build/dist/api/modules/erc8004/validation.d.ts +2 -0
  62. package/build/dist/api/modules/erc8004/validation.js +1 -0
  63. package/build/dist/api/modules/grove/index.js +1 -1
  64. package/build/dist/api/modules/heyresearch/freshness.d.ts +12 -0
  65. package/build/dist/api/modules/heyresearch/freshness.js +1 -0
  66. package/build/dist/api/modules/heyresearch/index.js +1 -1
  67. package/build/dist/api/modules/heyresearch/public-reads.d.ts +5 -0
  68. package/build/dist/api/modules/heyresearch/public-reads.js +1 -0
  69. package/build/dist/api/modules/hoodag/chain-reads.d.ts +33 -0
  70. package/build/dist/api/modules/hoodag/chain-reads.js +1 -0
  71. package/build/dist/api/modules/hoodag/index.d.ts +9 -1
  72. package/build/dist/api/modules/hoodag/index.js +1 -1
  73. package/build/dist/api/modules/hoodag/management.d.ts +2 -0
  74. package/build/dist/api/modules/hoodag/management.js +1 -0
  75. package/build/dist/api/modules/hoodag/public-reads.d.ts +2 -0
  76. package/build/dist/api/modules/hoodag/public-reads.js +1 -0
  77. package/build/dist/api/modules/hoodag/reconstruct.d.ts +14 -0
  78. package/build/dist/api/modules/hoodag/reconstruct.js +1 -0
  79. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  80. package/build/dist/api/modules/hoodlock/buyback.d.ts +28 -0
  81. package/build/dist/api/modules/hoodlock/buyback.js +1 -0
  82. package/build/dist/api/modules/hoodlock/commerce.d.ts +24 -0
  83. package/build/dist/api/modules/hoodlock/commerce.js +1 -0
  84. package/build/dist/api/modules/hoodlock/fee.d.ts +15 -0
  85. package/build/dist/api/modules/hoodlock/fee.js +1 -0
  86. package/build/dist/api/modules/hoodlock/guard.d.ts +5 -0
  87. package/build/dist/api/modules/hoodlock/guard.js +1 -0
  88. package/build/dist/api/modules/hoodlock/index.d.ts +4 -0
  89. package/build/dist/api/modules/hoodlock/index.js +1 -1
  90. package/build/dist/api/modules/hoodlock/lifecycle.d.ts +285 -0
  91. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -0
  92. package/build/dist/api/modules/hoodlock/locks-burn.d.ts +3 -3
  93. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  94. package/build/dist/api/modules/hoodlock/public.d.ts +3 -0
  95. package/build/dist/api/modules/hoodlock/public.js +1 -0
  96. package/build/dist/api/modules/hookr/actions.d.ts +4 -0
  97. package/build/dist/api/modules/hookr/actions.js +1 -0
  98. package/build/dist/api/modules/hookr/addons.d.ts +4 -0
  99. package/build/dist/api/modules/hookr/addons.js +1 -0
  100. package/build/dist/api/modules/hookr/contracts.d.ts +30 -0
  101. package/build/dist/api/modules/hookr/contracts.js +1 -0
  102. package/build/dist/api/modules/hookr/create-cancel.d.ts +10 -73
  103. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  104. package/build/dist/api/modules/hookr/discovery.d.ts +3 -0
  105. package/build/dist/api/modules/hookr/discovery.js +1 -0
  106. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  107. package/build/dist/api/modules/hookr/index.d.ts +0 -3
  108. package/build/dist/api/modules/hookr/index.js +1 -1
  109. package/build/dist/api/modules/hookr/public-reads.d.ts +4 -0
  110. package/build/dist/api/modules/hookr/public-reads.js +1 -0
  111. package/build/dist/api/modules/hookr/relay.d.ts +304 -0
  112. package/build/dist/api/modules/hookr/relay.js +1 -0
  113. package/build/dist/api/modules/hookr/revenue.d.ts +5 -0
  114. package/build/dist/api/modules/hookr/revenue.js +1 -0
  115. package/build/dist/api/modules/kyberswap/index.d.ts +18 -2
  116. package/build/dist/api/modules/kyberswap/index.js +1 -1
  117. package/build/dist/api/modules/kyberswap/source-pools.d.ts +9 -0
  118. package/build/dist/api/modules/kyberswap/source-pools.js +1 -0
  119. package/build/dist/api/modules/lighter/index.js +1 -1
  120. package/build/dist/api/modules/longbow/administration.d.ts +119 -0
  121. package/build/dist/api/modules/longbow/administration.js +1 -0
  122. package/build/dist/api/modules/longbow/analytics.d.ts +272 -0
  123. package/build/dist/api/modules/longbow/analytics.js +1 -0
  124. package/build/dist/api/modules/longbow/fixed.d.ts +126 -0
  125. package/build/dist/api/modules/longbow/fixed.js +1 -0
  126. package/build/dist/api/modules/longbow/index.d.ts +16 -0
  127. package/build/dist/api/modules/longbow/index.js +1 -1
  128. package/build/dist/api/modules/longbow/nft.d.ts +236 -0
  129. package/build/dist/api/modules/longbow/nft.js +1 -0
  130. package/build/dist/api/modules/longbow/rebates.d.ts +152 -0
  131. package/build/dist/api/modules/longbow/rebates.js +1 -0
  132. package/build/dist/api/modules/longbow/staking.d.ts +4 -0
  133. package/build/dist/api/modules/longbow/staking.js +1 -0
  134. package/build/dist/api/modules/meridian/index.js +1 -1
  135. package/build/dist/api/modules/meridian/markets.js +1 -1
  136. package/build/dist/api/modules/meridian/perps-batch.d.ts +4 -0
  137. package/build/dist/api/modules/meridian/perps-batch.js +1 -0
  138. package/build/dist/api/modules/meridian/perps-common.d.ts +56 -0
  139. package/build/dist/api/modules/meridian/perps-common.js +1 -0
  140. package/build/dist/api/modules/meridian/perps-guards.d.ts +3 -0
  141. package/build/dist/api/modules/meridian/perps-guards.js +1 -0
  142. package/build/dist/api/modules/meridian/perps-intents.d.ts +18 -0
  143. package/build/dist/api/modules/meridian/perps-intents.js +1 -0
  144. package/build/dist/api/modules/meridian/perps-stream.d.ts +3 -0
  145. package/build/dist/api/modules/meridian/perps-stream.js +1 -0
  146. package/build/dist/api/modules/meridian/perps.d.ts +3 -0
  147. package/build/dist/api/modules/meridian/perps.js +1 -0
  148. package/build/dist/api/modules/meridian/predict-read.d.ts +2 -0
  149. package/build/dist/api/modules/meridian/predict-read.js +1 -0
  150. package/build/dist/api/modules/meridian/rfq.d.ts +29 -0
  151. package/build/dist/api/modules/meridian/rfq.js +1 -1
  152. package/build/dist/api/modules/merkl/discovery.d.ts +2 -0
  153. package/build/dist/api/modules/merkl/discovery.js +1 -0
  154. package/build/dist/api/modules/merkl/index.d.ts +10 -1
  155. package/build/dist/api/modules/merkl/index.js +1 -1
  156. package/build/dist/api/modules/merkl/manage.d.ts +2 -0
  157. package/build/dist/api/modules/merkl/manage.js +1 -0
  158. package/build/dist/api/modules/merkl/protocol.d.ts +2 -0
  159. package/build/dist/api/modules/merkl/protocol.js +1 -0
  160. package/build/dist/api/modules/morpho/allocator.d.ts +308 -0
  161. package/build/dist/api/modules/morpho/allocator.js +1 -0
  162. package/build/dist/api/modules/morpho/bundles-abi.d.ts +705 -0
  163. package/build/dist/api/modules/morpho/bundles-abi.js +1 -0
  164. package/build/dist/api/modules/morpho/bundles.d.ts +3 -0
  165. package/build/dist/api/modules/morpho/bundles.js +1 -0
  166. package/build/dist/api/modules/morpho/in-kind.d.ts +85 -0
  167. package/build/dist/api/modules/morpho/in-kind.js +1 -0
  168. package/build/dist/api/modules/morpho/index.d.ts +10 -2
  169. package/build/dist/api/modules/morpho/index.js +1 -12
  170. package/build/dist/api/modules/morpho/local-guard.d.ts +26 -0
  171. package/build/dist/api/modules/morpho/local-guard.js +1 -0
  172. package/build/dist/api/modules/morpho/midnight-abi.d.ts +1690 -0
  173. package/build/dist/api/modules/morpho/midnight-abi.js +1 -0
  174. package/build/dist/api/modules/morpho/midnight.d.ts +179 -0
  175. package/build/dist/api/modules/morpho/midnight.js +1 -0
  176. package/build/dist/api/modules/morpho/protocol.d.ts +290 -0
  177. package/build/dist/api/modules/morpho/protocol.js +1 -0
  178. package/build/dist/api/modules/morpho/surface.d.ts +4 -0
  179. package/build/dist/api/modules/morpho/surface.js +1 -0
  180. package/build/dist/api/modules/morpho/vault-management.d.ts +10 -0
  181. package/build/dist/api/modules/morpho/vault-management.js +1 -0
  182. package/build/dist/api/modules/morpho/vault-tools.d.ts +6 -0
  183. package/build/dist/api/modules/morpho/vault-tools.js +1 -0
  184. package/build/dist/api/modules/morpho/vault-v2.d.ts +190 -0
  185. package/build/dist/api/modules/morpho/vault-v2.js +1 -0
  186. package/build/dist/api/modules/netnet/blackjack-hashes.d.ts +89 -0
  187. package/build/dist/api/modules/netnet/blackjack-hashes.js +1 -0
  188. package/build/dist/api/modules/netnet/card-abi.d.ts +3758 -0
  189. package/build/dist/api/modules/netnet/card-abi.js +1 -0
  190. package/build/dist/api/modules/netnet/card-plan.d.ts +43 -0
  191. package/build/dist/api/modules/netnet/card-plan.js +1 -0
  192. package/build/dist/api/modules/netnet/card-policy.d.ts +10 -0
  193. package/build/dist/api/modules/netnet/card-policy.js +1 -0
  194. package/build/dist/api/modules/netnet/card-read.d.ts +2 -0
  195. package/build/dist/api/modules/netnet/card-read.js +1 -0
  196. package/build/dist/api/modules/netnet/card-recovery.d.ts +2 -0
  197. package/build/dist/api/modules/netnet/card-recovery.js +1 -0
  198. package/build/dist/api/modules/netnet/desk-action-abi.d.ts +2 -0
  199. package/build/dist/api/modules/netnet/desk-action-abi.js +1 -0
  200. package/build/dist/api/modules/netnet/desk-action.d.ts +3 -0
  201. package/build/dist/api/modules/netnet/desk-action.js +1 -0
  202. package/build/dist/api/modules/netnet/desk-read.d.ts +5 -0
  203. package/build/dist/api/modules/netnet/desk-read.js +1 -0
  204. package/build/dist/api/modules/netnet/desk-registry.d.ts +5 -0
  205. package/build/dist/api/modules/netnet/desk-registry.js +1 -0
  206. package/build/dist/api/modules/netnet/financial-abi.d.ts +1764 -0
  207. package/build/dist/api/modules/netnet/financial-abi.js +1 -0
  208. package/build/dist/api/modules/netnet/financial.d.ts +13 -0
  209. package/build/dist/api/modules/netnet/financial.js +1 -0
  210. package/build/dist/api/modules/netnet/index.d.ts +1 -0
  211. package/build/dist/api/modules/netnet/index.js +1 -1
  212. package/build/dist/api/modules/netnet/staking.d.ts +8 -0
  213. package/build/dist/api/modules/netnet/staking.js +1 -0
  214. package/build/dist/api/modules/orbio/gateway.d.ts +24 -0
  215. package/build/dist/api/modules/orbio/gateway.js +1 -0
  216. package/build/dist/api/modules/orbio/index.d.ts +3 -1
  217. package/build/dist/api/modules/orbio/index.js +1 -1
  218. package/build/dist/api/modules/orbio/pins.d.ts +457 -0
  219. package/build/dist/api/modules/orbio/pins.js +1 -0
  220. package/build/dist/api/modules/pons/claim.d.ts +33 -1
  221. package/build/dist/api/modules/pons/claim.js +1 -1
  222. package/build/dist/api/modules/pons/holder-directory.d.ts +35 -0
  223. package/build/dist/api/modules/pons/holder-directory.js +1 -0
  224. package/build/dist/api/modules/pons/index.js +1 -1
  225. package/build/dist/api/modules/pons/launch-status.d.ts +151 -5
  226. package/build/dist/api/modules/pons/launch-status.js +1 -1
  227. package/build/dist/api/modules/pons/prices.js +1 -1
  228. package/build/dist/api/modules/pons/reads.d.ts +3 -0
  229. package/build/dist/api/modules/pons/reads.js +1 -0
  230. package/build/dist/api/modules/pons/swap-terms.d.ts +77 -0
  231. package/build/dist/api/modules/pons/swap-terms.js +1 -0
  232. package/build/dist/api/modules/pons/trade.d.ts +13 -2
  233. package/build/dist/api/modules/pons/trade.js +1 -1
  234. package/build/dist/api/modules/poolstrade/index.js +1 -1
  235. package/build/dist/api/modules/priors/coverage.d.ts +23 -0
  236. package/build/dist/api/modules/priors/coverage.js +1 -0
  237. package/build/dist/api/modules/priors/discovery.d.ts +4 -0
  238. package/build/dist/api/modules/priors/discovery.js +1 -0
  239. package/build/dist/api/modules/priors/features.d.ts +62 -0
  240. package/build/dist/api/modules/priors/features.js +1 -0
  241. package/build/dist/api/modules/priors/index.d.ts +9 -2
  242. package/build/dist/api/modules/priors/index.js +1 -1
  243. package/build/dist/api/modules/priors/integration.d.ts +6 -0
  244. package/build/dist/api/modules/priors/integration.js +1 -0
  245. package/build/dist/api/modules/priors/market.d.ts +10 -0
  246. package/build/dist/api/modules/priors/market.js +1 -0
  247. package/build/dist/api/modules/priors/pt.d.ts +421 -0
  248. package/build/dist/api/modules/priors/pt.js +1 -0
  249. package/build/dist/api/modules/priors/savings-exit.d.ts +85 -0
  250. package/build/dist/api/modules/priors/savings-exit.js +1 -0
  251. package/build/dist/api/modules/priors/starter-line.d.ts +495 -0
  252. package/build/dist/api/modules/priors/starter-line.js +1 -0
  253. package/build/dist/api/modules/priors/stock-swap.d.ts +101 -0
  254. package/build/dist/api/modules/priors/stock-swap.js +1 -0
  255. package/build/dist/api/modules/relay/api.d.ts +52 -0
  256. package/build/dist/api/modules/relay/api.js +1 -0
  257. package/build/dist/api/modules/relay/bootstrap.d.ts +2 -0
  258. package/build/dist/api/modules/relay/bootstrap.js +1 -0
  259. package/build/dist/api/modules/relay/discovery.d.ts +2 -0
  260. package/build/dist/api/modules/relay/discovery.js +1 -0
  261. package/build/dist/api/modules/relay/inbound.js +1 -1
  262. package/build/dist/api/modules/relay/index.d.ts +2 -0
  263. package/build/dist/api/modules/relay/index.js +1 -1
  264. package/build/dist/api/modules/relay/order.d.ts +2 -0
  265. package/build/dist/api/modules/relay/order.js +1 -0
  266. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  267. package/build/dist/api/modules/relay/readiness.d.ts +5 -0
  268. package/build/dist/api/modules/relay/readiness.js +1 -0
  269. package/build/dist/api/modules/relay/reads.d.ts +3 -0
  270. package/build/dist/api/modules/relay/reads.js +1 -0
  271. package/build/dist/api/modules/relay/vaults.d.ts +24 -0
  272. package/build/dist/api/modules/relay/vaults.js +1 -0
  273. package/build/dist/api/modules/spark/actions.d.ts +2 -0
  274. package/build/dist/api/modules/spark/actions.js +1 -0
  275. package/build/dist/api/modules/spark/details.d.ts +3 -0
  276. package/build/dist/api/modules/spark/details.js +1 -0
  277. package/build/dist/api/modules/spark/index.js +1 -1
  278. package/build/dist/api/modules/spark/management.d.ts +7 -0
  279. package/build/dist/api/modules/spark/management.js +1 -0
  280. package/build/dist/api/modules/steakhouse/analytics.d.ts +2 -0
  281. package/build/dist/api/modules/steakhouse/analytics.js +1 -0
  282. package/build/dist/api/modules/steakhouse/erc4626.d.ts +2 -0
  283. package/build/dist/api/modules/steakhouse/erc4626.js +1 -0
  284. package/build/dist/api/modules/steakhouse/index.js +1 -1
  285. package/build/dist/api/modules/steakhouse/local-guard.d.ts +7 -0
  286. package/build/dist/api/modules/steakhouse/local-guard.js +1 -0
  287. package/build/dist/api/modules/steakhouse/management.d.ts +3 -0
  288. package/build/dist/api/modules/steakhouse/management.js +1 -0
  289. package/build/dist/api/modules/steakhouse/v2-exit.d.ts +19 -0
  290. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -0
  291. package/build/dist/api/modules/tickerspring/basket-routes.d.ts +2 -0
  292. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -0
  293. package/build/dist/api/modules/tickerspring/contract-reads.d.ts +2 -0
  294. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -0
  295. package/build/dist/api/modules/tickerspring/discovery.d.ts +27 -0
  296. package/build/dist/api/modules/tickerspring/discovery.js +1 -0
  297. package/build/dist/api/modules/tickerspring/exit-preview.d.ts +14 -0
  298. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -0
  299. package/build/dist/api/modules/tickerspring/guards.d.ts +7 -0
  300. package/build/dist/api/modules/tickerspring/guards.js +1 -0
  301. package/build/dist/api/modules/tickerspring/index.d.ts +80 -1
  302. package/build/dist/api/modules/tickerspring/index.js +1 -1
  303. package/build/dist/api/modules/tickerspring/journeys.d.ts +31 -0
  304. package/build/dist/api/modules/tickerspring/journeys.js +1 -0
  305. package/build/dist/api/modules/tickerspring/ladder.d.ts +8 -0
  306. package/build/dist/api/modules/tickerspring/ladder.js +1 -0
  307. package/build/dist/api/modules/tickerspring/maker.d.ts +8 -0
  308. package/build/dist/api/modules/tickerspring/maker.js +1 -0
  309. package/build/dist/api/modules/tickerspring/order-accounting.d.ts +4 -0
  310. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -0
  311. package/build/dist/api/modules/tickerspring/research.d.ts +2 -0
  312. package/build/dist/api/modules/tickerspring/research.js +1 -0
  313. package/build/dist/api/modules/tickerspring/strategies.d.ts +17 -0
  314. package/build/dist/api/modules/tickerspring/strategies.js +1 -0
  315. package/build/dist/api/modules/uniswap/auction-create.d.ts +112 -0
  316. package/build/dist/api/modules/uniswap/auction-create.js +1 -0
  317. package/build/dist/api/modules/uniswap/auction.d.ts +212 -0
  318. package/build/dist/api/modules/uniswap/auction.js +1 -0
  319. package/build/dist/api/modules/uniswap/batch.d.ts +22 -0
  320. package/build/dist/api/modules/uniswap/batch.js +1 -0
  321. package/build/dist/api/modules/uniswap/common.d.ts +12 -0
  322. package/build/dist/api/modules/uniswap/common.js +1 -0
  323. package/build/dist/api/modules/uniswap/fees.d.ts +54 -0
  324. package/build/dist/api/modules/uniswap/fees.js +1 -0
  325. package/build/dist/api/modules/uniswap/index.d.ts +2 -1
  326. package/build/dist/api/modules/uniswap/index.js +1 -1
  327. package/build/dist/api/modules/uniswap/local-guard.d.ts +16 -0
  328. package/build/dist/api/modules/uniswap/local-guard.js +1 -0
  329. package/build/dist/api/modules/uniswap/oracle.d.ts +2 -0
  330. package/build/dist/api/modules/uniswap/oracle.js +1 -0
  331. package/build/dist/api/modules/uniswap/pool-math.d.ts +13 -0
  332. package/build/dist/api/modules/uniswap/pool-math.js +1 -0
  333. package/build/dist/api/modules/uniswap/pools.d.ts +30 -0
  334. package/build/dist/api/modules/uniswap/pools.js +1 -0
  335. package/build/dist/api/modules/uniswap/position.d.ts +69 -0
  336. package/build/dist/api/modules/uniswap/position.js +1 -0
  337. package/build/dist/api/modules/uniswap/protocol.d.ts +154 -0
  338. package/build/dist/api/modules/uniswap/protocol.js +1 -0
  339. package/build/dist/api/modules/uniswap/token-jar.d.ts +52 -0
  340. package/build/dist/api/modules/uniswap/token-jar.js +1 -0
  341. package/build/dist/api/modules/uniswap/trade-batch.d.ts +2 -0
  342. package/build/dist/api/modules/uniswap/trade-batch.js +1 -0
  343. package/build/dist/api/modules/uniswap/trade.d.ts +406 -0
  344. package/build/dist/api/modules/uniswap/trade.js +1 -0
  345. package/build/dist/api/modules/uniswap/v2.d.ts +180 -0
  346. package/build/dist/api/modules/uniswap/v2.js +1 -0
  347. package/build/dist/api/modules/uniswap/v3.d.ts +23 -2
  348. package/build/dist/api/modules/uniswap/v3.js +1 -1
  349. package/build/dist/api/modules/uniswap/v4.d.ts +17 -28
  350. package/build/dist/api/modules/uniswap/v4.js +1 -1
  351. package/build/dist/api/modules/uniswap/wrap.d.ts +17 -0
  352. package/build/dist/api/modules/uniswap/wrap.js +1 -0
  353. package/build/dist/api/modules/velora/claims.d.ts +86 -0
  354. package/build/dist/api/modules/velora/claims.js +1 -0
  355. package/build/dist/api/modules/velora/delta-reads.d.ts +2 -0
  356. package/build/dist/api/modules/velora/delta-reads.js +1 -0
  357. package/build/dist/api/modules/velora/index.js +1 -1
  358. package/build/dist/api/owner-signature.d.ts +29 -0
  359. package/build/dist/api/owner-signature.js +1 -0
  360. package/build/dist/api/positions.js +1 -1
  361. package/build/dist/api/pricenote.d.ts +0 -1
  362. package/build/dist/api/pricenote.js +1 -1
  363. package/build/dist/api/prices.js +1 -1
  364. package/build/dist/api/pricing.d.ts +1 -14
  365. package/build/dist/api/pricing.js +1 -1
  366. package/build/dist/api/routes.js +1 -1
  367. package/build/dist/api/rpc.d.ts +23 -0
  368. package/build/dist/api/rpc.js +1 -0
  369. package/build/dist/api/secret-fields.js +1 -1
  370. package/build/dist/api/send.js +1 -1
  371. package/build/dist/api/signing-registry.d.ts +19 -0
  372. package/build/dist/api/signing-registry.js +1 -0
  373. package/build/dist/api/signing.d.ts +162 -0
  374. package/build/dist/api/signing.js +1 -0
  375. package/build/dist/api/simulate.js +1 -1
  376. package/build/dist/api/swap.d.ts +61 -27
  377. package/build/dist/api/swap.js +1 -1
  378. package/build/dist/api/tokens.d.ts +5 -0
  379. package/build/dist/api/tokens.js +1 -1
  380. package/build/dist/api/tool-policy.d.ts +6 -0
  381. package/build/dist/api/tool-policy.js +1 -1
  382. package/build/dist/api/tx.js +1 -1
  383. package/build/dist/api/types.d.ts +2 -0
  384. package/build/dist/api/vendor-limits.js +1 -1
  385. package/build/dist/chunks/2EDXKJ3B.js +1 -0
  386. package/build/dist/chunks/2EGFALNH.js +1 -0
  387. package/build/dist/chunks/2LM5C7FQ.js +1 -0
  388. package/build/dist/chunks/2NA6JLEC.js +1 -0
  389. package/build/dist/chunks/2O6A6WEX.js +1 -0
  390. package/build/dist/chunks/37QNUNED.js +1 -0
  391. package/build/dist/chunks/3CCBUYUM.js +1 -0
  392. package/build/dist/chunks/3RFSGU2Y.js +1 -0
  393. package/build/dist/chunks/{B4FOHEBE.js → 3Z3U4YPA.js} +1 -1
  394. package/build/dist/chunks/4CDR7F4I.js +1 -0
  395. package/build/dist/chunks/4X6JEMSF.js +1 -0
  396. package/build/dist/chunks/53N7PNJH.js +1 -0
  397. package/build/dist/chunks/5EHQM6DM.js +1 -0
  398. package/build/dist/chunks/5H3MQWH7.js +18 -0
  399. package/build/dist/chunks/5XFXH2JT.js +1 -0
  400. package/build/dist/chunks/5YS5V2LK.js +1 -0
  401. package/build/dist/chunks/65QFM4JU.js +1 -0
  402. package/build/dist/chunks/67TJOOBI.js +1 -0
  403. package/build/dist/chunks/6HV5BR7P.js +1 -0
  404. package/build/dist/chunks/{A5ITAEUQ.js → 6IM6A5VA.js} +1 -1
  405. package/build/dist/chunks/6JCEJ66K.js +1 -0
  406. package/build/dist/chunks/6NR7SVRO.js +1 -0
  407. package/build/dist/chunks/6SB3FB3P.js +1 -0
  408. package/build/dist/chunks/6SCCW74G.js +1 -0
  409. package/build/dist/chunks/73N3TOJL.js +1 -0
  410. package/build/dist/chunks/74BPMUAG.js +1 -0
  411. package/build/dist/chunks/7B5UH2VS.js +1 -0
  412. package/build/dist/chunks/7LDAJ6BM.js +1 -0
  413. package/build/dist/chunks/7MR37STI.js +1 -0
  414. package/build/dist/chunks/7US6PD56.js +1 -0
  415. package/build/dist/chunks/7YU6DELJ.js +1 -0
  416. package/build/dist/chunks/AFHHRDPJ.js +1 -0
  417. package/build/dist/chunks/AIWZGIZ6.js +1 -0
  418. package/build/dist/chunks/{UCMNB2UP.js → AXYOJBX6.js} +1 -1
  419. package/build/dist/chunks/AYM5L6L7.js +1 -0
  420. package/build/dist/chunks/B72Q2EQ2.js +1 -0
  421. package/build/dist/chunks/B7V7AA5A.js +1 -0
  422. package/build/dist/chunks/BBQVTEYB.js +1 -0
  423. package/build/dist/chunks/BQLLTY4L.js +1 -0
  424. package/build/dist/chunks/BYXBS45D.js +1 -0
  425. package/build/dist/chunks/C2FEXLMA.js +1 -0
  426. package/build/dist/chunks/C3TJLARP.js +1 -0
  427. package/build/dist/chunks/C3ZZSGSP.js +1 -0
  428. package/build/dist/chunks/C5LR6F4B.js +1 -0
  429. package/build/dist/chunks/CAYBSVA6.js +1 -0
  430. package/build/dist/chunks/CBA776XQ.js +1 -0
  431. package/build/dist/chunks/CCEWSOBT.js +1 -0
  432. package/build/dist/chunks/CEQNXF6A.js +1 -0
  433. package/build/dist/chunks/CS55ERS3.js +1 -0
  434. package/build/dist/chunks/CXMC3T6B.js +1 -0
  435. package/build/dist/chunks/{6SYTB6FB.js → D3OWLDVB.js} +1 -1
  436. package/build/dist/chunks/DHXVYHT4.js +1 -0
  437. package/build/dist/chunks/E2IVNGLC.js +1 -0
  438. package/build/dist/chunks/E2Q5IA67.js +1 -0
  439. package/build/dist/chunks/{SJ7HDRI4.js → E7ASOYQI.js} +1 -1
  440. package/build/dist/chunks/EAEQOS7Y.js +1 -0
  441. package/build/dist/chunks/EC5W3UZD.js +1 -0
  442. package/build/dist/chunks/{B4MLWDPM.js → EG6M6SSO.js} +1 -1
  443. package/build/dist/chunks/EHVPRQHS.js +1 -0
  444. package/build/dist/chunks/EKGHKEKV.js +1 -0
  445. package/build/dist/chunks/EVANKNJV.js +1 -0
  446. package/build/dist/chunks/F2YH72GF.js +1 -0
  447. package/build/dist/chunks/F3TJCOVV.js +1 -0
  448. package/build/dist/chunks/F6WBPPBN.js +1 -0
  449. package/build/dist/chunks/FL3EF72E.js +1 -0
  450. package/build/dist/chunks/FLXID6I3.js +1 -0
  451. package/build/dist/chunks/FYTF2QMS.js +1 -0
  452. package/build/dist/chunks/G7UKNO2I.js +1 -0
  453. package/build/dist/chunks/GZ5TW3WB.js +1 -0
  454. package/build/dist/chunks/H4S2ZCWK.js +1 -0
  455. package/build/dist/chunks/H6ED3RHF.js +1 -0
  456. package/build/dist/chunks/HACP2Q6D.js +3 -0
  457. package/build/dist/chunks/HF2AGJZC.js +1 -0
  458. package/build/dist/chunks/HFQS5344.js +1 -0
  459. package/build/dist/chunks/{Y3P6SUNL.js → HIMVOTIU.js} +1 -1
  460. package/build/dist/chunks/HL2MLC3O.js +1 -0
  461. package/build/dist/chunks/HNMOB76J.js +1 -0
  462. package/build/dist/chunks/HQVC6X3T.js +1 -0
  463. package/build/dist/chunks/HYIEQG4X.js +1 -0
  464. package/build/dist/chunks/HZUWK5B2.js +1 -0
  465. package/build/dist/chunks/IHGVCPVA.js +2 -0
  466. package/build/dist/chunks/IKP3Z3RX.js +1 -0
  467. package/build/dist/chunks/ITIIHCZK.js +1 -0
  468. package/build/dist/chunks/IWALIX7Q.js +1 -0
  469. package/build/dist/chunks/JOMK32QW.js +1 -0
  470. package/build/dist/chunks/JRO6WTK4.js +1 -0
  471. package/build/dist/chunks/JRVTSGAT.js +1 -0
  472. package/build/dist/chunks/JRZLKIYB.js +1 -0
  473. package/build/dist/chunks/JVTVOK6P.js +1 -0
  474. package/build/dist/chunks/K2LWX3PZ.js +1 -0
  475. package/build/dist/chunks/KEPQXFHU.js +1 -0
  476. package/build/dist/chunks/L24EOVLT.js +1 -0
  477. package/build/dist/chunks/L2MTPRU7.js +1 -0
  478. package/build/dist/chunks/LBEMCOND.js +1 -0
  479. package/build/dist/chunks/LFKSXD3S.js +1 -0
  480. package/build/dist/chunks/MRWCFTMS.js +1 -0
  481. package/build/dist/chunks/MWWYIFXJ.js +1 -0
  482. package/build/dist/chunks/MYBDO5SA.js +1 -0
  483. package/build/dist/chunks/N77ANGBT.js +1 -0
  484. package/build/dist/chunks/NCQFWPAW.js +1 -0
  485. package/build/dist/chunks/NHCRJC5X.js +1 -0
  486. package/build/dist/chunks/NNZ4SZZ4.js +1 -0
  487. package/build/dist/chunks/NUWL6TJM.js +1 -0
  488. package/build/dist/chunks/O47JXRXN.js +1 -0
  489. package/build/dist/chunks/{GIBF3YJO.js → OG5HRQU4.js} +1 -1
  490. package/build/dist/chunks/OJLMF5AR.js +1 -0
  491. package/build/dist/chunks/OJMYESQU.js +1 -0
  492. package/build/dist/chunks/OJP7Y4AM.js +1 -0
  493. package/build/dist/chunks/OK3TQFXZ.js +1 -0
  494. package/build/dist/chunks/OW7GOYKA.js +1 -0
  495. package/build/dist/chunks/P4UQGWCP.js +1 -0
  496. package/build/dist/chunks/P6ELT4ZV.js +1 -0
  497. package/build/dist/chunks/PHXWBC4O.js +1 -0
  498. package/build/dist/chunks/Q2VMH2LB.js +1 -0
  499. package/build/dist/chunks/QH3AL3UN.js +1 -0
  500. package/build/dist/chunks/QHHZDXRG.js +1 -0
  501. package/build/dist/chunks/QNPEKNWM.js +1 -0
  502. package/build/dist/chunks/QOY4AANB.js +1 -0
  503. package/build/dist/chunks/QRUC7EFE.js +1 -0
  504. package/build/dist/chunks/QYKXWBZC.js +1 -0
  505. package/build/dist/chunks/REGJY5RC.js +1 -0
  506. package/build/dist/chunks/RETS2ZEK.js +1 -0
  507. package/build/dist/chunks/RFJCG4NA.js +1 -0
  508. package/build/dist/chunks/RNEMTLQG.js +1 -0
  509. package/build/dist/chunks/RRSODRGT.js +1 -0
  510. package/build/dist/chunks/SEW7UP5U.js +1 -0
  511. package/build/dist/chunks/SLSPWXR6.js +1 -0
  512. package/build/dist/chunks/SPRVVJXI.js +1 -0
  513. package/build/dist/chunks/SQ5BNSXR.js +1 -0
  514. package/build/dist/chunks/SQH7A4O3.js +1 -0
  515. package/build/dist/chunks/SS7U3CMZ.js +1 -0
  516. package/build/dist/chunks/SXX52Y27.js +1 -0
  517. package/build/dist/chunks/SYZ55RCX.js +1 -0
  518. package/build/dist/chunks/T6MTTMLQ.js +1 -0
  519. package/build/dist/chunks/TAI63P6E.js +1 -0
  520. package/build/dist/chunks/TCS3ICNE.js +2 -0
  521. package/build/dist/chunks/TRCP7X5P.js +1 -0
  522. package/build/dist/chunks/TWR7BF72.js +1 -0
  523. package/build/dist/chunks/UEYFMXV3.js +1 -0
  524. package/build/dist/chunks/UWOFA6GV.js +1 -0
  525. package/build/dist/chunks/UXG67LH3.js +1 -0
  526. package/build/dist/chunks/V6SDKPZS.js +1 -0
  527. package/build/dist/chunks/VCWDJQDE.js +1 -0
  528. package/build/dist/chunks/{BOFA26WU.js → VXLJRRKV.js} +1 -1
  529. package/build/dist/chunks/W6G2QGYF.js +1 -0
  530. package/build/dist/chunks/WCKMQFGS.js +1117 -0
  531. package/build/dist/chunks/WHT45EFX.js +1 -0
  532. package/build/dist/chunks/WIDTTGSH.js +1 -0
  533. package/build/dist/chunks/WQZLYX64.js +1 -0
  534. package/build/dist/chunks/X5V2Z2NM.js +1 -0
  535. package/build/dist/chunks/{GDP4JSAX.js → XCFA73P2.js} +1 -1
  536. package/build/dist/chunks/XPFVT2EA.js +1 -0
  537. package/build/dist/chunks/XV6F3RET.js +1 -0
  538. package/build/dist/chunks/XW7RH7YY.js +1 -0
  539. package/build/dist/chunks/YHPOXAKA.js +1 -0
  540. package/build/dist/chunks/YONRUWN7.js +1 -0
  541. package/build/dist/chunks/YR3QJVJQ.js +1 -0
  542. package/build/dist/chunks/Z4LJ2GTX.js +1 -0
  543. package/build/dist/chunks/ZL3KVABO.js +1 -0
  544. package/build/dist/chunks/ZPM2MFXZ.js +1 -0
  545. package/build/dist/chunks/ZPNGV34U.js +1 -0
  546. package/build/dist/chunks/ZQI7B2Z7.js +1 -0
  547. package/build/dist/chunks/ZT67OMLW.js +1 -0
  548. package/package.json +13 -9
  549. package/build/dist/chunks/2IRORNOH.js +0 -1
  550. package/build/dist/chunks/3PA2XT75.js +0 -1
  551. package/build/dist/chunks/52TGAWSI.js +0 -1
  552. package/build/dist/chunks/66DWJWDA.js +0 -1
  553. package/build/dist/chunks/73EABRFC.js +0 -1
  554. package/build/dist/chunks/A5KSG6LW.js +0 -1
  555. package/build/dist/chunks/BHR46XNW.js +0 -3
  556. package/build/dist/chunks/CQNZWL7F.js +0 -1
  557. package/build/dist/chunks/GN4QZ4JA.js +0 -1
  558. package/build/dist/chunks/I5CQ64EU.js +0 -1
  559. package/build/dist/chunks/ICCJ3TOO.js +0 -1
  560. package/build/dist/chunks/KL5YE7JA.js +0 -1
  561. package/build/dist/chunks/KVVTKM6E.js +0 -1
  562. package/build/dist/chunks/M6JGTQRY.js +0 -1
  563. package/build/dist/chunks/MK6L6TGI.js +0 -1
  564. package/build/dist/chunks/MOVRI5IV.js +0 -1
  565. package/build/dist/chunks/NA7HV7BR.js +0 -1
  566. package/build/dist/chunks/NGAI6GTU.js +0 -1
  567. package/build/dist/chunks/OBX7IZG5.js +0 -1
  568. package/build/dist/chunks/OSQ4AAM2.js +0 -2
  569. package/build/dist/chunks/OWEUVFB6.js +0 -1
  570. package/build/dist/chunks/P4G3EKF7.js +0 -1
  571. package/build/dist/chunks/QGDHMVPE.js +0 -1
  572. package/build/dist/chunks/SPAKOCR7.js +0 -1
  573. package/build/dist/chunks/T6O2L6HF.js +0 -1
  574. package/build/dist/chunks/TEVKPJV5.js +0 -1
  575. package/build/dist/chunks/YX4NVVSX.js +0 -1
  576. package/build/dist/chunks/ZUC6ILK2.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as c,b as T,e as v,f as F,g as I}from"./ITIIHCZK.js";import{a as l}from"./UWOFA6GV.js";import{c as A,g,h as S}from"./73N3TOJL.js";import{a as h}from"./XPFVT2EA.js";import{a as d}from"./5YS5V2LK.js";import{encodeFunctionData as y,getAddress as M,parseAbi as j,parseAbiItem as D,zeroAddress as H}from"viem";var x=M("0x000000001f26a0044baa66024e7b6599c61963f8"),_=D("event AuctionCreated(address indexed auction,address indexed token,uint256 amount,bytes configData)"),n=j(["function currency() view returns (address)","function token() view returns (address)","function startBlock() view returns (uint64)","function endBlock() view returns (uint64)","function claimBlock() view returns (uint64)","function validationHook() view returns (address)","function clearingPrice() view returns (uint256)","function isGraduated() view returns (bool)","function bids(uint256) view returns ((uint64 startBlock,uint24 startCumulativeMps,uint64 exitedBlock,uint256 maxPrice,address owner,uint256 amountQ96,uint256 tokensFilled))","function submitBid(uint256 maxPrice,uint128 amount,address owner,uint256 prevTickPrice,bytes hookData) payable returns (uint256)","function exitBid(uint256)","function exitPartiallyFilledBid(uint256,uint64,uint64)","function claimTokens(uint256)","function claimTokensBatch(address,uint256[])","function checkpoint()","function sweepCurrency()","function sweepUnsoldTokens()"]);async function $(s,B){let o=T(B.auction),t=c(B.creationBlock,"creationBlock",64,!0),e=await s.getLogs({address:x,event:_,args:{auction:o},fromBlock:t,toBlock:t,strict:!0});if(e.length!==1||!g(e[0].address,x)||!S(e[0].args.auction,o))throw new d("Auction has no matching AuctionCreated event at the pinned CCA factory and creationBlock.");return o}async function Q(s,B){let o=s.clientFor(h),t=await $(o,B),e=await o.getBlockNumber(),[a,k,i,b,m,C,u,w]=await Promise.all([o.readContract({address:t,abi:n,functionName:"currency",blockNumber:e}),o.readContract({address:t,abi:n,functionName:"token",blockNumber:e}),o.readContract({address:t,abi:n,functionName:"startBlock",blockNumber:e}),o.readContract({address:t,abi:n,functionName:"endBlock",blockNumber:e}),o.readContract({address:t,abi:n,functionName:"claimBlock",blockNumber:e}),o.readContract({address:t,abi:n,functionName:"validationHook",blockNumber:e}),o.readContract({address:t,abi:n,functionName:"clearingPrice",blockNumber:e}),o.readContract({address:t,abi:n,functionName:"isGraduated",blockNumber:e})]);return{auction:t,currency:a,saleToken:k,startBlock:i,endBlock:b,claimBlock:m,validationHook:C,clearingPrice:u,graduated:w,blockNumber:e}}var U={auction:A,creationBlock:l(),bidId:l(),amount:l(),maxPrice:l(),prevTickPrice:l(),lastFullyFilledCheckpointBlock:l(),outbidBlock:l(),mode:{type:"string",enum:["full","partial"]},bidIds:{type:"array",minItems:1,maxItems:50,items:l()}};function R(s){let o=["status","bid","exit","claim","checkpoint","sweep_currency","sweep_tokens"].map(t=>({name:`uniswap_auction_${t}`,inputSchema:{type:"object",additionalProperties:!1,required:["auction","creationBlock",...t==="bid"?["amount","maxPrice","prevTickPrice"]:t==="exit"?["bidId","mode"]:[]],properties:U},async execute(e,a){I(e,["auction","creationBlock",...t==="bid"?["amount","maxPrice","prevTickPrice"]:t==="exit"?["bidId","mode","lastFullyFilledCheckpointBlock","outbidBlock"]:t==="claim"?["bidId","bidIds"]:t==="status"?["bidId"]:[]]);let i=await Q(s,e),b=s.clientFor(h),[m,C]=await Promise.all([v(s,i.currency,i.blockNumber),v(s,i.saleToken,i.blockNumber)]),u=e.bidId===void 0?void 0:await b.readContract({address:i.auction,abi:n,functionName:"bids",args:[c(e.bidId,"bidId",256,!0)],blockNumber:i.blockNumber});if(t==="status")return{auction:i.auction,paymentToken:m,saleToken:C,startBlock:i.startBlock.toString(),endBlock:i.endBlock.toString(),claimBlock:i.claimBlock.toString(),validationHook:i.validationHook,clearingPrice:i.clearingPrice.toString(),graduated:i.graduated,...u?{bid:{...u,startBlock:u.startBlock.toString(),exitedBlock:u.exitedBlock.toString(),maxPrice:u.maxPrice.toString(),amountQ96:u.amountQ96.toString(),tokensFilled:u.tokensFilled.toString()}}:{},summary:"CCA prices use currency-base-units per sale-token-base-unit in Q96. Clearing price/graduation reflect the latest checkpoint and may lag the head."};let w=[],f,N=0n;if(t==="bid"){if(i.validationHook!==H)throw new d("This auction has a validation hook. Its validation/signing contract is not configured; do not pass an off-chain signature manually.");if(i.blockNumber<i.startBlock||i.blockNumber>=i.endBlock)throw new d("Auction is not in its bidding window.");let r=c(e.amount,"amount",128),p=c(e.maxPrice,"maxPrice"),P=c(e.prevTickPrice,"prevTickPrice",256,!0);if(p<=i.clearingPrice)throw new d("Bid maxPrice must be above the checkpoint clearing price.");i.currency===H?N=r:w.push(s.approval(i.currency,i.auction,r.toString(),h)),f=y({abi:n,functionName:"submitBid",args:[p,r,a,P,"0x"]})}else if(t==="exit"){if(!u||!g(u.owner,a))throw new d("Only exit a bid owned by the signing wallet.");let r=c(e.bidId,"bidId",256,!0);if(e.mode==="full"){if(e.lastFullyFilledCheckpointBlock!==void 0||e.outbidBlock!==void 0)throw new d("Full exit takes no checkpoint hints.");f=y({abi:n,functionName:"exitBid",args:[r]})}else if(e.mode==="partial")f=y({abi:n,functionName:"exitPartiallyFilledBid",args:[r,c(e.lastFullyFilledCheckpointBlock,"lastFullyFilledCheckpointBlock",64,!0),c(e.outbidBlock,"outbidBlock",64,!0)]});else throw new d("Choose full or partial exit explicitly; partial exits require checkpoint hints.")}else if(t==="claim"){if(e.bidId===void 0==(e.bidIds===void 0))throw new d("Provide bidId or bidIds, not both.");let r=e.bidIds===void 0?[c(e.bidId,"bidId",256,!0)]:Array.isArray(e.bidIds)?e.bidIds.map(p=>c(p,"bidIds",256,!0)):[];if(r.length<1||r.length>50||new Set(r.map(String)).size!==r.length)throw new d("Provide 1 to 50 unique bid IDs.");for(let p of r){let P=await b.readContract({address:i.auction,abi:n,functionName:"bids",args:[p],blockNumber:i.blockNumber});if(!g(P.owner,a))throw new d("Claimed tokens must belong to the signing wallet.")}f=y({abi:n,functionName:"claimTokensBatch",args:[a,r]})}else f=y({abi:n,functionName:t==="checkpoint"?"checkpoint":t==="sweep_currency"?"sweepCurrency":"sweepUnsoldTokens"});return w.push(s.unsignedTx({to:i.auction,data:f,value:N.toString(),chainId:h,description:`CCA ${t} on factory-verified auction ${i.auction}. Bid owner ${a}.`})),F(s,w,a,`CCA ${t}; checkpoint/exit/claim eligibility and creator-only sweeps are checked by the contract in preview. Sweeps pay the auction's immutable funds/tokens recipient, not an arbitrary recipient.`)}}));return o.push({name:"uniswap_auctions",inputSchema:{type:"object",additionalProperties:!1,properties:{fromBlock:l(),toBlock:l()}},async execute(t){I(t,["fromBlock","toBlock"]);let e=s.clientFor(h),a=await e.getBlockNumber(),k=t.fromBlock===void 0?a>9999n?a-9999n:0n:c(t.fromBlock,"fromBlock",64,!0),i=t.toBlock===void 0?a:c(t.toBlock,"toBlock",64,!0);if(k>i||i>a||i-k>=10000n)throw new d("Scan an ordered range of at most 10000 blocks, ending at or before the head.");let b=await e.getLogs({address:x,event:_,fromBlock:k,toBlock:i,strict:!0});return{factory:x,fromBlock:k.toString(),toBlock:i.toString(),auctions:b.map(m=>({auction:m.args.auction,token:m.args.token,amount:m.args.amount.toString(),creationBlock:m.blockNumber.toString()})),summary:"Factory-verified auctions in this block window only. An empty result does not establish that no auctions exist outside it. Scan earlier windows for older launches."}}}),{tools:o}}export{x as a,_ as b,n as c,$ as d,Q as e,R as f};
@@ -0,0 +1 @@
1
+ import{a as h,c as A}from"./MYBDO5SA.js";import{d as l,e as m,f as y,j as w}from"./73N3TOJL.js";import{a as t}from"./5YS5V2LK.js";import{a as f}from"./JXOEJPJ4.js";import{erc20Abi as g,parseAbi as R}from"viem";var x="https://api.relay.link",I="0x0000000000000000000000000000000000000000",L=R(["function depositNative(address depositor, bytes32 id) payable","function depositErc20(address depositor, address token, uint256 amount, bytes32 id)"]),k=(1n<<256n)-1n;function p(e){return y(e,"Relay returned an unexpected response.")}function _(e){if(!Array.isArray(e))throw new t("Relay returned an unexpected list.");return e}function b(e){return w(e,"Provide a valid wallet or token address.",l)}function S(e){let n=b(e);return n==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"?I:n}function E(e){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)throw new t("Provide a positive integer chain ID.");return e}function P(e){if(typeof e!="string"||!/^(0|[1-9]\d*)$/.test(e)||BigInt(e)>k)throw new t("Amounts must be decimal base-unit strings within the uint256 range.");return e}function $(e){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)throw new t("Relay returned an invalid order or refund deadline. Request a fresh quote.");return e}function q(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new t("Provide a valid Relay request or order ID.");return e}function T(e){let n=p(e);if(typeof n.symbol!="string"||!n.symbol.trim()||typeof n.decimals!="number"||!Number.isInteger(n.decimals)||n.decimals<0||n.decimals>255)throw new t("Relay returned invalid token metadata.");return{address:b(n.address),chainId:E(n.chainId),decimals:n.decimals,symbol:n.symbol}}function D(e){let n=p(e);return{token:T(n.currency),amount:P(n.amount)}}function M(e){if(!e)throw new t("Relay quote does not match the requested amount, chain, recipient, minimum or transaction.")}function V(e){return e===void 0?[]:_(e).map(q)}function z(e){if(!(e==null||e==="N/A")){if(typeof e!="string")throw new t("Relay returned an invalid failure reason.");return f(e)}}function H(e,n="symbol"){if(!(typeof e!="string"||!e.trim()))return(n==="symbol"?/^[A-Za-z0-9._-]{1,32}$/:/^[A-Za-z0-9 ()+-]{1,32}$/).test(e)?e:f(e)}async function J(e,n,r,o,s,c){let i=await e.clientFor(s).readContract({address:n,abi:g,functionName:"allowance",args:[c,r]});if(typeof i!="bigint"||i<0n||i>k)throw new t("Could not read the Relay token allowance.");return[...i>0n?[e.approval(n,r,"0",s)]:[],e.approval(n,r,o,s)]}function j(e){return async(n,r)=>p(await v(e)(n,r))}function v(e){return async(n,r)=>{let o=process.env.OAK_RELAY_API_KEY?.trim(),s=n.split("?")[0],c=s==="/quote/v2",i=s==="/requests/v3"||/^\/balance\/[^/]+\/events$/.test(s);if(!o&&i)throw new t("Configure OAK_RELAY_API_KEY on the server: Relay request history and balance events require an API key. A missing key does not mean this wallet has no requests or events. Check a saved request with relay_status.");if(!o&&c)throw new t("Configure the Relay API key (OAK_RELAY_API_KEY) on the server: Relay quote/v2 requires a valid API key since October 2, 2026. Status and chain reads remain available without it.");try{return await A(e.http,`${x}${n}`,{method:r===void 0?"GET":"POST",headers:{...o?{"x-api-key":o}:{},"Content-Type":"application/json","User-Agent":"oak-relay/1.0"},...r===void 0?{}:{body:JSON.stringify(r)}},a=>m(a)||Array.isArray(a))}catch(a){let d=a instanceof h?a.response.status:void 0,u=e.plainError(a);throw d===401||d===403||/HTTP (401|403)\b/.test(u)?new t("Relay requires an authorized API key for this endpoint. Ask the operator to configure a valid OAK_RELAY_API_KEY on the server with access to this resource; never pass keys in tool arguments."):s==="/prices/rates"&&(d!==void 0&&d>=500||/HTTP 5\d\d\b/.test(u))?new t("Relay exchange rates are unavailable because the upstream service failed. Retry later; no rates were returned. Use relay_token_price with chainId and address for an individual token."):new t(o?u.replaceAll(o,"[redacted]"):u)}}}export{x as a,I as b,L as c,p as d,_ as e,b as f,S as g,E as h,P as i,$ as j,q as k,T as l,D as m,M as n,V as o,z as p,H as q,J as r,j as s,v as t};
@@ -0,0 +1 @@
1
+ import{e as y,g as a,i as l,l as h,m as A,n as g}from"./73N3TOJL.js";import{a as f,i as k}from"./XPFVT2EA.js";import{a as s}from"./5YS5V2LK.js";import{encodeAbiParameters as S,keccak256 as I,parseAbi as _,parseAbiParameters as P}from"viem";var u=k[f].clanker,O={type:"string",pattern:"^\\d+$"},$={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},R=_(["function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))","function tokenRewards(address) view returns ((address token,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,uint256 positionId,uint256 numPositions,uint16[] rewardBps,address[] rewardAdmins,address[] rewardRecipients))","function feePreferences(address,uint256) view returns (uint8)","function updateRewardRecipient(address,uint256,address)","function updateRewardAdmin(address,uint256,address)","function updateFeePreference(address,uint256,uint8)"]),x="Provide a valid nonzero address.";function c(e,o=!1){let r=l(e,x);return o?r:h(r,x)}function F(e){return g(e,"Amount exceeds uint256.")}function w(e,o,r){if(typeof e!="number"||!Number.isSafeInteger(e)||e<o||e>r)throw new s(`Choose an integer from ${o} to ${r}.`);return e}function H(e,o){let r=Object.keys(e).find(n=>!o.includes(n));if(r)throw new s(`Unsupported Clanker input: ${r}.`)}function T(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new s("Provide bytes32 hexadecimal data.");return e}function b(e){return A(e,"Clanker returned an invalid amount.").toString()}async function v(e,o){let r=await e.clientFor(f).readContract({address:u.factory.address,abi:R,functionName:"tokenDeploymentInfo",args:[o]});if(!Array.isArray(r)||r.length!==4||typeof r[0]!="string"||!a(r[0],o)||!Array.isArray(r[3]))throw new s("The pinned factory did not identify this Clanker token.");let n=c(r[1]),d=c(r[2]);if(![u.locker.address,u.legacy_locker_v1.address].some(t=>a(t,d))||![u.fee_static_hook_v2.address,u.fee_dynamic_hook_v2.address].some(t=>a(t,n)))throw new s("This Clanker locker or hook has not been verified by Oak.");return{hook:n,locker:d,extensions:r[3].map(t=>c(t))}}async function K(e,o){let r=await v(e,o),n=await e.clientFor(f).readContract({address:r.locker,abi:R,functionName:"tokenRewards",args:[o]});if(!y(n)||typeof n.token!="string"||!a(n.token,o)||!y(n.poolKey)||!Array.isArray(n.rewardBps)||!Array.isArray(n.rewardAdmins)||!Array.isArray(n.rewardRecipients))throw new s("Clanker returned invalid reward configuration.");let d=n.poolKey,t={currency0:c(d.currency0),currency1:c(d.currency1),fee:w(d.fee,0,16777215),tickSpacing:w(d.tickSpacing,1,32767),hooks:c(d.hooks)};if(BigInt(t.currency0)>=BigInt(t.currency1)||!a(t.hooks,r.hook)||![t.currency0,t.currency1].some(i=>a(i,o)))throw new s("Clanker returned a mismatched pool key.");let p=n.rewardBps.length;if(!p||p>7||p!==n.rewardAdmins.length||p!==n.rewardRecipients.length)throw new s("Clanker returned mismatched rewards.");let m=n.rewardBps.map(i=>w(i,1,1e4));if(m.reduce((i,C)=>i+C,0)!==1e4)throw new s("Clanker returned invalid reward splits.");return{...r,poolKey:t,poolId:I(S(P("address,address,uint24,int24,address"),[t.currency0,t.currency1,t.fee,t.tickSpacing,t.hooks])),positionId:b(n.positionId),numPositions:b(n.numPositions),rewardBps:m,rewardAdmins:n.rewardAdmins.map(i=>c(i)),rewardRecipients:n.rewardRecipients.map(i=>c(i)),pairedToken:a(t.currency0,o)?t.currency1:t.currency0}}export{u as a,O as b,$ as c,R as d,x as e,c as f,F as g,w as h,H as i,T as j,b as k,v as l,K as m};
@@ -0,0 +1,18 @@
1
+ import{a as ae}from"./3CCBUYUM.js";import{a as bt,d as wt,e as ht}from"./L24EOVLT.js";import{a as Ne}from"./7MR37STI.js";import{a as We,b as Be,d as pt}from"./EC5W3UZD.js";import{b as ut,c as mt,d as ft}from"./HZUWK5B2.js";import{d as ct,e as te}from"./EAEQOS7Y.js";import{a as dt}from"./XCFA73P2.js";import{b as lt}from"./AXYOJBX6.js";import{a as q}from"./6IM6A5VA.js";import{a as A,d as z}from"./UWOFA6GV.js";import{d as De,g as E,i as Ue}from"./73N3TOJL.js";import{a as Me}from"./RETS2ZEK.js";import{j as it}from"./IWALIX7Q.js";import{a as p,i as V}from"./XPFVT2EA.js";import{a as i,d as se}from"./5YS5V2LK.js";import{a as ze}from"./JXOEJPJ4.js";import{encodeFunctionData as me,erc20Abi as Ha,getAddress as Kt,parseAbi as st,zeroAddress as qa}from"viem";import{decodeAbiParameters as aa,encodeFunctionData as oa,getAddress as ie,parseAbiParameters as ra,zeroAddress as fe,zeroHash as It}from"viem";import{decodeAbiParameters as Xt,encodeFunctionData as Yt,erc20Abi as Jt,getAddress as St,parseAbi as Zt,parseAbiParameters as ea,zeroHash as kt}from"viem";var Ke=St("0xCE29862924756584BBD0D75CA1249d22007E2813"),At="(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)",ta="(uint256 value,uint256 nonce,uint256 deadline,uint8 v,bytes32 r,bytes32 s)",yt=Zt(["function BLUE() view returns (address)",`function vaultExitBundlesV1InKindRedemptionVaultV2(address vault,address adapter,${At}[] marketParamsList,uint256 exitAssets,${ta} 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 gt=(e,t)=>e<t?e:t;async function Za(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),d=e.clientFor(p),m=await pt(d,t,s),c=(S,B,Te,ee=[])=>d.readContract({address:S,abi:B,functionName:Te,args:ee,blockNumber:m.blockNumber}),[f,b,w,h]=await Promise.all([d.getBlock({blockNumber:m.blockNumber}),c(Ke,yt,"BLUE"),c(t,Jt,"balanceOf",[n]),c(t,We,"previewRedeem",[a])]);if(typeof b!="string"||St(b)!==U)throw new i("VaultExitBundlesV1 does not report the pinned Morpho Blue.");if(u<f.timestamp||u>f.timestamp+300n)throw new i("Use an absolute Unix deadline within the next five minutes.");if(a>Be(w))throw new i("maxShares exceeds the wallet share balance.");let y=gt(m.idle,l),k=m.markets.filter(S=>S.supplied>0n&&W(S.id)),g=l-y,T=k[0]?.penalty??0n,I=g*10n**18n/(10n**18n+T);if(g>0n&&I===0n)throw new i("The penalty-adjusted in-kind amount rounds to zero.");let M=[];for(let S of k){if(I===0n)break;let B=gt(S.supplied,I);M.push({marketId:S.id,assets:B,penalty:(B*S.penalty+10n**18n-1n)/10n**18n}),I-=B}if(I>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)>Be(h))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 v=[...y?[y]:[],...M.flatMap(S=>[S.assets,S.penalty].filter(B=>B>0n))],G=(await Promise.all(v.map(S=>c(t,We,"previewWithdraw",[S])))).reduce((S,B)=>S+Be(B),0n);if(G===0n||G>a)throw new i("Separately rounded burns exceed maxShares.");let Z=M.map(S=>Xt(ea(At),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 ${G} 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.`,P=Yt({abi:yt,functionName:"vaultExitBundlesV1InKindRedemptionVaultV2",args:[t,H,Z,l,{value:0n,nonce:0n,deadline:0n,v:0,r:kt,s:kt},u]}),D=[e.approval(t,Ke,G.toString(),p),e.unsignedTx({to:Ke,data:P,value:"0",chainId:p,description:F})],$=await e.preview(D,n),j=-$.changes.filter(S=>S.token.chainId===p&&E(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(j<=0n||j>G)throw new i("In-kind preview exceeds the exact share authorization or burns no shares.");return{txs:D,preview:$,summary:F,receipt:{idleAssets:y.toString(),positions:M.map(S=>({marketId:S.marketId,asset:s,assets:S.assets.toString()})),penaltyAssets:C.toString()}}}var pe=ie("0x53A1eB6589861F686af7c531211E35Aefe30210f"),xt=["supply","withdraw","supplyCollateralAndBorrow","repayAndWithdrawCollateral","migrateBorrowPosition"],Qe={kind:0,data:"0x"},Oe={nonce:0n,deadline:0n,signature:{v:0,r:It,s:It}},na=ra("(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)"),Tt=e=>({tools:[{name:"morpho_bundle",inputSchema:{type:"object",additionalProperties:!1,required:["operation","marketId","deadline"],properties:{operation:{type:"string",enum:xt},marketId:{type:"string"},destinationMarketId:{type:"string"},assets:A(),collateralAssets:A(),shares:A(),maxRepayAssets:A(),maxLtv:A(),deadline:A(),allocations:{type:"array",maxItems:4,items:{type:"object",additionalProperties:!1,required:["vault","assets","maxPenaltyAssets"],properties:{vault:{type:"string"},sourceMarketId:{type:"string"},assets:A(),maxPenaltyAssets:A()}}}}},execute:async(t,s)=>{try{q(s);let r=t.operation,n=e.clientFor(p);if(await n.getChainId()!==p||typeof r!="string"||!xt.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(P=>!l.includes(P)))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,d]=await Promise.all([n.readContract({address:pe,abi:Ne,functionName:"BLUE",blockNumber:a.number}),n.readContract({address:pe,abi:Ne,functionName:"PUBLIC_ALLOCATOR",blockNumber:a.number})]);if(ie(u)!==U||ie(d)!==bt)throw new i("BlueBundlesV1 deployment does not match Oak\u2019s pinned Blue and Public Allocator.");let m=async P=>{if(typeof P!="string"||!W(P))throw new i("Choose a verified Morpho market with a supported exit.");let D=await n.readContract({address:U,abi:O,functionName:"idToMarketParams",args:[P],blockNumber:a.number}),$={loanToken:ie(D[0]),collateralToken:ie(D[1]),oracle:ie(D[2]),irm:ie(D[3]),lltv:D[4]};if(!E(be({...$,lltv:String($.lltv)}),P))throw new i("Blue bundle market identity mismatch.");return $},c=await m(t.marketId),f=r==="migrateBorrowPosition"?await m(t.destinationMarketId):c;if(c.loanToken!==f.loanToken||c.collateralToken!==f.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:U,abi:O,functionName:"isAuthorized",args:[s,pe],blockNumber:a.number}))throw new i(`Authorize the pinned Blue bundle explicitly with morpho_manage setAuthorization account ${pe}, 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),w=t.shares===void 0?0n:N(t.shares,!0),h=t.collateralAssets===void 0?0n:N(t.collateralAssets,!0),y=r==="supply"||r==="withdraw"?0n:N(t.maxLtv,!0);if(y>f.lltv)throw new i("maxLtv cannot exceed the verified destination market LLTV.");if(r==="supply"&&b===0n||r==="withdraw"&&b===0n==(w===0n)||r==="supplyCollateralAndBorrow"&&h===0n&&b===0n||r==="repayAndWithdrawCollateral"&&(b>0n&&w>0n||b===0n&&w===0n&&h===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=[],I=0n;for(let P of k){if(!P||typeof P!="object"||Array.isArray(P)||Object.keys(P).some(Ve=>!["vault","sourceMarketId","assets","maxPenaltyAssets"].includes(Ve)))throw new i("Unsupported bundled allocation input.");let D=P,$=await wt(e,{vault:D.vault,marketId:r==="migrateBorrowPosition"?t.destinationMarketId:t.marketId});if(g.has($.definition.vault.toLowerCase()))throw new i("Use each source vault at most once per bundle.");g.add($.definition.vault.toLowerCase());let j=N(D.assets),S=N(D.maxPenaltyAssets,!0);if(!$.permission||j>=1n<<128n||j>$.headroom||$.penalty>10n**18n||$.asset.address!==f.loanToken)throw new i("Bundled allocation is disabled, unqualified or exceeds target capacity.");let B=(j*$.penalty+10n**18n-1n)/10n**18n;if(B>S)throw new i("Bundled allocation exceeds maxPenaltyAssets.");I+=B;let Te=D.sourceMarketId===void 0,ee=Te?void 0:$.sources.find(Ve=>E(Ve.id,String(D.sourceMarketId)));if(Te?!$.canIdle||j>$.data.idle:!ee||!ee.canPull||j>ee.capacity||j>$.data.blueCash)throw new i("Bundled allocation source cannot cover the requested amount.");T.push({vault:$.definition.vault,adapter:$.target.adapter,marketParams:$.params,sourceAdapter:ee?.adapter??fe,sourceMarketParams:ee?aa(na,ee.data)[0]:$.params,assets:j,penalty:$.penalty,fromIdle:Te})}let M,C,v,x=0n;if(r==="supply")M="blueBundlesV1Supply",v=c.loanToken,x=b,C=[c,b,Qe,0n,fe,o];else if(r==="withdraw")M="blueBundlesV1Withdraw",C=[c,b,w,Oe,T,0n,fe,o];else if(r==="supplyCollateralAndBorrow"){if(M="blueBundlesV1SupplyCollateralAndBorrow",v=c.collateralToken,x=h,I>=b&&I>0n)throw new i("Allocation penalties would consume the borrow proceeds.");C=[c,h,b,y,Qe,Oe,T,0n,fe,o]}else if(r==="repayAndWithdrawCollateral"){if(M="blueBundlesV1RepayAndWithdrawCollateral",v=c.loanToken,x=N(t.maxRepayAssets,!0),b>x||w>0n&&x===0n)throw new i("Repayment requires a sufficient maxRepayAssets budget.");C=[c,b,w,x,h,y,Qe,Oe,0n,fe,o]}else M="blueBundlesV1MigrateBorrowPosition",C=[c,f,y,Oe,T,0n,fe,o];let G=`Morpho Blue atomic ${r}: ${JSON.stringify(t)}. Allocation penalties ${I} 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 ${x}. Existing Blue bundle authorization remains until explicitly revoked with morpho_manage. No opaque callback, permit or signature is accepted.`,Z=[...v&&x?[e.approval(v,pe,x.toString(),p)]:[],e.unsignedTx({to:pe,data:oa({abi:Ne,functionName:M,args:C}),value:"0",chainId:p,description:G})],H=await e.preview(Z,s),F=new Map;for(let P of H.changes)if(BigInt(P.amount)<0n){let D=P.token.address.toLowerCase();F.set(D,(F.get(D)??0n)-BigInt(P.amount))}if([...F].some(([P,D])=>!v||P!==v.toLowerCase()||D>x))throw new i("Bundle preview spends outside the exact input budget.");return{txs:Z,preview:H,summary:G}}catch(r){throw new i(e.plainError(r))}}}]});import{concatHex as Mt,decodeAbiParameters as sa,encodeAbiParameters as $t,encodeFunctionData as Xe,erc20Abi as Pt,getAddress as K,keccak256 as Je,zeroAddress as we,zeroHash as ia}from"viem";var Y=K("0x6120765Ba5336150BbdDdD0Cd9108B5bFD369632"),la=["0x90B800999e4ACd1bD20283BD450bBd2e06D91F7C","0x708d6Bf6F847202a0755bb5636bE663B174242ea"].map(e=>K(e)),Ze=ae.find(e=>e.name==="take"),vt=[Ze.inputs[0]],da=[Ze.inputs[0].components[0]];function Ct(e){let t=Je(Mt(["0x600b380380600b5f395ff3",$t(da,[e])]));return Je(Mt(["0xff",e.midnight,ia,t]))}var le=10n**18n,Lt=(e,t)=>(e+(t-1n)/2n)/t;function Dt(e){if(e<0n)return 10n**36n/Dt(-e);let t=693147180559945309n,s=(e+322611214989459870n)/t,r=e-s*t,n=r*r/(2n*le),l=n*r/(3n*le);return le+r+n+l<<s}function ca(e){if(e<0n||e>6744n)throw new i("Midnight tick is outside 0..6744.");return Lt(Lt(10n**36n,le+Dt(4987541511039073n*(3372n-e))),10n**11n)*10n**11n}function Ge(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 Ye(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 ua=e=>JSON.parse(JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s)),Ut=e=>{async function t(n,l){let a=Ge(n,32),o=e.clientFor(p);if(await o.getChainId()!==p)throw new i("Midnight requires chain 4663.");let u=await o.getBlock(),d=(k,g=[])=>o.readContract({address:Y,abi:ae,functionName:k,args:g,blockNumber:u.number}),m=await d("toMarket",[a]);if(m.chainId!==BigInt(p)||K(m.midnight)!==Y||!E(Ct(m),a))throw new i("Midnight market identity does not match the pinned chain and contract.");if(![V[p].tokens.USDG.address,V[p].tokens.WETH.address].some(k=>E(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[f,b,w,h]=await Promise.all([d("position",[a,l]),d("updatePositionView",[m,a,l]),d("marketState",[a]),d("isHealthy",[m,a,l])]),y=async k=>{let[g,T]=await Promise.all([o.readContract({address:k,abi:Pt,functionName:"decimals",blockNumber:u.number}),o.readContract({address:k,abi:Pt,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:p}};return{id:a,rpc:o,block:u,market:m,read:d,token:y,loan:await y(m.loanToken),position:Ye(f,6),updated:Ye(b,3),state:Ye(w,13),healthy:h}}let s=(n,l,a,o)=>({name:n,inputSchema:{type:"object",properties:l,required:a,additionalProperties:!1},execute:async(u,d)=>{try{if(q(d),Object.keys(u).some(m=>!Object.hasOwn(l,m)))throw new i("Unsupported Midnight argument.");return await o(u,d)}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"}},["marketId"],async(n,l)=>{let a=await t(n.marketId,l),o=await Promise.all(a.market.collateralParams.map(async(m,c)=>({token:await a.token(m.token),lltvWad:m.lltv.toString(),oracle:m.oracle,assets:String(await a.read("collateral",[a.id,l,BigInt(c)]))}))),u=["configurator","feeSetter","feeClaimer","tickSpacingSetter"],d=await Promise.all(u.map(m=>a.read(m)));return{protocol:Object.fromEntries(u.map((m,c)=>[m,K(String(d[c]))])),continuousFeePerSecondWad:String(a.state[11]),tickSpacing:String(a.state[12]),settlementFeeCbps:a.state.slice(4,11).map(String),settlementFeeCbpWadScale:"1000000000000",chainId:p,midnight:Y,marketId:a.id,blockNumber:String(a.block.number),market:ua(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"},units:A(),maxAssets:A(),minAssets:A()},["offer","ratifierData","units","maxAssets","minAssets"],async(n,l)=>{let a=Ge(n.offer),[o]=sa(vt,a);if(!E($t(vt,[o]),a))throw new i("Offer encoding is not canonical.");let u=await t(Ct(o.market),l),d=N(n.units),m=N(n.maxAssets,!0),c=N(n.minAssets,!0),f=Ge(n.ratifierData);if(d>=1n<<128n||E(o.maker,l)||o.callback!==we||o.callbackData!=="0x"||!la.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!==we||!o.buy&&o.receiverIfMakerIsSeller===we)throw new i("Invalid offer seller receiver.");if(o.buy&&u.block.timestamp>u.market.maturity&&d>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]),w=ca(o.tick);if(b>w&&o.buy)throw new i("Settlement fee exceeds the offer price.");let h=o.buy?w-b:w,y=h+b,k=P=>o.buy?P/le:(P+le-1n)/le,g=k(d*y),T=k(d*h);if(o.buy?T<c||T===0n:g>m||g===0n)throw new i("Midnight proceeds/spend do not fit the requested bounds.");let I=await u.read("consumed",[o.maker,o.group]);if(o.maxAssets===0n==(o.maxUnits===0n)||I+(o.maxAssets?o.buy?g:T:d)>(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:[Ze.inputs[0],{type:"bytes"},{type:"address"}],outputs:[{type:"bytes32"}]}],v=await u.rpc.readContract({address:o.ratifier,abi:C,functionName:"isRatified",args:[o,f,l],blockNumber:u.block.number});if(M!==!0||v!==Je(new TextEncoder().encode("morpho.midnight.callbackSuccess")))throw new i("The maker has not authorized and ratified this exact offer.");let x=Xe({abi:ae,functionName:"take",args:[o,f,d,l,o.buy?l:we,we,"0x"]}),G=`Midnight ${o.buy?"sell credit or borrow":"buy credit or reduce debt"}: ${d} 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(),p)],e.unsignedTx({to:Y,data:x,value:"0",chainId:p,description:G})],H=await r(Z,l,G),F=H.preview.changes.filter(P=>P.token.chainId===p&&E(P.token.address,u.loan.address)).reduce((P,D)=>P+BigInt(D.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"},operation:{enum:["supplyCollateral","withdrawCollateral","repay","withdraw","updatePosition","claimContinuousFee"]},amount:A(),collateralIndex:{type:"integer",minimum:0,maximum:127}},["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,d,m=a.loan,c=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(c=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,c,l]}else{if(c=N(n.amount),c>=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 w=BigInt(String(n.collateralIndex)),h=await a.token(a.market.collateralParams[Number(w)].token);if(m=h,o==="withdrawCollateral"&&c>await a.read("collateral",[a.id,l,w]))throw new i("Insufficient Midnight collateral.");u=o==="supplyCollateral"?[a.market,w,c,l]:[a.market,w,c,l,l],o==="supplyCollateral"&&(d=h)}else{if(n.collateralIndex!==void 0)throw new i("This operation takes no collateral index.");if(o==="repay"&&c>a.position[4]||o==="withdraw"&&(c>a.updated[0]||c>a.state[2]))throw new i("Amount exceeds current debt, credit or available repayment liquidity.");u=o==="repay"?[a.market,c,l,we,"0x"]:[a.market,c,l,l],o==="repay"&&(d=a.loan)}}let f=`Midnight ${o}: ${c} ${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=[...d?[e.approval(d.address,Y,c.toString(),p)]:[],e.unsignedTx({to:Y,data:Xe({abi:ae,functionName:String(o),args:u}),value:"0",chainId:p,description:f})];return r(b,l,f)}),s("morpho_midnight_manage",{operation:{type:"string",enum:["setConsumed","setIsAuthorized","setConfigurator","setFeeSetter","setFeeClaimer","setTickSpacingSetter","enableLltv","enableLiquidationCursor","setMarketTickSpacing","setMarketSettlementFee","setMarketContinuousFee","setDefaultSettlementFee","setDefaultContinuousFee","claimSettlementFee"]},values:{type:"array",maxItems:3,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(f=>f.name===o);if(n.values.length!==u.inputs.length)throw new i("Provide the exact ordered operation values.");let d=e.clientFor(p);if(await d.getChainId()!==p)throw new i("Midnight requires chain 4663.");let m=u.inputs.map((f,b)=>{let w=n.values[b];if(f.type==="bool"){if(typeof w!="boolean")throw new i("Use boolean management values.");return w}if(f.type==="address")return Ue(w,"Use explicit management addresses.",De);if(f.type==="bytes32")return Ge(w,32);if(/^uint/.test(f.type)){let h=N(w,!0);if(h>=1n<<BigInt(f.type.slice(4)))throw new i("Management integer exceeds its ABI width.");return h}throw new i("Unsupported management argument type.")});if(o==="setConsumed"||o==="setIsAuthorized"){if(!E(String(m[2]),l))throw new i("Midnight management is bound to this wallet.")}else{let f=await d.readContract({address:Y,abi:ae,functionName:a[o]});if(typeof f!="string"||K(f)!==K(l))throw new i("This wallet lacks the Midnight configuration, fee or tick role.")}let c=`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:Xe({abi:ae,functionName:o,args:m}),value:"0",chainId:p,description:c})],l,c)})]}};import{decodeAbiParameters as oe,encodeAbiParameters as ma,encodeFunctionData as R,erc20Abi as et,getAddress as L,isAddress as Re,keccak256 as fa,parseAbi as Ee,parseAbiParameters as J}from"viem";var Pe="morpho",pa="https://api.morpho.org/graphql",U=L(V[p].morpho.morpho_blue.address),ba=L(V[p].morpho.adaptive_curve_irm.address),wa=L(V[p].morpho.USDG.address),de=L(V[p].morpho.WETH.address),ha=["0x7c820d6a09502d63be80bb8025ec479d29d7c06e70f8df65a92aaeed23a366e2","0x1fa5293f9f60059a7f6a4923022156fcdcc038bd3749be55897000c03afe92d8"],ka={"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."},tt=[{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"}],ya=new Map(tt.map(e=>[e.marketId.toLowerCase(),e]));function W(e){return ya.get(e.toLowerCase())}function ot(e){let t=W(e);return t?{actions:"enabled",label:t.label,source:ka[t.source]}:{actions:"read-only",reason:"Not in Oak's verified Morpho market registry; Oak builds no transactions for it."}}var Bt=20,ve=120n,_e=1000000n,He=1n,he=10n**18n,ga=10n**36n,Et=(1n<<128n)-1n,Sa=(1n<<256n)-1n,X=Ee(["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)"]),Aa=Ee(["function price() view returns (uint256)"]),Ia=Ee(["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)"]),_t=Ee(["function deposit() payable"]);function ce(e){return{loanToken:e.loanToken,collateralToken:e.collateralToken,oracle:e.oracle,irm:e.irm,lltv:e.lltv.toString()}}function Ce(e,t){return e===0n?0n:(e+t-1n)/t}function xa(e,t,s){return e*(s+_e)/(t+He)}function Ta(e,t,s){return Ce(e*(s+_e),t+He)}function rt(e,t,s){return e*(t+He)/(s+_e)}function ne(e,t,s){return Ce(e*(t+He),s+_e)}function ke(e,t,s){return e*t/ga*s/he}function Ma(e,t,s){return t.startsWith("-")?`-${e.formatAmount(t.slice(1),s)}`:e.formatAmount(t,s)}function ye(e,t){let s=[],r={};for(let n of t.changes){let l=Ma(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 Ht(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 qe(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"||!Re(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:Me(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>=he)throw new i("Morpho marketParams LLTV must be between 0 and 1e18.");return{loanToken:t,collateralToken:s,oracle:r,irm:n,lltv:l}}function be(e){let t=qe(e),s=ma(J("address, address, address, address, uint256"),[t.loanToken,t.collateralToken,t.oracle,t.irm,t.lltv]);return fa(s)}function at(e){let t=e.toLowerCase();return t===dt.toLowerCase()||t===ct.toLowerCase()||t===te.toLowerCase()}function ge(e,t){let s=t??e.wallet;if(!s)throw new i("Provide a valid wallet address.");return q(s),L(s)}async function re(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 qt(e){return typeof e=="string"&&/^[A-Za-z0-9$._+-]{1,32}$/.test(e)?e:"UNKNOWN"}async function Q(e,t,s=p){if(q(t),at(t))return{...ut,chainId:s};let r=L(t),n=r.toLowerCase();if(s===p){if(n===wa.toLowerCase())return mt;if(n===de.toLowerCase())return ft}let[l,a]=await Promise.all([re(e,r,R({abi:et,functionName:"symbol"})),re(e,r,R({abi:et,functionName:"decimals"}))]),[o]=oe(J("string"),l),[u]=oe(J("uint8"),a);return{address:r,symbol:qt(o),decimals:Number(u),chainId:s}}async function Ft(e,t){let s=await re(e,U,R({abi:X,functionName:"idToMarketParams",args:[t]})),[r,n,l,a,o]=oe(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 re(e,U,R({abi:X,functionName:"market",args:[t]})),[r,n,l,a,o,u]=oe(J("uint128, uint128, uint128, uint128, uint128, uint128"),s);return{totalSupplyAssets:r,totalSupplyShares:n,totalBorrowAssets:l,totalBorrowShares:a,lastUpdate:o,fee:u}}async function Se(e,t,s){let r=await re(e,U,R({abi:X,functionName:"position",args:[t,L(s)]})),[n,l,a]=oe(J("uint256, uint128, uint128"),r);return{supplyShares:n,borrowShares:l,collateral:a}}async function Fe(e,t){let s=await re(e,L(t),R({abi:Aa,functionName:"price"})),[r]=oe(J("uint256"),s);return r}async function Pa(e,t,s){if(t.irm===te)return 0n;let r=await re(e,L(t.irm),R({abi:Ia,functionName:"borrowRateView",args:[t,s]})),[n]=oe(J("uint256"),r);return n}function je(e,t,s){let r=s>e.lastUpdate?s-e.lastUpdate:0n,n=t*r,l=Ce(n*n,2n*he),a=Ce(l*n,3n*he);return e.totalBorrowAssets+Ce(e.totalBorrowAssets*(n+l+a),he)}async function Le(e,t,s,r=0n){let[n,l]=await Promise.all([e.getBlock({blockTag:"latest"}),Pa(e,t,s)]),a=BigInt(Math.ceil(Date.now()/1e3)),o=(n.timestamp>a?n.timestamp:a)+r;return{totalBorrowAssets:je(s,l,o),accruedThrough:o,rate:l}}async function Vt(e,t,s){let r=await re(e,L(t),R({abi:et,functionName:"balanceOf",args:[L(s)]})),[n]=oe(J("uint256"),r);return n}async function ue(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?qe(n):void 0,a=l?be(l):void 0,o=r!==void 0?Ht(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&&!W(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[d,m]=await Promise.all([Ft(e,u),jt(e,u)]);if(d.loanToken===te||d.collateralToken===te||d.lltv===0n||m.lastUpdate===0n)throw new i(`Morpho market ${u} is not initialized on chain ${p}.`);let c=be(d);if(c.toLowerCase()!==u.toLowerCase())throw new i(`On-chain idToMarketParams tuple hash (${c}) does not match marketId (${u}).`);if(l&&!(l.loanToken.toLowerCase()===d.loanToken.toLowerCase()&&l.collateralToken.toLowerCase()===d.collateralToken.toLowerCase()&&l.oracle.toLowerCase()===d.oracle.toLowerCase()&&l.irm.toLowerCase()===d.irm.toLowerCase()&&l.lltv===d.lltv))throw new i(`Provided marketParams tuple does not match on-chain idToMarketParams for ${u}.`);return{marketId:u,marketParams:d,marketState:m}}function Ae(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=Me(t);if(s<=0n||s>Et)throw new i("Asset amount must be greater than zero and fit in uint128.");return s}function Ie(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 va(e,t,s){let r=ge(t,s);Ie(t,r);let n=r,l=e.clientFor(p),{marketId:a,marketParams:o}=await ue(l,t,!0),u=await Q(l,o.collateralToken,p),d=o.collateralToken.toLowerCase()===de.toLowerCase(),m=typeof t.collateralToken=="string"?(q(t.collateralToken),L(t.collateralToken)):void 0,c=z("wrapNative",t.wrapNative)===!0||m!==void 0&&at(m);if(m&&!at(m)&&m.toLowerCase()!==o.collateralToken.toLowerCase())throw new i(`Collateral token ${m} does not match market collateral ${o.collateralToken}.`);if(c&&!d)throw new i("Native ETH wrapping is only supported when market collateralToken is WETH.");let f=Ae(t),b=f.toString(),w=e.formatAmount(b,u.decimals),h=[];c&&h.push(e.unsignedTx({chainId:p,to:de,data:R({abi:_t,functionName:"deposit"}),value:b,description:`Wrap ${w} ETH into WETH at ${de}.`})),h.push(e.approval(o.collateralToken,U,b,p)),h.push(e.unsignedTx({chainId:p,to:U,data:R({abi:X,functionName:"supplyCollateral",args:[o,f,n,"0x"]}),value:"0",description:`Supply ${w} ${u.symbol} (${b} base units) collateral to Morpho market ${a}.`}));let y=await e.preview(h,r),{formattedChanges:k,formattedNetOutflows:g}=ye(e,y);return{action:"morpho_supply_collateral",chainId:p,marketId:a,marketParams:ce(o),collateralToken:u,assets:b,formattedAssets:w,onBehalf:n,txs:h,summary:`${c?`Send ${w} ETH to wrap into WETH. `:""}Supply ${w} ${u.symbol} collateral to Morpho Blue market ${a}.`,preview:y,formattedChanges:k,formattedNetOutflows:g}}async function Ca(e,t,s){let r=ge(t,s);Ie(t,r);let n=r,l=r,a=e.clientFor(p),{marketId:o,marketParams:u,marketState:d}=await ue(a,t,!0),[m,c,f,b]=await Promise.all([Q(a,u.loanToken,p),Se(a,o,n),Fe(a,u.oracle),Le(a,u,d,ve)]),w=Ae(t),h=w.toString(),y=e.formatAmount(h,m.decimals),k=d.totalSupplyAssets>d.totalBorrowAssets?d.totalSupplyAssets-d.totalBorrowAssets:0n;if(w>k)throw new i(`Insufficient market liquidity: requested ${h} base units, available ${k.toString()} base units.`);let g=ke(c.collateral,f,u.lltv),T=ne(c.borrowShares,b.totalBorrowAssets,d.totalBorrowShares);if(c.collateral===0n||T+w>g)throw new i(`Insufficient collateral or unhealthy borrow: total debt ${(T+w).toString()} exceeds max borrow ${g.toString()} base units.`);let I=Ta(w,b.totalBorrowAssets,d.totalBorrowShares),C=[e.unsignedTx({chainId:p,to:U,data:R({abi:X,functionName:"borrow",args:[u,w,0n,n,l]}),value:"0",description:`Borrow ${y} ${m.symbol} (${h} base units) from Morpho market ${o}.`})],v=await e.preview(C,r),{formattedChanges:x,formattedNetOutflows:G}=ye(e,v);return{action:"morpho_borrow",chainId:p,marketId:o,marketParams:ce(u),loanToken:m,assets:h,formattedAssets:y,borrowShares:I.toString(),onBehalf:n,receiver:l,txs:C,summary:`Borrow ${y} ${m.symbol} from Morpho Blue market ${o}.`,preview:v,formattedChanges:x,formattedNetOutflows:G}}async function La(e,t,s){let r=ge(t,s);Ie(t,r);let n=r,l=e.clientFor(p);if(t.shares!==void 0){let x=Me(t.shares);if(x<=0n||x===Sa||x>Et)throw new i("Morpho Blue core does not accept maxUint256 or out-of-range share sentinels; pass exact position.borrowShares.")}if(z("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 ue(l,t,!0),[d,m,c]=await Promise.all([Q(l,o.loanToken,p),Se(l,a,n),Vt(l,o.loanToken,r)]);if(m.borrowShares===0n)throw new i(`Position has no active borrow debt on Morpho market ${a}.`);let f=0n,b=0n;if(z("repayAll",t.repayAll)===!0)b=m.borrowShares;else if(t.shares!==void 0){let x=Me(t.shares);if(x>m.borrowShares)throw new i(`Repay shares (${x.toString()}) exceed current position borrowShares (${m.borrowShares.toString()}).`);b=x}else f=Ae(t);let w=b>0n?await Le(l,o,u,ve):void 0,h=b>0n?ne(b,w.totalBorrowAssets,u.totalBorrowShares):f;if(c<h)throw new i(`Insufficient loan token balance for repayment: wallet holds ${c.toString()} base units, but ${h.toString()} base units are required (including accrued interest).`);let y=h.toString(),k=e.formatAmount(y,d.decimals),g=e.approval(o.loanToken,U,y,p),T=e.unsignedTx({chainId:p,to:U,data:R({abi:X,functionName:"repay",args:[o,f,b,n,"0x"]}),value:"0",description:b>0n?`Repay ${b.toString()} borrow shares (${k} ${d.symbol}) on Morpho market ${a}.`:`Repay ${k} ${d.symbol} (${f.toString()} base units) on Morpho market ${a}.`}),I=[g,T],M=await e.preview(I,r),{formattedChanges:C,formattedNetOutflows:v}=ye(e,M);return{action:"morpho_repay",chainId:p,marketId:a,marketParams:ce(o),loanToken:d,repayAssets:f.toString(),repayShares:b.toString(),requiredAssets:y,...w?{accruedThrough:w.accruedThrough.toString(),borrowRatePerSecond:w.rate.toString(),inclusionSeconds:ve.toString()}:{},formattedRequiredAssets:k,onBehalf:n,txs:I,summary:b>0n?`Repay ${b.toString()} borrow shares (approval up to ${k} ${d.symbol}) on Morpho Blue market ${a}. Refresh if signing/inclusion takes more than ${ve} seconds.`:`Repay ${k} ${d.symbol} on Morpho Blue market ${a}.`,preview:M,formattedChanges:C,formattedNetOutflows:v}}async function $a(e,t,s){let r=ge(t,s);Ie(t,r);let n=r,l=r,a=e.clientFor(p),{marketId:o,marketParams:u,marketState:d}=await ue(a,t,!0),[m,c,f,b]=await Promise.all([Q(a,u.collateralToken,p),Se(a,o,n),Fe(a,u.oracle),Le(a,u,d,ve)]),w=z("withdrawAll",t.withdrawAll)===!0?c.collateral:Ae(t);if(w<=0n||w>c.collateral)throw new i(`Insufficient collateral to withdraw: requested ${w.toString()} base units, position holds ${c.collateral.toString()} base units.`);if(c.borrowShares>0n){let C=c.collateral-w,v=ke(C,f,u.lltv),x=ne(c.borrowShares,b.totalBorrowAssets,d.totalBorrowShares);if(x>v)throw new i(`Unhealthy collateral withdrawal: remaining max borrow ${v.toString()} would fall below current debt ${x.toString()} base units.`)}let h=w.toString(),y=e.formatAmount(h,m.decimals),g=[e.unsignedTx({chainId:p,to:U,data:R({abi:X,functionName:"withdrawCollateral",args:[u,w,n,l]}),value:"0",description:`Withdraw ${y} ${m.symbol} (${h} base units) collateral from Morpho market ${o}.`})],T=await e.preview(g,r),{formattedChanges:I,formattedNetOutflows:M}=ye(e,T);return{action:"morpho_withdraw_collateral",chainId:p,marketId:o,marketParams:ce(u),collateralToken:m,assets:h,formattedAssets:y,onBehalf:n,receiver:l,txs:g,summary:`Withdraw ${y} ${m.symbol} collateral from Morpho Blue market ${o}.`,preview:T,formattedChanges:I,formattedNetOutflows:M}}async function Da(e,t,s){let r=ge(t,s);Ie(t,r);let n=e.clientFor(p),{marketId:l,marketParams:a,marketState:o}=await ue(n,t,!0),u=z("wrapNative",t.wrapNative)===!0;if(u&&a.loanToken.toLowerCase()!==de.toLowerCase())throw new i("Native ETH wrapping is only supported when the market loanToken is WETH.");let d=Ae(t),m=d.toString(),[c,f]=await Promise.all([Q(n,a.loanToken,p),u?Promise.resolve(d):Vt(n,a.loanToken,r)]);if(f<d)throw new i(`Insufficient ${c.symbol} balance to lend: wallet holds ${f.toString()} base units, requested ${m}.`);let b=e.formatAmount(m,c.decimals),w=[];u&&w.push(e.unsignedTx({chainId:p,to:de,data:R({abi:_t,functionName:"deposit"}),value:m,description:`Wrap ${b} ETH into WETH at ${de}.`})),w.push(e.approval(a.loanToken,U,m,p)),w.push(e.unsignedTx({chainId:p,to:U,data:R({abi:X,functionName:"supply",args:[a,d,0n,r,"0x"]}),value:"0",description:`Lend ${b} ${c.symbol} (${m} base units) to Morpho market ${l}.`}));let h=xa(d,o.totalSupplyAssets,o.totalSupplyShares),y=await e.preview(w,r),{formattedChanges:k,formattedNetOutflows:g}=ye(e,y);return{action:"morpho_supply",chainId:p,marketId:l,marketParams:ce(a),loanToken:c,assets:m,formattedAssets:b,supplySharesEstimated:h.toString(),onBehalf:r,oak:ot(l),txs:w,summary:`${u?`Send ${b} ETH to wrap into WETH. `:""}Lend ${b} ${c.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 Ua(e,t,s){let r=ge(t,s);Ie(t,r);let n=e.clientFor(p),l=z("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 ue(n,t,!0),[d,m]=await Promise.all([Q(n,o.loanToken,p),Se(n,a,r)]);if(m.supplyShares===0n)throw new i(`This wallet has no lent ${d.symbol} on Morpho market ${a}.`);let c=rt(m.supplyShares,u.totalSupplyAssets,u.totalSupplyShares),f=l?0n:Ae(t),b=l?m.supplyShares:0n;if(!l&&f>c)throw new i(`Withdrawal exceeds the lent balance: requested ${f.toString()} base units, position holds about ${c.toString()}. Use withdrawAll for a full exit.`);let w=u.totalSupplyAssets>u.totalBorrowAssets?u.totalSupplyAssets-u.totalBorrowAssets:0n,h=l?c:f;if(h>w)throw new i(`Insufficient market liquidity: withdrawing ${h.toString()} base units needs idle assets, but only ${w.toString()} are available until borrowers repay. Withdraw at most that amount, or retry later.`);let y=e.formatAmount(h.toString(),d.decimals),g=[e.unsignedTx({chainId:p,to:U,data:R({abi:X,functionName:"withdraw",args:[o,f,b,r,r]}),value:"0",description:l?`Withdraw all ${m.supplyShares.toString()} supply shares (about ${y} ${d.symbol}) from Morpho market ${a}.`:`Withdraw ${y} ${d.symbol} (${f.toString()} base units) of lent assets from Morpho market ${a}.`})],T=await e.preview(g,r),{formattedChanges:I,formattedNetOutflows:M}=ye(e,T);return{action:"morpho_withdraw",chainId:p,marketId:a,marketParams:ce(o),loanToken:d,withdrawAssets:f.toString(),withdrawShares:b.toString(),estimatedAssets:h.toString(),formattedAssets:y,receiver:r,txs:g,summary:l?`Withdraw all lent ${d.symbol} (about ${y}, including interest) from Morpho Blue market ${a}.`:`Withdraw ${y} lent ${d.symbol} from Morpho Blue market ${a}.`,preview:T,formattedChanges:I,formattedNetOutflows:M}}async function zt(e,t,s){let r=await e.http(pa,{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 Wt(e){let t=`query Markets($chainId: Int!) {
2
+ markets(first: 1000, where: { chainId_in: [$chainId] }) {
3
+ items {
4
+ marketId chain { id } lltv listed
5
+ loanAsset { address symbol decimals }
6
+ collateralAsset { address symbol decimals }
7
+ oracle { address } morphoBlue { address } irmAddress
8
+ state { supplyAssets borrowAssets liquidityAssets fee supplyApy borrowApy }
9
+ warnings { type level }
10
+ }
11
+ pageInfo { count countTotal }
12
+ }
13
+ }`;try{let r=(await zt(e,t,{chainId:p})).markets;if(!Array.isArray(r?.items)||typeof r.pageInfo?.countTotal!="number"||r.pageInfo.countTotal!==r.items.length||r.items.some(n=>!n||typeof n.marketId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n.marketId)))throw new i("Morpho GraphQL returned an incomplete or invalid market inventory.");return r.items}catch(s){throw new i(`Morpho GraphQL read failed: ${se(s)}`)}}async function Ba(e,t){return(await Wt(e)).find(r=>r.marketId.toLowerCase()===t)??null}async function Na(e,t){let r=await zt(e,`query Positions($chainId: Int!, $wallet: String!) {
14
+ marketPositions(first: 1000, where: { chainId_in: [$chainId], userAddress_in: [$wallet] }) {
15
+ items { market { marketId } }
16
+ pageInfo { countTotal }
17
+ }
18
+ }`,{chainId:p,wallet:t}),n=r.marketPositions?.items;if(!Array.isArray(n)||r.marketPositions?.pageInfo?.countTotal!==n.length)throw new i("Morpho GraphQL returned an incomplete wallet position list.");return n.map(l=>Ht(l.market?.marketId))}function Nt(e){let t=e;return!t||typeof t.address!="string"||!Re(t.address,{strict:!1})?null:{address:L(t.address),symbol:qt(t.symbol),decimals:typeof t.decimals=="number"?t.decimals:null}}function Ot(e){return typeof e=="string"&&Re(e,{strict:!1})?L(e):null}function Gt(e,t){if(e===void 0)return;if(typeof e!="string"||!e.trim())throw new i(`Morpho ${t} filter must be a token address or symbol.`);let s=e.trim().toLowerCase();return r=>!!r&&(String(r.address).toLowerCase()===s||typeof r.symbol=="string"&&r.symbol.toLowerCase()===s.replace(/^\$/,""))}async function Oa(e,t){if(t.marketId!==void 0||t.marketParams!==void 0||t.includeGraphql!==void 0)throw new i("Use discover without marketId, marketParams or includeGraphql.");let s=t.limit===void 0?20:Number(t.limit);if(!Number.isSafeInteger(s)||s<1||s>100)throw new i("Morpho discover limit must be an integer from 1 to 100.");let r=Gt(t.loanToken,"loanToken"),n=Gt(t.collateralToken,"collateralToken"),l=z("verifiedOnly",t.verifiedOnly)===!0,a=await Wt(e),o=a.map(d=>{let m=d.marketId.toLowerCase(),c=d.state??{},f=Nt(d.loanAsset),b=Nt(d.collateralAsset),w=Array.isArray(d.warnings)?d.warnings.map(h=>({type:String(h?.type??"").slice(0,64),level:String(h?.level??"").slice(0,16)})):[];return{marketId:m,listed:d.listed===!0,warnings:w,loanToken:f,collateralToken:b,lltv:typeof d.lltv=="string"||typeof d.lltv=="number"?String(d.lltv):null,oracle:Ot(d.oracle?.address),irm:Ot(d.irmAddress),state:{supplyAssets:c.supplyAssets===void 0?null:String(c.supplyAssets),borrowAssets:c.borrowAssets===void 0?null:String(c.borrowAssets),liquidityAssets:c.liquidityAssets===void 0?null:String(c.liquidityAssets),supplyApy:typeof c.supplyApy=="number"?c.supplyApy:null,borrowApy:typeof c.borrowApy=="number"?c.borrowApy:null},oak:ot(m)}}).filter(d=>(!l||d.oak.actions==="enabled")&&(!r||r(d.loanToken))&&(!n||n(d.collateralToken))),u=d=>{try{return BigInt(d.state.liquidityAssets??"0")}catch{return 0n}};return o.sort((d,m)=>{let c=+(m.oak.actions==="enabled")-+(d.oak.actions==="enabled");if(c)return c;let f=u(m)-u(d);return f>0n?1:f<0n?-1:0}),{chainId:p,morphoBlue:U,source:"Morpho API market inventory; token symbols, rates and liquidity are indexer data, not chain reads.",totalMatching:o.length,inventoryTotal:a.length,markets:o.slice(0,s),next:'Re-read a market with morpho_status {"marketId":"<id>"} before acting. Only oak.actions "enabled" markets accept Oak transactions.'}}async function Ga(e,t,s){let r=e.clientFor(p),n=s??t.wallet,l=n&&Re(n,{strict:!1})?L(n):void 0;if(z("discover",t.discover)===!0)return Oa(e,t);for(let d of["loanToken","collateralToken","verifiedOnly","limit"])if(t[d]!==void 0)throw new i(`Morpho ${d} is a discover filter; pass discover:true with it.`);let a=z("includeGraphql",t.includeGraphql)===!0,o=t.marketId||t.marketParams?[t]:ha.map(d=>({marketId:d})),u=await Promise.all(o.map(async d=>{let{marketId:m,marketParams:c,marketState:f}=await ue(r,d),[b,w,h,y,k,g]=await Promise.all([Q(r,c.loanToken,p),Q(r,c.collateralToken,p),Fe(r,c.oracle),Le(r,c,f),l?Se(r,m,l):Promise.resolve(void 0),a?Ba(e,m):Promise.resolve(void 0)]),T=f.totalSupplyAssets>f.totalBorrowAssets?f.totalSupplyAssets-f.totalBorrowAssets:0n,I;if(k){let M=k.borrowShares>0n?ne(k.borrowShares,y.totalBorrowAssets,f.totalBorrowShares):0n,C=k.supplyShares>0n?rt(k.supplyShares,f.totalSupplyAssets,f.totalSupplyShares):0n,v=ke(k.collateral,h,c.lltv),x=M>0n?e.formatAmount((v*he/M).toString(),18):null;I={supplyShares:k.supplyShares.toString(),supplyAssets:C.toString(),borrowShares:k.borrowShares.toString(),borrowAssets:M.toString(),collateralAssets:k.collateral.toString(),maxBorrowAssets:v.toString(),healthFactor:x}}return{marketId:m,marketParams:ce(c),loanToken:b,collateralToken:w,state:{totalSupplyAssets:f.totalSupplyAssets.toString(),totalSupplyShares:f.totalSupplyShares.toString(),totalBorrowAssets:f.totalBorrowAssets.toString(),totalBorrowShares:f.totalBorrowShares.toString(),availableLiquidity:T.toString(),lastUpdate:f.lastUpdate.toString(),fee:f.fee.toString()},oraclePrice:h.toString(),borrowRatePerSecond:y.rate.toString(),oak:ot(m),...I?{position:I}:{},...a?{graphql:g??null}:{}}}));return{chainId:p,morphoBlue:U,adaptiveCurveIrm:ba,markets:u}}async function Ra(e,t,s,r){let[n,l]=await Promise.all([Ft(t,s),jt(t,s)]),[a,o,u,d]=await Promise.all([Q(t,n.loanToken,p),Q(t,n.collateralToken,p),Fe(t,n.oracle),Le(t,n,l)]),m=[];r.collateral>0n&&m.push({token:o,amount:r.collateral.toString()});let c=r.supplyShares>0n?rt(r.supplyShares,l.totalSupplyAssets,l.totalSupplyShares):0n;c>0n&&m.push({token:a,amount:c.toString()});let f=r.borrowShares>0n?ne(r.borrowShares,d.totalBorrowAssets,l.totalBorrowShares):0n,b=ke(r.collateral,u,n.lltv),w=e.formatAmount(r.collateral.toString(),o.decimals),h=e.formatAmount(f.toString(),a.decimals);return{module:Pe,id:s,chainId:p,assets:m,description:`Morpho Blue market ${s}: collateral=${w} ${o.symbol} (${r.collateral.toString()}), debt=${h} ${a.symbol} (${f.toString()}, shares=${r.borrowShares.toString()}), maxBorrow=${b.toString()}${r.supplyShares>0n?`, lent=${e.formatAmount(c.toString(),a.decimals)} ${a.symbol} (supplyShares=${r.supplyShares.toString()})`:""}.${W(s)?"":" Read-only: not in Oak's verified market registry, so Oak cannot build exits here."}`}}async function Ea(e,t){q(t);let s=L(t),r=e.clientFor(p),n=[],l=new Set(tt.map(c=>c.marketId)),a;try{for(let c of await Na(e,s))l.add(c)}catch(c){a=se(c)}let o=[...l],u=[],d=[];if(typeof r.multicall=="function")try{let c=await r.multicall({multicallAddress:it,batchSize:0,allowFailure:!0,contracts:o.map(f=>({address:U,abi:X,functionName:"position",args:[f,s]}))});if(c.length!==o.length)throw new i("Morpho multicall returned an incomplete position list.");c.forEach((f,b)=>{let w=o[b];if(f.status!=="success"){d.push({marketId:w,reason:se(f.error)});return}let[h,y,k]=f.result;u.push({marketId:w,position:{supplyShares:h,borrowShares:y,collateral:k}})})}catch(c){d.push(...o.map(f=>({marketId:f,reason:se(c)})))}else for(let c=0;c<o.length;c+=Bt)u.push(...await Promise.all(o.slice(c,c+Bt).map(async f=>({marketId:f,position:await Se(r,f,s).catch(b=>{d.push({marketId:f,reason:se(b)})})}))));d.length&&n.push({module:Pe,id:"morpho-market-reads-incomplete",chainId:p,assets:[],incomplete:!0,description:`Morpho could not read ${d.length} of ${o.length} markets. ${[...new Set(d.map(c=>c.reason))].slice(0,3).join(" ")} Example market IDs: ${d.slice(0,3).map(c=>c.marketId).join(", ")}. Retry positions or check a known market with morpho_status {"marketId":"<id>"}; other readable markets are retained.`});let m=u.filter(c=>c.position!==void 0&&(c.position.supplyShares>0n||c.position.borrowShares>0n||c.position.collateral>0n));for(let{marketId:c,position:f}of m)try{n.push(await Ra(e,r,c,f))}catch(b){let w=W(c)!==void 0;n.push({module:Pe,id:c,chainId:p,assets:[],incomplete:!0,description:`Unreadable ${w?"verified":"unverified"} Morpho market ${c}: the wallet holds supplyShares=${f.supplyShares.toString()}, borrowShares=${f.borrowShares.toString()}, collateral=${f.collateral.toString()} base units, but its token or oracle reads failed (${se(b)}). Retry morpho_status {"marketId":"${c}"}.${w?"":" Read-only in Oak."}`})}return a!==void 0&&n.push({module:Pe,id:"morpho-discovery-unavailable",incomplete:!0,chainId:p,assets:[],description:`Incomplete: Morpho API position discovery failed (${a}). Only Oak's ${tt.length} verified markets were checked on chain; check any other market with morpho_status {"marketId":"<id>"}.`}),n}var _a=e=>({tools:[{name:"morpho_supply_collateral",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:A(),amount:A(),collateralToken:{type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},wrapNative:{type:"boolean"},onBehalf:{type:"string"}}},execute:(s,r)=>va(e,s,r)},{name:"morpho_withdraw_collateral",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:A(),amount:A(),withdrawAll:{type:"boolean"},onBehalf:{type:"string"},receiver:{type:"string"}}},execute:(s,r)=>$a(e,s,r)},{name:"morpho_borrow",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:A(),amount:A(),onBehalf:{type:"string"},receiver:{type:"string"}}},execute:(s,r)=>Ca(e,s,r)},{name:"morpho_repay",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:A(),amount:A(),shares:A(),repayAll:{type:"boolean"},onBehalf:{type:"string"}}},execute:(s,r)=>La(e,s,r)},{name:"morpho_supply",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:A(),amount:A(),wrapNative:{type:"boolean"},onBehalf:{type:"string"}}},execute:(s,r)=>Da(e,s,r)},{name:"morpho_withdraw",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:A(),amount:A(),withdrawAll:{type:"boolean"},onBehalf:{type:"string"},receiver:{type:"string"}}},execute:(s,r)=>Ua(e,s,r)},{name:"morpho_status",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},includeGraphql:{type:"boolean"},discover:{type:"boolean",description:"List the Morpho API market inventory with Oak action eligibility instead of reading markets on chain."},loanToken:{type:"string",description:"discover filter: loan token address or symbol."},collateralToken:{type:"string",description:"discover filter: collateral token address or symbol."},verifiedOnly:{type:"boolean",description:"discover filter: only markets Oak can act on."},limit:{type:"integer",minimum:1,maximum:100,description:"discover page size, default 20."}}},execute:(s,r)=>Ga(e,s,r)}].map(s=>{let r=new Set(Object.keys(s.inputSchema.properties));if(r.add("wallet"),s.name!=="morpho_status")for(let l of["onBehalf","receiver","data"])r.add(l);let n=new Set(["loanToken","collateralToken","oracle","irm","lltv"]);return{...s,execute:async(l,a)=>{for(let o of Object.keys(l))if(!r.has(o))throw new i(`Unknown argument ${ze(o)} for ${s.name}; remove it and retry.`);if(l.marketParams&&typeof l.marketParams=="object"){for(let o of Object.keys(l.marketParams))if(!n.has(o))throw new i(`Unknown Morpho marketParams field ${ze(o)}; remove it and retry.`)}return s.execute(l,a)}}}),positions:s=>Ea(e,s)}),Eo=e=>lt(Pe,[_a(e),ht(e),Rt(e),Ut(e),Tt(e)]);var _=V[p].morpho.morpho_blue.address,xe="(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)",O=st(["function owner() view returns (address)","function feeRecipient() view returns (address)","function isIrmEnabled(address) view returns (bool)","function isLltvEnabled(uint256) view returns (bool)","function isAuthorized(address,address) view returns (bool)","function nonce(address) view returns (uint256)",`function idToMarketParams(bytes32) view returns ${xe}`,"function market(bytes32) view returns (uint128,uint128,uint128,uint128,uint128,uint128)","function position(bytes32,address) view returns (uint256 supplyShares,uint128 borrowShares,uint128 collateral)",`function createMarket(${xe} marketParams)`,`function accrueInterest(${xe} marketParams)`,`function setFee(${xe} marketParams,uint256 newFee)`,"function setAuthorization(address authorized,bool newIsAuthorized)","function setOwner(address newOwner)","function setFeeRecipient(address newFeeRecipient)","function enableIrm(address irm)","function enableLltv(uint256 lltv)",`function liquidate(${xe} marketParams,address borrower,uint256 seizedAssets,uint256 repaidShares,bytes data) returns (uint256,uint256)`]),Fa=st(["function price() view returns (uint256)"]),ja=st([`function borrowRateView(${xe} marketParams,(uint128 totalSupplyAssets,uint128 totalSupplyShares,uint128 totalBorrowAssets,uint128 totalBorrowShares,uint128 lastUpdate,uint128 fee) market) view returns (uint256)`]),Qt=["createMarket","accrueInterest","setAuthorization","setOwner","setFeeRecipient","enableIrm","enableLltv","setFee"],Va=new Set(["setOwner","setFeeRecipient","enableIrm","enableLltv","setFee"]);function $e(e){if(typeof e!="string"||!/^\d+$/.test(e)||e.length>78||BigInt(e)>=1n<<256n)throw new i("Provide a uint256 decimal base-unit string.");return BigInt(e)}function nt(e){return Ue(e,"Provide an explicit account address.",De)}var Rt=e=>{async function t(){let n=e.clientFor(p);if(await n.getChainId()!==p)throw new i("Morpho protocol tools require chain 4663.");return n}async function s(n){if(typeof n!="string"||!W(n))throw new i("Choose a market in Oak\u2019s verified registry.");let l=await t(),a=await l.readContract({address:_,abi:O,functionName:"idToMarketParams",args:[n]}),o={loanToken:a[0],collateralToken:a[1],oracle:a[2],irm:a[3],lltv:a[4]};if(!E(be({...o,lltv:o.lltv.toString()}),n))throw new i("On-chain Morpho parameters do not match the selected market.");return{rpc:l,params:o,marketId:n}}let r=(n,l,a,o)=>({name:n,inputSchema:{type:"object",properties:l,required:a,additionalProperties:!1},execute:async(u,d)=>{try{if(q(d),Object.keys(u).some(m=>!Object.hasOwn(l,m)))throw new i("Unsupported Morpho protocol argument.");return await o(u,d)}catch(m){throw new i(e.plainError(m))}}});return{tools:[r("morpho_protocol",{authorized:{type:"string"}},[],async(n,l)=>{let a=await t(),[o,u,d]=await Promise.all([a.readContract({address:_,abi:O,functionName:"owner"}),a.readContract({address:_,abi:O,functionName:"feeRecipient"}),a.readContract({address:_,abi:O,functionName:"nonce",args:[l]})]),m=n.authorized===void 0?void 0:nt(n.authorized);return{chainId:p,morpho:_,owner:o,feeRecipient:u,nonce:d.toString(),...m?{authorized:m,isAuthorized:await a.readContract({address:_,abi:O,functionName:"isAuthorized",args:[l,m]})}:{}}}),r("morpho_manage",{operation:{enum:Qt},marketId:{type:"string"},marketParams:{type:"object"},account:{type:"string"},enabled:{type:"boolean"},value:A()},["operation"],async(n,l)=>{if(typeof n.operation!="string"||!Qt.includes(n.operation))throw new i("Choose a documented Morpho protocol operation.");let a=n.operation,o=await t(),u=a==="createMarket"?["operation","marketParams"]:a==="accrueInterest"?["operation","marketId"]:a==="setFee"?["operation","marketId","value"]:a==="enableLltv"?["operation","value"]:a==="setAuthorization"?["operation","account","enabled"]:["operation","account"];if(Object.keys(n).some(f=>!u.includes(f)))throw new i("Unexpected fields for this Morpho operation.");if(Va.has(a)){let f=await o.readContract({address:_,abi:O,functionName:"owner"});if(Kt(f)!==Kt(l))throw new i("This wallet does not hold the Morpho owner role.")}let d;if(a==="createMarket"){if(!n.marketParams||typeof n.marketParams!="object"||Array.isArray(n.marketParams)||Object.keys(n.marketParams).some(h=>!["loanToken","collateralToken","oracle","irm","lltv"].includes(h)))throw new i("Provide only the five documented market parameter fields.");let f=qe(n.marketParams),[b,w]=await Promise.all([o.readContract({address:_,abi:O,functionName:"isIrmEnabled",args:[f.irm]}),o.readContract({address:_,abi:O,functionName:"isLltvEnabled",args:[f.lltv]})]);if(!b||!w)throw new i("The new market\u2019s IRM and LLTV must first be enabled by the Morpho owner.");d=me({abi:O,functionName:"createMarket",args:[f]})}else if(a==="accrueInterest"||a==="setFee"){let{params:f}=await s(n.marketId);if(a==="setFee"){let b=$e(n.value);if(b>250000000000000000n)throw new i("Morpho market fee cannot exceed 25% (0.25e18).");d=me({abi:O,functionName:"setFee",args:[f,b]})}else d=me({abi:O,functionName:"accrueInterest",args:[f]})}else if(a==="enableLltv"){let f=$e(n.value);if(f>=10n**18n)throw new i("Morpho LLTV must be below 1e18.");d=me({abi:O,functionName:"enableLltv",args:[f]})}else{let f=nt(n.account);if(a==="setAuthorization"){if(typeof n.enabled!="boolean")throw new i("Provide enabled as a boolean.");d=me({abi:O,functionName:"setAuthorization",args:[f,n.enabled]})}else if(a==="setOwner"||a==="enableIrm"||a==="setFeeRecipient")d=me({abi:O,functionName:a,args:[f]});else throw new i("Unsupported Morpho operation.")}let m=`Morpho ${a}: ${JSON.stringify(n)}. ${a==="setAuthorization"&&n.enabled?"This account can manage all your Morpho positions, including borrowing and withdrawals. There is no amount cap.":""}${a==="setOwner"&&n.account===qa?"Setting the owner to zero permanently relinquishes protocol administration.":""}${a==="createMarket"?"New market creation does not add it to Oak\u2019s verified action registry.":""}`,c=[e.unsignedTx({to:_,data:d,value:"0",chainId:p,description:m})];return{txs:c,preview:await e.preview(c,l),summary:m}}),r("morpho_liquidate",{marketId:{type:"string"},borrower:{type:"string"},repaidShares:A(),maxAssets:A(),minCollateral:A()},["marketId","borrower","repaidShares","maxAssets","minCollateral"],async(n,l)=>{let{rpc:a,params:o,marketId:u}=await s(n.marketId),d=nt(n.borrower),m=$e(n.repaidShares),c=$e(n.maxAssets),f=$e(n.minCollateral),[b,w,h,y]=await Promise.all([a.readContract({address:_,abi:O,functionName:"market",args:[u]}),a.readContract({address:_,abi:O,functionName:"position",args:[u,d]}),a.readContract({address:o.oracle,abi:Fa,functionName:"price"}),a.getBlock()]);if(m===0n||m>w[1]||h===0n)throw new i("Liquidation shares must fit the current debt and the oracle must be valid.");let k={totalSupplyAssets:b[0],totalSupplyShares:b[1],totalBorrowAssets:b[2],totalBorrowShares:b[3],lastUpdate:b[4],fee:b[5]},g=await a.readContract({address:o.irm,abi:ja,functionName:"borrowRateView",args:[o,k]}),T=je(k,g,y.timestamp);if(ne(w[1],T,b[3])<=ke(w[2],h,o.lltv))throw new i("This borrower is healthy; liquidation is unavailable.");let I=ne(m,je(k,g,y.timestamp+120n),b[3]);if(I>c)throw new i("Liquidation funding exceeds maxAssets.");if(await a.readContract({address:o.loanToken,abi:Ha,functionName:"balanceOf",args:[l]})<I)throw new i("Top up the loan token before liquidating.");let C=`Liquidate ${m} debt shares of ${d} on ${u}; exact approval ${I} loan-token base units; preview minimum ${f} collateral units. No callbacks; the wallet funds repayment. Approval can leave interest-buffer dust; revoke it afterward.`,v=[e.approval(o.loanToken,_,I.toString(),p),e.unsignedTx({to:_,data:me({abi:O,functionName:"liquidate",args:[o,d,0n,m,"0x"]}),value:"0",chainId:p,description:C})],x=await e.preview(v,l),G=Z=>x.changes.filter(H=>H.token.chainId===p&&E(H.token.address,Z)).reduce((H,F)=>H+BigInt(F.amount),0n);if(-G(o.loanToken)<=0n||-G(o.loanToken)>I||G(o.collateralToken)<f||G(o.collateralToken)<=0n)throw new i("Liquidation preview does not match the funding limit and collateral minimum.");return{txs:v,preview:x,requiredAssets:I.toString(),summary:`${C} MinCollateral is a local simulation check, not an on-chain floor.`}})]}};export{O as a,Rt as b,pe as c,Tt as d,Y as e,la as f,vt as g,da as h,Ct as i,ca as j,Ut as k,Pe as l,pa as m,U as n,ba as o,wa as p,de as q,ha as r,ka as s,tt as t,W as u,ve as v,xa as w,Ta as x,rt as y,ne as z,ke as A,Ma as B,qe as C,be as D,qt as E,je as F,_a as G,Eo as H,Ke as I,yt as J,N as K,Za as L};
@@ -0,0 +1 @@
1
+ import{a as J,h as K}from"./CBA776XQ.js";import{a as F}from"./6IM6A5VA.js";import{a as E}from"./UWOFA6GV.js";import{c as D,d as Y,g as _,i as V,m as Q,n as z}from"./73N3TOJL.js";import{a as p,i as G,j}from"./XPFVT2EA.js";import{a as d}from"./5YS5V2LK.js";import{decodeFunctionData as X,encodeFunctionData as U,erc20Abi as O,getAddress as N,parseAbi as Z}from"viem";var e={router:N("0xf5198743240fac98db71868f34c70139b1eb0474"),factory:N("0xfa5429aeba338bea2bfcc1b9a889862ee395bc28"),pair:N("0x8697bb63743678640710b1270e98772a29642b3c"),weth:N("0x0bd7d308f8e1639fab988df18a8011f41eacad73"),up:N("0x57c0e45cb534413d1c20a4240955d6bb250bb4f1"),eth:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"},L=Z(["function token0() view returns (address)","function token1() view returns (address)","function factory() view returns (address)","function defaultFactory() view returns (address)","function stable() view returns (bool)","function getReserves() view returns (uint112,uint112,uint32)","function poolFor(address,address,bool,address) view returns (address)","function getPool(address,address,bool) view returns (address)","function getAmountsOut(uint256,(address from,address to,bool stable,address factory)[]) view returns (uint256[])","function quoteAddLiquidity(address,address,bool,address,uint256,uint256) view returns (uint256,uint256,uint256)","function addLiquidity(address,address,bool,uint256,uint256,uint256,uint256,address,uint256) returns (uint256,uint256,uint256)","function removeLiquidity(address,address,bool,uint256,uint256,uint256,address,uint256) returns (uint256,uint256)","function swapExactTokensForTokens(uint256,uint256,(address from,address to,bool stable,address factory)[],address,uint256) returns (uint256[])","function deposit() payable"]),ee=Z(["function want() view returns (address)"]),W={vault:D,chainId:{const:p},slippageBps:{type:"integer",minimum:0,maximum:500}},ue=["beefy_swap","beefy_add_liquidity","beefy_remove_liquidity"];function de(s,w){let l=()=>{throw new d("Beefy calldata differs from locally reconstructed inputs, recipient, route or minimums; nothing was signed.")};s.length!==w.length&&l();for(let S=0;S<s.length;S++){let q=s[S],v=w[S];if((q.chainId!==v.chainId||!_(q.to,v.to)||q.value!==v.value)&&l(),!_(q.data,v.data))try{let B=X({abi:L,data:q.data}),n=X({abi:L,data:v.data});(B.functionName!==n.functionName||!B.args||!n.args)&&l();let t=[...B.args],a=n.args,r=B.functionName==="swapExactTokensForTokens"?[1]:B.functionName==="addLiquidity"?[5,6]:B.functionName==="removeLiquidity"?[4,5]:l(),i=U({abi:L,functionName:B.functionName,args:t});_(i,q.data)||l();let u=t.length-1;(f(t[u])<=f(a[u])-600n||f(t[u])>f(a[u]))&&l(),t[u]=a[u];for(let o of r)f(t[o])<f(a[o])&&l(),t[o]=a[o];_(U({abi:L,functionName:B.functionName,args:t}),v.data)||l()}catch{l()}}}function y(s){return V(s,"Provide a token or vault address.",Y)}function R(s){return z(s,"Amount must be positive and fit in uint256.",{notString:"Provide a positive base-unit integer string.",positive:!0})}function f(s){return Q(s,"Invalid Beefy liquidity integer.")}function M(s){let w=s??50;if(typeof w!="number"||!Number.isInteger(w)||w<0||w>500)throw new d("Use integer slippageBps from 0 to 500.");return BigInt(w)}function H(s,w){let l=s*(10000n-w)/10000n;if(l===0n)throw new d("The liquidity amount is too small for a positive minimum output.");return l}var ce=s=>{async function w(n){try{return await n()}catch(t){throw new d(s.plainError(t))}}function l(n,t){if(n.chainId!==void 0&&n.chainId!==p)throw new d("Beefy requires chain 4663.");for(let a of Object.keys(n))if(!["vault","chainId",...t].includes(a))throw new d(`Unsupported Beefy input: ${a}.`);if(y(n.vault)!==N(G[p].vaults.beefyTestedLpVault.address))throw new d("Beefy LP routes are qualified only for up33-weth-up.")}async function S(){let n=s.clientFor(p);if(await n.getChainId()!==p)throw new d("The Beefy endpoint must report chain 4663.");let t=f(await n.getBlockNumber()),a=await n.getBlock({blockNumber:t}),r=f(a.timestamp)+600n,i=(P,g,A=[])=>n.readContract({address:P,abi:L,functionName:g,args:A,blockNumber:t}),[u,o,m,c,h,b]=await Promise.all([i(e.pair,"token0"),i(e.pair,"token1"),i(e.pair,"factory"),i(e.router,"defaultFactory"),i(e.pair,"stable"),n.readContract({address:G[p].vaults.beefyTestedLpVault.address,abi:ee,functionName:"want",blockNumber:t})]);if(y(u)!==e.weth||y(o)!==e.up||y(m)!==e.factory||y(c)!==e.factory||h!==!1||y(b)!==e.pair)throw new d("The Beefy LP, vault or router no longer matches the qualified route.");if(y(await i(e.router,"poolFor",[e.weth,e.up,!1,e.factory]))!==e.pair)throw new d("The router selects a different Beefy LP.");let k=async(P,g)=>f(await n.readContract({address:P,abi:O,functionName:"balanceOf",args:[g],blockNumber:t}));async function T(P){let[g,A]=await Promise.all([n.readContract({address:P,abi:O,functionName:"symbol",blockNumber:t}),n.readContract({address:P,abi:O,functionName:"decimals",blockNumber:t})]);if(typeof g!="string"||!g.trim()||typeof A!="number"||!Number.isInteger(A)||A<0||A>255)throw new d("Invalid Beefy constituent metadata.");return{address:P,symbol:g,decimals:A,chainId:p}}return{client:n,blockNumber:t,deadline:r,read:i,balance:k,token:T}}async function q(n,t,a){let r=await s.preview(n,t);return{txs:n,preview:r,summary:`${a} ${r.summary} Re-read balances after mining each step; these transactions are separate and earlier steps can remain mined if a later step fails. Gas is additional.`}}function v(n,t,a,r="0"){return s.unsignedTx({to:n,data:t,value:r,description:a,chainId:p})}return{tools:[{name:"beefy_lp",inputSchema:{type:"object",properties:{vault:D,chainId:{const:p},amount:{...E(),description:"Optional CLM entry budget in the bridge token base units."},slippageBps:W.slippageBps},required:["vault"],additionalProperties:!1},execute:(n,t)=>w(async()=>{if(J.some(b=>_(b.vault,y(n.vault))))return K(s).tools[0].execute(n,t);l(n,[]),F(t);let a=await S(),[r,i,u,o,m,c,h]=await Promise.all([a.token(e.weth),a.token(e.up),a.token(e.pair),a.read(e.pair,"getReserves"),a.balance(e.weth,t),a.balance(e.up,t),a.balance(e.pair,t)]);if(!Array.isArray(o)||o.length!==3)throw new d("Invalid Beefy LP reserves.");return{chainId:p,vault:y(n.vault),router:e.router,factory:e.factory,stable:!1,constituents:[{token:r,balance:m.toString(),reserve:f(o[0]).toString()},{token:i,balance:c.toString(),reserve:f(o[1]).toString()}],lp:{token:u,balance:h.toString()},block:a.blockNumber.toString(),summary:"Acquire WETH and UP with beefy_swap; add with beefy_add_liquidity, then deposit the mined LP balance with beefy_deposit. Withdraw moo shares, remove LP with beefy_remove_liquidity, then swap constituents to USDG. Every action requires its own preview and local confirmation."}})},{name:"beefy_swap",inputSchema:{type:"object",properties:{...W,from:D,to:D,amount:E()},required:["vault","from","to","amount"],additionalProperties:!1},execute:(n,t)=>w(async()=>{l(n,["from","to","amount","slippageBps"]),F(t);let a=y(n.from),r=y(n.to),i=R(n.amount),u=M(n.slippageBps),o=[e.weth,e.up,N(j)],m=a.toLowerCase()===e.eth;if(!m&&!o.includes(a)||!o.includes(r)||a===r)throw new d("Use ETH, WETH, UP or USDG as input and a different WETH, UP or USDG output.");let c=await S();if((m?await c.client.getBalance({address:t,blockNumber:c.blockNumber}):await c.balance(a,t))<i)throw new d("Insufficient Beefy swap input balance; keep ETH for gas.");let h=[];m&&h.push(v(e.weth,U({abi:L,functionName:"deposit"}),`Wrap ${i} ETH base units for the Beefy LP workflow.`,i.toString()));let b=m?e.weth:a,k=i,T=i;if(b!==r){let g=b===e.weth||r===e.weth?[b,r]:[b,e.weth,r],A=[];for(let I=0;I<g.length-1;I++){let C={from:g[I],to:g[I+1],stable:!1,factory:e.factory},$=y(await c.read(e.factory,"getPool",[C.from,C.to,!1]));if($==="0x0000000000000000000000000000000000000000"||$!==y(await c.read(e.router,"poolFor",[C.from,C.to,!1,e.factory])))throw new d("No verified Up33 route for these Beefy constituents.");A.push(C)}let x=await c.read(e.router,"getAmountsOut",[i,A]);if(!Array.isArray(x)||x.length!==g.length||f(x[0])!==i)throw new d("Invalid Beefy constituent quote.");for(let I of x)if(f(I)===0n)throw new d("No liquidity for this Beefy constituent swap.");k=f(x.at(-1)),T=H(k,u),h.push(s.approval(b,e.router,i.toString(),p)),h.push(v(e.router,U({abi:L,functionName:"swapExactTokensForTokens",args:[i,T,A,t,c.deadline]}),`Swap ${i} constituent base units; receive at least ${T} output base units.`))}let P=await c.token(r);return{...await q(h,t,"Prepare or convert Beefy LP constituents using the verified Up33 router."),output:{token:P,amount:k.toString()},minimumOutput:{token:P,amount:T.toString()},deadline:c.deadline.toString()}})},{name:"beefy_add_liquidity",inputSchema:{type:"object",properties:{...W,amount0:E(),amount1:E()},required:["vault","amount0","amount1"],additionalProperties:!1},execute:(n,t)=>w(async()=>{l(n,["amount0","amount1","slippageBps"]),F(t);let a=R(n.amount0),r=R(n.amount1),i=M(n.slippageBps),u=await S();if(await u.balance(e.weth,t)<a||await u.balance(e.up,t)<r)throw new d("Acquire the WETH and UP constituents with beefy_swap, then retry with their mined balances.");let o=await u.read(e.router,"quoteAddLiquidity",[e.weth,e.up,!1,e.factory,a,r]);if(!Array.isArray(o)||o.length!==3)throw new d("Invalid Beefy add-liquidity quote.");let m=f(o[0]),c=f(o[1]),h=f(o[2]);if(m>a||c>r||h===0n)throw new d("Invalid Beefy add-liquidity amounts.");let b=H(m,i),k=H(c,i),T=[s.approval(e.weth,e.router,a.toString(),p),s.approval(e.up,e.router,r.toString(),p),v(e.router,U({abi:L,functionName:"addLiquidity",args:[e.weth,e.up,!1,a,r,b,k,t,u.deadline]}),"Mint the supported Beefy want LP directly to the calling wallet."),s.approval(e.weth,e.router,"0",p),s.approval(e.up,e.router,"0",p)];return{...await q(T,t,"Mint UP\u2013WETH LP. The router may use less than the approved desired amounts; final revocations clear unused allowances. Deposit the actual LP received in a separate beefy_deposit call."),output:{token:await u.token(e.pair),amount:h.toString()},minimumInputs:[{token:await u.token(e.weth),amount:b.toString()},{token:await u.token(e.up),amount:k.toString()}],deadline:u.deadline.toString()}})},{name:"beefy_remove_liquidity",inputSchema:{type:"object",properties:{...W,amount:{anyOf:[E(),{const:"all"}]}},required:["vault","amount"],additionalProperties:!1},execute:(n,t)=>w(async()=>{l(n,["amount","slippageBps"]),F(t);let a=M(n.slippageBps),r=n.amount==="all"?void 0:R(n.amount),i=await S(),u=await i.balance(e.pair,t),o=r??u;if(o===0n||o>u)throw new d("Withdraw your moo shares first, then provide a positive LP amount no greater than the fresh LP balance.");let[m,c,h]=await Promise.all([i.client.readContract({address:e.pair,abi:O,functionName:"totalSupply",blockNumber:i.blockNumber}),i.balance(e.weth,e.pair),i.balance(e.up,e.pair)]);if(f(m)===0n||o>m)throw new d("Invalid Beefy LP total supply.");let b=H(c*o/m,a),k=H(h*o/m,a),T=[s.approval(e.pair,e.router,o.toString(),p),v(e.router,U({abi:L,functionName:"removeLiquidity",args:[e.weth,e.up,!1,o,b,k,t,i.deadline]}),"Burn Beefy want LP and return WETH and UP to the calling wallet.")];return{...await q(T,t,"Remove UP\u2013WETH liquidity. Convert actual received constituents to USDG with beefy_swap after mining."),minimumOutputs:[{token:await i.token(e.weth),amount:b.toString()},{token:await i.token(e.up),amount:k.toString()}],deadline:i.deadline.toString()}})}]}};export{e as a,L as b,ue as c,de as d,ce as e};
@@ -0,0 +1 @@
1
+ import{a as r,b as c}from"./JXOEJPJ4.js";var a=class extends Error{name="OakError"};function u(e){let n=[],t=new Set;for(;e&&typeof e=="object"&&!t.has(e)&&n.length<16;){t.add(e);let o=e;n.push(o),e=o.cause}return n}function i(e,...n){return u(e).some(t=>typeof t.code=="number"&&n.includes(t.code))}function f(e){return u(e).some(n=>typeof n.message=="string"&&/insufficient funds for gas \* price \+ value/i.test(n.message))}function l(e){let n=u(e),t=n.find(s=>s instanceof a);if(t)return c(t.message)||t.message.length>1024?r(t.message):t.message;if(n.some(s=>s.name==="TimeoutError"))return"The request timed out. Please try again.";if(n.some(s=>s.name==="AbortError"))return"The request was cancelled.";if(i(e,4001))return"The request was declined.";if(i(e,-32601,-32004))return"This endpoint does not support the requested operation.";let o=n.map(s=>typeof s.message=="string"?s.message:"").join(" ");return n.some(s=>s.status===429||s.code===429)||/too many requests|rate limit/i.test(o)?"The RPC endpoint is busy; retry in 1 seconds.":f(e)?"Insufficient funds for the simulation gas budget. Check wallet ETH and the endpoint or fork block gas limit; no transaction was sent.":/revert/i.test(o)||i(e,3)?"The contract call reverted.":/fetch failed|ECONNREFUSED|ENOTFOUND|network/i.test(o)?"The service could not be reached. Please try again.":"The request failed. Please try again."}export{a,i as b,f as c,l as d};
@@ -0,0 +1 @@
1
+ import{a as l}from"./6IM6A5VA.js";import{a as F}from"./UWOFA6GV.js";import{g as D}from"./73N3TOJL.js";import{a as U}from"./RETS2ZEK.js";import{a as c}from"./XPFVT2EA.js";import{a as w}from"./5YS5V2LK.js";import{encodeFunctionData as A,getAddress as S,parseAbi as _}from"viem";var N={address:S("0xCA9c78Dd337A67F6e0077F65F5E9218719d30eDf"),symbol:"NET",decimals:9,chainId:c},r={address:S("0xb773ec2C326B7f98a5a83fc098825492F020a4c7"),symbol:"sNET",decimals:9,chainId:c},u={address:S("0x63C12667638f2Ae6fC6ae09B43D98Ec84a8586eA"),symbol:"wsNET",decimals:18,chainId:c},i=S("0xB078cc304A0B264C5F3680DC0488954ACcd02E87"),E=S("0xA1ee052EC32532304a7522bd9A4b594eC28fF1b1"),tt=[i,u.address,E],p=_(["function net() view returns (address)","function sNet() view returns (address)","function warmupEpochs() view returns (uint256)","function epoch() view returns (uint64 length,uint64 number,uint64 end,uint256 distribute)","function warmup(address) view returns (uint256 gons,uint64 releaseEpoch)","function totalStaked() view returns (uint256)","function enabled() view returns (bool)","function claim(address to) returns (uint256)","function rebase()","function stake(address to, uint256 amount) returns (uint256)","function unstake(address to, uint256 amount) returns (uint256)"]),k=_(["function sNet() view returns (address)","function wrap(uint256 sNetAmount) returns (uint256)","function unwrap(uint256 wsAmount) returns (uint256)","function sNetToWs(uint256 sNetAmount) view returns (uint256)","function wsToSNet(uint256 wsAmount) view returns (uint256)"]),C=_(["function net() view returns (address)","function sNet() view returns (address)","function staking() view returns (address)","function wsNet() view returns (address)","function zap(uint256 netAmount) returns (uint256)"]),W=_(["function balanceOf(address owner) view returns (uint256)","function balanceForGons(uint256) view returns (uint256)"]),z="The expected output is a chain-read estimate; these calls encode no minimum output. No transaction was sent.",O=o=>({anyOf:[F(`Positive ${o.symbol} amount in integer base units (${o.decimals} decimals).`),{const:"max",description:`The fresh full ${o.symbol} wallet balance.`}]}),et=o=>{async function v(e){try{return await e()}catch(t){throw new w(o.plainError(t))}}function y(e,t){if(Object.keys(e).some(n=>!t.includes(n)))throw new w("Unsupported NetNet staking argument. Use the fields in the tool schema.")}async function f(e=!1){let t=o.clientFor(c);if(await t.getChainId()!==c)throw new w("NetNet staking requires chain 4663.");let n=[t.readContract({address:i,abi:p,functionName:"net"}),t.readContract({address:i,abi:p,functionName:"sNet"}),t.readContract({address:u.address,abi:k,functionName:"sNet"}),...e?[t.readContract({address:E,abi:C,functionName:"net"}),t.readContract({address:E,abi:C,functionName:"sNet"}),t.readContract({address:E,abi:C,functionName:"staking"}),t.readContract({address:E,abi:C,functionName:"wsNet"})]:[]],[s,a,d,...m]=await Promise.all(n),b=[N.address,r.address,r.address,...e?[N.address,r.address,i,u.address]:[]];if(![s,a,d,...m].every((T,q)=>typeof T=="string"&&D(T,b[q])))throw new w("NetNet staking contracts do not report the pinned NET, sNET and wsNET links.");return t}async function x(e,t){return o.clientFor(c).readContract({address:e.address,abi:W,functionName:"balanceOf",args:[t]})}async function $(e,t,n){let s=await x(t,n),a;if(e==="max")a=s;else{if(typeof e!="string")throw new w(`Provide an integer ${t.symbol} amount in base units, or "max".`);a=U(e)}if(a<=0n||a>=1n<<256n)throw new w(`This wallet has no ${t.symbol} to use; the amount must be positive.`);if(a>s)throw new w(`Insufficient ${t.symbol}: wallet holds ${s.toString()} base units, requested ${a.toString()}.`);return a}async function g(e,t,n,s){let a=await o.preview(e,t),d=a.changes.map(({token:m,amount:b})=>{let T=b.startsWith("-");return`${T?"-":"+"}${o.formatAmount(T?b.slice(1):b,m.decimals)} ${m.symbol}`}).join(", ");return{txs:e,preview:a,expectedOutput:n,summary:`${s} ${a.summary} ${d?`Estimated changes: ${d}. `:""}${z}`}}let h=(e,t,n)=>o.unsignedTx({to:e,data:t,value:"0",chainId:c,description:n});async function j(e,t){if(y(e,["amount","wrap"]),l(t),e.wrap!==void 0&&typeof e.wrap!="boolean")throw new w("wrap must be a boolean.");let n=await f(e.wrap===!0);if(e.amount==="max")throw new w("Provide an exact NET amount in base units to stake.");let s=await n.readContract({address:i,abi:p,functionName:"warmupEpochs"});if(s!==0n&&e.wrap===!0)throw new w("NetNet warmup prevents immediate Zap wrapping; stake directly, then claim matured sNET before wrapping.");let a=await $(e.amount,N,t),d=o.formatAmount(a.toString(),N.decimals);if(e.wrap===!0){let m=await n.readContract({address:u.address,abi:k,functionName:"sNetToWs",args:[a]});return g([o.approval(N.address,E,a.toString(),c),h(E,A({abi:C,functionName:"zap",args:[a]}),`Stake ${d} NET and wrap it into wsNET with NetNet's Zap.`)],t,{token:u,amount:m.toString()},`Approve exactly ${d} NET, then stake and wrap it into wsNET in one call.`)}return g([o.approval(N.address,i,a.toString(),c),h(i,A({abi:p,functionName:"stake",args:[S(t),a]}),`Stake ${d} NET into sNET.`)],t,{token:r,amount:s===0n?a.toString():"0"},s===0n?`Approve exactly ${d} NET, then stake it 1:1 into rebasing sNET.`:`Approve exactly ${d} NET and stake it into a ${s}-epoch warmup. No immediate sNET receipt; netnet_claim_stake releases matured sNET. Another stake resets your release epoch.`)}async function B(e,t){y(e,["amount"]),l(t),await f();let n=await $(e.amount,r,t),s=o.formatAmount(n.toString(),r.decimals);return g([o.approval(r.address,i,n.toString(),c),h(i,A({abi:p,functionName:"unstake",args:[S(t),n]}),`Unstake ${s} sNET into NET.`)],t,{token:N,amount:n.toString()},`Approve exactly ${s} sNET, then unstake it 1:1 into NET.`)}async function L(e,t){y(e,["amount"]),l(t);let n=await f(),s=await $(e.amount,r,t),a=o.formatAmount(s.toString(),r.decimals),d=await n.readContract({address:u.address,abi:k,functionName:"sNetToWs",args:[s]});return g([o.approval(r.address,u.address,s.toString(),c),h(u.address,A({abi:k,functionName:"wrap",args:[s]}),`Wrap ${a} sNET into wsNET.`)],t,{token:u,amount:d.toString()},`Approve exactly ${a} sNET, then wrap it into non-rebasing wsNET, the Loopback collateral.`)}async function G(e,t){y(e,["amount"]),l(t);let n=await f(),s=await $(e.amount,u,t),a=o.formatAmount(s.toString(),u.decimals),d=await n.readContract({address:u.address,abi:k,functionName:"wsToSNet",args:[s]});return g([h(u.address,A({abi:k,functionName:"unwrap",args:[s]}),`Unwrap ${a} wsNET into sNET.`)],t,{token:r,amount:d.toString()},`Unwrap ${a} wsNET into sNET; no approval is needed.`)}async function M(e){return v(async()=>{l(e);let t=await f(),[n,s]=await Promise.all([x(r,e),x(u,e)]),a=[];if(n>0n&&a.push({module:"netnet",id:`${c}:${r.address.toLowerCase()}`,chainId:c,assets:[{token:{...N},amount:n.toString()}],description:`${o.formatAmount(n.toString(),r.decimals)} sNET staked NET (rebasing; unstakes 1:1 into NET with netnet_unstake).`}),s>0n){let m=await t.readContract({address:u.address,abi:k,functionName:"wsToSNet",args:[s]});a.push({module:"netnet",id:`${c}:${u.address.toLowerCase()}`,chainId:c,assets:[{token:{...N},amount:m.toString()}],description:`${o.formatAmount(s.toString(),u.decimals)} wsNET in the wallet, worth ${o.formatAmount(m.toString(),r.decimals)} sNET (NET 1:1) at the current index. wsNET posted as Morpho collateral appears under Morpho instead.`})}if(await t.readContract({address:i,abi:p,functionName:"warmupEpochs"})>0n){let m=await I({},e);BigInt(m.warmup.pendingSNet)>0n&&a.push({module:"netnet",id:`${c}:${i.toLowerCase()}:warmup`,chainId:c,assets:[{token:N,amount:m.warmup.pendingSNet}],description:`Pending NetNet warmup stake; releases sNET at epoch ${m.warmup.releaseEpoch}. Claim with netnet_claim_stake, then wrap or unstake.`})}return a})}async function I(e,t){y(e,[]),l(t);let n=await f(),[s,a,d,m,b]=await Promise.all([n.readContract({address:i,abi:p,functionName:"epoch"}),n.readContract({address:i,abi:p,functionName:"warmup",args:[t]}),n.readContract({address:i,abi:p,functionName:"warmupEpochs"}),n.readContract({address:i,abi:p,functionName:"totalStaked"}),n.readContract({address:i,abi:p,functionName:"enabled"})]),T=await n.readContract({address:r.address,abi:W,functionName:"balanceForGons",args:[a[0]]});return{chainId:c,staking:i,tokens:{net:N,sNet:r,wsNet:u},enabled:b,epoch:{length:s[0].toString(),number:s[1].toString(),end:s[2].toString(),distribute:s[3].toString()},warmupEpochs:d.toString(),totalStaked:m.toString(),warmup:{gons:a[0].toString(),releaseEpoch:a[1].toString(),pendingSNet:T.toString(),matured:a[0]>0n&&s[1]>=a[1]},caveat:"Warmup uses epoch numbers, not wall-clock time. Each rebase advances at most one due epoch; a claim also rebases once if due. A new stake resets the warmup release epoch."}}async function R(e,t){let n=await I(e,t);if(!n.enabled||!n.warmup.matured)throw new w("No matured NetNet warmup stake. Read netnet_staking_status and advance a due epoch before claiming.");return g([h(i,A({abi:p,functionName:"claim",args:[t]}),`Claim matured sNET to this wallet ${t}.`)],t,{token:r,amount:n.warmup.pendingSNet},"Claim matured NetNet staking warmup; rebase may change the sNET receipt.")}async function Z(e,t){y(e,[]),l(t);let n=await f(),[s,a,d]=await Promise.all([n.readContract({address:i,abi:p,functionName:"epoch"}),n.getBlock(),n.readContract({address:i,abi:p,functionName:"enabled"})]);if(!d||a.timestamp<s[2])throw new w("No enabled NetNet epoch is due to rebase.");return g([h(i,A({abi:p,functionName:"rebase"}),"Advance one due NetNet staking epoch and checkpoint its oracle.")],t,{token:r,amount:"0"},"Advance one due epoch. Distribution depends on live protocol state; this does not guarantee a reward.")}let P=(e,t,n)=>({name:e,inputSchema:{type:"object",properties:t,required:["amount"],additionalProperties:!1},execute:(s,a)=>v(()=>n(s,a))});return{positions:M,tools:[{name:"netnet_staking_status",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>I(e,t))},{name:"netnet_claim_stake",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>R(e,t))},{name:"netnet_rebase",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>Z(e,t))},P("netnet_stake",{amount:F("Positive NET amount in integer base units (9 decimals)."),wrap:{type:"boolean",default:!1,description:"Stake and wrap into wsNET in one call through NetNet's Zap."}},j),P("netnet_wrap",{amount:O(r)},L),P("netnet_unwrap",{amount:O(u)},G),P("netnet_unstake",{amount:O(r)},B)]}};export{N as a,r as b,u as c,i as d,E as e,tt as f,et as g};
@@ -0,0 +1 @@
1
+ import{i as R,s as g}from"./XPFVT2EA.js";import{a as w}from"./5YS5V2LK.js";import{isDeepStrictEqual as b}from"node:util";import{isAddress as x}from"viem";var O=2592e3,v=1n<<128n,m=new Set(["order","offer","link","consent"]),y=new Set(["order","offer","consent"]),E=new Set(["order","offer","link"]),I=3600,S=1e11;function l(e){return new w(`Local signing guard: ${e}; nothing was signed.`)}var V=e=>m.has(e.class);function T(e,r){let t=new Map,n=(s,a,o)=>{let u=e[s];if(!u||o>8)throw l("typed-data types changed");for(let c of u){let f=c.type.replace(/(\[[0-9]*\])+$/,""),i=`${a}${c.name}${c.type===f?"":"[]"}`;e[f]?n(f,`${i}.`,o+1):t.set(i,c.type)}};return n(r,"",0),t}function N(e,r){let t=new Set,n=s=>{if(!(t.has(s)||!e[s])){t.add(s);for(let a of e[s])n(a.type.replace(/(\[[0-9]*\])+$/,""))}};return n(r),t}function A(e=[]){let r=new Set(e.map(n=>n.toLowerCase())),t=(n,s)=>{if(!(s>12)){if(typeof n=="string"){x(n,{strict:!1})&&r.add(n.toLowerCase());return}if(n&&typeof n=="object")for(let a of Object.values(n))t(a,s+1)}};return t(R,0),t(g,0),r}function j(e,r=A()){let t=[],n=(i,d)=>t.push(`${i} ${e.id}: ${d}`),s=Object.entries(e.fields),a=i=>s.filter(([,d])=>d.role===i),o=i=>s.filter(([,d])=>d.role==="derived"&&d.yields?.includes(i)).length;["order","cancel","link","offer","consent","auth","relayed"].includes(e.class)||n("R5","unknown signature class; link-accept is a display role only"),e.expiryBinding&&!["signed","program-link","auth-window","cancel-only"].includes(e.expiryBinding)&&n("R5","unknown expiry binding"),(!e.id||!/^[a-z0-9]+(?:[.-][a-z0-9]+)+$/.test(e.id))&&n("ID","id must be dotted lower-case"),(!e.tools.length||new Set(e.tools).size!==e.tools.length)&&n("ID","tools must be a non-empty unique list");let u=e.network==="testnet"?g.testnet.chainId:g.mainnet.chainId;if(e.encoding==="eip712"){let i=e.domain;i?(Object.hasOwn(i,"salt")&&n("R1","domain must not carry a salt"),i.name||n("R1","domain name is missing"),!i.version&&e.class!=="relayed"&&n("R1","domain version is missing"),i.chainId!==u&&n("R1",`domain chain must be ${u}`),i.verifyingContract?r.has(i.verifyingContract.toLowerCase())||n("R1","verifying contract is not a pinned address"):e.class!=="cancel"&&e.class!=="auth"&&n("R1","verifying contract is missing")):n("R1","EIP-712 spec has no domain")}else e.domain&&n("R1","only EIP-712 specs carry a domain");if(e.encoding==="eip191-packed-hash"){let i=a("pinned").map(([,d])=>d.value);i.some(d=>d===u||d===String(u))||n("R1","packed layout must pin the chain id"),i.some(d=>typeof d=="string"&&r.has(d.toLowerCase()))||n("R1","packed layout must pin the verifying contract")}let c=new Map,f=e.class==="relayed"&&!Object.keys(e.types).length;if(e.encoding==="eip712"&&!f){Object.hasOwn(e.types,"EIP712Domain")&&n("R2","types must never carry EIP712Domain");try{c=T(e.types,e.primaryType);let i=N(e.types,e.primaryType);for(let d of Object.keys(e.types))i.has(d)||n("R2",`type ${d} is not reachable from ${e.primaryType}`)}catch{n("R2",`types do not resolve from ${e.primaryType}`)}for(let i of c.keys())Object.hasOwn(e.fields,i)||n("R3",`message path ${i} has no role`);for(let[i]of s)c.has(i)||n("R3",`declared field ${i} is not in the typed struct`)}else e.encoding!=="eip712"&&Object.keys(e.types).length&&n("R2","only EIP-712 specs carry types");for(let[i,d]of s)(!d.meaning||d.meaning.length>160)&&n("R3",`field ${i} needs a plain-English meaning`);(e.class==="order"||e.class==="offer")&&!s.some(([,i])=>i.role==="amount"&&i.side==="out")&&!o("amount-out")&&n("R4",`${e.class} must show the most that can leave`);for(let[i,d]of s){if(d.role==="amount"||d.role==="fee"){let h=d.token;(x(h,{strict:!1})?r.has(h.toLowerCase()):e.fields[h]?.role==="token")||n("R4",`amount ${i} does not name a token field or a pinned token`)}c.get(i)==="bytes"&&d.role!=="pinned"&&d.role!=="derived"&&n("R4",`bytes field ${i} must be pinned or derived`)}if(e.maxLifetimeSeconds>0&&e.maxLifetimeSeconds<=O||n("R5","maxLifetimeSeconds must be within 30 days"),y.has(e.class)){let i=a("expiry").length+o("expiry");i!==1&&n("R5",`${e.class} needs exactly one expiry (found ${i})`),e.expiry&&n("R5","API-only expiry is not a signed expiry"),e.expiryBinding&&e.expiryBinding!=="signed"&&n("R5",`${e.class} requires signed expiry`)}if(e.expiryBinding==="program-link"&&e.class!=="link"&&n("R5","only link can use program-link"),e.class==="link"&&e.expiryBinding!=="program-link"&&a("expiry").length+o("expiry")!==1&&n("R5","link needs signed expiry or program-link binding"),e.expiryBinding==="auth-window"){let i=e.authWindow;(e.class!=="auth"||!i||!c.has(i.field)||!Number.isSafeInteger(i.maxAgeSeconds)||i.maxAgeSeconds<=0||i.maxAgeSeconds>e.maxLifetimeSeconds||!Number.isSafeInteger(i.maxFutureSeconds)||i.maxFutureSeconds<0||i.maxFutureSeconds>e.maxLifetimeSeconds)&&n("R5","auth-window needs a signed timestamp and pinned acceptance window")}else e.authWindow&&n("R5","authWindow requires auth-window binding");return e.expiryBinding==="cancel-only"&&(e.class!=="cancel"||!a("nonce").length&&!o("nonce")&&!e.revoke?.staysExecutableUntilExpiry)&&n("R5","cancel-only needs a single-use nonce or targeted non-revoking hide"),(e.class==="auth"||e.class==="cancel")&&(s.some(([,i])=>i.role==="amount"&&i.side==="out")||o("amount-out"))&&n("R4","auth and cancel cannot grant spending authority"),E.has(e.class)&&!(e.revoke?.onchainTool||e.revoke?.offchainSpec)&&!(e.revoke?.none&&e.maxLifetimeSeconds<=I)&&n("R6",`${e.class} needs a revocation path (only a one-shot approval of at most one hour may declare none)`),e.submit.by==="addon"&&(!/^[a-z0-9-]+(\.[a-z0-9-]+)+$/.test(e.submit.host)||!/^\/[A-Za-z0-9/_.-]*$/.test(e.submit.path))&&n("R9","add-on submission needs a bare HTTPS host and a fixed path"),e.submit.by==="server-continuation"&&!e.submit.reason&&n("R9","server-continuation needs its recorded reason"),e.submit.by==="transaction"&&e.class!=="relayed"&&e.class!=="consent"&&n("R9","only relayed and consent signatures are consumed by a transaction"),(!/^[A-Za-z0-9 .'-]{1,40}$/.test(e.program)||!/^[A-Za-z0-9 .'-]{1,60}$/.test(e.purpose))&&n("R10","program and purpose must be short constant text"),m.has(e.class)&&!e.requireHuman&&!e.humanException&&n("C13",`${e.class} must require a human`),!m.has(e.class)&&e.humanException&&n("C13","only a value class can name a human exception"),e.relayedPaths&&e.class!=="relayed"&&n("ID","only relayed specs accept caller signatures"),e.enabled===!1&&!e.disabledReason&&n("ID","a disabled spec states why"),t}function z(e,r=A()){let t=e.filter(a=>a.enabled!==!1).flatMap(a=>j(a,r)),n=new Set,s=new Set;for(let a of e){n.has(a.id)&&t.push(`ID ${a.id}: duplicate spec id`),n.add(a.id);let o=C(a);s.has(o)&&t.push(`ID ${a.id}: another spec already covers ${o}`),s.add(o)}return t}function C(e){return`${e.network??"mainnet"}:${e.encoding}:${(e.domain?.verifyingContract??"-").toLowerCase()}:${e.primaryType}`}function k(e,r,t,n,s){let a=r.replace(/(\[[0-9]*\])+$/,"");if(a!==r){if(!Array.isArray(t))throw l(`message field ${n||r} is not declared`);for(let i of t)k(e,r.replace(/\[[0-9]*\]$/,""),i,`${n}[]`,s+1);return}let o=e[a];if(!o)return;if(s>8||!t||typeof t!="object"||Array.isArray(t))throw l(`message field ${n||r} is not declared`);let u=Object.keys(t),c=o.map(i=>i.name);if(u.find(i=>!c.includes(i))!==void 0)throw l(`an undeclared message field${n?` under ${n}`:""} is present`);for(let i of o){if(!Object.hasOwn(t,i.name))throw l(`message field ${n?`${n}.`:""}${i.name} is missing`);k(e,i.type,t[i.name],`${n?`${n}.`:""}${i.name}`,s+1)}}function W(e,r){if(e.encoding!=="eip712"||!e.domain)throw l("Oak has no signing contract for this request");if(!r||typeof r!="object"||!r.domain||typeof r.domain!="object")throw l("domain, chain or verifying contract is not the pinned one");let t=Object.fromEntries(Object.entries(e.domain).filter(([,n])=>n!==void 0));if(!b(Object.keys(r.domain).sort(),Object.keys(t).sort())||!b({...r.domain},t))throw l("domain, chain or verifying contract is not the pinned one");if(!r.types||typeof r.types!="object"||Object.hasOwn(r.types,"EIP712Domain")||!b(r.types,e.types)||r.primaryType!==e.primaryType)throw l("typed-data types changed");k(e.types,e.primaryType,r.message,"",0)}function p(e,r){let t=e;for(let n of r.split(".")){if(n.endsWith("[]")||!t||typeof t!="object"||Array.isArray(t))return;t=t[n]}return t}var $=e=>typeof e=="string"?e:typeof e=="number"||typeof e=="bigint"?String(e):void 0;function D(e,r){let t={},n=s=>x(s,{strict:!1})?s:$(p(r,s));for(let[s,a]of Object.entries(e.fields)){let o=$(p(r,s));if(o!==void 0)switch(a.role){case"signer":t.signer=o;break;case"account":t.account=o;break;case"recipient":t.recipient=o;break;case"delegate":t.delegate=o;break;case"counterparty":t.counterparty=o;break;case"token":a.side==="out"?t.tokenOut=o:t.tokenIn=o;break;case"amount":a.side==="out"?(t.amountOut=o,t.tokenOut??=n(a.token)):(t.minAmountIn=o,t.tokenIn??=n(a.token));break;case"fee":(t.fees??=[]).push({token:n(a.token)??a.token,value:o});break;case"expiry":t.expiry=/^[0-9]+$/.test(o)?Number(o):Number.NaN;break;case"nonce":t.nonce=o;break;default:break}}return t}function L(e,r,t){let n=Math.min(e.maxLifetimeSeconds,O),s=y.has(e.class)||e.humanException?60:1;if(!Number.isSafeInteger(t)||t<0||!Number.isFinite(n)||n<=0||r===void 0||!Number.isSafeInteger(r)||r<=0||r>=S||r<t+s||r>t+n)throw l(`expiry is missing, past or beyond ${n>=86400?`${Math.floor(n/86400)} days`:`${Math.ceil(n/60)} minutes`}`)}function U(e,r,t,n){if(e.enabled===!1)throw l("Oak has no signing contract for this request");if(!Number.isSafeInteger(t)||t<0||t>=S)throw l("signing time is unavailable");if(e.expiryBinding==="auth-window"){let o=e.authWindow,u=o&&p(r,o.field),c=typeof u=="number"?u:typeof u=="string"&&/^[0-9]+$/.test(u)?Number(u):NaN;if(e.class!=="auth"||!o||!Number.isSafeInteger(c)||c<=0||c>=S||c<t-o.maxAgeSeconds||c>t+o.maxFutureSeconds)throw l("authentication time is outside the pinned window");return c+o.maxAgeSeconds}if(e.expiryBinding==="cancel-only"){if(e.class!=="cancel")throw l("Oak has no signing contract for this request");return n}if(e.expiryBinding==="program-link")throw l("program link authority is not configured");if(y.has(e.class)&&(e.expiry||e.expiryBinding&&e.expiryBinding!=="signed"))throw l("order expiry must be signed");let s=D(e,r).expiry??n,a=Object.values(e.fields).some(o=>o.role==="expiry"||o.role==="derived"&&o.yields?.includes("expiry"));if(y.has(e.class)&&!a)throw l("order expiry must be signed");return(a||m.has(e.class))&&L(e,s,t),s}function H(e){if(e===void 0||!/^[0-9]{1,78}$/.test(e))throw l("open-ended or out-of-range amount");let r=BigInt(e);if(r<=0n||r>=v)throw l("open-ended or out-of-range amount");return r}function J(e,r){return Object.entries(e.fields).map(([t,n])=>{let s=t.includes("[]")?"(each item, listed below)":p(r,t),a=typeof s=="object"&&s!==null?JSON.stringify(s):String(s);a.length>200&&(a=`${a.slice(0,200)}\u2026`);let o=JSON.stringify(a).replace(/[\u007f-\u009f\u2028\u2029\u202a-\u202e\u2066-\u2069]/g,u=>`\\u${u.charCodeAt(0).toString(16).padStart(4,"0")}`);return`${t} = ${o} - ${n.meaning}`})}export{O as a,v as b,m as c,l as d,V as e,T as f,A as g,j as h,z as i,C as j,W as k,p as l,D as m,L as n,U as o,H as p,J as q};
@@ -0,0 +1 @@
1
+ import{a as T}from"./6IM6A5VA.js";import{a as C}from"./UWOFA6GV.js";import{g as k,m as I,n as _}from"./73N3TOJL.js";import{a as u,i as G,j as N}from"./XPFVT2EA.js";import{a as n}from"./5YS5V2LK.js";import{encodeFunctionData as w,erc20Abi as R,getAddress as D,parseAbi as z}from"viem";var d=D(G[u].vaults.spark.address),l={address:D(N),symbol:"USDG",decimals:6,chainId:u},E={address:d,symbol:"spUSDG",decimals:6,chainId:u},m=z(["function asset() view returns (address)","function decimals() view returns (uint8)","function maxMint(address) view returns (uint256)","function maxRedeem(address) view returns (uint256)","function maxDeposit(address) view returns (uint256)","function previewMint(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewDeposit(uint256) view returns (uint256)","function mint(uint256 shares,address receiver) returns (uint256)","function mint(uint256 shares,address receiver,uint16 referral) returns (uint256)","function deposit(uint256 assets,address receiver,uint16 referral) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)"]),Q=C("Positive decimal base-unit integer; USDG and spUSDG both have 6 decimals."),J={type:"integer",minimum:0,maximum:65535};function M(s){return _(s,"Amount must be positive and fit uint256.",{notString:"Amount must be a positive base-unit integer string.",positive:!0})}function j(s){return I(s,"Invalid Spark integer read.")}function Z(s){return["mint","redeem","deposit_referral","return_liquidity"].map(r=>{let t=r==="mint",a=r==="redeem",h=r==="deposit_referral",x=t?["shares","maxAssets","referral"]:a?["shares"]:h?["amount","referral"]:["amount"],O=t?["shares","maxAssets"]:a?["shares"]:h?["amount","referral"]:["amount"];return{name:`spark_${r}`,inputSchema:{type:"object",additionalProperties:!1,required:O,properties:Object.fromEntries(x.map(c=>[c,c==="referral"?J:Q]))},execute:async(c,o)=>{try{if(T(o),Object.keys(c).some(p=>!x.includes(p)))throw new n("Unexpected Spark action argument.");let e=M(c[t||a?"shares":"amount"]),P=t?M(c.maxAssets):void 0,i=c.referral;if((h||i!==void 0)&&(typeof i!="number"||!Number.isInteger(i)||i<0||i>65535))throw new n("Referral must be a uint16 integer.");let f=s.clientFor(u);if(await f.getChainId()!==u)throw new n("Spark requires chain 4663.");let[q,B,F]=await Promise.all([f.readContract({address:d,abi:m,functionName:"asset"}),f.readContract({address:d,abi:m,functionName:"decimals"}),f.readContract({address:l.address,abi:R,functionName:"decimals"})]);if(typeof q!="string"||D(q)!==l.address||B!==6||F!==6)throw new n("Spark requires the pinned USDG/share metadata.");let v=r==="return_liquidity"?e:j(await f.readContract({address:d,abi:m,functionName:t?"previewMint":a?"previewRedeem":"previewDeposit",args:[e]}));if(v===0n)throw new n("Spark returned a zero action quote.");if(r!=="return_liquidity"){let p=j(await f.readContract({address:d,abi:m,functionName:t?"maxMint":a?"maxRedeem":"maxDeposit",args:[o]}));if(e>p)throw new n("The amount exceeds Spark\u2019s current action capacity.")}if(t&&v>P)throw new n("The mint quote exceeds maxAssets.");let U=t?v:e,H=t?i===void 0?w({abi:m,functionName:"mint",args:[e,o]}):w({abi:m,functionName:"mint",args:[e,o,i]}):a?w({abi:m,functionName:"redeem",args:[e,o,o]}):h?w({abi:m,functionName:"deposit",args:[e,o,i]}):w({abi:R,functionName:"transfer",args:[d,e]}),A=`${r} ${e} ${t||a?"spUSDG share":"USDG asset"} base units; ${r==="return_liquidity"?`USDG goes to ${d}, with no shares minted`:`beneficiary ${o}`}${i===void 0?"":`; event-only referral ${i}`}.`,$=[...t||h?[s.approval(l.address,d,U.toString(),u)]:[],s.unsignedTx({to:r==="return_liquidity"?l.address:d,data:H,value:"0",chainId:u,description:A})],g=await s.preview($,o),S=p=>g.changes.filter(b=>b.token.chainId===u&&k(b.token.address,p.address)).reduce((b,y)=>{if(y.token.decimals!==p.decimals||!/^-?\d+$/.test(y.amount))throw new n("Invalid Spark preview metadata.");return b+BigInt(y.amount)},0n);if(a?S(E)!==-e||S(l)<=0n:S(l)!==-U||r!=="return_liquidity"&&S(E)<(t?e:1n))throw new n("Spark preview does not match the requested outflow and receipt.");return{txs:$,preview:g,summary:`${A} Quoted ${v} ${a?"USDG asset":t||r==="return_liquidity"?"USDG input":"spUSDG share"} base units. ${g.summary} Standard ERC-4626 encodes no output minimum; the exact mint approval can become insufficient as interest accrues. Re-preview before signing.`}}catch(e){throw new n(s.plainError(e))}}}})}export{Z as a};
@@ -1 +1 @@
1
- import{a as m}from"./I5CQ64EU.js";import{a as i}from"./NGAI6GTU.js";import{encodeFunctionData as d,erc20Abi as f,isAddress as g,parseAbi as h}from"viem";var p=h(["function deposit(uint256 assets,address receiver) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),l=(1n<<256n)-1n;function a(e){if(typeof e!="string"||!g(e,{strict:!1}))throw new i("Provide a valid contract or wallet address.")}function o(e){let t=m(e);if(t>l)throw new i("Amount exceeds the uint256 range.");return t}function u(e){a(e.to);let t=e.chainId??4663;if(!Number.isSafeInteger(t)||t<=0)throw new i("Provide a positive integer chain ID.");if(typeof e.data!="string"||!/^0x([0-9a-fA-F]{2})*$/.test(e.data))throw new i("Transaction data must be hex-encoded bytes.");if(typeof e.description!="string"||!e.description.trim())throw new i("Provide a transaction description.");return{to:e.to,data:e.data,value:o(e.value).toString(),chainId:t,description:e.description}}function A(e,t,s,r=4663){a(t);let n=o(s);return u({to:e,data:d({abi:f,functionName:"approve",args:[t,n]}),value:"0",chainId:r,description:`Approve ${n} token base units for ${t}.`})}function w(e,t,s,r,n=4663){a(r);let c=o(s);return{txs:[A(t,e,s,n),u({to:e,data:d({abi:p,functionName:"deposit",args:[c,r]}),value:"0",chainId:n,description:`Deposit ${c} asset base units into ${e}.`})],summary:"Approve the exact asset amount, then deposit into the vault."}}function y(e,t,s,r=4663){a(s);let n=o(t);return{txs:[u({to:e,data:d({abi:p,functionName:"redeem",args:[n,s,s]}),value:"0",chainId:r,description:`Redeem the full ${n} share base units from ${e}.`})],summary:"Redeem the supplied full share balance to the wallet."}}export{a,u as b,A as c,w as d,y as e};
1
+ import{a as m}from"./RETS2ZEK.js";import{a as i}from"./5YS5V2LK.js";import{encodeFunctionData as d,erc20Abi as f,isAddress as g,parseAbi as h}from"viem";var p=h(["function deposit(uint256 assets,address receiver) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),l=(1n<<256n)-1n;function a(e){if(typeof e!="string"||!g(e,{strict:!1}))throw new i("Provide a valid contract or wallet address.")}function o(e){let t=m(e);if(t>l)throw new i("Amount exceeds the uint256 range.");return t}function u(e){a(e.to);let t=e.chainId??4663;if(!Number.isSafeInteger(t)||t<=0)throw new i("Provide a positive integer chain ID.");if(typeof e.data!="string"||!/^0x([0-9a-fA-F]{2})*$/.test(e.data))throw new i("Transaction data must be hex-encoded bytes.");if(typeof e.description!="string"||!e.description.trim())throw new i("Provide a transaction description.");return{to:e.to,data:e.data,value:o(e.value).toString(),chainId:t,description:e.description}}function A(e,t,s,r=4663){a(t);let n=o(s);return u({to:e,data:d({abi:f,functionName:"approve",args:[t,n]}),value:"0",chainId:r,description:`Approve ${n} token base units for ${t}.`})}function w(e,t,s,r,n=4663){a(r);let c=o(s);return{txs:[A(t,e,s,n),u({to:e,data:d({abi:p,functionName:"deposit",args:[c,r]}),value:"0",chainId:n,description:`Deposit ${c} asset base units into ${e}.`})],summary:"Approve the exact asset amount, then deposit into the vault."}}function y(e,t,s,r=4663){a(s);let n=o(t);return{txs:[u({to:e,data:d({abi:p,functionName:"redeem",args:[n,s,s]}),value:"0",chainId:r,description:`Redeem the full ${n} share base units from ${e}.`})],summary:"Redeem the supplied full share balance to the wallet."}}export{a,u as b,A as c,w as d,y as e};
@@ -0,0 +1 @@
1
+ import{parseAbi as t}from"viem";var i={staking:"0xe0710011278bfb63e57c5f227e5980984b1eddca",orbio:"0xaa07a0e9209e16ac99708c3ec70159c6ef3128a3",agentVault:"0x0e1651aec67b2a049a4fa6aeb6c1c305aabfc35b",payout:"0x4cbbbf652b11ed1294df0ac49d8322394310cfc5"},e=["BudgetSpent","LiquidityExhausted","UnitUnaffordable","WorkLimit"],u=t(["function getQuote(uint256 usdgIn, uint256 maxFills) view returns (uint256 creditOut, uint256 usdgSpent, uint256 feeAtoms, uint256 fills, uint256 reason)","function getActivationQuote(uint256 usdgIn, uint256 maxFills) view returns (uint256 creditOut, uint256 usdgSpent, uint256 feeAtoms, uint256 fills, uint256 reason, uint256 creditedAtoms, uint256 activationFeeAtoms)","function buy(uint256 usdgIn, uint256 minCreditOut, address recipient, uint256 maxFills) returns (uint256 creditOut, uint256 usdgSpent)","function buyAndActivate(uint256 usdgIn, uint256 minCreditOut, bytes32 beneficiary, uint256 maxFills) returns (uint256 creditOut, uint256 usdgSpent, uint256 activationId)"]),s=t(["function activate(uint256 amount) returns (uint256 activationId)","function activate(uint256 amount, bytes32 beneficiary) returns (uint256 activationId)","function previewActivation(uint256 amount) view returns (uint256 credited, uint256 feeAtoms)","function activationFeeBps() view returns (uint16)","function transfer(address to, uint256 amount) returns (bool)"]),a=t(["event Activated(uint256 indexed activationId, address indexed from, bytes32 indexed beneficiary, uint256 amount)","event ActivationFeeCharged(uint256 indexed activationId, uint256 feeAtoms)"]),r=t(["function stake(uint256 orbioWei)","function unstake(uint256 orbioWei) returns (uint256 positionWei)","function claim() returns (uint256 creditMinted)","function positionOf(address account) view returns (uint256 orbioWei)","function settledOf(address account) view returns (uint256 creditAtoms)","function MIN_POSITION() view returns (uint256)"]),o=t(["struct Socials { string twitter; string telegram; string discord; string website; string farcaster; }","struct TokenParams { string name; string symbol; string logo; string description; Socials socials; address creatorFeeRecipient; uint16 creatorTaxBps; bool buybackEnabled; bytes32 expectedEconomics; bytes32 salt; }","function launch(TokenParams params, address agentWallet) payable returns (uint256 agentId, address token)","function claimCredit(uint256 agentId, bool activate) returns (uint256 creditAtoms)","function harvest(uint256[] agentIds) returns (uint256 stakedWei)","function withdrawPrincipal(uint256 agentId, uint256 orbioWei)","function setAgentWallet(uint256 agentId, address wallet)","function stakeOf(uint256 agentId) view returns (uint256 orbioWei)","function unlocksAt(uint256 agentId) view returns (uint64)","function nextAgentId() view returns (uint256)","event AgentLaunched(uint256 indexed agentId, address indexed token, address indexed owner, address receiver, address agentWallet, bytes32 beneficiary, uint16 feeBps, uint64 launchedAt)"]);export{i as a,e as b,u as c,s as d,a as e,r as f,o as g};
@@ -0,0 +1 @@
1
+ import{d as b,h as v,l as I,n as k,r as S}from"./2EDXKJ3B.js";import{a as T}from"./X5V2Z2NM.js";import{e as c,g as y}from"./73N3TOJL.js";import{a as i}from"./5YS5V2LK.js";import{a as l}from"./JXOEJPJ4.js";import{lookup as C}from"node:dns/promises";import{isIP as p}from"node:net";var N="/.well-known/agent-registration.json",P=262144;function R(n){let r=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i.exec(n);if(r)return R(r[1]);if(p(n)===4){let[e,t]=n.split(".").map(Number);return!(e===0||e===10||e===127||e>=224||e===100&&t>=64&&t<=127||e===169&&t===254||e===172&&t>=16&&t<=31||e===192&&t===168||e===192&&t===0||e===198&&(t===18||t===19))}if(p(n)===6){let e=n.toLowerCase();return!(e==="::"||e==="::1"||/^f[cd]/.test(e)||/^fe[89ab]/.test(e)||e.startsWith("ff")||e.startsWith("2001:db8")||e.startsWith("64:ff9b"))}return!1}async function E(n){let r;try{r=new URL(n)}catch{throw new i("Not a valid URL.")}if(r.protocol!=="https:"||r.username||r.password||r.port||p(r.hostname.replace(/^\[|\]$/g,""))!==0||!r.hostname.includes(".")||/\.(?:local|internal|localhost|lan)$/i.test(r.hostname))throw new i("Only public HTTPS hostnames on the default port are checked.");let e=await C(r.hostname,{all:!0});if(!e.length||!e.every(t=>R(t.address)))throw new i("That hostname does not resolve to a public address.");return r.hostname}async function L(n,r){let e=await n.http(r,{method:"GET",headers:{accept:"application/json"},redirect:"error",signal:AbortSignal.timeout(8e3)});if(!e.ok)throw new i(`The server answered HTTP ${e.status}.`);if(Number(e.headers.get("content-length")??0)>P)throw new i("The file is larger than 256 KiB.");let a=await e.text();if(a.length>P)throw new i("The file is larger than 256 KiB.");try{return JSON.parse(a)}catch{throw new i("The file is not JSON.")}}function O(n,r,e){return Array.isArray(n)&&n.some(t=>c(t)&&typeof t.agentRegistry=="string"&&y(t.agentRegistry,r)&&(typeof t.agentId=="number"||typeof t.agentId=="string")&&String(t.agentId)===e.toString())}var J=n=>({tools:[{name:"erc8004_verify_domain",inputSchema:{type:"object",additionalProperties:!1,required:["agentId"],description:"Read-only, optional ERC-8004 endpoint-domain verification: for each HTTPS service endpoint in the agent's on-chain profile, fetch https://{domain}/.well-known/agent-registration.json and check it lists this registry and agent ID. Only public HTTPS names are fetched; the profile itself is read only from a data: URI.",properties:{agentId:b,endpoint:{type:"string",description:"Check only this HTTPS endpoint (must be one of the profile's services)."}}},async execute(e){try{k(n,e.chainId);let t=I(e.agentId),{chainId:a,registry:H,registryId:u}=v(n),h=await n.clientFor(a).readContract({address:H,abi:T,functionName:"tokenURI",args:[t]});if(typeof h!="string")throw new i("The registry returned an invalid URI.");let f=S(h);if(!f)return{agentId:t.toString(),verified:null,reason:"The agent profile is not a base64 data: URI, so Oak will not fetch it from an agent-controlled location. Pass the endpoint host check yourself, or update the profile to a data: URI.",uri:l(h)};let g=(Array.isArray(f.services)?f.services.filter(c):[]).map(o=>String(o.endpoint??"")).filter(o=>/^https:\/\//i.test(o)),m=e.endpoint===void 0?g:g.filter(o=>o===e.endpoint);if(e.endpoint!==void 0&&!m.length)throw new i("That endpoint is not an HTTPS service in the agent's profile.");let U=[...new Set(m.map(o=>{try{return new URL(o).hostname}catch{return""}}).filter(Boolean))].slice(0,10),s=[];for(let o of U)try{await E(`https://${o}/`);let d=await L(n,`https://${o}${N}`),A=c(d)?d.registrations:void 0,w=O(A,u,t);s.push({domain:l(o),verified:w,reason:w?"The well-known file lists this registry and agent ID.":"The well-known file does not list this registry and agent ID."})}catch(d){s.push({domain:l(o),verified:!1,reason:n.plainError(d)})}return{agentId:t.toString(),registry:u,domains:s,checked:s.length,note:s.length?"Verified means that domain publishes a file naming this agent; it proves domain control by the agent, not that the endpoint is safe.":"The profile lists no HTTPS service endpoints to verify."}}catch(t){throw new i(n.plainError(t))}}}]});export{R as a,J as b};
@@ -0,0 +1 @@
1
+ import{b as J,e as Y}from"./HF2AGJZC.js";import{d as U,e as D,v as _}from"./FL3EF72E.js";import{a as R,b as Q,c as H,d as L,e as $,f as G,g as W}from"./ITIIHCZK.js";import{a as S}from"./UWOFA6GV.js";import{c as l,g as B}from"./73N3TOJL.js";import{a as g,i as N}from"./XPFVT2EA.js";import{a as E}from"./EG6M6SSO.js";import{a as o}from"./5YS5V2LK.js";import{encodeAbiParameters as x,encodeFunctionData as Z,encodePacked as pe,getAddress as ie,parseAbi as V,parseAbiParameters as A,zeroAddress as w}from"viem";var ee=ie("0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7"),te=ie(N[4663].ponsTrade.quoter.address),de=V(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),me=V(["function approve(address token,address spender,uint160 amount,uint48 expiration)"]),ne=V(["function factory() view returns (address)","function quoteExactInput(bytes path,uint256 amountIn) returns (uint256,uint160[],uint32[],uint256)","function quoteExactOutput(bytes path,uint256 amountOut) returns (uint256,uint160[],uint32[],uint256)"]),M="(address intermediateCurrency,uint24 fee,int24 tickSpacing,address hooks,bytes hookData)",z="(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)",oe=V([`function quoteExactInput((address exactCurrency,${M}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactOutput((address exactCurrency,${M}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactInputSingle((${z} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`,`function quoteExactOutputSingle((${z} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`]),fe=A(`(address exactCurrency,${M}[] path,uint256[] minHopPriceX36,uint128 amount,uint128 limit)`);function ye(u,t,i,d){let a=[],e=d?i:t,r=new Set([e]);for(let n of d?[...u].reverse():u){let s=n.currency0===e?n.currency1:n.currency1===e?n.currency0:void 0;if(!s||r.has(s))throw new o("V4 poolKeys must form a continuous route without repeated currencies.");a.push({intermediateCurrency:s,fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks,hookData:"0x"}),e=s,r.add(e)}if(e!==(d?t:i))throw new o("V4 route does not end at the requested currency.");return a}var le=A(`(${z} poolKey,bool zeroForOne,uint128 amount,uint128 limit,uint256 minHopPriceX36,bytes hookData)`),he=A("address recipient,uint256 amount,uint256 limit,bytes path,bool payerIsUser,uint256[] minHopPriceX36"),xe=A("address recipient,uint256 amount,uint256 limit,address[] path,bool payerIsUser,uint256[] minHopPriceX36"),re=A("address,uint256"),be=A("bytes,bytes[]");function we(u,t,i){let d=i?[...u].reverse():u,a=i?[...t].reverse():t,e=d[0];return a.forEach((r,n)=>{e=`${e}${pe(["uint24","address"],[r,d[n+1]]).slice(2)}`}),e}var ue={version:{type:"string",enum:["v2","v3","v4"]},tokenIn:l,tokenOut:l,path:{type:"array",minItems:2,maxItems:6,items:l},fees:{type:"array",items:{type:"integer",minimum:0,maximum:1e6}},poolKeys:{type:"array",minItems:1,maxItems:5,items:{type:"object",required:["currency0","currency1","fee","tickSpacing","hooks"],properties:{currency0:l,currency1:l,fee:{type:"integer"},tickSpacing:{type:"integer"},hooks:l},additionalProperties:!1}},poolKey:{type:"object",properties:{currency0:l,currency1:l,fee:{type:"integer"},tickSpacing:{type:"integer"},hooks:l},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},amountIn:S(),amountOut:S(),minAmountOut:S(),maxAmountIn:S(),slippageBps:{type:"integer",minimum:0,maximum:9999}};async function Ae(u,t,i,d=!1){W(t,Object.keys(ue));let a=t.version;if(!["v2","v3","v4"].includes(String(a)))throw new o("Provide version v2, v3 or v4.");let e=t.amountOut!==void 0;if(t.amountIn!==void 0===e)throw new o("Provide exactly one of amountIn or amountOut.");if(e&&t.minAmountOut!==void 0||!e&&t.maxAmountIn!==void 0)throw new o("Use maxAmountIn for exact output, minAmountOut for exact input.");let r=R(e?t.amountOut:t.amountIn,e?"amountOut":"amountIn",a==="v4"?128:160),n=H(t.tokenIn),s=H(t.tokenOut);if(n===s)throw new o("Swap requires different input and output currencies.");let v=u.clientFor(g),y=await v.getBlock(),F=L(t.slippageBps),I,m,q,k,h,c,C;if(a==="v4"){if(t.path!==void 0||t.fees!==void 0)throw new o("V4 uses poolKey or poolKeys; omit path and fees.");if(t.poolKey===void 0==(t.poolKeys===void 0))throw new o("Provide poolKey or poolKeys, not both.");if(t.poolKeys!==void 0){if(!Array.isArray(t.poolKeys)||t.poolKeys.length<1||t.poolKeys.length>5)throw new o("Provide 1 to 5 v4 poolKeys.");let p=t.poolKeys.map(P=>_(P));I=ye(p,n,s,e),m=(await v.simulateContract({address:te,abi:oe,functionName:e?"quoteExactOutput":"quoteExactInput",args:[{exactCurrency:e?s:n,path:I,exactAmount:r}],account:i,gas:E,blockNumber:y.number})).result[0]}else{if(h=_(t.poolKey),![h.currency0,h.currency1].includes(n)||![h.currency0,h.currency1].includes(s))throw new o("PoolKey currencies differ from the requested swap.");m=(await v.simulateContract({address:te,abi:oe,functionName:e?"quoteExactOutputSingle":"quoteExactInputSingle",args:[{poolKey:h,zeroForOne:n===h.currency0,exactAmount:r,hookData:"0x"}],account:i,gas:E,blockNumber:y.number})).result[0]}k="0x10"}else{if(t.poolKey!==void 0||t.poolKeys!==void 0||n===w||s===w)throw new o("V2/v3 routes use ERC-20 tokens; wrap ETH to WETH first.");if(c=Array.isArray(t.path)?t.path.map(Q):[n,s],c.length<2||c.length>6||c[0]!==n||c.at(-1)!==s||new Set(c).size!==c.length||c.includes(w))throw new o("Path must contain 2 to 6 distinct ERC-20 tokens in input-to-output order.");if(a==="v2"){if(t.fees!==void 0)throw new o("V2 fees are fixed by the pair; omit fees.");let p=await v.readContract({address:J,abi:Y,functionName:e?"getAmountsIn":"getAmountsOut",args:[r,c],blockNumber:y.number});m=e?p[0]:p.at(-1),k=e?"0x09":"0x08"}else{let p=t.fees;if(!Array.isArray(p)||p.length!==c.length-1||p.some(P=>typeof P!="number"||!Number.isInteger(P)||P<0||P>1e6))throw new o("Provide one integer v3 fee in pips per path hop.");if(!B(await v.readContract({address:ee,abi:ne,functionName:"factory",blockNumber:y.number}),N[4663].uniswap.v3_factory.address))throw new o("V3 quoter is not configured for the pinned factory.");C=we(c,p,e),m=(await v.simulateContract({address:ee,abi:ne,functionName:e?"quoteExactOutput":"quoteExactInput",args:[C,r],account:i,gas:E,blockNumber:y.number})).result[0],k=e?"0x01":"0x00"}}if(m<=0n)throw new o("No positive Uniswap quote is available.");let T=e?t.maxAmountIn:t.minAmountOut;if(!d&&T===void 0)throw new o(`Provide ${e?"maxAmountIn":"minAmountOut"} from uniswap_quote to confirm the trade bound.`);let f=T===void 0?e?(m*BigInt(1e4+F)+9999n)/10000n:m*BigInt(1e4-F)/10000n:R(T,e?"maxAmountIn":"minAmountOut",a==="v4"?128:160);if(f<=0n||(e?f<m:f>m))throw new o("The fresh quote does not satisfy the confirmed swap bound.");let b=e?f:r;if(b>=1n<<160n||a==="v4"&&(b>=1n<<128n||f>=1n<<128n))throw new o("Swap bounds exceed the router amount range.");let[ae,se]=await Promise.all([$(u,n,y.number),$(u,s,y.number)]),j={version:a,input:{token:ae,amount:(e?m:r).toString()},output:{token:se,amount:(e?r:m).toString()},[e?"maxAmountIn":"minAmountOut"]:f.toString(),blockNumber:y.number.toString(),expiresAt:(y.timestamp+60n).toString()};if(d)return{quote:j,summary:"Read-only on-chain quote. Repeat the same route with the returned bound in uniswap_swap; execution gets a fresh quote and preview."};let O=y.timestamp+300n,K=[];if(n!==w&&(K.push(u.approval(n,U,b.toString(),g)),K.push(u.unsignedTx({to:U,data:Z({abi:me,functionName:"approve",args:[n,D,b,Number(O)]}),value:"0",chainId:g,description:`Permit exactly ${b} input base units to Universal Router until ${O}.`}))),a==="v4"){let p=I?x(fe,[{exactCurrency:e?s:n,path:I,minHopPriceX36:[],amount:r,limit:f}]):x(le,[{poolKey:h,zeroForOne:n===h.currency0,amount:r,limit:f,minHopPriceX36:0n,hookData:"0x"}]);q=x(be,[I?e?"0x090c0f":"0x070c0f":e?"0x080c0f":"0x060c0f",[p,x(re,[n,b]),x(re,[s,e?r:f])]])}else a==="v2"?q=x(xe,[i,r,f,c,!0,[]]):q=x(he,[i,r,f,C,!0,[]]);let X=[q];return n===w&&e&&(k=`${k}04`,X.push(x(A("address,address,uint256"),[w,i,0n]))),K.push(u.unsignedTx({to:D,data:Z({abi:de,functionName:"execute",args:[k,X,O]}),value:n===w?b.toString():"0",chainId:g,description:`Uniswap ${a} ${e?"exact output":"exact input"} swap; recipient ${i}; deadline ${O}.`})),{...await G(u,K,i,"Swap through Universal Router 2.1.2. Exact approvals, fixed output/input bound and five-minute on-chain deadline. Venue fees included; gas excluded."),quote:j}}function Ee(u){return{tools:[!0,!1].map(t=>({name:t?"uniswap_quote":"uniswap_swap",inputSchema:{type:"object",additionalProperties:!1,required:["version","tokenIn","tokenOut"],properties:ue},execute:(i,d)=>Ae(u,i,d,t)}))}}export{ee as a,te as b,de as c,me as d,ne as e,oe as f,fe as g,ye as h,le as i,he as j,xe as k,we as l,Ae as m,Ee as n};
@@ -0,0 +1 @@
1
+ function c(r,t){return r==="hoodlock_airdrop_claim"&&!Object.hasOwn(t,"id")}var h=new Map([]),_="find_tool",l="run_tool",n=["oak_setup","oak_identity_unlink","oak_subscribe","oak_renew","send","hoodlock_feature_buy","hoodlock_feature_claim","hoodlock_referral_register"],d={oak:["account","balances","find_token","price","quote","swap","positions","send","oak_setup","oak_subscribe","oak_renew","oak_identity_unlink"],kyberswap:[],velora:[],steakhouse:["steakhouse_deposit","steakhouse_withdraw"],spark:["spark_deposit","spark_withdraw"],netnet:["netnet_deposit","netnet_withdraw"],longbow:["longbow_list","longbow_deposit","longbow_withdraw"],grove:["grove_deposit","grove_withdraw"],beefy:["beefy_list","beefy_deposit","beefy_withdraw"],pons:["pons_browse","pons_buy","pons_sell","pons_launch"],orbio:["orbio_credit_status","orbio_buy_credit"],hoodlock:["hoodlock_list_locks","hoodlock_lock","hoodlock_withdraw"],merkl:["merkl_rewards","merkl_claim"],relay:["relay_bridge_in","relay_bridge_out","relay_status"],lighter:["lighter_funding"],erc8004:["erc8004_identity"],hoodag:["hoodag_resolve","hoodag_register"],heyresearch:["heyresearch_research_project"],priors:["priors_status","priors_lend","priors_withdraw","priors_borrow","priors_repay"],morpho:["morpho_status","morpho_supply","morpho_withdraw","morpho_supply_collateral","morpho_withdraw_collateral","morpho_borrow","morpho_repay"],uniswap:["uniswap_list_positions","uniswap_add","uniswap_remove","uniswap_collect"],hookr:["hookr_orders","hookr_create","hookr_cancel"],meridian:["meridian_browse","meridian_positions","meridian_sell","meridian_redeem"],tickerspring:["tickerspring_account","tickerspring_create","tickerspring_cancel","tickerspring_claim"],clanker:["clanker_browse","clanker_launch"],poolstrade:["poolstrade_status","poolstrade_buy","poolstrade_sell","poolstrade_launch"]};function w(r,t){let i=new Set(r),s=new Set;for(let[e,a]of Object.entries(d))for(let o of a){if(s.has(o))throw new Error(`Visible tool ${o} is listed twice.`);if(e!=="oak"&&!o.startsWith(`${e}_`))throw new Error(`Visible tool ${o} is filed under ${e}.`);if(n.includes(o)||i.has(o))s.add(o);else if(t==="mainnet")throw new Error(`Visible tool ${o} is not registered.`)}for(let e of[_,l,...n])if(i.has(e))throw new Error(`Tool name ${e} is reserved for the add-on.`);return s}export{c as a,h as b,_ as c,l as d,n as e,d as f,w as g};
@@ -0,0 +1 @@
1
+ import{a as d}from"./RETS2ZEK.js";import{a as o}from"./5YS5V2LK.js";import{getAddress as w,isAddress as c,zeroAddress as g}from"viem";var u="^0x[0-9a-fA-F]{40}$",m=new RegExp(u),y={type:"string",pattern:u},R="Provide a valid contract or wallet address.";function a(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function h(n,t){if(!a(n))throw new o(t);return n}function A(n,t){return n.toLowerCase()===t.toLowerCase()}function S(n,t){return typeof n=="string"&&typeof t=="string"&&A(n,t)}function s(n,t,r){if(typeof n!="string")throw new o(t);if(!c(n,{strict:!1}))throw new o(r);return n}function E(n,t,r=t){return w(s(n,t,r))}function D(n,t,r=t){return s(n,t,r).toLowerCase()}function T(n,t,r=t){return s(n,t,r)}function L(n,t){if(n.toLowerCase()===g)throw new o(t);return n}function B(n,t){if(typeof n!="bigint"||n<0n||n>=1n<<256n)throw new o(t);return n}function C(n,t,r={}){let{notString:i,bits:f=256,positive:p=!1}=r;if(i!==void 0&&typeof n!="string")throw new o(i);let e=d(n);if(e>=1n<<BigInt(f)||p&&e===0n)throw new o(t);return e}export{u as a,m as b,y as c,R as d,a as e,h as f,A as g,S as h,E as i,D as j,T as k,L as l,B as m,C as n};
@@ -0,0 +1 @@
1
+ import{a as p,e as C}from"./HNMOB76J.js";import{a as A}from"./UWOFA6GV.js";import{a as u}from"./XPFVT2EA.js";import{a as f}from"./5YS5V2LK.js";import{encodeFunctionData as E,erc20Abi as v,getAddress as i,parseAbi as F}from"viem";var s={chainId:4663,usdg:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",v4:{poolManager:"0x8366a39CC670B4001A1121B8F6A443A643e40951",swapper:"0x7Cd4E04E433E69e588728c86A3832753B5F846d4",quoter:"0x8dc178efb8111bb0973dd9d722ebeff267c98f94",stateView:"0xf3334192d15450cdd385c8b70e03f9a6bd9e673b"},v3:{router:"0xCaf681a66D020601342297493863E78C959E5cb2",quoter:"0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7",factory:"0x1f7d7550B1b028f7571E69A784071F0205FD2EfA"},tokens:[{symbol:"AAPL",token:"0xaF3D76f1834A1d425780943C99Ea8A608f8a93f9",pools:[{v:3,fee:500,pool:"0xAae0d815EE56e4092a5E5C2911E676Fea50B2d6D"},{v:4,fee:3e3,tickSpacing:60,id:"0xc748f4671a867db48b552f6b7650bf3255e05f80f00e3f7aad1b17ccb7898fdb"},{v:3,fee:3e3,pool:"0x783C9bbB765047CFdD2b84b92b2Ca9F11D34b7Ed"}]},{symbol:"AMD",token:"0x86923f96303D656E4aa86D9d42D1e57ad2023fdC",pools:[{v:3,fee:3e3,pool:"0x48D284A2A4d3DC1b3Da08231Fe44317e7e7Aa51f"}]},{symbol:"AMZN",token:"0x12f190a9F9d7D37a250758b26824B97CE941bF54",pools:[{v:3,fee:3e3,pool:"0x8AC92DA74AB5F3b1d024Dc1943Ad7e15Dc4179Ef"},{v:4,fee:2400,tickSpacing:24,id:"0xefc94885c96b02696b9b45de43eeeb8ac53c0199cab42b4daae4911b96fb8825"}]},{symbol:"ASML",token:"0x47F93d52cBeC7C6D2CfC080e154002370a60dAEA",pools:[{v:3,fee:1e4,pool:"0xedb22516B14Eb2d1C86927Db373B0E8bF70F5cD1"}]},{symbol:"BABA",token:"0xad25Ac6C84D497db898fa1E8387bf6Af3532a1c4",pools:[{v:4,fee:1e3,tickSpacing:10,id:"0x1791fc651cc794a282e5dbcb56d0b2b38eff8754b677c8876e86901521ecc439"},{v:3,fee:3e3,pool:"0xa57ab582b310dd6f9e934EA1EEEa152741545E6A"}]},{symbol:"COIN",token:"0x6330D8C3178a418788dF01a47479c0ce7CCF450b",pools:[{v:4,fee:2500,tickSpacing:25,id:"0xe2e1a0e32205e854525e0fb1d3667a53bd3b4919f032b9bcd2a038b6b6dac314"},{v:4,fee:1e4,tickSpacing:200,id:"0x007a13fa152f6dc383cad20a8eaab4e1e2538b606936eae2a424f8aa47d6db31"}]},{symbol:"CRCL",token:"0xdF0992E440dD0be65BD8439b609d6D4366bf1CB5",pools:[{v:3,fee:3e3,pool:"0x654E4143e82a5824445Ade0824351C2A9ACD95a8"},{v:4,fee:3e3,tickSpacing:30,id:"0x628c98ab436ee34a6a7decd606242890582591bdf7c9a35d90e0d08021c31ea0"},{v:4,fee:1500,tickSpacing:15,id:"0x5177eac8c2176468bbf15e44081e151d35c2e7d068e96d3db94f496a4dc944b2"}]},{symbol:"CRWV",token:"0x5f10A1C971B69e47e059e1dC91901B59b3fB49C3",pools:[{v:4,fee:9e3,tickSpacing:90,id:"0x237014478f7ef98afbe7412ac35b6a3f96b8fb111de48b7c4dbf49dba4bd9c4b"}]},{symbol:"DELL",token:"0x941AE714EC6D8130c7B75d67160Ca08f1e7d11Dd",pools:[{v:3,fee:1e4,pool:"0xc30c89cB7815A1488b7998D15eEC73961707Fc5a"}]},{symbol:"GME",token:"0x1b0E319c6A659F002271B69dB8A7df2F911c153E",pools:[{v:3,fee:500,pool:"0xE2b46c905E12Ab8E2f864e4821a4325884C1B126"}]},{symbol:"GOOGL",token:"0x2e0847E8910a9732eB3fb1bb4b70a580ADAD4FE3",pools:[{v:3,fee:500,pool:"0x34D0dC122CF9A8Eb296fC5e0D3A233625D7d19b7"},{v:4,fee:300,tickSpacing:3,id:"0x43fe16b75cabbf38f5b185d16142b02d1d9200d8f1ba17cb6cf899f562c6197f"},{v:4,fee:3e3,tickSpacing:60,id:"0xd4ecb79fdc521d7725d22b33ed43cb4e47aa96bfad76aa29577e3151f723ac5e"}]},{symbol:"INTC",token:"0xc72b96e0E48ecd4DC75E1e45396e26300BC39681",pools:[{v:3,fee:3e3,pool:"0x2e5a92f5013a64661A49312111be2e8aBd33F56a"}]},{symbol:"META",token:"0xc0D6457C16Cc70d6790Dd43521C899C87ce02f35",pools:[{v:4,fee:310,tickSpacing:3,id:"0xc58bb68060bcb7b3ea0f6d4a4afef1e57f628722e808db12afb6d1733552872f"},{v:3,fee:3e3,pool:"0x107a7Cb40d8665360ba10E59471Af06150A50922"},{v:4,fee:3e3,tickSpacing:60,id:"0x5875d407a42965b0e768c8925cea290e06fa50603ef34fc99eb92a1050e6ae36"}]},{symbol:"MSFT",token:"0xe93237C50D904957Cf27E7B1133b510C669c2e74",pools:[{v:3,fee:3e3,pool:"0xeb60bCD1D920ad6E102690CCFC6fB488899E1510"},{v:4,fee:3e3,tickSpacing:60,id:"0x9194a557b6a6bb2236b49ea7e2bbccec5d3eeb705aef00903be4b3de1d949579"}]},{symbol:"MSTR",token:"0xec262a75e413fAfD0dF80480274532C79D42da09",pools:[{v:4,fee:2500,tickSpacing:25,id:"0x319bac87e616a89e241c10aeb8afd4892a852cdd8b373cd9765ecddc40b87cfe"},{v:4,fee:2400,tickSpacing:24,id:"0xc105b8300ff65d750a0e4e63c7a879e20504069b770713464a5315e797735326"}]},{symbol:"MU",token:"0xfF080c8ce2E5feadaCa0Da81314Ae59D232d4afD",pools:[{v:3,fee:3e3,pool:"0xd057B1Bc54917855BBee58eAd58647f47caB35E5"}]},{symbol:"NBIS",token:"0x9D9c6684F596F66a64C030B93A886D51Fd4D7931",pools:[{v:4,fee:9900,tickSpacing:99,id:"0x7c2f9ce1214ba9baf56d1b6a1fc640c1b63e9a711172c0c7d10e5a9c4a3d4f0c"}]},{symbol:"NVDA",token:"0xd0601CE157Db5bdC3162BbaC2a2C8aF5320D9EEC",pools:[{v:3,fee:500,pool:"0xd4EB21209C4D6093f80B5b84f5C45cc093EA14a3"},{v:4,fee:100,tickSpacing:1,id:"0x6444a8e0b267406a15db74ca00c4a24bdfa81ed3180f5b6d0851f8ed6f4f29c5"},{v:4,fee:3e3,tickSpacing:60,id:"0x3bb34a44f1b2b5f32c034c38a53065a521a47b199700fa9bd19d60985ff24bf1"}]},{symbol:"ORCL",token:"0xb0992820E760d836549ba69BC7598b4af75dEE03",pools:[{v:4,fee:1e4,tickSpacing:200,id:"0xc2ce4784e1e72cf0221b51b30c8aaadf6c0b12863cf03ab3687854fb7b1d850a"}]},{symbol:"PLTR",token:"0x894E1EC2D74FFE5AEF8Dc8A9e84686acCB964F2A",pools:[{v:4,fee:1500,tickSpacing:15,id:"0xc59eaeda6d1a6f031bc7e1d039772f2d675e7b4de2c8668610f4471bd60b3802"},{v:3,fee:3e3,pool:"0x851680416A4f4E1c463d45171d61ACDdBc8554c0"}]},{symbol:"QQQ",token:"0xD5f3879160bc7c32ebb4dC785F8a4F505888de68",pools:[{v:3,fee:500,pool:"0xD60A5d14dB690B7Afad71F76B108071D7175597d"}]},{symbol:"SGOV",token:"0x92FD66527192E3e61d4DDd13322Aa222DE86F9B5",pools:[{v:3,fee:500,pool:"0x6Ba50150B17Ffd0972915Aaf04fFd5E8f4Fa49b4"},{v:3,fee:3e3,pool:"0xfAb520051f96F4D2a32c22B6a3dD7fFfdf231bFe"}]},{symbol:"SLV",token:"0x411eFb0E7f985935DAec3D4C3ebaEa0d0AD7D89f",pools:[{v:3,fee:3e3,pool:"0x8cB787e6c315D464775289BaD00FDD67d53Ecb3D"},{v:3,fee:1e4,pool:"0x0Fa7BC480885DCf58Ad2ef63eC7289cF2481D51c"}]},{symbol:"SNDK",token:"0xB90A19fF0Af67f7779afF50A882A9CfF42446400",pools:[{v:4,fee:1e4,tickSpacing:200,id:"0x2707cb88a6a40fa0f948f58958051ba097d6f6a3cf7f87929bd68ccc5becea24"}]},{symbol:"SPCX",token:"0x4a0E65A3EcceC6dBe60AE065F2e7bb85Fae35eEa",pools:[{v:3,fee:500,pool:"0xc61284332117c3FB23A2A56cceFFD07F7aF60029"},{v:3,fee:3e3,pool:"0xEb07d9587eFD1778dFb9c385Ec43EF6d5F9fE401"}]},{symbol:"SPY",token:"0x117cc2133c37B721F49dE2A7a74833232B3B4C0C",pools:[{v:4,fee:100,tickSpacing:1,id:"0xe1ae6a4c6ccc9f037389a8d50a4f577bde1a9fe01d85d88ecbbd39955ce53288"},{v:3,fee:500,pool:"0xa7Bb1AC63BBaB0C44316E6c8C455213441689167"},{v:4,fee:500,tickSpacing:5,id:"0xe5923c8a8be481ec89a2ca784a2bbfa4235de6d88f92260fd66b660c4babf907"}]},{symbol:"TSLA",token:"0x322F0929c4625eD5bAd873c95208D54E1c003b2d",pools:[{v:3,fee:3e3,pool:"0xf4ACdAEEB7022862A763C9B1B885e11191c889E3"},{v:4,fee:3e3,tickSpacing:60,id:"0x8517f8071ae5b831b738052f12125e8e3d6c158b78728aa44ce3b25e5104d32e"}]},{symbol:"TSM",token:"0x58FfE4a942d3885bAa22D7520691F611EF09e7AA",pools:[{v:4,fee:7500,tickSpacing:75,id:"0x0ba5d53d2f6255f334b7c8ead4f56b6aef5af3402c5e4d11180afd38c6b85fb1"},{v:3,fee:1e4,pool:"0x07e8Ea83D4C1340774c8965125e26e12bf943bf1"}]},{symbol:"USAR",token:"0xd917B029C761D264c6A312BBbcDA868658eF86a6",pools:[{v:3,fee:3e3,pool:"0x04391780F519B7d3ba59c9590459D76e23d225C4"}]},{symbol:"USO",token:"0xa30FA36Db767ad9eD3f7a60fC79526fB4d56D344",pools:[{v:4,fee:1200,tickSpacing:15,id:"0x1f2ad5a274a776d8e1408292bde1d92d8fa7b6444acf14ad60b9c3e4e5b66420"},{v:3,fee:3e3,pool:"0x02175608F1b5E6b5ed221cCFdC7Be197D111D915"}]}],notOffered:{CLSK:"thin",EWY:"thin",IONQ:"thin",RGTI:"thin",RKLB:"thin"},sourceCommit:"02230282d8888e00794207ed271ee01b4ce30309"};var g="(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)",w="(address tokenIn,address tokenOut,uint24 fee,address recipient,uint256 amountIn,uint256 amountOutMinimum,uint160 sqrtPriceLimitX96)",y=F([`function swapExactIn(${g} key,bool zeroForOne,uint128 amountIn,uint256 minOut,uint160 sqrtPriceLimitX96,address to,uint256 deadline) returns (uint256 paid,uint256 out)`,`function exactInputSingle(${w} params) payable returns (uint256 amountOut)`,"function multicall(uint256 deadline,bytes[] data) payable returns (bytes[] results)"]),O=F(["function quoteExactInputSingle((address tokenIn,address tokenOut,uint256 amountIn,uint24 fee,uint160 sqrtPriceLimitX96) params) returns (uint256 amountOut,uint160 sqrtPriceX96After,uint32 initializedTicksCrossed,uint256 gasEstimate)"]),P=F([`function quoteExactInputSingle((${g} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256 amountOut,uint256 gasEstimate)`]),q="0x0000000000000000000000000000000000000000",D={symbol:{type:"string",enum:s.tokens.map(o=>o.symbol)},side:{type:"string",enum:["buy","sell"]},amountIn:A()};function B(o){let t=s.tokens.find(e=>e.symbol===o.symbol);if(!t||o.side!=="buy"&&o.side!=="sell")throw new f("Choose a published stock symbol and buy or sell.");let a=C(o.amountIn,"amountIn",128);if(a===0n)throw new f("amountIn must be positive base units.");return{token:t,amount:a,input:o.side==="buy"?p.usdg:i(t.token),output:o.side==="buy"?i(t.token):p.usdg}}function S(o,t,a){let[e,n]=BigInt(p.usdg)<BigInt(o)?[p.usdg,o]:[o,p.usdg];return{currency0:e,currency1:n,fee:t,tickSpacing:a,hooks:q}}function j(o){return{tools:[{name:"priors_stock_quote",inputSchema:{type:"object",properties:D,required:Object.keys(D),additionalProperties:!1},async execute(t,a){if(o.network==="testnet")throw new f("Priors stock swaps require mainnet chain 4663.");let e=B(t),n=o.clientFor(u),c=await n.getBlockNumber({cacheTime:0}),m=await Promise.all(e.token.pools.map(async(b,l)=>{try{let r=S(i(e.token.token),b.fee,"tickSpacing"in b?b.tickSpacing:0),x=b.v===3?await n.simulateContract({address:i(s.v3.quoter),abi:O,functionName:"quoteExactInputSingle",args:[{tokenIn:e.input,tokenOut:e.output,amountIn:e.amount,fee:b.fee,sqrtPriceLimitX96:0n}],account:a,blockNumber:c}):await n.simulateContract({address:i(s.v4.quoter),abi:P,functionName:"quoteExactInputSingle",args:[{poolKey:r,zeroForOne:e.input===r.currency0,exactAmount:e.amount,hookData:"0x"}],account:a,blockNumber:c});return{poolIndex:l,version:b.v,amountOut:x.result[0].toString()}}catch(r){return{poolIndex:l,version:b.v,error:o.plainError(r)}}})),[d,k]=await Promise.all([n.readContract({address:i(e.token.token),abi:v,functionName:"decimals"}),n.readContract({address:i(e.token.token),abi:v,functionName:"symbol"})]);return{chainId:u,blockNumber:c.toString(),token:{address:i(e.token.token),symbol:k,decimals:d,chainId:u},quotes:m,warning:"Use explicit minimum output with priors_stock_swap and inspect its preview. Issuer restrictions can prevent sale. Quote is no promise of an exit; local regional eligibility remains required."}}},{name:"priors_stock_swap",inputSchema:{type:"object",properties:{...D,poolIndex:{type:"integer",minimum:0,maximum:2},minOut:A(),deadline:A(),eligible:{type:"boolean",description:"Operator/user affirms eligibility for this stock-token trade in their jurisdiction."}},required:[...Object.keys(D),"poolIndex","minOut","deadline","eligible"],additionalProperties:!1},async execute(t,a){if(o.network==="testnet")throw new f("Priors stock swaps require mainnet chain 4663.");if(a=i(a),t.eligible!==!0)throw new f("Confirm local eligibility for Robinhood stock tokens before trading.");let e=B(t),n=C(t.minOut,"minOut"),c=C(t.deadline,"deadline"),m=BigInt(Math.floor(Date.now()/1e3));if(n===0n||c<=m||c>m+1800n||!Number.isSafeInteger(t.poolIndex))throw new f("Provide positive minOut, poolIndex and a deadline within 30 minutes.");let d=e.token.pools[t.poolIndex];if(!d)throw new f("No published pool at that index. Read priors_stock_quote.");let k=S(i(e.token.token),d.fee,"tickSpacing"in d?d.tickSpacing:0),b=e.input===k.currency0,l=i(d.v===3?s.v3.router:s.v4.swapper),r=d.v===3?E({abi:y,functionName:"multicall",args:[c,[E({abi:y,functionName:"exactInputSingle",args:[{tokenIn:e.input,tokenOut:e.output,fee:d.fee,recipient:a,amountIn:e.amount,amountOutMinimum:n,sqrtPriceLimitX96:0n}]})]]}):E({abi:y,functionName:"swapExactIn",args:[k,b,e.amount,n,b?4295128740n:1461446703485210103287273052203988822378723970341n,a,c]}),x=[o.approval(e.input,l,e.amount.toString(),u),o.unsignedTx({to:l,data:r,value:"0",chainId:u,description:`Priors stock ${t.side}: ${e.amount} input base units; minimum ${n}; pinned V${d.v} pool.`})],I=await o.preview(x,a);return{txs:x,expiresAt:c.toString(),summary:`Stock ${t.side} ${t.symbol}: input ${e.amount} base units (${e.input}), minimum output ${n} (${e.output}), receiver ${a}, deadline ${c}. Issuer transfer/sale restrictions apply. Price impact is not measured by this builder; inspect minOut and the preview. ${I.summary}`}}}]}}export{y as a,j as b};
@@ -0,0 +1 @@
1
+ import{g as h}from"./O47JXRXN.js";import{a as O}from"./6IM6A5VA.js";import{a as l}from"./UWOFA6GV.js";import{h as g}from"./73N3TOJL.js";import{a as w,i as B}from"./XPFVT2EA.js";import{a as n}from"./5YS5V2LK.js";import{encodeFunctionData as k,getAddress as T,parseAbi as D,parseAbiItem as _,zeroAddress as E}from"viem";var b=T("0x23e99d72e24dc538c955b9bade710d2ce3a7fca4"),v={address:T(B[w].tokens.USDG.address),symbol:"USDG",decimals:6,chainId:w},f=D(["function rewardToken() view returns (address)","function owner() view returns (address)","function publisher() view returns (address)","function epochs(uint256) view returns (bytes32 root,uint128 total,uint128 claimed,uint64 expiry,bool swept)","function hasClaimed(uint256,address) view returns (bool)","function claimable(uint256 epochId,address account,uint256 amount,bytes32[] proof) view returns (bool)","function claim(uint256 epochId,uint256 amount,bytes32[] proof)","function setPublisher(address publisher)","function sweep(uint256 epochId,address to)","function fundEpoch(uint256 epochId,bytes32 root,uint256 total,uint64 expiry)","function transferOwnership(address newOwner)","function renounceOwnership()"]),N=_("event EpochFunded(uint256 indexed epochId,bytes32 root,uint256 total,uint64 expiry)"),P=p=>{if(typeof p!="string"||!/^0x[0-9a-f]{64}$/i.test(p))throw new n("Provide a bytes32 Merkle root or proof element.");return p};function R(p){if(!Array.isArray(p)||p.length>64)throw new n("Provide the publisher\u2019s Merkle proof array (at most 64 elements).");return p.map(P)}var M=p=>{async function x(){let e=p.clientFor(w);if(await e.getChainId()!==w)throw new n("Longbow rebates require chain 4663.");let a=await e.getBlock(),s=(o,c=[])=>e.readContract({address:b,abi:f,functionName:o,args:c,blockNumber:a.number}),i=await s("rewardToken");if(!g(i,v.address))throw new n("The Longbow rebate distributor does not report canonical USDG.");return{client:e,block:a,read:s}}async function A(e,a,s,i){let[o,c]=await Promise.all([s("epochs",[e]),s("hasClaimed",[e,a])]);if(!Array.isArray(o)||o.length!==5||typeof c!="boolean")throw new n("Invalid rebate epoch state.");let[r,d,u,m,t]=o;if(typeof d!="bigint"||typeof u!="bigint"||u>d||typeof m!="bigint"||typeof t!="boolean")throw new n("Invalid rebate epoch amounts.");return{epochId:e.toString(),root:P(r),total:d.toString(),claimedAmount:u.toString(),outstanding:(t?0n:d-u).toString(),expiry:m.toString(),swept:t,hasClaimed:c,open:r!==`0x${"0".repeat(64)}`&&!t&&i<m}}let S=(e,a,s,i)=>({name:e,inputSchema:{type:"object",properties:a,required:s,additionalProperties:!1},execute:async(o,c)=>{try{if(O(c),Object.keys(o).some(r=>!Object.hasOwn(a,r)))throw new n("Unsupported Longbow rebate argument.");return await i(o,c)}catch(r){throw new n(p.plainError(r))}}});return{tools:[S("longbow_rebates",{epochIds:{type:"array",maxItems:100,items:l()},fromBlock:l()},[],async(e,a)=>{let{client:s,read:i,block:o}=await x();if(e.epochIds!==void 0&&e.fromBlock!==void 0)throw new n("Use epochIds or fromBlock, not both.");let c,r;if(e.epochIds!==void 0){if(!Array.isArray(e.epochIds)||e.epochIds.length>100)throw new n("Provide at most 100 rebate epochIds.");c=e.epochIds.map(t=>h(t))}else{if(r=e.fromBlock===void 0?o.number>100000n?o.number-100000n:0n:h(e.fromBlock),r>o.number||o.number-r>1000000n)throw new n("Read at most 1000000 blocks per rebate discovery window.");let t=await s.getLogs({address:b,event:N,fromBlock:r,toBlock:o.number,strict:!0});if(c=[...new Set(t.map(y=>y.args.epochId))],c.length>100)throw new n("Too many rebate epochs; narrow the block window.")}let[d,u,m]=await Promise.all([i("owner"),i("publisher"),Promise.all(c.map(t=>A(t,a,i,o.timestamp)))]);return{chainId:w,distributor:b,token:v,blockNumber:o.number.toString(),owner:d,publisher:u,epochs:m,scannedFromBlock:r?.toString()??null,caveat:"Discovery covers only these IDs or this event window. Amounts/proofs require the publisher\u2019s tree; the app does not expose a verified proof endpoint. Claims expire at each on-chain expiry, even if app prose says otherwise."}}),S("longbow_claim_rebate",{epochId:l(),amount:l(),proof:{type:"array",maxItems:64,items:{type:"string"}}},["epochId","amount","proof"],async(e,a)=>{let s=h(e.epochId),i=h(e.amount),o=R(e.proof),{read:c,block:r}=await x(),d=await A(s,a,c,r.timestamp);if(!d.open||d.hasClaimed||i===0n||await c("claimable",[s,a,i,o])!==!0)throw new n("Rebate is closed, already claimed or not proven for this wallet and amount.");let u=`Claim ${i} USDG base units from Longbow rebate epoch ${s} to this wallet ${a}. No approvals.`,m=[p.unsignedTx({to:b,data:k({abi:f,functionName:"claim",args:[s,i,o]}),value:"0",chainId:w,description:u})],t=await p.preview(m,a);if(t.changes.filter(I=>I.token.chainId===w&&g(I.token.address,v.address)&&I.token.decimals===6).reduce((I,C)=>I+BigInt(C.amount),0n)!==i)throw new n("Rebate preview does not return the exact proven USDG amount.");return{txs:m,preview:t,summary:`${u} ${t.summary}`}}),S("longbow_manage_rebates",{operation:{enum:["setPublisher","fundEpoch","sweep","transferOwnership","renounceOwnership"]},epochId:l(),root:{type:"string"},amount:l(),expiry:l(),account:{type:"string"}},["operation"],async(e,a)=>{let{read:s,block:i}=await x(),o=e.operation==="fundEpoch";if(!g(await s(o?"publisher":"owner"),a))throw new n("This wallet lacks the rebate publisher/owner role.");let c=o?["operation","epochId","root","amount","expiry"]:e.operation==="sweep"?["operation","epochId","account"]:e.operation==="renounceOwnership"?["operation"]:["operation","account"];if(Object.keys(e).some(t=>!c.includes(t)))throw new n("Unexpected fields for this rebate management operation.");let r,d=0n;if(o){let t=h(e.expiry,64);if(d=h(e.amount,128),d===0n||t<i.timestamp+30n*86400n)throw new n("Fund a positive rebate amount with at least 30 days to claim.");r=k({abi:f,functionName:"fundEpoch",args:[h(e.epochId),P(e.root),d,t]})}else if(e.operation==="renounceOwnership")r=k({abi:f,functionName:"renounceOwnership"});else{if(typeof e.account!="string")throw new n("Provide the explicit publisher, owner or sweep recipient.");O(e.account);let t=T(e.account);if(t===E)throw new n("The rebate recipient/role cannot be zero.");if(e.operation==="sweep"){let y=await A(h(e.epochId),a,s,i.timestamp);if(y.swept||i.timestamp<BigInt(y.expiry))throw new n("Only expired, unswept rebate epochs can be swept.");r=k({abi:f,functionName:"sweep",args:[h(e.epochId),t]})}else if(e.operation==="setPublisher"||e.operation==="transferOwnership")r=k({abi:f,functionName:e.operation,args:[t]});else throw new n("Choose a supported rebate management operation.")}let u=`Longbow rebate ${String(e.operation)}: ${JSON.stringify(e)}. ${e.operation==="renounceOwnership"?"Owner administration is permanently relinquished.":""}`,m=[...o?[p.approval(v.address,b,d.toString(),w)]:[],p.unsignedTx({to:b,data:r,value:"0",chainId:w,description:u})];return{txs:m,preview:await p.preview(m,a),summary:u}})]}};export{b as a,f as b,M as c};
@@ -0,0 +1 @@
1
+ import{b as R}from"./UXG67LH3.js";import{a as w}from"./6IM6A5VA.js";import{g as S}from"./73N3TOJL.js";import{a as o,i as k,j as v}from"./XPFVT2EA.js";import{a as t}from"./5YS5V2LK.js";import{encodeFunctionData as x,getAddress as h,keccak256 as A,parseAbi as O,parseAbiItem as T,toHex as C,zeroHash as E}from"viem";var i=h(k[o].vaults.spark.address),g={admin:E,setter:A(C("SETTER_ROLE")),taker:A(C("TAKER_ROLE"))},D=[["drip()","any"],["setVsr(uint256 rate)","setter"],["setVsrBounds(uint256 minimum,uint256 maximum)","admin"],["setDepositCap(uint256 cap)","admin"],["take(uint256 assets)","taker"],["grantRole(bytes32 role,address account)","admin"],["revokeRole(bytes32 role,address account)","admin"],["renounceRole(bytes32 role,address account)","any"],["upgradeToAndCall(address implementation,bytes data)","admin"]],N=D.map(([r,a])=>({abi:T(`function ${r}`),authority:a})),p=O(["function asset() view returns (address)","function hasRole(bytes32,address) view returns (bool)","function getRoleMemberCount(bytes32) view returns (uint256)","function getRoleMember(bytes32,uint256) view returns (address)"]);function _(r){return[{name:"spark_roles",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async(a,s)=>{try{if(w(s),Object.keys(a).length)throw new t("Spark roles takes no arguments.");let e=r.clientFor(o);if(await e.getChainId()!==o)throw new t("Spark requires chain 4663.");let u=await e.getBlockNumber({cacheTime:0}),c=await Promise.all(Object.entries(g).map(async([f,d])=>{let l=await e.readContract({address:i,abi:p,functionName:"getRoleMemberCount",args:[d],blockNumber:u});if(l>256n)throw new t("Spark role membership exceeds this reader\u2019s supported size.");let[b,n]=await Promise.all([e.readContract({address:i,abi:p,functionName:"hasRole",args:[d,s],blockNumber:u}),Promise.all(Array.from({length:Number(l)},(y,m)=>e.readContract({address:i,abi:p,functionName:"getRoleMember",args:[d,BigInt(m)],blockNumber:u})))]);return{name:f,role:d,heldByWallet:b,members:n.map(y=>h(y))}}));return{vault:i,chainId:o,blockNumber:u.toString(),roles:c}}catch(e){throw new t(r.plainError(e))}}},{name:"spark_manage",inputSchema:{type:"object",additionalProperties:!1,required:["operation","values"],properties:{operation:{type:"string",enum:N.map(a=>a.abi.name)},values:{type:"array",maxItems:2,items:{type:"string"},description:"Ordered contract inputs; all integers are decimal base-unit strings."}}},execute:async(a,s)=>{try{if(w(s),Object.keys(a).some(n=>!["operation","values"].includes(n)))throw new t("Unexpected Spark management argument.");let e=N.find(n=>n.abi.name===a.operation);if(!e||!Array.isArray(a.values)||a.values.length!==e.abi.inputs.length)throw new t("Provide a supported Spark operation and its exact ordered values.");let u=e.abi.inputs.map((n,y)=>{let m=a.values[y];if(n.type==="bytes32"){if(typeof m!="string"||!Object.values(g).includes(m))throw new t("Provide a documented Spark role identifier.");return m}return R(n.type,m)});if(e.abi.name==="renounceRole"&&!S(String(u[1]),s))throw new t("Role renunciation must name this wallet.");let c=r.clientFor(o);if(await c.getChainId()!==o)throw new t("Spark requires chain 4663.");let f=await c.readContract({address:i,abi:p,functionName:"asset"});if(h(f)!==h(v))throw new t("Spark does not use canonical USDG.");if(e.authority!=="any"&&await c.readContract({address:i,abi:p,functionName:"hasRole",args:[g[e.authority],s]})!==!0)throw new t("This wallet does not hold the required Spark role. No transaction was built.");let d=`${e.abi.name} on Spark ${i}; ordered values ${JSON.stringify(a.values)}. ${e.abi.name==="upgradeToAndCall"?"Replaces vault implementation; Oak must review and re-pin upgraded code before subsequent use.":e.abi.name==="take"?"Pulls vault liquidity to this role-authorized wallet; it mints no savings shares.":""}`,l=[r.unsignedTx({to:i,data:x({abi:[e.abi],functionName:e.abi.name,args:u}),value:"0",chainId:o,description:d})],b=await r.preview(l,s);return{txs:l,preview:b,summary:`${d} ${b.summary} Role and rate bounds are enforced again by the contract at execution.`}}catch(e){throw new t(r.plainError(e))}}}]}export{N as a,_ as b};
@@ -0,0 +1 @@
1
+ var e=[{name:"BLUE",type:"function",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{name:"PUBLIC_ALLOCATOR",type:"function",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{name:"blueBundlesV1MigrateBorrowPosition",type:"function",inputs:[{name:"sourceMarketParams",type:"tuple",components:[{name:"loanToken",type:"address",internalType:"address"},{name:"collateralToken",type:"address",internalType:"address"},{name:"oracle",type:"address",internalType:"address"},{name:"irm",type:"address",internalType:"address"},{name:"lltv",type:"uint256",internalType:"uint256"}],internalType:"struct MarketParams"},{name:"destMarketParams",type:"tuple",components:[{name:"loanToken",type:"address",internalType:"address"},{name:"collateralToken",type:"address",internalType:"address"},{name:"oracle",type:"address",internalType:"address"},{name:"irm",type:"address",internalType:"address"},{name:"lltv",type:"uint256",internalType:"uint256"}],internalType:"struct MarketParams"},{name:"maxLtv",type:"uint256",internalType:"uint256"},{name:"signedAuthorization",type:"tuple",components:[{name:"signature",type:"tuple",components:[{name:"v",type:"uint8",internalType:"uint8"},{name:"r",type:"bytes32",internalType:"bytes32"},{name:"s",type:"bytes32",internalType:"bytes32"}],internalType:"struct Signature"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"}],internalType:"struct SignedAuthorization"},{name:"reallocations",type:"tuple[]",components:[{name:"vault",type:"address",internalType:"address"},{name:"adapter",type:"address",internalType:"address"},{name:"marketParams",type:"tuple",components:[{name:"loanToken",type:"address",internalType:"address"},{name:"collateralToken",type:"address",internalType:"address"},{name:"oracle",type:"address",internalType:"address"},{name:"irm",type:"address",internalType:"address"},{name:"lltv",type:"uint256",internalType:"uint256"}],internalType:"struct MarketParams"},{name:"fromIdle",type:"bool",internalType:"bool"},{name:"sourceAdapter",type:"address",internalType:"address"},{name:"sourceMarketParams",type:"tuple",components:[{name:"loanToken",type:"address",internalType:"address"},{name:"collateralToken",type:"address",internalType:"address"},{name:"oracle",type:"address",internalType:"address"},{name:"irm",type:"address",internalType:"address"},{name:"lltv",type:"uint256",internalType:"uint256"}],internalType:"struct MarketParams"},{name:"assets",type:"uint128",internalType:"uint128"},{name:"penalty",type:"uint64",internalType:"uint64"}],internalType:"struct PublicAllocations[]"},{name:"referralFeePct",type:"uint256",internalType:"uint256"},{name:"referralFeeRecipient",type:"address",internalType:"address"},{name:"deadline",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{name:"blueBundlesV1RepayAndWithdrawCollateral",type:"function",inputs:[{name:"marketParams",type:"tuple",components:[{name:"loanToken",type:"address",internalType:"address"},{name:"collateralToken",type:"address",internalType:"address"},{name:"oracle",type:"address",internalType:"address"},{name:"irm",type:"address",internalType:"address"},{name:"lltv",type:"uint256",internalType:"uint256"}],internalType:"struct MarketParams"},{name:"repayAssets",type:"uint256",internalType:"uint256"},{name:"repayShares",type:"uint256",internalType:"uint256"},{name:"maxRepayAssets",type:"uint256",internalType:"uint256"},{name:"collateralAssets",type:"uint256",internalType:"uint256"},{name:"maxLtv",type:"uint256",internalType:"uint256"},{name:"loanTokenPermit",type:"tuple",components:[{name:"kind",type:"uint8",internalType:"enum PermitKind"},{name:"data",type:"bytes",internalType:"bytes"}],internalType:"struct TokenPermit"},{name:"signedAuthorization",type:"tuple",components:[{name:"signature",type:"tuple",components:[{name:"v",type:"uint8",internalType:"uint8"},{name:"r",type:"bytes32",internalType:"bytes32"},{name:"s",type:"bytes32",internalType:"bytes32"}],internalType:"struct Signature"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"}],internalType:"struct SignedAuthorization"},{name:"referralFeePct",type:"uint256",internalType:"uint256"},{name:"referralFeeRecipient",type:"address",internalType:"address"},{name:"deadline",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"payable"},{name:"blueBundlesV1Supply",type:"function",inputs:[{name:"marketParams",type:"tuple",components:[{name:"loanToken",type:"address",internalType:"address"},{name:"collateralToken",type:"address",internalType:"address"},{name:"oracle",type:"address",internalType:"address"},{name:"irm",type:"address",internalType:"address"},{name:"lltv",type:"uint256",internalType:"uint256"}],internalType:"struct MarketParams"},{name:"assets",type:"uint256",internalType:"uint256"},{name:"loanTokenPermit",type:"tuple",components:[{name:"kind",type:"uint8",internalType:"enum PermitKind"},{name:"data",type:"bytes",internalType:"bytes"}],internalType:"struct TokenPermit"},{name:"referralFeePct",type:"uint256",internalType:"uint256"},{name:"referralFeeRecipient",type:"address",internalType:"address"},{name:"deadline",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"payable"},{name:"blueBundlesV1SupplyCollateralAndBorrow",type:"function",inputs:[{name:"marketParams",type:"tuple",components:[{name:"loanToken",type:"address",internalType:"address"},{name:"collateralToken",type:"address",internalType:"address"},{name:"oracle",type:"address",internalType:"address"},{name:"irm",type:"address",internalType:"address"},{name:"lltv",type:"uint256",internalType:"uint256"}],internalType:"struct MarketParams"},{name:"collateralAssets",type:"uint256",internalType:"uint256"},{name:"borrowAssets",type:"uint256",internalType:"uint256"},{name:"maxLtv",type:"uint256",internalType:"uint256"},{name:"collateralPermit",type:"tuple",components:[{name:"kind",type:"uint8",internalType:"enum PermitKind"},{name:"data",type:"bytes",internalType:"bytes"}],internalType:"struct TokenPermit"},{name:"signedAuthorization",type:"tuple",components:[{name:"signature",type:"tuple",components:[{name:"v",type:"uint8",internalType:"uint8"},{name:"r",type:"bytes32",internalType:"bytes32"},{name:"s",type:"bytes32",internalType:"bytes32"}],internalType:"struct Signature"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"}],internalType:"struct SignedAuthorization"},{name:"reallocations",type:"tuple[]",components:[{name:"vault",type:"address",internalType:"address"},{name:"adapter",type:"address",internalType:"address"},{name:"marketParams",type:"tuple",components:[{name:"loanToken",type:"address",internalType:"address"},{name:"collateralToken",type:"address",internalType:"address"},{name:"oracle",type:"address",internalType:"address"},{name:"irm",type:"address",internalType:"address"},{name:"lltv",type:"uint256",internalType:"uint256"}],internalType:"struct MarketParams"},{name:"fromIdle",type:"bool",internalType:"bool"},{name:"sourceAdapter",type:"address",internalType:"address"},{name:"sourceMarketParams",type:"tuple",components:[{name:"loanToken",type:"address",internalType:"address"},{name:"collateralToken",type:"address",internalType:"address"},{name:"oracle",type:"address",internalType:"address"},{name:"irm",type:"address",internalType:"address"},{name:"lltv",type:"uint256",internalType:"uint256"}],internalType:"struct MarketParams"},{name:"assets",type:"uint128",internalType:"uint128"},{name:"penalty",type:"uint64",internalType:"uint64"}],internalType:"struct PublicAllocations[]"},{name:"referralFeePct",type:"uint256",internalType:"uint256"},{name:"referralFeeRecipient",type:"address",internalType:"address"},{name:"deadline",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"payable"},{name:"blueBundlesV1Withdraw",type:"function",inputs:[{name:"marketParams",type:"tuple",components:[{name:"loanToken",type:"address",internalType:"address"},{name:"collateralToken",type:"address",internalType:"address"},{name:"oracle",type:"address",internalType:"address"},{name:"irm",type:"address",internalType:"address"},{name:"lltv",type:"uint256",internalType:"uint256"}],internalType:"struct MarketParams"},{name:"withdrawAssets",type:"uint256",internalType:"uint256"},{name:"withdrawShares",type:"uint256",internalType:"uint256"},{name:"signedAuthorization",type:"tuple",components:[{name:"signature",type:"tuple",components:[{name:"v",type:"uint8",internalType:"uint8"},{name:"r",type:"bytes32",internalType:"bytes32"},{name:"s",type:"bytes32",internalType:"bytes32"}],internalType:"struct Signature"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"}],internalType:"struct SignedAuthorization"},{name:"reallocations",type:"tuple[]",components:[{name:"vault",type:"address",internalType:"address"},{name:"adapter",type:"address",internalType:"address"},{name:"marketParams",type:"tuple",components:[{name:"loanToken",type:"address",internalType:"address"},{name:"collateralToken",type:"address",internalType:"address"},{name:"oracle",type:"address",internalType:"address"},{name:"irm",type:"address",internalType:"address"},{name:"lltv",type:"uint256",internalType:"uint256"}],internalType:"struct MarketParams"},{name:"fromIdle",type:"bool",internalType:"bool"},{name:"sourceAdapter",type:"address",internalType:"address"},{name:"sourceMarketParams",type:"tuple",components:[{name:"loanToken",type:"address",internalType:"address"},{name:"collateralToken",type:"address",internalType:"address"},{name:"oracle",type:"address",internalType:"address"},{name:"irm",type:"address",internalType:"address"},{name:"lltv",type:"uint256",internalType:"uint256"}],internalType:"struct MarketParams"},{name:"assets",type:"uint128",internalType:"uint128"},{name:"penalty",type:"uint64",internalType:"uint64"}],internalType:"struct PublicAllocations[]"},{name:"referralFeePct",type:"uint256",internalType:"uint256"},{name:"referralFeeRecipient",type:"address",internalType:"address"},{name:"deadline",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"}];export{e as a};