@oakagentkit/core 0.2.7 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (508) hide show
  1. package/build/dist/api/addresses.d.ts +9 -0
  2. package/build/dist/api/addresses.js +1 -1
  3. package/build/dist/api/chain.d.ts +4 -0
  4. package/build/dist/api/chain.js +1 -1
  5. package/build/dist/api/history.js +1 -1
  6. package/build/dist/api/identity-link.js +1 -1
  7. package/build/dist/api/metadata.js +1 -1
  8. package/build/dist/api/modules/beefy/boosts.js +1 -1
  9. package/build/dist/api/modules/beefy/clm.d.ts +9 -0
  10. package/build/dist/api/modules/beefy/clm.js +1 -1
  11. package/build/dist/api/modules/beefy/guard.js +1 -1
  12. package/build/dist/api/modules/beefy/index.js +1 -1
  13. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  14. package/build/dist/api/modules/beefy/management.js +1 -1
  15. package/build/dist/api/modules/beefy/vaults.js +1 -1
  16. package/build/dist/api/modules/borro/abi.d.ts +54 -0
  17. package/build/dist/api/modules/borro/abi.js +1 -1
  18. package/build/dist/api/modules/borro/actions.d.ts +14 -1
  19. package/build/dist/api/modules/borro/actions.js +1 -1
  20. package/build/dist/api/modules/borro/checks.js +1 -1
  21. package/build/dist/api/modules/borro/copy.d.ts +10 -2
  22. package/build/dist/api/modules/borro/copy.js +1 -1
  23. package/build/dist/api/modules/borro/index.js +1 -1
  24. package/build/dist/api/modules/borro/liquidity.js +1 -1
  25. package/build/dist/api/modules/borro/pins.d.ts +30 -14
  26. package/build/dist/api/modules/borro/pins.js +1 -1
  27. package/build/dist/api/modules/borro/positions.js +1 -1
  28. package/build/dist/api/modules/borro/reader.js +1 -1
  29. package/build/dist/api/modules/borro/types.d.ts +1 -0
  30. package/build/dist/api/modules/chop/actions.js +1 -1
  31. package/build/dist/api/modules/chop/checks.js +1 -1
  32. package/build/dist/api/modules/chop/copy.js +1 -1
  33. package/build/dist/api/modules/chop/guard.js +1 -1
  34. package/build/dist/api/modules/chop/index.js +1 -1
  35. package/build/dist/api/modules/chop/pins.d.ts +13 -0
  36. package/build/dist/api/modules/chop/pins.js +1 -1
  37. package/build/dist/api/modules/chop/positions.js +1 -1
  38. package/build/dist/api/modules/chop/reader.js +1 -1
  39. package/build/dist/api/modules/clanker/extensions.js +1 -1
  40. package/build/dist/api/modules/clanker/index.js +1 -1
  41. package/build/dist/api/modules/clanker/manage.js +1 -1
  42. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  43. package/build/dist/api/modules/clanker/protocol.js +1 -1
  44. package/build/dist/api/modules/clanker/state.js +1 -1
  45. package/build/dist/api/modules/earn/copy.d.ts +6 -6
  46. package/build/dist/api/modules/earn/copy.js +1 -1
  47. package/build/dist/api/modules/earn/cost.d.ts +1 -1
  48. package/build/dist/api/modules/earn/cost.js +1 -1
  49. package/build/dist/api/modules/earn/index.js +1 -1
  50. package/build/dist/api/modules/earn/lp.js +1 -1
  51. package/build/dist/api/modules/earn/options.js +1 -1
  52. package/build/dist/api/modules/erc8004/common.js +1 -1
  53. package/build/dist/api/modules/erc8004/domain.js +1 -1
  54. package/build/dist/api/modules/erc8004/index.js +1 -1
  55. package/build/dist/api/modules/erc8004/management.js +1 -1
  56. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  57. package/build/dist/api/modules/erc8004/services.js +1 -1
  58. package/build/dist/api/modules/erc8004/thesis.d.ts +61 -0
  59. package/build/dist/api/modules/erc8004/thesis.js +1 -0
  60. package/build/dist/api/modules/erc8004/validation.js +1 -1
  61. package/build/dist/api/modules/fobo/client.d.ts +9 -0
  62. package/build/dist/api/modules/fobo/client.js +1 -0
  63. package/build/dist/api/modules/fobo/index.d.ts +16 -0
  64. package/build/dist/api/modules/fobo/index.js +1 -0
  65. package/build/dist/api/modules/fobo/intent.d.ts +243 -0
  66. package/build/dist/api/modules/fobo/intent.js +1 -0
  67. package/build/dist/api/modules/fobo/pins.d.ts +178 -0
  68. package/build/dist/api/modules/fobo/pins.js +1 -0
  69. package/build/dist/api/modules/fobo/steps.d.ts +25 -0
  70. package/build/dist/api/modules/fobo/steps.js +1 -0
  71. package/build/dist/api/modules/fobo/verify.d.ts +89 -0
  72. package/build/dist/api/modules/fobo/verify.js +1 -0
  73. package/build/dist/api/modules/gloam/copy.d.ts +1 -1
  74. package/build/dist/api/modules/gloam/copy.js +1 -1
  75. package/build/dist/api/modules/gloam/index.js +1 -1
  76. package/build/dist/api/modules/grove/index.js +1 -1
  77. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  78. package/build/dist/api/modules/heyresearch/index.js +1 -1
  79. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  80. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  81. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  82. package/build/dist/api/modules/hoodag/index.d.ts +12 -1
  83. package/build/dist/api/modules/hoodag/index.js +1 -1
  84. package/build/dist/api/modules/hoodag/management.js +1 -1
  85. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  86. package/build/dist/api/modules/hoodag/reconstruct.d.ts +14 -0
  87. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  88. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  89. package/build/dist/api/modules/hoodlock/buyback.js +1 -1
  90. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  91. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  92. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  93. package/build/dist/api/modules/hoodlock/index.js +1 -1
  94. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  95. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  96. package/build/dist/api/modules/hoodlock/public.js +1 -1
  97. package/build/dist/api/modules/hookr/actions.js +1 -1
  98. package/build/dist/api/modules/hookr/addons.js +1 -1
  99. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  100. package/build/dist/api/modules/hookr/contracts.js +1 -1
  101. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  102. package/build/dist/api/modules/hookr/discovery.js +1 -1
  103. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  104. package/build/dist/api/modules/hookr/index.js +1 -1
  105. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  106. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  107. package/build/dist/api/modules/hookr/launch.js +1 -1
  108. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  109. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  110. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  111. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  112. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  113. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  114. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  115. package/build/dist/api/modules/hookr/relay.js +1 -1
  116. package/build/dist/api/modules/hookr/revenue.js +1 -1
  117. package/build/dist/api/modules/kyberswap/index.d.ts +2 -1
  118. package/build/dist/api/modules/kyberswap/index.js +1 -1
  119. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  120. package/build/dist/api/modules/layerbank/abi.js +1 -1
  121. package/build/dist/api/modules/layerbank/actions.js +1 -1
  122. package/build/dist/api/modules/layerbank/checks.js +1 -1
  123. package/build/dist/api/modules/layerbank/index.js +1 -1
  124. package/build/dist/api/modules/layerbank/merkl.js +1 -1
  125. package/build/dist/api/modules/layerbank/reader.js +1 -1
  126. package/build/dist/api/modules/layerbank/reserve.js +1 -1
  127. package/build/dist/api/modules/lighter/index.js +1 -1
  128. package/build/dist/api/modules/longbow/administration.js +1 -1
  129. package/build/dist/api/modules/longbow/analytics.js +1 -1
  130. package/build/dist/api/modules/longbow/fixed.js +1 -1
  131. package/build/dist/api/modules/longbow/index.js +1 -1
  132. package/build/dist/api/modules/longbow/nft.js +1 -1
  133. package/build/dist/api/modules/longbow/rebates.js +1 -1
  134. package/build/dist/api/modules/longbow/staking.js +1 -1
  135. package/build/dist/api/modules/meridian/index.js +1 -1
  136. package/build/dist/api/modules/meridian/markets.js +1 -1
  137. package/build/dist/api/modules/meridian/predict-read.js +1 -1
  138. package/build/dist/api/modules/meridian/rfq.js +1 -1
  139. package/build/dist/api/modules/merkl/discovery.js +1 -1
  140. package/build/dist/api/modules/merkl/index.js +1 -1
  141. package/build/dist/api/modules/merkl/manage.js +1 -1
  142. package/build/dist/api/modules/merkl/protocol.js +1 -1
  143. package/build/dist/api/modules/morpho/allocator.js +1 -1
  144. package/build/dist/api/modules/morpho/bundles.js +1 -1
  145. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  146. package/build/dist/api/modules/morpho/index.js +1 -1
  147. package/build/dist/api/modules/morpho/local-guard.d.ts +2 -1
  148. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  149. package/build/dist/api/modules/morpho/midnight.js +1 -1
  150. package/build/dist/api/modules/morpho/protocol.js +1 -1
  151. package/build/dist/api/modules/morpho/surface.js +1 -1
  152. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  153. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  154. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  155. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  156. package/build/dist/api/modules/netnet/card-policy.d.ts +1 -0
  157. package/build/dist/api/modules/netnet/card-policy.js +1 -1
  158. package/build/dist/api/modules/netnet/card-read.js +1 -1
  159. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  160. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  161. package/build/dist/api/modules/netnet/desk-read.js +1 -1
  162. package/build/dist/api/modules/netnet/financial.js +1 -1
  163. package/build/dist/api/modules/netnet/index.js +1 -1
  164. package/build/dist/api/modules/netnet/staking.js +1 -1
  165. package/build/dist/api/modules/orbio/index.d.ts +6 -0
  166. package/build/dist/api/modules/orbio/index.js +1 -1
  167. package/build/dist/api/modules/orbio/positions.js +1 -1
  168. package/build/dist/api/modules/pendle/costs.js +1 -1
  169. package/build/dist/api/modules/pendle/index.js +1 -1
  170. package/build/dist/api/modules/pendle/markets.js +1 -1
  171. package/build/dist/api/modules/pendle/positions.js +1 -1
  172. package/build/dist/api/modules/pendle/pricecheck.js +1 -1
  173. package/build/dist/api/modules/pendle/reader.js +1 -1
  174. package/build/dist/api/modules/pendle/redeem.js +1 -1
  175. package/build/dist/api/modules/pendle/trade.js +1 -1
  176. package/build/dist/api/modules/pendle/validate.js +1 -1
  177. package/build/dist/api/modules/pendle/verify.js +1 -1
  178. package/build/dist/api/modules/pons/claim.js +1 -1
  179. package/build/dist/api/modules/pons/index.js +1 -1
  180. package/build/dist/api/modules/pons/launch-status.js +1 -1
  181. package/build/dist/api/modules/pons/prices.js +1 -1
  182. package/build/dist/api/modules/pons/reads.js +1 -1
  183. package/build/dist/api/modules/pons/swap-terms.d.ts +2 -8
  184. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  185. package/build/dist/api/modules/pons/trade.js +1 -1
  186. package/build/dist/api/modules/poolstrade/index.js +1 -1
  187. package/build/dist/api/modules/priors/coverage.js +1 -1
  188. package/build/dist/api/modules/priors/discovery.js +1 -1
  189. package/build/dist/api/modules/priors/features.js +1 -1
  190. package/build/dist/api/modules/priors/holdings.js +1 -1
  191. package/build/dist/api/modules/priors/index.js +1 -1
  192. package/build/dist/api/modules/priors/integration.js +1 -1
  193. package/build/dist/api/modules/priors/market.js +1 -1
  194. package/build/dist/api/modules/priors/pt.js +1 -1
  195. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  196. package/build/dist/api/modules/priors/starter-line.js +1 -1
  197. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  198. package/build/dist/api/modules/relay/api.js +1 -1
  199. package/build/dist/api/modules/relay/bootstrap.js +1 -1
  200. package/build/dist/api/modules/relay/discovery.js +1 -1
  201. package/build/dist/api/modules/relay/inbound.js +1 -1
  202. package/build/dist/api/modules/relay/index.js +1 -1
  203. package/build/dist/api/modules/relay/order.js +1 -1
  204. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  205. package/build/dist/api/modules/relay/readiness.js +1 -1
  206. package/build/dist/api/modules/relay/reads.js +1 -1
  207. package/build/dist/api/modules/relay/vaults.js +1 -1
  208. package/build/dist/api/modules/spark/actions.js +1 -1
  209. package/build/dist/api/modules/spark/details.js +1 -1
  210. package/build/dist/api/modules/spark/index.js +1 -1
  211. package/build/dist/api/modules/spark/management.js +1 -1
  212. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  213. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  214. package/build/dist/api/modules/steakhouse/index.js +1 -1
  215. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  216. package/build/dist/api/modules/steakhouse/management.js +1 -1
  217. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  218. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  219. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  220. package/build/dist/api/modules/tickerspring/discovery.js +1 -1
  221. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  222. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  223. package/build/dist/api/modules/tickerspring/index.js +1 -1
  224. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  225. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  226. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  227. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  228. package/build/dist/api/modules/tickerspring/research.js +1 -1
  229. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  230. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  231. package/build/dist/api/modules/uniswap/auction.js +1 -1
  232. package/build/dist/api/modules/uniswap/batch.js +1 -1
  233. package/build/dist/api/modules/uniswap/common.js +1 -1
  234. package/build/dist/api/modules/uniswap/fees.js +1 -1
  235. package/build/dist/api/modules/uniswap/index.js +1 -1
  236. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  237. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  238. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  239. package/build/dist/api/modules/uniswap/pools.js +1 -1
  240. package/build/dist/api/modules/uniswap/position.js +1 -1
  241. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  242. package/build/dist/api/modules/uniswap/quote-guard.js +1 -1
  243. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  244. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  245. package/build/dist/api/modules/uniswap/trade.js +1 -1
  246. package/build/dist/api/modules/uniswap/v2.js +1 -1
  247. package/build/dist/api/modules/uniswap/v3.js +1 -1
  248. package/build/dist/api/modules/uniswap/v4.js +1 -1
  249. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  250. package/build/dist/api/modules/upoch/copy.d.ts +5 -0
  251. package/build/dist/api/modules/upoch/copy.js +1 -0
  252. package/build/dist/api/modules/upoch/index.d.ts +8 -0
  253. package/build/dist/api/modules/upoch/index.js +1 -0
  254. package/build/dist/api/modules/upoch/pins.d.ts +8 -0
  255. package/build/dist/api/modules/upoch/pins.js +1 -0
  256. package/build/dist/api/modules/upoch/reads.d.ts +509 -0
  257. package/build/dist/api/modules/upoch/reads.js +1 -0
  258. package/build/dist/api/modules/velora/claims.js +1 -1
  259. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  260. package/build/dist/api/modules/velora/index.js +1 -1
  261. package/build/dist/api/modules/wormhole/index.js +1 -1
  262. package/build/dist/api/modules/wormhole/x402-client.d.ts +17 -1
  263. package/build/dist/api/modules/wormhole/x402-client.js +1 -1
  264. package/build/dist/api/positions.js +1 -1
  265. package/build/dist/api/pricenote.js +1 -1
  266. package/build/dist/api/prices.d.ts +5 -0
  267. package/build/dist/api/prices.js +1 -1
  268. package/build/dist/api/pricing.js +1 -1
  269. package/build/dist/api/rpc.js +1 -1
  270. package/build/dist/api/secret-fields.d.ts +2 -0
  271. package/build/dist/api/secret-fields.js +1 -1
  272. package/build/dist/api/send.js +1 -1
  273. package/build/dist/api/signing-registry.js +1 -1
  274. package/build/dist/api/signing.js +1 -1
  275. package/build/dist/api/simulate.js +1 -1
  276. package/build/dist/api/swap.d.ts +1 -0
  277. package/build/dist/api/swap.js +1 -1
  278. package/build/dist/api/tokens.js +1 -1
  279. package/build/dist/api/tool-policy.d.ts +1 -0
  280. package/build/dist/api/tool-policy.js +1 -1
  281. package/build/dist/api/universal-router.d.ts +45 -0
  282. package/build/dist/api/universal-router.js +1 -0
  283. package/build/dist/api/usd-estimate.js +1 -1
  284. package/build/dist/chunks/{ZOMFHTB2.js → 22TU5PFT.js} +1 -1
  285. package/build/dist/chunks/23HNDJ76.js +2 -0
  286. package/build/dist/chunks/{ZFU65MB4.js → 257N7343.js} +1 -1
  287. package/build/dist/chunks/{F3VDVTMS.js → 27PVS6BU.js} +1 -1
  288. package/build/dist/chunks/{N245WC5R.js → 2JWAFLJU.js} +1 -1
  289. package/build/dist/chunks/{GQYV4TFO.js → 2OVJ2BTJ.js} +1 -1
  290. package/build/dist/chunks/{JS53DQVT.js → 35LXCSHY.js} +1 -1
  291. package/build/dist/chunks/{V37L4DU4.js → 3A2IKFTV.js} +1 -1
  292. package/build/dist/chunks/{OYPAVXGQ.js → 3BMM3V4P.js} +1 -1
  293. package/build/dist/chunks/{ZKZUS3QU.js → 3FU6XP6S.js} +1 -1
  294. package/build/dist/chunks/{BB765L75.js → 3PHJUFU2.js} +1 -1
  295. package/build/dist/chunks/{FWIFTPSE.js → 3PU2SD3U.js} +1 -1
  296. package/build/dist/chunks/{SBY4RJ7I.js → 3ZH5SOC2.js} +1 -1
  297. package/build/dist/chunks/43BG2JRB.js +1 -0
  298. package/build/dist/chunks/{YTLH4M4Y.js → 47HSRR7G.js} +1 -1
  299. package/build/dist/chunks/4NBXBKOX.js +2 -0
  300. package/build/dist/chunks/{EZZM2GQT.js → 4NDIYRH5.js} +1 -1
  301. package/build/dist/chunks/{FOKEFXGP.js → 4PLLS6CT.js} +1 -1
  302. package/build/dist/chunks/4RCYYN6O.js +1 -0
  303. package/build/dist/chunks/{XHYFISVV.js → 4Z3IGMU6.js} +1 -1
  304. package/build/dist/chunks/4ZD5D2UP.js +1 -0
  305. package/build/dist/chunks/{CSDN4MYP.js → 5GQJVKVY.js} +1 -1
  306. package/build/dist/chunks/{QFSBDPLN.js → 65OITTDL.js} +1 -1
  307. package/build/dist/chunks/{4FPV4CRC.js → 6D3XNCOX.js} +1 -1
  308. package/build/dist/chunks/{DSTMEY5F.js → 6F527FLN.js} +1 -1
  309. package/build/dist/chunks/{O3JWCJIF.js → 6GWXPQZ6.js} +1 -1
  310. package/build/dist/chunks/{32RXFUOH.js → 73BZPPRS.js} +1 -1
  311. package/build/dist/chunks/75SULXNT.js +1 -0
  312. package/build/dist/chunks/{WU7XIAXB.js → 7EACRKFV.js} +1 -1
  313. package/build/dist/chunks/{SKEKXEUU.js → 7FIEBJOZ.js} +1 -1
  314. package/build/dist/chunks/{4GNUXN4K.js → 7FZXSYFD.js} +1 -1
  315. package/build/dist/chunks/{ZP36DSOD.js → 7TSIF3F4.js} +1 -1
  316. package/build/dist/chunks/{AMTRDPVO.js → 7U62MMUQ.js} +1 -1
  317. package/build/dist/chunks/{DW4V5PUY.js → 7VH6JQ2H.js} +1 -1
  318. package/build/dist/chunks/A3BJSQ23.js +1 -0
  319. package/build/dist/chunks/{YSMWCKIX.js → ADIPEGNN.js} +1 -1
  320. package/build/dist/chunks/AG2G7BHH.js +6 -0
  321. package/build/dist/chunks/AIYNFIG6.js +1 -0
  322. package/build/dist/chunks/ANIF3JMV.js +4 -0
  323. package/build/dist/chunks/{4JTTA3BX.js → AWV24X7F.js} +1 -1
  324. package/build/dist/chunks/{7QKYDNF6.js → AXHFNE6L.js} +1 -1
  325. package/build/dist/chunks/{WOGWLFAL.js → BGVC5NI6.js} +1 -1
  326. package/build/dist/chunks/BJK75C7G.js +1 -0
  327. package/build/dist/chunks/BSX4LFYI.js +1 -0
  328. package/build/dist/chunks/{OYJFXEDU.js → BZPFPQ2I.js} +1 -1
  329. package/build/dist/chunks/{5PI57UC2.js → C76D54YG.js} +1 -1
  330. package/build/dist/chunks/{TDZTC5WR.js → DBOGRUPS.js} +1 -1
  331. package/build/dist/chunks/{HHO5ISMM.js → DCGNVMKG.js} +1 -1
  332. package/build/dist/chunks/{Y77EVVT4.js → DGDMRATN.js} +1 -1
  333. package/build/dist/chunks/{EGZREEG2.js → DLNA5272.js} +1 -1
  334. package/build/dist/chunks/{TM7Z5SA4.js → DMDOSHV7.js} +1 -1
  335. package/build/dist/chunks/{WHVZ372B.js → DRLBTB4E.js} +1 -1
  336. package/build/dist/chunks/DXAPKN7H.js +1 -0
  337. package/build/dist/chunks/{FZ6IJZZM.js → E76Z2TT4.js} +1 -1
  338. package/build/dist/chunks/{67BWOVET.js → EHGH646D.js} +1 -1
  339. package/build/dist/chunks/{KKPMOAVI.js → ELHRXA5U.js} +1 -1
  340. package/build/dist/chunks/{PZEF5LBL.js → ETMD747Y.js} +1 -1
  341. package/build/dist/chunks/{XCKTE4ON.js → F7MGYRPU.js} +1 -1
  342. package/build/dist/chunks/{MRMR4QHA.js → FAH7FKUT.js} +1 -1
  343. package/build/dist/chunks/FXOFR432.js +1 -0
  344. package/build/dist/chunks/{VHV6WQ5F.js → G2AA73ZE.js} +1 -1
  345. package/build/dist/chunks/{JWR5XVP2.js → GBIBRYOV.js} +1 -1
  346. package/build/dist/chunks/{FNGIJKMZ.js → GDOHHXNH.js} +1 -1
  347. package/build/dist/chunks/{BZ34ZR65.js → GGMVT5A6.js} +1 -1
  348. package/build/dist/chunks/GK3D7OKG.js +1 -0
  349. package/build/dist/chunks/{2OKYXT25.js → GQITAJVF.js} +1 -1
  350. package/build/dist/chunks/GYPMUYB5.js +1 -0
  351. package/build/dist/chunks/H3E7UD2X.js +1 -0
  352. package/build/dist/chunks/{GDRQ2ANN.js → H64QC4QR.js} +1 -1
  353. package/build/dist/chunks/HFVXNKA5.js +1 -0
  354. package/build/dist/chunks/HHYE42JG.js +21 -0
  355. package/build/dist/chunks/{U363GQTF.js → HIG7JY3J.js} +1 -1
  356. package/build/dist/chunks/{XWKK75TO.js → HOBIXKGO.js} +1 -1
  357. package/build/dist/chunks/HQIS3QI7.js +3 -0
  358. package/build/dist/chunks/{UOCRYXAB.js → HRAHGYNK.js} +1 -1
  359. package/build/dist/chunks/{GLF7WEY2.js → HUKDISRE.js} +1 -1
  360. package/build/dist/chunks/{GSFHM5L3.js → HZSYMGJ2.js} +1 -1
  361. package/build/dist/chunks/{FJLJ7ZQ5.js → I4473OC6.js} +1 -1
  362. package/build/dist/chunks/IBL6TL2Q.js +1 -0
  363. package/build/dist/chunks/{3DNJTJ2X.js → IJ4HZIDG.js} +1 -1
  364. package/build/dist/chunks/{OARVU3RC.js → IPU656WB.js} +1 -1
  365. package/build/dist/chunks/{HCBX4NFM.js → IT2JLILU.js} +1 -1
  366. package/build/dist/chunks/{REWXG6X6.js → JDSSYT6R.js} +1 -1
  367. package/build/dist/chunks/{XRDXFHIK.js → JFWJBZ7M.js} +1 -1
  368. package/build/dist/chunks/{TPEKCXVE.js → JTPHZCO3.js} +1 -1
  369. package/build/dist/chunks/{CSOO4SW7.js → K4GUZ5QS.js} +1 -1
  370. package/build/dist/chunks/{BAIY32AV.js → KLEJ3W4T.js} +1 -1
  371. package/build/dist/chunks/{ACH4BSME.js → KOKLM63Q.js} +1 -1
  372. package/build/dist/chunks/{7D73A6KS.js → KVVBT43U.js} +1 -1
  373. package/build/dist/chunks/{CO4GCF4L.js → KXX7ZBFY.js} +1 -1
  374. package/build/dist/chunks/{I6PQW2JI.js → L2AE32SL.js} +1 -1
  375. package/build/dist/chunks/{WUT7TZYM.js → LCH6F5HT.js} +1 -1
  376. package/build/dist/chunks/LEV5SNNC.js +3 -0
  377. package/build/dist/chunks/{SPRVVJXI.js → LFSJDFMY.js} +1 -1
  378. package/build/dist/chunks/{6UVGQYZ3.js → LGLWEGPY.js} +1 -1
  379. package/build/dist/chunks/{PV4AK32X.js → LQSPWRHN.js} +1 -1
  380. package/build/dist/chunks/{C3WBHFLX.js → LTDF2LNP.js} +1 -1
  381. package/build/dist/chunks/{5HIHUYA4.js → M4AGEGWW.js} +1 -1
  382. package/build/dist/chunks/{ARI72OYT.js → M6SQPOOL.js} +1 -1
  383. package/build/dist/chunks/{SOTYQGPT.js → M7CQPTRK.js} +1 -1
  384. package/build/dist/chunks/{XPEDQBLI.js → MGVX5EUH.js} +1 -1
  385. package/build/dist/chunks/{C5ZZAYXD.js → MI5HZDMH.js} +1 -1
  386. package/build/dist/chunks/{APHNOGNS.js → MQ37QX6U.js} +1 -1
  387. package/build/dist/chunks/MQ5F2VOK.js +1 -0
  388. package/build/dist/chunks/{JKD2B6OX.js → MSRCJ2BS.js} +1 -1
  389. package/build/dist/chunks/{JKRBGAX2.js → NAO7VWZF.js} +1 -1
  390. package/build/dist/chunks/{RLMVA575.js → NDSNE6PS.js} +1 -1
  391. package/build/dist/chunks/{RT7IU6TI.js → NMJVQX5M.js} +1 -1
  392. package/build/dist/chunks/NQ4MTIU3.js +1 -0
  393. package/build/dist/chunks/{IEG6GLFR.js → NTUXDIY6.js} +1 -1
  394. package/build/dist/chunks/{F4UQEPJT.js → NUERUFH7.js} +1 -1
  395. package/build/dist/chunks/NV6FDIYT.js +1 -0
  396. package/build/dist/chunks/O2J5I4VA.js +1 -0
  397. package/build/dist/chunks/{XVJ7ILKK.js → O3CC5SRM.js} +1 -1
  398. package/build/dist/chunks/{2SUHQWND.js → O4S6XAYV.js} +1 -1
  399. package/build/dist/chunks/{TAEZTP4L.js → O5QTITN6.js} +1 -1
  400. package/build/dist/chunks/{NA424YAL.js → OB7BFDOV.js} +1 -1
  401. package/build/dist/chunks/{523ZIR3J.js → ODV3XT5U.js} +1 -1
  402. package/build/dist/chunks/{GW5IXLKU.js → OI3N4EW4.js} +1 -1
  403. package/build/dist/chunks/{FL5SSHUL.js → OIQTZOBN.js} +1 -1
  404. package/build/dist/chunks/OLDQV43V.js +1 -0
  405. package/build/dist/chunks/OOPMZIG7.js +1 -0
  406. package/build/dist/chunks/{XYPGLG6A.js → OSMOBKRQ.js} +1 -1
  407. package/build/dist/chunks/{OZ5MDUD2.js → OVM4QIET.js} +1 -1
  408. package/build/dist/chunks/{N4XNNXOJ.js → OY5W7ZSL.js} +1 -1
  409. package/build/dist/chunks/{GRSXWQWD.js → PDGYM2WG.js} +1 -1
  410. package/build/dist/chunks/{UQEEF5W5.js → PDPTJMTJ.js} +1 -1
  411. package/build/dist/chunks/PEHXHQVA.js +1 -0
  412. package/build/dist/chunks/{JOKL5L6X.js → PKYQ3XVA.js} +1 -1
  413. package/build/dist/chunks/PMFR47H3.js +1 -0
  414. package/build/dist/chunks/{N6GIC7HJ.js → PWJVC2FV.js} +1 -1
  415. package/build/dist/chunks/{753HZZTY.js → QBYV7NXH.js} +1 -1
  416. package/build/dist/chunks/QHV5GORV.js +1 -0
  417. package/build/dist/chunks/{2LWBN35N.js → QIB6OMQV.js} +1 -1
  418. package/build/dist/chunks/{TK55VASJ.js → QMNUB2GM.js} +1 -1
  419. package/build/dist/chunks/{HKVQ646Q.js → QN45T4N3.js} +1 -1
  420. package/build/dist/chunks/{J73ATSEQ.js → QPY6UTLU.js} +1 -1
  421. package/build/dist/chunks/{YUHNPUNK.js → R73R4KN3.js} +1 -1
  422. package/build/dist/chunks/{RLI4JDOL.js → RA7DOR7F.js} +1 -1
  423. package/build/dist/chunks/{VR344DAZ.js → RN3WUJIO.js} +1 -1
  424. package/build/dist/chunks/RUSXMQSJ.js +1 -0
  425. package/build/dist/chunks/{D742AYEV.js → RUTSEGGD.js} +1 -1
  426. package/build/dist/chunks/{4Q2ZBZXM.js → RXP7ZUPY.js} +1 -1
  427. package/build/dist/chunks/{TFDPEAVZ.js → S4JUFCT4.js} +1 -1
  428. package/build/dist/chunks/{DYYEA5HB.js → SMKO7GKX.js} +1 -1
  429. package/build/dist/chunks/{C75MT5SD.js → SNCV6HV7.js} +1 -1
  430. package/build/dist/chunks/{HIX5N25Z.js → SOJHYMD7.js} +1 -1
  431. package/build/dist/chunks/{JLRHM2DQ.js → SUNTJ6IU.js} +1 -1
  432. package/build/dist/chunks/{4JRXEN7C.js → THL4TMQW.js} +2 -2
  433. package/build/dist/chunks/TI727O2H.js +1 -0
  434. package/build/dist/chunks/{PV5FDT6O.js → TXGZ6NWN.js} +1 -1
  435. package/build/dist/chunks/{Q2ACLVWR.js → UBI3HBXD.js} +1 -1
  436. package/build/dist/chunks/{YMV5TL5C.js → UEHN2IDF.js} +1 -1
  437. package/build/dist/chunks/{ZF2VPDRQ.js → UHIJMDD2.js} +1 -1
  438. package/build/dist/chunks/UJQYOTO5.js +1 -0
  439. package/build/dist/chunks/{VTPT5544.js → USEF3QKG.js} +1 -1
  440. package/build/dist/chunks/{LR4XTZ37.js → UYULQHZJ.js} +1 -1
  441. package/build/dist/chunks/{YWZQJJYY.js → V4UJMUIB.js} +1 -1
  442. package/build/dist/chunks/{7VC53B5X.js → V5YSJKRH.js} +13 -13
  443. package/build/dist/chunks/{INOYMBWE.js → VC5ZCQYZ.js} +1 -1
  444. package/build/dist/chunks/{M7ZXDLKM.js → VDJPDIBV.js} +1 -1
  445. package/build/dist/chunks/{2FHELZ7Y.js → VFM2BICB.js} +1 -1
  446. package/build/dist/chunks/{TE6D3OIX.js → VOJULRNU.js} +1 -1
  447. package/build/dist/chunks/{UEDGYZOC.js → VVAM3EAK.js} +1 -1
  448. package/build/dist/chunks/VVJO6OYK.js +1 -0
  449. package/build/dist/chunks/{JESMX2UC.js → VXCGMALF.js} +1 -1
  450. package/build/dist/chunks/{NUFZUKYS.js → W32UECOL.js} +1 -1
  451. package/build/dist/chunks/{UUID2E22.js → W3DGFMQE.js} +1 -1
  452. package/build/dist/chunks/W7OCS4AM.js +6 -0
  453. package/build/dist/chunks/{DNNFKDZR.js → W7QNSNOH.js} +1 -1
  454. package/build/dist/chunks/{2MZXTOZU.js → WAKZWSHB.js} +1 -1
  455. package/build/dist/chunks/{HM72DH4V.js → WRUTW6CG.js} +1 -1
  456. package/build/dist/chunks/{VYYSL557.js → WSILNJS2.js} +1 -1
  457. package/build/dist/chunks/{L646YWDP.js → X24YTJST.js} +1 -1
  458. package/build/dist/chunks/{FOD34G2H.js → XL3W7DAQ.js} +1 -1
  459. package/build/dist/chunks/{2E4I7CJ7.js → XRDLMTBJ.js} +1 -1
  460. package/build/dist/chunks/{GG24LO2R.js → XVOW6UCI.js} +1 -1
  461. package/build/dist/chunks/XW3VGWXK.js +1 -0
  462. package/build/dist/chunks/{6WD4HHID.js → Y2QADJOB.js} +1 -1
  463. package/build/dist/chunks/Y64GFBTA.js +1 -0
  464. package/build/dist/chunks/Y7HBFQYG.js +1 -0
  465. package/build/dist/chunks/{ARLGF5MU.js → YGW4ODAP.js} +1 -1
  466. package/build/dist/chunks/YRSAZTTC.js +7 -0
  467. package/build/dist/chunks/YW4W3LPQ.js +1 -0
  468. package/build/dist/chunks/{3VBIRLU3.js → YXXK6EPI.js} +1 -1
  469. package/build/dist/chunks/{EH5G4O3U.js → Z2QV6EZY.js} +1 -1
  470. package/build/dist/chunks/Z3IBPCY4.js +2 -0
  471. package/build/dist/chunks/{H5DY7CNB.js → Z7FGEWO2.js} +1 -1
  472. package/build/dist/chunks/{KDGSYNOP.js → ZDCCFEVL.js} +1 -1
  473. package/build/dist/chunks/{4RQAOOO2.js → ZOLHVZDK.js} +1 -1
  474. package/build/dist/chunks/{AI3VAPA3.js → ZSVAGOF2.js} +1 -1
  475. package/build/dist/chunks/{EVBHQQQG.js → ZTKT3ZQK.js} +1 -1
  476. package/build/dist/chunks/{4BVP652W.js → ZZ6FZGHF.js} +1 -1
  477. package/package.json +1 -1
  478. package/build/dist/chunks/3K2N5VFH.js +0 -1
  479. package/build/dist/chunks/3ZABD6ZF.js +0 -2
  480. package/build/dist/chunks/44MB6SA6.js +0 -1
  481. package/build/dist/chunks/4D4ZRZUW.js +0 -1
  482. package/build/dist/chunks/4OVIMYNH.js +0 -2
  483. package/build/dist/chunks/6NUNCD5J.js +0 -1
  484. package/build/dist/chunks/6PZGDVHV.js +0 -1
  485. package/build/dist/chunks/7MBVTNLU.js +0 -1
  486. package/build/dist/chunks/7VNO46LV.js +0 -1
  487. package/build/dist/chunks/CAWTAR5V.js +0 -1
  488. package/build/dist/chunks/DPE7SPW7.js +0 -1
  489. package/build/dist/chunks/E3RACZUY.js +0 -1
  490. package/build/dist/chunks/EI6GGPDS.js +0 -20
  491. package/build/dist/chunks/FV4WZOTD.js +0 -1
  492. package/build/dist/chunks/FWD4L3CJ.js +0 -1
  493. package/build/dist/chunks/JBTOZ6IH.js +0 -1
  494. package/build/dist/chunks/KREBNL2D.js +0 -1
  495. package/build/dist/chunks/MVD3KWPP.js +0 -1
  496. package/build/dist/chunks/P6OMKZMR.js +0 -3
  497. package/build/dist/chunks/PXVREXCS.js +0 -1
  498. package/build/dist/chunks/QJNLLI6N.js +0 -1
  499. package/build/dist/chunks/RPB46QAC.js +0 -1
  500. package/build/dist/chunks/TID4C2KC.js +0 -1
  501. package/build/dist/chunks/U2YCQWZK.js +0 -1
  502. package/build/dist/chunks/UWBKAWX3.js +0 -7
  503. package/build/dist/chunks/V6SDKPZS.js +0 -1
  504. package/build/dist/chunks/WHTRPRRD.js +0 -1
  505. package/build/dist/chunks/WLMWWEP7.js +0 -2
  506. package/build/dist/chunks/XQ24RSEI.js +0 -1
  507. package/build/dist/chunks/YDNTY67T.js +0 -1
  508. package/build/dist/chunks/ZQAFFWDK.js +0 -1
@@ -1 +1 @@
1
- import{c as me}from"./BB765L75.js";import{a as fe}from"./HHO5ISMM.js";import{a as Z}from"./PV4AK32X.js";import{a as M,b as P}from"./H5DY7CNB.js";import{a as L}from"./UEDGYZOC.js";import{a as ue}from"./P4UQGWCP.js";import{a as x}from"./43LI5NKJ.js";import{b as de,c as le}from"./SCG5HWMN.js";import{a as re,b as X,c as j}from"./5HCXZWUH.js";import{m as ie,o as F,p as ce}from"./6NUNCD5J.js";import{a as w,b as _,c as B,d as oe,i as E,j as ae,s as N}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 De,encodeFunctionData as ve,erc20Abi as Y,getAddress as b,isAddress as G,parseAbi as ne}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,n=w,s={}){let t=Array.isArray(e)?e:K(e)&&Array.isArray(e.assets)?e.assets:void 0;if(!t)throw new k("Official stock asset list response is malformed.");let a=new Map,d=new Map;if(t.length>1e4)throw new k("Official stock asset list exceeds the lookup limit.");for(let o of t){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!==n)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:n,...s.includeNames&&typeof r.tokenName=="string"&&r.tokenName.trim()?{name:r.tokenName.trim()}:{}})}}return[...a.values()]}function Ee(e,n){if(typeof e.address!="string"||!G(e.address,{strict:!1}))return!1;let s=e.chainId??w,t=e.address.toLowerCase();return n.some(a=>a.chainId===s&&a.address.toLowerCase()===t&&a.symbol===e.symbol)}function W(e,n){x(e.address);let s=e.chainId??w,t=b(e.address),a=t.toLowerCase(),d=O(e.symbol),o=n.find(l=>l.chainId===s&&l.address.toLowerCase()===a),r=n.find(l=>l.chainId===s&&O(l.symbol)===d);if(o){if(e.symbol!==o.symbol)throw new k(`Token at ${t} 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 ${t} does not match official decimals ${o.decimals}.`);return o}if(r)throw new k(`Token symbol ${p(e.symbol)} at ${t} does not match the official stock contract address ${r.address}.`);return{address:t,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([]),D;function tt(){if(!D)return he;let e=Date.now()-D.started;return e>=0&&e<ge?D.tokens:he}var ee=new WeakMap;function H(e,n){return(ee.get(e)??F)(n)}async function Ae(e){let n=e?.http??de(),s=e?.url??z,t=e?.chainId??w,a=j(n),d=ke.get(a);d||(d=new re(ge),ke.set(a,d));let{value:o,started:r}=await H(n,()=>d.read(`${t}:${s}`,async()=>{let u=await F(h=>le(a,s,{method:"GET",signal:h},y=>K(y)||Array.isArray(y))),m=$(u,t,{allowAmbiguousSymbols:!0});if(t===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,t,e);if(t===w&&s===z&&(!D||r>=D.started||Date.now()<D.started)&&(D={started:r,tokens:Object.freeze($(o,t,{allowAmbiguousSymbols:!0}).map(u=>Object.freeze(u)))}),t===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=ne(["function aggregate3((address target, bool allowFailure, bytes callData)[] calls) payable returns ((bool success, bytes returnData)[] returnData)"]);function ye(e){let n=e,s=new Set;for(;n&&typeof n=="object"&&!s.has(n)&&s.size<10;){s.add(n);let t=n;if(t.name==="ContractFunctionZeroDataError"||t.name==="AbiDecodingZeroDataError")return!0;let a=`${typeof t.shortMessage=="string"?t.shortMessage:""} ${typeof t.message=="string"?t.message:""}`;if(/returned no data \("0x"\)|Cannot decode zero data/i.test(a))return!0;n=t.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,n,s){if(typeof e.getCode=="function")try{let t=await e.getCode({address:n});return!t||t==="0x"}catch{return ye(s)}return ye(s)}async function Te(e,n,s){if(n.length===0)return[];let t=await Promise.allSettled(n.map(a=>e.readContract({address:a.address,abi:Y,functionName:"balanceOf",args:[s]})));if(t.every(a=>a.status==="rejected")&&t[0]?.status==="rejected"&&Re(t[0].reason))throw t[0].reason;return t.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,n,s,t){if(s.length===0)return[];let a=ie(n,e);if(!a)return Te(e,s,t);let d=s.map(r=>({target:r.address,allowFailure:!0,callData:ve({abi:Y,functionName:"balanceOf",args:[t]})})),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,t);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=De({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 nt(e,n={}){x(e);let s=b(e),t=n.chainId??w,a=n.client??ce(n.rpcUrl,t),d=[];if(n.stockTokens?d=[...n.stockTokens]:n.stockAssetsPayload!==void 0?d=$(n.stockAssetsPayload,t):n.includeStockTokens!==!1&&t!==_&&(d=await Ae({http:n.http,url:n.stockAssetsUrl,chainId:t})),n.tokens)for(let i of n.tokens)W(i,d);let o=t===w?[Q,J,we,...n.oakTokenAddress||process.env.OAK_TOKEN_ADDRESS?[{address:b(n.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS),symbol:"OAK",decimals:B,chainId:t}]:[]]:t===_?[{...Q,address:b(N.testnet.usdg),chainId:t},{...J,address:b(N.testnet.weth),chainId:t},...n.oakTokenAddress?[{address:b(n.oakTokenAddress),symbol:"OAK",decimals:B,chainId:t}]:[]]:[],r=t===w&&n.includePoolTokens!==!1?ue.vaults.flatMap(i=>[{address:b(i.tokenAddress),symbol:b(i.tokenAddress),decimals:i.tokenDecimals,chainId:t},{address:b(i.earnContractAddress),symbol:b(i.earnContractAddress),decimals:18,chainId:t}]):[],l=new Set(r.map(i=>i.address.toLowerCase())),u=[],m=new Set;for(let i of[...o,...d,...n.tokens??[],...r]){if(i.chainId!==t||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,t,u,s)]),f=[],g={address:M,symbol:"ETH",decimals:18,chainId:t};(h>0n||n.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,t,c.address,"symbol"),L(a,t,c.address,"decimals")]);T=p(S),c.decimals=R}catch{}(A>0n||n.includeZero)&&f.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:A.toString()})}return f}async function st(e,n,s){if(x(e),n.length>1e4)throw new k("Journal token discovery exceeds the balance lookup limit.");let t=[...new Set(n.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,t,b(e)),d=t.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,n)=>e.toLowerCase()===n.toLowerCase(),O=e=>se(e.normalize("NFKC")).toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");function Oe(e){let n=e.context.network??"mainnet",{chainId:s,usdg:t,weth:a}=N[n],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:t,chainId:s},"Global Dollar","stablecoin"),d({...J,address:a,chainId:s},"Wrapped Ether","wrapped"),...n==="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 n=e.officialStockTokens??await Ae({http:e.context.http,includeNames:!0,allowAmbiguousSymbols:!0});return n.filter(s=>Ee(s,n)).map(s=>({...s,name:s.name??s.symbol,kind:"official_stock",verified:!0,source:z,warnings:[],identityNote:"Official Robinhood stock token: this address matches Robinhood's published list. The quoted name is text from that list."}))}async function te(e,n,s=!0){let{chainId:t}=N[n.context.network??"mainnet"],a=n.context.clientFor(t);if(await a.getChainId()!==t)throw new k(`Token lookup requires Robinhood Chain ${t}.`);let[d,o,r]=await Promise.all([H(a,()=>L(a,t,e,"name",n.blockNumber)).catch(l=>{if(s)throw l;return""}),H(a,()=>L(a,t,e,"symbol",n.blockNumber)),H(a,()=>L(a,t,e,"decimals",n.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:t}}async function be(e,n){let s=await n.context.clientFor(w).readContract({address:E[w].clanker.factory.address,abi:ne(["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,n){let s=n.context.clientFor(w),t=E[w].poolsTrade,a=[t.instantLaunchStrategyFeesOn.address,t.instantLaunchStrategyFeesOff.address],d=ne(["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 n=Date.now()+Ke,s=0,t=new Map,a=o=>{let r=n-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(!t.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)};t.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(t.get(o),l)}return t.get(o)}}}}function pe(e){return e.source==="Oak fixed addresses"?e:{...e,symbol:p(e.symbol),name:p(e.name)}}async function ot(e,n){if(n=Le(n),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),t=G(e.trim(),{strict:!1})?P(b(e.trim())):void 0,{chainId:a}=N[n.context.network??"mainnet"],d=[],o=Oe(n),r=!1;try{o.push(...await Ce(n))}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=>t?C(i.address,t):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(t&&!u.length){let i=await te(t,n),c={};if(a===w){try{await be(t,n)&&(c.launchpad="clanker")}catch{d.push("Clanker origin lookup was unavailable for this address.")}if(c.launchpad==="clanker")try{let I=(await Z(n.context,{q:t,limit:20})).tokens.find(A=>C(A.contract_address,t));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(n.context,t);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(t,n);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(!t&&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(n.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 te(v,n);if(!l(U))continue;let Ne=await be(v,n)?{launchpad:"clanker",creator:b(R.msg_sender),creatorSource:"Clanker indexer msg_sender"}:{};y(U,Ne)}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 at(e,n){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,t=G(s,{strict:!1})?P(b(s)):void 0,a=Oe(n),d=t&&a.find(y=>C(y.address,t));if(d)return d;let o=s.toUpperCase()==="$OAK"?"OAK":s.toUpperCase(),r=!t&&a.find(y=>y.symbol.toUpperCase()===o),l=[],u=!1;try{l=await Ce(n)}catch{if(r)return r;if(!t)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(t){let y=l.find(i=>C(i.address,t));if(y)return n.tokenMetadata&&W(n.tokenMetadata,l),{...y,name:p(y.name)};let f=n.tokenMetadata??await n.readMetadata?.(t);if(f&&(!C(f.address,t)||f.chainId!==N[n.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 te(t,Le(n),!1);if(u){let i=O(g.symbol),c=q.get(j(n.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,tt as i,Ae as j,Me as k,nt as l,st as m,ot as n,at as o};
1
+ import{a as fe}from"./DCGNVMKG.js";import{c as me}from"./3PHJUFU2.js";import{a as Z}from"./LQSPWRHN.js";import{a as M,b as P}from"./Z7FGEWO2.js";import{a as L}from"./VVAM3EAK.js";import{a as ue}from"./P4UQGWCP.js";import{a as x}from"./43LI5NKJ.js";import{b as de,c as le}from"./SCG5HWMN.js";import{a as re,b as X,c as j}from"./5HCXZWUH.js";import{q as ie,s as F,t as ce}from"./MQ5F2VOK.js";import{b as w,c as _,d as B,e as oe,j as E,k as ae,t as N}from"./TI727O2H.js";import{a as k}from"./XSD5NL7J.js";import{a as p,b as V,c as se}from"./JXOEJPJ4.js";import{decodeFunctionResult as De,encodeFunctionData as ve,erc20Abi as Y,getAddress as b,isAddress as G,parseAbi as ne}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,n=w,s={}){let t=Array.isArray(e)?e:K(e)&&Array.isArray(e.assets)?e.assets:void 0;if(!t)throw new k("Official stock asset list response is malformed.");let a=new Map,d=new Map;if(t.length>1e4)throw new k("Official stock asset list exceeds the lookup limit.");for(let o of t){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!==n)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:n,...s.includeNames&&typeof r.tokenName=="string"&&r.tokenName.trim()?{name:r.tokenName.trim()}:{}})}}return[...a.values()]}function Ee(e,n){if(typeof e.address!="string"||!G(e.address,{strict:!1}))return!1;let s=e.chainId??w,t=e.address.toLowerCase();return n.some(a=>a.chainId===s&&a.address.toLowerCase()===t&&a.symbol===e.symbol)}function W(e,n){x(e.address);let s=e.chainId??w,t=b(e.address),a=t.toLowerCase(),d=O(e.symbol),o=n.find(l=>l.chainId===s&&l.address.toLowerCase()===a),r=n.find(l=>l.chainId===s&&O(l.symbol)===d);if(o){if(e.symbol!==o.symbol)throw new k(`Token at ${t} 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 ${t} does not match official decimals ${o.decimals}.`);return o}if(r)throw new k(`Token symbol ${p(e.symbol)} at ${t} does not match the official stock contract address ${r.address}.`);return{address:t,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([]),D;function tt(){if(!D)return he;let e=Date.now()-D.started;return e>=0&&e<ge?D.tokens:he}var ee=new WeakMap;function H(e,n){return(ee.get(e)??F)(n)}async function Ae(e){let n=e?.http??de(),s=e?.url??z,t=e?.chainId??w,a=j(n),d=ke.get(a);d||(d=new re(ge),ke.set(a,d));let{value:o,started:r}=await H(n,()=>d.read(`${t}:${s}`,async()=>{let u=await F(h=>le(a,s,{method:"GET",signal:h},y=>K(y)||Array.isArray(y))),m=$(u,t,{allowAmbiguousSymbols:!0});if(t===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,t,e);if(t===w&&s===z&&(!D||r>=D.started||Date.now()<D.started)&&(D={started:r,tokens:Object.freeze($(o,t,{allowAmbiguousSymbols:!0}).map(u=>Object.freeze(u)))}),t===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=ne(["function aggregate3((address target, bool allowFailure, bytes callData)[] calls) payable returns ((bool success, bytes returnData)[] returnData)"]);function ye(e){let n=e,s=new Set;for(;n&&typeof n=="object"&&!s.has(n)&&s.size<10;){s.add(n);let t=n;if(t.name==="ContractFunctionZeroDataError"||t.name==="AbiDecodingZeroDataError")return!0;let a=`${typeof t.shortMessage=="string"?t.shortMessage:""} ${typeof t.message=="string"?t.message:""}`;if(/returned no data \("0x"\)|Cannot decode zero data/i.test(a))return!0;n=t.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,n,s){if(typeof e.getCode=="function")try{let t=await e.getCode({address:n});return!t||t==="0x"}catch{return ye(s)}return ye(s)}async function Te(e,n,s){if(n.length===0)return[];let t=await Promise.allSettled(n.map(a=>e.readContract({address:a.address,abi:Y,functionName:"balanceOf",args:[s]})));if(t.every(a=>a.status==="rejected")&&t[0]?.status==="rejected"&&Re(t[0].reason))throw t[0].reason;return t.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,n,s,t){if(s.length===0)return[];let a=ie(n,e);if(!a)return Te(e,s,t);let d=s.map(r=>({target:r.address,allowFailure:!0,callData:ve({abi:Y,functionName:"balanceOf",args:[t]})})),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,t);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=De({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 nt(e,n={}){x(e);let s=b(e),t=n.chainId??w,a=n.client??ce(n.rpcUrl,t),d=[];if(n.stockTokens?d=[...n.stockTokens]:n.stockAssetsPayload!==void 0?d=$(n.stockAssetsPayload,t):n.includeStockTokens!==!1&&t!==_&&(d=await Ae({http:n.http,url:n.stockAssetsUrl,chainId:t})),n.tokens)for(let i of n.tokens)W(i,d);let o=t===w?[Q,J,we,...n.oakTokenAddress||process.env.OAK_TOKEN_ADDRESS?[{address:b(n.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS),symbol:"OAK",decimals:B,chainId:t}]:[]]:t===_?[{...Q,address:b(N.testnet.usdg),chainId:t},{...J,address:b(N.testnet.weth),chainId:t},...n.oakTokenAddress?[{address:b(n.oakTokenAddress),symbol:"OAK",decimals:B,chainId:t}]:[]]:[],r=t===w&&n.includePoolTokens!==!1?ue.vaults.flatMap(i=>[{address:b(i.tokenAddress),symbol:b(i.tokenAddress),decimals:i.tokenDecimals,chainId:t},{address:b(i.earnContractAddress),symbol:b(i.earnContractAddress),decimals:18,chainId:t}]):[],l=new Set(r.map(i=>i.address.toLowerCase())),u=[],m=new Set;for(let i of[...o,...d,...n.tokens??[],...r]){if(i.chainId!==t||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,t,u,s)]),f=[],g={address:M,symbol:"ETH",decimals:18,chainId:t};(h>0n||n.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,t,c.address,"symbol"),L(a,t,c.address,"decimals")]);T=p(S),c.decimals=R}catch{}(A>0n||n.includeZero)&&f.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:A.toString()})}return f}async function st(e,n,s){if(x(e),n.length>1e4)throw new k("Journal token discovery exceeds the balance lookup limit.");let t=[...new Set(n.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,t,b(e)),d=t.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,n)=>e.toLowerCase()===n.toLowerCase(),O=e=>se(e.normalize("NFKC")).toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");function Oe(e){let n=e.context.network??"mainnet",{chainId:s,usdg:t,weth:a}=N[n],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:t,chainId:s},"Global Dollar","stablecoin"),d({...J,address:a,chainId:s},"Wrapped Ether","wrapped"),...n==="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 n=e.officialStockTokens??await Ae({http:e.context.http,includeNames:!0,allowAmbiguousSymbols:!0});return n.filter(s=>Ee(s,n)).map(s=>({...s,name:s.name??s.symbol,kind:"official_stock",verified:!0,source:z,warnings:[],identityNote:"Official Robinhood stock token: this address matches Robinhood's published list. The quoted name is text from that list."}))}async function te(e,n,s=!0){let{chainId:t}=N[n.context.network??"mainnet"],a=n.context.clientFor(t);if(await a.getChainId()!==t)throw new k(`Token lookup requires Robinhood Chain ${t}.`);let[d,o,r]=await Promise.all([H(a,()=>L(a,t,e,"name",n.blockNumber)).catch(l=>{if(s)throw l;return""}),H(a,()=>L(a,t,e,"symbol",n.blockNumber)),H(a,()=>L(a,t,e,"decimals",n.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:t}}async function be(e,n){let s=await n.context.clientFor(w).readContract({address:E[w].clanker.factory.address,abi:ne(["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,n){let s=n.context.clientFor(w),t=E[w].poolsTrade,a=[t.instantLaunchStrategyFeesOn.address,t.instantLaunchStrategyFeesOff.address],d=ne(["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 n=Date.now()+Ke,s=0,t=new Map,a=o=>{let r=n-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(!t.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)};t.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(t.get(o),l)}return t.get(o)}}}}function pe(e){return e.source==="Oak fixed addresses"?e:{...e,symbol:p(e.symbol),name:p(e.name)}}async function ot(e,n){if(n=Le(n),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),t=G(e.trim(),{strict:!1})?P(b(e.trim())):void 0,{chainId:a}=N[n.context.network??"mainnet"],d=[],o=Oe(n),r=!1;try{o.push(...await Ce(n))}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=>t?C(i.address,t):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(t&&!u.length){let i=await te(t,n),c={};if(a===w){try{await be(t,n)&&(c.launchpad="clanker")}catch{d.push("Clanker origin lookup was unavailable for this address.")}if(c.launchpad==="clanker")try{let I=(await Z(n.context,{q:t,limit:20})).tokens.find(A=>C(A.contract_address,t));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(n.context,t);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(t,n);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(!t&&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(n.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 te(v,n);if(!l(U))continue;let Ne=await be(v,n)?{launchpad:"clanker",creator:b(R.msg_sender),creatorSource:"Clanker indexer msg_sender"}:{};y(U,Ne)}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 at(e,n){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,t=G(s,{strict:!1})?P(b(s)):void 0,a=Oe(n),d=t&&a.find(y=>C(y.address,t));if(d)return d;let o=s.toUpperCase()==="$OAK"?"OAK":s.toUpperCase(),r=!t&&a.find(y=>y.symbol.toUpperCase()===o),l=[],u=!1;try{l=await Ce(n)}catch{if(r)return r;if(!t)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(t){let y=l.find(i=>C(i.address,t));if(y)return n.tokenMetadata&&W(n.tokenMetadata,l),{...y,name:p(y.name)};let f=n.tokenMetadata??await n.readMetadata?.(t);if(f&&(!C(f.address,t)||f.chainId!==N[n.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 te(t,Le(n),!1);if(u){let i=O(g.symbol),c=q.get(j(n.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,tt as i,Ae as j,Me as k,nt as l,st as m,ot as n,at as o};
@@ -1 +1 @@
1
- import{a as e,d as t,i as r}from"./FWD4L3CJ.js";import{getAddress as s,parseAbi as a}from"viem";var n=r[e],u=s(n.layerbank.pool.address),o=s(n.layerbank.aToken.address),c={address:s(n.tokens.USDG.address),symbol:"USDG",decimals:t,chainId:e},l={address:o,symbol:"lRobUSDG",decimals:t,chainId:e},p=(1n<<256n)-1n,f=10n**27n,m=a(["function getReserveData(address asset) view returns (((uint256 data) configuration,uint128 liquidityIndex,uint128 currentLiquidityRate,uint128 variableBorrowIndex,uint128 currentVariableBorrowRate,uint128 currentStableBorrowRate,uint40 lastUpdateTimestamp,uint16 id,address aTokenAddress,address stableDebtTokenAddress,address variableDebtTokenAddress,address interestRateStrategyAddress,uint128 accruedToTreasury,uint128 unbacked,uint128 isolationModeTotalDebt) reserve)","function getConfiguration(address asset) view returns ((uint256 data) configuration)","function getReserveNormalizedIncome(address asset) view returns (uint256)","function supply(address asset,uint256 amount,address onBehalfOf,uint16 referralCode)","function withdraw(address asset,uint256 amount,address to) returns (uint256)"]),b=a(["function POOL() view returns (address)","function UNDERLYING_ASSET_ADDRESS() view returns (address)","function decimals() view returns (uint8)","function scaledTotalSupply() view returns (uint256)"]);export{u as a,o as b,c,l as d,p as e,f,m as g,b as h};
1
+ import{b as e,e as t,j as r}from"./TI727O2H.js";import{getAddress as s,parseAbi as a}from"viem";var n=r[e],u=s(n.layerbank.pool.address),o=s(n.layerbank.aToken.address),c={address:s(n.tokens.USDG.address),symbol:"USDG",decimals:t,chainId:e},l={address:o,symbol:"lRobUSDG",decimals:t,chainId:e},p=(1n<<256n)-1n,f=10n**27n,m=a(["function getReserveData(address asset) view returns (((uint256 data) configuration,uint128 liquidityIndex,uint128 currentLiquidityRate,uint128 variableBorrowIndex,uint128 currentVariableBorrowRate,uint128 currentStableBorrowRate,uint40 lastUpdateTimestamp,uint16 id,address aTokenAddress,address stableDebtTokenAddress,address variableDebtTokenAddress,address interestRateStrategyAddress,uint128 accruedToTreasury,uint128 unbacked,uint128 isolationModeTotalDebt) reserve)","function getConfiguration(address asset) view returns ((uint256 data) configuration)","function getReserveNormalizedIncome(address asset) view returns (uint256)","function supply(address asset,uint256 amount,address onBehalfOf,uint16 referralCode)","function withdraw(address asset,uint256 amount,address to) returns (uint256)"]),b=a(["function POOL() view returns (address)","function UNDERLYING_ASSET_ADDRESS() view returns (address)","function decimals() view returns (uint8)","function scaledTotalSupply() view returns (uint256)"]);export{u as a,o as b,c,l as d,p as e,f,m as g,b as h};
@@ -1 +1 @@
1
- import{b as o,g as s}from"./NWNYJ26T.js";import{a as i,s as r}from"./FWD4L3CJ.js";var d=new Set(["0x0000000000000000000000000000000000000000","0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",r.mainnet.usdg.toLowerCase()]);function a(f,e,n){if(f!=="relay_bridge_in"||e.swap!==void 0||typeof n!="string"||!o.test(n)||e.destinationChainId!==void 0&&e.destinationChainId!==i||e.recipient!==void 0&&(typeof e.recipient!="string"||!s(e.recipient,n)))return!1;let t=e.destinationCurrency??"0x0000000000000000000000000000000000000000";return typeof t=="string"&&d.has(t.toLowerCase())}export{a};
1
+ import{b as o,g as s}from"./NWNYJ26T.js";import{b as i,t as r}from"./TI727O2H.js";var d=new Set(["0x0000000000000000000000000000000000000000","0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",r.mainnet.usdg.toLowerCase()]);function a(f,e,n){if(f!=="relay_bridge_in"||e.swap!==void 0||typeof n!="string"||!o.test(n)||e.destinationChainId!==void 0&&e.destinationChainId!==i||e.recipient!==void 0&&(typeof e.recipient!="string"||!s(e.recipient,n)))return!1;let t=e.destinationCurrency??"0x0000000000000000000000000000000000000000";return typeof t=="string"&&d.has(t.toLowerCase())}export{a};
@@ -1 +1 @@
1
- import{b as D}from"./IX3GZMTM.js";import{a as d}from"./FWD4L3CJ.js";import{a as c}from"./XSD5NL7J.js";import{concat as B,encodeAbiParameters as k,getAddress as v,isAddress as F,keccak256 as g,parseAbiParameters as O,recoverAddress as q,toHex as N}from"viem";import{privateKeyToAccount as U}from"viem/accounts";var T="OakPriceNote",l="1",w=300,E="0x0000000000000000000000000000000000000000",W=g(N("PriceNote(address wallet,uint256 oakPerEthE18,uint64 timestamp,bytes32 nonce)")),L=g(N("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")),M=(1n<<64n)-1n,P=(1n<<256n)-1n,z=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,G=0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0n;function X(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{130}$/.test(e))return!1;let n=BigInt(`0x${e.slice(2,66)}`),t=BigInt(`0x${e.slice(66,130)}`),i=Number.parseInt(e.slice(130,132),16);return!(i!==27&&i!==28||n<=0n||n>=z||t<=0n||t>G)}function m(e,n){if(typeof e!="string"||!F(e,{strict:!1}))throw new c(`Invalid ${n} address.`);return v(e)}function p(e,n){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"){if(!Number.isSafeInteger(e)||e<0)throw new c(`Invalid ${n}.`);t=BigInt(e)}else t=D(e);if(t<0n||t>P)throw new c(`${n} exceeds uint256 bounds.`);return t}function h(e,n){let t=p(e,n);if(t>M)throw new c(`${n} exceeds uint64 bounds.`);return t}function Y(e,n){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new c(`${n} must be a 32-byte hex string.`);return e}function j(e){if(typeof e=="bigint"){if(e<=0n||e>P)throw new c("Private key must be a positive scalar.");return`0x${e.toString(16).padStart(64,"0")}`}if(typeof e=="string"&&/^0x[0-9a-fA-F]{1,64}$/.test(e))return`0x${e.slice(2).padStart(64,"0")}`;throw new c("Invalid private key format.")}function K(e){let n=p(e.chainId,"chainId"),t=m(e.verifyingContract,"verifyingContract");return g(k(O("bytes32, bytes32, bytes32, uint256, address"),[L,g(N(e.name)),g(N(e.version)),n,t]))}function ae(e,n=d,t=l){return{name:T,version:t,chainId:Number(p(n,"chainId")),verifyingContract:m(e,"consumer")}}function J(e,n=d,t=l){return K({name:T,version:t,chainId:n,verifyingContract:e})}function Q(e){let n=m(e.wallet,"wallet"),t=p(e.oakPerEthE18,"oakPerEthE18"),i=h(e.timestamp,"timestamp"),r=Y(e.nonce,"nonce");return g(k(O("bytes32, address, uint256, uint64, bytes32"),[W,n,t,i,r]))}function C(e,n,t=d,i=l){let r=J(n,t,i),o=Q(e);return g(B(["0x1901",r,o]))}async function ce(e,n,t,i=d,r=l){let o=C(e,n,i,r);return typeof t=="object"&&t!==null&&"sign"in t?t.sign({hash:o}):U(j(t)).sign({hash:o})}async function Z(e,n,t,i=d,r=l){if(!X(n))return E;try{let o=C(e,t,i,r),x=await q({hash:o,signature:n});return v(x)}catch{return E}}function ee(e,n){let t=p(e,"oakPerEthE18"),i=p(n,"spotOakPerEthE18");if(i<=0n||t<=0n)return!1;if(t>P/2n||i>P/3n)throw new c("Guard arithmetic overflow.");let r=t*2n;return r>=i&&r<=i*3n}function te(e,n,t,i){if("signature"in e&&"consumer"in e&&"note"in e&&!("average"in e))return e;if("note"in e&&"signature"in e&&"consumer"in e){let a=e,f=n??{};return{...f,note:a.note,signature:a.signature,consumer:f.consumer??a.consumer,expiresAt:f.expiresAt??a.expiresAt}}return{...i??{},note:e,signature:n,consumer:t}}async function fe(e,n,t,i){let r=te(e,n,t,i),{note:o,signature:x,consumer:S}=r,a=h(o.timestamp,"timestamp"),f=p(o.oakPerEthE18,"oakPerEthE18"),y=(a+BigInt(w)).toString(),s=(b,V,H)=>({valid:!1,ok:!1,...H?{signer:H}:{},oakPerEthE18:f.toString(),expiresAt:y,reason:b,error:V}),I=r.wallet??r.boundWallet;if(I===void 0)return s("wrong_wallet","Bound wallet context is required to verify a price note.");if(m(o.wallet,"wallet")!==m(I,"boundWallet"))return s("wrong_wallet","Price note wallet does not match the bound wallet.");if(r.now===void 0)return s("expired","Current time (now) is required to verify price note expiry.");let A=h(r.now,"now");if(a>A)return s("not_yet_valid","Price note timestamp is in the future.");if(A-a>BigInt(w))return s("expired","Price note has expired.");if(r.expiresAt!==void 0){let b=h(r.expiresAt,"expiresAt");if(b!==a+BigInt(w)||A>b)return s("expired","Price note has expired.")}let R=r.chainId??d,$=r.version??l,u=await Z(o,x,S,R,$);if(u===E)return s("bad_signature","Price note signature could not be recovered.");if(r.signer===void 0)return s("bad_signature","Expected oracle signer is required to verify a price note.",u);let _=m(r.signer,"signer");return _===E||u!==_?s("bad_signature","Price note signer does not match the oracle signer.",u):r.spotOakPerEthE18===void 0?s("outside_guard","Spot OAK/ETH price is required to verify the price note guard band.",u):ee(f,r.spotOakPerEthE18)?{valid:!0,ok:!0,signer:u,oakPerEthE18:f.toString(),expiresAt:y}:s("outside_guard","Price note is outside the 50% spot guard band.",u)}export{T as a,l as b,w as c,E as d,W as e,K as f,ae as g,J as h,Q as i,C as j,ce as k,Z as l,ee as m,fe as n};
1
+ import{b as D}from"./IX3GZMTM.js";import{b as d}from"./TI727O2H.js";import{a as c}from"./XSD5NL7J.js";import{concat as B,encodeAbiParameters as k,getAddress as v,isAddress as F,keccak256 as g,parseAbiParameters as O,recoverAddress as q,toHex as N}from"viem";import{privateKeyToAccount as U}from"viem/accounts";var T="OakPriceNote",l="1",w=300,E="0x0000000000000000000000000000000000000000",W=g(N("PriceNote(address wallet,uint256 oakPerEthE18,uint64 timestamp,bytes32 nonce)")),L=g(N("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")),M=(1n<<64n)-1n,P=(1n<<256n)-1n,z=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,G=0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0n;function X(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{130}$/.test(e))return!1;let n=BigInt(`0x${e.slice(2,66)}`),t=BigInt(`0x${e.slice(66,130)}`),i=Number.parseInt(e.slice(130,132),16);return!(i!==27&&i!==28||n<=0n||n>=z||t<=0n||t>G)}function m(e,n){if(typeof e!="string"||!F(e,{strict:!1}))throw new c(`Invalid ${n} address.`);return v(e)}function p(e,n){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"){if(!Number.isSafeInteger(e)||e<0)throw new c(`Invalid ${n}.`);t=BigInt(e)}else t=D(e);if(t<0n||t>P)throw new c(`${n} exceeds uint256 bounds.`);return t}function h(e,n){let t=p(e,n);if(t>M)throw new c(`${n} exceeds uint64 bounds.`);return t}function Y(e,n){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new c(`${n} must be a 32-byte hex string.`);return e}function j(e){if(typeof e=="bigint"){if(e<=0n||e>P)throw new c("Private key must be a positive scalar.");return`0x${e.toString(16).padStart(64,"0")}`}if(typeof e=="string"&&/^0x[0-9a-fA-F]{1,64}$/.test(e))return`0x${e.slice(2).padStart(64,"0")}`;throw new c("Invalid private key format.")}function K(e){let n=p(e.chainId,"chainId"),t=m(e.verifyingContract,"verifyingContract");return g(k(O("bytes32, bytes32, bytes32, uint256, address"),[L,g(N(e.name)),g(N(e.version)),n,t]))}function ae(e,n=d,t=l){return{name:T,version:t,chainId:Number(p(n,"chainId")),verifyingContract:m(e,"consumer")}}function J(e,n=d,t=l){return K({name:T,version:t,chainId:n,verifyingContract:e})}function Q(e){let n=m(e.wallet,"wallet"),t=p(e.oakPerEthE18,"oakPerEthE18"),i=h(e.timestamp,"timestamp"),r=Y(e.nonce,"nonce");return g(k(O("bytes32, address, uint256, uint64, bytes32"),[W,n,t,i,r]))}function C(e,n,t=d,i=l){let r=J(n,t,i),o=Q(e);return g(B(["0x1901",r,o]))}async function ce(e,n,t,i=d,r=l){let o=C(e,n,i,r);return typeof t=="object"&&t!==null&&"sign"in t?t.sign({hash:o}):U(j(t)).sign({hash:o})}async function Z(e,n,t,i=d,r=l){if(!X(n))return E;try{let o=C(e,t,i,r),x=await q({hash:o,signature:n});return v(x)}catch{return E}}function ee(e,n){let t=p(e,"oakPerEthE18"),i=p(n,"spotOakPerEthE18");if(i<=0n||t<=0n)return!1;if(t>P/2n||i>P/3n)throw new c("Guard arithmetic overflow.");let r=t*2n;return r>=i&&r<=i*3n}function te(e,n,t,i){if("signature"in e&&"consumer"in e&&"note"in e&&!("average"in e))return e;if("note"in e&&"signature"in e&&"consumer"in e){let a=e,f=n??{};return{...f,note:a.note,signature:a.signature,consumer:f.consumer??a.consumer,expiresAt:f.expiresAt??a.expiresAt}}return{...i??{},note:e,signature:n,consumer:t}}async function fe(e,n,t,i){let r=te(e,n,t,i),{note:o,signature:x,consumer:S}=r,a=h(o.timestamp,"timestamp"),f=p(o.oakPerEthE18,"oakPerEthE18"),y=(a+BigInt(w)).toString(),s=(b,V,H)=>({valid:!1,ok:!1,...H?{signer:H}:{},oakPerEthE18:f.toString(),expiresAt:y,reason:b,error:V}),I=r.wallet??r.boundWallet;if(I===void 0)return s("wrong_wallet","Bound wallet context is required to verify a price note.");if(m(o.wallet,"wallet")!==m(I,"boundWallet"))return s("wrong_wallet","Price note wallet does not match the bound wallet.");if(r.now===void 0)return s("expired","Current time (now) is required to verify price note expiry.");let A=h(r.now,"now");if(a>A)return s("not_yet_valid","Price note timestamp is in the future.");if(A-a>BigInt(w))return s("expired","Price note has expired.");if(r.expiresAt!==void 0){let b=h(r.expiresAt,"expiresAt");if(b!==a+BigInt(w)||A>b)return s("expired","Price note has expired.")}let R=r.chainId??d,$=r.version??l,u=await Z(o,x,S,R,$);if(u===E)return s("bad_signature","Price note signature could not be recovered.");if(r.signer===void 0)return s("bad_signature","Expected oracle signer is required to verify a price note.",u);let _=m(r.signer,"signer");return _===E||u!==_?s("bad_signature","Price note signer does not match the oracle signer.",u):r.spotOakPerEthE18===void 0?s("outside_guard","Spot OAK/ETH price is required to verify the price note guard band.",u):ee(f,r.spotOakPerEthE18)?{valid:!0,ok:!0,signer:u,oakPerEthE18:f.toString(),expiresAt:y}:s("outside_guard","Price note is outside the 50% spot guard band.",u)}export{T as a,l as b,w as c,E as d,W as e,K as f,ae as g,J as h,Q as i,C as j,ce as k,Z as l,ee as m,fe as n};
@@ -1 +1 @@
1
- import{a as D}from"./43LI5NKJ.js";import{b as Q}from"./IX3GZMTM.js";import{a as x,i as J}from"./FWD4L3CJ.js";import{a as r}from"./XSD5NL7J.js";import{decodeAbiParameters as se,encodeAbiParameters as Z,encodeFunctionData as F,erc20Abi as O,getAddress as g,keccak256 as ee,parseAbi as L,parseAbiParameters as oe,zeroAddress as te}from"viem";var I=10n**18n,$=(1n<<256n)-1n,q=g(J[x].morpho.morpho_blue.address),_=oe("(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)"),w=L(["function adaptersLength() view returns (uint256)","function adapters(uint256) view returns (address)","function liquidityAdapter() view returns (address)","function liquidityData() view returns (bytes)","function forceDeallocatePenalty(address) view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)","function owner() view returns (address)","function curator() view returns (address)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function forceDeallocate(address adapter,bytes data,uint256 assets,address onBehalf) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function multicall(bytes[] data)"]),v=L(["function parentVault() view returns (address)","function asset() view returns (address)","function morpho() view returns (address)","function marketIdsLength() view returns (uint256)","function marketIds(uint256) view returns (bytes32)","function expectedSupplyAssets(bytes32) view returns (uint256)"]),ne=L(["function idToMarketParams(bytes32) view returns (address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)","function market(bytes32) view returns (uint128 totalSupplyAssets,uint128 totalSupplyShares,uint128 totalBorrowAssets,uint128 totalBorrowShares,uint128 lastUpdate,uint128 fee)"]),M=(e,t)=>e<t?e:t,T=(e,t)=>(e+t-1n)/t;function p(e){if(typeof e!="bigint"||e<0n||e>$)throw new r("Invalid Morpho V2 integer read.");return e}function he(e){if(typeof e!="string")throw new r("Provide maxPenaltyAssets as a USDG base-unit integer string, including 0 for no penalty.");let t=Q(e);if(t>$)throw new r("Penalty limit exceeds uint256.");return t}function h(e){if(typeof e!="string")throw new r("Invalid Morpho V2 address read.");return D(e),g(e)}async function ae(e,t,n){if(await e.getChainId()!==x||n.chainId!==x)throw new r("Vault exit requires chain 4663.");let c=await e.getBlockNumber({cacheTime:0}),a=(m,y,k,S=[])=>e.readContract({address:m,abi:y,functionName:k,args:S,blockNumber:c}),[d,o,i,l,u]=await Promise.all([a(t,w,"adaptersLength"),a(t,w,"liquidityAdapter"),a(t,w,"liquidityData"),a(g(n.address),O,"balanceOf",[t]),a(g(n.address),O,"balanceOf",[q])]);if(p(d)!==1n)throw new r("Force exit requires exactly one verified MorphoMarketV1AdapterV2. This vault needs a separately qualified adapter plan.");let s=h(await a(t,w,"adapters",[0n])),C=h(o);if(C!==te&&C!==s)throw new r("The liquidity adapter is not the supported market adapter.");let[A,N,P,f,B]=await Promise.all([a(s,v,"parentVault"),a(s,v,"asset"),a(s,v,"morpho"),a(s,v,"marketIdsLength"),a(t,w,"forceDeallocatePenalty",[s])]);if(h(A)!==g(t)||h(N)!==g(n.address)||h(P)!==q)throw new r("The adapter does not match this vault and pinned Morpho Blue deployment.");let b=p(f);if(b>64n)throw new r("The adapter market inventory exceeds this reader\u2019s supported size.");let E=p(B);if(E>I/50n)throw new r("The force-deallocation penalty exceeds the documented 2% maximum.");let H;if(C!==te){if(typeof i!="string")throw new r("Invalid liquidity-market data.");let[m]=se(_,i);H=ee(Z(_,[m])).toLowerCase()}let V=await Promise.all(Array.from({length:Number(b)},(m,y)=>a(s,v,"marketIds",[BigInt(y)])));if(V.some(m=>typeof m!="string"||!/^0x[0-9a-f]{64}$/i.test(m))||new Set(V.map(m=>String(m).toLowerCase())).size!==V.length)throw new r("The adapter returned an invalid or duplicate market ID.");let R=await Promise.all(V.map(async m=>{let y=m,[k,S,ie]=await Promise.all([a(q,ne,"idToMarketParams",[y]),a(q,ne,"market",[y]),a(s,v,"expectedSupplyAssets",[y])]);if(!Array.isArray(k)||k.length!==5||!Array.isArray(S)||S.length!==6)throw new r("Invalid Morpho market state.");let z={loanToken:h(k[0]),collateralToken:h(k[1]),oracle:h(k[2]),irm:h(k[3]),lltv:p(k[4])},j=Z(_,[z]);if(ee(j).toLowerCase()!==y.toLowerCase()||z.loanToken!==g(n.address))throw new r("Morpho market identity or loan asset does not match the vault.");let G=p(S[0]),X=p(S[2]);if(X>G)throw new r("Invalid Morpho market liquidity.");let Y=p(ie),K=G-X;return{id:y,adapter:s,data:j,supplied:Y,liquidity:K,capacity:M(Y,K),penalty:E,normal:y.toLowerCase()===H}})),U=p(l),W=p(u),re=U+M(W,R.filter(m=>m.normal).reduce((m,y)=>m+y.capacity,0n));return{vault:t,blockNumber:c,idle:U,blueCash:W,normalCapacity:re,markets:R}}function de(e,t){if(t<=0n||t>$)throw new r("Force exit needs a positive position value.");let n=t>e.normalCapacity?t-e.normalCapacity:0n,c=[],a=e.blueCash-(e.normalCapacity-e.idle);for(let d of e.markets.filter(o=>!o.normal).sort((o,i)=>o.capacity===i.capacity?o.id.localeCompare(i.id):o.capacity>i.capacity?-1:1)){if(n===0n)break;let o=M(d.capacity,a);if(o===0n)continue;let i=s=>s+T(s*d.penalty,I),l=o;i(o)>=n&&(l=T(n*I,I+d.penalty),l>0n&&i(l-1n)>=n&&(l-=1n),l=M(o,l+(T(t,10000n)||1n)));let u=T(l*d.penalty,I);c.push({...d,amount:l,penaltyAssets:u}),a-=l,n=i(l)>=n?0n:n-i(l)}if(n>0n)throw new r("Underlying market liquidity cannot cover this force exit. Request a partial withdrawal or use a separately supported in-kind exit; force deallocation cannot create liquidity.");return{requestedAssets:t,normalCapacity:e.normalCapacity,legs:c,penaltyAssets:c.reduce((d,o)=>d+o.penaltyAssets,0n)}}async function we(e,t,n,c,a,d,o){let i=await ae(t,n,o),l=p(await t.readContract({address:n,abi:O,functionName:"balanceOf",args:[c],blockNumber:i.blockNumber}));if(a<=0n||a>l)throw new r("The fresh share balance cannot cover this exit.");let u=p(await t.readContract({address:n,abi:w,functionName:"previewRedeem",args:[a],blockNumber:i.blockNumber})),s=de(i,u);if(s.penaltyAssets>d)throw new r("The force-exit penalty exceeds maxPenaltyAssets. Inspect a fresh plan before authorizing a larger penalty.");let A=(await Promise.all(s.legs.map(b=>t.readContract({address:n,abi:w,functionName:"previewWithdraw",args:[b.penaltyAssets],blockNumber:i.blockNumber})))).reduce((b,E)=>b+p(E),0n);if(A>=a)throw new r("The penalty would consume the share balance.");let N=a-A,P=s.legs.map(b=>F({abi:w,functionName:"forceDeallocate",args:[b.adapter,b.data,b.amount,c]})),f=F({abi:w,functionName:"redeem",args:[N,c,c]});return P.push(f),{tx:e.unsignedTx({to:n,chainId:x,value:"0",data:s.legs.length?F({abi:w,functionName:"multicall",args:[P]}):f,description:`Exit this wallet\u2019s Morpho V2 shares; estimated penalty ${s.penaltyAssets} ${o.symbol} base units. No approvals.`}),plan:s,penaltyShares:A,redeemShares:N,blockNumber:i.blockNumber}}var ye="This vault lists no lending markets right now, and Morpho's index shows 0% over this window. On these numbers it earns nothing.";async function be(e,t){try{let n=p(await e.readContract({address:t,abi:w,functionName:"adaptersLength"}));if(n>8n)return;let c=await Promise.all(Array.from({length:Number(n)},(d,o)=>e.readContract({address:t,abi:w,functionName:"adapters",args:[BigInt(o)]})));return(await Promise.all(c.map(d=>e.readContract({address:h(d),abi:v,functionName:"marketIdsLength"})))).every(d=>p(d)===0n)}catch{return}}var ce="In-kind exits transfer supported market positions rather than cash; use the project in_kind_exit tool.";function ge(e,t,n,c,a=ce){return{name:t,inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async(d,o)=>{try{if(D(o),Object.keys(d).length)throw new r("Vault details takes no arguments.");let i=e.clientFor(x);if(await i.getChainId()!==x)throw new r("Vault details requires chain 4663.");let l=await i.readContract({address:n,abi:L(["function asset() view returns (address)"]),functionName:"asset"});if(h(l)!==g(c.address))throw new r("The vault does not use the pinned underlying asset.");let u=await ae(i,n,c),[s,C,A,N]=await Promise.all(["performanceFee","managementFee","owner","curator"].map(f=>i.readContract({address:n,abi:w,functionName:f,blockNumber:u.blockNumber}))),P={...c,address:g(c.address)};return{vault:n,chainId:x,blockNumber:u.blockNumber.toString(),asset:P,owner:h(A),curator:h(N),idleAssets:u.idle.toString(),normalCapacityAssets:u.normalCapacity.toString(),markets:u.markets.map(f=>({marketId:f.id,adapter:f.adapter,suppliedAssets:f.supplied.toString(),marketLiquidityAssets:f.liquidity.toString(),capacityAssets:f.capacity.toString(),liquidityMarket:f.normal,penaltyWad:f.penalty.toString()})),fees:{performanceFeeWad:p(s).toString(),managementFeePerSecondWad:p(C).toString(),scale:I.toString()},apy:null,apyStatus:"This onchain snapshot does not include APY. Use the module analytics tool for indexed historical APY; maxRate is an accrual ceiling.",capacityCaveat:`Snapshot estimates; gates, price accrual, liquidity and penalties can change. Preview the exact action. Force exits may leave share rounding dust. ${a}`}}catch(i){throw new r(e.plainError(i))}}}}function ke(e,t){return`Force-exit estimate: position ${e.requestedAssets} ${t} base units; penalty ${e.penaltyAssets}; net estimate ${e.requestedAssets-e.penaltyAssets}; effective penalty ${T(e.penaltyAssets*10000n,e.requestedAssets)} bps (rounded up). Penalty limit is a local preview check, not a calldata bound. Re-preview before signing and recheck positions for rounding dust.`}function xe(e,t,n,c,a){let d=(i,l)=>e.filter(u=>u.token.chainId===x&&u.token.address.toLowerCase()===i.toLowerCase()).reduce((u,s)=>{if(s.token.decimals!==l||!/^-?\d+$/.test(s.amount))throw new r("Invalid force-exit preview metadata.");return u+BigInt(s.amount)},0n),o=-d(t,18);if(o<=0n||o>n||d(g(a.address),a.decimals)<c)throw new r("The force-exit preview exceeds the share balance or returns less than minAmountOut.")}export{w as a,p as b,he as c,ae as d,de as e,we as f,ye as g,be as h,ge as i,ke as j,xe as k};
1
+ import{a as D}from"./43LI5NKJ.js";import{b as Q}from"./IX3GZMTM.js";import{b as x,j as J}from"./TI727O2H.js";import{a as r}from"./XSD5NL7J.js";import{decodeAbiParameters as se,encodeAbiParameters as Z,encodeFunctionData as F,erc20Abi as O,getAddress as g,keccak256 as ee,parseAbi as L,parseAbiParameters as oe,zeroAddress as te}from"viem";var I=10n**18n,$=(1n<<256n)-1n,q=g(J[x].morpho.morpho_blue.address),_=oe("(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)"),w=L(["function adaptersLength() view returns (uint256)","function adapters(uint256) view returns (address)","function liquidityAdapter() view returns (address)","function liquidityData() view returns (bytes)","function forceDeallocatePenalty(address) view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)","function owner() view returns (address)","function curator() view returns (address)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function forceDeallocate(address adapter,bytes data,uint256 assets,address onBehalf) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function multicall(bytes[] data)"]),v=L(["function parentVault() view returns (address)","function asset() view returns (address)","function morpho() view returns (address)","function marketIdsLength() view returns (uint256)","function marketIds(uint256) view returns (bytes32)","function expectedSupplyAssets(bytes32) view returns (uint256)"]),ne=L(["function idToMarketParams(bytes32) view returns (address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)","function market(bytes32) view returns (uint128 totalSupplyAssets,uint128 totalSupplyShares,uint128 totalBorrowAssets,uint128 totalBorrowShares,uint128 lastUpdate,uint128 fee)"]),M=(e,t)=>e<t?e:t,T=(e,t)=>(e+t-1n)/t;function p(e){if(typeof e!="bigint"||e<0n||e>$)throw new r("Invalid Morpho V2 integer read.");return e}function he(e){if(typeof e!="string")throw new r("Provide maxPenaltyAssets as a USDG base-unit integer string, including 0 for no penalty.");let t=Q(e);if(t>$)throw new r("Penalty limit exceeds uint256.");return t}function h(e){if(typeof e!="string")throw new r("Invalid Morpho V2 address read.");return D(e),g(e)}async function ae(e,t,n){if(await e.getChainId()!==x||n.chainId!==x)throw new r("Vault exit requires chain 4663.");let c=await e.getBlockNumber({cacheTime:0}),a=(m,y,k,S=[])=>e.readContract({address:m,abi:y,functionName:k,args:S,blockNumber:c}),[d,o,i,l,u]=await Promise.all([a(t,w,"adaptersLength"),a(t,w,"liquidityAdapter"),a(t,w,"liquidityData"),a(g(n.address),O,"balanceOf",[t]),a(g(n.address),O,"balanceOf",[q])]);if(p(d)!==1n)throw new r("Force exit requires exactly one verified MorphoMarketV1AdapterV2. This vault needs a separately qualified adapter plan.");let s=h(await a(t,w,"adapters",[0n])),C=h(o);if(C!==te&&C!==s)throw new r("The liquidity adapter is not the supported market adapter.");let[A,N,P,f,B]=await Promise.all([a(s,v,"parentVault"),a(s,v,"asset"),a(s,v,"morpho"),a(s,v,"marketIdsLength"),a(t,w,"forceDeallocatePenalty",[s])]);if(h(A)!==g(t)||h(N)!==g(n.address)||h(P)!==q)throw new r("The adapter does not match this vault and pinned Morpho Blue deployment.");let b=p(f);if(b>64n)throw new r("The adapter market inventory exceeds this reader\u2019s supported size.");let E=p(B);if(E>I/50n)throw new r("The force-deallocation penalty exceeds the documented 2% maximum.");let H;if(C!==te){if(typeof i!="string")throw new r("Invalid liquidity-market data.");let[m]=se(_,i);H=ee(Z(_,[m])).toLowerCase()}let V=await Promise.all(Array.from({length:Number(b)},(m,y)=>a(s,v,"marketIds",[BigInt(y)])));if(V.some(m=>typeof m!="string"||!/^0x[0-9a-f]{64}$/i.test(m))||new Set(V.map(m=>String(m).toLowerCase())).size!==V.length)throw new r("The adapter returned an invalid or duplicate market ID.");let R=await Promise.all(V.map(async m=>{let y=m,[k,S,ie]=await Promise.all([a(q,ne,"idToMarketParams",[y]),a(q,ne,"market",[y]),a(s,v,"expectedSupplyAssets",[y])]);if(!Array.isArray(k)||k.length!==5||!Array.isArray(S)||S.length!==6)throw new r("Invalid Morpho market state.");let z={loanToken:h(k[0]),collateralToken:h(k[1]),oracle:h(k[2]),irm:h(k[3]),lltv:p(k[4])},j=Z(_,[z]);if(ee(j).toLowerCase()!==y.toLowerCase()||z.loanToken!==g(n.address))throw new r("Morpho market identity or loan asset does not match the vault.");let G=p(S[0]),X=p(S[2]);if(X>G)throw new r("Invalid Morpho market liquidity.");let Y=p(ie),K=G-X;return{id:y,adapter:s,data:j,supplied:Y,liquidity:K,capacity:M(Y,K),penalty:E,normal:y.toLowerCase()===H}})),U=p(l),W=p(u),re=U+M(W,R.filter(m=>m.normal).reduce((m,y)=>m+y.capacity,0n));return{vault:t,blockNumber:c,idle:U,blueCash:W,normalCapacity:re,markets:R}}function de(e,t){if(t<=0n||t>$)throw new r("Force exit needs a positive position value.");let n=t>e.normalCapacity?t-e.normalCapacity:0n,c=[],a=e.blueCash-(e.normalCapacity-e.idle);for(let d of e.markets.filter(o=>!o.normal).sort((o,i)=>o.capacity===i.capacity?o.id.localeCompare(i.id):o.capacity>i.capacity?-1:1)){if(n===0n)break;let o=M(d.capacity,a);if(o===0n)continue;let i=s=>s+T(s*d.penalty,I),l=o;i(o)>=n&&(l=T(n*I,I+d.penalty),l>0n&&i(l-1n)>=n&&(l-=1n),l=M(o,l+(T(t,10000n)||1n)));let u=T(l*d.penalty,I);c.push({...d,amount:l,penaltyAssets:u}),a-=l,n=i(l)>=n?0n:n-i(l)}if(n>0n)throw new r("Underlying market liquidity cannot cover this force exit. Request a partial withdrawal or use a separately supported in-kind exit; force deallocation cannot create liquidity.");return{requestedAssets:t,normalCapacity:e.normalCapacity,legs:c,penaltyAssets:c.reduce((d,o)=>d+o.penaltyAssets,0n)}}async function we(e,t,n,c,a,d,o){let i=await ae(t,n,o),l=p(await t.readContract({address:n,abi:O,functionName:"balanceOf",args:[c],blockNumber:i.blockNumber}));if(a<=0n||a>l)throw new r("The fresh share balance cannot cover this exit.");let u=p(await t.readContract({address:n,abi:w,functionName:"previewRedeem",args:[a],blockNumber:i.blockNumber})),s=de(i,u);if(s.penaltyAssets>d)throw new r("The force-exit penalty exceeds maxPenaltyAssets. Inspect a fresh plan before authorizing a larger penalty.");let A=(await Promise.all(s.legs.map(b=>t.readContract({address:n,abi:w,functionName:"previewWithdraw",args:[b.penaltyAssets],blockNumber:i.blockNumber})))).reduce((b,E)=>b+p(E),0n);if(A>=a)throw new r("The penalty would consume the share balance.");let N=a-A,P=s.legs.map(b=>F({abi:w,functionName:"forceDeallocate",args:[b.adapter,b.data,b.amount,c]})),f=F({abi:w,functionName:"redeem",args:[N,c,c]});return P.push(f),{tx:e.unsignedTx({to:n,chainId:x,value:"0",data:s.legs.length?F({abi:w,functionName:"multicall",args:[P]}):f,description:`Exit this wallet\u2019s Morpho V2 shares; estimated penalty ${s.penaltyAssets} ${o.symbol} base units. No approvals.`}),plan:s,penaltyShares:A,redeemShares:N,blockNumber:i.blockNumber}}var ye="This vault lists no lending markets right now, and Morpho's index shows 0% over this window. On these numbers it earns nothing.";async function be(e,t){try{let n=p(await e.readContract({address:t,abi:w,functionName:"adaptersLength"}));if(n>8n)return;let c=await Promise.all(Array.from({length:Number(n)},(d,o)=>e.readContract({address:t,abi:w,functionName:"adapters",args:[BigInt(o)]})));return(await Promise.all(c.map(d=>e.readContract({address:h(d),abi:v,functionName:"marketIdsLength"})))).every(d=>p(d)===0n)}catch{return}}var ce="In-kind exits transfer supported market positions rather than cash; use the project in_kind_exit tool.";function ge(e,t,n,c,a=ce){return{name:t,inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async(d,o)=>{try{if(D(o),Object.keys(d).length)throw new r("Vault details takes no arguments.");let i=e.clientFor(x);if(await i.getChainId()!==x)throw new r("Vault details requires chain 4663.");let l=await i.readContract({address:n,abi:L(["function asset() view returns (address)"]),functionName:"asset"});if(h(l)!==g(c.address))throw new r("The vault does not use the pinned underlying asset.");let u=await ae(i,n,c),[s,C,A,N]=await Promise.all(["performanceFee","managementFee","owner","curator"].map(f=>i.readContract({address:n,abi:w,functionName:f,blockNumber:u.blockNumber}))),P={...c,address:g(c.address)};return{vault:n,chainId:x,blockNumber:u.blockNumber.toString(),asset:P,owner:h(A),curator:h(N),idleAssets:u.idle.toString(),normalCapacityAssets:u.normalCapacity.toString(),markets:u.markets.map(f=>({marketId:f.id,adapter:f.adapter,suppliedAssets:f.supplied.toString(),marketLiquidityAssets:f.liquidity.toString(),capacityAssets:f.capacity.toString(),liquidityMarket:f.normal,penaltyWad:f.penalty.toString()})),fees:{performanceFeeWad:p(s).toString(),managementFeePerSecondWad:p(C).toString(),scale:I.toString()},apy:null,apyStatus:"This onchain snapshot does not include APY. Use the module analytics tool for indexed historical APY; maxRate is an accrual ceiling.",capacityCaveat:`Snapshot estimates; gates, price accrual, liquidity and penalties can change. Preview the exact action. Force exits may leave share rounding dust. ${a}`}}catch(i){throw new r(e.plainError(i))}}}}function ke(e,t){return`Force-exit estimate: position ${e.requestedAssets} ${t} base units; penalty ${e.penaltyAssets}; net estimate ${e.requestedAssets-e.penaltyAssets}; effective penalty ${T(e.penaltyAssets*10000n,e.requestedAssets)} bps (rounded up). Penalty limit is a local preview check, not a calldata bound. Re-preview before signing and recheck positions for rounding dust.`}function xe(e,t,n,c,a){let d=(i,l)=>e.filter(u=>u.token.chainId===x&&u.token.address.toLowerCase()===i.toLowerCase()).reduce((u,s)=>{if(s.token.decimals!==l||!/^-?\d+$/.test(s.amount))throw new r("Invalid force-exit preview metadata.");return u+BigInt(s.amount)},0n),o=-d(t,18);if(o<=0n||o>n||d(g(a.address),a.decimals)<c)throw new r("The force-exit preview exceeds the share balance or returns less than minAmountOut.")}export{w as a,p as b,he as c,ae as d,de as e,we as f,ye as g,be as h,ge as i,ke as j,xe as k};
@@ -1 +1 @@
1
- import{b as I,c as M}from"./GQYV4TFO.js";import{a as b,c as s,d as k,f as E}from"./2OKYXT25.js";import{g}from"./OUROA7XR.js";import{a as N}from"./43LI5NKJ.js";import{a as C,i as D,j as i}from"./FWD4L3CJ.js";import{a as y}from"./XSD5NL7J.js";import{erc20Abi as U,parseAbi as P}from"viem";var o=P(["function isValidMarket(address market) view returns(bool)","function readTokens() view returns(address sy,address pt,address yt)","function expiry() view returns(uint256)","function isExpired() view returns(bool)","function getTokensIn() view returns(address[])","function getTokensOut() view returns(address[])"]);async function H(u,r,d){if(N(r),I(d,!0),u.network==="testnet")throw new y("Pendle is available on chain 4663 only.");let e=u.clientFor(C),w=await e.getBlock(),t=w.number;s(await e.readContract({address:D[4663].pendle.marketFactory.address,abi:o,functionName:"isValidMarket",args:[r],blockNumber:t})===!0,"market is not verified by Pendle\u2019s factory");let[[c,m,O],p,h]=await Promise.all([e.readContract({address:r,abi:o,functionName:"readTokens",blockNumber:t}),e.readContract({address:r,abi:o,functionName:"expiry",blockNumber:t}),e.readContract({address:r,abi:o,functionName:"isExpired",blockNumber:t})]),[v,T]=await Promise.all([e.readContract({address:c,abi:o,functionName:"getTokensIn",blockNumber:t}),e.readContract({address:c,abi:o,functionName:"getTokensOut",blockNumber:t})]);s(v.some(n=>k(n,i)),"the earn cost comparison requires a USDG term"),s(T.some(n=>k(n,i)),"this term cannot cash out to USDG"),s(!h&&p>w.timestamp&&p<=BigInt(Number.MAX_SAFE_INTEGER),"this term has ended or its end date is unreadable");let l=n=>e.readContract({address:n,abi:U,functionName:"decimals",blockNumber:t}),[S,x,R]=await Promise.all([l(i),l(m),l(c)]),A={market:r,sy:c,pt:m,yt:O,expiry:Number(p),expired:h,kind:"stable",inputToken:i,inputSymbol:"USDG",inputDecimals:S,ptDecimals:x,syDecimals:R,tokensIn:[...v],tokensOut:[...T]},f=await g(u.http,{inputToken:i,outputToken:m,amount:d,wallet:b,slippageBps:50}),a=E(f.body,{market:A,wallet:b,amount:d,slippageBps:50});if(Math.abs(a.priceImpact)>.03)throw new y("This is a thin market and your size moves the price too much. Try a smaller amount.");return await M(e,A,"buy",d,a.amountOut,a.priceImpact),s(Date.now()-f.receivedAt>=0&&Date.now()-f.receivedAt<=3e4,"display quote is too old; try again"),{feeUsd:a.feeUsd,impactPct:Math.abs(a.priceImpact)*100,ptOutBase:a.amountOut}}export{H as a};
1
+ import{b as I,c as M}from"./2OVJ2BTJ.js";import{a as b,c as s,d as k,f as E}from"./GQITAJVF.js";import{g}from"./OUROA7XR.js";import{a as N}from"./43LI5NKJ.js";import{b as C,j as D,k as i}from"./TI727O2H.js";import{a as y}from"./XSD5NL7J.js";import{erc20Abi as U,parseAbi as P}from"viem";var o=P(["function isValidMarket(address market) view returns(bool)","function readTokens() view returns(address sy,address pt,address yt)","function expiry() view returns(uint256)","function isExpired() view returns(bool)","function getTokensIn() view returns(address[])","function getTokensOut() view returns(address[])"]);async function H(u,r,d){if(N(r),I(d,!0),u.network==="testnet")throw new y("Pendle is available on chain 4663 only.");let e=u.clientFor(C),w=await e.getBlock(),t=w.number;s(await e.readContract({address:D[4663].pendle.marketFactory.address,abi:o,functionName:"isValidMarket",args:[r],blockNumber:t})===!0,"market is not verified by Pendle\u2019s factory");let[[c,m,O],p,h]=await Promise.all([e.readContract({address:r,abi:o,functionName:"readTokens",blockNumber:t}),e.readContract({address:r,abi:o,functionName:"expiry",blockNumber:t}),e.readContract({address:r,abi:o,functionName:"isExpired",blockNumber:t})]),[v,T]=await Promise.all([e.readContract({address:c,abi:o,functionName:"getTokensIn",blockNumber:t}),e.readContract({address:c,abi:o,functionName:"getTokensOut",blockNumber:t})]);s(v.some(n=>k(n,i)),"the earn cost comparison requires a USDG term"),s(T.some(n=>k(n,i)),"this term cannot cash out to USDG"),s(!h&&p>w.timestamp&&p<=BigInt(Number.MAX_SAFE_INTEGER),"this term has ended or its end date is unreadable");let l=n=>e.readContract({address:n,abi:U,functionName:"decimals",blockNumber:t}),[S,x,R]=await Promise.all([l(i),l(m),l(c)]),A={market:r,sy:c,pt:m,yt:O,expiry:Number(p),expired:h,kind:"stable",inputToken:i,inputSymbol:"USDG",inputDecimals:S,ptDecimals:x,syDecimals:R,tokensIn:[...v],tokensOut:[...T]},f=await g(u.http,{inputToken:i,outputToken:m,amount:d,wallet:b,slippageBps:50}),a=E(f.body,{market:A,wallet:b,amount:d,slippageBps:50});if(Math.abs(a.priceImpact)>.03)throw new y("This is a thin market and your size moves the price too much. Try a smaller amount.");return await M(e,A,"buy",d,a.amountOut,a.priceImpact),s(Date.now()-f.receivedAt>=0&&Date.now()-f.receivedAt<=3e4,"display quote is too old; try again"),{feeUsd:a.feeUsd,impactPct:Math.abs(a.priceImpact)*100,ptOutBase:a.amountOut}}export{H as a};
@@ -1 +1 @@
1
- import{b as s}from"./MQK6OP7S.js";import{a as p}from"./LT5P6PZW.js";import{a as u}from"./H5DY7CNB.js";import{f as a}from"./NWNYJ26T.js";import{a as r}from"./XSD5NL7J.js";import{erc20Abi as f,getAddress as i,parseAbi as g,zeroAddress as b}from"viem";var w={type:"string",pattern:"^(0|[1-9][0-9]*)$",maxLength:78},O={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},R={blockNumber:{...w,description:"Optional named chain-4663 block; defaults to the head captured once for this read."}},T=g(["function launchFee() view returns (uint256 fee,address treasury,uint256 pendingFee,address pendingTreasury,uint256 readyAt)"]),k=p;function B(e,n,t=[]){let o=a(e,"Provide the documented Hookr object.");if(Object.keys(o).some(d=>!n.includes(d))||t.some(d=>!Object.hasOwn(o,d)))throw new r("Provide exactly the documented Hookr fields; wallet overrides are not accepted.");return o}function l(e,n=256){if(typeof e!="string"||!/^(0|[1-9][0-9]*)$/.test(e)||e.length>78||BigInt(e)>=1n<<BigInt(n))throw new r(`Provide a decimal integer string within uint${n}.`);return BigInt(e)}function N(e){return e.blockNumber===void 0?void 0:l(e.blockNumber,64)}function S(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new r("Provide an exact bytes32 Hookr ID.");return e.toLowerCase()}function $(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{40}$/.test(e)||i(e)!==e)throw new r("Provide an EIP-55 checksummed address.");return i(e)}function y(e,n=256){if(typeof e!="bigint"&&(typeof e!="number"||!Number.isSafeInteger(e)))throw new r("Hookr integer read is incomplete. Retry the named-block read.");let t=BigInt(e);if(t<0n||t>=1n<<BigInt(n))throw new r("Hookr integer read is outside its ABI bounds.");return t}function E(e){if(typeof e!="boolean")throw new r("Hookr boolean read is incomplete.");return e}function j(e,n){if(!Array.isArray(e)||e.length!==n)throw new r("Hookr tuple read is incomplete.");return e}var C=e=>a(e,"Hookr struct read is incomplete.");function F(e){return JSON.parse(JSON.stringify(e,(n,t)=>typeof t=="bigint"||typeof t=="number"?String(t):t))}function V(e){return k[e].abi}function m(e,n,t,o,d,c){return e.readContract({address:n,abi:t,functionName:o,args:d,blockNumber:c})}var L=i(s.rootV1),_=i(s.registry),D=i(s.poolManager),J=i(s.agentGateV1);function K(e){if(e===i(s.rulesV1))return"rulesV1";if(e===i(s.rulesPrevious))return"rules";if(e===i(s.rulesLegacy))return"rulesLegacy";throw new r("Unknown Hookr core deployment. Review and pin it before reading this position.")}async function U(e,n,t){if(n===b)return{address:u,symbol:"ETH",decimals:18,chainId:4663};let[o,d]=await Promise.all([m(e,n,f,"symbol",[],t),m(e,n,f,"decimals",[],t)]),c=y(d,8);if(typeof o!="string"||o.length===0||new TextEncoder().encode(o).length>128)throw new r("Hookr token metadata is incomplete. Retry before valuing this currency.");return{address:n,symbol:o,decimals:Number(c),chainId:4663}}export{w as a,O as b,R as c,T as d,B as e,l as f,N as g,S as h,$ as i,y as j,E as k,j as l,C as m,F as n,V as o,m as p,L as q,_ as r,D as s,J as t,K as u,U as v};
1
+ import{b as s}from"./MQK6OP7S.js";import{a as p}from"./LT5P6PZW.js";import{a as u}from"./Z7FGEWO2.js";import{f as a}from"./NWNYJ26T.js";import{a as r}from"./XSD5NL7J.js";import{erc20Abi as f,getAddress as i,parseAbi as g,zeroAddress as b}from"viem";var w={type:"string",pattern:"^(0|[1-9][0-9]*)$",maxLength:78},O={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},R={blockNumber:{...w,description:"Optional named chain-4663 block; defaults to the head captured once for this read."}},T=g(["function launchFee() view returns (uint256 fee,address treasury,uint256 pendingFee,address pendingTreasury,uint256 readyAt)"]),k=p;function B(e,n,t=[]){let o=a(e,"Provide the documented Hookr object.");if(Object.keys(o).some(d=>!n.includes(d))||t.some(d=>!Object.hasOwn(o,d)))throw new r("Provide exactly the documented Hookr fields; wallet overrides are not accepted.");return o}function l(e,n=256){if(typeof e!="string"||!/^(0|[1-9][0-9]*)$/.test(e)||e.length>78||BigInt(e)>=1n<<BigInt(n))throw new r(`Provide a decimal integer string within uint${n}.`);return BigInt(e)}function N(e){return e.blockNumber===void 0?void 0:l(e.blockNumber,64)}function S(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new r("Provide an exact bytes32 Hookr ID.");return e.toLowerCase()}function $(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{40}$/.test(e)||i(e)!==e)throw new r("Provide an EIP-55 checksummed address.");return i(e)}function y(e,n=256){if(typeof e!="bigint"&&(typeof e!="number"||!Number.isSafeInteger(e)))throw new r("Hookr integer read is incomplete. Retry the named-block read.");let t=BigInt(e);if(t<0n||t>=1n<<BigInt(n))throw new r("Hookr integer read is outside its ABI bounds.");return t}function E(e){if(typeof e!="boolean")throw new r("Hookr boolean read is incomplete.");return e}function j(e,n){if(!Array.isArray(e)||e.length!==n)throw new r("Hookr tuple read is incomplete.");return e}var C=e=>a(e,"Hookr struct read is incomplete.");function F(e){return JSON.parse(JSON.stringify(e,(n,t)=>typeof t=="bigint"||typeof t=="number"?String(t):t))}function V(e){return k[e].abi}function m(e,n,t,o,d,c){return e.readContract({address:n,abi:t,functionName:o,args:d,blockNumber:c})}var L=i(s.rootV1),_=i(s.registry),D=i(s.poolManager),J=i(s.agentGateV1);function K(e){if(e===i(s.rulesV1))return"rulesV1";if(e===i(s.rulesPrevious))return"rules";if(e===i(s.rulesLegacy))return"rulesLegacy";throw new r("Unknown Hookr core deployment. Review and pin it before reading this position.")}async function U(e,n,t){if(n===b)return{address:u,symbol:"ETH",decimals:18,chainId:4663};let[o,d]=await Promise.all([m(e,n,f,"symbol",[],t),m(e,n,f,"decimals",[],t)]),c=y(d,8);if(typeof o!="string"||o.length===0||new TextEncoder().encode(o).length>128)throw new r("Hookr token metadata is incomplete. Retry before valuing this currency.");return{address:n,symbol:o,decimals:Number(c),chainId:4663}}export{w as a,O as b,R as c,T as d,B as e,l as f,N as g,S as h,$ as i,y as j,E as k,j as l,C as m,F as n,V as o,m as p,L as q,_ as r,D as s,J as t,K as u,U as v};
@@ -1 +1 @@
1
- import{b as s}from"./Q2ACLVWR.js";import{a as o,c as t}from"./JESMX2UC.js";import{getAddress as i}from"viem";var f=new Set(["priors_status",...s,...t.filter(r=>r.read).map(r=>r.name),"priors_ethos_status","priors_request_borrow","priors_request_repay","priors_request_stock","priors_request_backing","priors_pt_quote","priors_pt_position","priors_stock_quote","priors_savings_liquidity","priors_market_origin","priors_market_pins","priors_capabilities"]),p=new Set(["priors_sign_consent",...t.filter(r=>r.consentRoot).map(r=>r.name)]),u=new Set([...p,"priors_starter_line"]),R=new Set([...t.filter(r=>!r.read).map(r=>r.name),"priors_root_offer","priors_autopay_on","priors_autopay_off","priors_pt_buy","priors_pt_sell","priors_pt_redeem","priors_savings_force_withdraw","priors_stock_swap","priors_market_clear_bid_budget","priors_market_revoke_nft","priors_x_link"]),S=["priors_lend","priors_withdraw","priors_borrow","priors_repay","priors_starter_line","priors_close_line","priors_release_bond"];function c(r){let _=t.find(e=>e.name===r);return _?[o[_.contract],..._.approval==="bid"?[o.bidSpender]:[]]:r==="priors_root_offer"?[o.pool]:r==="priors_autopay_on"||r==="priors_autopay_off"?[o.autopay]:r==="priors_savings_force_withdraw"?[o.savings]:r==="priors_stock_swap"?[i("0xCaf681a66D020601342297493863E78C959E5cb2"),i("0x7Cd4E04E433E69e588728c86A3832753B5F846d4")]:r==="priors_pt_buy"||r==="priors_pt_sell"||r==="priors_pt_redeem"?[i("0x888888888889758F76e7103c6CbF23ABbF58F946")]:r==="priors_market_clear_bid_budget"?[o.bidSpender]:r==="priors_market_revoke_nft"?[o.registry,"0x0000000000000000000000000000000000000000"]:r==="priors_x_link"?[o.registry]:[]}export{f as a,p as b,u as c,R as d,S as e,c as f};
1
+ import{b as s}from"./UBI3HBXD.js";import{a as o,c as t}from"./VXCGMALF.js";import{getAddress as i}from"viem";var f=new Set(["priors_status",...s,...t.filter(r=>r.read).map(r=>r.name),"priors_ethos_status","priors_request_borrow","priors_request_repay","priors_request_stock","priors_request_backing","priors_pt_quote","priors_pt_position","priors_stock_quote","priors_savings_liquidity","priors_market_origin","priors_market_pins","priors_capabilities"]),p=new Set(["priors_sign_consent",...t.filter(r=>r.consentRoot).map(r=>r.name)]),u=new Set([...p,"priors_starter_line"]),R=new Set([...t.filter(r=>!r.read).map(r=>r.name),"priors_root_offer","priors_autopay_on","priors_autopay_off","priors_pt_buy","priors_pt_sell","priors_pt_redeem","priors_savings_force_withdraw","priors_stock_swap","priors_market_clear_bid_budget","priors_market_revoke_nft","priors_x_link"]),S=["priors_lend","priors_withdraw","priors_borrow","priors_repay","priors_starter_line","priors_close_line","priors_release_bond"];function c(r){let _=t.find(e=>e.name===r);return _?[o[_.contract],..._.approval==="bid"?[o.bidSpender]:[]]:r==="priors_root_offer"?[o.pool]:r==="priors_autopay_on"||r==="priors_autopay_off"?[o.autopay]:r==="priors_savings_force_withdraw"?[o.savings]:r==="priors_stock_swap"?[i("0xCaf681a66D020601342297493863E78C959E5cb2"),i("0x7Cd4E04E433E69e588728c86A3832753B5F846d4")]:r==="priors_pt_buy"||r==="priors_pt_sell"||r==="priors_pt_redeem"?[i("0x888888888889758F76e7103c6CbF23ABbF58F946")]:r==="priors_market_clear_bid_budget"?[o.bidSpender]:r==="priors_market_revoke_nft"?[o.registry,"0x0000000000000000000000000000000000000000"]:r==="priors_x_link"?[o.registry]:[]}export{f as a,p as b,u as c,R as d,S as e,c as f};
@@ -0,0 +1 @@
1
+ import{a as g,b as p}from"./2OVJ2BTJ.js";import{a as y,b as D,c as m,d as T,e as I}from"./GQITAJVF.js";import{c as O,d as A,f as P,g as R}from"./OUROA7XR.js";import{b as k,c as x}from"./43LI5NKJ.js";import{b}from"./TI727O2H.js";import{a as f}from"./XSD5NL7J.js";import{encodeFunctionData as C,zeroAddress as N}from"viem";function v(t=10){if(!Number.isInteger(t)||t<0||t>50)throw new f("Oak won't accept a cash-out reduction that big. Use a whole number from 0 to 50 bps (0.5%).");return t}async function z(t,e,a,u=10,r){let l=v(u);p(a,!0),m(e.tokensOut.some(n=>T(n,e.inputToken)),"the market input token cannot be redeemed from SY");try{let n=await t.client.getBlock();m(e.expired&&n.timestamp>=BigInt(e.expiry),"this term has not ended; wait for its end date");let h=p((await t.client.simulateContract({address:e.yt,abi:g,functionName:"pyIndexCurrent",blockNumber:n.number})).result,!0);for(let o of[e.syDecimals,e.ptDecimals])m(Number.isInteger(o)&&o>=0&&o<=77,"unreadable token decimals");let d=a*10n**18n*10n**BigInt(e.syDecimals)/(h*10n**BigInt(e.ptDecimals));p(d,!0);let i=p(await t.client.readContract({address:e.sy,abi:g,functionName:"previewRedeem",args:[e.inputToken,d],blockNumber:n.number}),!0),s=I(i,l);if(m(s>0n,"this cash-out amount is too small"),r&&(r.apiAmountOut>i?r.apiAmountOut-i:i-r.apiAmountOut)*10000n>i*50n)try{r.note("Pendle\u2019s API cash-out estimate differs from the chain by over 0.5%. Oak kept the chain estimate.")}catch{}let c={tokenOut:e.inputToken,minTokenOut:s,tokenRedeemSy:e.inputToken,pendleSwap:N,swapData:{swapType:0,extRouter:N,extCalldata:"0x",needScale:!1}},w=k({to:y,data:C({abi:D,functionName:"redeemPyToToken",args:[t.wallet,e.yt,a,c]}),value:"0",chainId:b,description:"Cash out ended Pendle PT to its input token."});return{txs:[x(e.pt,y,a.toString(),b),w],expected:i,minOut:s,summary:"Approve the exact PT amount, then cash out the ended term to its input token."}}catch(n){throw n instanceof f?n:new f("Oak could not read the Pendle cash-out amount from the chain. Try again.")}}async function F(t,e,a,u,r){let l=new AbortController,n;try{let h=new Promise(o=>{n=setTimeout(()=>{l.abort(),o(void 0)},1500)}),d=await Promise.race([R((o,B)=>t.http(o,{...B,signal:l.signal}),{inputToken:e.pt,outputToken:e.inputToken,amount:a,wallet:t.wallet,slippageBps:r}),h]);if(!d)return;let i=P(d.body).outputs;if(i.length!==1)return;let s=O(i[0]);if(!T(s.token,e.inputToken))return;let c=A(s.amount);return(c>u?c-u:u-c)*10000n>u*50n?"Pendle\u2019s API cash-out estimate differs from the chain by over 0.5%. Oak kept the chain estimate.":void 0}catch{return}finally{n!==void 0&&clearTimeout(n)}}export{v as a,z as b,F as c};
@@ -1 +1 @@
1
- import{g as u}from"./NWNYJ26T.js";import{a as o,i as d}from"./FWD4L3CJ.js";import{a as s}from"./XSD5NL7J.js";import{encodeAbiParameters as g,keccak256 as b,parseAbi as f,zeroAddress as h}from"viem";var p=d[o].pons,w=f(["function getLaunchedToken(address) view returns ((address token,address curve,address deployer,address creatorFeeRecipient,address pairToken,uint256 graduationThreshold,uint24 poolFee,int24 tickSpacing,uint16 creatorTaxBps,bool buybackEnabled,uint8 phase,uint256 sweptQuote,uint256 sweptTokens,uint256 sweptAt,bool exists))","function memeHook() view returns (address)"]),l=f(["function factory() view returns (address)","function getReserves() view returns (uint256 quoteReserve,uint256 tokenReserve)"]),v=f(["function getSlot0(bytes32) view returns (uint160,int24,uint24,uint24)","function getLiquidity(bytes32) view returns (uint128)"]);async function A(t,r,n){if(t.chainId!==o||!Number.isInteger(t.decimals)||t.decimals<0||t.decimals>255)throw new s("No supported Pons reference price on this chain or for these token decimals.");let e=await r.readContract({address:p.factory.address,abi:w,functionName:"getLaunchedToken",args:[t.address],blockNumber:n});if(!e.exists||!u(e.token,t.address)||e.pairToken.toLowerCase()!==h)throw new s("No supported native-ETH Pons launch reference price.");let m=10n**BigInt(t.decimals);if(e.phase===0){let[c,[a,i]]=await Promise.all([r.readContract({address:e.curve,abi:l,functionName:"factory",blockNumber:n}),r.readContract({address:e.curve,abi:l,functionName:"getReserves",blockNumber:n})]);if(!u(c,p.factory.address)||a<=0n||i<=0n)throw new s("The Pons curve reference price is unavailable.");return{numerator:a*m,denominator:i*10n**18n}}if(e.phase===2){let c=await r.readContract({address:p.factory.address,abi:w,functionName:"memeHook",blockNumber:n}),a=b(g([{type:"address"},{type:"address"},{type:"uint24"},{type:"int24"},{type:"address"}],[h,t.address,e.poolFee,e.tickSpacing,c])),[i,y]=await Promise.all([r.readContract({address:d[o].ponsTrade.state_view.address,abi:v,functionName:"getSlot0",args:[a],blockNumber:n}),r.readContract({address:d[o].ponsTrade.state_view.address,abi:v,functionName:"getLiquidity",args:[a],blockNumber:n})]);if(i[0]<=0n||y<=0n)throw new s("The graduated Pons pool reference price is unavailable.");return{numerator:(1n<<192n)*m,denominator:i[0]**2n*10n**18n}}throw new s("The Pons launch has no active reference price in this phase.")}export{A as a};
1
+ import{g as u}from"./NWNYJ26T.js";import{b as o,j as d}from"./TI727O2H.js";import{a as s}from"./XSD5NL7J.js";import{encodeAbiParameters as g,keccak256 as b,parseAbi as f,zeroAddress as h}from"viem";var p=d[o].pons,w=f(["function getLaunchedToken(address) view returns ((address token,address curve,address deployer,address creatorFeeRecipient,address pairToken,uint256 graduationThreshold,uint24 poolFee,int24 tickSpacing,uint16 creatorTaxBps,bool buybackEnabled,uint8 phase,uint256 sweptQuote,uint256 sweptTokens,uint256 sweptAt,bool exists))","function memeHook() view returns (address)"]),l=f(["function factory() view returns (address)","function getReserves() view returns (uint256 quoteReserve,uint256 tokenReserve)"]),v=f(["function getSlot0(bytes32) view returns (uint160,int24,uint24,uint24)","function getLiquidity(bytes32) view returns (uint128)"]);async function A(t,r,n){if(t.chainId!==o||!Number.isInteger(t.decimals)||t.decimals<0||t.decimals>255)throw new s("No supported Pons reference price on this chain or for these token decimals.");let e=await r.readContract({address:p.factory.address,abi:w,functionName:"getLaunchedToken",args:[t.address],blockNumber:n});if(!e.exists||!u(e.token,t.address)||e.pairToken.toLowerCase()!==h)throw new s("No supported native-ETH Pons launch reference price.");let m=10n**BigInt(t.decimals);if(e.phase===0){let[c,[a,i]]=await Promise.all([r.readContract({address:e.curve,abi:l,functionName:"factory",blockNumber:n}),r.readContract({address:e.curve,abi:l,functionName:"getReserves",blockNumber:n})]);if(!u(c,p.factory.address)||a<=0n||i<=0n)throw new s("The Pons curve reference price is unavailable.");return{numerator:a*m,denominator:i*10n**18n}}if(e.phase===2){let c=await r.readContract({address:p.factory.address,abi:w,functionName:"memeHook",blockNumber:n}),a=b(g([{type:"address"},{type:"address"},{type:"uint24"},{type:"int24"},{type:"address"}],[h,t.address,e.poolFee,e.tickSpacing,c])),[i,y]=await Promise.all([r.readContract({address:d[o].ponsTrade.state_view.address,abi:v,functionName:"getSlot0",args:[a],blockNumber:n}),r.readContract({address:d[o].ponsTrade.state_view.address,abi:v,functionName:"getLiquidity",args:[a],blockNumber:n})]);if(i[0]<=0n||y<=0n)throw new s("The graduated Pons pool reference price is unavailable.");return{numerator:(1n<<192n)*m,denominator:i[0]**2n*10n**18n}}throw new s("The Pons launch has no active reference price in this phase.")}export{A as a};
@@ -0,0 +1 @@
1
+ import{a as R,c as I}from"./SCG5HWMN.js";import{d as g,e as A,f as b,j as x}from"./NWNYJ26T.js";import{a}from"./XSD5NL7J.js";import{a as y}from"./JXOEJPJ4.js";import{erc20Abi as D,parseAbi as P}from"viem";var T="https://api.relay.link",C="0x0000000000000000000000000000000000000000",d=Object.freeze({recipient:"0x856bb126188bDB5e425D3ac9D59E9ffBD12e6ECf",bps:25});function F(e){return{...i(e),includeProtocolData:!0,appFees:[{recipient:d.recipient,fee:String(d.bps)}]}}function f(){throw new a("Relay did not confirm the Oak fee of 0.25% to the treasury with matching amount and recipient. Request a fresh quote.")}function _(e){try{let n=i(e),r=l(i(n.details).currencyIn),t=i(i(n.fees).app),o=l(t),u=(BigInt(r.amount)*BigInt(d.bps)/10000n).toString();if((o.amount!==u||h(t.minimumAmount)!==u||o.token.address!==r.token.address||o.token.chainId!==r.token.chainId||o.token.decimals!==r.token.decimals||typeof t.amountUsd!="string"||!/^(0|[1-9]\d*)(?:\.\d+)?$/.test(t.amountUsd)||t.amountUsd.length>100)&&f(),(t.recipient!==void 0&&m(t.recipient)!==d.recipient.toLowerCase()||t.fee!==void 0&&t.fee!==String(d.bps))&&f(),n.appFees!==void 0){let p=w(n.appFees);(p.length!==1||m(i(p[0]).recipient)!==d.recipient.toLowerCase()||i(p[0]).fee!==String(d.bps))&&f()}let s=i(i(n.protocol).v2),c=w(i(s.orderData).fees);if(c.length>1&&f(),c.length===1){let p=i(c[0]),k=i(s.paymentDetails).chainId;(typeof k!="string"||p.currencyChainId!==k||typeof p.recipientChainId!="string"||m(p.recipient)!==d.recipient.toLowerCase()||m(p.currency)!==r.token.address||h(p.amount)!==u)&&f()}return{...o,recipient:d.recipient,bps:d.bps,amountUsd:t.amountUsd}}catch{return f()}}function $(e){return`Oak fee ${d.bps/100}% (\u2248 $${e.amountUsd})`}function z(e){let n=i(e),r=i(n.app),t={...l(r),recipient:d.recipient,bps:d.bps,amountUsd:String(r.amountUsd)};(!/^(0|[1-9]\d*)(?:\.\d+)?$/.test(t.amountUsd)||t.amountUsd.length>100)&&f();let o=l(n.relayer);return{oakFee:t,feeDisclosure:`Relay fee ${o.amount} base units of ${L(o.token.symbol)}; ${$(t)}. Output is already net of quoted fees; origin gas is separate.`}}var j=P(["function depositNative(address depositor, bytes32 id) payable","function depositErc20(address depositor, address token, uint256 amount, bytes32 id)"]),E=(1n<<256n)-1n;function i(e){return b(e,"Relay returned an unexpected response.")}function w(e){if(!Array.isArray(e))throw new a("Relay returned an unexpected list.");return e}function m(e){return x(e,"Provide a valid wallet or token address.",g)}function H(e){let n=m(e);return n==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"?C:n}function q(e){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)throw new a("Provide a positive integer chain ID.");return e}function h(e){if(typeof e!="string"||!/^(0|[1-9]\d*)$/.test(e)||BigInt(e)>E)throw new a("Amounts must be decimal base-unit strings within the uint256 range.");return e}function J(e){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)throw new a("Relay returned an invalid order or refund deadline. Request a fresh quote.");return e}function U(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new a("Provide a valid Relay request or order ID.");return e}function S(e){let n=i(e);if(typeof n.symbol!="string"||!n.symbol.trim()||typeof n.decimals!="number"||!Number.isInteger(n.decimals)||n.decimals<0||n.decimals>255)throw new a("Relay returned invalid token metadata.");return{address:m(n.address),chainId:q(n.chainId),decimals:n.decimals,symbol:n.symbol}}function l(e){let n=i(e);return{token:S(n.currency),amount:h(n.amount)}}function K(e){if(!e)throw new a("Relay quote does not match the requested amount, chain, recipient, minimum or transaction.")}function v(e){return e===void 0?[]:w(e).map(U)}function Q(e){if(!(e==null||e==="N/A")){if(typeof e!="string")throw new a("Relay returned an invalid failure reason.");return y(e)}}function L(e,n="symbol"){if(!(typeof e!="string"||!e.trim()))return(n==="symbol"?/^[A-Za-z0-9._-]{1,32}$/:/^[A-Za-z0-9 ()+-]{1,32}$/).test(e)?e:y(e)}async function Z(e,n,r,t,o,u){let s=await e.clientFor(o).readContract({address:n,abi:D,functionName:"allowance",args:[u,r]});if(typeof s!="bigint"||s<0n||s>E)throw new a("Could not read the Relay token allowance.");return[...s>0n?[e.approval(n,r,"0",o)]:[],e.approval(n,r,t,o)]}function G(e){return async(n,r)=>i(await N(e)(n,r))}function N(e){return async(n,r)=>{let t=n.split("?")[0],o=t==="/quote/v2";try{let u=await I(e.http,`${T}${n}`,{method:o||r!==void 0?"POST":"GET",headers:{"Content-Type":"application/json","User-Agent":"oak-relay/1.0"},...r===void 0&&!o?{}:{body:JSON.stringify(o?F(r):r)}},s=>A(s)||Array.isArray(s));return o&&_(u),u}catch(u){let s=u instanceof R?u.response.status:void 0,c=e.plainError(u);throw s===401||s===403||/HTTP (401|403)\b/.test(c)?new a("Relay requires an authorized API key for this endpoint. Ask the operator to configure a valid OAK_RELAY_API_KEY on the server with access to this resource; never pass keys in tool arguments."):t==="/prices/rates"&&(s!==void 0&&s>=500||/HTTP 5\d\d\b/.test(c))?new a("Relay exchange rates are unavailable because the upstream service failed. Retry later; no rates were returned. Use relay_token_price with chainId and address for an individual token."):new a(c)}}}export{T as a,C as b,d as c,F as d,_ as e,$ as f,z as g,j as h,i,w as j,m as k,H as l,q as m,h as n,J as o,U as p,S as q,l as r,K as s,v as t,Q as u,L as v,Z as w,G as x,N as y};
@@ -0,0 +1 @@
1
+ import{a as k}from"./22TU5PFT.js";import{e as P,i as O}from"./6D3XNCOX.js";import{a as g,b as f,f as E,g as S}from"./QPY6UTLU.js";import{a as h,w as M}from"./KLEJ3W4T.js";import{a as y}from"./66F5ZH34.js";import{c as v,g as C}from"./NWNYJ26T.js";import{b}from"./TI727O2H.js";import{a as l}from"./XSD5NL7J.js";import{encodeFunctionData as c,parseAbi as H,zeroAddress as R}from"viem";var r=H(["function owner() view returns (address)","function feeTo() view returns (address)","function feeToSetter() view returns (address)","function protocolFeeController() view returns (address)","function setFeeTo(address)","function setFeeToSetter(address)","function setOwner(address)","function enableFeeAmount(uint24,int24)","function setFeeProtocol(uint8,uint8)","function collectProtocol(address,uint128,uint128) returns (uint128,uint128)","function transferOwnership(address)","function setProtocolFeeController(address)","function setProtocolFee((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks),uint24)","function collectProtocolFees(address recipient,address currency,uint256 amount) returns (uint256)"]),K=["set_fee_recipient","set_fee_setter","set_owner","enable_fee","set_pool_fee","collect_protocol","set_controller"],V={version:{description:'Uniswap version: "v2" for pairs, "v3" for concentrated liquidity or "v4" for PoolManager.',type:"string",enum:["v2","v3","v4"]},operation:{description:"set_fee_recipient/set_fee_setter: v2 roles; set_owner: owner; enable_fee: v3 tier; set_pool_fee: protocol fees; collect_protocol: collect fees; set_controller: v4 controller.",type:"string",enum:K},target:{...v,description:"Intended fee recipient, fee setter, owner or controller address for the selected administrative operation."},token0:{...v,description:"Lower sorted ERC-20 token address; use WETH for native ETH in v3."},token1:{...v,description:"Higher sorted ERC-20 token address."},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"integer"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"integer"},fee0:{description:"Token0 or zero-for-one protocol fee: v3 divisor 0 (off) or 4\u201310; v4 pips, hundredths of a basis point, from 0 to 1000 (1000 = 0.1%).",type:"integer"},fee1:{description:"Token1 or one-for-zero protocol fee: v3 divisor 0 (off) or 4\u201310; v4 pips, hundredths of a basis point, from 0 to 1000 (1000 = 0.1%).",type:"integer"},currency:{...v,description:"Address of the currency whose protocol fees are collected; the zero address means native ETH."},amount:y('Amount of currency in base units; use currency decimals. Example: "1000000" = 1 currency at 6 decimals.'),amount0Max:y('Maximum amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'),amount1Max:y('Maximum amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'),poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object"}};function G(_){let x=async e=>{let i=_.clientFor(b);if(e==="v2"){let[t,o]=await Promise.all([i.readContract({address:k,abi:r,functionName:"feeToSetter"}),i.readContract({address:k,abi:r,functionName:"feeTo"})]);return{version:e,contract:k,owner:t,feeRecipient:o}}if(e==="v3")return{version:e,contract:P.factory,owner:await i.readContract({address:P.factory,abi:r,functionName:"owner"})};if(e==="v4"){let[t,o]=await Promise.all([i.readContract({address:h,abi:r,functionName:"owner"}),i.readContract({address:h,abi:r,functionName:"protocolFeeController"})]);return{version:e,contract:h,owner:t,controller:o}}throw new l("Provide protocol version v2, v3 or v4.")};return{tools:[{name:"uniswap_protocol_status",inputSchema:{type:"object",additionalProperties:!1,required:["version"],properties:{version:V.version}},async execute(e){return S(e,["version"]),x(e.version)}},{name:"uniswap_protocol_admin",inputSchema:{type:"object",additionalProperties:!1,required:["version","operation"],properties:V},async execute(e,i){let{version:t,operation:o}=e,w=await x(t),I=_.clientFor(b),T=t==="v4"&&["set_pool_fee","collect_protocol"].includes(String(o))?"controller"in w?w.controller:void 0:w.owner;if(!T||!C(T,i))throw new l("The signing wallet does not hold the required Uniswap owner/controller role.");let N=w.contract,s,a,A=()=>{let n=f(e.target);if(n===R)throw new l("Administration target must be nonzero.");return n},d=(n,p,u,m)=>{if(typeof n!="number"||!Number.isInteger(n)||n<u||n>m)throw new l(`${p} must be an integer from ${u} to ${m}.`);return n};if(t==="v2"&&o==="set_fee_recipient")a=["target"],s=c({abi:r,functionName:"setFeeTo",args:[f(e.target)]});else if(t==="v2"&&o==="set_fee_setter")a=["target"],s=c({abi:r,functionName:"setFeeToSetter",args:[A()]});else if(t==="v3"&&o==="set_owner")a=["target"],s=c({abi:r,functionName:"setOwner",args:[A()]});else if(t==="v3"&&o==="enable_fee")a=["fee","tickSpacing"],s=c({abi:r,functionName:"enableFeeAmount",args:[d(e.fee,"fee",0,999999),d(e.tickSpacing,"tickSpacing",1,16383)]});else if(t==="v3"&&["set_pool_fee","collect_protocol"].includes(String(o))){a=["token0","token1","fee",...o==="set_pool_fee"?["fee0","fee1"]:["amount0Max","amount1Max"]];let n=f(e.token0),p=f(e.token1),u=d(e.fee,"fee",0,999999);if(N=await I.readContract({address:P.factory,abi:O,functionName:"getPool",args:[n,p,u]}),N===R)throw new l("No factory-verified v3 pool exists for these tokens and fee.");if(o==="set_pool_fee"){let m=z=>{let F=d(z,"fee divisor",0,10);if(F!==0&&F<4)throw new l("V3 protocol fee divisors must be zero or 4 through 10.");return F};s=c({abi:r,functionName:"setFeeProtocol",args:[m(e.fee0),m(e.fee1)]})}else s=c({abi:r,functionName:"collectProtocol",args:[i,g(e.amount0Max,"amount0Max",128,!0),g(e.amount1Max,"amount1Max",128,!0)]})}else if(t==="v4"&&o==="set_owner")a=["target"],s=c({abi:r,functionName:"transferOwnership",args:[A()]});else if(t==="v4"&&o==="set_controller")a=["target"],s=c({abi:r,functionName:"setProtocolFeeController",args:[f(e.target)]});else if(t==="v4"&&o==="set_pool_fee"){a=["poolKey","fee0","fee1"];let n=M(e.poolKey),p=d(e.fee0,"fee0 pips",0,1e3),u=d(e.fee1,"fee1 pips",0,1e3);s=c({abi:r,functionName:"setProtocolFee",args:[n,p+(u<<12)]})}else if(t==="v4"&&o==="collect_protocol")a=["currency","amount"],s=c({abi:r,functionName:"collectProtocolFees",args:[i,f(e.currency),g(e.amount,"amount",256,!0)]});else throw new l("This operation is not supported by the selected Uniswap protocol version.");return S(e,["version","operation",...a]),E(_,[_.unsignedTx({to:N,data:s,value:"0",chainId:b,description:`Uniswap ${t} protocol administration: ${o}. Role holder ${i}.`})],i,"Privileged protocol operation. Review the exact role/recipient/fee changes. Protocol fee collections pay the signing wallet; no wallet token approval is required.")}}]}}export{r as a,G as b};
@@ -1 +1 @@
1
- import{c as D}from"./3K2N5VFH.js";import{b as O,g as M,i as A,j as B,k as T,l as P,m as I,n as U,r as k,s as F,v as f,x as z}from"./QJNLLI6N.js";import{a as w,e as _}from"./NWNYJ26T.js";import{a as y}from"./FWD4L3CJ.js";import{a as d}from"./XSD5NL7J.js";function $(u){return{...u,token:{...u.token,symbol:f(u.token.symbol)??"unknown"}}}var Q=u=>{let N=z(u);async function G(t,r){let g=T(r),i=I(t.originChainId),e=I(t.destinationChainId);if(i!==y&&e!==y)throw new d(`A Relay quote must start or end on chain ${y}.`);let h=P(t.originCurrency??O),b=P(t.destinationCurrency??O),c=T(t.recipient??g),a=U(t.amount);if(a==="0")throw new d("Provide a positive bridge amount.");let n=t.tradeType??"EXACT_INPUT";if(!["EXACT_INPUT","EXACT_OUTPUT","EXPECTED_OUTPUT"].includes(String(n)))throw new d("Choose EXACT_INPUT, EXACT_OUTPUT or EXPECTED_OUTPUT.");let m={};for(let E of["includedSwapSources","excludedSwapSources","includedOriginSwapSources","includedDestinationSwapSources"]){let p=t[E];if(p!==void 0){if(!Array.isArray(p)||p.length>100||p.some(j=>typeof j!="string"||!/^[A-Za-z0-9._ -]{1,128}$/.test(j)))throw new d("Provide valid Relay swap source names.");m[E]=p}}let S=await N("/quote/v2",{user:g,recipient:c,originChainId:i,destinationChainId:e,originCurrency:h,destinationCurrency:b,amount:a,tradeType:n,...m}),o=A(S.details),l=$(k(o.currencyIn)),s=$(k(o.currencyOut)),C=U(A(o.currencyOut).minimumAmount);F(T(o.sender)===g&&T(o.recipient)===c&&l.token.chainId===i&&l.token.address===h&&(n==="EXACT_INPUT"?l.amount===a:s.amount===a)&&s.token.chainId===e&&s.token.address===b&&BigInt(C)<=BigInt(s.amount));let H=Object.fromEntries(Object.entries(A(S.fees)).map(([E,p])=>[E,$(k(p))])),R=typeof o.timeEstimate=="number"&&Number.isFinite(o.timeEstimate)&&o.timeEstimate>=0?o.timeEstimate:void 0,v=M(S.fees),X=e===y,x=X?"relay_bridge_in":"relay_bridge_out",q=n==="EXACT_INPUT"&&Object.keys(m).length===0&&i!==e&&(!X||D(i)!==void 0);return{executable:!1,nextAction:q?x:void 0,originChainId:i,destinationChainId:e,recipient:c,tradeType:n,amountIn:l,amountOut:s,minAmountOut:{token:s.token,amount:C},fees:H,...v,slippage:{source:"provider",minimumAmount:C},...R===void 0?{}:{timeEstimateSeconds:R},summary:`${v.feeDisclosure} Read-only Relay estimate: ${l.amount} base units of ${l.token.symbol} (${l.token.decimals} decimals) on chain ${i} for about ${s.amount}, minimum ${C}, base units of ${s.token.symbol} (${s.token.decimals} decimals) on chain ${e} for ${c}. Slippage: selected by Relay; Oak sent no slippage setting. The returned minimum above is the quote floor. Relay fees are already deducted from the output; origin gas is separate. Nothing was built or signed, and this estimate cannot be executed. ${q?`To bridge, call ${x}; it fetches a fresh quote and shows its own preview for human confirmation.`:"This estimate shape has no matching Oak execution path. No action will preserve these trade type or routing options."}`}}async function Z(t){let r=t.chainId===void 0?void 0:I(t.chainId),i=B((await N("/chains")).chains).map(A).flatMap(e=>{if(typeof e.id!="number"||!Number.isSafeInteger(e.id)||e.id<=0)return[];if(r!==void 0&&e.id!==r)return[];let h=e.disabled===!1,b=_(e.currency)?e.currency:{},c={chainId:e.id,name:f(e.displayName,"name")??f(e.name,"name")??String(e.id),vmType:f(e.vmType),nativeCurrency:{symbol:f(b.symbol),decimals:typeof b.decimals=="number"?b.decimals:void 0},bridgeIn:e.id!==y&&h&&D(e.id)!==void 0,bridgeOut:e.id!==y&&h&&e.vmType==="evm"};if(r===void 0)return[c];let a=new Map;for(let n of[...Array.isArray(e.featuredTokens)?e.featuredTokens:[],...Array.isArray(e.erc20Currencies)?e.erc20Currencies:[]]){if(!_(n)||typeof n.address!="string"||!new RegExp(w).test(n.address)||typeof n.decimals!="number"||!Number.isInteger(n.decimals)||n.decimals<0||n.decimals>255)continue;let m=T(n.address);a.has(m)||a.set(m,{address:m,symbol:f(n.symbol)??"unknown",decimals:n.decimals,bridgeable:n.supportsBridging===!0})}return[{...c,currencies:[...a.values()]}]});if(r!==void 0&&!i.length)throw new d(`Relay does not list chain ${r}.`);return{chains:i,summary:`${i.length} Relay chain${i.length===1?"":"s"}. bridgeIn marks origins relay_bridge_in can build from; bridgeOut marks destinations relay_bridge_out can reach. Currency lists are Relay-reported display data; bridgeable false means Relay does not bridge that token. Confirm token addresses before bridging.`}}return{tools:[{name:"relay_quote",inputSchema:{type:"object",additionalProperties:!1,required:["originChainId","destinationChainId","amount"],properties:{originChainId:{type:"integer",minimum:1,description:"Origin chain ID."},destinationChainId:{type:"integer",minimum:1,description:"Destination chain ID."},originCurrency:{type:"string",pattern:w,description:"Origin token address; defaults to the origin chain\u2019s native token."},destinationCurrency:{type:"string",pattern:w,description:"Destination token address; defaults to the destination chain\u2019s native token."},amount:{type:"string",pattern:"^[1-9][0-9]*$",description:'Input token amount for EXACT_INPUT, otherwise output token amount, in base units using that token\u2019s decimals (USDG has 6: "1000000" = 1 USDG).'},recipient:{type:"string",pattern:w,description:"Destination recipient address; defaults to your wallet."},tradeType:{type:"string",enum:["EXACT_INPUT","EXACT_OUTPUT","EXPECTED_OUTPUT"],description:"EXACT_INPUT fixes input; EXACT_OUTPUT fixes output; EXPECTED_OUTPUT targets output."},...Object.fromEntries(["includedSwapSources","excludedSwapSources","includedOriginSwapSources","includedDestinationSwapSources"].map(t=>[t,{type:"array",description:t==="excludedSwapSources"?"Swap sources to exclude.":t==="includedOriginSwapSources"?"Origin swap sources to include.":t==="includedDestinationSwapSources"?"Destination swap sources to include.":"Swap sources to include.",maxItems:100,items:{type:"string",pattern:"^[A-Za-z0-9._ -]{1,128}$"}}]))}},execute:async(t,r)=>{try{return await G(t,r)}catch(g){throw new d(u.plainError(g))}}},{name:"relay_chains",inputSchema:{type:"object",additionalProperties:!1,properties:{chainId:{type:"integer",minimum:1,description:"Filter by chain ID."}}},execute:async t=>{try{return await Z(t)}catch(r){throw new d(u.plainError(r))}}}]}};export{Q as a};
1
+ import{c as D}from"./DXAPKN7H.js";import{b as O,g as M,i as A,j as B,k as T,l as P,m as I,n as U,r as k,s as F,v as f,x as z}from"./Y64GFBTA.js";import{a as w,e as _}from"./NWNYJ26T.js";import{b as y}from"./TI727O2H.js";import{a as d}from"./XSD5NL7J.js";function $(u){return{...u,token:{...u.token,symbol:f(u.token.symbol)??"unknown"}}}var Q=u=>{let N=z(u);async function G(t,r){let g=T(r),i=I(t.originChainId),e=I(t.destinationChainId);if(i!==y&&e!==y)throw new d(`A Relay quote must start or end on chain ${y}.`);let h=P(t.originCurrency??O),b=P(t.destinationCurrency??O),c=T(t.recipient??g),a=U(t.amount);if(a==="0")throw new d("Provide a positive bridge amount.");let n=t.tradeType??"EXACT_INPUT";if(!["EXACT_INPUT","EXACT_OUTPUT","EXPECTED_OUTPUT"].includes(String(n)))throw new d("Choose EXACT_INPUT, EXACT_OUTPUT or EXPECTED_OUTPUT.");let m={};for(let E of["includedSwapSources","excludedSwapSources","includedOriginSwapSources","includedDestinationSwapSources"]){let p=t[E];if(p!==void 0){if(!Array.isArray(p)||p.length>100||p.some(j=>typeof j!="string"||!/^[A-Za-z0-9._ -]{1,128}$/.test(j)))throw new d("Provide valid Relay swap source names.");m[E]=p}}let S=await N("/quote/v2",{user:g,recipient:c,originChainId:i,destinationChainId:e,originCurrency:h,destinationCurrency:b,amount:a,tradeType:n,...m}),o=A(S.details),l=$(k(o.currencyIn)),s=$(k(o.currencyOut)),C=U(A(o.currencyOut).minimumAmount);F(T(o.sender)===g&&T(o.recipient)===c&&l.token.chainId===i&&l.token.address===h&&(n==="EXACT_INPUT"?l.amount===a:s.amount===a)&&s.token.chainId===e&&s.token.address===b&&BigInt(C)<=BigInt(s.amount));let H=Object.fromEntries(Object.entries(A(S.fees)).map(([E,p])=>[E,$(k(p))])),R=typeof o.timeEstimate=="number"&&Number.isFinite(o.timeEstimate)&&o.timeEstimate>=0?o.timeEstimate:void 0,v=M(S.fees),X=e===y,x=X?"relay_bridge_in":"relay_bridge_out",q=n==="EXACT_INPUT"&&Object.keys(m).length===0&&i!==e&&(!X||D(i)!==void 0);return{executable:!1,nextAction:q?x:void 0,originChainId:i,destinationChainId:e,recipient:c,tradeType:n,amountIn:l,amountOut:s,minAmountOut:{token:s.token,amount:C},fees:H,...v,slippage:{source:"provider",minimumAmount:C},...R===void 0?{}:{timeEstimateSeconds:R},summary:`${v.feeDisclosure} Read-only Relay estimate: ${l.amount} base units of ${l.token.symbol} (${l.token.decimals} decimals) on chain ${i} for about ${s.amount}, minimum ${C}, base units of ${s.token.symbol} (${s.token.decimals} decimals) on chain ${e} for ${c}. Slippage: selected by Relay; Oak sent no slippage setting. The returned minimum above is the quote floor. Relay fees are already deducted from the output; origin gas is separate. Nothing was built or signed, and this estimate cannot be executed. ${q?`To bridge, call ${x}; it fetches a fresh quote and shows its own preview for human confirmation.`:"This estimate shape has no matching Oak execution path. No action will preserve these trade type or routing options."}`}}async function Z(t){let r=t.chainId===void 0?void 0:I(t.chainId),i=B((await N("/chains")).chains).map(A).flatMap(e=>{if(typeof e.id!="number"||!Number.isSafeInteger(e.id)||e.id<=0)return[];if(r!==void 0&&e.id!==r)return[];let h=e.disabled===!1,b=_(e.currency)?e.currency:{},c={chainId:e.id,name:f(e.displayName,"name")??f(e.name,"name")??String(e.id),vmType:f(e.vmType),nativeCurrency:{symbol:f(b.symbol),decimals:typeof b.decimals=="number"?b.decimals:void 0},bridgeIn:e.id!==y&&h&&D(e.id)!==void 0,bridgeOut:e.id!==y&&h&&e.vmType==="evm"};if(r===void 0)return[c];let a=new Map;for(let n of[...Array.isArray(e.featuredTokens)?e.featuredTokens:[],...Array.isArray(e.erc20Currencies)?e.erc20Currencies:[]]){if(!_(n)||typeof n.address!="string"||!new RegExp(w).test(n.address)||typeof n.decimals!="number"||!Number.isInteger(n.decimals)||n.decimals<0||n.decimals>255)continue;let m=T(n.address);a.has(m)||a.set(m,{address:m,symbol:f(n.symbol)??"unknown",decimals:n.decimals,bridgeable:n.supportsBridging===!0})}return[{...c,currencies:[...a.values()]}]});if(r!==void 0&&!i.length)throw new d(`Relay does not list chain ${r}.`);return{chains:i,summary:`${i.length} Relay chain${i.length===1?"":"s"}. bridgeIn marks origins relay_bridge_in can build from; bridgeOut marks destinations relay_bridge_out can reach. Currency lists are Relay-reported display data; bridgeable false means Relay does not bridge that token. Confirm token addresses before bridging.`}}return{tools:[{name:"relay_quote",inputSchema:{type:"object",additionalProperties:!1,required:["originChainId","destinationChainId","amount"],properties:{originChainId:{type:"integer",minimum:1,description:"Origin chain ID."},destinationChainId:{type:"integer",minimum:1,description:"Destination chain ID."},originCurrency:{type:"string",pattern:w,description:"Origin token address; defaults to the origin chain\u2019s native token."},destinationCurrency:{type:"string",pattern:w,description:"Destination token address; defaults to the destination chain\u2019s native token."},amount:{type:"string",pattern:"^[1-9][0-9]*$",description:'Input token amount for EXACT_INPUT, otherwise output token amount, in base units using that token\u2019s decimals (USDG has 6: "1000000" = 1 USDG).'},recipient:{type:"string",pattern:w,description:"Destination recipient address; defaults to your wallet."},tradeType:{type:"string",enum:["EXACT_INPUT","EXACT_OUTPUT","EXPECTED_OUTPUT"],description:"EXACT_INPUT fixes input; EXACT_OUTPUT fixes output; EXPECTED_OUTPUT targets output."},...Object.fromEntries(["includedSwapSources","excludedSwapSources","includedOriginSwapSources","includedDestinationSwapSources"].map(t=>[t,{type:"array",description:t==="excludedSwapSources"?"Swap sources to exclude.":t==="includedOriginSwapSources"?"Origin swap sources to include.":t==="includedDestinationSwapSources"?"Destination swap sources to include.":"Swap sources to include.",maxItems:100,items:{type:"string",pattern:"^[A-Za-z0-9._ -]{1,128}$"}}]))}},execute:async(t,r)=>{try{return await G(t,r)}catch(g){throw new d(u.plainError(g))}}},{name:"relay_chains",inputSchema:{type:"object",additionalProperties:!1,properties:{chainId:{type:"integer",minimum:1,description:"Filter by chain ID."}}},execute:async t=>{try{return await Z(t)}catch(r){throw new d(u.plainError(r))}}}]}};export{Q as a};
@@ -0,0 +1,7 @@
1
+ import{b as E,f as P,g as w,j as ne,k as C,m as H,n as d,o as T,p as L,r as N,s as se}from"./H3E7UD2X.js";import{Q as X,R as v,U as I,V as ee,X as te,b as n,e as j,f as G,g as x,m as F,n as q,o as K,p as z,q as S,r as y,s as Y,t as Z,u as Q,v as V,w as J,x as W}from"./V5YSJKRH.js";import{a as D}from"./XSD5NL7J.js";var M=6,re=/^[A-Za-z0-9._-]{1,12}$/;function de(e){return re.test(e)?e:"the stock token"}function $(e){return e instanceof D?e.message:"unexpected error"}function k(e,t=M){return C({redeemOutBase:e,amountBase:0n,decimals:t})}function oe(e,t,a){let _={amount_usd:d(t),gross_usd:d(e.grossUsd),horizon:a,costs_usd:d(e.costsUsd),net_usd:d(e.netUsd)};return e.suggestUsd===void 0?n(v,_):n(X,{..._,suggest_usd:`$${e.suggestUsd}`})}function ie(e,t,a,_){let f={id:"A",project:"layerbank"},s=k(t);if(!Number.isFinite(e.rateBasePct)||e.rateBasePct<0)return _.push("LayerBank rate was malformed"),{option:{...f,offered:!1,reason:"cant_check"},block:n(S,{})};if(!e.open)return{option:{...f,offered:!1,reason:"closed"},block:n(Y,{})};if(e.capRoomBase<t)return{option:{...f,offered:!1,reason:"no_room"},block:n(Z,{cap_room_usd:d(k(e.capRoomBase)),amount_usd:d(s)})};let o=e.bonus,i=o!==void 0&&Number.isFinite(o.ratePct)&&o.ratePct>0&&o.endsAt>a,u=e.rateBasePct+(i?o.ratePct:0),O=i?H(a,o.endsAt):0,c=P(e.gasInUsd),l=P(e.gasOutUsd),p=c.usd+l.usd,h=c.estimatedHigh||l.estimatedHigh,m=ne({amountUsd:s,baseRatePct:e.rateBasePct,bonusRatePct:i?o.ratePct:0,bonusDays:O,days:30}),g=w({gross:m,costs:p,amount:s}),A=n(F,{lb_base_rate:T(e.rateBasePct),bonus_clause:i?n(q,{lb_bonus_rate:T(o.ratePct),bonus_days:N(O),lb_base_rate:T(e.rateBasePct)}):"",lb_cash_usd:d(k(e.cashUsdgBase)),lb_gas_in_usd:d(c.usd),lb_gas_out_usd:d(l.usd)});return h&&(A+=`
2
+ ${n(I,{})}`),g.tooSmall&&(A+=`
3
+ ${oe(g,s,N(30))}`),{option:{...f,offered:!0,amountUsd:s,ratePct:u,grossUsd:m,costsUsd:p,netUsd:g.netUsd,tooSmall:g.tooSmall,...g.suggestUsd===void 0?{}:{suggestUsd:g.suggestUsd},estimatedHigh:h},block:A,gross30d:m,horizonEndsAt:a+30*86400}}function ue(e,t,a){return e.filter(s=>s.kind==="stable"&&!s.matured&&s.endsAt>t).filter(s=>s.unitDecimals===M&&Number.isFinite(s.ratePct)?!0:(a.push(`Pendle term ${s.market} skipped: its USDG figures were not in the expected form`),!1)).sort((s,o)=>o.liquidityUsd-s.liquidityUsd||s.endsAt-o.endsAt)[0]}async function ce(e,t,a,_,f){let s={id:"B",project:"pendle"};if(!t)return{option:{...s,offered:!1,reason:"no_term"},block:n(z,{})};let o={option:{...s,offered:!1,reason:"cant_check"},block:n(y,{})},i=k(a),u;try{u=await e.pendleQuoteCosts(t.market,a)}catch(B){return f.push(`Pendle quote failed: ${$(B)}`),o}if(typeof u.ptOutBase!="bigint"||u.ptOutBase<=0n)return f.push("Pendle quote was malformed"),o;let O=u.ptOutBase,c=C({redeemOutBase:O,amountBase:a,decimals:M}),l=P(t.gasInUsd),p=P(t.gasOutUsd),h=Number.isFinite(u.feeUsd)&&u.feeUsd>0?u.feeUsd:0,m=l.usd+p.usd,g=l.estimatedHigh||p.estimatedHigh,A=H(_,t.endsAt),b=w({gross:c,costs:m,amount:i}),R=L(t.endsAt),U=n(K,{pendle_end_date:R,pendle_rate:T(t.ratePct),pendle_payout_usd:d(k(O)),pendle_unit_usd:d(i),pendle_cost_in_usd:d(h+l.usd),pendle_gas_out_usd:d(p.usd)});return g&&(U+=`
4
+ ${n(I,{})}`),b.tooSmall&&(U+=`
5
+ ${oe(b,i,`the ${N(A)} until ${R}`)}`),{option:{...s,offered:!0,amountUsd:i,ratePct:t.ratePct,market:t.market,endsAt:t.endsAt,grossUsd:c,costsUsd:m,netUsd:b.netUsd,tooSmall:b.tooSmall,...b.suggestUsd===void 0?{}:{suggestUsd:b.suggestUsd},estimatedHigh:g},block:U,gross30d:A>30?c*(30/A):c,horizonEndsAt:t.endsAt}}function le(e){return e.filter(t=>t.matured&&t.ptBalanceBase>0n).map(t=>{let a=L(t.endsAt);if(t.kind==="stock")return n(te,{stock_symbol:de(t.unitSymbol),pendle_end_date:a});let _=se(t.ptBalanceBase,t.unitDecimals);return n(ee,{pendle_end_date:a,pt_amount:_,usdg_out:_})})}function fe(e){if(e!==void 0){if(!/^[0-9]+$/.test(e))throw new D("The amount must be a whole number of USDG base units (6 decimals), for example 50000000 for 50 USDG.");return BigInt(e)}}async function ge(e,t,a,_={}){let f=fe(_.amount),s=t.nowSec(),o=[],[i,u]=await Promise.allSettled([e.layerbank(a),e.pendleTerms(a)]),O=i.status==="fulfilled"?i.value:void 0,c=u.status==="fulfilled"?u.value:void 0;i.status==="rejected"&&o.push(`LayerBank could not be read: ${$(i.reason)}`),u.status==="rejected"&&o.push(`Pendle could not be read: ${$(u.reason)}`),o.push(...O?.checks??[],...c?.flatMap(r=>r.checks)??[]);let l=O?.walletUsdgBase;if(l===void 0)try{l=await t.usdgBalance(a)}catch{o.push("wallet USDG balance could not be read")}let p=f??l,h=c?le(c):[],m=(r,ae)=>({card:[...h,...r].join(`
6
+
7
+ `),options:ae,notices:h,checks:[...new Set(o)]});if(p===void 0)return m([n(S,{}),n(y,{})],[{id:"A",project:"layerbank",offered:!1,reason:"cant_check"},{id:"B",project:"pendle",offered:!1,reason:"cant_check"}]);if(p===0n){let r=0n;try{r=await t.ethBalance(a)}catch{o.push("wallet ETH balance could not be read")}return r>0n?m([n(J,{})],[]):m([n(W,{})],[])}let g=O?ie(O,p,s,o):{option:{id:"A",project:"layerbank",offered:!1,reason:"cant_check"},block:n(S,{})},A=c?await ce(e,ue(c,s,o),p,s,o):{option:{id:"B",project:"pendle",offered:!1,reason:"cant_check"},block:n(y,{})},b=[g,A],U=[f===void 0||f===l?n(j,{amount_usd:d(k(p))}):n(l!==void 0&&f<l?G:x,{amount_usd:d(k(p))}),...b.map(r=>r.block)],B=b.filter(r=>r.option.offered&&!r.option.tooSmall).map(r=>r.option.id);if(B.length>0){let r=B.length===2?"A, B, or neither":`${B[0]}, or neither`;U.push(n(Q,{choices:r}))}else b.some(r=>r.option.offered)&&U.push(n(V,{}));return m(U,b.map(r=>r.option))}export{ge as a};
@@ -0,0 +1 @@
1
+ import{A as Ee,a as Be,b as he,g as Z,h as be,i as Oe,m as ee,n as D,y as ke}from"./GYPMUYB5.js";import{b as y,c as qe}from"./GK3D7OKG.js";import{a as fe,b as H}from"./Z7FGEWO2.js";import{a as Q}from"./43LI5NKJ.js";import{a as Ie}from"./IOYRL6AY.js";import{a as $e}from"./66F5ZH34.js";import{c as le,g as P}from"./NWNYJ26T.js";import{b as Se}from"./IX3GZMTM.js";import{b,j as me}from"./TI727O2H.js";import{a as d}from"./XSD5NL7J.js";import{a as pe}from"./JXOEJPJ4.js";import{randomUUID as ze}from"node:crypto";import{encodeAbiParameters as ne,encodeFunctionData as we,erc20Abi as ge,getAddress as F,parseAbi as X,parseAbiParameters as oe,zeroAddress as K}from"viem";var Re=me[b].pons,C=me[b].ponsTrade,_e=X(["function getLaunchedToken(address) view returns ((address token,address curve,address deployer,address creatorFeeRecipient,address pairToken,uint256 graduationThreshold,uint24 poolFee,int24 tickSpacing,uint16 creatorTaxBps,bool buybackEnabled,uint8 phase,uint256 sweptQuote,uint256 sweptTokens,uint256 sweptAt,bool exists))"]),te=X(["function getReserves() view returns (uint256 quoteReserve,uint256 tokenReserve)","function feeBps() view returns (uint256)","function creatorTaxBps() view returns (uint256)","function currentSnipeTaxBps(address) view returns (uint256)","function sellableTokens() view returns (uint256)","function buy(uint256 quoteIn,uint256 minTokensOut,address recipient) payable returns (uint256)","function sell(uint256 tokensIn,uint256 minQuoteOut,address recipient) returns (uint256)"]),He=X(["function quoteExactInputSingle(((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256 amountOut,uint256 gasEstimate)"]),Ke=X(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),Xe=X(["function approve(address token,address spender,uint160 amount,uint48 expiration)"]),je=oe("((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 amountIn,uint128 amountOutMinimum,uint256 minHopPriceX36,bytes hookData)"),Ge={address:fe,chainId:b,decimals:18,symbol:"ETH"},Qe="There is no on-chain expiry. The signed transaction is protected by its minimum output.",Ve="This trade must be sent within 5 minutes of its quote. If you approve later, Oak shows you fresh terms first.",We=`Quote expiry is enforced by Oak before signing only. ${Qe}`,$=10000n,Te=(1n<<256n)-1n,Ne=(1n<<128n)-1n,I=(n,t)=>({token:n,amount:t.toString()}),Ce=(n,t)=>(n+t-1n)/t,Me="Reuse existing exact allowance";async function Je(n,t,r,o,c){try{let e=await n.readContract({address:t,abi:ge,functionName:"allowance",args:[r,o],blockNumber:c});return typeof e=="bigint"?e:void 0}catch{return}}var Ye={type:"object",additionalProperties:!1,required:["token","amountIn"],properties:{token:{...le,description:"Pons launch token address on chain 4663."},amountIn:$e('Input in base units: pair token for buys (use its decimals), launch token for sells (18 decimals). Examples: "1000000" = 1 pair token at 6 decimals; "1000000000000000000" = 1 launch token.'),pairToken:{...le,description:"The launch pair from pons_status. Required to buy a custom-pair launch, so amountIn is never read in the wrong units; omit or use the zero address for native ETH."},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:he}}};function De(n,t,r,o){if(n===void 0){if(r&&y(t)!==K)throw new d(`This Pons launch is paired with ${o}; amountIn is in that token's base units. Repeat with pairToken "${t}" to confirm the input asset.`);return}if(typeof n!="string")throw new d("pairToken must be a token address.");if(Q(n),!P(y(n),y(t)))throw new Z(`This Pons launch trades only against ${o}.`)}async function Fe(n,t,r,o,{quoteOnly:c=!1,curveOnly:e=!1,blockNumber:p}={}){if(Q(r),Object.keys(t).some(f=>!["token","amountIn","slippageBps","pairToken"].includes(f)))throw new d("Provide only token, amountIn, optional pairToken and optional slippageBps.");if(typeof t.token!="string")throw new d("Provide a launch token address.");Q(t.token);let s=F(t.token),i=Se(t.amountIn);if(i===0n||i>Te)throw new d("Trade amount must be positive and within the uint256 range.");let m=t.slippageBps??he;if(typeof m!="number"||!Number.isInteger(m)||m<0||m>=1e4)throw new d("Slippage must be an integer from 0 to 9999 basis points.");let x=f=>f*($-BigInt(m))/$,a=n.clientFor(b),l=p===void 0?await a.getBlock():await a.getBlock({blockNumber:p});if(p!==void 0&&l.number!==p)throw new d("Pons quote snapshot is unavailable.");let u=await a.readContract({address:Re.factory.address,abi:_e,functionName:"getLaunchedToken",args:[s],blockNumber:l.number});if(!u.exists||!P(u.token,s))throw new d("This address is not a Pons launch token.");if(e&&u.phase!==0)throw new Z("Pons curve quotes are only available before graduation.");if(u.phase===1)throw new d("Pons graduation is pending; the curve is closed and the pool is not ready.");if(u.phase===3)throw new d("This Pons launch was rescued and has no active trade route.");if(u.phase!==0&&u.phase!==2)throw new d("This Pons launch has an unknown trade phase.");let g=y(u.pairToken)===K,M=F(u.pairToken);if(P(M,s))throw new d("This Pons launch has an invalid pair.");let j=f=>Promise.all([a.readContract({address:f,abi:ge,functionName:"symbol",blockNumber:l.number}),a.readContract({address:f,abi:ge,functionName:"decimals",blockNumber:l.number})]),[[B,U],L]=await Promise.all([j(s),g?void 0:j(M)]),w=L?{address:M,chainId:b,symbol:pe(L[0]),decimals:L[1]}:Ge,G=g?"native ETH":`${w.symbol} (${w.address})`;De(t.pairToken,M,o,`${G}, ${w.decimals} decimals`);let V={address:s,chainId:b,symbol:pe(B),decimals:U},se=o?w:V,ie=o?V:w,q=[],re=(f,h,S,A)=>n.unsignedTx({to:f,data:h,value:S.toString(),chainId:b,description:A}),T,k,W,O=i,ve=null,ae,ye="",ue;if(u.phase===0){let f=v=>a.readContract({address:u.curve,abi:te,functionName:v,blockNumber:l.number}),[[h,S],A,R,E,_]=await Promise.all([a.readContract({address:u.curve,abi:te,functionName:"getReserves",blockNumber:l.number}),f("feeBps"),f("creatorTaxBps"),o?a.readContract({address:u.curve,abi:te,functionName:"currentSnipeTaxBps",args:[r],blockNumber:l.number}):Promise.resolve(0n),o?f("sellableTokens"):Promise.resolve(0n)]);if(h<=0n||S<=0n||A+R>$-100n)throw new d("Pons curve reserves or fee settings are unavailable.");let J=$-A-R-100n,N=E<J?E:J,Ae=v=>({base:v*A/$,creator:v*R/$,snipe:v*N/$}),Pe=v=>{let z=Ae(v);return v-z.base-z.creator-z.snipe},Y;if(o){if(_<=0n||_>=S)throw new d("The curve has no available sellable tokens.");let v=Pe(i);if(T=v*S/(h+v),T>=_){T=_;let z=T*h/(S-T)+1n;O=Ce(z*$,$-A-R-N),O>i&&(O=i)}Y=O,k=x(T),W=Ce(k*i,O),g||q.push(n.approval(w.address,u.curve,i.toString(),b))}else Y=i*h/(S+i),T=Pe(Y),k=x(T),q.push(n.approval(s,u.curve,i.toString(),b));let ce=Ae(Y);ve={base:I(w,ce.base),creator:I(w,ce.creator),snipe:I(w,ce.snipe)},ae=`Curve fees included: ${A} base, ${R} creator and ${N} opening-tax basis points, each rounded separately.`,q.push(re(u.curve,we({abi:te,functionName:o?"buy":"sell",args:[i,W??k,r]}),o&&g?i:0n,o?`Buy Pons curve tokens with ${G}.`:`Sell Pons curve tokens for ${G}.`))}else{if(i>Ne)throw new d("Trade amount exceeds the router uint128 range.");let f=qe(u.pairToken,s,u.poolFee,u.tickSpacing),h=o?y(u.pairToken):s,S=o?s:y(u.pairToken),A=P(h,f.currency0);if(T=(await a.simulateContract({address:C.quoter.address,abi:He,functionName:"quoteExactInputSingle",args:[{poolKey:f,zeroForOne:A,exactAmount:i,hookData:"0x"}],account:r,gas:Ie,blockNumber:l.number})).result[0],k=x(T),k>Ne)throw new d("Minimum output exceeds the router uint128 range.");let E=l.timestamp+300n;if(ue=E.toString(),E>=1n<<48n)throw new d("Permit2 expiry exceeds its timestamp range.");if(h!==K){let N=!c&&await Je(a,h,r,C.permit2.address,l.number)===i;N||q.push(n.approval(h,C.permit2.address,i.toString(),b)),ye=N?`${Me}: ${i} input base units already approved to Permit2. `:"",q.push(re(C.permit2.address,we({abi:Xe,functionName:"approve",args:[h,C.universal_router.address,i,Number(E)]}),0n,`${N?`${Me}. `:""}Approve the exact token amount to the Pons router through Permit2 for five minutes.`))}let _=[ne(je,[{poolKey:f,zeroForOne:A,amountIn:i,amountOutMinimum:k,minHopPriceX36:0n,hookData:"0x"}]),ne(oe("address,uint256"),[h,i]),ne(oe("address,uint256"),[S,k])],J=ne(oe("bytes,bytes[]"),["0x060c0f",_]);q.push(re(C.universal_router.address,we({abi:Ke,functionName:"execute",args:["0x10",[J],E]}),h===K?i:0n,"Trade through Pons Universal Router v2.1.2.")),ae="Quoter output is net of Pons hook fees; no additional fee is subtracted."}if(T<=0n||k<=0n||k>Te||(W??k)>Te)throw new d("Trade output or minimum is outside the supported positive range.");let xe=c?{changes:[],summary:"Quote only; preview is required before sending."}:await n.preview(q,r),de=i-O;return{txs:q,changes:xe.changes,...ue===void 0?{}:{expiresAt:ue},summary:`${o?"Buy":"Sell"} ${V.symbol} (${V.address}) on chain ${b}${g?"":` ${o?"with":"for"} ${G}`}. ${ae} ${ye}${u.phase===0?`${Qe} `:`${Ve} `}${de>0n?`Expected ${g?"native refund":"refund"}: ${n.formatAmount(de.toString(),w.decimals)} ${w.symbol}; minimum output uses the expected spend after refund. `:""}${xe.summary}`,pairToken:w,quote:{phase:u.phase,amountIn:I(se,i),amountOut:I(ie,T),minAmountOut:I(ie,k),minimumKind:"absolute",calldataMinAmountOut:I(ie,W??k),expectedSpend:I(se,O),expectedRefund:I(se,de),fees:ve,blockNumber:l.number.toString(),blockTimestamp:l.timestamp.toString()}}}function hn(n){return Ue(n,!0)}function Ue(n,t=!1,r){let o=new Map,c=e=>{if(BigInt(ee())>=BigInt(e.expiresAt))throw new be};return{name:"pons",async quote(e,p){if(e={...e,from:H(e.from),to:H(e.to)},D(e.from)&&D(e.to))throw new Z("Pons quotes require a launch token and its pair token.");let s=D(e.from)||!D(e.to)&&await Ze(n,e.from,e.to,r),i=ee(),m=await Fe(n,{token:s?e.to:e.from,amountIn:e.amountIn,slippageBps:e.slippageBps,pairToken:y(s?e.from:e.to)},p,s,{quoteOnly:!0,curveOnly:t,blockNumber:r}),x=m.txs.at(-1),a=m.quote,l=String(BigInt(r===void 0?i:a.blockTimestamp)+BigInt(Be)),u=a.minAmountOut.amount,g=a.fees,M=D(m.pairToken.address)?"native ETH base units (18 decimals)":`${m.pairToken.symbol} (${m.pairToken.address}) base units (${m.pairToken.decimals} decimals)`,j=g?`Pons curve fees included in net output: ${g.base.amount} base, ${g.creator.amount} creator and ${g.snipe.amount} opening tax, in ${M}. Oak swap fee: 0 (venue fee is never Oak income). ${We}`:"Quoter output is net of Pons hook fees; no additional fee is subtracted. Oak swap fee: 0.",B=Ee({...e,quoteId:`pons:${ze()}`,provider:"pons",wallet:p,chainId:b,router:x.to,spender:a.phase===0?x.to:C.permit2.address,expiresAt:l,data:x.data,value:x.value,amountOut:a.amountOut.amount,minAmountOut:u,blockNumber:a.blockNumber,...a.phase===0?{ponsCurveToken:s?e.to:e.from,calldataMinAmountOut:a.calldataMinAmountOut.amount}:{ponsPoolToken:s?e.to:e.from},expectedSpend:a.expectedSpend.amount,expectedRefund:a.expectedRefund.amount,feeDisclosure:j,oakFee:"0"});ke(x,B),c(B);for(let[U,L]of o)BigInt(ee())>=BigInt(L.quote.expiresAt)&&o.delete(U);for(;o.size>=Oe;)o.delete(o.keys().next().value);return o.set(B.quoteId,{quote:{...B},txs:m.txs.map(U=>({...U})),summary:m.summary}),B},async build(e,p){let s=o.get(e);if(!s)throw new be;if(c(s.quote),Q(p),!P(p,s.quote.wallet))throw new d("Quote was issued for a different wallet.");let i=s.txs.map(a=>({...a}));ke(i.at(-1),s.quote);let m=await n.preview(i,p);if(c(s.quote),m.changes.filter(a=>P(H(a.token.address),H(s.quote.to))).reduce((a,l)=>a+BigInt(l.amount),0n)<BigInt(s.quote.minAmountOut))throw new d("Preview retained output is below the accepted minimum.");return{txs:i,summary:`${s.summary} ${m.summary} ${s.quote.feeDisclosure}`}}}}async function Le(n,t,r){return n.clientFor(b).readContract({address:Re.factory.address,abi:_e,functionName:"getLaunchedToken",args:[F(t)],...r===void 0?{}:{blockNumber:r}})}async function Ze(n,t,r,o){let c=await Le(n,r,o);return c.exists&&P(c.token,r)&&P(y(c.pairToken),y(t))}async function bn(n,t,r,o,c){if(typeof r.token!="string")throw new d("Provide a launch token address.");Q(r.token);let e=F(r.token),p=await Le(n,e,c);if(!p.exists||!P(p.token,e))throw new d("This address is not a Pons launch token.");let s=y(p.pairToken)===K?fe:F(p.pairToken);return De(r.pairToken,F(p.pairToken),t,s),{quote:await Ue(n,!1,c).quote({from:t?s:e,to:t?e:s,amountIn:String(r.amountIn),...r.slippageBps===void 0?{}:{slippageBps:r.slippageBps}},o),input:t?s:e}}var en=n=>({tools:[!0,!1].map(t=>({name:t?"pons_buy":"pons_sell",inputSchema:Ye,async execute(r,o){try{return await Fe(n,r,o,t)}catch(c){throw new d(n.plainError(c))}}}))}),kn=en;export{hn as a,Ue as b,bn as c,en as d,kn as e};
@@ -1 +1 @@
1
- import{h as re,i as ae}from"./2GXHYI23.js";import{a as j}from"./43LI5NKJ.js";import{a as G}from"./66F5ZH34.js";import{d as ne,f as te,g as v,i as oe}from"./NWNYJ26T.js";import{a as f,i as ee}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{a as E}from"./JXOEJPJ4.js";import{encodeFunctionData as W,encodePacked as me,erc20Abi as V,getAddress as y,hashMessage as pe,keccak256 as ge,parseAbi as D,recoverMessageAddress as we,toHex as be,zeroAddress as _}from"viem";var w=y("0xE3535330a82867cD7b81C0d7e518f465D12dDd99"),N=y("0xf08c65564eb07d880021105489552080b08e4319"),ie=y("0xc3e91d2d8a4145055c26c1174eb124ff3e3ed697"),se=y("0x7c4726c6fb8eeb7b329ac037bbc71cc3153234b5"),ue=y("0xa76c1d0bdcd94f16d5edd01c29483a2131d4c529"),F={address:y(ee[f].tokens.USDG.address),symbol:"USDG",decimals:6,chainId:f},A=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)"]),he=D(["function getContract(bytes32) view returns (address)"]),ye=D(["function getNFTWrapper(address) view returns (address)"]),M=["loanPrincipalAmount","maximumRepaymentAmount","nftCollateralId","nftCollateralContract","loanDuration","loanAdminFeeInBasisPoints","loanERC20Denomination","referrer"],Z=["nonce","expiry","signer","signature"],Ie={loanPrincipalAmount:'Amount of USDG the lender advances, in base units (USDG has 6 decimals). Example: "1000000" = 1 USDG.',maximumRepaymentAmount:'Maximum USDG the borrower repays at maturity, in base units (USDG has 6 decimals). Example: "1100000" = 1.1 USDG.',nftCollateralId:"Token id of the Robinhood Punks NFT pledged as collateral, as a decimal string.",nftCollateralContract:"Address of the NFT collection contract pledged as collateral; must be the Robinhood Punks collection.",loanDuration:"Loan length in seconds, as a decimal string (86400 = 1 day).",loanAdminFeeInBasisPoints:"Protocol admin fee in basis points (50 = 0.5%), as a decimal string, copied from the lender offer.",loanERC20Denomination:"Address of the ERC-20 token the loan is denominated in; must be canonical USDG.",referrer:"Referrer address recorded in the offer; must be the zero address 0x0000000000000000000000000000000000000000."},Ae={nonce:"Lender signature nonce, as a decimal string; a used nonce cannot be reused.",expiry:"Unix seconds after which the lender signature is no longer valid, as a decimal string.",signer:"Address of the lender who signed the offer.",signature:"Lender signature over the offer terms, as 0x-prefixed hex bytes. Oak never signs lender offers."},R=n=>te(n,"Provide the documented Longbow NFT object.");function x(n,l){if(Object.keys(n).some(i=>!l.includes(i)))throw new o("Unsupported Longbow NFT argument.")}function h(n,l=256){if(typeof n!="string"||!/^\d+$/.test(n)||n.length>78||BigInt(n)>=1n<<BigInt(l))throw new o(`NFT amounts and IDs must be uint${l} decimal strings.`);return BigInt(n)}function m(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 de(n,l,i=!0){let s=R(n),e=R(l);x(s,M),x(e,Z);let t={loanPrincipalAmount:h(s.loanPrincipalAmount),maximumRepaymentAmount:h(s.maximumRepaymentAmount),nftCollateralId:h(s.nftCollateralId),nftCollateralContract:m(s.nftCollateralContract),loanDuration:Number(h(s.loanDuration,32)),loanAdminFeeInBasisPoints:Number(h(s.loanAdminFeeInBasisPoints,16)),loanERC20Denomination:m(s.loanERC20Denomination),referrer:m(s.referrer)};if(i&&(!v(t.nftCollateralContract,N)||!v(t.loanERC20Denomination,F.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:m(e.signer),signature:e.signature};if(r.signer===_)throw new o("NFT lender cannot be the zero address.");return{offer:t,signature:r}}function Ne(n){let{offer:l,signature:i}=n;return ge(me(["address","uint256","uint256","address","uint256","address","uint32","uint16","address","uint256","uint256","address","uint256"],[l.loanERC20Denomination,l.loanPrincipalAmount,l.maximumRepaymentAmount,l.nftCollateralContract,l.nftCollateralId,l.referrer,l.loanDuration,l.loanAdminFeeInBasisPoints,i.signer,i.nonce,i.expiry,w,BigInt(f)]))}function le(n,l){if(n.filter(s=>s.token.chainId===f&&v(s.token.address,F.address)).reduce((s,e)=>{if(e.token.decimals!==F.decimals||!/^-?\d+$/.test(e.amount))throw new o("Invalid NFT currency preview metadata.");return s+BigInt(e.amount)},0n)!==l)throw new o("NFT preview does not match the exact principal or payoff.")}async function ce(n){let l=n.clientFor(f);if(await l.getChainId()!==f)throw new o("Longbow NFT loans require chain 4663.");let i=await l.getBlock(),s=(a,g,p,u=[])=>l.readContract({address:a,abi:g,functionName:p,args:u,blockNumber:i.number}),[e,t,r,c]=await Promise.all([s(w,A,"hub"),s(ie,he,"getContract",[be("PERMITTED_NFTS",{size:32})]),s(se,ye,"getNFTWrapper",[N]),s(N,J,"supportsInterface",["0x80ac58cd"])]);if(m(e)!==ie||m(t)!==se||m(r)!==ue||c!==!0)throw new o("The NFT hub, collection interface or collateral wrapper changed. No action was built.");return{client:l,block:i,read:s}}async function q(n,l){let i=Number(h(l,32));if(i===0)throw new o("NFT loanId must be positive.");let s=n.clientFor(f);if(await s.getChainId()!==f)throw new o("Longbow NFT loan reads require chain 4663.");let e=await s.getBlock(),t=(T,I,U,b=[])=>s.readContract({address:T,abi:I,functionName:U,args:b,blockNumber:e.number}),[r,c,a]=await Promise.all([t(w,A,"loanIdToLoan",[i]),t(w,A,"loanRepaidOrLiquidated",[i]),t(w,A,"getPayoffAmount",[i])]);if(!Array.isArray(r)||r.length!==11||typeof c!="boolean")throw new o("Invalid NFT loan state.");let[g,p,u,d,z,,,$,S,B,L]=r;if(BigInt(S)===0n)throw new o("This NFT loan does not exist.");let O=m(d)===F.address&&m(B)===N&&m($)===ue&&m(L)!==_,k=F;if(m(d)!==F.address){let[T,I]=await Promise.all([t(m(d),V,"symbol"),t(m(d),V,"decimals")]);if(typeof I!="number"||!Number.isInteger(I)||I<0||I>255)throw new o("NFT loan currency decimals are unavailable.");k={address:m(d),symbol:typeof T=="string"&&/^[A-Za-z0-9$._ -]{1,32}$/.test(T)?T:"TOKEN",decimals:I,chainId:f}}if(typeof a!="bigint"||a!==BigInt(p)||a<BigInt(g))throw new o("NFT payoff does not match the fixed loan terms.");let C=BigInt(S)+BigInt(z);return{loanId:l,loanContract:w,chainId:f,blockNumber:e.number.toString(),collection:m(B),wrapper:m($),tokenId:String(u),borrower:m(L),currency:k,supportedForActions:O,principalAmount:String(g),payoffAmount:a.toString(),startedAt:String(S),deadline:C.toString(),deadlineUtc:K(C),status:c?"repaid_or_liquidated":e.timestamp>C?"overdue":"active",repayable:!c&&e.timestamp<=C,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,l){let i=await n.http(`https://longbow.credit/api/nft${l}`,{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(R)}var Re=n=>{async function l(e,t,r){if(j(t),r){if(x(e,["loanId","maxPayoff"]),typeof e.loanId!="string")throw new o("NFT loanId must be a decimal string.");let b=await q(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 fe=h(e.maxPayoff);if(await ce(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 P=BigInt(b.payoffAmount);if(P>fe)throw new o("NFT payoff exceeds maxPayoff.");if(await n.clientFor(f).readContract({address:F.address,abi:V,functionName:"balanceOf",args:[t]})<P)throw new o(`NFT repayment needs ${P} USDG base units. Top up before the deadline ${b.deadlineUtc}.`);let Y=`Repay ${P} USDG base units to recover Robinhood Punks ${b.collection} token ID ${b.tokenId}; deadline ${b.deadlineUtc}.`,Q=[n.approval(F.address,w,P.toString(),f),n.unsignedTx({to:w,data:W({abi:A,functionName:"payBackLoan",args:[Number(b.loanId)]}),value:"0",chainId:f,description:Y})],X=await n.preview(Q,t);return le(X.changes,-P),{txs:Q,preview:X,summary:Y,requiresHumanConfirmation:!0}}x(e,["offer","lenderSignature"]);let c=de(e.offer,e.lenderSignature),{offer:a,signature:g}=c,{client:p,block:u,read:d}=await ce(n),[z,$,S,B,L]=await Promise.all([d(N,J,"ownerOf",[a.nftCollateralId]),d(w,A,"getWhetherNonceHasBeenUsedForUser",[g.signer,g.nonce]),d(w,A,"paused"),d(w,A,"maximumLoanDuration"),d(w,A,"adminFeeInBasisPoints")]);if(m(z)!==y(t))throw new o("This wallet does not own the offered NFT.");if($!==!1||S!==!1||g.expiry<u.timestamp||BigInt(a.loanDuration)>BigInt(String(B))||a.loanAdminFeeInBasisPoints!==L)throw new o("NFT offer is used, expired, paused or inconsistent with current loan settings.");let O=Ne(c),k=!1;try{k=v(await we({message:{raw:O},signature:g.signature}),g.signer)}catch{}if(!k){let b=await p.getCode({address:g.signer,blockNumber:u.number});b&&b!=="0x"&&(k=await d(g.signer,D(["function isValidSignature(bytes32,bytes) view returns (bytes4)"]),"isValidSignature",[pe({raw:O}),g.signature])==="0x1626ba7e")}if(!k)throw new o("NFT offer signature does not match these terms, chain and loan contract.");let C=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(C)} 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 ${w}.`,I=[n.unsignedTx({to:N,data:W({abi:J,functionName:"approve",args:[w,a.nftCollateralId]}),value:"0",chainId:f,description:`Approve only Robinhood Punks token ID ${a.nftCollateralId} to the pinned loan contract.`}),n.unsignedTx({to:w,data:W({abi:A,functionName:"acceptOffer",args:[a,g,{revenueSharePartner:_,referralFeeInBasisPoints:0}]}),value:"0",chainId:f,description:T})],U=await n.preview(I,t);return le(U.changes,a.loanPrincipalAmount),{txs:I,preview:U,summary:T,requiresHumanConfirmation:!0,estimatedDeadlineUtc:K(C),deadlineIsEstimate:!0}}let i=(e,t,r,c)=>({name:e,inputSchema:{type:"object",properties:t,required:r,additionalProperties:!1},execute:async(a,g)=>{try{return await c(a,g)}catch(p){throw new o(n.plainError(p))}}});async function s(e){j(e);let t=(r,c)=>{let a=`Longbow borrower NFT loans unreadable: ${n.plainError(c)}`;return{module:"longbow",id:`4663:${w.toLowerCase()}:${r}`,chainId:f,incomplete:!0,assets:[],economics:{principal:[],debt:[],rewards:[],backing:[],coverage:{complete:!1,reason:a}},description:`${a} 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 c=new Set,a=[];for(let[g,p]of r.entries()){let u=`unreadable-${g}`;try{if(p.loanContract!==void 0&&m(p.loanContract)!==w)throw new o("The NFT indexer returned a loan from another contract.");if(u=h(String(p.loanId??p.id),32).toString(),c.has(u))continue;c.add(u);let d=await q(n,u);if(d.borrower!==y(e))throw new o("The NFT indexer returned another borrower\u2019s loan.");if(d.status==="repaid_or_liquidated")continue;a.push({module:"longbow",id:`4663:${w.toLowerCase()}:${u}`,chainId:f,assets:[],economics:{principal:[re("collateral",{token:{address:d.collection,symbol:"NFT",decimals:0,chainId:f},amount:"1",tokenId:d.tokenId,source:"longbow.nft.collateral",measuredAtBlock:d.blockNumber})],debt:[ae({token:d.currency,amount:d.payoffAmount,source:"longbow.nft.payoffAmount",dueAt:d.deadline,measuredAtBlock:d.blockNumber})],rewards:[],backing:[],coverage:{complete:!0}},description:`Longbow borrower NFT loan ${u}: ${d.status}, payoff debt ${d.payoffAmount} ${d.currency.symbol} base units (token ${d.currency.address}, decimals ${d.currency.decimals}); collateral ${d.collection} token ID ${d.tokenId} is escrowed. Deadline ${d.deadlineUtc}. ${d.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(d){a.push(t(u,d))}}return a}catch(r){return[t("unreadable",r)]}}return{positions:s,tools:[i("longbow_nft_listings",{},[],async e=>{x(e,[]);let t=await H(n,"/listings");return{chainId:f,source:"Longbow public order book; untrusted and potentially stale. No offer or execution is guaranteed.",listings:t.map(r=>{if(r.chainId!==f)throw new o("Longbow returned a listing on another chain.");return{id:E(String(r.id)),collection:m(r.nftContract??r.collection),tokenId:h(r.tokenId).toString(),borrower:m(r.borrower??r.owner),status:E(String(r.status)),note:r.note==null?null:E(String(r.note)).slice(0,512)}})}}),i("longbow_nft_offers",{listingId:{type:"string",maxLength:128,description:"Longbow NFT listing id, as returned by longbow_nft_listings (letters, digits, underscore or hyphen)."}},["listingId"],async e=>{if(x(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 c=r.raw?R(r.raw):r,a={...R(c.offer??Object.fromEntries(M.map(p=>[p,c[p]])))};for(let p of["loanDuration","loanAdminFeeInBasisPoints"]){let u=a[p];typeof u=="number"&&Number.isSafeInteger(u)&&u>=0&&(a[p]=String(u))}let g=de(a,typeof c.signature=="object"?c.signature:{nonce:c.nonce,expiry:c.expiry,signer:c.signer??c.lender,signature:c.signature},!1);return JSON.parse(JSON.stringify({id:String(r.id),...g},(p,u)=>typeof u=="bigint"||p==="loanDuration"||p==="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:G('Longbow NFT loan id, as a decimal string. Example: "1".')},["loanId"],async e=>{if(x(e,["loanId"]),typeof e.loanId!="string")throw new o("NFT loanId must be a decimal string.");return q(n,e.loanId)}),i("longbow_nft_loans",{role:{enum:["borrower","lender"],description:'Which loans to list for this wallet: "borrower" (default) for loans it took out, "lender" for loans it funded.'}},[],async(e,t)=>{x(e,["role"]),j(t);let r=e.role??"borrower";if(r!=="borrower"&&r!=="lender")throw new o("Choose borrower or lender NFT loan discovery.");let c=await H(n,`/loans/${r}/${y(t)}`);if(c.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(c.map(a=>{if(a.loanContract!==void 0&&m(a.loanContract)!==w)throw new o("The NFT indexer returned a loan from another contract.");return q(n,String(a.loanId??a.id))}))}}),i("longbow_nft_accept_offer",{offer:{type:"object",description:"Lender-signed NFT loan terms to accept, exactly as returned by longbow_nft_offers.",properties:Object.fromEntries(M.map(e=>[e,{type:"string",description:Ie[e]}])),required:M,additionalProperties:!1},lenderSignature:{type:"object",description:"The lender signature and its nonce, expiry and signer, as returned with the offer.",properties:Object.fromEntries(Z.map(e=>[e,{type:"string",description:Ae[e]}])),required:Z,additionalProperties:!1}},["offer","lenderSignature"],(e,t)=>l(e,t,!1)),i("longbow_nft_repay",{loanId:G('Longbow NFT loan id to repay, as a decimal string. Example: "1".'),maxPayoff:G('Highest USDG payoff you accept, in base units (USDG has 6 decimals). Example: "1100000" = 1.1 USDG.')},["loanId","maxPayoff"],(e,t)=>l(e,t,!0))]}};async function $e(n,l,i){if(await n.getChainId()!==f||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:N,abi:s,functionName:"ownerOf",args:[i]});if(!v(e,l))return;let t=await n.readContract({address:N,abi:s,functionName:"getApproved",args:[i]});if(v(t,w))return{to:N,data:W({abi:s,functionName:"approve",args:[_,i]}),value:"0",chainId:f,description:`Revoke only Robinhood Punks token ID ${i} approval to the Longbow loan contract.`}}export{w as a,N as b,ie as c,se as d,ue as e,A as f,h as g,de as h,Ne as i,q as j,Re as k,$e as l};
1
+ import{h as re,i as ae}from"./2GXHYI23.js";import{a as j}from"./43LI5NKJ.js";import{a as G}from"./66F5ZH34.js";import{d as ne,f as te,g as v,i as oe}from"./NWNYJ26T.js";import{b as f,j as ee}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{a as E}from"./JXOEJPJ4.js";import{encodeFunctionData as W,encodePacked as me,erc20Abi as V,getAddress as y,hashMessage as pe,keccak256 as ge,parseAbi as D,recoverMessageAddress as we,toHex as be,zeroAddress as _}from"viem";var w=y("0xE3535330a82867cD7b81C0d7e518f465D12dDd99"),N=y("0xf08c65564eb07d880021105489552080b08e4319"),ie=y("0xc3e91d2d8a4145055c26c1174eb124ff3e3ed697"),se=y("0x7c4726c6fb8eeb7b329ac037bbc71cc3153234b5"),ue=y("0xa76c1d0bdcd94f16d5edd01c29483a2131d4c529"),F={address:y(ee[f].tokens.USDG.address),symbol:"USDG",decimals:6,chainId:f},A=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)"]),he=D(["function getContract(bytes32) view returns (address)"]),ye=D(["function getNFTWrapper(address) view returns (address)"]),M=["loanPrincipalAmount","maximumRepaymentAmount","nftCollateralId","nftCollateralContract","loanDuration","loanAdminFeeInBasisPoints","loanERC20Denomination","referrer"],Z=["nonce","expiry","signer","signature"],Ie={loanPrincipalAmount:'Amount of USDG the lender advances, in base units (USDG has 6 decimals). Example: "1000000" = 1 USDG.',maximumRepaymentAmount:'Maximum USDG the borrower repays at maturity, in base units (USDG has 6 decimals). Example: "1100000" = 1.1 USDG.',nftCollateralId:"Token id of the Robinhood Punks NFT pledged as collateral, as a decimal string.",nftCollateralContract:"Address of the NFT collection contract pledged as collateral; must be the Robinhood Punks collection.",loanDuration:"Loan length in seconds, as a decimal string (86400 = 1 day).",loanAdminFeeInBasisPoints:"Protocol admin fee in basis points (50 = 0.5%), as a decimal string, copied from the lender offer.",loanERC20Denomination:"Address of the ERC-20 token the loan is denominated in; must be canonical USDG.",referrer:"Referrer address recorded in the offer; must be the zero address 0x0000000000000000000000000000000000000000."},Ae={nonce:"Lender signature nonce, as a decimal string; a used nonce cannot be reused.",expiry:"Unix seconds after which the lender signature is no longer valid, as a decimal string.",signer:"Address of the lender who signed the offer.",signature:"Lender signature over the offer terms, as 0x-prefixed hex bytes. Oak never signs lender offers."},R=n=>te(n,"Provide the documented Longbow NFT object.");function x(n,l){if(Object.keys(n).some(i=>!l.includes(i)))throw new o("Unsupported Longbow NFT argument.")}function h(n,l=256){if(typeof n!="string"||!/^\d+$/.test(n)||n.length>78||BigInt(n)>=1n<<BigInt(l))throw new o(`NFT amounts and IDs must be uint${l} decimal strings.`);return BigInt(n)}function m(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 de(n,l,i=!0){let s=R(n),e=R(l);x(s,M),x(e,Z);let t={loanPrincipalAmount:h(s.loanPrincipalAmount),maximumRepaymentAmount:h(s.maximumRepaymentAmount),nftCollateralId:h(s.nftCollateralId),nftCollateralContract:m(s.nftCollateralContract),loanDuration:Number(h(s.loanDuration,32)),loanAdminFeeInBasisPoints:Number(h(s.loanAdminFeeInBasisPoints,16)),loanERC20Denomination:m(s.loanERC20Denomination),referrer:m(s.referrer)};if(i&&(!v(t.nftCollateralContract,N)||!v(t.loanERC20Denomination,F.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:m(e.signer),signature:e.signature};if(r.signer===_)throw new o("NFT lender cannot be the zero address.");return{offer:t,signature:r}}function Ne(n){let{offer:l,signature:i}=n;return ge(me(["address","uint256","uint256","address","uint256","address","uint32","uint16","address","uint256","uint256","address","uint256"],[l.loanERC20Denomination,l.loanPrincipalAmount,l.maximumRepaymentAmount,l.nftCollateralContract,l.nftCollateralId,l.referrer,l.loanDuration,l.loanAdminFeeInBasisPoints,i.signer,i.nonce,i.expiry,w,BigInt(f)]))}function le(n,l){if(n.filter(s=>s.token.chainId===f&&v(s.token.address,F.address)).reduce((s,e)=>{if(e.token.decimals!==F.decimals||!/^-?\d+$/.test(e.amount))throw new o("Invalid NFT currency preview metadata.");return s+BigInt(e.amount)},0n)!==l)throw new o("NFT preview does not match the exact principal or payoff.")}async function ce(n){let l=n.clientFor(f);if(await l.getChainId()!==f)throw new o("Longbow NFT loans require chain 4663.");let i=await l.getBlock(),s=(a,g,p,u=[])=>l.readContract({address:a,abi:g,functionName:p,args:u,blockNumber:i.number}),[e,t,r,c]=await Promise.all([s(w,A,"hub"),s(ie,he,"getContract",[be("PERMITTED_NFTS",{size:32})]),s(se,ye,"getNFTWrapper",[N]),s(N,J,"supportsInterface",["0x80ac58cd"])]);if(m(e)!==ie||m(t)!==se||m(r)!==ue||c!==!0)throw new o("The NFT hub, collection interface or collateral wrapper changed. No action was built.");return{client:l,block:i,read:s}}async function q(n,l){let i=Number(h(l,32));if(i===0)throw new o("NFT loanId must be positive.");let s=n.clientFor(f);if(await s.getChainId()!==f)throw new o("Longbow NFT loan reads require chain 4663.");let e=await s.getBlock(),t=(T,I,U,b=[])=>s.readContract({address:T,abi:I,functionName:U,args:b,blockNumber:e.number}),[r,c,a]=await Promise.all([t(w,A,"loanIdToLoan",[i]),t(w,A,"loanRepaidOrLiquidated",[i]),t(w,A,"getPayoffAmount",[i])]);if(!Array.isArray(r)||r.length!==11||typeof c!="boolean")throw new o("Invalid NFT loan state.");let[g,p,u,d,z,,,$,S,B,L]=r;if(BigInt(S)===0n)throw new o("This NFT loan does not exist.");let O=m(d)===F.address&&m(B)===N&&m($)===ue&&m(L)!==_,k=F;if(m(d)!==F.address){let[T,I]=await Promise.all([t(m(d),V,"symbol"),t(m(d),V,"decimals")]);if(typeof I!="number"||!Number.isInteger(I)||I<0||I>255)throw new o("NFT loan currency decimals are unavailable.");k={address:m(d),symbol:typeof T=="string"&&/^[A-Za-z0-9$._ -]{1,32}$/.test(T)?T:"TOKEN",decimals:I,chainId:f}}if(typeof a!="bigint"||a!==BigInt(p)||a<BigInt(g))throw new o("NFT payoff does not match the fixed loan terms.");let C=BigInt(S)+BigInt(z);return{loanId:l,loanContract:w,chainId:f,blockNumber:e.number.toString(),collection:m(B),wrapper:m($),tokenId:String(u),borrower:m(L),currency:k,supportedForActions:O,principalAmount:String(g),payoffAmount:a.toString(),startedAt:String(S),deadline:C.toString(),deadlineUtc:K(C),status:c?"repaid_or_liquidated":e.timestamp>C?"overdue":"active",repayable:!c&&e.timestamp<=C,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,l){let i=await n.http(`https://longbow.credit/api/nft${l}`,{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(R)}var Re=n=>{async function l(e,t,r){if(j(t),r){if(x(e,["loanId","maxPayoff"]),typeof e.loanId!="string")throw new o("NFT loanId must be a decimal string.");let b=await q(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 fe=h(e.maxPayoff);if(await ce(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 P=BigInt(b.payoffAmount);if(P>fe)throw new o("NFT payoff exceeds maxPayoff.");if(await n.clientFor(f).readContract({address:F.address,abi:V,functionName:"balanceOf",args:[t]})<P)throw new o(`NFT repayment needs ${P} USDG base units. Top up before the deadline ${b.deadlineUtc}.`);let Y=`Repay ${P} USDG base units to recover Robinhood Punks ${b.collection} token ID ${b.tokenId}; deadline ${b.deadlineUtc}.`,Q=[n.approval(F.address,w,P.toString(),f),n.unsignedTx({to:w,data:W({abi:A,functionName:"payBackLoan",args:[Number(b.loanId)]}),value:"0",chainId:f,description:Y})],X=await n.preview(Q,t);return le(X.changes,-P),{txs:Q,preview:X,summary:Y,requiresHumanConfirmation:!0}}x(e,["offer","lenderSignature"]);let c=de(e.offer,e.lenderSignature),{offer:a,signature:g}=c,{client:p,block:u,read:d}=await ce(n),[z,$,S,B,L]=await Promise.all([d(N,J,"ownerOf",[a.nftCollateralId]),d(w,A,"getWhetherNonceHasBeenUsedForUser",[g.signer,g.nonce]),d(w,A,"paused"),d(w,A,"maximumLoanDuration"),d(w,A,"adminFeeInBasisPoints")]);if(m(z)!==y(t))throw new o("This wallet does not own the offered NFT.");if($!==!1||S!==!1||g.expiry<u.timestamp||BigInt(a.loanDuration)>BigInt(String(B))||a.loanAdminFeeInBasisPoints!==L)throw new o("NFT offer is used, expired, paused or inconsistent with current loan settings.");let O=Ne(c),k=!1;try{k=v(await we({message:{raw:O},signature:g.signature}),g.signer)}catch{}if(!k){let b=await p.getCode({address:g.signer,blockNumber:u.number});b&&b!=="0x"&&(k=await d(g.signer,D(["function isValidSignature(bytes32,bytes) view returns (bytes4)"]),"isValidSignature",[pe({raw:O}),g.signature])==="0x1626ba7e")}if(!k)throw new o("NFT offer signature does not match these terms, chain and loan contract.");let C=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(C)} 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 ${w}.`,I=[n.unsignedTx({to:N,data:W({abi:J,functionName:"approve",args:[w,a.nftCollateralId]}),value:"0",chainId:f,description:`Approve only Robinhood Punks token ID ${a.nftCollateralId} to the pinned loan contract.`}),n.unsignedTx({to:w,data:W({abi:A,functionName:"acceptOffer",args:[a,g,{revenueSharePartner:_,referralFeeInBasisPoints:0}]}),value:"0",chainId:f,description:T})],U=await n.preview(I,t);return le(U.changes,a.loanPrincipalAmount),{txs:I,preview:U,summary:T,requiresHumanConfirmation:!0,estimatedDeadlineUtc:K(C),deadlineIsEstimate:!0}}let i=(e,t,r,c)=>({name:e,inputSchema:{type:"object",properties:t,required:r,additionalProperties:!1},execute:async(a,g)=>{try{return await c(a,g)}catch(p){throw new o(n.plainError(p))}}});async function s(e){j(e);let t=(r,c)=>{let a=`Longbow borrower NFT loans unreadable: ${n.plainError(c)}`;return{module:"longbow",id:`4663:${w.toLowerCase()}:${r}`,chainId:f,incomplete:!0,assets:[],economics:{principal:[],debt:[],rewards:[],backing:[],coverage:{complete:!1,reason:a}},description:`${a} 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 c=new Set,a=[];for(let[g,p]of r.entries()){let u=`unreadable-${g}`;try{if(p.loanContract!==void 0&&m(p.loanContract)!==w)throw new o("The NFT indexer returned a loan from another contract.");if(u=h(String(p.loanId??p.id),32).toString(),c.has(u))continue;c.add(u);let d=await q(n,u);if(d.borrower!==y(e))throw new o("The NFT indexer returned another borrower\u2019s loan.");if(d.status==="repaid_or_liquidated")continue;a.push({module:"longbow",id:`4663:${w.toLowerCase()}:${u}`,chainId:f,assets:[],economics:{principal:[re("collateral",{token:{address:d.collection,symbol:"NFT",decimals:0,chainId:f},amount:"1",tokenId:d.tokenId,source:"longbow.nft.collateral",measuredAtBlock:d.blockNumber})],debt:[ae({token:d.currency,amount:d.payoffAmount,source:"longbow.nft.payoffAmount",dueAt:d.deadline,measuredAtBlock:d.blockNumber})],rewards:[],backing:[],coverage:{complete:!0}},description:`Longbow borrower NFT loan ${u}: ${d.status}, payoff debt ${d.payoffAmount} ${d.currency.symbol} base units (token ${d.currency.address}, decimals ${d.currency.decimals}); collateral ${d.collection} token ID ${d.tokenId} is escrowed. Deadline ${d.deadlineUtc}. ${d.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(d){a.push(t(u,d))}}return a}catch(r){return[t("unreadable",r)]}}return{positions:s,tools:[i("longbow_nft_listings",{},[],async e=>{x(e,[]);let t=await H(n,"/listings");return{chainId:f,source:"Longbow public order book; untrusted and potentially stale. No offer or execution is guaranteed.",listings:t.map(r=>{if(r.chainId!==f)throw new o("Longbow returned a listing on another chain.");return{id:E(String(r.id)),collection:m(r.nftContract??r.collection),tokenId:h(r.tokenId).toString(),borrower:m(r.borrower??r.owner),status:E(String(r.status)),note:r.note==null?null:E(String(r.note)).slice(0,512)}})}}),i("longbow_nft_offers",{listingId:{type:"string",maxLength:128,description:"Longbow NFT listing id, as returned by longbow_nft_listings (letters, digits, underscore or hyphen)."}},["listingId"],async e=>{if(x(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 c=r.raw?R(r.raw):r,a={...R(c.offer??Object.fromEntries(M.map(p=>[p,c[p]])))};for(let p of["loanDuration","loanAdminFeeInBasisPoints"]){let u=a[p];typeof u=="number"&&Number.isSafeInteger(u)&&u>=0&&(a[p]=String(u))}let g=de(a,typeof c.signature=="object"?c.signature:{nonce:c.nonce,expiry:c.expiry,signer:c.signer??c.lender,signature:c.signature},!1);return JSON.parse(JSON.stringify({id:String(r.id),...g},(p,u)=>typeof u=="bigint"||p==="loanDuration"||p==="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:G('Longbow NFT loan id, as a decimal string. Example: "1".')},["loanId"],async e=>{if(x(e,["loanId"]),typeof e.loanId!="string")throw new o("NFT loanId must be a decimal string.");return q(n,e.loanId)}),i("longbow_nft_loans",{role:{enum:["borrower","lender"],description:'Which loans to list for this wallet: "borrower" (default) for loans it took out, "lender" for loans it funded.'}},[],async(e,t)=>{x(e,["role"]),j(t);let r=e.role??"borrower";if(r!=="borrower"&&r!=="lender")throw new o("Choose borrower or lender NFT loan discovery.");let c=await H(n,`/loans/${r}/${y(t)}`);if(c.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(c.map(a=>{if(a.loanContract!==void 0&&m(a.loanContract)!==w)throw new o("The NFT indexer returned a loan from another contract.");return q(n,String(a.loanId??a.id))}))}}),i("longbow_nft_accept_offer",{offer:{type:"object",description:"Lender-signed NFT loan terms to accept, exactly as returned by longbow_nft_offers.",properties:Object.fromEntries(M.map(e=>[e,{type:"string",description:Ie[e]}])),required:M,additionalProperties:!1},lenderSignature:{type:"object",description:"The lender signature and its nonce, expiry and signer, as returned with the offer.",properties:Object.fromEntries(Z.map(e=>[e,{type:"string",description:Ae[e]}])),required:Z,additionalProperties:!1}},["offer","lenderSignature"],(e,t)=>l(e,t,!1)),i("longbow_nft_repay",{loanId:G('Longbow NFT loan id to repay, as a decimal string. Example: "1".'),maxPayoff:G('Highest USDG payoff you accept, in base units (USDG has 6 decimals). Example: "1100000" = 1.1 USDG.')},["loanId","maxPayoff"],(e,t)=>l(e,t,!0))]}};async function $e(n,l,i){if(await n.getChainId()!==f||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:N,abi:s,functionName:"ownerOf",args:[i]});if(!v(e,l))return;let t=await n.readContract({address:N,abi:s,functionName:"getApproved",args:[i]});if(v(t,w))return{to:N,data:W({abi:s,functionName:"approve",args:[_,i]}),value:"0",chainId:f,description:`Revoke only Robinhood Punks token ID ${i} approval to the Longbow loan contract.`}}export{w as a,N as b,ie as c,se as d,ue as e,A as f,h as g,de as h,Ne as i,q as j,Re as k,$e as l};