@oakagentkit/core 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (678) hide show
  1. package/build/dist/api/abort-scope.d.ts +2 -0
  2. package/build/dist/api/abort-scope.js +1 -0
  3. package/build/dist/api/chain.js +1 -1
  4. package/build/dist/api/history.js +1 -1
  5. package/build/dist/api/http.js +1 -1
  6. package/build/dist/api/metadata.js +1 -1
  7. package/build/dist/api/modules/beefy/boosts.js +1 -1
  8. package/build/dist/api/modules/beefy/clm.js +1 -1
  9. package/build/dist/api/modules/beefy/guard.js +1 -1
  10. package/build/dist/api/modules/beefy/index.js +1 -1
  11. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  12. package/build/dist/api/modules/beefy/management.js +1 -1
  13. package/build/dist/api/modules/beefy/vaults.js +1 -1
  14. package/build/dist/api/modules/borro/actions.js +1 -1
  15. package/build/dist/api/modules/borro/checks.js +1 -1
  16. package/build/dist/api/modules/borro/copy.d.ts +17 -12
  17. package/build/dist/api/modules/borro/copy.js +1 -1
  18. package/build/dist/api/modules/borro/index.js +1 -1
  19. package/build/dist/api/modules/borro/liquidity.js +1 -1
  20. package/build/dist/api/modules/borro/positions.js +1 -1
  21. package/build/dist/api/modules/borro/reader.d.ts +6 -2
  22. package/build/dist/api/modules/borro/reader.js +1 -1
  23. package/build/dist/api/modules/borro/types.d.ts +6 -0
  24. package/build/dist/api/modules/chop/abi.d.ts +558 -0
  25. package/build/dist/api/modules/chop/abi.js +1 -0
  26. package/build/dist/api/modules/chop/actions.d.ts +24 -0
  27. package/build/dist/api/modules/chop/actions.js +1 -0
  28. package/build/dist/api/modules/chop/checks.d.ts +34 -0
  29. package/build/dist/api/modules/chop/checks.js +1 -0
  30. package/build/dist/api/modules/chop/copy.d.ts +15 -0
  31. package/build/dist/api/modules/chop/copy.js +1 -0
  32. package/build/dist/api/modules/chop/guard.d.ts +13 -0
  33. package/build/dist/api/modules/chop/guard.js +1 -0
  34. package/build/dist/api/modules/chop/index.d.ts +3 -0
  35. package/build/dist/api/modules/chop/index.js +1 -0
  36. package/build/dist/api/modules/chop/pins.d.ts +53 -0
  37. package/build/dist/api/modules/chop/pins.js +1 -0
  38. package/build/dist/api/modules/chop/positions.d.ts +3 -0
  39. package/build/dist/api/modules/chop/positions.js +1 -0
  40. package/build/dist/api/modules/chop/reader.d.ts +195 -0
  41. package/build/dist/api/modules/chop/reader.js +1 -0
  42. package/build/dist/api/modules/chop/types.d.ts +44 -0
  43. package/build/dist/api/modules/chop/types.js +0 -0
  44. package/build/dist/api/modules/clanker/extensions.d.ts +9 -0
  45. package/build/dist/api/modules/clanker/extensions.js +1 -1
  46. package/build/dist/api/modules/clanker/index.js +1 -1
  47. package/build/dist/api/modules/clanker/manage.js +1 -1
  48. package/build/dist/api/modules/clanker/pool-config.d.ts +15 -0
  49. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  50. package/build/dist/api/modules/clanker/protocol.js +1 -1
  51. package/build/dist/api/modules/earn/copy.d.ts +32 -10
  52. package/build/dist/api/modules/earn/copy.js +1 -1
  53. package/build/dist/api/modules/earn/cost.d.ts +11 -1
  54. package/build/dist/api/modules/earn/cost.js +1 -1
  55. package/build/dist/api/modules/earn/index.js +1 -1
  56. package/build/dist/api/modules/earn/lp.d.ts +14 -1
  57. package/build/dist/api/modules/earn/lp.js +1 -1
  58. package/build/dist/api/modules/earn/options.d.ts +6 -4
  59. package/build/dist/api/modules/earn/options.js +1 -1
  60. package/build/dist/api/modules/erc8004/common.d.ts +1 -1
  61. package/build/dist/api/modules/erc8004/common.js +1 -1
  62. package/build/dist/api/modules/erc8004/domain.js +1 -1
  63. package/build/dist/api/modules/erc8004/index.js +1 -1
  64. package/build/dist/api/modules/erc8004/management.js +1 -1
  65. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  66. package/build/dist/api/modules/erc8004/services.js +1 -1
  67. package/build/dist/api/modules/erc8004/validation.js +1 -1
  68. package/build/dist/api/modules/factor/abi.d.ts +642 -0
  69. package/build/dist/api/modules/factor/abi.js +1 -0
  70. package/build/dist/api/modules/factor/actions.d.ts +15 -0
  71. package/build/dist/api/modules/factor/actions.js +1 -0
  72. package/build/dist/api/modules/factor/api.d.ts +7 -0
  73. package/build/dist/api/modules/factor/api.js +1 -0
  74. package/build/dist/api/modules/factor/checks.d.ts +11 -0
  75. package/build/dist/api/modules/factor/checks.js +1 -0
  76. package/build/dist/api/modules/factor/copy.d.ts +33 -0
  77. package/build/dist/api/modules/factor/copy.js +1 -0
  78. package/build/dist/api/modules/factor/guard.d.ts +12 -0
  79. package/build/dist/api/modules/factor/guard.js +1 -0
  80. package/build/dist/api/modules/factor/index.d.ts +16 -0
  81. package/build/dist/api/modules/factor/index.js +8 -0
  82. package/build/dist/api/modules/factor/messages.d.ts +46 -0
  83. package/build/dist/api/modules/factor/messages.js +1 -0
  84. package/build/dist/api/modules/factor/pins.d.ts +64 -0
  85. package/build/dist/api/modules/factor/pins.js +1 -0
  86. package/build/dist/api/modules/factor/reader.d.ts +17 -0
  87. package/build/dist/api/modules/factor/reader.js +1 -0
  88. package/build/dist/api/modules/factor/types.d.ts +18 -0
  89. package/build/dist/api/modules/factor/types.js +0 -0
  90. package/build/dist/api/modules/gloam/abi.d.ts +89 -0
  91. package/build/dist/api/modules/gloam/abi.js +1 -0
  92. package/build/dist/api/modules/gloam/actions.d.ts +5 -0
  93. package/build/dist/api/modules/gloam/actions.js +1 -0
  94. package/build/dist/api/modules/gloam/checks.d.ts +17 -0
  95. package/build/dist/api/modules/gloam/checks.js +1 -0
  96. package/build/dist/api/modules/gloam/copy.d.ts +23 -0
  97. package/build/dist/api/modules/gloam/copy.js +2 -0
  98. package/build/dist/api/modules/gloam/index.d.ts +6 -0
  99. package/build/dist/api/modules/gloam/index.js +1 -0
  100. package/build/dist/api/modules/gloam/pins.d.ts +41 -0
  101. package/build/dist/api/modules/gloam/pins.js +1 -0
  102. package/build/dist/api/modules/gloam/types.d.ts +308 -0
  103. package/build/dist/api/modules/gloam/types.js +1 -0
  104. package/build/dist/api/modules/grove/index.js +1 -1
  105. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  106. package/build/dist/api/modules/heyresearch/index.js +1 -1
  107. package/build/dist/api/modules/heyresearch/public-reads.d.ts +29 -1
  108. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  109. package/build/dist/api/modules/heyresearch/scan.js +1 -1
  110. package/build/dist/api/modules/heyresearch/status-labels.d.ts +2 -0
  111. package/build/dist/api/modules/heyresearch/status-labels.js +1 -1
  112. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  113. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  114. package/build/dist/api/modules/hoodag/index.js +1 -1
  115. package/build/dist/api/modules/hoodag/management.js +1 -1
  116. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  117. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  118. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  119. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  120. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  121. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  122. package/build/dist/api/modules/hoodlock/index.js +1 -1
  123. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  124. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  125. package/build/dist/api/modules/hoodlock/public.js +1 -1
  126. package/build/dist/api/modules/hookr/actions.js +1 -1
  127. package/build/dist/api/modules/hookr/addons.js +1 -1
  128. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  129. package/build/dist/api/modules/hookr/contracts.d.ts +2 -1
  130. package/build/dist/api/modules/hookr/contracts.js +1 -1
  131. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  132. package/build/dist/api/modules/hookr/discovery.js +1 -1
  133. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  134. package/build/dist/api/modules/hookr/index.js +1 -1
  135. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  136. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  137. package/build/dist/api/modules/hookr/launch.js +1 -1
  138. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  139. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  140. package/build/dist/api/modules/hookr/lp-reads.d.ts +2 -0
  141. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  142. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  143. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  144. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  145. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  146. package/build/dist/api/modules/hookr/relay.js +1 -1
  147. package/build/dist/api/modules/hookr/revenue.js +1 -1
  148. package/build/dist/api/modules/kyberswap/index.js +1 -1
  149. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  150. package/build/dist/api/modules/layerbank/actions.js +1 -1
  151. package/build/dist/api/modules/layerbank/index.js +1 -1
  152. package/build/dist/api/modules/layerbank/merkl.js +1 -1
  153. package/build/dist/api/modules/layerbank/reader.js +1 -1
  154. package/build/dist/api/modules/lighter/index.js +1 -1
  155. package/build/dist/api/modules/longbow/administration.js +1 -1
  156. package/build/dist/api/modules/longbow/fixed.js +1 -1
  157. package/build/dist/api/modules/longbow/index.js +1 -1
  158. package/build/dist/api/modules/longbow/nft.js +1 -1
  159. package/build/dist/api/modules/longbow/rebates.js +1 -1
  160. package/build/dist/api/modules/longbow/staking.js +1 -1
  161. package/build/dist/api/modules/meridian/index.js +1 -1
  162. package/build/dist/api/modules/meridian/markets.js +1 -1
  163. package/build/dist/api/modules/meridian/perps-batch.js +1 -1
  164. package/build/dist/api/modules/meridian/perps-stream.js +1 -1
  165. package/build/dist/api/modules/meridian/perps.js +1 -1
  166. package/build/dist/api/modules/meridian/predict-read.js +1 -1
  167. package/build/dist/api/modules/meridian/rfq.js +1 -1
  168. package/build/dist/api/modules/merkl/discovery.js +1 -1
  169. package/build/dist/api/modules/merkl/index.js +1 -1
  170. package/build/dist/api/modules/merkl/manage.js +1 -1
  171. package/build/dist/api/modules/merkl/protocol.js +1 -1
  172. package/build/dist/api/modules/morpho/allocator.js +1 -1
  173. package/build/dist/api/modules/morpho/bundles.js +1 -1
  174. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  175. package/build/dist/api/modules/morpho/index.js +1 -1
  176. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  177. package/build/dist/api/modules/morpho/midnight.js +1 -1
  178. package/build/dist/api/modules/morpho/protocol.js +1 -1
  179. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  180. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  181. package/build/dist/api/modules/morpho/vault-v2.d.ts +2 -0
  182. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  183. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  184. package/build/dist/api/modules/netnet/card-read.js +1 -1
  185. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  186. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  187. package/build/dist/api/modules/netnet/desk-read.js +1 -1
  188. package/build/dist/api/modules/netnet/financial.js +1 -1
  189. package/build/dist/api/modules/netnet/index.js +1 -1
  190. package/build/dist/api/modules/netnet/staking.js +1 -1
  191. package/build/dist/api/modules/orbio/gateway.js +1 -1
  192. package/build/dist/api/modules/orbio/index.js +1 -1
  193. package/build/dist/api/modules/pendle/convert.js +1 -1
  194. package/build/dist/api/modules/pendle/costs.js +1 -1
  195. package/build/dist/api/modules/pendle/index.js +1 -1
  196. package/build/dist/api/modules/pendle/markets.js +1 -1
  197. package/build/dist/api/modules/pendle/positions.js +1 -1
  198. package/build/dist/api/modules/pendle/pricecheck.js +1 -1
  199. package/build/dist/api/modules/pendle/reader.js +1 -1
  200. package/build/dist/api/modules/pendle/redeem.js +1 -1
  201. package/build/dist/api/modules/pendle/trade.js +1 -1
  202. package/build/dist/api/modules/pendle/validate.js +1 -1
  203. package/build/dist/api/modules/pons/claim.js +1 -1
  204. package/build/dist/api/modules/pons/holder-directory.js +1 -1
  205. package/build/dist/api/modules/pons/index.js +1 -1
  206. package/build/dist/api/modules/pons/launch-status.d.ts +1 -0
  207. package/build/dist/api/modules/pons/launch-status.js +1 -1
  208. package/build/dist/api/modules/pons/reads.js +1 -1
  209. package/build/dist/api/modules/pons/trade.d.ts +3 -2
  210. package/build/dist/api/modules/pons/trade.js +1 -1
  211. package/build/dist/api/modules/poolstrade/index.js +1 -1
  212. package/build/dist/api/modules/priors/coverage.js +1 -1
  213. package/build/dist/api/modules/priors/discovery.js +1 -1
  214. package/build/dist/api/modules/priors/features.js +1 -1
  215. package/build/dist/api/modules/priors/holdings.js +1 -1
  216. package/build/dist/api/modules/priors/index.js +1 -1
  217. package/build/dist/api/modules/priors/integration.d.ts +1 -0
  218. package/build/dist/api/modules/priors/integration.js +1 -1
  219. package/build/dist/api/modules/priors/market.js +1 -1
  220. package/build/dist/api/modules/priors/pt.js +1 -1
  221. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  222. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  223. package/build/dist/api/modules/raeto/authorization.d.ts +30 -0
  224. package/build/dist/api/modules/raeto/authorization.js +1 -0
  225. package/build/dist/api/modules/raeto/copy.d.ts +46 -0
  226. package/build/dist/api/modules/raeto/copy.js +1 -0
  227. package/build/dist/api/modules/raeto/errors.d.ts +4 -0
  228. package/build/dist/api/modules/raeto/errors.js +1 -0
  229. package/build/dist/api/modules/raeto/estimate.d.ts +2 -0
  230. package/build/dist/api/modules/raeto/estimate.js +1 -0
  231. package/build/dist/api/modules/raeto/index.d.ts +16 -0
  232. package/build/dist/api/modules/raeto/index.js +1 -0
  233. package/build/dist/api/modules/raeto/pairing.d.ts +40 -0
  234. package/build/dist/api/modules/raeto/pairing.js +1 -0
  235. package/build/dist/api/modules/raeto/pins.d.ts +24 -0
  236. package/build/dist/api/modules/raeto/pins.js +1 -0
  237. package/build/dist/api/modules/raeto/templates.d.ts +22 -0
  238. package/build/dist/api/modules/raeto/templates.js +1 -0
  239. package/build/dist/api/modules/raeto/terms.d.ts +8 -0
  240. package/build/dist/api/modules/raeto/terms.js +1 -0
  241. package/build/dist/api/modules/raeto/types.d.ts +64 -0
  242. package/build/dist/api/modules/raeto/types.js +0 -0
  243. package/build/dist/api/modules/relay/api.d.ts +16 -0
  244. package/build/dist/api/modules/relay/api.js +1 -1
  245. package/build/dist/api/modules/relay/discovery.js +1 -1
  246. package/build/dist/api/modules/relay/inbound.js +1 -1
  247. package/build/dist/api/modules/relay/index.d.ts +1 -0
  248. package/build/dist/api/modules/relay/index.js +1 -1
  249. package/build/dist/api/modules/relay/order.js +1 -1
  250. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  251. package/build/dist/api/modules/relay/readiness.d.ts +1 -0
  252. package/build/dist/api/modules/relay/readiness.js +1 -1
  253. package/build/dist/api/modules/relay/reads.js +1 -1
  254. package/build/dist/api/modules/relay/vaults.js +1 -1
  255. package/build/dist/api/modules/spark/actions.js +1 -1
  256. package/build/dist/api/modules/spark/index.js +1 -1
  257. package/build/dist/api/modules/spark/management.js +1 -1
  258. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  259. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  260. package/build/dist/api/modules/steakhouse/index.js +1 -1
  261. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  262. package/build/dist/api/modules/steakhouse/management.js +1 -1
  263. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  264. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  265. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  266. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  267. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  268. package/build/dist/api/modules/tickerspring/index.js +1 -1
  269. package/build/dist/api/modules/tickerspring/journeys.d.ts +1 -0
  270. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  271. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  272. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  273. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  274. package/build/dist/api/modules/tickerspring/research.js +1 -1
  275. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  276. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  277. package/build/dist/api/modules/uniswap/auction.js +1 -1
  278. package/build/dist/api/modules/uniswap/batch.js +1 -1
  279. package/build/dist/api/modules/uniswap/common.js +1 -1
  280. package/build/dist/api/modules/uniswap/fee-percent.d.ts +4 -0
  281. package/build/dist/api/modules/uniswap/fee-percent.js +1 -0
  282. package/build/dist/api/modules/uniswap/fees.js +1 -1
  283. package/build/dist/api/modules/uniswap/index.js +1 -1
  284. package/build/dist/api/modules/uniswap/local-guard.d.ts +2 -0
  285. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  286. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  287. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  288. package/build/dist/api/modules/uniswap/pools.d.ts +2 -0
  289. package/build/dist/api/modules/uniswap/pools.js +1 -1
  290. package/build/dist/api/modules/uniswap/position.js +1 -1
  291. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  292. package/build/dist/api/modules/uniswap/quote-guard.d.ts +38 -0
  293. package/build/dist/api/modules/uniswap/quote-guard.js +1 -0
  294. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  295. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  296. package/build/dist/api/modules/uniswap/trade.d.ts +10 -3
  297. package/build/dist/api/modules/uniswap/trade.js +1 -1
  298. package/build/dist/api/modules/uniswap/v2.js +1 -1
  299. package/build/dist/api/modules/uniswap/v3.js +1 -1
  300. package/build/dist/api/modules/uniswap/v4.d.ts +6 -0
  301. package/build/dist/api/modules/uniswap/v4.js +1 -1
  302. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  303. package/build/dist/api/modules/velora/claims.js +1 -1
  304. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  305. package/build/dist/api/modules/velora/index.js +1 -1
  306. package/build/dist/api/modules/wormhole/index.d.ts +3 -0
  307. package/build/dist/api/modules/wormhole/index.js +1 -1
  308. package/build/dist/api/modules/wormhole/scan-text.js +1 -1
  309. package/build/dist/api/modules/wormhole/swap-token-verdict.d.ts +11 -0
  310. package/build/dist/api/modules/wormhole/swap-token-verdict.js +1 -0
  311. package/build/dist/api/modules/wormhole/third-party-text.d.ts +24 -0
  312. package/build/dist/api/modules/wormhole/third-party-text.js +1 -0
  313. package/build/dist/api/modules/wormhole/token-check.d.ts +2 -0
  314. package/build/dist/api/modules/wormhole/token-check.js +1 -1
  315. package/build/dist/api/modules/wormhole/x402-client.d.ts +36 -0
  316. package/build/dist/api/modules/wormhole/x402-client.js +1 -0
  317. package/build/dist/api/oak-fee.d.ts +12 -0
  318. package/build/dist/api/oak-fee.js +1 -0
  319. package/build/dist/api/param-text.d.ts +22 -0
  320. package/build/dist/api/param-text.js +1 -0
  321. package/build/dist/api/position-economics.d.ts +70 -0
  322. package/build/dist/api/position-economics.js +1 -0
  323. package/build/dist/api/positions.d.ts +8 -5
  324. package/build/dist/api/positions.js +1 -1
  325. package/build/dist/api/prices.d.ts +3 -0
  326. package/build/dist/api/prices.js +1 -1
  327. package/build/dist/api/progress.d.ts +7 -0
  328. package/build/dist/api/progress.js +1 -0
  329. package/build/dist/api/read-budgets.d.ts +4 -0
  330. package/build/dist/api/read-budgets.js +1 -0
  331. package/build/dist/api/read-shape.d.ts +45 -0
  332. package/build/dist/api/read-shape.js +1 -0
  333. package/build/dist/api/revert.d.ts +23 -0
  334. package/build/dist/api/revert.js +1 -0
  335. package/build/dist/api/routes.js +1 -1
  336. package/build/dist/api/rpc.d.ts +1 -0
  337. package/build/dist/api/rpc.js +1 -1
  338. package/build/dist/api/secret-fields.js +1 -1
  339. package/build/dist/api/send.js +1 -1
  340. package/build/dist/api/signing-registry.d.ts +8 -0
  341. package/build/dist/api/signing-registry.js +1 -1
  342. package/build/dist/api/simulate.js +1 -1
  343. package/build/dist/api/swap.d.ts +4 -0
  344. package/build/dist/api/swap.js +1 -1
  345. package/build/dist/api/tokens.d.ts +1 -0
  346. package/build/dist/api/tokens.js +1 -1
  347. package/build/dist/api/tool-policy.js +1 -1
  348. package/build/dist/api/types.d.ts +9 -1
  349. package/build/dist/api/untrusted-unwrap.d.ts +1 -0
  350. package/build/dist/api/untrusted-unwrap.js +1 -0
  351. package/build/dist/api/usd-estimate.d.ts +23 -0
  352. package/build/dist/api/usd-estimate.js +1 -0
  353. package/build/dist/api/vendor-limits.js +1 -1
  354. package/build/dist/chunks/{JVLLVNF2.js → 2E4I7CJ7.js} +1 -1
  355. package/build/dist/chunks/2FHELZ7Y.js +1 -0
  356. package/build/dist/chunks/2GXHYI23.js +1 -0
  357. package/build/dist/chunks/2LWBN35N.js +1 -0
  358. package/build/dist/chunks/{4HG6FRVH.js → 2OKYXT25.js} +1 -1
  359. package/build/dist/chunks/2SUHQWND.js +1 -0
  360. package/build/dist/chunks/2ZWKIBJT.js +1 -0
  361. package/build/dist/chunks/32RXFUOH.js +1 -0
  362. package/build/dist/chunks/3CH2IPQL.js +1 -0
  363. package/build/dist/chunks/3DNJTJ2X.js +1 -0
  364. package/build/dist/chunks/3K2N5VFH.js +1 -0
  365. package/build/dist/chunks/3VBIRLU3.js +1 -0
  366. package/build/dist/chunks/3VWVW7PX.js +1 -0
  367. package/build/dist/chunks/3ZABD6ZF.js +2 -0
  368. package/build/dist/chunks/44MB6SA6.js +1 -0
  369. package/build/dist/chunks/4D4ZRZUW.js +1 -0
  370. package/build/dist/chunks/{KIFSRO5K.js → 4FPV4CRC.js} +1 -1
  371. package/build/dist/chunks/4GNUXN4K.js +1 -0
  372. package/build/dist/chunks/{K4DHHQBI.js → 4JRXEN7C.js} +2 -2
  373. package/build/dist/chunks/4JTTA3BX.js +1 -0
  374. package/build/dist/chunks/4OVIMYNH.js +2 -0
  375. package/build/dist/chunks/{326QMOTR.js → 4Q2ZBZXM.js} +1 -1
  376. package/build/dist/chunks/4RQAOOO2.js +1 -0
  377. package/build/dist/chunks/4TTDAF4B.js +1 -0
  378. package/build/dist/chunks/523ZIR3J.js +1 -0
  379. package/build/dist/chunks/5DPJQCKJ.js +68 -0
  380. package/build/dist/chunks/5HIHUYA4.js +1 -0
  381. package/build/dist/chunks/5PI57UC2.js +1 -0
  382. package/build/dist/chunks/5RXALTDT.js +1 -0
  383. package/build/dist/chunks/5TUXSOMI.js +1 -0
  384. package/build/dist/chunks/5UAXLWJ2.js +1 -0
  385. package/build/dist/chunks/5XAXJEWM.js +5 -0
  386. package/build/dist/chunks/67BWOVET.js +1 -0
  387. package/build/dist/chunks/6NUNCD5J.js +1 -0
  388. package/build/dist/chunks/6PZGDVHV.js +1 -0
  389. package/build/dist/chunks/{OKUO3BVM.js → 6UVGQYZ3.js} +1 -1
  390. package/build/dist/chunks/753HZZTY.js +1 -0
  391. package/build/dist/chunks/77CLMPM7.js +1 -0
  392. package/build/dist/chunks/7D73A6KS.js +1 -0
  393. package/build/dist/chunks/7MBVTNLU.js +1 -0
  394. package/build/dist/chunks/7QKYDNF6.js +18 -0
  395. package/build/dist/chunks/7VC53B5X.js +70 -0
  396. package/build/dist/chunks/{QSHCBASA.js → 7VNO46LV.js} +1 -1
  397. package/build/dist/chunks/ACH4BSME.js +3 -0
  398. package/build/dist/chunks/AHUCYDBC.js +1 -0
  399. package/build/dist/chunks/AI3VAPA3.js +1 -0
  400. package/build/dist/chunks/AMTRDPVO.js +1 -0
  401. package/build/dist/chunks/APHNOGNS.js +1 -0
  402. package/build/dist/chunks/APQYLJGS.js +1 -0
  403. package/build/dist/chunks/{WDK6VOG4.js → ARI72OYT.js} +1 -1
  404. package/build/dist/chunks/ARLGF5MU.js +1 -0
  405. package/build/dist/chunks/BAIY32AV.js +1 -0
  406. package/build/dist/chunks/BB765L75.js +3 -0
  407. package/build/dist/chunks/BE3A7677.js +1 -0
  408. package/build/dist/chunks/BX46C5ZP.js +1 -0
  409. package/build/dist/chunks/{IY7BXLT4.js → BZ34ZR65.js} +1 -1
  410. package/build/dist/chunks/C3WBHFLX.js +1 -0
  411. package/build/dist/chunks/C75MT5SD.js +1 -0
  412. package/build/dist/chunks/CAWTAR5V.js +1 -0
  413. package/build/dist/chunks/CNLL4NCR.js +1 -0
  414. package/build/dist/chunks/CO4GCF4L.js +1 -0
  415. package/build/dist/chunks/{P5PYFK7L.js → CQ5WRWV4.js} +1 -1
  416. package/build/dist/chunks/{SJJR4ZBZ.js → CSDN4MYP.js} +1 -1
  417. package/build/dist/chunks/CSOO4SW7.js +1 -0
  418. package/build/dist/chunks/CZL6T2ZQ.js +1 -0
  419. package/build/dist/chunks/D742AYEV.js +1 -0
  420. package/build/dist/chunks/DGCJZ3HO.js +1 -0
  421. package/build/dist/chunks/DNNFKDZR.js +1 -0
  422. package/build/dist/chunks/DPE7SPW7.js +1 -0
  423. package/build/dist/chunks/DSTMEY5F.js +1 -0
  424. package/build/dist/chunks/{X3BYCOWS.js → DYYEA5HB.js} +1 -1
  425. package/build/dist/chunks/EFESPGA2.js +1 -0
  426. package/build/dist/chunks/EGZREEG2.js +1 -0
  427. package/build/dist/chunks/EH5G4O3U.js +1 -0
  428. package/build/dist/chunks/EI6GGPDS.js +20 -0
  429. package/build/dist/chunks/EVBHQQQG.js +1 -0
  430. package/build/dist/chunks/EZZM2GQT.js +2 -0
  431. package/build/dist/chunks/F3VDVTMS.js +1 -0
  432. package/build/dist/chunks/F4UQEPJT.js +1 -0
  433. package/build/dist/chunks/FHTNMGFR.js +1 -0
  434. package/build/dist/chunks/FIO6VC2J.js +1 -0
  435. package/build/dist/chunks/FJLJ7ZQ5.js +1 -0
  436. package/build/dist/chunks/{WP6RHXGN.js → FL5SSHUL.js} +1 -1
  437. package/build/dist/chunks/FNGIJKMZ.js +1 -0
  438. package/build/dist/chunks/{KIFZ5ZSK.js → FOD34G2H.js} +1 -1
  439. package/build/dist/chunks/{WV3A3OUU.js → FOKEFXGP.js} +1 -1
  440. package/build/dist/chunks/FV4WZOTD.js +1 -0
  441. package/build/dist/chunks/FWIFTPSE.js +2 -0
  442. package/build/dist/chunks/FZ6IJZZM.js +1 -0
  443. package/build/dist/chunks/G2LAO23N.js +1 -0
  444. package/build/dist/chunks/GDRQ2ANN.js +1 -0
  445. package/build/dist/chunks/GG24LO2R.js +1 -0
  446. package/build/dist/chunks/GLF7WEY2.js +1 -0
  447. package/build/dist/chunks/GQ3XZFRL.js +1 -0
  448. package/build/dist/chunks/{QU5XKRGK.js → GQYV4TFO.js} +1 -1
  449. package/build/dist/chunks/GRSXWQWD.js +1 -0
  450. package/build/dist/chunks/{3GOHSYHW.js → GSFHM5L3.js} +1 -1
  451. package/build/dist/chunks/H5DY7CNB.js +1 -0
  452. package/build/dist/chunks/HCBX4NFM.js +1 -0
  453. package/build/dist/chunks/HHO5ISMM.js +1 -0
  454. package/build/dist/chunks/HIX5N25Z.js +1 -0
  455. package/build/dist/chunks/HKVQ646Q.js +1 -0
  456. package/build/dist/chunks/HS4DZPYT.js +1 -0
  457. package/build/dist/chunks/I6PQW2JI.js +1 -0
  458. package/build/dist/chunks/IEG6GLFR.js +1 -0
  459. package/build/dist/chunks/INOYMBWE.js +1 -0
  460. package/build/dist/chunks/IV4K7FMD.js +1 -0
  461. package/build/dist/chunks/{T2WHOZXM.js → J73ATSEQ.js} +1 -1
  462. package/build/dist/chunks/JBTOZ6IH.js +1 -0
  463. package/build/dist/chunks/JESMX2UC.js +1 -0
  464. package/build/dist/chunks/JJGZ7W3V.js +1 -0
  465. package/build/dist/chunks/JKRBGAX2.js +1 -0
  466. package/build/dist/chunks/JLRHM2DQ.js +1 -0
  467. package/build/dist/chunks/JOKL5L6X.js +1 -0
  468. package/build/dist/chunks/JS53DQVT.js +1 -0
  469. package/build/dist/chunks/{WIRBCS4W.js → JWR5XVP2.js} +1 -1
  470. package/build/dist/chunks/K6D6SDIG.js +1 -0
  471. package/build/dist/chunks/K7HTDKAT.js +1 -0
  472. package/build/dist/chunks/{GQ5GYUEH.js → KDGSYNOP.js} +1 -1
  473. package/build/dist/chunks/KKPMOAVI.js +1 -0
  474. package/build/dist/chunks/KREBNL2D.js +1 -0
  475. package/build/dist/chunks/L646YWDP.js +1 -0
  476. package/build/dist/chunks/{2MAMJJJC.js → LR4XTZ37.js} +1 -1
  477. package/build/dist/chunks/LVFI74ST.js +1 -0
  478. package/build/dist/chunks/{Z4FZVJ5Z.js → M7ZXDLKM.js} +1 -1
  479. package/build/dist/chunks/MVD3KWPP.js +1 -0
  480. package/build/dist/chunks/N245WC5R.js +1 -0
  481. package/build/dist/chunks/{WTXC3XKW.js → N4XNNXOJ.js} +1 -1
  482. package/build/dist/chunks/N6GIC7HJ.js +1 -0
  483. package/build/dist/chunks/{RUC7KH7A.js → NA424YAL.js} +1 -1
  484. package/build/dist/chunks/NUFZUKYS.js +1 -0
  485. package/build/dist/chunks/O3JWCJIF.js +1 -0
  486. package/build/dist/chunks/OARVU3RC.js +1 -0
  487. package/build/dist/chunks/OEZ7FCLF.js +1 -0
  488. package/build/dist/chunks/{H43RNCX2.js → OUROA7XR.js} +1 -1
  489. package/build/dist/chunks/{3FUVMSCF.js → OYJFXEDU.js} +1 -1
  490. package/build/dist/chunks/OYPAVXGQ.js +1 -0
  491. package/build/dist/chunks/{SMYWWIE6.js → OZ5MDUD2.js} +1 -1
  492. package/build/dist/chunks/P6OMKZMR.js +3 -0
  493. package/build/dist/chunks/PV4AK32X.js +1 -0
  494. package/build/dist/chunks/{HKEMQBFA.js → PXVREXCS.js} +1 -1
  495. package/build/dist/chunks/PZEF5LBL.js +2 -0
  496. package/build/dist/chunks/Q2ACLVWR.js +1 -0
  497. package/build/dist/chunks/QFSBDPLN.js +1 -0
  498. package/build/dist/chunks/QJNLLI6N.js +1 -0
  499. package/build/dist/chunks/QMZEGT5B.js +1 -0
  500. package/build/dist/chunks/{HSCQZ66A.js → REWXG6X6.js} +1 -1
  501. package/build/dist/chunks/{6B3VVISQ.js → RLI4JDOL.js} +1 -1
  502. package/build/dist/chunks/{4MXM6Q4W.js → RLMVA575.js} +1 -1
  503. package/build/dist/chunks/RPB46QAC.js +1 -0
  504. package/build/dist/chunks/{Q42YI3EP.js → RT7IU6TI.js} +1 -1
  505. package/build/dist/chunks/{ER47KGRM.js → SBY4RJ7I.js} +1 -1
  506. package/build/dist/chunks/SCG5HWMN.js +1 -0
  507. package/build/dist/chunks/SENOU5JR.js +1 -0
  508. package/build/dist/chunks/SKEKXEUU.js +1 -0
  509. package/build/dist/chunks/SOTYQGPT.js +1 -0
  510. package/build/dist/chunks/SZ466I5X.js +1 -0
  511. package/build/dist/chunks/{GNC6RXLT.js → TDZTC5WR.js} +1 -1
  512. package/build/dist/chunks/TE6D3OIX.js +1 -0
  513. package/build/dist/chunks/TID4C2KC.js +1 -0
  514. package/build/dist/chunks/TK55VASJ.js +2 -0
  515. package/build/dist/chunks/TM7Z5SA4.js +1 -0
  516. package/build/dist/chunks/TNJTET4G.js +1 -0
  517. package/build/dist/chunks/TPEKCXVE.js +1 -0
  518. package/build/dist/chunks/TVIMP5CK.js +1 -0
  519. package/build/dist/chunks/U2YCQWZK.js +1 -0
  520. package/build/dist/chunks/U363GQTF.js +1 -0
  521. package/build/dist/chunks/{U4JGEMKT.js → UEDGYZOC.js} +1 -1
  522. package/build/dist/chunks/UOCRYXAB.js +1 -0
  523. package/build/dist/chunks/UQEEF5W5.js +1 -0
  524. package/build/dist/chunks/{QQECG3WP.js → UUID2E22.js} +1 -1
  525. package/build/dist/chunks/UWBKAWX3.js +7 -0
  526. package/build/dist/chunks/V37L4DU4.js +1 -0
  527. package/build/dist/chunks/VR344DAZ.js +1 -0
  528. package/build/dist/chunks/{TX2EOIRS.js → VST6LFUB.js} +1 -1
  529. package/build/dist/chunks/VTPT5544.js +1 -0
  530. package/build/dist/chunks/VVWFB53Q.js +1 -0
  531. package/build/dist/chunks/WHTRPRRD.js +1 -0
  532. package/build/dist/chunks/WHVZ372B.js +1 -0
  533. package/build/dist/chunks/{AFBEZXNV.js → WNWRF4HE.js} +1 -1
  534. package/build/dist/chunks/WOGWLFAL.js +3 -0
  535. package/build/dist/chunks/WUT7TZYM.js +1 -0
  536. package/build/dist/chunks/XCKTE4ON.js +1 -0
  537. package/build/dist/chunks/XEPCDGN2.js +1 -0
  538. package/build/dist/chunks/XHYFISVV.js +1 -0
  539. package/build/dist/chunks/XPEDQBLI.js +1 -0
  540. package/build/dist/chunks/{D3YLXQPW.js → XQ24RSEI.js} +1 -1
  541. package/build/dist/chunks/XRDXFHIK.js +1 -0
  542. package/build/dist/chunks/XTFRPI4G.js +1 -0
  543. package/build/dist/chunks/XVJ7ILKK.js +1 -0
  544. package/build/dist/chunks/XWKK75TO.js +1 -0
  545. package/build/dist/chunks/{74Y2KDNR.js → XYPGLG6A.js} +1 -1
  546. package/build/dist/chunks/Y77EVVT4.js +1 -0
  547. package/build/dist/chunks/YEIM6BZQ.js +1 -0
  548. package/build/dist/chunks/{S47VUTHM.js → YMV5TL5C.js} +1 -1
  549. package/build/dist/chunks/YSMWCKIX.js +1 -0
  550. package/build/dist/chunks/YTLH4M4Y.js +1 -0
  551. package/build/dist/chunks/YUHNPUNK.js +1 -0
  552. package/build/dist/chunks/YWZQJJYY.js +1 -0
  553. package/build/dist/chunks/{UMIZMJWW.js → ZF2VPDRQ.js} +1 -1
  554. package/build/dist/chunks/ZFU65MB4.js +1 -0
  555. package/build/dist/chunks/ZKZUS3QU.js +1 -0
  556. package/build/dist/chunks/ZOMFHTB2.js +1 -0
  557. package/build/dist/chunks/{BTD5SMOW.js → ZP36DSOD.js} +1 -1
  558. package/build/dist/chunks/ZQ6AF3VX.js +1 -0
  559. package/package.json +1 -1
  560. package/build/dist/chunks/2KYAMXTS.js +0 -1
  561. package/build/dist/chunks/2TK3ETUO.js +0 -1
  562. package/build/dist/chunks/3MLUCYCB.js +0 -1
  563. package/build/dist/chunks/3NJ5KQ3Q.js +0 -1
  564. package/build/dist/chunks/3XNZUIRU.js +0 -1
  565. package/build/dist/chunks/3XXBLNEX.js +0 -1
  566. package/build/dist/chunks/45BRW2ZF.js +0 -1
  567. package/build/dist/chunks/46547QT3.js +0 -1
  568. package/build/dist/chunks/4PY3UFNR.js +0 -1
  569. package/build/dist/chunks/52ELWNXJ.js +0 -2
  570. package/build/dist/chunks/553UE2ZQ.js +0 -1
  571. package/build/dist/chunks/57MEFFCU.js +0 -1
  572. package/build/dist/chunks/5APS4T2D.js +0 -1
  573. package/build/dist/chunks/5SMVQCAP.js +0 -1
  574. package/build/dist/chunks/64GOINYS.js +0 -1
  575. package/build/dist/chunks/6D5DJA5B.js +0 -1
  576. package/build/dist/chunks/6I4NTKB2.js +0 -1
  577. package/build/dist/chunks/6OGDTEGH.js +0 -1
  578. package/build/dist/chunks/6PBGEPUK.js +0 -20
  579. package/build/dist/chunks/6WZX7C4T.js +0 -2
  580. package/build/dist/chunks/7WSHW7KW.js +0 -1
  581. package/build/dist/chunks/ABPL3ZZI.js +0 -1
  582. package/build/dist/chunks/AKYF5264.js +0 -7
  583. package/build/dist/chunks/APGLZXIW.js +0 -1
  584. package/build/dist/chunks/AVG4W3Y7.js +0 -1
  585. package/build/dist/chunks/B3RXD5ET.js +0 -1
  586. package/build/dist/chunks/BBS3ODWZ.js +0 -1
  587. package/build/dist/chunks/BJ2VGRF4.js +0 -1
  588. package/build/dist/chunks/BTPXJAUX.js +0 -1
  589. package/build/dist/chunks/C36BFZH6.js +0 -1
  590. package/build/dist/chunks/C7AXJHBT.js +0 -1
  591. package/build/dist/chunks/CBG5HARQ.js +0 -2
  592. package/build/dist/chunks/CCTXCMH4.js +0 -1
  593. package/build/dist/chunks/CHXBOXOD.js +0 -1
  594. package/build/dist/chunks/DJN3JAWB.js +0 -1
  595. package/build/dist/chunks/E674J2MD.js +0 -1
  596. package/build/dist/chunks/EE64JSLY.js +0 -1
  597. package/build/dist/chunks/EJ7O75A7.js +0 -1
  598. package/build/dist/chunks/ELSXLZN5.js +0 -1
  599. package/build/dist/chunks/FQ6UZCM6.js +0 -1
  600. package/build/dist/chunks/GEIFITAQ.js +0 -1
  601. package/build/dist/chunks/GGSAKCND.js +0 -1
  602. package/build/dist/chunks/GL4NCUMH.js +0 -1
  603. package/build/dist/chunks/GW626GG2.js +0 -1
  604. package/build/dist/chunks/H2XDMFQQ.js +0 -1
  605. package/build/dist/chunks/HAQPIBYR.js +0 -1
  606. package/build/dist/chunks/HCUHMCBW.js +0 -1
  607. package/build/dist/chunks/I26DMNJG.js +0 -1
  608. package/build/dist/chunks/IMO3GDA5.js +0 -1
  609. package/build/dist/chunks/INOZIE55.js +0 -1
  610. package/build/dist/chunks/J2OT4KAH.js +0 -1
  611. package/build/dist/chunks/JUZ5JU6D.js +0 -70
  612. package/build/dist/chunks/K3RDPI5J.js +0 -1
  613. package/build/dist/chunks/KBKK7UNY.js +0 -1
  614. package/build/dist/chunks/KPCY5V35.js +0 -1
  615. package/build/dist/chunks/L4N2RSK2.js +0 -1
  616. package/build/dist/chunks/L5BLHY34.js +0 -1
  617. package/build/dist/chunks/LSXUAHOE.js +0 -1
  618. package/build/dist/chunks/M37654RL.js +0 -1
  619. package/build/dist/chunks/MJ6WEWMI.js +0 -3
  620. package/build/dist/chunks/MR5L7V6Z.js +0 -1
  621. package/build/dist/chunks/N4Q6GN65.js +0 -1
  622. package/build/dist/chunks/NAZPDRIF.js +0 -1
  623. package/build/dist/chunks/NDCLTVIU.js +0 -1
  624. package/build/dist/chunks/NEEZBJBC.js +0 -1
  625. package/build/dist/chunks/NKX3FE34.js +0 -1
  626. package/build/dist/chunks/NKZKKCK2.js +0 -1
  627. package/build/dist/chunks/OJ4WJUPP.js +0 -1
  628. package/build/dist/chunks/OJPG45AC.js +0 -1
  629. package/build/dist/chunks/OTXSKFUD.js +0 -1
  630. package/build/dist/chunks/P3S4BR5G.js +0 -1
  631. package/build/dist/chunks/P56RZC2M.js +0 -1
  632. package/build/dist/chunks/P7I62KFR.js +0 -1
  633. package/build/dist/chunks/PK66GCDT.js +0 -1
  634. package/build/dist/chunks/PSBQWDYI.js +0 -1
  635. package/build/dist/chunks/PXT5YTWU.js +0 -1
  636. package/build/dist/chunks/QA3UHEO3.js +0 -1
  637. package/build/dist/chunks/QC3HH5UD.js +0 -3
  638. package/build/dist/chunks/QF52OIBS.js +0 -1
  639. package/build/dist/chunks/QO3KCJMP.js +0 -1
  640. package/build/dist/chunks/QZZ4O34L.js +0 -1
  641. package/build/dist/chunks/RQ4GHJXE.js +0 -1
  642. package/build/dist/chunks/RUX3RY7Y.js +0 -1
  643. package/build/dist/chunks/RVDUSNWW.js +0 -1
  644. package/build/dist/chunks/S7IFAQPG.js +0 -1
  645. package/build/dist/chunks/SIYUNOLI.js +0 -1
  646. package/build/dist/chunks/SSHCD6RZ.js +0 -18
  647. package/build/dist/chunks/T3AJSQYT.js +0 -1
  648. package/build/dist/chunks/TEJ7W534.js +0 -1
  649. package/build/dist/chunks/TM2XCRU7.js +0 -1
  650. package/build/dist/chunks/TVWMTMEF.js +0 -1
  651. package/build/dist/chunks/U5PMVP56.js +0 -1
  652. package/build/dist/chunks/U67J4BCH.js +0 -1
  653. package/build/dist/chunks/UHTRW2R6.js +0 -1
  654. package/build/dist/chunks/UHVSINR5.js +0 -1
  655. package/build/dist/chunks/VEQBHI6O.js +0 -1
  656. package/build/dist/chunks/VJS4DHQQ.js +0 -1
  657. package/build/dist/chunks/VOMGT5SG.js +0 -1
  658. package/build/dist/chunks/VY7XRHZQ.js +0 -1
  659. package/build/dist/chunks/VYAJXLND.js +0 -1
  660. package/build/dist/chunks/VYN2NRAP.js +0 -1
  661. package/build/dist/chunks/W2BYU5JQ.js +0 -2
  662. package/build/dist/chunks/W6BS3T7S.js +0 -1
  663. package/build/dist/chunks/WCNHZYQQ.js +0 -1
  664. package/build/dist/chunks/X2KFXCVD.js +0 -1
  665. package/build/dist/chunks/X3PQMS4N.js +0 -1
  666. package/build/dist/chunks/XBE3B6Y2.js +0 -1
  667. package/build/dist/chunks/XLOYBLFI.js +0 -1
  668. package/build/dist/chunks/XR7VK24E.js +0 -1
  669. package/build/dist/chunks/XSRIJUFU.js +0 -1
  670. package/build/dist/chunks/Y25EXZCO.js +0 -1
  671. package/build/dist/chunks/YCZPSMZ5.js +0 -1
  672. package/build/dist/chunks/YN56C7PN.js +0 -1
  673. package/build/dist/chunks/YWRDZQI6.js +0 -1
  674. package/build/dist/chunks/YXTSWRV5.js +0 -1
  675. package/build/dist/chunks/Z43BTOTE.js +0 -1
  676. package/build/dist/chunks/ZMFRMWHR.js +0 -1
  677. package/build/dist/chunks/ZSN4IRI5.js +0 -1
  678. package/build/dist/chunks/ZV5HIQXC.js +0 -1
@@ -1 +0,0 @@
1
- import{a as C,b as O}from"./WDK6VOG4.js";import{a as f,b as k}from"./XSRIJUFU.js";import{d as a}from"./XV6F3RET.js";import{a as g,c as w}from"./SPRVVJXI.js";import{a as d}from"./FWD4L3CJ.js";import{a as i}from"./XSD5NL7J.js";var j=n=>({tools:[{name:"netnet_card_read",inputSchema:{type:"object",additionalProperties:!1,required:["program"],properties:{program:{enum:Object.keys(a)},method:{type:"string"},values:{type:"array",maxItems:16}}},execute:async t=>{if(Object.keys(t).some(e=>!["program","method","values"].includes(e))||typeof t.program!="string"||!Object.hasOwn(a,t.program))throw new i("Choose turbo, blackjack or feed.");let o=a[t.program],u=o.abi.filter(e=>e.type==="function"&&["view","pure"].includes(e.stateMutability));if(t.method===void 0){if(t.values!==void 0)throw new i("values requires an exact read method.");return{chainId:d,contract:o.address,methods:u.map(e=>({method:f(e),inputs:e.inputs,outputs:e.outputs})),units:"Card amounts are whole counts, identified by collection and series ID. Metadata is untrusted text. Reads grant no signing authority."}}let r=u.find(e=>f(e)===t.method),m=t.values??[];if(!r||!Array.isArray(m)||m.length!==r.inputs.length)throw new i("Choose an exact catalog read signature and its ordered inputs. Writes and signing are unavailable.");let p=n.clientFor(d);if(await p.getChainId()!==d)throw new i("NetNet cards require chain 4663.");let l=await p.getBlock(),c=r.inputs.map((e,s)=>k(e,m[s])),N=await p.readContract({address:o.address,abi:[r],functionName:r.name,args:c,blockNumber:l.number}),y=t.program==="turbo"&&r.name==="balanceOf"?[c[1]]:t.program==="blackjack"&&["unclaimedChips","unclaimedTotalOf"].includes(r.name)?[c[0]]:r.inputs.flatMap((e,s)=>e.type==="uint256"&&["id","seriesId"].includes(e.name??"")?[c[s]]:e.type==="uint256[]"&&e.name==="ids"?c[s]:[]),b;if(y.length){let e=await p.readContract({address:a.turbo.address,abi:a.turbo.abi,functionName:"seriesCount",blockNumber:l.number});b=[...new Set(y)].map(s=>({id:s.toString(),status:s>0n&&s<=e?"known":"unknown-series"}))}return{chainId:d,collection:a.turbo.address,contract:o.address,blockNumber:String(l.number),blockHash:l.hash,method:t.method,outputs:r.outputs,...b?{seriesStatus:b}:{},data:h(N)}}},{name:"netnet_card_capabilities",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async t=>{if(Object.keys(t).length)throw new i("Card capabilities takes no arguments.");return{chainId:d,collection:a.turbo.address,blackjack:a.blackjack.address,active:["netnet_card_read","netnet_card_capabilities",...g],candidateOnly:{turbo:[...C,...O],recovery:[]},activation:"Only self-only finalize, expire and parked-chip claim are enabled, with local human confirmation and durable recovery. TURBO writes, seating, channel signatures and collection approvals remain disabled.",refused:w}}}]});function h(n,t=0){if(t>12)throw new i("Card read result exceeds the supported nesting.");if(typeof n=="bigint")return n.toString();if(typeof n=="string"){if(n.length>8194)throw new i("Card read result exceeds the supported length.");return/^0x[0-9a-f]*$/i.test(n)?n:`untrusted ${JSON.stringify(n)}`}if(Array.isArray(n)){if(n.length>4096)throw new i("Choose a bounded card read.");return n.map(o=>h(o,t+1))}return n&&typeof n=="object"?Object.fromEntries(Object.entries(n).map(([o,u])=>[o,h(u,t+1)])):n}export{j as a};
@@ -1 +0,0 @@
1
- import{a as fe}from"./TM2XCRU7.js";import{c as me}from"./MJ6WEWMI.js";import{a as Z}from"./L4N2RSK2.js";import{a as M,b as P}from"./3MLUCYCB.js";import{a as L}from"./U4JGEMKT.js";import{a as ue}from"./P4UQGWCP.js";import{a as x}from"./43LI5NKJ.js";import{b as de,c as le}from"./VEQBHI6O.js";import{a as re,b as X,c as j}from"./5HCXZWUH.js";import{l as ie,n as F,o as ce}from"./ABPL3ZZI.js";import{a as w,b as _,c as B,d as oe,i as E,j as ae,s as D}from"./FWD4L3CJ.js";import{a as k}from"./XSD5NL7J.js";import{a as p,b as V,c as se}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ne,encodeFunctionData as ve,erc20Abi as Y,getAddress as b,isAddress as G,parseAbi as te}from"viem";var z="https://api.robinhood.com/rhj/assets",Pe={address:M,symbol:"ETH",decimals:18,chainId:w},Q={address:b(ae),symbol:"USDG",decimals:oe,chainId:w},J={address:b(E[4663].tokens.WETH.address),symbol:"WETH",decimals:18,chainId:w},we={address:b(E[4663].meridian.CollateralToken_USDe.address),symbol:"USDe",decimals:18,chainId:w};function K(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function $(e,t=w,s={}){let n=Array.isArray(e)?e:K(e)&&Array.isArray(e.assets)?e.assets:void 0;if(!n)throw new k("Official stock asset list response is malformed.");let a=new Map,d=new Map;if(n.length>1e4)throw new k("Official stock asset list exceeds the lookup limit.");for(let o of n){if(!K(o))continue;let r=o;if(typeof r.tokenSymbol!="string"||!r.tokenSymbol.trim()||!Array.isArray(r.deployments))continue;if(r.deployments.length>100)throw new k("Official stock deployment list exceeds the lookup limit.");let l=r.tokenSymbol;if(!/^[A-Za-z0-9.$_-]{1,32}$/.test(l))throw new k(`Invalid official stock ticker ${p(l)}.`);if(r.tokenDecimals!==void 0&&(typeof r.tokenDecimals!="number"||!Number.isInteger(r.tokenDecimals)||r.tokenDecimals<0||r.tokenDecimals>255))throw new k("Official stock asset has invalid token decimals.");let u=typeof r.tokenDecimals=="number"&&Number.isInteger(r.tokenDecimals)&&r.tokenDecimals>=0&&r.tokenDecimals<=255?r.tokenDecimals:18;for(let m of r.deployments){if(!K(m))continue;let h=m;if(h.chainId!==t)continue;if(typeof h.contractAddress!="string"||!G(h.contractAddress,{strict:!1}))throw new k("Official stock deployment has an invalid contract address.");let y=b(h.contractAddress),f=y.toLowerCase(),g=l.toUpperCase(),i=d.get(g);if(!s.allowAmbiguousSymbols&&i&&i!==f)throw new k(`Ambiguous official stock ticker ${p(l)} across multiple addresses.`);let c=a.get(f);if(c&&(c.symbol!==l||c.decimals!==u))throw new k(`Conflicting official stock identity at ${y}.`);d.set(g,f),a.set(f,{address:y,symbol:l,decimals:u,chainId:t,...s.includeNames&&typeof r.tokenName=="string"&&r.tokenName.trim()?{name:r.tokenName.trim()}:{}})}}return[...a.values()]}function Ee(e,t){if(typeof e.address!="string"||!G(e.address,{strict:!1}))return!1;let s=e.chainId??w,n=e.address.toLowerCase();return t.some(a=>a.chainId===s&&a.address.toLowerCase()===n&&a.symbol===e.symbol)}function W(e,t){x(e.address);let s=e.chainId??w,n=b(e.address),a=n.toLowerCase(),d=O(e.symbol),o=t.find(l=>l.chainId===s&&l.address.toLowerCase()===a),r=t.find(l=>l.chainId===s&&O(l.symbol)===d);if(o){if(e.symbol!==o.symbol)throw new k(`Token at ${n} does not match official stock ticker ${p(o.symbol)} (received ${p(e.symbol)}).`);if(e.decimals!==void 0&&e.decimals!==o.decimals)throw new k(`Token ${p(o.symbol)} at ${n} does not match official decimals ${o.decimals}.`);return o}if(r)throw new k(`Token symbol ${p(e.symbol)} at ${n} does not match the official stock contract address ${r.address}.`);return{address:n,symbol:e.symbol.trim(),decimals:e.decimals??18,chainId:s}}var xe=["AAOI","AAPL","ABCL","ADBE","AEHR","AEIS","ALAB","AMAT","AMBA","AMC","AMD","AMKR","AMZN","ANET","APLD","APP","ASML","ASTS","AUR","AVAV","AVGO","AXON","AXTI","BA","BABA","BB","BE","BMNR","BND","BULL","CBRS","CCL","CEG","CELH","CIEN","CLOV","CLS","CLSK","COHR","COIN","COST","CRCL","CRDO","CRM","CRWD","CRWV","CSCO","CTSH","CVNA","DDOG","DELL","DIS","DJT","DOCN","ELF","EWT","EWY","F","FICO","FIG","FISV","FIX","FLNC","FLY","FTNT","FUTU","GDX","GE","GEV","GLD","GLW","GLXY","GME","GOOGL","HII","HIMS","HPE","HWM","IBM","IBRX","INDA","INFQ","INOD","INTC","INTU","IONQ","IREN","JBL","JNJ","JOBY","JPM","KLAC","KSS","KTOS","LHX","LITE","LLY","LMT","LRCX","LULU","LUNR","MCD","MDB","META","MOD","MPWR","MRNA","MRVL","MSFT","MSTR","MTSI","MU","MXL","NAVN","NBIS","NET","NFLX","NNE","NOW","NU","NVDA","NVTS","OKLO","ON","ONTO","ORCL","OUST","P","PANW","PATH","PENG","PFE","PL","PLTR","POET","POWL","PR","PWR","PYPL","QBTS","QCOM","QQQ","QUBT","RBLX","RCAT","RDDT","RDW","RGTI","RIVN","RKLB","RUN","SATS","SCHD","SGOV","SHOP","SHY","SIMO","SKHY","SLS","SLV","SMCI","SMH","SMR","SNAP","SNDK","SNOW","SOFI","SOUN","SOXX","SPCX","SPMO","SPY","TE","TEAM","TEM","TER","TSEM","TSLA","TSM","TTD","TTWO","UBER","UMC","UNH","UPS","USAR","USO","V","VICR","VRT","VSAT","VST","VTI","WDAY","WDC","WULF","WYFI","XLK","XNDU","XOM","ZETA","ZM","ZS"],q=new WeakMap,ke=new WeakMap,ge=3e4,he=Object.freeze([]),N;function nn(){if(!N)return he;let e=Date.now()-N.started;return e>=0&&e<ge?N.tokens:he}var ee=new WeakMap;function H(e,t){return(ee.get(e)??F)(t)}async function Ae(e){let t=e?.http??de(),s=e?.url??z,n=e?.chainId??w,a=j(t),d=ke.get(a);d||(d=new re(ge),ke.set(a,d));let{value:o,started:r}=await H(t,()=>d.read(`${n}:${s}`,async()=>{let u=await F(h=>le(a,s,{method:"GET",signal:h},y=>K(y)||Array.isArray(y))),m=$(u,n,{allowAmbiguousSymbols:!0});if(n===w&&m.length===0)throw new k("Official stock asset list has no mainnet deployments; retry when the list is available.");return u})),l=$(o,n,e);if(n===w&&s===z&&(!N||r>=N.started||Date.now()<N.started)&&(N={started:r,tokens:Object.freeze($(o,n,{allowAmbiguousSymbols:!0}).map(u=>Object.freeze(u)))}),n===w){let u=q.get(a);u||(u=new Set,q.set(a,u));for(let m of l)u.add(O(m.symbol))}return l}var Me=te(["function aggregate3((address target, bool allowFailure, bytes callData)[] calls) payable returns ((bool success, bytes returnData)[] returnData)"]);function ye(e){let t=e,s=new Set;for(;t&&typeof t=="object"&&!s.has(t)&&s.size<10;){s.add(t);let n=t;if(n.name==="ContractFunctionZeroDataError"||n.name==="AbiDecodingZeroDataError")return!0;let a=`${typeof n.shortMessage=="string"?n.shortMessage:""} ${typeof n.message=="string"?n.message:""}`;if(/returned no data \("0x"\)|Cannot decode zero data/i.test(a))return!0;t=n.cause}return!1}function Re(e){return e instanceof k?/RPC endpoint|too many requests|malformed JSON/i.test(e.message):e instanceof Error?/fetch failed|network|ECONNREFUSED|ETIMEDOUT|HTTP \d{3}|rate limit|too many requests/i.test(e.message):!1}async function Ue(e,t,s){if(typeof e.getCode=="function")try{let n=await e.getCode({address:t});return!n||n==="0x"}catch{return ye(s)}return ye(s)}async function Te(e,t,s){if(t.length===0)return[];let n=await Promise.allSettled(t.map(a=>e.readContract({address:a.address,abi:Y,functionName:"balanceOf",args:[s]})));if(n.every(a=>a.status==="rejected")&&n[0]?.status==="rejected"&&Re(n[0].reason))throw n[0].reason;return n.map(a=>{if(a.status!=="fulfilled"||a.value===void 0||a.value===null)return{ok:!1};try{let d=typeof a.value=="bigint"?a.value:BigInt(a.value);return d>=0n?{ok:!0,amount:d}:{ok:!1}}catch{return{ok:!1}}})}async function Se(e,t,s,n){if(s.length===0)return[];let a=ie(t,e);if(!a)return Te(e,s,n);let d=s.map(r=>({target:r.address,allowFailure:!0,callData:ve({abi:Y,functionName:"balanceOf",args:[n]})})),o;try{o=await e.readContract({address:a,abi:Me,functionName:"aggregate3",args:[d]})}catch(r){if(await Ue(e,a,r))return Te(e,s,n);throw r}if(!Array.isArray(o)||o.length!==s.length)throw new k("Multicall3 aggregate3 returned an invalid result list.");return o.map(r=>{let l=r,u=Array.isArray(l)?l[0]:l?.success,m=Array.isArray(l)?l[1]:l?.returnData;if(!u||typeof m!="string"||m==="0x")return{ok:!1};try{let h=Ne({abi:Y,functionName:"balanceOf",data:m}),y=typeof h=="bigint"?h:BigInt(h);return y>=0n?{ok:!0,amount:y}:{ok:!1}}catch{return{ok:!1}}})}async function tn(e,t={}){x(e);let s=b(e),n=t.chainId??w,a=t.client??ce(t.rpcUrl,n),d=[];if(t.stockTokens?d=[...t.stockTokens]:t.stockAssetsPayload!==void 0?d=$(t.stockAssetsPayload,n):t.includeStockTokens!==!1&&n!==_&&(d=await Ae({http:t.http,url:t.stockAssetsUrl,chainId:n})),t.tokens)for(let i of t.tokens)W(i,d);let o=n===w?[Q,J,we,...t.oakTokenAddress||process.env.OAK_TOKEN_ADDRESS?[{address:b(t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS),symbol:"OAK",decimals:B,chainId:n}]:[]]:n===_?[{...Q,address:b(D.testnet.usdg),chainId:n},{...J,address:b(D.testnet.weth),chainId:n},...t.oakTokenAddress?[{address:b(t.oakTokenAddress),symbol:"OAK",decimals:B,chainId:n}]:[]]:[],r=n===w&&t.includePoolTokens!==!1?ue.vaults.flatMap(i=>[{address:b(i.tokenAddress),symbol:b(i.tokenAddress),decimals:i.tokenDecimals,chainId:n},{address:b(i.earnContractAddress),symbol:b(i.earnContractAddress),decimals:18,chainId:n}]):[],l=new Set(r.map(i=>i.address.toLowerCase())),u=[],m=new Set;for(let i of[...o,...d,...t.tokens??[],...r]){if(i.chainId!==n||P(i.address)===M)continue;let c=W(i,d),T=c.address.toLowerCase();m.has(T)||(m.add(T),u.push(c))}let[h,y]=await Promise.all([a.getBalance({address:s}),Se(a,n,u,s)]),f=[],g={address:M,symbol:"ETH",decimals:18,chainId:n};(h>0n||t.includeZero)&&f.push({token:g,amount:h.toString()});for(let i=0;i<u.length;i++){let c=u[i],T=o.some(S=>C(S.address,c.address))||d.some(S=>C(S.address,c.address))?c.symbol:p(c.symbol),I=y[i]??{ok:!1};if(!I.ok){f.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:"unavailable"});continue}let A=I.amount;if(A>0n&&l.has(c.address.toLowerCase()))try{let[S,R]=await Promise.all([L(a,n,c.address,"symbol"),L(a,n,c.address,"decimals")]);T=p(S),c.decimals=R}catch{}(A>0n||t.includeZero)&&f.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:A.toString()})}return f}async function sn(e,t,s){if(x(e),t.length>1e4)throw new k("Journal token discovery exceeds the balance lookup limit.");let n=[...new Set(t.map(o=>(x(o),b(o))))].filter(o=>P(o)!==M).map(o=>({address:o,symbol:o,decimals:0,chainId:s.chainId})),a=await Se(s.client,s.chainId,n,b(e)),d=n.flatMap((o,r)=>{let l=a[r];return l.ok&&l.amount===0n?[]:[{token:o,amount:l.ok?l.amount.toString():"unavailable"}]});return Promise.all(d.map(async({token:o,amount:r})=>{let[l,u]=await Promise.all([L(s.client,s.chainId,o.address,"symbol").catch(()=>o.address),L(s.client,s.chainId,o.address,"decimals").catch(()=>{throw new k(`Token decimals are unavailable for journal-received token ${o.address}; retry balances when RPC metadata is available.`)})]);return{token:{...o,symbol:p(l),decimals:u},amount:r}}))}var C=(e,t)=>e.toLowerCase()===t.toLowerCase(),O=e=>se(e.normalize("NFKC")).toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");function Oe(e){let t=e.context.network??"mainnet",{chainId:s,usdg:n,weth:a}=D[t],d=(o,r,l)=>({...o,address:P(b(o.address)),name:r,kind:l,verified:!0,source:"Oak fixed addresses",warnings:[]});return[d({...Pe,chainId:s},"Ether","native"),d({...Q,address:n,chainId:s},"Global Dollar","stablecoin"),d({...J,address:a,chainId:s},"Wrapped Ether","wrapped"),...t==="mainnet"?[d(we,"USDe","stablecoin")]:[],...e.oakTokenAddress?[d({address:e.oakTokenAddress,symbol:"OAK",decimals:B,chainId:s},"Oak","oak")]:[]]}async function Ce(e){if(e.context.network==="testnet")return[];let t=e.officialStockTokens??await Ae({http:e.context.http,includeNames:!0,allowAmbiguousSymbols:!0});return t.filter(s=>Ee(s,t)).map(s=>({...s,name:s.name??s.symbol,kind:"official_stock",verified:!0,source:z,warnings:[]}))}async function ne(e,t,s=!0){let{chainId:n}=D[t.context.network??"mainnet"],a=t.context.clientFor(n);if(await a.getChainId()!==n)throw new k(`Token lookup requires Robinhood Chain ${n}.`);let[d,o,r]=await Promise.all([H(a,()=>L(a,n,e,"name",t.blockNumber)).catch(l=>{if(s)throw l;return""}),H(a,()=>L(a,n,e,"symbol",t.blockNumber)),H(a,()=>L(a,n,e,"decimals",t.blockNumber))]);if(typeof d!="string"||s&&!d.trim()||typeof o!="string"||!o.trim()||!Number.isInteger(r)||r<0||r>255)throw new k("The contract returned invalid token metadata.");return{address:b(e),name:d||o,symbol:o,decimals:r,chainId:n}}async function be(e,t){let s=await t.context.clientFor(w).readContract({address:E[w].clanker.factory.address,abi:te(["function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),functionName:"tokenDeploymentInfo",args:[e]});return Array.isArray(s)&&s.length===4&&typeof s[0]=="string"&&C(s[0],e)}async function _e(e,t){let s=t.context.clientFor(w),n=E[w].poolsTrade,a=[n.instantLaunchStrategyFeesOn.address,n.instantLaunchStrategyFeesOff.address],d=te(["event TokenLaunched(bytes32 indexed poolId,address indexed token,address indexed feeSplitter,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey)"])[0],o=await s.getBlockNumber(),r=new Set,l=0,u=0;for(let m=63127652n;m<=o;m+=10000000n){if(++l>Ie)throw new k("Token origin scan limit reached.");let h=m+9999999n>o?o:m+9999999n,y=await s.getLogs({address:a,event:d,args:{token:e},fromBlock:m,toBlock:h,strict:!0});for(let f of y){if(f.removed||!a.some(i=>C(i,f.address))||!f.args.token||!C(f.args.token,e)||!f.transactionHash||r.has(f.transactionHash))continue;if(r.add(f.transactionHash),++u>20)throw new k("Token origin receipt limit reached.");let g=await s.getTransactionReceipt({hash:f.transactionHash});if(fe(g).some(i=>C(i.token,e)))return b(g.from)}}}var Ie=5,Be=100,Fe=500,Ke=3e4;function Le(e){let t=Date.now()+Ke,s=0,n=new Map,a=o=>{let r=t-Date.now();if(r<=0)throw new k("Token lookup time budget reached; results are partial.");return F(o,Math.min(1e4,r))},d=X((o,r)=>a(async l=>{let u=await e.context.http(o,{...r,signal:l});return new Proxy(u,{get(m,h){if(h==="json")return()=>a(()=>m.json());let y=Reflect.get(m,h,m);return typeof y=="function"?y.bind(m):y}})}),e.context.http);return ee.set(d,a),{...e,context:{...e.context,http:d,clientFor:o=>{if(!n.has(o)){let r=e.context.clientFor(o),l=u=>{if(++s>Fe)throw new k("Token lookup RPC budget reached; results are partial.");return a(u)};n.set(o,X(new Proxy(r,{get(u,m){let h=Reflect.get(u,m);return typeof h!="function"?h:(...y)=>l(()=>h.apply(u,y))}}),r)),ee.set(n.get(o),l)}return n.get(o)}}}}function pe(e){return e.source==="Oak fixed addresses"?e:{...e,symbol:p(e.symbol),name:p(e.name)}}async function on(e,t){if(t=Le(t),typeof e!="string"||e.length>256||!O(e))throw new k("Provide a token name, symbol or address to find_token.");let s=O(e),n=G(e.trim(),{strict:!1})?P(b(e.trim())):void 0,{chainId:a}=D[t.context.network??"mainnet"],d=[],o=Oe(t),r=!1;try{o.push(...await Ce(t))}catch{r=!0,d.push("The official stock list is unavailable; results are partial and stock identities and lookalikes could not be checked.")}let l=i=>n?C(i.address,n):O(i.symbol).includes(s)||O(i.name).includes(s),u=o.filter(l),m=[],h=(i,c)=>[i.symbol,i.name??""].some(T=>[c.symbol,c.name].some(I=>{let A=O(T),S=O(I);return!!A&&!!S&&(A.includes(S)||S.includes(A))})),y=(i,c={})=>{if(m.some(A=>C(A.address,i.address)))return;let T=[`Token ${p(i.symbol)} at ${i.address} is an unverified ${c.launchpad?"launchpad token":"token"}. Use its address, not its name or symbol.`];(V(i.symbol)||V(i.name)||o.some(A=>!C(A.address,i.address)&&h(i,A)))&&T.push(`Lookalike warning: ${p(i.symbol)} at ${i.address} resembles a verified token's name or symbol.`);let I={...i,...c,kind:c.launchpad?"launchpad":"erc20",verified:!1,source:c.launchpad?`${c.launchpad} origin and on-chain metadata; not a verified token`:"On-chain metadata only",warnings:T};m.push(I),d.push(...T)};if(n&&!u.length){let i=await ne(n,t),c={};if(a===w){try{await be(n,t)&&(c.launchpad="clanker")}catch{d.push("Clanker origin lookup was unavailable for this address.")}if(c.launchpad==="clanker")try{let I=(await Z(t.context,{q:n,limit:20})).tokens.find(A=>C(A.contract_address,n));I&&(c.creator=b(I.msg_sender),c.creatorSource="Clanker indexer msg_sender")}catch{d.push("Clanker creator lookup is unavailable.")}else try{let T=await me(t.context,n);c.launchpad="pons",c.creator=b(T.creator),c.creatorSource="Pons factory deployer"}catch{d.push("Pons launch origin could not be confirmed for this address.")}if(!c.launchpad)try{let T=await _e(n,t);T&&(c.launchpad="pools.trade",c.creator=T,c.creatorSource="Launch transaction sender; may be a relayer")}catch{r=!0,d.push("pools.trade launch receipt lookup is unavailable; origin results are partial.")}}y(i,c)}else if(!n&&a===w){let i=new Set,c=new Set,T,I=0,A=0;try{do{if(++I>Ie)throw new k("Token search page limit reached.");let S=await Z(t.context,{q:e.trim(),limit:20,...T?{cursor:T}:{}});for(let R of S.tokens){if(++A>Be)throw new k("Token candidate limit reached.");let v=b(R.contract_address);if(!(c.has(v)||o.some(U=>C(U.address,v)))){c.add(v);try{let U=await ne(v,t);if(!l(U))continue;let De=await be(v,t)?{launchpad:"clanker",creator:b(R.msg_sender),creatorSource:"Clanker indexer msg_sender"}:{};y(U,De)}catch{r=!0,d.push(`Could not read Clanker candidate ${v}; it was omitted from these partial results.`)}}}if(S.cursor&&i.has(S.cursor))throw new k("The Clanker indexer repeated a pagination cursor.");S.cursor&&i.add(S.cursor),T=S.cursor??void 0}while(T)}catch{r=!0,d.push("Clanker name search is unavailable, incomplete or reached its scan limit; results are partial.")}d.push("Pons and pools.trade require a token address; name search does not cover those launchpads.")}a===_&&d.push("Testnet lookup covers pinned tokens and explicit token addresses; stock and launchpad discovery are unavailable.");let f=i=>[...new Map(i.map(c=>[c.address.toLowerCase(),c])).values()],g=f([...u,...m]);for(let i of g)if(g.some(c=>!C(c.address,i.address)&&(O(i.symbol)===O(c.symbol)||O(i.name)===O(c.name)))){let c=`Duplicate warning: several tokens share the symbol or name of ${i.address}. Choose the intended address; do not guess from the name.`;i.warnings.push(c),d.push(c)}return u.length>1&&d.push("Several verified tokens match this search, including possible substring matches. Choose an exact address; the search does not select a quote token."),{query:p(e.trim()),chainId:a,partial:r,matches:f(u).map(pe),unverified:f(m).map(pe),warnings:d}}async function an(e,t){if(typeof e!="string"||!e.trim())throw new k("Provide a token address or verified symbol; use find_token to look it up.");if(!/^[A-Za-z0-9.$_-]{1,42}$/.test(e))throw new k("Use an exact ASCII verified symbol or token address; use find_token to look it up.");let s=e,n=G(s,{strict:!1})?P(b(s)):void 0,a=Oe(t),d=n&&a.find(y=>C(y.address,n));if(d)return d;let o=s.toUpperCase()==="$OAK"?"OAK":s.toUpperCase(),r=!n&&a.find(y=>y.symbol.toUpperCase()===o),l=[],u=!1;try{l=await Ce(t)}catch{if(r)return r;if(!n)throw new k("The official stock list is unavailable; stock symbols cannot be checked. Use find_token and try again when the list is reachable.");u=!0}if(n){let y=l.find(i=>C(i.address,n));if(y)return t.tokenMetadata&&W(t.tokenMetadata,l),{...y,name:p(y.name)};let f=t.tokenMetadata??await t.readMetadata?.(n);if(f&&(!C(f.address,n)||f.chainId!==D[t.context.network??"mainnet"].chainId))throw new k("Token metadata does not match the requested address and chain.");if(f&&(typeof f.symbol!="string"||!f.symbol.trim()||!Number.isInteger(f.decimals)||f.decimals<0||f.decimals>255))throw new k("The contract returned invalid token metadata.");let g=f?{...f,name:f.symbol}:await ne(n,Le(t),!1);if(u){let i=O(g.symbol),c=q.get(j(t.context.http));if(xe.some(T=>O(T)===i)||c?.has(i))throw new k("The official stock list is unavailable; this address claims a stock ticker that cannot be checked. Try again when the list is reachable.")}return W(g,l),{...g,symbol:p(g.symbol),name:p(g.name),kind:"erc20",verified:!1,source:"On-chain metadata only",warnings:["This token address is unverified. On-chain names and symbols do not prove identity.",...u?["The official stock list is unavailable; stock identity could not be verified."]:[]]}}let m=[...a,...l].filter(y=>y.symbol.toUpperCase()===o);if(m.length!==1)throw new k(`Token symbol ${p(s)} is ${m.length?"ambiguous":"unverified"}; use find_token and choose an explicit address.`);let h=m[0];if(h.kind==="official_stock"&&s!==h.symbol)throw new k(`Use the exact official stock ticker ${p(h.symbol)}; case variants are refused.`);return h.source==="Oak fixed addresses"?h:{...h,name:p(h.name)}}export{z as a,Pe as b,Q as c,J as d,we as e,$ as f,Ee as g,W as h,nn as i,Ae as j,Me as k,tn as l,sn as m,on as n,an as o};
@@ -1 +0,0 @@
1
- import{a as b,b as w,e as R,f as N,g as S}from"./T2WHOZXM.js";import{a as h}from"./66F5ZH34.js";import{c as g,g as E}from"./NWNYJ26T.js";import{a as d}from"./FWD4L3CJ.js";import{a as r}from"./XSD5NL7J.js";import{encodeFunctionData as v,erc20Abi as I,getAddress as _,parseAbi as O,zeroAddress as C}from"viem";var k=_("0x2ac03e14cfe755426daaee0a4994184ce81482f8"),a=_("0x7a8f74c2585f84c781f951b7f2ff21337d5b630b"),o=O(["function RESOURCE() view returns (address)","function TOKEN_JAR() view returns (address)","function threshold() view returns (uint256)","function nonce() view returns (uint256)","function release(uint256 nonce,address[] assets,address recipient)"]),B={assets:{type:"array",minItems:1,maxItems:20,items:g},nonce:h(),maxResourceAmount:h()};function F(n){return{tools:[!1,!0].map(i=>({name:i?"uniswap_token_jar_release":"uniswap_token_jar",inputSchema:{type:"object",additionalProperties:!1,required:i?["assets","nonce","maxResourceAmount"]:["assets"],properties:B},async execute(t,m){if(S(t,i?["assets","nonce","maxResourceAmount"]:["assets"]),!Array.isArray(t.assets)||t.assets.length<1||t.assets.length>20)throw new r("Provide 1 to 20 unique assets to release.");let c=t.assets.map(w);if(new Set(c).size!==c.length)throw new r("Token Jar assets must be unique.");let s=n.clientFor(d),e=await s.getBlockNumber(),[x,P,u,f]=await Promise.all([s.readContract({address:a,abi:o,functionName:"RESOURCE",blockNumber:e}),s.readContract({address:a,abi:o,functionName:"TOKEN_JAR",blockNumber:e}),s.readContract({address:a,abi:o,functionName:"threshold",blockNumber:e}),s.readContract({address:a,abi:o,functionName:"nonce",blockNumber:e})]);if(!E(String(P),k)||x===C)throw new r("Releaser deployment does not match the pinned Token Jar and ERC-20 resource.");let p=await R(n,w(x),e),T=await Promise.all(c.map(async l=>({token:await R(n,l,e),amount:(l===C?await s.getBalance({address:k,blockNumber:e}):await s.readContract({address:l,abi:I,functionName:"balanceOf",args:[k],blockNumber:e})).toString()}))),y={payment:{token:p,amount:String(u)},nonce:String(f),assets:T,blockNumber:e.toString()};if(!i)return{...y,summary:"Resource payment buys the listed jar contents; no profit is promised. Release uses a nonce to refuse competing releases."};let J=b(t.maxResourceAmount,"maxResourceAmount"),A=b(t.nonce,"nonce",256,!0);if(A!==BigInt(f)||BigInt(u)>J)throw new r("Token Jar nonce or resource cost changed. Read uniswap_token_jar and confirm fresh terms.");let j=[n.approval(p.address,a,String(u),d),n.unsignedTx({to:a,data:v({abi:o,functionName:"release",args:[A,c,m]}),value:"0",chainId:d,description:`Pay ${u} base units of ${p.address} to release Token Jar assets to ${m}, nonce ${f}.`})];return{...await N(n,j,m,"Exchange resource tokens for Token Jar assets. Check the full payment, assets and recipient in the preview; gas is additional."),...y}}}))}}export{k as a,a as b,o as c,F as d};
@@ -1 +0,0 @@
1
- import{d as p}from"./M7U3A4EH.js";import{e as a}from"./NWNYJ26T.js";import{a as l}from"./XSD5NL7J.js";import{createHash as x}from"node:crypto";var c=32768,g="wormhole-x402@0.11.0/603aba277a626630d9b9463f713121dc4327325c";function w(s){if(!a(s)||Object.keys(s).length!==1||typeof s.text!="string")throw new l("Provide only text as a string for the local Wormhole scan.");let n=s.text,f=n.length>c||Buffer.byteLength(n,"utf8")>c,i={local:!0,scannerVersion:g,attribution:{provider:"Agent Wormhole",source:"https://github.com/runningoffcode/agent-wormhole"},limitation:"Evadable English instruction-shape rules. Allow is not proof of safety, intent, or coverage of unknown attacks."};if(f)return{...i,decision:"abstain",codes:[],findings:[],scannedPaths:[],charsScanned:0,inputHash:null,reason:"Text exceeds the 32768-byte local scan limit; no text was scanned or hashed."};let u=x("sha256").update(n,"utf8").digest("hex"),m={maxFieldChars:c,maxDecodeDepth:3,maxDepth:12},d=t=>{try{return p(t,m)}catch{return{decision:"abstain",findings:[],scanned:[],charsScanned:0}}},e=[{path:"text",verdict:d(n)}];try{let t=JSON.parse(n);(typeof t=="string"||a(t)||Array.isArray(t))&&e.push({path:"text.json",verdict:d(t)})}catch{}let r=e.flatMap(t=>t.verdict.findings.map(o=>({code:o.code,severity:o.severity,path:t.path,offset:o.offset}))),h=e.some(t=>t.verdict.decision==="refuse")?"refuse":e.some(t=>t.verdict.decision==="abstain")?"abstain":"allow";return{...i,decision:h,codes:[...new Set(r.map(t=>t.code))],findings:r.slice(0,64),findingsTruncated:r.length>64,scannedPaths:e.filter(t=>t.verdict.scanned.length).map(t=>t.path),charsScanned:e.reduce((t,o)=>t+o.verdict.charsScanned,0),inputHash:u,...h==="abstain"?{reason:"The local scanner could not cover all supplied text. Treat the result as unknown."}:{}}}export{c as a,g as b,w as c};
@@ -1 +0,0 @@
1
- import{a as q}from"./43LI5NKJ.js";import{a as j}from"./66F5ZH34.js";import{d as ne,f as te,g as v,i as oe}from"./NWNYJ26T.js";import{a as p,i as ee}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{a as U}from"./JXOEJPJ4.js";import{encodeFunctionData as W,encodePacked as ue,erc20Abi as V,getAddress as y,hashMessage as fe,keccak256 as pe,parseAbi as D,recoverMessageAddress as me,toHex as we,zeroAddress as _}from"viem";var g=y("0xE3535330a82867cD7b81C0d7e518f465D12dDd99"),A=y("0xf08c65564eb07d880021105489552080b08e4319"),re=y("0xc3e91d2d8a4145055c26c1174eb124ff3e3ed697"),ae=y("0x7c4726c6fb8eeb7b329ac037bbc71cc3153234b5"),le=y("0xa76c1d0bdcd94f16d5edd01c29483a2131d4c529"),C={address:y(ee[p].tokens.USDG.address),symbol:"USDG",decimals:6,chainId:p},N=D(["function acceptOffer((uint256 loanPrincipalAmount,uint256 maximumRepaymentAmount,uint256 nftCollateralId,address nftCollateralContract,uint32 loanDuration,uint16 loanAdminFeeInBasisPoints,address loanERC20Denomination,address referrer) offer,(uint256 nonce,uint256 expiry,address signer,bytes signature) signature,(address revenueSharePartner,uint16 referralFeeInBasisPoints) borrowerSettings) returns (uint32)","function payBackLoan(uint32 loanId)","function getPayoffAmount(uint32 loanId) view returns (uint256)","function loanIdToLoan(uint32 loanId) view returns (uint256 loanPrincipalAmount,uint256 maximumRepaymentAmount,uint256 nftCollateralId,address loanERC20Denomination,uint32 loanDuration,uint16 loanInterestRateForDurationInBasisPoints,uint16 loanAdminFeeInBasisPoints,address nftCollateralWrapper,uint64 loanStartTime,address nftCollateralContract,address borrower)","function loanRepaidOrLiquidated(uint32 loanId) view returns (bool)","function getWhetherNonceHasBeenUsedForUser(address user,uint256 nonce) view returns (bool)","function hub() view returns (address)","function paused() view returns (bool)","function maximumLoanDuration() view returns (uint256)","function adminFeeInBasisPoints() view returns (uint16)"]),J=D(["function ownerOf(uint256 tokenId) view returns (address)","function approve(address spender,uint256 tokenId)","function supportsInterface(bytes4) view returns (bool)"]),ge=D(["function getContract(bytes32) view returns (address)"]),be=D(["function getNFTWrapper(address) view returns (address)"]),M=["loanPrincipalAmount","maximumRepaymentAmount","nftCollateralId","nftCollateralContract","loanDuration","loanAdminFeeInBasisPoints","loanERC20Denomination","referrer"],Z=["nonce","expiry","signer","signature"],$=n=>te(n,"Provide the documented Longbow NFT object.");function F(n,d){if(Object.keys(n).some(i=>!d.includes(i)))throw new o("Unsupported Longbow NFT argument.")}function h(n,d=256){if(typeof n!="string"||!/^\d+$/.test(n)||n.length>78||BigInt(n)>=1n<<BigInt(d))throw new o(`NFT amounts and IDs must be uint${d} decimal strings.`);return BigInt(n)}function f(n){return oe(n,"Provide an NFT contract address.",ne)}var K=n=>{if(n>8640000000000n)throw new o("NFT deadline exceeds the supported timestamp range.");return new Date(Number(n)*1e3).toISOString()};function ie(n,d,i=!0){let s=$(n),e=$(d);F(s,M),F(e,Z);let t={loanPrincipalAmount:h(s.loanPrincipalAmount),maximumRepaymentAmount:h(s.maximumRepaymentAmount),nftCollateralId:h(s.nftCollateralId),nftCollateralContract:f(s.nftCollateralContract),loanDuration:Number(h(s.loanDuration,32)),loanAdminFeeInBasisPoints:Number(h(s.loanAdminFeeInBasisPoints,16)),loanERC20Denomination:f(s.loanERC20Denomination),referrer:f(s.referrer)};if(i&&(!v(t.nftCollateralContract,A)||!v(t.loanERC20Denomination,C.address)))throw new o("NFT borrowing supports only Robinhood Punks collateral and canonical USDG.");if(i&&(t.loanPrincipalAmount===0n||t.maximumRepaymentAmount<t.loanPrincipalAmount||t.loanDuration===0||t.referrer!==_))throw new o("NFT offer principal, payoff, duration or referrer is unsupported.");if(typeof e.signature!="string"||!/^0x(?:[0-9a-f]{2}){0,4096}$/i.test(e.signature))throw new o("Provide the existing lender\u2019s bounded hexadecimal offer signature; Oak does not sign lender offers.");let r={nonce:h(e.nonce),expiry:h(e.expiry),signer:f(e.signer),signature:e.signature};if(r.signer===_)throw new o("NFT lender cannot be the zero address.");return{offer:t,signature:r}}function he(n){let{offer:d,signature:i}=n;return pe(ue(["address","uint256","uint256","address","uint256","address","uint32","uint16","address","uint256","uint256","address","uint256"],[d.loanERC20Denomination,d.loanPrincipalAmount,d.maximumRepaymentAmount,d.nftCollateralContract,d.nftCollateralId,d.referrer,d.loanDuration,d.loanAdminFeeInBasisPoints,i.signer,i.nonce,i.expiry,g,BigInt(p)]))}function se(n,d){if(n.filter(s=>s.token.chainId===p&&v(s.token.address,C.address)).reduce((s,e)=>{if(e.token.decimals!==C.decimals||!/^-?\d+$/.test(e.amount))throw new o("Invalid NFT currency preview metadata.");return s+BigInt(e.amount)},0n)!==d)throw new o("NFT preview does not match the exact principal or payoff.")}async function de(n){let d=n.clientFor(p);if(await d.getChainId()!==p)throw new o("Longbow NFT loans require chain 4663.");let i=await d.getBlock(),s=(a,w,m,u=[])=>d.readContract({address:a,abi:w,functionName:m,args:u,blockNumber:i.number}),[e,t,r,l]=await Promise.all([s(g,N,"hub"),s(re,ge,"getContract",[we("PERMITTED_NFTS",{size:32})]),s(ae,be,"getNFTWrapper",[A]),s(A,J,"supportsInterface",["0x80ac58cd"])]);if(f(e)!==re||f(t)!==ae||f(r)!==le||l!==!0)throw new o("The NFT hub, collection interface or collateral wrapper changed. No action was built.");return{client:d,block:i,read:s}}async function G(n,d){let i=Number(h(d,32));if(i===0)throw new o("NFT loanId must be positive.");let s=n.clientFor(p);if(await s.getChainId()!==p)throw new o("Longbow NFT loan reads require chain 4663.");let e=await s.getBlock(),t=(T,I,E,b=[])=>s.readContract({address:T,abi:I,functionName:E,args:b,blockNumber:e.number}),[r,l,a]=await Promise.all([t(g,N,"loanIdToLoan",[i]),t(g,N,"loanRepaidOrLiquidated",[i]),t(g,N,"getPayoffAmount",[i])]);if(!Array.isArray(r)||r.length!==11||typeof l!="boolean")throw new o("Invalid NFT loan state.");let[w,m,u,c,z,,,R,S,B,O]=r;if(BigInt(S)===0n)throw new o("This NFT loan does not exist.");let L=f(c)===C.address&&f(B)===A&&f(R)===le&&f(O)!==_,x=C;if(f(c)!==C.address){let[T,I]=await Promise.all([t(f(c),V,"symbol"),t(f(c),V,"decimals")]);if(typeof I!="number"||!Number.isInteger(I)||I<0||I>255)throw new o("NFT loan currency decimals are unavailable.");x={address:f(c),symbol:typeof T=="string"&&/^[A-Za-z0-9$._ -]{1,32}$/.test(T)?T:"TOKEN",decimals:I,chainId:p}}if(typeof a!="bigint"||a!==BigInt(m)||a<BigInt(w))throw new o("NFT payoff does not match the fixed loan terms.");let P=BigInt(S)+BigInt(z);return{loanId:d,loanContract:g,chainId:p,blockNumber:e.number.toString(),collection:f(B),wrapper:f(R),tokenId:String(u),borrower:f(O),currency:x,supportedForActions:L,principalAmount:String(w),payoffAmount:a.toString(),startedAt:String(S),deadline:P.toString(),deadlineUtc:K(P),status:l?"repaid_or_liquidated":e.timestamp>P?"overdue":"active",repayable:!l&&e.timestamp<=P,warning:"After the on-chain deadline repayment is rejected; the lender can permanently take this NFT. Settled state alone does not distinguish repayment from liquidation."}}async function H(n,d){let i=await n.http(`https://longbow.credit/api/nft${d}`,{headers:{accept:"application/json"},signal:AbortSignal.timeout(1e4),redirect:"error"});if(!i.ok)throw new o("Longbow NFT discovery is unavailable. Retry the read; no loan was originated.");let s=await i.json();if(!Array.isArray(s)||s.length>1e3)throw new o("Longbow NFT discovery returned an invalid or oversized list.");return s.map($)}var ve=n=>{async function d(e,t,r){if(q(t),r){if(F(e,["loanId","maxPayoff"]),typeof e.loanId!="string")throw new o("NFT loanId must be a decimal string.");let b=await G(n,e.loanId);if(!b.supportedForActions)throw new o("This NFT loan is read-only in Oak; its collection, currency, wrapper or obligation-receipt borrower is not qualified for repayment.");let ce=h(e.maxPayoff);if(await de(n),b.borrower!==y(t))throw new o("Only this NFT loan\u2019s borrower may repay through Oak.");if(!b.repayable)throw new o("NFT loan is settled or overdue; repayment is unavailable.");let k=BigInt(b.payoffAmount);if(k>ce)throw new o("NFT payoff exceeds maxPayoff.");if(await n.clientFor(p).readContract({address:C.address,abi:V,functionName:"balanceOf",args:[t]})<k)throw new o(`NFT repayment needs ${k} USDG base units. Top up before the deadline ${b.deadlineUtc}.`);let Y=`Repay ${k} USDG base units to recover Robinhood Punks ${b.collection} token ID ${b.tokenId}; deadline ${b.deadlineUtc}.`,Q=[n.approval(C.address,g,k.toString(),p),n.unsignedTx({to:g,data:W({abi:N,functionName:"payBackLoan",args:[Number(b.loanId)]}),value:"0",chainId:p,description:Y})],X=await n.preview(Q,t);return se(X.changes,-k),{txs:Q,preview:X,summary:Y,requiresHumanConfirmation:!0}}F(e,["offer","lenderSignature"]);let l=ie(e.offer,e.lenderSignature),{offer:a,signature:w}=l,{client:m,block:u,read:c}=await de(n),[z,R,S,B,O]=await Promise.all([c(A,J,"ownerOf",[a.nftCollateralId]),c(g,N,"getWhetherNonceHasBeenUsedForUser",[w.signer,w.nonce]),c(g,N,"paused"),c(g,N,"maximumLoanDuration"),c(g,N,"adminFeeInBasisPoints")]);if(f(z)!==y(t))throw new o("This wallet does not own the offered NFT.");if(R!==!1||S!==!1||w.expiry<u.timestamp||BigInt(a.loanDuration)>BigInt(String(B))||a.loanAdminFeeInBasisPoints!==O)throw new o("NFT offer is used, expired, paused or inconsistent with current loan settings.");let L=he(l),x=!1;try{x=v(await me({message:{raw:L},signature:w.signature}),w.signer)}catch{}if(!x){let b=await m.getCode({address:w.signer,blockNumber:u.number});b&&b!=="0x"&&(x=await c(w.signer,D(["function isValidSignature(bytes32,bytes) view returns (bytes4)"]),"isValidSignature",[fe({raw:L}),w.signature])==="0x1626ba7e")}if(!x)throw new o("NFT offer signature does not match these terms, chain and loan contract.");let P=u.timestamp+BigInt(a.loanDuration),T=`Borrow ${a.loanPrincipalAmount} USDG base units; total payoff ${a.maximumRepaymentAmount} USDG base units. Escrow Robinhood Punks collection ${a.nftCollateralContract}, token ID ${a.nftCollateralId}. Estimated absolute repayment deadline ${K(P)} at snapshot ${u.number}; actual deadline is the mined start plus ${a.loanDuration} seconds. Read longbow_nft_loan after mining. Late repayment is rejected and you can permanently lose this NFT. Approve only this token ID to ${g}.`,I=[n.unsignedTx({to:A,data:W({abi:J,functionName:"approve",args:[g,a.nftCollateralId]}),value:"0",chainId:p,description:`Approve only Robinhood Punks token ID ${a.nftCollateralId} to the pinned loan contract.`}),n.unsignedTx({to:g,data:W({abi:N,functionName:"acceptOffer",args:[a,w,{revenueSharePartner:_,referralFeeInBasisPoints:0}]}),value:"0",chainId:p,description:T})],E=await n.preview(I,t);return se(E.changes,a.loanPrincipalAmount),{txs:I,preview:E,summary:T,requiresHumanConfirmation:!0,estimatedDeadlineUtc:K(P),deadlineIsEstimate:!0}}let i=(e,t,r,l)=>({name:e,inputSchema:{type:"object",properties:t,required:r,additionalProperties:!1},execute:async(a,w)=>{try{return await l(a,w)}catch(m){throw new o(n.plainError(m))}}});async function s(e){q(e);let t=(r,l)=>({module:"longbow",id:`4663:${g.toLowerCase()}:${r}`,chainId:p,incomplete:!0,assets:[],description:`Longbow borrower NFT loans unreadable: ${n.plainError(l)} Use longbow_nft_loans or longbow_nft_loan for a known loanId.`});try{let r=await H(n,`/loans/borrower/${y(e)}`);if(r.length>100)throw new o("NFT loan discovery exceeds 100 rows; read specific loan IDs with longbow_nft_loan.");let l=new Set,a=[];for(let[w,m]of r.entries()){let u=`unreadable-${w}`;try{if(m.loanContract!==void 0&&f(m.loanContract)!==g)throw new o("The NFT indexer returned a loan from another contract.");if(u=h(String(m.loanId??m.id),32).toString(),l.has(u))continue;l.add(u);let c=await G(n,u);if(c.borrower!==y(e))throw new o("The NFT indexer returned another borrower\u2019s loan.");if(c.status==="repaid_or_liquidated")continue;a.push({module:"longbow",id:`4663:${g.toLowerCase()}:${u}`,chainId:p,assets:[],description:`Longbow borrower NFT loan ${u}: ${c.status}, payoff debt ${c.payoffAmount} ${c.currency.symbol} base units (token ${c.currency.address}, decimals ${c.currency.decimals}); collateral ${c.collection} token ID ${c.tokenId} is escrowed. Deadline ${c.deadlineUtc}. ${c.repayable?"Use longbow_nft_repay before the deadline.":"Repayment is unavailable; the lender can permanently take the collateral."} Indexer discovery may be incomplete; lender interests are not included.`})}catch(c){a.push(t(u,c))}}return a}catch(r){return[t("unreadable",r)]}}return{positions:s,tools:[i("longbow_nft_listings",{},[],async e=>{F(e,[]);let t=await H(n,"/listings");return{chainId:p,source:"Longbow public order book; untrusted and potentially stale. No offer or execution is guaranteed.",listings:t.map(r=>{if(r.chainId!==p)throw new o("Longbow returned a listing on another chain.");return{id:U(String(r.id)),collection:f(r.nftContract??r.collection),tokenId:h(r.tokenId).toString(),borrower:f(r.borrower??r.owner),status:U(String(r.status)),note:r.note==null?null:U(String(r.note)).slice(0,512)}})}}),i("longbow_nft_offers",{listingId:{type:"string",maxLength:128}},["listingId"],async e=>{if(F(e,["listingId"]),typeof e.listingId!="string"||!/^[a-zA-Z0-9_-]{1,128}$/.test(e.listingId))throw new o("Provide the listingId returned by longbow_nft_listings.");let t=await H(n,`/listings/${encodeURIComponent(e.listingId)}/offers`);return{listingId:e.listingId,offers:t.map(r=>{let l=r.raw?$(r.raw):r,a={...$(l.offer??Object.fromEntries(M.map(m=>[m,l[m]])))};for(let m of["loanDuration","loanAdminFeeInBasisPoints"]){let u=a[m];typeof u=="number"&&Number.isSafeInteger(u)&&u>=0&&(a[m]=String(u))}let w=ie(a,typeof l.signature=="object"?l.signature:{nonce:l.nonce,expiry:l.expiry,signer:l.signer??l.lender,signature:l.signature},!1);return JSON.parse(JSON.stringify({id:String(r.id),...w},(m,u)=>typeof u=="bigint"||m==="loanDuration"||m==="loanAdminFeeInBasisPoints"?String(u):u))}),caveat:"These are lender-signed terms from an untrusted indexer. Accept rechecks ownership, wrapper, nonce, expiry and signature on chain. Empty offers do not imply a discovery failure."}}),i("longbow_nft_loan",{loanId:j()},["loanId"],async e=>{if(F(e,["loanId"]),typeof e.loanId!="string")throw new o("NFT loanId must be a decimal string.");return G(n,e.loanId)}),i("longbow_nft_loans",{role:{enum:["borrower","lender"]}},[],async(e,t)=>{F(e,["role"]),q(t);let r=e.role??"borrower";if(r!=="borrower"&&r!=="lender")throw new o("Choose borrower or lender NFT loan discovery.");let l=await H(n,`/loans/${r}/${y(t)}`);if(l.length>100)throw new o("NFT loan discovery exceeds 100 rows; read a specific loanId.");return{source:"Longbow indexer IDs, freshly checked on chain. Indexer completeness is not guaranteed.",loans:await Promise.all(l.map(a=>{if(a.loanContract!==void 0&&f(a.loanContract)!==g)throw new o("The NFT indexer returned a loan from another contract.");return G(n,String(a.loanId??a.id))}))}}),i("longbow_nft_accept_offer",{offer:{type:"object",properties:Object.fromEntries(M.map(e=>[e,{type:"string"}])),required:M,additionalProperties:!1},lenderSignature:{type:"object",properties:Object.fromEntries(Z.map(e=>[e,{type:"string"}])),required:Z,additionalProperties:!1}},["offer","lenderSignature"],(e,t)=>d(e,t,!1)),i("longbow_nft_repay",{loanId:j(),maxPayoff:j()},["loanId","maxPayoff"],(e,t)=>d(e,t,!0))]}};async function ke(n,d,i){if(await n.getChainId()!==p||i<0n||i>=1n<<256n)throw new o("NFT cleanup requires chain 4663 and the original token ID.");let s=D(["function ownerOf(uint256) view returns (address)","function getApproved(uint256) view returns (address)","function approve(address,uint256)"]),e=await n.readContract({address:A,abi:s,functionName:"ownerOf",args:[i]});if(!v(e,d))return;let t=await n.readContract({address:A,abi:s,functionName:"getApproved",args:[i]});if(v(t,g))return{to:A,data:W({abi:s,functionName:"approve",args:[_,i]}),value:"0",chainId:p,description:`Revoke only Robinhood Punks token ID ${i} approval to the Longbow loan contract.`}}export{g as a,A as b,re as c,ae as d,le as e,N as f,h as g,ie as h,he as i,G as j,ve as k,ke as l};
@@ -1 +0,0 @@
1
- import{d as R,e as z,g as V,h as S,k as I,l as k,m as W,n as X,t as E,u as Z,v as J,w as C,x as Q,y as ee,z as $}from"./N4Q6GN65.js";import{a as h,d as Y}from"./X5V2Z2NM.js";import{a as M}from"./43LI5NKJ.js";import{a as U}from"./66F5ZH34.js";import{c as _,e as K,g as p,h as G}from"./NWNYJ26T.js";import{a as l}from"./XSD5NL7J.js";import{a as B}from"./JXOEJPJ4.js";import{encodeFunctionData as P,hashTypedData as se,parseAbiItem as le,recoverTypedDataAddress as de,decodeFunctionData as ce}from"viem";import{isDeepStrictEqual as pe}from"node:util";var he={AgentWalletSet:[{name:"agentId",type:"uint256"},{name:"newWallet",type:"address"},{name:"owner",type:"address"},{name:"deadline",type:"uint256"}]},we=300n,q=240n,ge="0x1626ba7e";function L(t,c,s,g,v){let{chainId:b,registry:O}=S(t);return{domain:{name:"ERC8004IdentityRegistry",version:"1",chainId:b,verifyingContract:O},types:he,primaryType:"AgentWalletSet",message:{agentId:c.toString(),newWallet:s,owner:g,deadline:v.toString()}}}async function j(t){let c=await t.clientFor(S(t).chainId).getBlock();if(typeof c?.timestamp!="bigint")throw new l("The chain time is unavailable; nothing was built.");return c.timestamp}async function ue(t,c,s,g){try{let H=await de({...c,signature:g});if(p(H,s))return!0}catch{}let v=t.clientFor(S(t).chainId),b=await v.getCode({address:s});if(!b||b==="0x")return!1;let O=se(c);try{return await v.readContract({address:s,abi:Y,functionName:"isValidSignature",args:[O,g]})===ge}catch{return!1}}var te={transactionHash:{...z,description:"After local submission, repeat the same arguments with the mined hash: Oak verifies the exact calldata, the emitted event and the resulting registry state."}},N=(t,c)=>({type:"object",additionalProperties:!1,required:c,properties:{...t,...te}});async function D(t,c){let{chainId:s,registry:g}=S(t),v=await t.clientFor(s).readContract({address:g,abi:h,functionName:"ownerOf",args:[c]});return M(v),v}async function x(t,c,s){let{chainId:g,registry:v}=S(t),b=await t.clientFor(g).readContract({address:v,abi:h,functionName:s,args:[c]});return M(b),b}var Re=t=>{let{chainId:c,registry:s}=S(t),g=(a,r,e)=>({name:a,inputSchema:r,execute:async(n,o)=>{try{return M(o),X(t,n.chainId),await e(n,o)}catch(d){throw new l(t.plainError(d))}}}),v=g("erc8004_wallet_proof",{type:"object",additionalProperties:!1,required:["agentId","newWallet"],description:"Read-only: the exact EIP-712 AgentWalletSet message that newWallet must sign to become the agent's verified payment wallet. Nothing is signed or sent.",properties:{agentId:R,newWallet:{..._,description:"The wallet that will receive payments; it must sign."}}},async a=>{let r=k(a.agentId),e=W(a.newWallet,"newWallet");if(I(e))throw new l("To clear the payment wallet use erc8004_unset_wallet.");let[n,o]=await Promise.all([D(t,r),j(t)]),d=o+q;return{agentId:r.toString(),owner:n,newWallet:e,deadline:d.toString(),validForSeconds:Number(q),chainId:c,registry:s,typedData:L(t,r,e,n,d),next:"Have newWallet sign typedData (EIP-712, eth_signTypedData_v4; an ERC-1271 contract wallet returns its own signature). Never share a key. Then, from the agent owner or an approved operator, call erc8004_set_wallet with the same agentId, newWallet, deadline and the signature as walletSignature before the deadline. If newWallet is the Oak wallet, call erc8004_set_wallet without walletSignature and Oak signs locally.",note:"The owner field is the owner at this moment; a transfer before submission invalidates the signature. The registry rejects a deadline more than 5 minutes ahead."}}),b=g("erc8004_set_wallet",{type:"object",additionalProperties:!1,required:["agentId"],description:"Verify a payment wallet for the agent (setAgentWallet). The new wallet proves control with an EIP-712 signature. Omit walletSignature to sign locally with the Oak wallet when it is the new wallet.",properties:{agentId:R,newWallet:{..._,description:"Defaults to the Oak wallet."},deadline:U("Unix seconds from erc8004_wallet_proof; required with walletSignature."),walletSignature:{...V,description:"newWallet's EIP-712 signature of the erc8004_wallet_proof message."},continuation:{type:"object"},signature:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$"},...te}},async(a,r)=>{let e=k(a.agentId),n=a.newWallet===void 0?r:W(a.newWallet,"newWallet");if(I(n))throw new l("To clear the payment wallet use erc8004_unset_wallet.");let o=async w=>{let f=C(w,s,h,"MetadataSet"),T=await x(t,e,"getAgentWallet");if(f.metadataKey!=="agentWallet"||!G(f.metadataValue?.toString(),n)||!p(T,n))throw new l("The registry event or current payment wallet does not match the verified wallet.");return{agentId:e.toString(),agentWallet:T,verified:!0,summary:"The payment wallet is now the signed wallet."}},d=w=>{try{let f=ce({abi:h,data:w});return f.functionName==="setAgentWallet"&&f.args[0]===e&&p(f.args[1],n)}catch{return!1}};if(a.transactionHash!==void 0){let w=await J(t,a.transactionHash,r,d,s);return o(w)}let u=async(w,f,T)=>{let F=L(t,e,n,T,w);if(!await ue(t,F,n,f))throw new l("That signature is not a valid signature by newWallet for this exact agent, owner and deadline; nothing was built.");let A=await j(t);if(A>w)throw new l("The wallet proof has expired; request a fresh erc8004_wallet_proof.");if(w>A+we)throw new l("The deadline is more than 5 minutes ahead; the registry would revert. Request a fresh erc8004_wallet_proof.");let ie=P({abi:h,functionName:"setAgentWallet",args:[e,n,w,f]});return $(t,r,{},{to:s,data:ie,description:`Verify ${n} as the payment wallet of ERC-8004 agent ${e}.`,summary:`Sets the verified payment wallet of agent ${e} to ${n} (setAgentWallet; the wallet's own signature was checked locally). The wallet is cleared again by any NFT transfer. The signature expires at ${w}; confirm before then. Repeat the arguments with transactionHash to verify.`,authority:async()=>{},verify:o})};if(a.continuation===void 0){if(a.signature!==void 0)throw new l("A signature needs its continuation; start erc8004_set_wallet again.");let w=await E(t,e,r,"set the payment wallet");if(a.walletSignature!==void 0){if(typeof a.deadline!="string"||!/^[0-9]+$/.test(a.deadline))throw new l("Provide the deadline from erc8004_wallet_proof together with walletSignature.");return u(BigInt(a.deadline),a.walletSignature,w)}if(!p(n,r))throw new l(`The payment wallet must prove control. Call erc8004_wallet_proof for ${n}, have that wallet sign the returned typedData, then call erc8004_set_wallet again with deadline and walletSignature.`);let f=await j(t)+q,T=L(t,e,n,w,f);return{steps:[{kind:"typedData",request:T}],continuation:{stage:"wallet",wallet:r,chainId:c,agentId:e.toString(),newWallet:n,owner:w,deadline:f.toString(),request:T},summary:`Sign locally: the Oak wallet proves control of ${n} so it can become the verified payment wallet of ERC-8004 agent ${e}. It is an EIP-712 message to the agent registry; it moves no funds. Oak then builds the setAgentWallet transaction for confirmation. The proof expires in ${q} seconds.`}}let i=a.continuation;if(!K(i)||i.stage!=="wallet"||i.chainId!==c||typeof i.wallet!="string"||!p(i.wallet,r)||i.agentId!==e.toString()||typeof i.newWallet!="string"||!p(i.newWallet,r)||typeof i.owner!="string"||typeof i.deadline!="string"||!/^[0-9]+$/.test(i.deadline))throw new l("This payment-wallet continuation does not match the wallet, chain and agent; start erc8004_set_wallet again.");if(typeof a.signature!="string")throw new l("Provide this wallet's signature of the payment-wallet proof.");let m=await E(t,e,r,"set the payment wallet");if(!p(m,i.owner))throw new l("The agent changed owner while signing; start erc8004_set_wallet again.");let y=L(t,e,r,m,BigInt(i.deadline));if(!pe(y,i.request))throw new l("The signed request differs from the payment-wallet proof Oak built; nothing was sent.");return u(BigInt(i.deadline),a.signature,m)}),O=g("erc8004_unset_wallet",N({agentId:R},["agentId"]),async(a,r)=>{let e=k(a.agentId),n=P({abi:h,functionName:"unsetAgentWallet",args:[e]});return $(t,r,a,{to:s,data:n,description:`Clear the verified payment wallet of ERC-8004 agent ${e}.`,summary:`Clears the verified payment wallet of agent ${e} (unsetAgentWallet). Payers then have no registry-verified wallet until erc8004_set_wallet proves one. Repeat the arguments with transactionHash to verify.`,authority:()=>E(t,e,r,"clear the payment wallet"),verify:async o=>{let d=C(o,s,h,"MetadataSet"),u=await x(t,e,"getAgentWallet");if(d.metadataKey!=="agentWallet"||d.metadataValue!=="0x"||!I(u))throw new l("The registry event or current payment wallet does not show a cleared wallet.");return{agentId:e.toString(),agentWallet:u,cleared:!0}}})}),H=g("erc8004_transfer",N({agentId:R,to:{..._,description:"The new owner. The agent NFT, its profile and its on-chain history move with it."}},["agentId","to"]),async(a,r)=>{let e=k(a.agentId),n=W(a.to,"recipient");if(I(n)||p(n,s))throw new l("Choose a wallet that can own the agent, not the zero address or the registry.");let o=await D(t,e);if(p(o,n))throw new l("That wallet already owns this agent.");let d=P({abi:h,functionName:"safeTransferFrom",args:[o,n,e]});return $(t,r,a,{to:s,data:d,description:`Transfer ERC-8004 agent ${e} from ${o} to ${n}.`,summary:`Transfers ownership of agent ${e} to ${n} (ERC-721 safeTransferFrom). This clears its verified payment wallet and token approval, ends Oak access linked to the current owner, and the new owner must run oak setup link and re-verify a payment wallet. Operators approved for all agents keep that approval. Repeat the arguments with transactionHash to verify.`,authority:()=>E(t,e,r,"transfer this agent"),verify:async u=>{let i=C(u,s,h,"Transfer"),[m,y]=await Promise.all([D(t,e),x(t,e,"getAgentWallet")]);if(!p(String(i.from),o)||!p(String(i.to),n)||i.tokenId!==e||!p(m,n))throw new l("The registry event or current owner does not match the transfer.");return{agentId:e.toString(),owner:m,previousOwner:o,agentWallet:y,transferred:!0,next:"The new owner links Oak with oak setup link and verifies a payment wallet again."}}})}),ae=g("erc8004_approve",N({agentId:R,operator:{..._,description:"The single address allowed to manage and transfer this one agent."},clear:{type:"boolean",description:"Remove the approval for this agent instead."}},["agentId"]),async(a,r)=>{let e=k(a.agentId),n=a.clear===!0;if(n===(a.operator!==void 0))throw new l("Provide operator to approve, or clear:true to remove the approval, not both.");let o=n?"0x0000000000000000000000000000000000000000":W(a.operator,"operator");if(!n&&I(o))throw new l("Use clear:true to remove an approval.");let d=await D(t,e);if(!n&&p(o,d))throw new l("The owner does not need an approval.");let u=P({abi:h,functionName:"approve",args:[o,e]});return $(t,r,a,{to:s,data:u,description:n?`Remove the approved operator of ERC-8004 agent ${e}.`:`Approve ${o} to manage ERC-8004 agent ${e}.`,summary:n?`Removes the single-agent approval on agent ${e}. Repeat with transactionHash to verify.`:`Lets ${o} update agent ${e}'s profile and metadata, set its payment wallet, request validations for it and TRANSFER it (ERC-721 approve). A transfer or another approve clears it. Repeat with transactionHash to verify.`,authority:()=>Z(t,e,r),verify:async i=>{let m=C(i,s,h,"Approval"),y=await x(t,e,"getApproved");if(m.tokenId!==e||!p(String(m.approved),o)||!p(y,o))throw new l("The registry event or current approval does not match.");return{agentId:e.toString(),approved:I(y)?null:y,owner:m.owner}}})}),ne=g("erc8004_set_operator",N({operator:_,approved:{type:"boolean",description:"true grants, false revokes."}},["operator","approved"]),async(a,r)=>{let e=W(a.operator,"operator");if(typeof a.approved!="boolean")throw new l("approved must be true or false.");if(I(e)||p(e,r))throw new l("Choose another wallet as the operator.");let n=P({abi:h,functionName:"setApprovalForAll",args:[e,a.approved]});return $(t,r,a,{to:s,data:n,description:`${a.approved?"Approve":"Revoke"} ${e} as operator for all this wallet's ERC-8004 agents.`,summary:a.approved?`Gives ${e} control of EVERY ERC-8004 agent this wallet owns now or later: profile and metadata edits, payment wallet, validation requests and TRANSFER of the NFTs (ERC-721 setApprovalForAll). Revoke with approved:false. Repeat with transactionHash to verify.`:`Revokes ${e}'s control of all agents this wallet owns. Repeat with transactionHash to verify.`,authority:async()=>{},verify:async o=>{let d=C(o,s,h,"ApprovalForAll"),u=await t.clientFor(c).readContract({address:s,abi:h,functionName:"isApprovedForAll",args:[r,e]});if(!p(String(d.owner),r)||!p(String(d.operator),e)||d.approved!==a.approved||u!==a.approved)throw new l("The registry event or current operator approval does not match.");return{owner:r,operator:e,approved:u}}})}),re=g("erc8004_set_metadata",N({agentId:R,key:{type:"string",minLength:1,maxLength:128,description:"Onchain metadata key. agentWallet is reserved."},value:{...V,description:"0x hex bytes; provide this or text."},text:{type:"string",description:"UTF-8 text stored as bytes; provide this or value."}},["agentId","key"]),async(a,r)=>{let e=k(a.agentId),n=Q(a.key),o=ee(a),d=P({abi:h,functionName:"setMetadata",args:[e,n,o]});return $(t,r,a,{to:s,data:d,description:`Set onchain metadata ${n} on ERC-8004 agent ${e}.`,summary:`Publishes ${(o.length-2)/2} bytes under the key ${B(n)} on agent ${e}. Onchain metadata is public, mutable and self-asserted. Repeat with transactionHash to verify.`,authority:()=>E(t,e,r,"set metadata"),verify:async u=>{let i=C(u,s,h,"MetadataSet"),m=await t.clientFor(c).readContract({address:s,abi:h,functionName:"getMetadata",args:[e,n]});if(i.agentId!==e||i.metadataKey!==n||i.metadataValue!==o||m!==o)throw new l("The registry event or current metadata does not match.");return{agentId:e.toString(),key:B(n),value:o,confirmed:!0}}})}),oe=g("erc8004_owned",{type:"object",additionalProperties:!1,description:"Read-only: the agent IDs a wallet owns on the registry (it is not enumerable, so this scans incoming Transfer logs and confirms each with ownerOf).",properties:{owner:{..._,description:"Defaults to the Oak wallet."},limit:{type:"integer",minimum:1,maximum:50,default:25}}},async(a,r)=>{let e=a.owner===void 0?r:W(a.owner,"owner"),n=typeof a.limit=="number"?Math.min(Math.max(1,Math.trunc(a.limit)),50):25,o=t.clientFor(c),d=await o.readContract({address:s,abi:h,functionName:"balanceOf",args:[e]});if(typeof d!="bigint")throw new l("Registry balance is unavailable.");if(d===0n)return{owner:e,balance:"0",agents:[],complete:!0};let u=d<BigInt(n)?Number(d):n,i=[],m=new Set,y=await o.getBlockNumber({cacheTime:0});for(let w=0;w<40&&i.length<u;w++){let f=y>9999999n?y-9999999n:0n,T=await o.getLogs({address:s,event:le("event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"),args:{to:e},fromBlock:f,toBlock:y,strict:!0});for(let F of[...T].reverse()){let A=F.args.tokenId.toString();if(!(F.removed||m.has(A))&&(m.add(A),p(await D(t,BigInt(A)),e)&&i.push(A),i.length>=u))break}if(f===0n)break;y=f-1n}return{owner:e,balance:d.toString(),agents:i,complete:i.length===Number(d),note:i.length<Number(d)?"More agents exist than were listed (limit or scan budget); raise limit or look up a known ID with erc8004_identity.":void 0}});return{tools:[v,b,O,H,ae,ne,re,oe]}};export{we as a,L as b,Re as c};
@@ -1 +0,0 @@
1
- import{h as l}from"./NWNYJ26T.js";import{a as i}from"./XSD5NL7J.js";async function m(a,e,t,r){let n=`OAK_RPC_URL_${e}`;try{let s=a(e);if(await s.getChainId()!==e)throw new Error("Wrong chain");let o=await s.request({method:"debug_traceCall",params:[{from:t,to:t,data:"0x",value:"0x0",gas:"0x5208"},"latest",{tracer:"callTracer"}]});if(o?.type!=="CALL"||!l(o.to,t)||o.error)throw new Error("Invalid trace")}catch{throw new i(`Relay return path is unavailable on the ${r} for chain ${e}. Set ${n} in both the Oak server and local add-on environments to an RPC for chain ${e} that supports debug_traceCall with callTracer, then restart both and retry bridge-out. Nothing was submitted.`)}return`Relay return path checked on the ${r}: chain ${e} RPC and debug_traceCall with callTracer are available. This checks setup now; it does not guarantee future RPC availability or Relay settlement. Keep destination ETH for return gas.`}var h=500;function d(a,e){let t=BigInt(a),r=BigInt(e),n=((t-r)*10000n+t-1n)/t;return new i(`Relay order minimum is below the allowed slippage minimum. This quote needs slippageBps at least ${n} (maximum 9999), or explicit minAmountOut "${e}". Review that minimum before retrying; a new quote alone may have the same floor.`)}export{m as a,h as b,d as c};
@@ -1,3 +0,0 @@
1
- import{a as v}from"./VHV6WQ5F.js";import{$ as M,_ as P,ca as x}from"./6PBGEPUK.js";import{g as A,i as B,m as _,n as q}from"./NWNYJ26T.js";import{a as p}from"./FWD4L3CJ.js";import{a as n}from"./XSD5NL7J.js";import{encodeFunctionData as D}from"viem";var H={asset:{type:"string",pattern:"^[A-Za-z0-9.$_-]{1,32}$",description:"Official asset symbol; use vault if discovery is unavailable or ambiguous."},vault:{type:"string",pattern:"^0x[0-9a-fA-F]{40}$",description:"Vault address verified on chain on every call; required for a rebuild without HTTP."}};function R(i){return{type:"object",additionalProperties:!1,properties:{...H,amount:{type:"string",pattern:i==="withdraw"?"^(?:[0-9]+|max)$":"^[0-9]+$"}},required:["amount"],anyOf:[{required:["asset"]},{required:["vault"]}]}}function O(i){return q(i,"Borro amount must be positive and fit uint256.",{positive:!0,notString:"Borro amount must be an integer string in asset base units."})}function g(i){return _(i,"Borro returned an invalid uint256 read.")}var U=i=>i*9950n/10000n;function z(i,l,h,d,N){let S=0n,m=0n;for(let y of i.changes){let b=y.token;if(typeof y.amount!="string"||!/^-?\d+$/.test(y.amount))throw new n("Borro preview returned invalid token changes. Nothing was signed.");let e=BigInt(y.amount);g(e<0n?-e:e);let o=A(b.address,l.address)?l:A(b.address,d.address)?d:void 0;if(!o||b.chainId!==p||b.decimals!==o.decimals)throw new n("Borro preview showed an unexpected token movement. Nothing was signed.");if(o===l){if(e>0n)throw new n("Borro preview showed a reversed input movement. Nothing was signed.");S-=e}else{if(e<0n)throw new n("Borro preview showed a reversed output movement. Nothing was signed.");m+=e}}if(g(S),g(m),S!==h||m<N||m===0n)throw new n("Borro preview did not match the requested receipt. Nothing was signed.")}var J=i=>{let{client:l,context:h,wallet:d}=i;async function N(e,o,a){if(B(a,"Provide a valid wallet address."),!A(a,d))throw new n("Borro action wallet differs from the signing wallet. Nothing was signed.");if(h.network==="testnet"||await l.getChainId()!==p)throw new n("Borro requires chain 4663. Nothing was signed.");if(Object.keys(e).some(r=>!["asset","vault","amount"].includes(r)))throw new n("Unsupported Borro argument.");if(e.asset!==void 0&&(typeof e.asset!="string"||!/^[A-Za-z0-9.$_-]{1,32}$/.test(e.asset)||/^0x/i.test(e.asset)))throw new n("Provide an asset symbol, or put the vault address in vault.");let w=e.vault===void 0?void 0:B(e.vault,"Provide a valid Borro vault address.");if(!w&&e.asset===void 0)throw new n("Provide an asset symbol or a vault address.");let t=w?await i.verifyVault(l,w,o,{wallet:d}):await i.resolveVault(l,{asset:e.asset},o,d);if(w&&!A(w,t.vault)||e.asset!==void 0&&e.asset.toUpperCase()!==t.symbol.toUpperCase())throw new n("Borro vault and asset selectors do not match. Nothing was signed.");if(B(t.vault,"Borro returned an invalid vault address."),B(t.asset,"Borro returned an invalid asset address."),t.chainId!==p||t.shareDecimals!==18||A(t.asset,t.vault)||!Number.isInteger(t.assetDecimals)||t.assetDecimals<0||t.assetDecimals>255||t.mode!==o)throw new n(x("setup-mismatch",{}));let s=await i.verifySetup(l,t,o);if(!s.ok||o==="deposit"&&(!t.assetAllowed||s.drift.length>0))throw new n(x("setup-mismatch",{}));return{...t,setup:s}}function S(e){let o=e.mode==="withdraw"&&!/^[A-Za-z0-9.$_-]{1,16}$/.test(e.symbol)?"token":e.symbol;return{asset:{address:B(e.asset,"Borro returned an invalid asset."),symbol:o,decimals:e.assetDecimals,chainId:p},share:{address:B(e.vault,"Borro returned an invalid vault."),symbol:e.vaultSymbol,decimals:18,chainId:p}}}let m=(e,o)=>h.formatAmount(e.toString(),o),y="The minimum is checked in the preview; standard ERC-4626 calldata does not enforce it on chain. Re-preview before signing; execution output can change.",b=[{name:"borro_deposit",inputSchema:R("deposit"),execute:async(e,o)=>{let a=O(e.amount),w=await N(e,"deposit",o),{asset:t,share:s}=S(w),r=g(await l.readContract({address:t.address,abi:v,functionName:"balanceOf",args:[d]}));if(a>r)throw new n("This wallet does not hold enough of that asset for the Borro deposit.");let f=g(await l.readContract({address:s.address,abi:v,functionName:"previewDeposit",args:[a]}));if(f===0n)throw new n(x("deposit-would-revert",{}));let u=U(f),c=[h.approval(t.address,s.address,a.toString(),p),h.unsignedTx({to:s.address,data:D({abi:v,functionName:"deposit",args:[a,d]}),value:"0",chainId:p,description:`Deposit ${a} asset base units into Borro vault ${s.address}.`})],$;try{$=await h.preview(c,d),z($,t,a,s,u)}catch{throw new n(x("deposit-would-revert",{}))}let T=w.deployedAt===void 0?void 0:Date.parse(w.deployedAt)/1e3,k=P({amount:m(a,t.decimals),symbol:t.symbol,kind:t.symbol==="USDG"?"usdg":"stock",shares:m(f,18),sharesMin:m(u,18),vaultSymbol:s.symbol,deployedAtSeconds:T,nowSeconds:Math.floor(Date.now()/1e3)});return{txs:c,preview:$,vault:s.address,asset:t,shareToken:s,amount:a.toString(),shares:f.toString(),shares_min:u.toString(),summary:`${k}
2
- Base units: amount ${a} (${t.address}, decimals ${t.decimals}); shares ${f} (${s.address}, decimals 18); shares_min ${u}. ${y}`}}},{name:"borro_withdraw",inputSchema:R("withdraw"),execute:async(e,o)=>{let a=e.amount==="max",w=a?void 0:O(e.amount),t=await N(e,"withdraw",o),{asset:s,share:r}=S(t),f=g(await l.readContract({address:r.address,abi:v,functionName:"balanceOf",args:[d]}));if(f===0n)throw new n(x("no-shares",{symbol:s.symbol}));let u=a?f:g(await l.readContract({address:r.address,abi:v,functionName:"previewWithdraw",args:[w]}));if(u===0n||u>f)throw new n("This wallet does not hold enough Borro shares for that withdrawal.");let c=w??g(await l.readContract({address:r.address,abi:v,functionName:"previewRedeem",args:[u]}));if(c===0n)throw new n("Borro preview returned no assets for these shares. Nothing was signed.");let $=await i.readLiquidity(l,t).catch(()=>({kind:"unknown"})),T=$.kind!=="unknown"&&"readyBase"in $?$.readyBase:void 0,k=typeof T=="bigint"&&T>=0n&&T<1n<<256n?T:void 0;if(k!==void 0&&k<c)return{txs:[],vault:r.address,asset:s,shareToken:r,amount:c.toString(),shares:u.toString(),max_now:k.toString(),summary:x("too-little-ready",{ready:m(k,s.decimals),requested:m(c,s.decimals),maxNow:m(k,s.decimals),symbol:s.symbol})};let C=a?U(c):c,V=[h.unsignedTx({to:r.address,data:a?D({abi:v,functionName:"redeem",args:[u,d,d]}):D({abi:v,functionName:"withdraw",args:[c,d,d]}),value:"0",chainId:p,description:`Withdraw ${c} asset base units from Borro vault ${r.address} for ${u} share base units.`})],I=await h.preview(V,d);z(I,r,u,s,C);let E=M({amount:m(c,s.decimals),isAll:a,symbol:s.symbol,out:m(c,s.decimals),shares:m(u,18),vaultSymbol:r.symbol,drift:t.setup.drift.length>0});return{txs:V,preview:I,vault:r.address,asset:s,shareToken:r,amount:c.toString(),shares:u.toString(),assets_min:C.toString(),isMax:a,setup:t.setup,summary:`${E}
3
- Base units: amount ${c} (${s.address}, decimals ${s.decimals}); shares ${u} (${r.address}, decimals 18); assets_min ${C}. ${y}`}}}];for(let e of b){let o=e.execute;e.execute=async(a,w)=>{try{return await o(a,w)}catch(t){throw new n(h.plainError(t))}}}return b};export{J as a};
@@ -1 +0,0 @@
1
- import{a,b as o,d as r}from"./BBS3ODWZ.js";import{c as s}from"./DJN3JAWB.js";import{a as t}from"./FWD4L3CJ.js";var i=[{feature:"Ethos claim",source:"https://go.priors.trade/start-ethos.js",missing:"Public claim endpoint signs/sends the sponsor transaction remotely. No unsigned final transaction with a local preview/confirmation handoff is published. Use the owner Go Start workflow; Oak offers status and route discovery."},{feature:"x402 pay_url, paid reports, hire payments and pay_gateway",source:"https://github.com/priors-agents/priors/tree/02230282d8888e00794207ed271ee01b4ce30309/packages/x402",missing:"These hand EIP-3009 payment authorization to an external merchant/facilitator. The recipient settles remotely; no Oak-local unsigned transaction handoff is exposed. Oak discovery is supported; external payment-signature validation, recipient/invoice binding and preview semantics require a shared add-on protocol, beyond this module write scope. Gateway source also says its live 402 surface was not measured."},{feature:"Go Google/Privy account, gas sponsorship, recovery and agent001 approvals",source:"https://go.priors.trade/account",missing:"Authenticated smart-account/session and sponsored-operation APIs are not publicly specified as an unsigned plain-wallet contract. Owner uses Priors UI. Underlying pool, stock, savings and backing contracts are supported here."},{feature:"Publish merchant listings, job offers/results, board requests and signed public offers",source:"https://priors.trade/agent",missing:"Hosted MCP supplies discovery and signed board reads. A versioned authenticated mutation/withdrawal contract is not pinned from the inspected public SDK. Existing owner consent plus direct sponsor offer is supported on chain; creating external listings/messages remains an owner workflow."},{feature:"Create the X proof post",source:"https://go.priors.trade/xlink-core.js",missing:"Requires the human account owner to publish on X. Oak can set or clear the canonical proof URL as public ERC-8004 metadata, but does not publish posts or claim metadata alone verifies X ownership."}];function p(){return{tools:[{name:"priors_capabilities",inputSchema:{type:"object",properties:{},additionalProperties:!1},async execute(){return{chainId:t,sourceCommit:"02230282d8888e00794207ed271ee01b4ce30309",reads:[...a],actions:[...r],localOwnerSignatures:[...o],ownerOnly:s.filter(e=>e.owner).map(e=>e.name),blocked:i.map(e=>({...e,status:"BLOCKED"})),integration:"The shared bridge/server diffs must be integrated for open reads, local signing continuations, exact calldata reconstruction, action destinations and human confirmation. New core builders fail closed in older add-ons; a core-only install does not establish end-to-end feature availability.",safety:"Every local action previews its exact unsigned transaction bundle. Approvals equal inputs or explicit finite future budgets; never unlimited. Persistent autopay and bids authorize later third-party execution within the stated budget. Token backing is collateral and provides no promised returns."}}}]}}export{i as a,p as b};
@@ -1 +0,0 @@
1
- import{d as a}from"./WDK6VOG4.js";import{a as i}from"./SPRVVJXI.js";import{a as o}from"./FWD4L3CJ.js";var d=n=>({tools:i.map(e=>{let t=e==="netnet_blackjack_claim"?"seriesId":"sessionId";return{name:e,inputSchema:{description:"Self-only recovery on chain 4663, available without an active identity or subscription; every action requires local human confirmation. Card counts use whole units.",type:"object",additionalProperties:!1,required:[t],properties:{[t]:{type:"string",pattern:"^[1-9][0-9]{0,77}$"}}},execute:async(s,c)=>{let r=await a(e,s,c,n.clientFor(o));return{txs:r.txs,summary:r.decision}}}})});export{d as a};
@@ -1 +0,0 @@
1
- import{b as Y,e as Z}from"./Y25EXZCO.js";import{a as U,b as L,c as D,d as G,e as _,f as W,g as J}from"./T2WHOZXM.js";import{d as C,e as $,v as H}from"./GEIFITAQ.js";import{a as K}from"./IOYRL6AY.js";import{a as S}from"./66F5ZH34.js";import{c as h,g as Q}from"./NWNYJ26T.js";import{a as I,i as T}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as b,encodeFunctionData as ee,encodePacked as de,erc20Abi as me,getAddress as ue,parseAbi as N,parseAbiParameters as A,zeroAddress as v}from"viem";var te=ue("0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7"),ne=ue(T[4663].ponsTrade.quoter.address),fe=N(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),le=N(["function approve(address token,address spender,uint160 amount,uint48 expiration)"]),oe=N(["function factory() view returns (address)","function quoteExactInput(bytes path,uint256 amountIn) returns (uint256,uint160[],uint32[],uint256)","function quoteExactOutput(bytes path,uint256 amountOut) returns (uint256,uint160[],uint32[],uint256)"]),F="(address intermediateCurrency,uint24 fee,int24 tickSpacing,address hooks,bytes hookData)",M="(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)",re=N([`function quoteExactInput((address exactCurrency,${F}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactOutput((address exactCurrency,${F}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactInputSingle((${M} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`,`function quoteExactOutputSingle((${M} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`]),ye=A(`(address exactCurrency,${F}[] path,uint256[] minHopPriceX36,uint128 amount,uint128 limit)`);function he(u,t,r,d){let a=[],e=d?r:t,i=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||i.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,i.add(e)}if(e!==(d?t:r))throw new o("V4 route does not end at the requested currency.");return a}var xe=A(`(${M} poolKey,bool zeroForOne,uint128 amount,uint128 limit,uint256 minHopPriceX36,bytes hookData)`),be=A("address recipient,uint256 amount,uint256 limit,bytes path,bool payerIsUser,uint256[] minHopPriceX36"),we=A("address recipient,uint256 amount,uint256 limit,address[] path,bool payerIsUser,uint256[] minHopPriceX36"),ie=A("address,uint256"),ve=A("bytes,bytes[]");function Ae(u,t,r){let d=r?[...u].reverse():u,a=r?[...t].reverse():t,e=d[0];return a.forEach((i,n)=>{e=`${e}${de(["uint24","address"],[i,d[n+1]]).slice(2)}`}),e}var ae={version:{type:"string",enum:["v2","v3","v4"]},tokenIn:h,tokenOut:h,path:{type:"array",minItems:2,maxItems:6,items:h},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:h,currency1:h,fee:{type:"integer"},tickSpacing:{type:"integer"},hooks:h},additionalProperties:!1}},poolKey:{type:"object",properties:{currency0:h,currency1:h,fee:{type:"integer"},tickSpacing:{type:"integer"},hooks:h},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 ke(u,t,r,d=!1){J(t,Object.keys(ae));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 i=U(e?t.amountOut:t.amountIn,e?"amountOut":"amountIn",a==="v4"?128:160),n=D(t.tokenIn),s=D(t.tokenOut);if(n===s)throw new o("Swap requires different input and output currencies.");let w=u.clientFor(I),m=await w.getBlock(),z=G(t.slippageBps),g,f,q,k,x,p,R;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 c=t.poolKeys.map(P=>H(P));g=he(c,n,s,e),f=(await w.simulateContract({address:ne,abi:re,functionName:e?"quoteExactOutput":"quoteExactInput",args:[{exactCurrency:e?s:n,path:g,exactAmount:i}],account:r,gas:K,blockNumber:m.number})).result[0]}else{if(x=H(t.poolKey),![x.currency0,x.currency1].includes(n)||![x.currency0,x.currency1].includes(s))throw new o("PoolKey currencies differ from the requested swap.");f=(await w.simulateContract({address:ne,abi:re,functionName:e?"quoteExactOutputSingle":"quoteExactInputSingle",args:[{poolKey:x,zeroForOne:n===x.currency0,exactAmount:i,hookData:"0x"}],account:r,gas:K,blockNumber:m.number})).result[0]}k="0x10"}else{if(t.poolKey!==void 0||t.poolKeys!==void 0||n===v||s===v)throw new o("V2/v3 routes use ERC-20 tokens; wrap ETH to WETH first.");if(p=Array.isArray(t.path)?t.path.map(L):[n,s],p.length<2||p.length>6||p[0]!==n||p.at(-1)!==s||new Set(p).size!==p.length||p.includes(v))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 c=await w.readContract({address:Y,abi:Z,functionName:e?"getAmountsIn":"getAmountsOut",args:[i,p],blockNumber:m.number});f=e?c[0]:c.at(-1),k=e?"0x09":"0x08"}else{let c=t.fees;if(!Array.isArray(c)||c.length!==p.length-1||c.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(!Q(await w.readContract({address:te,abi:oe,functionName:"factory",blockNumber:m.number}),T[4663].uniswap.v3_factory.address))throw new o("V3 quoter is not configured for the pinned factory.");R=Ae(p,c,e),f=(await w.simulateContract({address:te,abi:oe,functionName:e?"quoteExactOutput":"quoteExactInput",args:[R,i],account:r,gas:K,blockNumber:m.number})).result[0],k=e?"0x01":"0x00"}}if(f<=0n)throw new o("No positive Uniswap quote is available.");let V=e?t.maxAmountIn:t.minAmountOut;if(!d&&V===void 0)throw new o(`Provide ${e?"maxAmountIn":"minAmountOut"} from uniswap_quote to confirm the trade bound.`);let l=V===void 0?e?(f*BigInt(1e4+z)+9999n)/10000n:f*BigInt(1e4-z)/10000n:U(V,e?"maxAmountIn":"minAmountOut",a==="v4"?128:160);if(l<=0n||(e?l<f:l>f))throw new o("The fresh quote does not satisfy the confirmed swap bound.");let y=e?l:i;if(y>=1n<<160n||a==="v4"&&(y>=1n<<128n||l>=1n<<128n))throw new o("Swap bounds exceed the router amount range.");let[se,ce]=await Promise.all([_(u,n,m.number),_(u,s,m.number)]),j={version:a,input:{token:se,amount:(e?f:i).toString()},output:{token:ce,amount:(e?i:f).toString()},[e?"maxAmountIn":"minAmountOut"]:l.toString(),blockNumber:m.number.toString(),expiresAt:(m.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=m.timestamp+300n,E=[],X="Native ETH input; no token approvals.";if(n!==v){let c=await w.readContract({address:n,abi:me,functionName:"allowance",args:[r,C],blockNumber:m.number});c!==y&&E.push(u.approval(n,C,y.toString(),I)),X=`${c===y?"Reuse existing exact ERC-20 allowance of":"Set ERC-20 allowance to exactly"} ${y} input base units to Permit2; exact router permit.`,E.push(u.unsignedTx({to:C,data:ee({abi:le,functionName:"approve",args:[n,$,y,Number(O)]}),value:"0",chainId:I,description:`Permit exactly ${y} input base units to Universal Router until ${O}.`}))}if(a==="v4"){let c=g?b(ye,[{exactCurrency:e?s:n,path:g,minHopPriceX36:[],amount:i,limit:l}]):b(xe,[{poolKey:x,zeroForOne:n===x.currency0,amount:i,limit:l,minHopPriceX36:0n,hookData:"0x"}]);q=b(ve,[g?e?"0x090c0f":"0x070c0f":e?"0x080c0f":"0x060c0f",[c,b(ie,[n,y]),b(ie,[s,e?i:l])]])}else a==="v2"?q=b(we,[r,i,l,p,!0,[]]):q=b(be,[r,i,l,R,!0,[]]);let B=[q];return n===v&&e&&(k=`${k}04`,B.push(b(A("address,address,uint256"),[v,r,0n]))),E.push(u.unsignedTx({to:$,data:ee({abi:fe,functionName:"execute",args:[k,B,O]}),value:n===v?y.toString():"0",chainId:I,description:`Uniswap ${a} ${e?"exact output":"exact input"} swap; recipient ${r}; deadline ${O}.`})),{...await W(u,E,r,`Swap through Universal Router 2.1.2. ${X} Fixed output/input bound and five-minute on-chain deadline. Venue fees included; gas excluded.`),quote:j}}function Ne(u){return{tools:[!0,!1].map(t=>({name:t?"uniswap_quote":"uniswap_swap",inputSchema:{type:"object",additionalProperties:!1,required:["version","tokenIn","tokenOut"],properties:ae},execute:(r,d)=>ke(u,r,d,t)}))}}export{te as a,ne as b,fe as c,le as d,oe as e,re as f,ye as g,he as h,xe as i,be as j,we as k,Ae as l,ke as m,Ne as n};
@@ -1 +0,0 @@
1
- import{b as _,c as q,d as O,e as R}from"./Z4FZVJ5Z.js";import{a as N}from"./C7AXJHBT.js";import{a as E}from"./XLOYBLFI.js";import{a as I}from"./K3RDPI5J.js";import{c as M}from"./7WSHW7KW.js";import{b as G}from"./SPJCSEKP.js";import{a as y}from"./43LI5NKJ.js";import{b as x}from"./IX3GZMTM.js";import{a as o,d as U,i as P,j as b}from"./FWD4L3CJ.js";import{a as r}from"./XSD5NL7J.js";import{encodeFunctionData as g,erc20Abi as k,parseAbi as F}from"viem";var i=P[o].vaults.steakhouse.address,j=(1n<<256n)-1n,l=F(["function asset() view returns (address)","function totalAssets() view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256 assets)","function previewWithdraw(uint256 assets) view returns (uint256 shares)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]);function S(e){if(typeof e!="bigint"||e<0n||e>j)throw new r("The vault returned an invalid base-unit amount.");return e}function D(e){if(typeof e!="string")throw new r("Amount must be an integer string in base units.");let c=x(e);if(c===0n)throw new r("Amount must be positive.");if(c>j)throw new r("Amount exceeds the uint256 range.");return c}function T(e,c,h=!1){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(w=>!c||!["amount",...h?["force","maxPenaltyAssets","minAmountOut"]:[]].includes(w)))throw new r("Unexpected Steakhouse argument.")}var L=e=>{async function c(t){try{return await t()}catch(s){throw new r(e.plainError(s))}}async function h(){let t=e.clientFor(o);if(await t.getChainId()!==o)throw new r("Steakhouse requires chain 4663.");let s=await t.readContract({address:i,abi:l,functionName:"asset"});if(typeof s!="string"||s.toLowerCase()!==b.toLowerCase())throw new r("The Steakhouse vault asset does not match USDG on chain 4663.");let[a,n]=await Promise.all([t.readContract({address:b,abi:k,functionName:"decimals"}),t.readContract({address:i,abi:k,functionName:"decimals"})]);if(a!==U||!Number.isInteger(n)||n<0||n>255)throw new r("The vault returned invalid asset or share decimals.");return{client:t,asset:{address:b,symbol:"USDG",decimals:a,chainId:o},shares:{address:i,symbol:"steakUSDG",decimals:n,chainId:o}}}async function w(t,s){return S(await t.readContract({address:i,abi:k,functionName:"balanceOf",args:[s]}))}async function C(t,s,a){let n=await e.preview(t,s);if(n.changes.length===0)throw new r("The Steakhouse simulation returned no token balance changes.");let u=n.changes.map(({token:m,amount:d})=>{let f=d.startsWith("-"),p=e.formatAmount(f?d.slice(1):d,m.decimals);return`${f?"-":""}${p} ${m.symbol} (${m.address}, chain ${m.chainId}, decimals ${m.decimals})`});return{txs:t,summary:`${a} ${n.summary} Changes: ${u.join("; ")}.`}}return{tools:[q(e,"steakhouse_details",i),I(e,"steakhouse_analytics",i),E(e,"steakhouse_manage",i),...N(e,"steakhouse",i),{name:"steakhouse_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async t=>c(async()=>{T(t,!1);let{client:s,asset:a,shares:n}=await h(),u=S(await s.readContract({address:i,abi:l,functionName:"totalAssets"}));return[{name:"Steakhouse USDG",vault:n,asset:a,totalAssets:{token:a,amount:u.toString()}}]})},{name:"steakhouse_deposit",inputSchema:{...$(!1),description:"Deposit USDG in base units (1 USDG = 1000000) for vault shares. Exit with steakhouse_withdraw; check positions after confirmation."},execute:async(t,s)=>c(async()=>{T(t,!0);let a=D(t.amount);y(s);let{asset:n}=await h(),u=[e.approval(n.address,i,a.toString(),o),e.unsignedTx({to:i,data:g({abi:l,functionName:"deposit",args:[a,s]}),value:"0",chainId:o,description:`Deposit ${e.formatAmount(a.toString(),n.decimals)} USDG into Steakhouse.`})];return C(u,s,"Approve the exact USDG amount, then deposit into Steakhouse.")})},{name:"steakhouse_withdraw",inputSchema:{...$(!0),description:"Withdraw USDG in 6-decimal base units, or amount max to redeem every share for USDG. Check positions after confirmation.",properties:{...$(!0).properties,force:{type:"boolean",description:"Explicitly plan a full Morpho V2 force exit with penalty disclosure."},maxPenaltyAssets:{type:"string",pattern:"^[0-9]+$"},minAmountOut:{type:"string",pattern:"^[0-9]+$"}}},execute:async(t,s)=>c(async()=>{T(t,!0,!0);let a=t.amount==="max"?null:D(t.amount);y(s);let{client:n,asset:u,shares:m}=await h(),d=await w(n,s);if(d===0n)throw new r("The wallet has no Steakhouse shares to withdraw.");if(t.force!==void 0&&typeof t.force!="boolean")throw new r("force must be a boolean.");if(t.force===!0){if(a!==null)throw new r("Force exit currently requires amount max.");let p=M(t.maxPenaltyAssets),W=D(t.minAmountOut),v=await _(e,n,i,s,d,p),A=await e.preview([v.tx],s);return R(A.changes,i,d,W),{txs:[v.tx],preview:A,summary:`${O(v.plan)} ${A.summary}`}}if(t.maxPenaltyAssets!==void 0||t.minAmountOut!==void 0)throw new r("Penalty and output limits require force true.");let f;if(a===null)f=e.unsignedTx({to:i,data:g({abi:l,functionName:"redeem",args:[d,s,s]}),value:"0",chainId:o,description:`Redeem all ${e.formatAmount(d.toString(),m.decimals)} steakUSDG shares.`});else{let p=S(await n.readContract({address:i,abi:l,functionName:"previewWithdraw",args:[a]}));if(p===0n||p>d)throw new r("The withdrawal exceeds the available share balance or has an invalid share quote.");f=e.unsignedTx({to:i,data:g({abi:l,functionName:"withdraw",args:[a,s,s]}),value:"0",chainId:o,description:`Withdraw ${e.formatAmount(a.toString(),u.decimals)} USDG from Steakhouse.`})}return C([f],s,a===null?"Redeem the current full share balance from Steakhouse.":"Withdraw the requested USDG amount from Steakhouse.")})}],positions:t=>c(async()=>{y(t);let{client:s,asset:a,shares:n}=await h(),u=await w(s,t);if(u===0n)return[];let m=S(await s.readContract({address:i,abi:l,functionName:"convertToAssets",args:[u]}));return[{module:"steakhouse",id:`${o}:${i.toLowerCase()}`,chainId:o,assets:[{token:a,amount:m.toString()}],description:`${e.formatAmount(u.toString(),n.decimals)} steakUSDG shares (${i}, chain ${o}, decimals ${n.decimals}); USDG conversion is indicative, not guaranteed exit liquidity.`}]})}};function $(e){return{type:"object",additionalProperties:!1,required:["amount"],properties:{amount:{type:"string",pattern:e?"^(?:[0-9]+|max)$":"^[0-9]+$",description:`USDG base-unit integer string (6 decimals)${e?", or max to redeem every share":""}.`}}}}var te=e=>G("steakhouse",[L(e)]);export{L as a,te as b};
@@ -1 +0,0 @@
1
- import{a as S,b as N,d as k,f as c,g as $,h as p,i as T,k as v,l as F,m as P}from"./PV5FDT6O.js";import{c as u,g as h}from"./NWNYJ26T.js";import{a as g}from"./FWD4L3CJ.js";import{a as d}from"./XSD5NL7J.js";import{a as I}from"./JXOEJPJ4.js";import{encodeFunctionData as l,erc20Abi as x,parseAbi as O}from"viem";var w=O(["function admin() view returns (address)","function originalAdmin() view returns (address)","function updateAdmin(address)","function updateImage(string)","function updateMetadata(string)","function verify()","function delegate(address)","function burn(uint256)"]),j=m=>{let f=()=>m.clientFor(g),y=(t,i,n,e)=>({name:`clanker_${t}`,inputSchema:{type:"object",properties:i,required:n,additionalProperties:!1},execute:async(r,a)=>{try{return T(r,Object.keys(i)),await e(r,c(a))}catch(o){throw new d(m.plainError(o))}}}),A=async(t,i,n,e)=>{let r=[m.unsignedTx({to:t,data:i,chainId:g,value:"0",description:n})],a=await m.preview(r,e);return{txs:r,preview:a,summary:`${n} ${a.summary}`}},C=async t=>{let[i,n]=await Promise.all([f().readContract({address:t,abi:x,functionName:"symbol"}),f().readContract({address:t,abi:x,functionName:"decimals"})]);if(typeof i!="string"||!i.trim())throw new d("Clanker returned invalid metadata.");return{address:t,symbol:I(i),decimals:p(n,0,255),chainId:g}};return{tools:[y("status",{token:u},["token"],async(t,i)=>{let n=c(t.token),e=await P(m,n),r=await C(n),[a,o,b]=await Promise.all([f().readContract({address:n,abi:x,functionName:"balanceOf",args:[i]}),Promise.all(e.rewardBps.map((s,_)=>f().readContract({address:e.locker,abi:k,functionName:"feePreferences",args:[n,BigInt(_)]}))),Promise.all([n,e.pairedToken].map(async s=>({token:await C(s),amount:v(await f().readContract({address:S.fee_locker.address,abi:O(["function availableFees(address,address) view returns (uint256)"]),functionName:"availableFees",args:[i,s]}))})))]);return{...e,token:r,balance:{token:r,amount:v(a)},feePreferences:o.map(s=>p(s,0,2)),collectedFees:b,summary:"Onchain pool and connected-wallet holdings. Collected fees exclude pending LP fees. Token metadata is untrusted public text."}}),y("update_reward",{token:u,rewardIndex:{type:"integer",minimum:0,maximum:6},field:{enum:["recipient","admin","feePreference"]},recipient:u,admin:u,feePreference:{type:"integer",minimum:0,maximum:2}},["token","rewardIndex","field"],async(t,i)=>{let n=c(t.token),e=await P(m,n),r=p(t.rewardIndex,0,e.rewardAdmins.length-1);if(!h(e.rewardAdmins[r],i))throw new d("Only this reward index administrator may update its configuration.");let a=t.field;if(!["recipient","admin","feePreference"].includes(String(a)))throw new d("Choose recipient, admin or feePreference.");for(let s of["recipient","admin","feePreference"])if(t[s]!==void 0&&s!==a)throw new d(`Input ${s} does not match field ${String(a)}.`);let o=`Update Clanker reward ${r} ${String(a)} for ${n} to ${String(t[String(a)])}. Existing collected fees keep their prior recipient; transferring admin transfers future control.`,b=a==="feePreference"?l({abi:k,functionName:"updateFeePreference",args:[n,BigInt(r),p(t.feePreference,0,2)]}):l({abi:k,functionName:a==="admin"?"updateRewardAdmin":"updateRewardRecipient",args:[n,BigInt(r),c(t[String(a)])]});return A(e.locker,b,o,i)}),y("update_token",{token:u,field:{enum:["image","metadata","admin","verify","delegate","burn"]},text:{type:"string"},recipient:u,amount:N},["token","field"],async(t,i)=>{let n=c(t.token);await F(m,n);let e=t.field;if(!["image","metadata","admin","verify","delegate","burn"].includes(String(e)))throw new d("Choose a supported token update.");let r=e==="image"||e==="metadata"?"text":e==="admin"||e==="delegate"?"recipient":e==="burn"?"amount":void 0;for(let o of["text","recipient","amount"])if(t[o]!==void 0&&o!==r)throw new d(`Input ${o} does not match this token update.`);if(["image","metadata","admin","verify"].includes(String(e))){let o=await f().readContract({address:n,abi:w,functionName:e==="verify"?"originalAdmin":"admin"});if(!h(c(o),i))throw new d("The connected wallet is not the required token administrator.")}let a;if(e==="image"||e==="metadata"){if(typeof t.text!="string")throw new d("Provide public metadata text.");a=l({abi:w,functionName:e==="image"?"updateImage":"updateMetadata",args:[t.text]})}else if(e==="admin"||e==="delegate")a=l({abi:w,functionName:e==="admin"?"updateAdmin":"delegate",args:[c(t.recipient,e==="delegate")]});else if(e==="verify")a=l({abi:w,functionName:"verify"});else{let o=$(t.amount);if(!o)throw new d("Provide a positive burn amount.");a=l({abi:w,functionName:"burn",args:[o]})}return A(n,a,`Clanker token ${n}: ${String(e)} ${String(t.text??t.recipient??t.amount??"")}. Burns are irreversible; verification records original-admin approval, not an Oak safety review.`,i)})]}};export{j as a};
@@ -1 +0,0 @@
1
- import{a as f,b as O,f as c,g as _,i as D}from"./PV5FDT6O.js";import{c as i,g as C}from"./NWNYJ26T.js";import{a as m}from"./FWD4L3CJ.js";import{a}from"./XSD5NL7J.js";import{encodeFunctionData as F,parseAbi as P}from"viem";var E=["function owner() view returns (address)","function admins(address) view returns (bool)","function allowedDepositors(address) view returns (bool)","function setAdmin(address,bool)","function setDeprecated(bool)","function setTeamFeeRecipient(address)","function claimTeamFees(address)","function setHook(address,bool)","function setLocker(address,address,bool)","function setMevModule(address,bool)","function setExtension(address,bool)","function addDepositor(address)","function storeFees(address,address,uint256)","function claim(address,address)","function withdrawETH(address)","function withdrawERC20(address,address)","function transferOwnership(address)","function renounceOwnership()"],w=P(E),g={setAdmin:{contract:"factory",fields:["target","enabled"],admin:!1},setDeprecated:{contract:"factory",fields:["enabled"],admin:!1},setTeamFeeRecipient:{contract:"factory",fields:["recipient"],admin:!1},claimTeamFees:{contract:"factory",fields:["token"],admin:!0},setHook:{contract:"factory",fields:["target","enabled"],admin:!0},setLocker:{contract:"factory",fields:["target","hook","enabled"],admin:!0},setMevModule:{contract:"factory",fields:["target","enabled"],admin:!0},setExtension:{contract:"factory",fields:["target","enabled"],admin:!0},addDepositor:{contract:"fee_locker",fields:["target"],admin:!1},withdrawETH:{contract:"locker",fields:["recipient"],admin:!1},withdrawERC20:{contract:"locker",fields:["token","recipient"],admin:!1}},R=p=>{let h=()=>p.clientFor(m),k=async(e,n,t)=>({txs:e,preview:await p.preview(e,n),summary:t}),y=(e,n,t,r)=>p.unsignedTx({to:e,chainId:m,data:F({abi:w,functionName:n,args:t}),value:"0",description:r}),$={operation:{enum:[...Object.keys(g),"transferOwnership","renounceOwnership"]},contract:{enum:["factory","locker","fee_locker"]},target:i,hook:i,token:i,recipient:i,enabled:{type:"boolean"}},b=(e,n,t,r)=>({name:`clanker_${e}`,inputSchema:{type:"object",properties:n,required:t,additionalProperties:!1},execute:async(o,s)=>{try{return D(o,Object.keys(n)),await r(o,c(s))}catch(d){throw new a(p.plainError(d))}}});return{tools:[b("protocol_admin",$,["operation"],async(e,n)=>{let t=String(e.operation),r=t==="transferOwnership"||t==="renounceOwnership";if(!r&&!Object.hasOwn(g,t))throw new a("Choose a supported Clanker protocol operation.");let o=r?void 0:g[t],s=o?.contract??e.contract;if(s!=="factory"&&s!=="locker"&&s!=="fee_locker")throw new a("Select factory, locker or fee_locker for an ownership change.");if(!r&&e.contract!==void 0&&e.contract!==s)throw new a("This operation targets a different pinned contract.");let d=o?.fields??(t==="transferOwnership"?["recipient"]:[]);for(let l of["target","hook","token","recipient","enabled"])if(e[l]!==void 0&&!d.includes(l))throw new a(`Input ${l} does not match this protocol operation.`);let u=f[s].address,A=c(await h().readContract({address:u,abi:w,functionName:"owner"}),!0);if(!C(A,n)&&(o?.admin&&await h().readContract({address:u,abi:w,functionName:"admins",args:[n]}))!==!0)throw new a("The connected wallet lacks the required Clanker protocol owner/admin role.");let T=d.map(l=>{if(l!=="enabled")return c(e[l]);if(typeof e.enabled!="boolean")throw new a("Provide enabled as boolean.");return e.enabled}),v=`Clanker protocol ${s}: ${t} ${JSON.stringify(T)}. Owner/admin operation; renouncing ownership permanently removes owner-only controls. Withdrawals transfer the entire recorded asset balance; team fees go to the configured team recipient.`;return k([y(u,t,T,v)],n,v)}),b("store_fees",{token:i,recipient:i,amount:O},["token","recipient","amount"],async(e,n)=>{let t=c(e.token),r=c(e.recipient),o=_(e.amount);if(!o)throw new a("Provide a positive fee deposit amount.");if(await h().readContract({address:f.fee_locker.address,abi:w,functionName:"allowedDepositors",args:[n]})!==!0)throw new a("This wallet is not an authorized Clanker fee depositor.");let d=`Deposit exactly ${o} base units of token ${t} into Clanker fees for ${r}. Fee-on-transfer receipts may be smaller; the recorded recipient can later claim them.`,u=[p.approval(t,f.fee_locker.address,o.toString(),m),y(f.fee_locker.address,"storeFees",[r,t,o],d)];return k(u,n,d)}),b("claim_for",{token:i,recipient:i},["token","recipient"],async(e,n)=>{let t=c(e.token),r=c(e.recipient),o=`Permissionlessly claim already-collected Clanker ${t} fees for ${r}; all receipts go to that fee owner, while ${n} pays gas.`;return k([y(f.fee_locker.address,"claim",[r,t],o)],n,o)})]}};export{R as a};
@@ -1 +0,0 @@
1
- import{a as Ee}from"./NAZPDRIF.js";import{c as xe}from"./FQ6UZCM6.js";import{a as $e,b as pe,c as Te}from"./QA3UHEO3.js";import{c as Re,d as t,e as R,f as d,g as Ae,h as W,i as v,j as ue,k as L,m as O,n as c,o as ce,p as le,q as me,r as Ce,s as qe}from"./64GOINYS.js";import{a as ke,o as de}from"./3NJ5KQ3Q.js";import{a as ve}from"./66F5ZH34.js";import{c as re,e as Q,g as M}from"./NWNYJ26T.js";import{a as l,i as be}from"./FWD4L3CJ.js";import{a as h}from"./XSD5NL7J.js";import{decodeFunctionData as Fe,erc20Abi as Me}from"viem";var z="0x0000000000000000000000000000000000000000",N=be[l].relay.depository.address.toLowerCase(),Se=30,ze=w=>{let U=qe(w);async function he(n){let e;try{e=await U(`/intents/status/v3?requestId=${encodeURIComponent(n)}`)}catch(C){if(w.plainError(C)!=="The request timed out. Please try again.")throw C;return{requestId:n,status:"unknown",timedOut:!0,fulfilled:!1,settled:!1,pollAgain:!0,needsAttention:!1,inTxHashes:[],txHashes:[],originChainId:void 0,destinationChainId:void 0,summary:"The status request timed out. Bridge settlement is unknown; poll again."}}if(typeof e.status!="string")throw new h("Relay returned an invalid bridge status.");let i=ce(e.inTxHashes),p=ce(e.txHashes),u=e.originChainId===void 0?void 0:W(e.originChainId),a=e.destinationChainId===void 0?void 0:W(e.destinationChainId),s=le(e.failReason),m=le(e.refundFailReason),r=e.status==="success"&&p.length>0&&a!==void 0,q=e.status==="refund"&&p.length>0&&u!==void 0,g=e.status==="failure"&&m!==void 0,A=["waiting","depositing","pending","submitted","failure","refund","success"].includes(e.status)?e.status==="failure"&&/TIMEOUT|EXPIRED/.test(typeof e.failReason=="string"?e.failReason:"")?"timeout":e.status:"unknown",k=r?"Relay reports destination fulfillment.":q?"Relay reports a refund on the origin chain; the destination was not fulfilled.":g?"The bridge failed and automatic refund is unavailable. Review the request with Relay.":"Bridge settlement is not confirmed. Poll Relay again; an origin receipt alone does not prove destination fulfillment.";return{requestId:n,status:A,relayStatus:e.status,fulfilled:r,settled:r||q,pollAgain:!r&&!q&&!g,needsAttention:g,timedOut:!1,inTxHashes:i,txHashes:p,originChainId:u,destinationChainId:a,failReason:s,refundFailReason:m,...e.updatedAt===void 0?{}:{updatedAt:v(String(e.updatedAt))},summary:k}}async function De(n,e){let i=s=>({destinationVerified:!1,destinationCheck:s}),p;try{if(p=w.clientFor(n),await p.getChainId()!==n)return i(`The configured RPC does not serve chain ${n}; destination receipts were not checked.`)}catch{return i(`No RPC is available for chain ${n}; destination receipts were not checked.`)}let u=[];for(let s of e)try{let m=await p.getTransactionReceipt({hash:s});u.push({hash:s,status:m.status,blockNumber:m.blockNumber.toString()})}catch{return{...i(`Receipt ${s} is not available on chain ${n} yet; poll again.`),destinationReceipts:u}}let a=u.length>0&&u.every(s=>s.status==="success");return{destinationVerified:a,destinationReceipts:u,destinationCheck:a?`Every Relay destination transaction has a successful receipt on chain ${n}. Amounts are not decoded here; compare the recipient balance for the exact delivered amount.`:`A Relay destination transaction did not succeed on chain ${n}; do not treat this bridge as delivered.`}}async function Pe(n){let e=await w.clientFor(l).readContract({address:n,abi:Me,functionName:"decimals"}),i=typeof e=="bigint"?Number(e):e;if(typeof i!="number"||!Number.isInteger(i)||i<0||i>255)throw new h("Could not read valid ERC-20 decimals() on-chain.");return i}async function _e(n,e){let i=d(e),p=d(n.recipient??i),u=W(n.destinationChainId);if(u===l)throw new h("Choose a destination chain other than 4663.");let a=Ae(n.originCurrency??z),s=a!==z,m=d(n.destinationCurrency??z),r=v(n.amount);if(r==="0")throw new h("Provide a positive bridge amount.");let q=n.minAmountOut===void 0?void 0:v(n.minAmountOut),g=n.slippageBps??pe;if(typeof g!="number")throw new h("Slippage must be an integer from 0 to 9999 bps.");de("0",g);let I=R((await U("/chains")).chains).map(t),A=I.find(o=>o.id===l),k=I.find(o=>o.id===u);if(!A||!k||A.disabled!==!1||k.disabled!==!1||A.depositEnabled!==!0||A.vmType!=="evm"||k.vmType!=="evm")throw new h("Relay does not currently support this outbound chain route.");if(!xe(u))throw new h(`Relay has no supported Oak return path from chain ${u}. Choose a destination supported by relay_bridge_in before bridge-out.`);let C=await $e(w.clientFor,u,i,"server"),b=s?await Pe(a):18,P=Math.floor(Date.now()/1e3)+ke,$=await U("/quote/v2",{user:i,recipient:p,originChainId:l,destinationChainId:u,originCurrency:a,destinationCurrency:m,amount:r,tradeType:"EXACT_INPUT",...s?{explicitDeposit:!0}:{}}),E=L($.requestId),S=t($.details),B=O(S.currencyIn),f=O(S.currencyOut),T={token:f.token,amount:v(t(S.currencyOut).minimumAmount)};if(c(d(S.sender)===i&&d(S.recipient)===p&&B.token.chainId===l&&B.token.address===a&&B.token.decimals===b&&B.amount===r&&f.token.chainId===u&&f.token.address===m&&BigInt(T.amount)>0n&&BigInt(T.amount)<=BigInt(f.amount)),m===z&&c(f.token.decimals===t(k.currency).decimals),q!==void 0){if(T.amount!==q)throw new h("Relay order minimum must exactly match minAmountOut. Request a new quote.")}else if(BigInt(T.amount)<BigInt(de(f.amount,g)))throw Te(f.amount,T.amount);let J=t(t($.protocol).v2),j=L(J.orderId),Z=t(J.orderData),Y=t(Z.output),ee=ue(Y.deadline),K=R(Z.inputs).map(t);c(K.length>0);let te=K.flatMap(o=>{let y=R(o.refunds).map(t);return c(y.length>0),y.map(we=>{if(d(we.recipient)!==i)throw new h("Relay refund recipient does not match the agent wallet. Request a new quote.");return ue(we.deadline)})}),Oe=te.reduce((o,y)=>Math.min(o,y),ee),ne=Math.min(P,Oe-Se),fe=()=>{if(Date.now()/1e3>=ne)throw new h("The Relay quote expired or its order/refund deadline leaves too little time to sign and send. Request a fresh bridge quote.")};fe();let H=R(Y.payments).map(t),ie=t(t(A.protocol).v2),Ne=t(t(k.protocol).v2),V=t(J.paymentDetails);c(Y.chainId===Ne.chainId&&H.length===1&&R(Y.calls).length===0&&d(H[0].recipient)===p&&d(H[0].currency)===m&&v(H[0].minimumAmount)===T.amount&&v(H[0].expectedAmount)===f.amount&&V.chainId===ie.chainId&&d(V.currency)===a&&v(V.amount)===r),c(d(V.depository)===N&&d(ie.depository)===N);let oe=t(K[0].payment);c(K.length===1&&oe.chainId===ie.chainId&&d(oe.currency)===a&&v(oe.amount)===r);let F=R($.steps).map(t),_=s&&F.length===2?F[0]:void 0;c(F.length===(_?2:1));let G=F[F.length-1];c(G.kind==="transaction"&&G.id==="deposit"&&G.requestId===E);let X=R(G.items).map(t);c(X.length===1&&X[0].status==="incomplete");let x=t(X[0].data),ye=t(X[0].check);if(c(ye.method==="GET"&&ye.endpoint===`/intents/status/v3?requestId=${E}`&&x.chainId===l&&d(x.from)===i&&d(x.to)===N&&v(x.value)===(s?"0":r)),typeof x.data!="string"||!(s?/^0x[0-9a-fA-F]{264}$/:/^0x[0-9a-fA-F]{136}$/).test(x.data))throw new h(`Relay returned unexpected ${s?"ERC-20":"native"} deposit calldata.`);let D=Fe({abi:Re,data:x.data});D.functionName==="depositErc20"?c(s&&d(D.args[0])===i&&d(D.args[1])===a&&D.args[2]===BigInt(r)&&M(D.args[3],j)):c(!s&&d(D.args[0])===i&&M(D.args[1],j));let Be=I.filter(o=>o.vmType==="evm"&&Q(o.protocol)&&Q(o.protocol.v2)).map(o=>t(t(o.protocol).v2).chainId).filter(o=>typeof o=="string");if(!M(Ee(Z,Be),j))throw new h("Relay order ID does not match the checked quote terms. Request a new quote.");let ae=s?w.approval(a,N,r,l):void 0;if(_&&ae){c(_.kind==="transaction"&&_.id==="approve"&&_.requestId===E);let o=R(_.items).map(t);c(o.length===1&&o[0].status==="incomplete");let y=t(o[0].data);c(y.chainId===l&&d(y.from)===i&&d(y.to)===a&&v(y.value)==="0"&&typeof y.data=="string"&&M(y.data,ae.data))}let ge=[...ae?await Ce(w,a,N,r,l,i):[],w.unsignedTx({to:N,data:x.data,value:s?"0":r,chainId:l,description:s?`Deposit ${r} base units of ${a} for Relay request ${E}.`:`Deposit native ETH for Relay request ${E}.`})],Ie=t($.fees);for(let o of Object.values(Ie))O(o);let se=await w.preview(ge,i);fe();let He=se.changes.map(o=>{let y=o.amount.startsWith("-");return`${y?"-":""}${w.formatAmount(y?o.amount.slice(1):o.amount,o.token.decimals)} ${o.token.symbol}`}).join(", ");return{txs:ge,requestId:E,orderId:j,recipient:p,originChainId:l,destinationChainId:u,expiresAt:String(ne),orderDeadline:String(ee),refundDeadlines:te.map(String),returnPath:C,amountIn:B,amountOut:f,minAmountOut:T,fees:Ie,expandedPriceImpact:S.expandedPriceImpact,timeEstimate:S.timeEstimate,preview:se,summary:`${C} Bridge to ${p} on chain ${u}; asset ${f.token.address} on chain ${f.token.chainId} (${me(f.token.symbol)}); expected ${f.amount}, minimum ${T.amount} base units (${f.token.decimals} decimals). Order deadline ${ee} Unix seconds; refund deadlines ${te.join(", ")} Unix seconds; accept before ${ne} Unix seconds to reserve ${Se}s to sign and send. Origin preview: ${He||se.summary}. Relay route fees are included in the quote; origin gas is separate. Poll relay_status with requestId ${E} after local submission; destination fulfillment is not yet confirmed.`}}return{tools:[{name:"relay_bridge_out",inputSchema:{type:"object",required:["destinationChainId","amount"],additionalProperties:!1,properties:{destinationChainId:{type:"integer",minimum:1},amount:{type:"string",pattern:"^[1-9][0-9]*$"},recipient:re,originCurrency:re,slippageBps:{type:"integer",minimum:0,maximum:9999,default:pe},destinationCurrency:{type:"string"},minAmountOut:ve()}},execute:async(n,e)=>{try{return await _e(n,e)}catch(i){throw new h(w.plainError(i))}}},{name:"relay_status",inputSchema:{type:"object",required:["requestId"],additionalProperties:!1,properties:{requestId:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},verifyDestination:{type:"boolean"}}},execute:async n=>{let e=await he(L(n.requestId));return n.verifyDestination!==!0||!e.fulfilled||e.destinationChainId===void 0?e:{...e,...await De(e.destinationChainId,e.txHashes)}}}],positions:async n=>{let e=d(n);if(!process.env.OAK_RELAY_API_KEY?.trim())return[{module:"relay",id:"relay-discovery-unavailable",chainId:l,assets:[],incomplete:!0,description:'Relay pending bridge discovery requires OAK_RELAY_API_KEY on the server. The request-history API requires this key; no pending bridges were checked. Ask the operator to configure it, or check a known request with relay_status {"requestId":"<id>"}. Legacy vault shares on other chains can be checked with relay_vault_status {"chainId":1} or {"chainId":42161}.'}];let i=new Map;for(let p of["outbound","inbound"]){let u=new Set,a;do{let s=new URLSearchParams({user:e,[p==="outbound"?"originChainId":"destinationChainId"]:String(l),limit:"100",includePendingRequests:"true"});a&&s.set("continuation",a);let m=await U(`/requests/v3?${s}`);for(let r of R(m.requests).map(t)){let q=Q(r.depositAddress)?r.depositAddress.depositor:void 0;if(![r.user,r.sender,q].some($=>typeof $=="string"&&$.toLowerCase()===e))throw new h("Relay returned a request for another wallet.");let g=L(r.id);if(i.has(g))continue;let I=await he(g);if(I.settled)continue;let A=t(r.data),k=t(t(A.route).quoted),C=O(t(k.origin).inputCurrency),b={...C,token:{...C.token,symbol:me(C.token.symbol)??"unknown"}},P=O(t(k.destination).outputCurrency);c(p==="outbound"?b.token.chainId===l&&P.token.chainId!==l:b.token.chainId!==l&&P.token.chainId===l),I.originChainId!==void 0&&c(I.originChainId===b.token.chainId),I.destinationChainId!==void 0&&c(I.destinationChainId===P.token.chainId),i.set(g,{module:"relay",id:g,chainId:b.token.chainId,assets:[b],description:`Relay ${p} ${I.status}: ${b.amount} ${b.token.symbol} base units (${b.token.decimals} decimals) from chain ${b.token.chainId} toward ${d(r.recipient)} on chain ${P.token.chainId}. ${I.summary} Track with relay_status requestId ${g}.`})}if(m.continuation!==void 0&&m.continuation!==null&&typeof m.continuation!="string")throw new h("Relay returned invalid pagination.");if(a=typeof m.continuation=="string"&&m.continuation?m.continuation:void 0,a){if(u.has(a))throw new h("Relay repeated its pagination cursor. Pending positions are incomplete.");u.add(a)}}while(a)}return[...i.values()]}}};export{ze as a};
@@ -1 +0,0 @@
1
- import{c as w,d as T,i as A,m as S}from"./NWNYJ26T.js";import{a as c,i as k}from"./FWD4L3CJ.js";import{a as r}from"./XSD5NL7J.js";import{encodeFunctionData as D,getAddress as E,keccak256 as P,parseAbi as O}from"viem";var g=E("0x03695edcfcf2c62a4dc36b032eb2513cd1d928a2"),I="0x0b3d9287f6788f70f8f32597eb50d8aaf791742819ecf58053f3e22fd96cb76b",F=["beefy_vault_manage"],C=O(["function owner() view returns(address)","function want() view returns(address)","function vault() view returns(address)","function strategy() view returns(address)","function approvalDelay() view returns(uint256)","function stratCandidate() view returns(address implementation,uint256 proposedTime)","function earn()","function proposeStrat(address)","function upgradeStrat()","function inCaseTokensGetStuck(address)","function transferOwnership(address)","function renounceOwnership()"]),s=E(k[c].vaults.beefyTestedLpVault.address);function d(u){return A(u,"Provide a contract or wallet address.",T)}function h(u){return S(u,"Invalid Beefy administration integer.")}var R=u=>{async function v(e){try{return await e()}catch(t){throw new r(u.plainError(t))}}function b(e,t){if(e.chainId!==void 0&&e.chainId!==c)throw new r("Beefy requires chain 4663.");for(let p of Object.keys(e))if(!["chainId","vault",...t].includes(p))throw new r(`Unsupported Beefy input: ${p}.`);if(d(e.vault)!==s)throw new r("Administration is qualified only for the measured up33-weth-up vault.")}async function _(){let e=u.clientFor(c);if(await e.getChainId()!==c)throw new r("The Beefy endpoint must report chain 4663.");let t=h(await e.getBlockNumber()),[p,n]=await Promise.all([e.getCode({address:s,blockNumber:t}),e.getCode({address:g,blockNumber:t})]),o=`0x363d3d373d3d3d363d73${g.slice(2).toLowerCase()}5af43d82803e903d91602b57fd5bf3`;if(p?.toLowerCase()!==o||!n||P(n)!==I)throw new r("The Beefy vault implementation no longer matches its qualified code hash.");let a=(B,N)=>e.readContract({address:B,abi:C,functionName:N,blockNumber:t}),[f,m,y,i,l,x]=await Promise.all([a(s,"owner"),a(s,"want"),a(s,"strategy"),a(s,"approvalDelay"),a(s,"stratCandidate"),e.getBlock({blockNumber:t})]);if(!Array.isArray(l)||l.length!==2)throw new r("Invalid Beefy strategy candidate.");return{client:e,blockNumber:t,owner:d(f),want:d(m),strategy:d(y),approvalDelay:h(i),candidate:{implementation:d(l[0]),proposedTime:h(l[1])},timestamp:h(x.timestamp),read:a}}return{tools:[{name:"beefy_vault_admin",inputSchema:{type:"object",properties:{vault:w,chainId:{const:c}},required:["vault"],additionalProperties:!1},execute:e=>v(async()=>{b(e,[]);let t=await _();return{vault:s,chainId:c,owner:t.owner,want:t.want,strategy:t.strategy,candidate:{implementation:t.candidate.implementation,proposedTime:t.candidate.proposedTime.toString()},approvalDelay:t.approvalDelay.toString(),block:t.blockNumber.toString(),implementation:g,codeHash:I}})},{name:"beefy_vault_manage",inputSchema:{type:"object",properties:{vault:w,action:{enum:["earn","propose_strategy","upgrade_strategy","rescue_tokens","transfer_ownership","renounce_ownership"]},strategy:w,token:w,recipient:w,chainId:{const:c}},required:["vault","action"],additionalProperties:!1},execute:(e,t)=>v(async()=>{let p={earn:[],propose_strategy:["strategy"],upgrade_strategy:[],rescue_tokens:["token"],transfer_ownership:["recipient"],renounce_ownership:[]},n=String(e.action);if(!Object.hasOwn(p,n))throw new r("Choose a documented Beefy vault management action.");b(e,["action",...p[n]]),t=d(t);let o=await _();if(n!=="earn"&&o.owner!==t)throw new r("This wallet is not the Beefy vault owner.");let a,f=[];if(n==="earn")a="earn";else if(n==="propose_strategy"){let i=d(e.strategy),l=await o.client.getCode({address:i,blockNumber:o.blockNumber});if(!l||l==="0x"||d(await o.read(i,"vault"))!==s||d(await o.read(i,"want"))!==o.want)throw new r("The proposed strategy must be deployed for this exact vault and want token.");a="proposeStrat",f=[i]}else if(n==="upgrade_strategy"){if(o.candidate.implementation==="0x0000000000000000000000000000000000000000"||o.candidate.proposedTime+o.approvalDelay>=o.timestamp)throw new r("Propose a strategy first and wait until the on-chain approval delay has fully passed.");a="upgradeStrat"}else if(n==="rescue_tokens"){let i=d(e.token);if(i===o.want)throw new r("The vault owner cannot rescue the want token.");a="inCaseTokensGetStuck",f=[i]}else if(n==="transfer_ownership"){let i=d(e.recipient);if(i==="0x0000000000000000000000000000000000000000")throw new r("Ownership transfer needs a nonzero recipient.");a="transferOwnership",f=[i]}else a="renounceOwnership";let m=[u.unsignedTx({to:s,data:D({abi:C,functionName:a,args:f}),value:"0",chainId:c,description:`Beefy vault ${n}.`})],y=n==="renounce_ownership"?" This permanently gives up owner administration.":n==="rescue_tokens"?" Rescued tokens go to the calling owner wallet; want is excluded.":n==="propose_strategy"||n==="upgrade_strategy"?" Strategy changes affect all vault depositors.":"";return{txs:m,inputs:[],preview:await u.preview(m,t),summary:`Beefy vault action ${n} on ${s}.${y} Inspect the preview before local human confirmation.`}})}]}};export{g as a,I as b,F as c,C as d,R as e};
@@ -1,18 +0,0 @@
1
- import{a as ae}from"./3CCBUYUM.js";import{a as bt,d as wt,e as ht}from"./CHXBOXOD.js";import{a as Ne}from"./7MR37STI.js";import{a as We,b as Be,d as pt}from"./7WSHW7KW.js";import{b as ut,c as mt,d as ft}from"./P56RZC2M.js";import{d as ct,e as te}from"./3NJ5KQ3Q.js";import{a as dt}from"./3MLUCYCB.js";import{b as lt}from"./SPJCSEKP.js";import{a as q}from"./43LI5NKJ.js";import{a as A,d as z}from"./66F5ZH34.js";import{d as De,g as E,i as Ue}from"./NWNYJ26T.js";import{b as Me}from"./IX3GZMTM.js";import{j as it}from"./ABPL3ZZI.js";import{a as p,i as V}from"./FWD4L3CJ.js";import{a as i,e as se}from"./XSD5NL7J.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};