@oakagentkit/core 0.3.5 → 0.3.6

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 (517) hide show
  1. package/build/dist/api/addresses.d.ts +14 -0
  2. package/build/dist/api/addresses.js +1 -1
  3. package/build/dist/api/chain.js +1 -1
  4. package/build/dist/api/history.d.ts +2 -0
  5. package/build/dist/api/history.js +1 -1
  6. package/build/dist/api/identity-link.js +1 -1
  7. package/build/dist/api/metadata.js +1 -1
  8. package/build/dist/api/modules/beefy/boosts.js +1 -1
  9. package/build/dist/api/modules/beefy/clm.js +1 -1
  10. package/build/dist/api/modules/beefy/guard.js +1 -1
  11. package/build/dist/api/modules/beefy/index.js +1 -1
  12. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  13. package/build/dist/api/modules/beefy/management.js +1 -1
  14. package/build/dist/api/modules/beefy/vaults.js +1 -1
  15. package/build/dist/api/modules/borro/actions.js +1 -1
  16. package/build/dist/api/modules/borro/index.js +1 -1
  17. package/build/dist/api/modules/borro/liquidity.js +1 -1
  18. package/build/dist/api/modules/borro/positions.js +1 -1
  19. package/build/dist/api/modules/borro/reader.js +1 -1
  20. package/build/dist/api/modules/chop/display.js +1 -1
  21. package/build/dist/api/modules/chop/guard.js +1 -1
  22. package/build/dist/api/modules/chop/index.js +1 -1
  23. package/build/dist/api/modules/clanker/extensions.js +1 -1
  24. package/build/dist/api/modules/clanker/index.js +1 -1
  25. package/build/dist/api/modules/clanker/manage.js +1 -1
  26. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  27. package/build/dist/api/modules/clanker/protocol.js +1 -1
  28. package/build/dist/api/modules/clanker/state.js +1 -1
  29. package/build/dist/api/modules/earn/index.js +1 -1
  30. package/build/dist/api/modules/erc8004/common.js +1 -1
  31. package/build/dist/api/modules/erc8004/domain.js +1 -1
  32. package/build/dist/api/modules/erc8004/index.js +1 -1
  33. package/build/dist/api/modules/erc8004/management.js +1 -1
  34. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  35. package/build/dist/api/modules/erc8004/services.js +1 -1
  36. package/build/dist/api/modules/erc8004/thesis.js +1 -1
  37. package/build/dist/api/modules/erc8004/validation.js +1 -1
  38. package/build/dist/api/modules/fobo/index.js +1 -1
  39. package/build/dist/api/modules/fobo/intent.js +1 -1
  40. package/build/dist/api/modules/fobo/steps.js +1 -1
  41. package/build/dist/api/modules/fobo/verify.js +1 -1
  42. package/build/dist/api/modules/grove/index.js +1 -1
  43. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  44. package/build/dist/api/modules/heyresearch/index.js +1 -1
  45. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  46. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  47. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  48. package/build/dist/api/modules/hoodag/index.js +1 -1
  49. package/build/dist/api/modules/hoodag/management.js +1 -1
  50. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  51. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  52. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  53. package/build/dist/api/modules/hoodlock/buyback.js +1 -1
  54. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  55. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  56. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  57. package/build/dist/api/modules/hoodlock/index.js +1 -1
  58. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  59. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  60. package/build/dist/api/modules/hoodlock/public.js +1 -1
  61. package/build/dist/api/modules/hookr/actions.d.ts +39 -2
  62. package/build/dist/api/modules/hookr/actions.js +1 -1
  63. package/build/dist/api/modules/hookr/addons.js +1 -1
  64. package/build/dist/api/modules/hookr/agent-gate.d.ts +14 -2
  65. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  66. package/build/dist/api/modules/hookr/agent-link.d.ts +17 -0
  67. package/build/dist/api/modules/hookr/agent-link.js +1 -0
  68. package/build/dist/api/modules/hookr/api-client.d.ts +9 -0
  69. package/build/dist/api/modules/hookr/api-client.js +1 -0
  70. package/build/dist/api/modules/hookr/blocks/advisory.d.ts +41 -0
  71. package/build/dist/api/modules/hookr/blocks/advisory.js +1 -0
  72. package/build/dist/api/modules/hookr/blocks/buy-sell-block.d.ts +7 -0
  73. package/build/dist/api/modules/hookr/blocks/buy-sell-block.js +1 -0
  74. package/build/dist/api/modules/hookr/blocks/core-settings.d.ts +6 -0
  75. package/build/dist/api/modules/hookr/blocks/core-settings.js +1 -0
  76. package/build/dist/api/modules/hookr/blocks/exit-clock.d.ts +14 -0
  77. package/build/dist/api/modules/hookr/blocks/exit-clock.js +1 -0
  78. package/build/dist/api/modules/hookr/blocks/holder-pot.d.ts +30 -0
  79. package/build/dist/api/modules/hookr/blocks/holder-pot.js +1 -0
  80. package/build/dist/api/modules/hookr/blocks/managed-fee.d.ts +96 -0
  81. package/build/dist/api/modules/hookr/blocks/managed-fee.js +1 -0
  82. package/build/dist/api/modules/hookr/blocks/market-guard.d.ts +116 -0
  83. package/build/dist/api/modules/hookr/blocks/market-guard.js +1 -0
  84. package/build/dist/api/modules/hookr/blocks/market-hours-fee.d.ts +87 -0
  85. package/build/dist/api/modules/hookr/blocks/market-hours-fee.js +1 -0
  86. package/build/dist/api/modules/hookr/blocks/pay-later.d.ts +199 -0
  87. package/build/dist/api/modules/hookr/blocks/pay-later.js +1 -0
  88. package/build/dist/api/modules/hookr/blocks/sandwich-guard.d.ts +3 -0
  89. package/build/dist/api/modules/hookr/blocks/sandwich-guard.js +1 -0
  90. package/build/dist/api/modules/hookr/blocks/storm-fee.d.ts +3 -0
  91. package/build/dist/api/modules/hookr/blocks/storm-fee.js +1 -0
  92. package/build/dist/api/modules/hookr/blocks/swap-cut.d.ts +3 -0
  93. package/build/dist/api/modules/hookr/blocks/swap-cut.js +1 -0
  94. package/build/dist/api/modules/hookr/blocks/swap-reward-mint.d.ts +125 -0
  95. package/build/dist/api/modules/hookr/blocks/swap-reward-mint.js +1 -0
  96. package/build/dist/api/modules/hookr/blocks/wallet-cap.d.ts +3 -0
  97. package/build/dist/api/modules/hookr/blocks/wallet-cap.js +1 -0
  98. package/build/dist/api/modules/hookr/blocks/zap-source.d.ts +161 -0
  99. package/build/dist/api/modules/hookr/blocks/zap-source.js +1 -0
  100. package/build/dist/api/modules/hookr/blocks/zap-target.d.ts +51 -0
  101. package/build/dist/api/modules/hookr/blocks/zap-target.js +1 -0
  102. package/build/dist/api/modules/hookr/claims.d.ts +53 -0
  103. package/build/dist/api/modules/hookr/claims.js +1 -0
  104. package/build/dist/api/modules/hookr/contracts.d.ts +3 -1
  105. package/build/dist/api/modules/hookr/contracts.js +1 -1
  106. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  107. package/build/dist/api/modules/hookr/discovery.d.ts +2 -2
  108. package/build/dist/api/modules/hookr/discovery.js +1 -1
  109. package/build/dist/api/modules/hookr/fill-bounty.d.ts +2 -0
  110. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  111. package/build/dist/api/modules/hookr/gas.d.ts +48 -0
  112. package/build/dist/api/modules/hookr/gas.js +1 -0
  113. package/build/dist/api/modules/hookr/gates.d.ts +51 -0
  114. package/build/dist/api/modules/hookr/gates.js +1 -0
  115. package/build/dist/api/modules/hookr/hook-blocks.d.ts +304 -0
  116. package/build/dist/api/modules/hookr/hook-blocks.js +1 -0
  117. package/build/dist/api/modules/hookr/index.d.ts +4 -2
  118. package/build/dist/api/modules/hookr/index.js +1 -1
  119. package/build/dist/api/modules/hookr/jobs.d.ts +7 -0
  120. package/build/dist/api/modules/hookr/jobs.js +1 -0
  121. package/build/dist/api/modules/hookr/launch-options.d.ts +52 -3
  122. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  123. package/build/dist/api/modules/hookr/launch-profile.d.ts +8 -0
  124. package/build/dist/api/modules/hookr/launch-profile.js +1 -1
  125. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  126. package/build/dist/api/modules/hookr/launch.d.ts +24 -0
  127. package/build/dist/api/modules/hookr/launch.js +1 -1
  128. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  129. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  130. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  131. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  132. package/build/dist/api/modules/hookr/lp-state.d.ts +90 -2
  133. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  134. package/build/dist/api/modules/hookr/pay-later-actions.d.ts +52 -0
  135. package/build/dist/api/modules/hookr/pay-later-actions.js +1 -0
  136. package/build/dist/api/modules/hookr/pins.d.ts +5 -0
  137. package/build/dist/api/modules/hookr/pins.js +1 -1
  138. package/build/dist/api/modules/hookr/pm-liquidity.d.ts +215 -0
  139. package/build/dist/api/modules/hookr/pm-liquidity.js +1 -0
  140. package/build/dist/api/modules/hookr/public-reads.d.ts +1 -1
  141. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  142. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  143. package/build/dist/api/modules/hookr/relay.js +1 -1
  144. package/build/dist/api/modules/hookr/revenue.d.ts +4 -1
  145. package/build/dist/api/modules/hookr/revenue.js +1 -1
  146. package/build/dist/api/modules/hookr/scan.d.ts +25 -0
  147. package/build/dist/api/modules/hookr/scan.js +1 -0
  148. package/build/dist/api/modules/hookr/swap.d.ts +161 -0
  149. package/build/dist/api/modules/hookr/swap.js +1 -0
  150. package/build/dist/api/modules/kyberswap/index.js +1 -1
  151. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  152. package/build/dist/api/modules/layerbank/abi.js +1 -1
  153. package/build/dist/api/modules/layerbank/actions.js +1 -1
  154. package/build/dist/api/modules/layerbank/checks.js +1 -1
  155. package/build/dist/api/modules/layerbank/index.js +1 -1
  156. package/build/dist/api/modules/layerbank/merkl.js +1 -1
  157. package/build/dist/api/modules/layerbank/reader.js +1 -1
  158. package/build/dist/api/modules/layerbank/reserve.js +1 -1
  159. package/build/dist/api/modules/lighter/index.js +1 -1
  160. package/build/dist/api/modules/longbow/administration.js +1 -1
  161. package/build/dist/api/modules/longbow/analytics.js +1 -1
  162. package/build/dist/api/modules/longbow/fixed.js +1 -1
  163. package/build/dist/api/modules/longbow/index.js +1 -1
  164. package/build/dist/api/modules/longbow/nft.js +1 -1
  165. package/build/dist/api/modules/longbow/rebates.js +1 -1
  166. package/build/dist/api/modules/longbow/staking.js +1 -1
  167. package/build/dist/api/modules/meridian/index.js +1 -1
  168. package/build/dist/api/modules/meridian/markets.js +1 -1
  169. package/build/dist/api/modules/meridian/rfq.js +1 -1
  170. package/build/dist/api/modules/merkl/discovery.js +1 -1
  171. package/build/dist/api/modules/merkl/index.js +1 -1
  172. package/build/dist/api/modules/merkl/manage.js +1 -1
  173. package/build/dist/api/modules/merkl/protocol.js +1 -1
  174. package/build/dist/api/modules/morpho/allocator.js +1 -1
  175. package/build/dist/api/modules/morpho/bundles.js +1 -1
  176. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  177. package/build/dist/api/modules/morpho/index.js +1 -1
  178. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  179. package/build/dist/api/modules/morpho/midnight.js +1 -1
  180. package/build/dist/api/modules/morpho/protocol.js +1 -1
  181. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  182. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  183. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  184. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  185. package/build/dist/api/modules/netnet/card-read.js +1 -1
  186. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  187. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  188. package/build/dist/api/modules/netnet/desk-read.js +1 -1
  189. package/build/dist/api/modules/netnet/financial.js +1 -1
  190. package/build/dist/api/modules/netnet/index.js +1 -1
  191. package/build/dist/api/modules/netnet/staking.js +1 -1
  192. package/build/dist/api/modules/orbio/index.js +1 -1
  193. package/build/dist/api/modules/orbio/positions.js +1 -1
  194. package/build/dist/api/modules/pendle/costs.js +1 -1
  195. package/build/dist/api/modules/pendle/index.js +1 -1
  196. package/build/dist/api/modules/pendle/markets.js +1 -1
  197. package/build/dist/api/modules/pendle/positions.js +1 -1
  198. package/build/dist/api/modules/pendle/pricecheck.js +1 -1
  199. package/build/dist/api/modules/pendle/reader.js +1 -1
  200. package/build/dist/api/modules/pendle/redeem.js +1 -1
  201. package/build/dist/api/modules/pendle/trade.js +1 -1
  202. package/build/dist/api/modules/pendle/validate.js +1 -1
  203. package/build/dist/api/modules/pendle/verify.js +1 -1
  204. package/build/dist/api/modules/pons/claim.js +1 -1
  205. package/build/dist/api/modules/pons/index.js +1 -1
  206. package/build/dist/api/modules/pons/launch-status.js +1 -1
  207. package/build/dist/api/modules/pons/prices.js +1 -1
  208. package/build/dist/api/modules/pons/reads.js +1 -1
  209. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  210. package/build/dist/api/modules/pons/trade.js +1 -1
  211. package/build/dist/api/modules/poolstrade/index.js +1 -1
  212. package/build/dist/api/modules/priors/coverage.js +1 -1
  213. package/build/dist/api/modules/priors/discovery.js +1 -1
  214. package/build/dist/api/modules/priors/features.js +1 -1
  215. package/build/dist/api/modules/priors/holdings.js +1 -1
  216. package/build/dist/api/modules/priors/index.js +1 -1
  217. package/build/dist/api/modules/priors/integration.js +1 -1
  218. package/build/dist/api/modules/priors/market.js +1 -1
  219. package/build/dist/api/modules/priors/pt.js +1 -1
  220. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  221. package/build/dist/api/modules/priors/starter-line.js +1 -1
  222. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  223. package/build/dist/api/modules/raeto/index.js +1 -1
  224. package/build/dist/api/modules/relay/bootstrap.js +1 -1
  225. package/build/dist/api/modules/relay/discovery.js +1 -1
  226. package/build/dist/api/modules/relay/inbound.js +1 -1
  227. package/build/dist/api/modules/relay/index.js +1 -1
  228. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  229. package/build/dist/api/modules/relay/reads.js +1 -1
  230. package/build/dist/api/modules/spark/actions.js +1 -1
  231. package/build/dist/api/modules/spark/details.js +1 -1
  232. package/build/dist/api/modules/spark/index.js +1 -1
  233. package/build/dist/api/modules/spark/management.js +1 -1
  234. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  235. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  236. package/build/dist/api/modules/steakhouse/index.js +1 -1
  237. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  238. package/build/dist/api/modules/steakhouse/management.js +1 -1
  239. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  240. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  241. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  242. package/build/dist/api/modules/tickerspring/discovery.js +1 -1
  243. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  244. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  245. package/build/dist/api/modules/tickerspring/index.js +1 -1
  246. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  247. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  248. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  249. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  250. package/build/dist/api/modules/tickerspring/research.js +1 -1
  251. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  252. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  253. package/build/dist/api/modules/uniswap/auction.js +1 -1
  254. package/build/dist/api/modules/uniswap/batch.js +1 -1
  255. package/build/dist/api/modules/uniswap/common.js +1 -1
  256. package/build/dist/api/modules/uniswap/fees.js +1 -1
  257. package/build/dist/api/modules/uniswap/index.js +1 -1
  258. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  259. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  260. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  261. package/build/dist/api/modules/uniswap/pools.js +1 -1
  262. package/build/dist/api/modules/uniswap/position.js +1 -1
  263. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  264. package/build/dist/api/modules/uniswap/quote-guard.js +1 -1
  265. package/build/dist/api/modules/uniswap/stock-prices.d.ts +25 -0
  266. package/build/dist/api/modules/uniswap/stock-prices.js +1 -1
  267. package/build/dist/api/modules/uniswap/stocks.js +1 -1
  268. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  269. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  270. package/build/dist/api/modules/uniswap/trade.js +1 -1
  271. package/build/dist/api/modules/uniswap/v2.js +1 -1
  272. package/build/dist/api/modules/uniswap/v3.js +1 -1
  273. package/build/dist/api/modules/uniswap/v4.js +1 -1
  274. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  275. package/build/dist/api/modules/upoch/index.js +1 -1
  276. package/build/dist/api/modules/upoch/reads.js +1 -1
  277. package/build/dist/api/modules/velora/claims.js +1 -1
  278. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  279. package/build/dist/api/modules/velora/index.js +1 -1
  280. package/build/dist/api/modules/wormhole/index.js +1 -1
  281. package/build/dist/api/modules/wormhole/scan-text.d.ts +1 -1
  282. package/build/dist/api/positions.js +1 -1
  283. package/build/dist/api/pricenote.js +1 -1
  284. package/build/dist/api/prices.js +1 -1
  285. package/build/dist/api/rpc.js +1 -1
  286. package/build/dist/api/send.js +1 -1
  287. package/build/dist/api/signing-registry.js +1 -1
  288. package/build/dist/api/signing.js +1 -1
  289. package/build/dist/api/simulate.js +1 -1
  290. package/build/dist/api/swap.d.ts +2 -0
  291. package/build/dist/api/swap.js +1 -1
  292. package/build/dist/api/tokens.d.ts +9 -1
  293. package/build/dist/api/tokens.js +1 -1
  294. package/build/dist/api/tool-policy.js +1 -1
  295. package/build/dist/api/universal-router.js +1 -1
  296. package/build/dist/api/usd-estimate.js +1 -1
  297. package/build/dist/chunks/{DMDOSHV7.js → 266VIESP.js} +1 -1
  298. package/build/dist/chunks/{R66NSNNQ.js → 2BKZLF5A.js} +1 -1
  299. package/build/dist/chunks/{HFVXNKA5.js → 2BM2WX2G.js} +1 -1
  300. package/build/dist/chunks/{OY5W7ZSL.js → 2H2OZE6X.js} +1 -1
  301. package/build/dist/chunks/{E76Z2TT4.js → 2QQ5CGQI.js} +1 -1
  302. package/build/dist/chunks/{4PLLS6CT.js → 2VYA6WIN.js} +1 -1
  303. package/build/dist/chunks/{LCH6F5HT.js → 342OZP53.js} +1 -1
  304. package/build/dist/chunks/{C57DITTF.js → 3HF6WE4L.js} +1 -1
  305. package/build/dist/chunks/3M7RMROZ.js +1 -0
  306. package/build/dist/chunks/3RGED2KO.js +1 -0
  307. package/build/dist/chunks/{4HQEJHCD.js → 3XIJCHT7.js} +1 -1
  308. package/build/dist/chunks/3XY44BP5.js +1 -0
  309. package/build/dist/chunks/3YNXQ3EZ.js +1 -0
  310. package/build/dist/chunks/45QP74CE.js +1 -0
  311. package/build/dist/chunks/{SX5YNFHG.js → 4GAU3JLN.js} +1 -1
  312. package/build/dist/chunks/{Y2QADJOB.js → 4P6DRKY3.js} +1 -1
  313. package/build/dist/chunks/{W3DGFMQE.js → 4RTXP2YP.js} +1 -1
  314. package/build/dist/chunks/{QMIH6HXH.js → 4SXRXNHG.js} +1 -1
  315. package/build/dist/chunks/{ZTKT3ZQK.js → 53VBLEYS.js} +1 -1
  316. package/build/dist/chunks/{FRT6AC6M.js → 5677LZOV.js} +1 -1
  317. package/build/dist/chunks/{ADIPEGNN.js → 5AO2QPWE.js} +1 -1
  318. package/build/dist/chunks/{GQITAJVF.js → 5BPFF7NX.js} +1 -1
  319. package/build/dist/chunks/{JDHPMS7X.js → 5DWQUEBA.js} +1 -1
  320. package/build/dist/chunks/{WAKZWSHB.js → 5KKAN7XQ.js} +1 -1
  321. package/build/dist/chunks/{VVAM3EAK.js → 5N6YJFFA.js} +1 -1
  322. package/build/dist/chunks/{QIB6OMQV.js → 5O67QQIY.js} +1 -1
  323. package/build/dist/chunks/5PNFV7HH.js +1 -0
  324. package/build/dist/chunks/5RAZFRO4.js +1 -0
  325. package/build/dist/chunks/{FAH7FKUT.js → 5UWVXEPD.js} +1 -1
  326. package/build/dist/chunks/5VKVAUFQ.js +1 -0
  327. package/build/dist/chunks/5Y457HYC.js +1 -0
  328. package/build/dist/chunks/64LAWFBE.js +1 -0
  329. package/build/dist/chunks/{3BQ5XHDJ.js → 6EWSLHXL.js} +1 -1
  330. package/build/dist/chunks/{6F527FLN.js → 6HNQAYBM.js} +1 -1
  331. package/build/dist/chunks/{FUP53K6G.js → 6LDC5D2S.js} +1 -1
  332. package/build/dist/chunks/{TZ7S5KRB.js → 6QXTL65K.js} +1 -1
  333. package/build/dist/chunks/6RVAV6BB.js +1 -0
  334. package/build/dist/chunks/{WSILNJS2.js → 6STUQOFL.js} +1 -1
  335. package/build/dist/chunks/{RUHNLNVX.js → 6Y2546JA.js} +1 -1
  336. package/build/dist/chunks/{4Z3IGMU6.js → 7AYP4ATZ.js} +1 -1
  337. package/build/dist/chunks/{YGW4ODAP.js → 7EPU3XGY.js} +1 -1
  338. package/build/dist/chunks/7GL547YZ.js +1 -0
  339. package/build/dist/chunks/7JTXYMNP.js +1 -0
  340. package/build/dist/chunks/{A3BJSQ23.js → 7VU5VCTL.js} +1 -1
  341. package/build/dist/chunks/{Z7FGEWO2.js → 7WXAS54T.js} +1 -1
  342. package/build/dist/chunks/{WQ2XTDHO.js → 7X5JVF3F.js} +1 -1
  343. package/build/dist/chunks/{DRLBTB4E.js → A72ADVYF.js} +1 -1
  344. package/build/dist/chunks/{ANIF3JMV.js → AG66NM3J.js} +1 -1
  345. package/build/dist/chunks/AODUTN65.js +1 -0
  346. package/build/dist/chunks/{DBOGRUPS.js → AONO47JX.js} +1 -1
  347. package/build/dist/chunks/{JTPHZCO3.js → AQJLEG6B.js} +1 -1
  348. package/build/dist/chunks/AZBTNUXF.js +1 -0
  349. package/build/dist/chunks/{TOIKOIY6.js → B5BU645H.js} +1 -1
  350. package/build/dist/chunks/{ZX43P4BK.js → B75SS7H6.js} +1 -1
  351. package/build/dist/chunks/{GBIBRYOV.js → B7HVPHSS.js} +1 -1
  352. package/build/dist/chunks/{LT5P6PZW.js → B7WZJHIJ.js} +1 -1
  353. package/build/dist/chunks/{3A2IKFTV.js → BIFANUTV.js} +1 -1
  354. package/build/dist/chunks/BM4KHOFB.js +1 -0
  355. package/build/dist/chunks/{N65J3L2H.js → BSV65PCA.js} +1 -1
  356. package/build/dist/chunks/{ZVY7GGSP.js → BW755PNH.js} +1 -1
  357. package/build/dist/chunks/{VXCGMALF.js → BWE5PXRE.js} +1 -1
  358. package/build/dist/chunks/{7U62MMUQ.js → BY2OWKZB.js} +1 -1
  359. package/build/dist/chunks/{CNDIAF3P.js → C2H3BWN5.js} +1 -1
  360. package/build/dist/chunks/{F7MGYRPU.js → CCPG6PRL.js} +1 -1
  361. package/build/dist/chunks/{OI3N4EW4.js → CG7ABZXH.js} +1 -1
  362. package/build/dist/chunks/CJMVRV34.js +1 -0
  363. package/build/dist/chunks/CQPIR6ER.js +1 -0
  364. package/build/dist/chunks/{A4K5GXVO.js → CR7DPGI6.js} +1 -1
  365. package/build/dist/chunks/{UUF4Z6K6.js → CVVNAFUE.js} +1 -1
  366. package/build/dist/chunks/{MI5HZDMH.js → D6JOXK7Q.js} +1 -1
  367. package/build/dist/chunks/{2PS4GCOZ.js → DJRS3TR5.js} +1 -1
  368. package/build/dist/chunks/{IZFED3R2.js → DLNDJZR4.js} +1 -1
  369. package/build/dist/chunks/{MQXSCNUL.js → DPSFR3ZS.js} +1 -1
  370. package/build/dist/chunks/{LKUZAJPZ.js → DV2HVFTM.js} +1 -1
  371. package/build/dist/chunks/{NMJVQX5M.js → DWRRIFXS.js} +1 -1
  372. package/build/dist/chunks/{3ZH5SOC2.js → EFOC337C.js} +1 -1
  373. package/build/dist/chunks/EHQRAA3R.js +1 -0
  374. package/build/dist/chunks/{A4FLWHLP.js → EJIP7RBG.js} +1 -1
  375. package/build/dist/chunks/EWZFZUVF.js +1 -0
  376. package/build/dist/chunks/{OB7BFDOV.js → EYE3ZAJB.js} +1 -1
  377. package/build/dist/chunks/{MQ5F2VOK.js → EZUQMTLE.js} +1 -1
  378. package/build/dist/chunks/{O2QBSINK.js → F36IA5RI.js} +1 -1
  379. package/build/dist/chunks/{XTXXWRN2.js → F74ARK4H.js} +1 -1
  380. package/build/dist/chunks/{HPS4KOU4.js → FGGDAAHW.js} +1 -1
  381. package/build/dist/chunks/FMEO7RX7.js +1 -0
  382. package/build/dist/chunks/{FHB7QYJO.js → FN6XY6ET.js} +1 -1
  383. package/build/dist/chunks/G4IX4CYN.js +1 -0
  384. package/build/dist/chunks/G53U6Y4L.js +1 -0
  385. package/build/dist/chunks/{HDBZZOHJ.js → GBIL2I2K.js} +1 -1
  386. package/build/dist/chunks/{MJGEGNDU.js → GCFHKJIO.js} +1 -1
  387. package/build/dist/chunks/{O5QTITN6.js → GRHBE4MQ.js} +1 -1
  388. package/build/dist/chunks/GTJ6LBGB.js +1 -0
  389. package/build/dist/chunks/GV6Z3MET.js +1 -0
  390. package/build/dist/chunks/{GK3D7OKG.js → GVCNTGLC.js} +1 -1
  391. package/build/dist/chunks/GX2RCAHG.js +1 -0
  392. package/build/dist/chunks/{7TRO6MBQ.js → H5KU4DUU.js} +1 -1
  393. package/build/dist/chunks/H7ZJ7LAB.js +1 -0
  394. package/build/dist/chunks/{DCGNVMKG.js → HC3QFA5I.js} +1 -1
  395. package/build/dist/chunks/{6CKCZJ3F.js → HEQBTHFS.js} +1 -1
  396. package/build/dist/chunks/{C76D54YG.js → HGSFRN57.js} +1 -1
  397. package/build/dist/chunks/HJI7KO6F.js +1 -0
  398. package/build/dist/chunks/{KO7ANIKY.js → HNBYPHTA.js} +1 -1
  399. package/build/dist/chunks/{MSRCJ2BS.js → HPBTSJW7.js} +1 -1
  400. package/build/dist/chunks/HPO673QQ.js +1 -0
  401. package/build/dist/chunks/{4IOHSX3Z.js → HRGLFGFL.js} +1 -1
  402. package/build/dist/chunks/{DGDMRATN.js → ICHT3H3W.js} +1 -1
  403. package/build/dist/chunks/IJVBCEA2.js +1 -0
  404. package/build/dist/chunks/{N742W5KX.js → IKVRFAUP.js} +1 -1
  405. package/build/dist/chunks/IM7ZF7XZ.js +1 -0
  406. package/build/dist/chunks/{I4473OC6.js → IMD33NQS.js} +1 -1
  407. package/build/dist/chunks/IR7KDBFU.js +1 -0
  408. package/build/dist/chunks/{X24YTJST.js → IY7FWTAL.js} +1 -1
  409. package/build/dist/chunks/IYOWMW5B.js +1 -0
  410. package/build/dist/chunks/J2J73XYU.js +1 -0
  411. package/build/dist/chunks/JCS24YBB.js +1 -0
  412. package/build/dist/chunks/JQVTHPUO.js +1 -0
  413. package/build/dist/chunks/{USGMGKAG.js → JTWJT2O3.js} +1 -1
  414. package/build/dist/chunks/{W7BFM6CK.js → K4CYAWNL.js} +1 -1
  415. package/build/dist/chunks/{7VH6JQ2H.js → K5C6QBOO.js} +1 -1
  416. package/build/dist/chunks/K5OXLIPK.js +1 -0
  417. package/build/dist/chunks/{ZKBOPZH5.js → K6GECT3F.js} +1 -1
  418. package/build/dist/chunks/{6LVHN33V.js → KB2JWQZ4.js} +1 -1
  419. package/build/dist/chunks/{YW4W3LPQ.js → KHLM6NIZ.js} +1 -1
  420. package/build/dist/chunks/{OIQTZOBN.js → KKGHXNM4.js} +1 -1
  421. package/build/dist/chunks/{SUNTJ6IU.js → KYANIEPX.js} +1 -1
  422. package/build/dist/chunks/{JJSCDDQO.js → L3IAEXQR.js} +1 -1
  423. package/build/dist/chunks/{ZZ6FZGHF.js → L4UFGM7M.js} +1 -1
  424. package/build/dist/chunks/{YWVPK3DV.js → L76P6WIH.js} +1 -1
  425. package/build/dist/chunks/{QMNUB2GM.js → LBT6WR4U.js} +1 -1
  426. package/build/dist/chunks/LD3A2KLN.js +1 -0
  427. package/build/dist/chunks/{WRUTW6CG.js → LFSNAQ7V.js} +1 -1
  428. package/build/dist/chunks/{ZQPC54J5.js → LKRAUTYI.js} +1 -1
  429. package/build/dist/chunks/{23HNDJ76.js → M2SWILNG.js} +1 -1
  430. package/build/dist/chunks/{IT2JLILU.js → MFKDNAHB.js} +1 -1
  431. package/build/dist/chunks/MFQTBUSD.js +1 -0
  432. package/build/dist/chunks/{V4UJMUIB.js → MLN5KTG7.js} +1 -1
  433. package/build/dist/chunks/{S4JUFCT4.js → MSQNOK3I.js} +1 -1
  434. package/build/dist/chunks/{O4P5IQCP.js → MXI7LX2F.js} +1 -1
  435. package/build/dist/chunks/N6YNJGEF.js +1 -0
  436. package/build/dist/chunks/{DXAPKN7H.js → NLC36QHL.js} +1 -1
  437. package/build/dist/chunks/NUTTPUYJ.js +1 -0
  438. package/build/dist/chunks/{O4S6XAYV.js → O7L55XM3.js} +1 -1
  439. package/build/dist/chunks/{NAO7VWZF.js → OCIEVYPR.js} +1 -1
  440. package/build/dist/chunks/{4NBXBKOX.js → OD7CY6BY.js} +1 -1
  441. package/build/dist/chunks/{RUTSEGGD.js → OHZHQSCA.js} +1 -1
  442. package/build/dist/chunks/{E47UYYK4.js → OIGTTRN5.js} +1 -1
  443. package/build/dist/chunks/{2I7XHRTI.js → P6JE2NRA.js} +1 -1
  444. package/build/dist/chunks/PD5NXIRT.js +1 -0
  445. package/build/dist/chunks/{TXGZ6NWN.js → PG7HZIZL.js} +1 -1
  446. package/build/dist/chunks/{VREGY7E6.js → PMFR47H3.js} +1 -1
  447. package/build/dist/chunks/{PV7FEVBD.js → PXVF2SHU.js} +1 -1
  448. package/build/dist/chunks/{2FOI2625.js → Q43WPRYU.js} +1 -1
  449. package/build/dist/chunks/QAAKUIWE.js +1 -0
  450. package/build/dist/chunks/{ZXFJKW6H.js → QAVP3CWL.js} +1 -1
  451. package/build/dist/chunks/{YXXK6EPI.js → QBHY2QRC.js} +1 -1
  452. package/build/dist/chunks/{ELHRXA5U.js → QFK335LC.js} +1 -1
  453. package/build/dist/chunks/{3PHJUFU2.js → QFUSCK5C.js} +1 -1
  454. package/build/dist/chunks/{IPU656WB.js → QKH7ED6B.js} +1 -1
  455. package/build/dist/chunks/{XW3VGWXK.js → QMWHQRYC.js} +1 -1
  456. package/build/dist/chunks/{ZXRIJG6H.js → QP2B7AYX.js} +1 -1
  457. package/build/dist/chunks/{TJU644I7.js → QZ6V6J6W.js} +1 -1
  458. package/build/dist/chunks/{MDLJFCT4.js → R5Z4HPCA.js} +1 -1
  459. package/build/dist/chunks/RKJFSDGV.js +1 -0
  460. package/build/dist/chunks/RKS3M7L5.js +1 -0
  461. package/build/dist/chunks/{GDOHHXNH.js → RLX6YTNT.js} +1 -1
  462. package/build/dist/chunks/{IZP3EKKS.js → RYEQIZ2H.js} +1 -1
  463. package/build/dist/chunks/{USEF3QKG.js → S432S6NA.js} +1 -1
  464. package/build/dist/chunks/{2OVJ2BTJ.js → SEXKWYUM.js} +1 -1
  465. package/build/dist/chunks/{KKTOBXIT.js → SRYX65GZ.js} +1 -1
  466. package/build/dist/chunks/{GKUPC4DO.js → TMENUIBC.js} +1 -1
  467. package/build/dist/chunks/{BSX4LFYI.js → TNHU5UBQ.js} +1 -1
  468. package/build/dist/chunks/{PDPTJMTJ.js → TT2ST3Q3.js} +1 -1
  469. package/build/dist/chunks/TTBB6EFN.js +1 -0
  470. package/build/dist/chunks/{FRVCSDKU.js → TWVDWNTG.js} +1 -1
  471. package/build/dist/chunks/TZG7HTVM.js +1 -0
  472. package/build/dist/chunks/{OVM4QIET.js → U4MSIH4G.js} +1 -1
  473. package/build/dist/chunks/{G5AMH4IP.js → UGFRBJDQ.js} +1 -1
  474. package/build/dist/chunks/{OB3YMTDI.js → UIVOYAO2.js} +1 -1
  475. package/build/dist/chunks/{XRDLMTBJ.js → UMY6SP7C.js} +1 -1
  476. package/build/dist/chunks/UNBRUWSV.js +1 -0
  477. package/build/dist/chunks/{LGLWEGPY.js → UPX3OWKA.js} +1 -1
  478. package/build/dist/chunks/{TGXEKBLV.js → URTQNYWU.js} +1 -1
  479. package/build/dist/chunks/{4RCYYN6O.js → V7HTGO23.js} +1 -1
  480. package/build/dist/chunks/{HZSYMGJ2.js → VS7ZA4OF.js} +1 -1
  481. package/build/dist/chunks/{BJ2U2VXJ.js → VTWAVH74.js} +1 -1
  482. package/build/dist/chunks/{LZM3DO5Q.js → W5GWK72I.js} +1 -1
  483. package/build/dist/chunks/{65OITTDL.js → W73SLWBT.js} +1 -1
  484. package/build/dist/chunks/{3YH5B5NQ.js → WUONMIA2.js} +1 -1
  485. package/build/dist/chunks/{XL3W7DAQ.js → X3BB6WME.js} +1 -1
  486. package/build/dist/chunks/{XADHV2DT.js → X53QVHBC.js} +1 -1
  487. package/build/dist/chunks/{GBPB7JIB.js → XSQJOOEY.js} +1 -1
  488. package/build/dist/chunks/XUDQYSPU.js +1 -0
  489. package/build/dist/chunks/{S37D7HOK.js → XWZ5SL5Q.js} +1 -1
  490. package/build/dist/chunks/{NIWAVMDR.js → XXLQDQEX.js} +1 -1
  491. package/build/dist/chunks/{QBNASL3T.js → Y5T36EEU.js} +1 -1
  492. package/build/dist/chunks/{R73R4KN3.js → YBLJ2MCR.js} +1 -1
  493. package/build/dist/chunks/ZSGW2ZSO.js +1 -0
  494. package/build/dist/chunks/{HRAHGYNK.js → ZTNBX4VH.js} +1 -1
  495. package/package.json +1 -1
  496. package/build/dist/chunks/5H7NVE6O.js +0 -1
  497. package/build/dist/chunks/7OOCAZBE.js +0 -1
  498. package/build/dist/chunks/DFM4T6ZE.js +0 -1
  499. package/build/dist/chunks/FCVH4FYH.js +0 -1
  500. package/build/dist/chunks/GDUKZYE2.js +0 -1
  501. package/build/dist/chunks/GYPMUYB5.js +0 -1
  502. package/build/dist/chunks/J7OZLXSG.js +0 -1
  503. package/build/dist/chunks/JFC2QCMW.js +0 -1
  504. package/build/dist/chunks/M6JNGU4E.js +0 -1
  505. package/build/dist/chunks/M7OVMIIE.js +0 -1
  506. package/build/dist/chunks/MQK6OP7S.js +0 -1
  507. package/build/dist/chunks/N624NR7Y.js +0 -1
  508. package/build/dist/chunks/OSMOBKRQ.js +0 -1
  509. package/build/dist/chunks/Q3Q3YHEX.js +0 -1
  510. package/build/dist/chunks/QQD4PV64.js +0 -1
  511. package/build/dist/chunks/RN3WUJIO.js +0 -1
  512. package/build/dist/chunks/RP5VCG54.js +0 -1
  513. package/build/dist/chunks/TI727O2H.js +0 -1
  514. package/build/dist/chunks/UHIJMDD2.js +0 -1
  515. package/build/dist/chunks/W32UECOL.js +0 -1
  516. package/build/dist/chunks/WWNAGOCD.js +0 -1
  517. package/build/dist/chunks/XWC6IC5E.js +0 -1
@@ -1,2 +1,2 @@
1
- import{g as c}from"./NWNYJ26T.js";import{b as a,j as l}from"./TI727O2H.js";import{a as f}from"./XSD5NL7J.js";import{formatUnits as b,getAddress as d,hashTypedData as w,parseAbi as I}from"viem";var p=d("0x8BE478c754D9124D11e78dB20F5bf4dA45403275"),h=d("0x0c5091235A25bBFD3F5a009cBe04120D0CBAD573"),x=6228n,_="https://priors.trade/prove",$="https://priors.trade/invite",m=1800,k=3600,S=/^[0-9a-f]{32}$/,A=/^priors-invite:(\d{1,10}):(\d{1,12}):(0x[0-9a-fA-F]{130})$/,g=I(["function amount() view returns (uint256)","function unusedAfter() view returns (uint64)","function bonds(uint256 agentId) view returns ((address depositor, uint64 at, uint256 amount, uint256 qualifiedAt))","function releasable(uint256 agentId) view returns (bool)","function unusedReleaseAt(uint256 agentId) view returns (uint256)","function progress(uint256 agentId) view returns (uint256 repaid, uint256 needed)","function deposit(uint256 agentId)","function release(uint256 agentId)","error AlreadyBonded(uint256 agentId)","error NotOwner(uint256 agentId)","error AgentDefaulted(uint256 agentId)","error NoBond(uint256 agentId)","error NotReleasable(uint256 agentId)"]);async function E(e,t){let r=e.clientFor(a),n=await r.getBlockNumber({cacheTime:0}),[i,o,s]=await Promise.all([r.readContract({address:p,abi:g,functionName:"amount",blockNumber:n}),r.readContract({address:p,abi:g,functionName:"unusedAfter",blockNumber:n}),r.readContract({address:p,abi:g,functionName:"unusedReleaseAt",args:[t],blockNumber:n})]);if(typeof i!="bigint"||i<0n||typeof o!="bigint"||o<0n||typeof s!="bigint"||s<0n)throw new f("Priors bond terms are unavailable. Read amount, unusedAfter and unusedReleaseAt again before posting a bond.");return{amount:i.toString(),unusedAfter:o.toString(),unusedReleaseAt:s.toString(),blockNumber:n.toString(),summary:`Bond first: the starter line requires ${b(i,6)} USDG locked for at least ${o} seconds (${Number(o)/86400} days) after posting${s?`; unusedReleaseAt(${t}) is ${s} Unix seconds`:"; the exact release time is read after posting"}. Release requires no line and no open loan; default can forfeit the bond. Invites are not guaranteed. The credit score can lag qualifying repayments.`}}var R="(uint256 agentId, uint256 sponsorId, address owner, uint256 maxPremiumBps, uint256 nonce, uint256 deadline)",B=I(["function agentId() view returns (uint256)","function firstLined(uint256 id) view returns (bool)","function inviteDigest(uint256 id, uint64 expiry) view returns (bytes32)","function inviters(address who) view returns (bool)","function inviteUsed(bytes32 digest) view returns (bool)","function epochRoom() view returns (uint256)","function rules() view returns (uint256 reserveBps, uint256 firstLine, uint256 secondLine, uint256 epochCap, uint64 epochLength, uint64 minSeasoning, uint256 minQualified, uint256 minScore, uint64 idleAfter)",`function firstLine(uint256 id, uint64 expiry, bytes invite, ${R} c, bytes consentSig)`,"error NotAdopted()","error AlreadyLined(uint256 agentId)","error OwnerDefaulted(address owner)","error EpochCapReached(uint256 wanted, uint256 left)","error NotInvited(uint256 agentId, address signer)","error InviteExpired(uint256 agentId, uint64 expiry)","error InviteUsed(uint256 agentId)","error BadConsent()","error ConsentExpired()","error PremiumTooHigh(uint256 bps, uint256 cap)","error InsufficientBacking(uint256 rootId, uint256 requested, uint256 free)","error AgentDefaulted(uint256 agentId)","error IsRoot(uint256 agentId)","error V1Busy(uint256 agentId)","error LoanOpen(uint256 agentId)","error InvalidAgent(uint256 id)","error Paused()","error ECDSAInvalidSignature()","error ECDSAInvalidSignatureLength(uint256 length)","error ECDSAInvalidSignatureS(bytes32 s)"]),v={Consent:[{name:"agentId",type:"uint256"},{name:"sponsorId",type:"uint256"},{name:"owner",type:"address"},{name:"maxPremiumBps",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]};function D(){return{name:"Priors Credit",version:"2",chainId:a,verifyingContract:d(l[4663].priors.pool.address)}}function q(e){return{domain:{...D()},types:{Consent:v.Consent.map(t=>({...t}))},primaryType:"Consent",message:{agentId:e.agentId,sponsorId:x.toString(),owner:d(e.owner),maxPremiumBps:"0",nonce:e.nonce,deadline:e.deadline}}}function L(e){return w(e)}function U(e,t){return w({domain:{name:"Priors Treasury",version:"4",chainId:a,verifyingContract:h},types:{Invite:[{name:"agentId",type:"uint256"},{name:"expiry",type:"uint64"}]},primaryType:"Invite",message:{agentId:e,expiry:t}})}function O(e,t,r){return["priors.trade seat request","",`I own agent #${e} on Robinhood Chain and I am asking for a seat.`,"Asked from the priors.trade start page","","This signature only proves ownership. It sends no transaction and moves no funds.","",`request: ${t}`,`expires: ${new Date(r*1e3).toISOString().replace(".000","")}`].join(`
1
+ import{g as c}from"./NWNYJ26T.js";import{b as a,j as l}from"./EWZFZUVF.js";import{a as f}from"./XSD5NL7J.js";import{formatUnits as b,getAddress as d,hashTypedData as w,parseAbi as I}from"viem";var p=d("0x8BE478c754D9124D11e78dB20F5bf4dA45403275"),h=d("0x0c5091235A25bBFD3F5a009cBe04120D0CBAD573"),x=6228n,_="https://priors.trade/prove",$="https://priors.trade/invite",m=1800,k=3600,S=/^[0-9a-f]{32}$/,A=/^priors-invite:(\d{1,10}):(\d{1,12}):(0x[0-9a-fA-F]{130})$/,g=I(["function amount() view returns (uint256)","function unusedAfter() view returns (uint64)","function bonds(uint256 agentId) view returns ((address depositor, uint64 at, uint256 amount, uint256 qualifiedAt))","function releasable(uint256 agentId) view returns (bool)","function unusedReleaseAt(uint256 agentId) view returns (uint256)","function progress(uint256 agentId) view returns (uint256 repaid, uint256 needed)","function deposit(uint256 agentId)","function release(uint256 agentId)","error AlreadyBonded(uint256 agentId)","error NotOwner(uint256 agentId)","error AgentDefaulted(uint256 agentId)","error NoBond(uint256 agentId)","error NotReleasable(uint256 agentId)"]);async function E(e,t){let r=e.clientFor(a),n=await r.getBlockNumber({cacheTime:0}),[i,o,s]=await Promise.all([r.readContract({address:p,abi:g,functionName:"amount",blockNumber:n}),r.readContract({address:p,abi:g,functionName:"unusedAfter",blockNumber:n}),r.readContract({address:p,abi:g,functionName:"unusedReleaseAt",args:[t],blockNumber:n})]);if(typeof i!="bigint"||i<0n||typeof o!="bigint"||o<0n||typeof s!="bigint"||s<0n)throw new f("Priors bond terms are unavailable. Read amount, unusedAfter and unusedReleaseAt again before posting a bond.");return{amount:i.toString(),unusedAfter:o.toString(),unusedReleaseAt:s.toString(),blockNumber:n.toString(),summary:`Bond first: the starter line requires ${b(i,6)} USDG locked for at least ${o} seconds (${Number(o)/86400} days) after posting${s?`; unusedReleaseAt(${t}) is ${s} Unix seconds`:"; the exact release time is read after posting"}. Release requires no line and no open loan; default can forfeit the bond. Invites are not guaranteed. The credit score can lag qualifying repayments.`}}var R="(uint256 agentId, uint256 sponsorId, address owner, uint256 maxPremiumBps, uint256 nonce, uint256 deadline)",B=I(["function agentId() view returns (uint256)","function firstLined(uint256 id) view returns (bool)","function inviteDigest(uint256 id, uint64 expiry) view returns (bytes32)","function inviters(address who) view returns (bool)","function inviteUsed(bytes32 digest) view returns (bool)","function epochRoom() view returns (uint256)","function rules() view returns (uint256 reserveBps, uint256 firstLine, uint256 secondLine, uint256 epochCap, uint64 epochLength, uint64 minSeasoning, uint256 minQualified, uint256 minScore, uint64 idleAfter)",`function firstLine(uint256 id, uint64 expiry, bytes invite, ${R} c, bytes consentSig)`,"error NotAdopted()","error AlreadyLined(uint256 agentId)","error OwnerDefaulted(address owner)","error EpochCapReached(uint256 wanted, uint256 left)","error NotInvited(uint256 agentId, address signer)","error InviteExpired(uint256 agentId, uint64 expiry)","error InviteUsed(uint256 agentId)","error BadConsent()","error ConsentExpired()","error PremiumTooHigh(uint256 bps, uint256 cap)","error InsufficientBacking(uint256 rootId, uint256 requested, uint256 free)","error AgentDefaulted(uint256 agentId)","error IsRoot(uint256 agentId)","error V1Busy(uint256 agentId)","error LoanOpen(uint256 agentId)","error InvalidAgent(uint256 id)","error Paused()","error ECDSAInvalidSignature()","error ECDSAInvalidSignatureLength(uint256 length)","error ECDSAInvalidSignatureS(bytes32 s)"]),v={Consent:[{name:"agentId",type:"uint256"},{name:"sponsorId",type:"uint256"},{name:"owner",type:"address"},{name:"maxPremiumBps",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]};function D(){return{name:"Priors Credit",version:"2",chainId:a,verifyingContract:d(l[4663].priors.pool.address)}}function q(e){return{domain:{...D()},types:{Consent:v.Consent.map(t=>({...t}))},primaryType:"Consent",message:{agentId:e.agentId,sponsorId:x.toString(),owner:d(e.owner),maxPremiumBps:"0",nonce:e.nonce,deadline:e.deadline}}}function L(e){return w(e)}function U(e,t){return w({domain:{name:"Priors Treasury",version:"4",chainId:a,verifyingContract:h},types:{Invite:[{name:"agentId",type:"uint256"},{name:"expiry",type:"uint64"}]},primaryType:"Invite",message:{agentId:e,expiry:t}})}function O(e,t,r){return["priors.trade seat request","",`I own agent #${e} on Robinhood Chain and I am asking for a seat.`,"Asked from the priors.trade start page","","This signature only proves ownership. It sends no transaction and moves no funds.","",`request: ${t}`,`expires: ${new Date(r*1e3).toISOString().replace(".000","")}`].join(`
2
2
  `)}var u=e=>typeof e=="string"?JSON.stringify(e.length>80?`${e.slice(0,80)}...`:e):typeof e=="number"?String(e):e===null?"null":typeof e;function V(e,t){let r=o=>({ok:!1,why:o});if(!e||typeof e!="object"||Array.isArray(e))return r("its answer is not the bot's form");let n=e;if(n.ok!==!0)return{ok:!1,refused:!0,why:typeof n.error=="string"&&n.error?n.error:"it answered no, with no reason"};if(typeof n.agentId!="string"&&typeof n.agentId!="number"||String(n.agentId)!==t.agentId)return r(`it is for agent ${u(n.agentId)}, not agent #${t.agentId}`);if(typeof n.owner!="string"||!c(n.owner,t.owner))return r(`it names ${u(n.owner)} as the agent's owner, not this wallet (${t.owner})`);if(typeof n.n!="string"||!S.test(n.n))return r(`its request ${u(n.n)} is not the bot's form (32 hex digits)`);if(typeof n.exp!="number"||!Number.isSafeInteger(n.exp))return r(`its expiry ${u(n.exp)} is not a time`);if(n.exp<=t.now)return r(`its expiry (${new Date(n.exp*1e3).toISOString()}) has already passed`);if(n.exp>t.now+m+300)return r(`its expiry (${new Date(n.exp*1e3).toISOString()}) is further away than the bot's ${m/60} minutes`);let i=O(t.agentId,n.n,n.exp);if(typeof n.message!="string")return r("it carries no message");if(n.message!==i){let o=0;for(;o<i.length&&n.message[o]===i[o];)o++;return r(`its message is not the bot's own form for agent #${t.agentId}, request ${n.n} and that expiry: the two first differ at character ${o+1} of ${i.length}`)}return{ok:!0,n:n.n,exp:n.exp,message:i}}function H(e,t,r){let n=A.exec(typeof e=="string"?e:"");if(!n)return{ok:!1,why:"it is not an invite code (priors-invite:<id>:<expiry>:<signature>)"};if(n[1]!==t)return{ok:!1,why:`it is for agent #${n[1]}, not agent #${t}`};let i=Number(n[2]);return i<=r?{ok:!1,why:`it expired at ${new Date(i*1e3).toISOString()}`}:{ok:!0,expiry:BigInt(n[2]),signature:n[3]}}var y=e=>`${new Date(e*1e3).toISOString().slice(0,16).replace("T"," ")} UTC`;function F(e){let t=typeof e.reopensAt=="number"&&Number.isSafeInteger(e.reopensAt)&&e.reopensAt>0?e.reopensAt:null;switch(e.reason){case"default":return"A default on this wallet's record stops new lines for its agents, so a bond would bring no invite.";case"day":return"Today's automatic invites are taken. New ones open at 00:00 UTC: call priors_starter_line again after that.";case"room":return e.held===!0&&t?`This week's first lines are held by invites that haven't been used yet. One may be free after ${y(t)}: call priors_starter_line again then.`:`This week's first lines are taken.${t?` New ones open after ${y(t)}: call priors_starter_line again then.`:" Come back next week."}`;case"owner":return`This wallet already used its ${typeof e.perOwner=="number"&&Number.isSafeInteger(e.perOwner)&&e.perOwner>0?e.perOwner:2} automatic invites, so a bond would bring no invite.`;case"waiting":return"Another agent of this wallet has an invite waiting. Use it, or let it expire, before asking for this one.";case"backing":return"The treasury can't back a new line right now. Try again later.";default:return"Automatic invites aren't open right now, so a bond would bring no invite. Try again later."}}export{p as a,h as b,x as c,_ as d,$ as e,m as f,k as g,S as h,A as i,g as j,E as k,B as l,v as m,D as n,q as o,L as p,U as q,O as r,V as s,H as t,F as u};
@@ -1 +1 @@
1
- import{a as l}from"./43LI5NKJ.js";import{a as F}from"./66F5ZH34.js";import{g as D}from"./NWNYJ26T.js";import{b as U}from"./IX3GZMTM.js";import{b as c}from"./TI727O2H.js";import{a as w}from"./XSD5NL7J.js";import{encodeFunctionData as A,getAddress as S,parseAbi as _}from"viem";var N={address:S("0xCA9c78Dd337A67F6e0077F65F5E9218719d30eDf"),symbol:"NET",decimals:9,chainId:c},r={address:S("0xb773ec2C326B7f98a5a83fc098825492F020a4c7"),symbol:"sNET",decimals:9,chainId:c},u={address:S("0x63C12667638f2Ae6fC6ae09B43D98Ec84a8586eA"),symbol:"wsNET",decimals:18,chainId:c},i=S("0xB078cc304A0B264C5F3680DC0488954ACcd02E87"),k=S("0xA1ee052EC32532304a7522bd9A4b594eC28fF1b1"),tt=[i,u.address,k],p=_(["function net() view returns (address)","function sNet() view returns (address)","function warmupEpochs() view returns (uint256)","function epoch() view returns (uint64 length,uint64 number,uint64 end,uint256 distribute)","function warmup(address) view returns (uint256 gons,uint64 releaseEpoch)","function totalStaked() view returns (uint256)","function enabled() view returns (bool)","function claim(address to) returns (uint256)","function rebase()","function stake(address to, uint256 amount) returns (uint256)","function unstake(address to, uint256 amount) returns (uint256)"]),E=_(["function sNet() view returns (address)","function wrap(uint256 sNetAmount) returns (uint256)","function unwrap(uint256 wsAmount) returns (uint256)","function sNetToWs(uint256 sNetAmount) view returns (uint256)","function wsToSNet(uint256 wsAmount) view returns (uint256)"]),$=_(["function net() view returns (address)","function sNet() view returns (address)","function staking() view returns (address)","function wsNet() view returns (address)","function zap(uint256 netAmount) returns (uint256)"]),W=_(["function balanceOf(address owner) view returns (uint256)","function balanceForGons(uint256) view returns (uint256)"]),z="The expected output is a chain-read estimate; these calls encode no minimum output. No transaction was sent.",O=o=>({description:`${o.symbol} amount in base units (${o.symbol} has ${o.decimals} decimals; "${"1".padEnd(o.decimals+1,"0")}" = 1 ${o.symbol}), or "max" for the whole wallet balance.`,anyOf:[F(`Positive ${o.symbol} amount in integer base units (${o.decimals} decimals).`),{const:"max",description:`The fresh full ${o.symbol} wallet balance.`}]}),et=o=>{async function v(e){try{return await e()}catch(t){throw new w(o.plainError(t))}}function y(e,t){if(Object.keys(e).some(n=>!t.includes(n)))throw new w("Unsupported NetNet staking argument. Use the fields in the tool schema.")}async function f(e=!1){let t=o.clientFor(c);if(await t.getChainId()!==c)throw new w("NetNet staking requires chain 4663.");let n=[t.readContract({address:i,abi:p,functionName:"net"}),t.readContract({address:i,abi:p,functionName:"sNet"}),t.readContract({address:u.address,abi:E,functionName:"sNet"}),...e?[t.readContract({address:k,abi:$,functionName:"net"}),t.readContract({address:k,abi:$,functionName:"sNet"}),t.readContract({address:k,abi:$,functionName:"staking"}),t.readContract({address:k,abi:$,functionName:"wsNet"})]:[]],[s,a,d,...m]=await Promise.all(n),b=[N.address,r.address,r.address,...e?[N.address,r.address,i,u.address]:[]];if(![s,a,d,...m].every((T,q)=>typeof T=="string"&&D(T,b[q])))throw new w("NetNet staking contracts do not report the pinned NET, sNET and wsNET links.");return t}async function x(e,t){return o.clientFor(c).readContract({address:e.address,abi:W,functionName:"balanceOf",args:[t]})}async function C(e,t,n){let s=await x(t,n),a;if(e==="max")a=s;else{if(typeof e!="string")throw new w(`Provide an integer ${t.symbol} amount in base units, or "max".`);a=U(e)}if(a<=0n||a>=1n<<256n)throw new w(`This wallet has no ${t.symbol} to use; the amount must be positive.`);if(a>s)throw new w(`Insufficient ${t.symbol}: wallet holds ${s.toString()} base units, requested ${a.toString()}.`);return a}async function g(e,t,n,s){let a=await o.preview(e,t),d=a.changes.map(({token:m,amount:b})=>{let T=b.startsWith("-");return`${T?"-":"+"}${o.formatAmount(T?b.slice(1):b,m.decimals)} ${m.symbol}`}).join(", ");return{txs:e,preview:a,expectedOutput:n,summary:`${s} ${a.summary} ${d?`Estimated changes: ${d}. `:""}${z}`}}let h=(e,t,n)=>o.unsignedTx({to:e,data:t,value:"0",chainId:c,description:n});async function j(e,t){if(y(e,["amount","wrap"]),l(t),e.wrap!==void 0&&typeof e.wrap!="boolean")throw new w("wrap must be a boolean.");let n=await f(e.wrap===!0);if(e.amount==="max")throw new w("Provide an exact NET amount in base units to stake.");let s=await n.readContract({address:i,abi:p,functionName:"warmupEpochs"});if(s!==0n&&e.wrap===!0)throw new w("NetNet warmup prevents immediate Zap wrapping; stake directly, then claim matured sNET before wrapping.");let a=await C(e.amount,N,t),d=o.formatAmount(a.toString(),N.decimals);if(e.wrap===!0){let m=await n.readContract({address:u.address,abi:E,functionName:"sNetToWs",args:[a]});return g([o.approval(N.address,k,a.toString(),c),h(k,A({abi:$,functionName:"zap",args:[a]}),`Stake ${d} NET and wrap it into wsNET with NetNet's Zap.`)],t,{token:u,amount:m.toString()},`Approve exactly ${d} NET, then stake and wrap it into wsNET in one call.`)}return g([o.approval(N.address,i,a.toString(),c),h(i,A({abi:p,functionName:"stake",args:[S(t),a]}),`Stake ${d} NET into sNET.`)],t,{token:r,amount:s===0n?a.toString():"0"},s===0n?`Approve exactly ${d} NET, then stake it 1:1 into rebasing sNET.`:`Approve exactly ${d} NET and stake it into a ${s}-epoch warmup. No immediate sNET receipt; netnet_claim_stake releases matured sNET. Another stake resets your release epoch.`)}async function B(e,t){y(e,["amount"]),l(t),await f();let n=await C(e.amount,r,t),s=o.formatAmount(n.toString(),r.decimals);return g([o.approval(r.address,i,n.toString(),c),h(i,A({abi:p,functionName:"unstake",args:[S(t),n]}),`Unstake ${s} sNET into NET.`)],t,{token:N,amount:n.toString()},`Approve exactly ${s} sNET, then unstake it 1:1 into NET.`)}async function L(e,t){y(e,["amount"]),l(t);let n=await f(),s=await C(e.amount,r,t),a=o.formatAmount(s.toString(),r.decimals),d=await n.readContract({address:u.address,abi:E,functionName:"sNetToWs",args:[s]});return g([o.approval(r.address,u.address,s.toString(),c),h(u.address,A({abi:E,functionName:"wrap",args:[s]}),`Wrap ${a} sNET into wsNET.`)],t,{token:u,amount:d.toString()},`Approve exactly ${a} sNET, then wrap it into non-rebasing wsNET, the Loopback collateral.`)}async function G(e,t){y(e,["amount"]),l(t);let n=await f(),s=await C(e.amount,u,t),a=o.formatAmount(s.toString(),u.decimals),d=await n.readContract({address:u.address,abi:E,functionName:"wsToSNet",args:[s]});return g([h(u.address,A({abi:E,functionName:"unwrap",args:[s]}),`Unwrap ${a} wsNET into sNET.`)],t,{token:r,amount:d.toString()},`Unwrap ${a} wsNET into sNET; no approval is needed.`)}async function M(e){return v(async()=>{l(e);let t=await f(),[n,s]=await Promise.all([x(r,e),x(u,e)]),a=[];if(n>0n&&a.push({module:"netnet",id:`${c}:${r.address.toLowerCase()}`,chainId:c,assets:[{token:{...N},amount:n.toString()}],description:`${o.formatAmount(n.toString(),r.decimals)} sNET staked NET (rebasing; unstakes 1:1 into NET with netnet_unstake).`}),s>0n){let m=await t.readContract({address:u.address,abi:E,functionName:"wsToSNet",args:[s]});a.push({module:"netnet",id:`${c}:${u.address.toLowerCase()}`,chainId:c,assets:[{token:{...N},amount:m.toString()}],description:`${o.formatAmount(s.toString(),u.decimals)} wsNET in the wallet, worth ${o.formatAmount(m.toString(),r.decimals)} sNET (NET 1:1) at the current index. wsNET posted as Morpho collateral appears under Morpho instead.`})}if(await t.readContract({address:i,abi:p,functionName:"warmupEpochs"})>0n){let m=await I({},e);BigInt(m.warmup.pendingSNet)>0n&&a.push({module:"netnet",id:`${c}:${i.toLowerCase()}:warmup`,chainId:c,assets:[{token:N,amount:m.warmup.pendingSNet}],description:`Pending NetNet warmup stake; releases sNET at epoch ${m.warmup.releaseEpoch}. Claim with netnet_claim_stake, then wrap or unstake.`})}return a})}async function I(e,t){y(e,[]),l(t);let n=await f(),[s,a,d,m,b]=await Promise.all([n.readContract({address:i,abi:p,functionName:"epoch"}),n.readContract({address:i,abi:p,functionName:"warmup",args:[t]}),n.readContract({address:i,abi:p,functionName:"warmupEpochs"}),n.readContract({address:i,abi:p,functionName:"totalStaked"}),n.readContract({address:i,abi:p,functionName:"enabled"})]),T=await n.readContract({address:r.address,abi:W,functionName:"balanceForGons",args:[a[0]]});return{chainId:c,staking:i,tokens:{net:N,sNet:r,wsNet:u},enabled:b,epoch:{length:s[0].toString(),number:s[1].toString(),end:s[2].toString(),distribute:s[3].toString()},warmupEpochs:d.toString(),totalStaked:m.toString(),warmup:{gons:a[0].toString(),releaseEpoch:a[1].toString(),pendingSNet:T.toString(),matured:a[0]>0n&&s[1]>=a[1]},caveat:"Warmup uses epoch numbers, not wall-clock time. Each rebase advances at most one due epoch; a claim also rebases once if due. A new stake resets the warmup release epoch."}}async function R(e,t){let n=await I(e,t);if(!n.enabled||!n.warmup.matured)throw new w("No matured NetNet warmup stake. Read netnet_staking_status and advance a due epoch before claiming.");return g([h(i,A({abi:p,functionName:"claim",args:[t]}),`Claim matured sNET to this wallet ${t}.`)],t,{token:r,amount:n.warmup.pendingSNet},"Claim matured NetNet staking warmup; rebase may change the sNET receipt.")}async function Z(e,t){y(e,[]),l(t);let n=await f(),[s,a,d]=await Promise.all([n.readContract({address:i,abi:p,functionName:"epoch"}),n.getBlock(),n.readContract({address:i,abi:p,functionName:"enabled"})]);if(!d||a.timestamp<s[2])throw new w("No enabled NetNet epoch is due to rebase.");return g([h(i,A({abi:p,functionName:"rebase"}),"Advance one due NetNet staking epoch and checkpoint its oracle.")],t,{token:r,amount:"0"},"Advance one due epoch. Distribution depends on live protocol state; this does not guarantee a reward.")}let P=(e,t,n)=>({name:e,inputSchema:{type:"object",properties:t,required:["amount"],additionalProperties:!1},execute:(s,a)=>v(()=>n(s,a))});return{positions:M,tools:[{name:"netnet_staking_status",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>I(e,t))},{name:"netnet_claim_stake",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>R(e,t))},{name:"netnet_rebase",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>Z(e,t))},P("netnet_stake",{amount:F("Positive NET amount in integer base units (9 decimals)."),wrap:{type:"boolean",default:!1,description:"Stake and wrap into wsNET in one call through NetNet's Zap."}},j),P("netnet_wrap",{amount:O(r)},L),P("netnet_unwrap",{amount:O(u)},G),P("netnet_unstake",{amount:O(r)},B)]}};export{N as a,r as b,u as c,i as d,k as e,tt as f,et as g};
1
+ import{a as l}from"./43LI5NKJ.js";import{a as F}from"./66F5ZH34.js";import{g as D}from"./NWNYJ26T.js";import{b as U}from"./IX3GZMTM.js";import{b as c}from"./EWZFZUVF.js";import{a as w}from"./XSD5NL7J.js";import{encodeFunctionData as A,getAddress as S,parseAbi as _}from"viem";var N={address:S("0xCA9c78Dd337A67F6e0077F65F5E9218719d30eDf"),symbol:"NET",decimals:9,chainId:c},r={address:S("0xb773ec2C326B7f98a5a83fc098825492F020a4c7"),symbol:"sNET",decimals:9,chainId:c},u={address:S("0x63C12667638f2Ae6fC6ae09B43D98Ec84a8586eA"),symbol:"wsNET",decimals:18,chainId:c},i=S("0xB078cc304A0B264C5F3680DC0488954ACcd02E87"),k=S("0xA1ee052EC32532304a7522bd9A4b594eC28fF1b1"),tt=[i,u.address,k],p=_(["function net() view returns (address)","function sNet() view returns (address)","function warmupEpochs() view returns (uint256)","function epoch() view returns (uint64 length,uint64 number,uint64 end,uint256 distribute)","function warmup(address) view returns (uint256 gons,uint64 releaseEpoch)","function totalStaked() view returns (uint256)","function enabled() view returns (bool)","function claim(address to) returns (uint256)","function rebase()","function stake(address to, uint256 amount) returns (uint256)","function unstake(address to, uint256 amount) returns (uint256)"]),E=_(["function sNet() view returns (address)","function wrap(uint256 sNetAmount) returns (uint256)","function unwrap(uint256 wsAmount) returns (uint256)","function sNetToWs(uint256 sNetAmount) view returns (uint256)","function wsToSNet(uint256 wsAmount) view returns (uint256)"]),$=_(["function net() view returns (address)","function sNet() view returns (address)","function staking() view returns (address)","function wsNet() view returns (address)","function zap(uint256 netAmount) returns (uint256)"]),W=_(["function balanceOf(address owner) view returns (uint256)","function balanceForGons(uint256) view returns (uint256)"]),z="The expected output is a chain-read estimate; these calls encode no minimum output. No transaction was sent.",O=o=>({description:`${o.symbol} amount in base units (${o.symbol} has ${o.decimals} decimals; "${"1".padEnd(o.decimals+1,"0")}" = 1 ${o.symbol}), or "max" for the whole wallet balance.`,anyOf:[F(`Positive ${o.symbol} amount in integer base units (${o.decimals} decimals).`),{const:"max",description:`The fresh full ${o.symbol} wallet balance.`}]}),et=o=>{async function v(e){try{return await e()}catch(t){throw new w(o.plainError(t))}}function y(e,t){if(Object.keys(e).some(n=>!t.includes(n)))throw new w("Unsupported NetNet staking argument. Use the fields in the tool schema.")}async function f(e=!1){let t=o.clientFor(c);if(await t.getChainId()!==c)throw new w("NetNet staking requires chain 4663.");let n=[t.readContract({address:i,abi:p,functionName:"net"}),t.readContract({address:i,abi:p,functionName:"sNet"}),t.readContract({address:u.address,abi:E,functionName:"sNet"}),...e?[t.readContract({address:k,abi:$,functionName:"net"}),t.readContract({address:k,abi:$,functionName:"sNet"}),t.readContract({address:k,abi:$,functionName:"staking"}),t.readContract({address:k,abi:$,functionName:"wsNet"})]:[]],[s,a,d,...m]=await Promise.all(n),b=[N.address,r.address,r.address,...e?[N.address,r.address,i,u.address]:[]];if(![s,a,d,...m].every((T,q)=>typeof T=="string"&&D(T,b[q])))throw new w("NetNet staking contracts do not report the pinned NET, sNET and wsNET links.");return t}async function x(e,t){return o.clientFor(c).readContract({address:e.address,abi:W,functionName:"balanceOf",args:[t]})}async function C(e,t,n){let s=await x(t,n),a;if(e==="max")a=s;else{if(typeof e!="string")throw new w(`Provide an integer ${t.symbol} amount in base units, or "max".`);a=U(e)}if(a<=0n||a>=1n<<256n)throw new w(`This wallet has no ${t.symbol} to use; the amount must be positive.`);if(a>s)throw new w(`Insufficient ${t.symbol}: wallet holds ${s.toString()} base units, requested ${a.toString()}.`);return a}async function g(e,t,n,s){let a=await o.preview(e,t),d=a.changes.map(({token:m,amount:b})=>{let T=b.startsWith("-");return`${T?"-":"+"}${o.formatAmount(T?b.slice(1):b,m.decimals)} ${m.symbol}`}).join(", ");return{txs:e,preview:a,expectedOutput:n,summary:`${s} ${a.summary} ${d?`Estimated changes: ${d}. `:""}${z}`}}let h=(e,t,n)=>o.unsignedTx({to:e,data:t,value:"0",chainId:c,description:n});async function j(e,t){if(y(e,["amount","wrap"]),l(t),e.wrap!==void 0&&typeof e.wrap!="boolean")throw new w("wrap must be a boolean.");let n=await f(e.wrap===!0);if(e.amount==="max")throw new w("Provide an exact NET amount in base units to stake.");let s=await n.readContract({address:i,abi:p,functionName:"warmupEpochs"});if(s!==0n&&e.wrap===!0)throw new w("NetNet warmup prevents immediate Zap wrapping; stake directly, then claim matured sNET before wrapping.");let a=await C(e.amount,N,t),d=o.formatAmount(a.toString(),N.decimals);if(e.wrap===!0){let m=await n.readContract({address:u.address,abi:E,functionName:"sNetToWs",args:[a]});return g([o.approval(N.address,k,a.toString(),c),h(k,A({abi:$,functionName:"zap",args:[a]}),`Stake ${d} NET and wrap it into wsNET with NetNet's Zap.`)],t,{token:u,amount:m.toString()},`Approve exactly ${d} NET, then stake and wrap it into wsNET in one call.`)}return g([o.approval(N.address,i,a.toString(),c),h(i,A({abi:p,functionName:"stake",args:[S(t),a]}),`Stake ${d} NET into sNET.`)],t,{token:r,amount:s===0n?a.toString():"0"},s===0n?`Approve exactly ${d} NET, then stake it 1:1 into rebasing sNET.`:`Approve exactly ${d} NET and stake it into a ${s}-epoch warmup. No immediate sNET receipt; netnet_claim_stake releases matured sNET. Another stake resets your release epoch.`)}async function B(e,t){y(e,["amount"]),l(t),await f();let n=await C(e.amount,r,t),s=o.formatAmount(n.toString(),r.decimals);return g([o.approval(r.address,i,n.toString(),c),h(i,A({abi:p,functionName:"unstake",args:[S(t),n]}),`Unstake ${s} sNET into NET.`)],t,{token:N,amount:n.toString()},`Approve exactly ${s} sNET, then unstake it 1:1 into NET.`)}async function L(e,t){y(e,["amount"]),l(t);let n=await f(),s=await C(e.amount,r,t),a=o.formatAmount(s.toString(),r.decimals),d=await n.readContract({address:u.address,abi:E,functionName:"sNetToWs",args:[s]});return g([o.approval(r.address,u.address,s.toString(),c),h(u.address,A({abi:E,functionName:"wrap",args:[s]}),`Wrap ${a} sNET into wsNET.`)],t,{token:u,amount:d.toString()},`Approve exactly ${a} sNET, then wrap it into non-rebasing wsNET, the Loopback collateral.`)}async function G(e,t){y(e,["amount"]),l(t);let n=await f(),s=await C(e.amount,u,t),a=o.formatAmount(s.toString(),u.decimals),d=await n.readContract({address:u.address,abi:E,functionName:"wsToSNet",args:[s]});return g([h(u.address,A({abi:E,functionName:"unwrap",args:[s]}),`Unwrap ${a} wsNET into sNET.`)],t,{token:r,amount:d.toString()},`Unwrap ${a} wsNET into sNET; no approval is needed.`)}async function M(e){return v(async()=>{l(e);let t=await f(),[n,s]=await Promise.all([x(r,e),x(u,e)]),a=[];if(n>0n&&a.push({module:"netnet",id:`${c}:${r.address.toLowerCase()}`,chainId:c,assets:[{token:{...N},amount:n.toString()}],description:`${o.formatAmount(n.toString(),r.decimals)} sNET staked NET (rebasing; unstakes 1:1 into NET with netnet_unstake).`}),s>0n){let m=await t.readContract({address:u.address,abi:E,functionName:"wsToSNet",args:[s]});a.push({module:"netnet",id:`${c}:${u.address.toLowerCase()}`,chainId:c,assets:[{token:{...N},amount:m.toString()}],description:`${o.formatAmount(s.toString(),u.decimals)} wsNET in the wallet, worth ${o.formatAmount(m.toString(),r.decimals)} sNET (NET 1:1) at the current index. wsNET posted as Morpho collateral appears under Morpho instead.`})}if(await t.readContract({address:i,abi:p,functionName:"warmupEpochs"})>0n){let m=await I({},e);BigInt(m.warmup.pendingSNet)>0n&&a.push({module:"netnet",id:`${c}:${i.toLowerCase()}:warmup`,chainId:c,assets:[{token:N,amount:m.warmup.pendingSNet}],description:`Pending NetNet warmup stake; releases sNET at epoch ${m.warmup.releaseEpoch}. Claim with netnet_claim_stake, then wrap or unstake.`})}return a})}async function I(e,t){y(e,[]),l(t);let n=await f(),[s,a,d,m,b]=await Promise.all([n.readContract({address:i,abi:p,functionName:"epoch"}),n.readContract({address:i,abi:p,functionName:"warmup",args:[t]}),n.readContract({address:i,abi:p,functionName:"warmupEpochs"}),n.readContract({address:i,abi:p,functionName:"totalStaked"}),n.readContract({address:i,abi:p,functionName:"enabled"})]),T=await n.readContract({address:r.address,abi:W,functionName:"balanceForGons",args:[a[0]]});return{chainId:c,staking:i,tokens:{net:N,sNet:r,wsNet:u},enabled:b,epoch:{length:s[0].toString(),number:s[1].toString(),end:s[2].toString(),distribute:s[3].toString()},warmupEpochs:d.toString(),totalStaked:m.toString(),warmup:{gons:a[0].toString(),releaseEpoch:a[1].toString(),pendingSNet:T.toString(),matured:a[0]>0n&&s[1]>=a[1]},caveat:"Warmup uses epoch numbers, not wall-clock time. Each rebase advances at most one due epoch; a claim also rebases once if due. A new stake resets the warmup release epoch."}}async function R(e,t){let n=await I(e,t);if(!n.enabled||!n.warmup.matured)throw new w("No matured NetNet warmup stake. Read netnet_staking_status and advance a due epoch before claiming.");return g([h(i,A({abi:p,functionName:"claim",args:[t]}),`Claim matured sNET to this wallet ${t}.`)],t,{token:r,amount:n.warmup.pendingSNet},"Claim matured NetNet staking warmup; rebase may change the sNET receipt.")}async function Z(e,t){y(e,[]),l(t);let n=await f(),[s,a,d]=await Promise.all([n.readContract({address:i,abi:p,functionName:"epoch"}),n.getBlock(),n.readContract({address:i,abi:p,functionName:"enabled"})]);if(!d||a.timestamp<s[2])throw new w("No enabled NetNet epoch is due to rebase.");return g([h(i,A({abi:p,functionName:"rebase"}),"Advance one due NetNet staking epoch and checkpoint its oracle.")],t,{token:r,amount:"0"},"Advance one due epoch. Distribution depends on live protocol state; this does not guarantee a reward.")}let P=(e,t,n)=>({name:e,inputSchema:{type:"object",properties:t,required:["amount"],additionalProperties:!1},execute:(s,a)=>v(()=>n(s,a))});return{positions:M,tools:[{name:"netnet_staking_status",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>I(e,t))},{name:"netnet_claim_stake",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>R(e,t))},{name:"netnet_rebase",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>Z(e,t))},P("netnet_stake",{amount:F("Positive NET amount in integer base units (9 decimals)."),wrap:{type:"boolean",default:!1,description:"Stake and wrap into wsNET in one call through NetNet's Zap."}},j),P("netnet_wrap",{amount:O(r)},L),P("netnet_unwrap",{amount:O(u)},G),P("netnet_unstake",{amount:O(r)},B)]}};export{N as a,r as b,u as c,i as d,k as e,tt as f,et as g};
@@ -1 +1 @@
1
- import{a as y,b as P,d as I,e as q,f as T,g as L}from"./ZXRIJG6H.js";import{a as w}from"./66F5ZH34.js";import{c as k,g as D}from"./NWNYJ26T.js";import{b as f}from"./TI727O2H.js";import{a as c}from"./XSD5NL7J.js";import{encodeFunctionData as U,erc20Abi as $,getAddress as O,parseAbi as S,zeroAddress as g}from"viem";var _=O("0x8bceaa40b9acdfaedf85adf4ff01f5ad6517937f"),h=O("0x89e5db8b5aa49aa85ac63f691524311aeb649eba"),F=S(["function getPair(address,address) view returns (address)"]),N=S(["function token0() view returns (address)","function token1() view returns (address)","function getReserves() view returns (uint112,uint112,uint32)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)"]),E=S(["function factory() view returns (address)","function addLiquidity(address tokenA,address tokenB,uint256 amountADesired,uint256 amountBDesired,uint256 amountAMin,uint256 amountBMin,address to,uint256 deadline) returns (uint256,uint256,uint256)","function removeLiquidity(address tokenA,address tokenB,uint256 liquidity,uint256 amountAMin,uint256 amountBMin,address to,uint256 deadline) returns (uint256,uint256)","function getAmountsOut(uint256 amountIn,address[] path) view returns (uint256[] amounts)","function getAmountsIn(uint256 amountOut,address[] path) view returns (uint256[] amounts)"]);async function z(s,p,t,n){if(p===g||t===g||p===t)throw new c("Provide two different ERC-20 tokens; use WETH for native ETH.");let r=s.clientFor(f),i=await r.getBlockNumber(),a=await r.readContract({address:_,abi:F,functionName:"getPair",args:[p,t],blockNumber:i}),[e,A]=await Promise.all([q(s,p,i),q(s,t,i)]);if(a===g)return{pair:a,tokenA:e,tokenB:A,reserveA:0n,reserveB:0n,supply:0n,balance:0n,blockNumber:i};let[M,l,v,B]=await Promise.all([r.readContract({address:a,abi:N,functionName:"token0",blockNumber:i}),r.readContract({address:a,abi:N,functionName:"getReserves",blockNumber:i}),r.readContract({address:a,abi:N,functionName:"totalSupply",blockNumber:i}),r.readContract({address:a,abi:$,functionName:"balanceOf",args:[n],blockNumber:i})]),[b,o]=D(M,p)?l:[l[1],l[0]];return{pair:a,tokenA:e,tokenB:A,reserveA:b,reserveB:o,supply:v,balance:B,blockNumber:i}}var H={tokenA:{...k,description:"Address of the first ERC-20 token."},tokenB:{...k,description:"Address of the second ERC-20 token."},amountADesired:w('Desired amount of tokenA in base units; use tokenA decimals. Example: "1000000" = 1 tokenA at 6 decimals.'),amountBDesired:w('Desired amount of tokenB in base units; use tokenB decimals. Example: "1000000" = 1 tokenB at 6 decimals.'),liquidity:{description:'LP token amount in base units (18 decimals), or "all" for the wallet balance. Example: "1000000000000000000" = 1 LP token.',type:"string",pattern:"^(?:[0-9]+|all)$"},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999},amountAMin:w('Minimum amount of tokenA in base units; use tokenA decimals. Example: "1000000" = 1 tokenA at 6 decimals.'),amountBMin:w('Minimum amount of tokenB in base units; use tokenB decimals. Example: "1000000" = 1 tokenB at 6 decimals.')};function J(s){let p=async(t,n,r)=>{L(n,t==="pool"?["tokenA","tokenB"]:["tokenA","tokenB","slippageBps","amountAMin","amountBMin",...t==="add"?["amountADesired","amountBDesired"]:["liquidity"]]);let i=P(n.tokenA),a=P(n.tokenB),e=await z(s,i,a,r);if(t==="pool")return{pair:e.pair,tokenA:e.tokenA,tokenB:e.tokenB,reserveA:e.reserveA.toString(),reserveB:e.reserveB.toString(),totalSupply:e.supply.toString(),balance:e.balance.toString(),blockNumber:e.blockNumber.toString(),initialized:e.pair!==g};let A=s.clientFor(f),M=I(n.slippageBps);if(!D(await A.readContract({address:h,abi:E,functionName:"factory"}),_))throw new c("Uniswap v2 router factory differs from its pinned deployment.");let l=(await A.getBlock()).timestamp+300n,v=[],B=(o,d,m)=>{let u=o===void 0?d*BigInt(1e4-M)/10000n:y(o,m,256,!0);if(u>d||d>0n&&u===0n)throw new c(`${m} must be positive and no more than the reserve-ratio estimate.`);return u},b;if(t==="add"){let o=y(n.amountADesired,"amountADesired"),d=y(n.amountBDesired,"amountBDesired");if(e.reserveA===0n!=(e.reserveB===0n))throw new c("Uniswap v2 pair reserves are inconsistent.");let m=o,u=d;if(e.reserveA>0n&&e.reserveB>0n){let R=o*e.reserveB/e.reserveA;R<=d?u=R:m=d*e.reserveA/e.reserveB}if(m===0n||u===0n)throw new c("Liquidity amounts round to zero at the pool reserve ratio.");let x=B(n.amountAMin,m,"amountAMin"),C=B(n.amountBMin,u,"amountBMin");v.push(s.approval(i,h,o.toString(),f),s.approval(a,h,d.toString(),f)),b=U({abi:E,functionName:"addLiquidity",args:[i,a,o,d,x,C,r,l]})}else{if(e.pair===g||e.supply===0n)throw new c("No Uniswap v2 liquidity exists for this pair.");let o=n.liquidity==="all"?e.balance:y(n.liquidity,"liquidity");if(o===0n||o>e.balance)throw new c("Removal exceeds the wallet LP token balance or is zero.");let[d,m]=await Promise.all([i,a].map(C=>A.readContract({address:C,abi:$,functionName:"balanceOf",args:[e.pair]}))),u=B(n.amountAMin,o*d/e.supply,"amountAMin"),x=B(n.amountBMin,o*m/e.supply,"amountBMin");v.push(s.approval(e.pair,h,o.toString(),f)),b=U({abi:E,functionName:"removeLiquidity",args:[i,a,o,u,x,r,l]})}return v.push(s.unsignedTx({to:h,data:b,value:"0",chainId:f,description:`${t} Uniswap v2 liquidity for ${i}/${a}; recipient ${r}; deadline ${l}.`})),T(s,v,r,`${t==="add"?"Add":"Remove"} v2 liquidity. Review exact approvals, token minimums and wallet recipient. The first deposit sets the price; v2 locks MINIMUM_LIQUIDITY permanently.`)};return{tools:["pool","add","remove"].map(t=>({name:`uniswap_v2_${t}`,inputSchema:{type:"object",additionalProperties:!1,required:["tokenA","tokenB",...t==="add"?["amountADesired","amountBDesired"]:t==="remove"?["liquidity"]:[]],properties:t==="pool"?{tokenA:{...k,description:"Address of the first ERC-20 token."},tokenB:{...k,description:"Address of the second ERC-20 token."}}:H},execute:(n,r)=>p(t,n,r)}))}}export{_ as a,h as b,F as c,N as d,E as e,z as f,J as g};
1
+ import{a as y,b as P,d as I,e as q,f as T,g as L}from"./QP2B7AYX.js";import{a as w}from"./66F5ZH34.js";import{c as k,g as D}from"./NWNYJ26T.js";import{b as f}from"./EWZFZUVF.js";import{a as c}from"./XSD5NL7J.js";import{encodeFunctionData as U,erc20Abi as $,getAddress as O,parseAbi as S,zeroAddress as g}from"viem";var _=O("0x8bceaa40b9acdfaedf85adf4ff01f5ad6517937f"),h=O("0x89e5db8b5aa49aa85ac63f691524311aeb649eba"),F=S(["function getPair(address,address) view returns (address)"]),N=S(["function token0() view returns (address)","function token1() view returns (address)","function getReserves() view returns (uint112,uint112,uint32)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)"]),E=S(["function factory() view returns (address)","function addLiquidity(address tokenA,address tokenB,uint256 amountADesired,uint256 amountBDesired,uint256 amountAMin,uint256 amountBMin,address to,uint256 deadline) returns (uint256,uint256,uint256)","function removeLiquidity(address tokenA,address tokenB,uint256 liquidity,uint256 amountAMin,uint256 amountBMin,address to,uint256 deadline) returns (uint256,uint256)","function getAmountsOut(uint256 amountIn,address[] path) view returns (uint256[] amounts)","function getAmountsIn(uint256 amountOut,address[] path) view returns (uint256[] amounts)"]);async function z(s,p,t,n){if(p===g||t===g||p===t)throw new c("Provide two different ERC-20 tokens; use WETH for native ETH.");let r=s.clientFor(f),i=await r.getBlockNumber(),a=await r.readContract({address:_,abi:F,functionName:"getPair",args:[p,t],blockNumber:i}),[e,A]=await Promise.all([q(s,p,i),q(s,t,i)]);if(a===g)return{pair:a,tokenA:e,tokenB:A,reserveA:0n,reserveB:0n,supply:0n,balance:0n,blockNumber:i};let[M,l,v,B]=await Promise.all([r.readContract({address:a,abi:N,functionName:"token0",blockNumber:i}),r.readContract({address:a,abi:N,functionName:"getReserves",blockNumber:i}),r.readContract({address:a,abi:N,functionName:"totalSupply",blockNumber:i}),r.readContract({address:a,abi:$,functionName:"balanceOf",args:[n],blockNumber:i})]),[b,o]=D(M,p)?l:[l[1],l[0]];return{pair:a,tokenA:e,tokenB:A,reserveA:b,reserveB:o,supply:v,balance:B,blockNumber:i}}var H={tokenA:{...k,description:"Address of the first ERC-20 token."},tokenB:{...k,description:"Address of the second ERC-20 token."},amountADesired:w('Desired amount of tokenA in base units; use tokenA decimals. Example: "1000000" = 1 tokenA at 6 decimals.'),amountBDesired:w('Desired amount of tokenB in base units; use tokenB decimals. Example: "1000000" = 1 tokenB at 6 decimals.'),liquidity:{description:'LP token amount in base units (18 decimals), or "all" for the wallet balance. Example: "1000000000000000000" = 1 LP token.',type:"string",pattern:"^(?:[0-9]+|all)$"},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999},amountAMin:w('Minimum amount of tokenA in base units; use tokenA decimals. Example: "1000000" = 1 tokenA at 6 decimals.'),amountBMin:w('Minimum amount of tokenB in base units; use tokenB decimals. Example: "1000000" = 1 tokenB at 6 decimals.')};function J(s){let p=async(t,n,r)=>{L(n,t==="pool"?["tokenA","tokenB"]:["tokenA","tokenB","slippageBps","amountAMin","amountBMin",...t==="add"?["amountADesired","amountBDesired"]:["liquidity"]]);let i=P(n.tokenA),a=P(n.tokenB),e=await z(s,i,a,r);if(t==="pool")return{pair:e.pair,tokenA:e.tokenA,tokenB:e.tokenB,reserveA:e.reserveA.toString(),reserveB:e.reserveB.toString(),totalSupply:e.supply.toString(),balance:e.balance.toString(),blockNumber:e.blockNumber.toString(),initialized:e.pair!==g};let A=s.clientFor(f),M=I(n.slippageBps);if(!D(await A.readContract({address:h,abi:E,functionName:"factory"}),_))throw new c("Uniswap v2 router factory differs from its pinned deployment.");let l=(await A.getBlock()).timestamp+300n,v=[],B=(o,d,m)=>{let u=o===void 0?d*BigInt(1e4-M)/10000n:y(o,m,256,!0);if(u>d||d>0n&&u===0n)throw new c(`${m} must be positive and no more than the reserve-ratio estimate.`);return u},b;if(t==="add"){let o=y(n.amountADesired,"amountADesired"),d=y(n.amountBDesired,"amountBDesired");if(e.reserveA===0n!=(e.reserveB===0n))throw new c("Uniswap v2 pair reserves are inconsistent.");let m=o,u=d;if(e.reserveA>0n&&e.reserveB>0n){let R=o*e.reserveB/e.reserveA;R<=d?u=R:m=d*e.reserveA/e.reserveB}if(m===0n||u===0n)throw new c("Liquidity amounts round to zero at the pool reserve ratio.");let x=B(n.amountAMin,m,"amountAMin"),C=B(n.amountBMin,u,"amountBMin");v.push(s.approval(i,h,o.toString(),f),s.approval(a,h,d.toString(),f)),b=U({abi:E,functionName:"addLiquidity",args:[i,a,o,d,x,C,r,l]})}else{if(e.pair===g||e.supply===0n)throw new c("No Uniswap v2 liquidity exists for this pair.");let o=n.liquidity==="all"?e.balance:y(n.liquidity,"liquidity");if(o===0n||o>e.balance)throw new c("Removal exceeds the wallet LP token balance or is zero.");let[d,m]=await Promise.all([i,a].map(C=>A.readContract({address:C,abi:$,functionName:"balanceOf",args:[e.pair]}))),u=B(n.amountAMin,o*d/e.supply,"amountAMin"),x=B(n.amountBMin,o*m/e.supply,"amountBMin");v.push(s.approval(e.pair,h,o.toString(),f)),b=U({abi:E,functionName:"removeLiquidity",args:[i,a,o,u,x,r,l]})}return v.push(s.unsignedTx({to:h,data:b,value:"0",chainId:f,description:`${t} Uniswap v2 liquidity for ${i}/${a}; recipient ${r}; deadline ${l}.`})),T(s,v,r,`${t==="add"?"Add":"Remove"} v2 liquidity. Review exact approvals, token minimums and wallet recipient. The first deposit sets the price; v2 locks MINIMUM_LIQUIDITY permanently.`)};return{tools:["pool","add","remove"].map(t=>({name:`uniswap_v2_${t}`,inputSchema:{type:"object",additionalProperties:!1,required:["tokenA","tokenB",...t==="add"?["amountADesired","amountBDesired"]:t==="remove"?["liquidity"]:[]],properties:t==="pool"?{tokenA:{...k,description:"Address of the first ERC-20 token."},tokenB:{...k,description:"Address of the second ERC-20 token."}}:H},execute:(n,r)=>p(t,n,r)}))}}export{_ as a,h as b,F as c,N as d,E as e,z as f,J as g};
@@ -1 +1 @@
1
- import{e as v,h as W,i as j,n as z}from"./JDHPMS7X.js";import{a as B,e as F,g as R}from"./ZXRIJG6H.js";import{A as D,b as C,c as O,t as X}from"./FRT6AC6M.js";import{a as H}from"./66F5ZH34.js";import{g as U}from"./NWNYJ26T.js";import{b as L}from"./TI727O2H.js";import{a as c}from"./XSD5NL7J.js";import{decodeEventLog as J,parseAbi as V,toEventSelector as Z,toHex as x}from"viem";var K=V(["function getPositionInfo(bytes32 poolId,address owner,int24 tickLower,int24 tickUpper,bytes32 salt) view returns (uint128 liquidity,uint256 feeGrowthInside0LastX128,uint256 feeGrowthInside1LastX128)","function getFeeGrowthInside(bytes32 poolId,int24 tickLower,int24 tickUpper) view returns (uint256,uint256)"]),Q=V(["function ownerOf(uint256) view returns (address)","function getPoolAndPositionInfo(uint256) view returns ((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks),uint256)"]),P=V(["function slot0() view returns (uint160,int24,uint16,uint16,uint16,uint8,bool)","function feeGrowthGlobal0X128() view returns (uint256)","function feeGrowthGlobal1X128() view returns (uint256)","function ticks(int24) view returns (uint128,int128,uint256,uint256,int56,uint160,uint32,bool)"]),$=(1n<<256n)-1n,ee=1n<<128n,A=(s,t)=>s-t&$;function G(s,t,r,n=0n){return A(s,t)*r/ee+n}function ue(s){return{tools:[{name:"uniswap_fees",inputSchema:{type:"object",additionalProperties:!1,required:["version","tokenId"],properties:{includeHistory:{type:"boolean",description:"V3 only: read the complete NFT collect/decrease event history for lifetime fees. This can require multiple RPC log windows."},version:{description:'Uniswap version: "v3" for concentrated liquidity or "v4" for PoolManager.',type:"string",enum:["v3","v4"]},tokenId:H('Identifier of the position NFT, as a decimal string. Example: "1".')}},async execute(t){if(R(t,["version","tokenId","includeHistory"]),t.includeHistory!==void 0&&typeof t.includeHistory!="boolean")throw new c("includeHistory must be a boolean.");if(t.includeHistory===!0&&t.version!=="v3")throw new c("V4 position lifetime fees need historical liquidity/fee-growth checkpoints; no verified history source is configured.");let r=B(t.tokenId,"tokenId"),n=s.clientFor(L),i=await n.getBlockNumber();if(t.version!=="v3"&&t.version!=="v4")throw new c("Provide version v3 or v4 for fee reads.");let _=await n.readContract({address:t.version==="v4"?C:v.positionManager,abi:Q,functionName:"ownerOf",args:[r],blockNumber:i}),b,m,a,d,u,w=0n,p=0n;if(t.version==="v4"){let[e,f]=await n.readContract({address:C,abi:Q,functionName:"getPoolAndPositionInfo",args:[r],blockNumber:i}),{tickLower:h,tickUpper:N}=D(f),S=X(e),[k,I]=await Promise.all([n.readContract({address:O,abi:K,functionName:"getPositionInfo",args:[S,C,h,N,x(r,{size:32})],blockNumber:i}),n.readContract({address:O,abi:K,functionName:"getFeeGrowthInside",args:[S,h,N],blockNumber:i})]);[b,m,a]=[e.currency0,e.currency1,k[0]],[d,u]=[G(I[0],k[1],a),G(I[1],k[2],a)]}else if(t.version==="v3"){let e=z(await n.readContract({address:v.positionManager,abi:W,functionName:"positions",args:[r],blockNumber:i})),f=await n.readContract({address:v.factory,abi:j,functionName:"getPool",args:[e.token0,e.token1,e.fee],blockNumber:i}),[h,N,S,k,I]=await Promise.all([n.readContract({address:f,abi:P,functionName:"slot0",blockNumber:i}),n.readContract({address:f,abi:P,functionName:"feeGrowthGlobal0X128",blockNumber:i}),n.readContract({address:f,abi:P,functionName:"feeGrowthGlobal1X128",blockNumber:i}),n.readContract({address:f,abi:P,functionName:"ticks",args:[e.tickLower],blockNumber:i}),n.readContract({address:f,abi:P,functionName:"ticks",args:[e.tickUpper],blockNumber:i})]),M=(q,E,T)=>A(A(q,h[1]>=e.tickLower?E:A(q,E)),h[1]<e.tickUpper?T:A(q,T));[b,m,a]=[e.token0,e.token1,e.liquidity],[w,p]=[e.tokensOwed0,e.tokensOwed1],[d,u]=[G(M(N,k[2],I[2]),e.feeGrowthInside0LastX128,a,e.tokensOwed0),G(M(S,k[3],I[3]),e.feeGrowthInside1LastX128,a,e.tokensOwed1)]}else throw new c('Provide version "v3" or "v4" for fee reads.');let[o,g]=await Promise.all([F(s,b,i),F(s,m,i)]),y=[{token:o,amount:d.toString()},{token:g,amount:u.toString()}],l=t.includeHistory===!0?await te(s,r,i,d,u):void 0;return{version:t.version,tokenId:r.toString(),owner:_,blockNumber:i.toString(),liquidity:a.toString(),...t.version==="v4"?{uncollected:y}:{},collectable:y,feeGrowthAccrual:[{token:o,amount:(d-w).toString()},{token:g,amount:(u-p).toString()}],tokensOwed:[{token:o,amount:w.toString()},{token:g,amount:p.toString()}],...l?{lifetimeFees:[{token:o,amount:l[0].toString()},{token:g,amount:l[1].toString()}]}:{},summary:"One-block collectable estimate, excluding gas. V3 tokensOwed may include withdrawn principal; feeGrowthAccrual excludes those stored amounts. V4 hook accounting can change actual collections. V4 current liquidity times lifetime range growth is not lifetime position earnings."}}}]}}var Y=V(["event IncreaseLiquidity(uint256 indexed tokenId,uint128 liquidity,uint256 amount0,uint256 amount1)","event DecreaseLiquidity(uint256 indexed tokenId,uint128 liquidity,uint256 amount0,uint256 amount1)","event Collect(uint256 indexed tokenId,address recipient,uint256 amount0,uint256 amount1)"]);async function te(s,t,r,n,i){let _=s.clientFor(L),b=Y.map(o=>Z(o)),m=0n,a=0n,d=0n,u=0n,w=0;for(let o=0n;o<=r;o+=10000000n){let g=o+9999999n<r?o+9999999n:r,y=await _.request({method:"eth_getLogs",params:[{address:v.positionManager,topics:[b,x(t,{size:32})],fromBlock:x(o),toBlock:x(g)}]});if(!Array.isArray(y))throw new c("V3 lifetime fee history is unavailable; do not treat missing history as zero earnings.");for(let l of y){if(!U(l.address,v.positionManager))throw new c("Unexpected contract in v3 lifetime fee history.");let e=J({abi:Y,data:l.data,topics:l.topics});if(e.args.tokenId!==t)throw new c("Unexpected NFT in v3 fee history.");e.eventName==="Collect"?(m+=e.args.amount0,a+=e.args.amount1):e.eventName==="DecreaseLiquidity"?(d+=e.args.amount0,u+=e.args.amount1):w++}}if(w===0)throw new c("V3 mint/increase history is missing for this existing NFT; lifetime earnings are unknown.");let p=[m+n-d,a+i-u];if(p.some(o=>o<0n))throw new c("V3 fee history is incomplete or inconsistent; lifetime earnings are unknown.");return p}export{K as a,A as b,G as c,ue as d};
1
+ import{e as v,h as W,i as j,n as z}from"./5DWQUEBA.js";import{a as B,e as F,g as R}from"./QP2B7AYX.js";import{A as D,b as C,c as O,t as X}from"./5677LZOV.js";import{a as H}from"./66F5ZH34.js";import{g as U}from"./NWNYJ26T.js";import{b as L}from"./EWZFZUVF.js";import{a as c}from"./XSD5NL7J.js";import{decodeEventLog as J,parseAbi as V,toEventSelector as Z,toHex as x}from"viem";var K=V(["function getPositionInfo(bytes32 poolId,address owner,int24 tickLower,int24 tickUpper,bytes32 salt) view returns (uint128 liquidity,uint256 feeGrowthInside0LastX128,uint256 feeGrowthInside1LastX128)","function getFeeGrowthInside(bytes32 poolId,int24 tickLower,int24 tickUpper) view returns (uint256,uint256)"]),Q=V(["function ownerOf(uint256) view returns (address)","function getPoolAndPositionInfo(uint256) view returns ((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks),uint256)"]),P=V(["function slot0() view returns (uint160,int24,uint16,uint16,uint16,uint8,bool)","function feeGrowthGlobal0X128() view returns (uint256)","function feeGrowthGlobal1X128() view returns (uint256)","function ticks(int24) view returns (uint128,int128,uint256,uint256,int56,uint160,uint32,bool)"]),$=(1n<<256n)-1n,ee=1n<<128n,A=(s,t)=>s-t&$;function G(s,t,r,n=0n){return A(s,t)*r/ee+n}function ue(s){return{tools:[{name:"uniswap_fees",inputSchema:{type:"object",additionalProperties:!1,required:["version","tokenId"],properties:{includeHistory:{type:"boolean",description:"V3 only: read the complete NFT collect/decrease event history for lifetime fees. This can require multiple RPC log windows."},version:{description:'Uniswap version: "v3" for concentrated liquidity or "v4" for PoolManager.',type:"string",enum:["v3","v4"]},tokenId:H('Identifier of the position NFT, as a decimal string. Example: "1".')}},async execute(t){if(R(t,["version","tokenId","includeHistory"]),t.includeHistory!==void 0&&typeof t.includeHistory!="boolean")throw new c("includeHistory must be a boolean.");if(t.includeHistory===!0&&t.version!=="v3")throw new c("V4 position lifetime fees need historical liquidity/fee-growth checkpoints; no verified history source is configured.");let r=B(t.tokenId,"tokenId"),n=s.clientFor(L),i=await n.getBlockNumber();if(t.version!=="v3"&&t.version!=="v4")throw new c("Provide version v3 or v4 for fee reads.");let _=await n.readContract({address:t.version==="v4"?C:v.positionManager,abi:Q,functionName:"ownerOf",args:[r],blockNumber:i}),b,m,a,d,u,w=0n,p=0n;if(t.version==="v4"){let[e,f]=await n.readContract({address:C,abi:Q,functionName:"getPoolAndPositionInfo",args:[r],blockNumber:i}),{tickLower:h,tickUpper:N}=D(f),S=X(e),[k,I]=await Promise.all([n.readContract({address:O,abi:K,functionName:"getPositionInfo",args:[S,C,h,N,x(r,{size:32})],blockNumber:i}),n.readContract({address:O,abi:K,functionName:"getFeeGrowthInside",args:[S,h,N],blockNumber:i})]);[b,m,a]=[e.currency0,e.currency1,k[0]],[d,u]=[G(I[0],k[1],a),G(I[1],k[2],a)]}else if(t.version==="v3"){let e=z(await n.readContract({address:v.positionManager,abi:W,functionName:"positions",args:[r],blockNumber:i})),f=await n.readContract({address:v.factory,abi:j,functionName:"getPool",args:[e.token0,e.token1,e.fee],blockNumber:i}),[h,N,S,k,I]=await Promise.all([n.readContract({address:f,abi:P,functionName:"slot0",blockNumber:i}),n.readContract({address:f,abi:P,functionName:"feeGrowthGlobal0X128",blockNumber:i}),n.readContract({address:f,abi:P,functionName:"feeGrowthGlobal1X128",blockNumber:i}),n.readContract({address:f,abi:P,functionName:"ticks",args:[e.tickLower],blockNumber:i}),n.readContract({address:f,abi:P,functionName:"ticks",args:[e.tickUpper],blockNumber:i})]),M=(q,E,T)=>A(A(q,h[1]>=e.tickLower?E:A(q,E)),h[1]<e.tickUpper?T:A(q,T));[b,m,a]=[e.token0,e.token1,e.liquidity],[w,p]=[e.tokensOwed0,e.tokensOwed1],[d,u]=[G(M(N,k[2],I[2]),e.feeGrowthInside0LastX128,a,e.tokensOwed0),G(M(S,k[3],I[3]),e.feeGrowthInside1LastX128,a,e.tokensOwed1)]}else throw new c('Provide version "v3" or "v4" for fee reads.');let[o,g]=await Promise.all([F(s,b,i),F(s,m,i)]),y=[{token:o,amount:d.toString()},{token:g,amount:u.toString()}],l=t.includeHistory===!0?await te(s,r,i,d,u):void 0;return{version:t.version,tokenId:r.toString(),owner:_,blockNumber:i.toString(),liquidity:a.toString(),...t.version==="v4"?{uncollected:y}:{},collectable:y,feeGrowthAccrual:[{token:o,amount:(d-w).toString()},{token:g,amount:(u-p).toString()}],tokensOwed:[{token:o,amount:w.toString()},{token:g,amount:p.toString()}],...l?{lifetimeFees:[{token:o,amount:l[0].toString()},{token:g,amount:l[1].toString()}]}:{},summary:"One-block collectable estimate, excluding gas. V3 tokensOwed may include withdrawn principal; feeGrowthAccrual excludes those stored amounts. V4 hook accounting can change actual collections. V4 current liquidity times lifetime range growth is not lifetime position earnings."}}}]}}var Y=V(["event IncreaseLiquidity(uint256 indexed tokenId,uint128 liquidity,uint256 amount0,uint256 amount1)","event DecreaseLiquidity(uint256 indexed tokenId,uint128 liquidity,uint256 amount0,uint256 amount1)","event Collect(uint256 indexed tokenId,address recipient,uint256 amount0,uint256 amount1)"]);async function te(s,t,r,n,i){let _=s.clientFor(L),b=Y.map(o=>Z(o)),m=0n,a=0n,d=0n,u=0n,w=0;for(let o=0n;o<=r;o+=10000000n){let g=o+9999999n<r?o+9999999n:r,y=await _.request({method:"eth_getLogs",params:[{address:v.positionManager,topics:[b,x(t,{size:32})],fromBlock:x(o),toBlock:x(g)}]});if(!Array.isArray(y))throw new c("V3 lifetime fee history is unavailable; do not treat missing history as zero earnings.");for(let l of y){if(!U(l.address,v.positionManager))throw new c("Unexpected contract in v3 lifetime fee history.");let e=J({abi:Y,data:l.data,topics:l.topics});if(e.args.tokenId!==t)throw new c("Unexpected NFT in v3 fee history.");e.eventName==="Collect"?(m+=e.args.amount0,a+=e.args.amount1):e.eventName==="DecreaseLiquidity"?(d+=e.args.amount0,u+=e.args.amount1):w++}}if(w===0)throw new c("V3 mint/increase history is missing for this existing NFT; lifetime earnings are unknown.");let p=[m+n-d,a+i-u];if(p.some(o=>o<0n))throw new c("V3 fee history is incomplete or inconsistent; lifetime earnings are unknown.");return p}export{K as a,A as b,G as c,ue as d};
@@ -0,0 +1 @@
1
+ import{b as j,d as H,f as O}from"./LD3A2KLN.js";import{g as P}from"./3RGED2KO.js";import{b as A,j as S}from"./EWZFZUVF.js";import{a as g}from"./XSD5NL7J.js";import{encodeFunctionData as B,formatEther as D,getAddress as k,parseAbi as h,zeroAddress as R}from"viem";var I=k(S[4663].hookr.HookrLimitOrders.address),_=["0x522723A7a09684515881568Ab8247f3846D66F43","0xfb3c1501c727f30883cd7B36Ec380381af7412Ef"].map(f=>k(f)),W=[h(["function tokenizations(address token) view returns ((address creator,address forwarder,bytes32 marketFamilyId,uint64 createdAt))"]),h(["function tokenizations(address token) view returns ((address creator,uint8 way,address forwarder,address adapter,address door,bytes32 familyId,bytes32 marketFamilyId,uint64 unlockBlock,uint16 legBps))"])],x=h(["function getOrder(uint256 orderId) view returns (((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) key,address owner,uint40 createdAt,uint40 expiry,bool zeroForOne,uint8 status,address recipient,uint128 amountIn,uint128 minAmountOut,uint128 bounty,uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable,uint256 amountOut)","function fill(uint256 orderId) returns (uint256 amountOut)"]),G=h(["function sync() returns (uint256 tip)"]);function U(f){return{name:"hookr_jobs",inputSchema:{type:"object",properties:{},additionalProperties:!1,description:"Find currently profitable Hookr fill and revenue sync jobs. Coverage is bounded and reported."},async execute($,v){if(f.network==="testnet")throw new g("Hookr jobs require Robinhood Chain 4663.");if(Object.keys($).length)throw new g("Hookr jobs takes no arguments.");let l=f.clientFor(A),n=await l.getBlock();if(typeof n.number!="bigint"||typeof n.timestamp!="bigint"||!n.hash)throw new g("Hookr jobs need a valid named chain block. Coverage is unknown.");let y=[],b=[],E=async(o,e,t,r,d)=>{let a,s=new Set,i=new Set;for(let c=0;c<2;c++)try{let u=await P(f,o,{limit:t,...a?{cursor:a}:{}});if(u.status!=="ready"||!Array.isArray(u[e])||u[e].length>t||!("nextCursor"in u))throw new Error("Invalid page");for(let p of u[e]){if(!p||typeof p!="object"||Array.isArray(p)){b.push(`${e}: malformed candidate`);continue}let w=p,F=e==="orders"?w.id??w.orderId:w.address;if(typeof F=="string"){let N=F.toLowerCase();if(i.has(N))continue;i.add(N)}try{await d(w)}catch{b.push(`${e}: candidate could not be checked`)}}let m=u.nextCursor;if(m===null)return;if(typeof m!="string"||!r.test(m)||s.has(m))throw new Error("Invalid cursor");s.add(m),a=m}catch{b.push(`${e}: discovery unavailable or malformed`);return}b.push(`${e}: scan limit reached; more candidates unknown`)},C=async(o,e,t,r=0n)=>{let d=await l.estimateGas({account:v,to:o,data:e,value:0n,blockNumber:n.number});if(typeof d!="bigint"||d<=0n)throw new Error("Gas unavailable");let a=H(d,r),s=n.baseFeePerGas,i=await l.estimateMaxPriorityFeePerGas();if(typeof s!="bigint"||s<0n||typeof i!="bigint"||i<0n||s*2n+i<=0n)throw new Error("Network fee data unavailable");let c=s*2n+i,u=a*c;return{gasLimit:a.toString(),maxFeePerGas:c.toString(),gasCostWei:u.toString(),gasCostEth:D(u),netWei:(t-u).toString()}};if(await E("hookr_open_orders","orders",5,/^[1-9][0-9]{0,19}$/,async o=>{if(o={...o,id:o.id??o.orderId},typeof o.id!="string"||!/^[1-9][0-9]{0,19}$/.test(o.id))throw new Error("Invalid id");let e=BigInt(o.id),[t,r]=await Promise.all([l.readContract({address:I,abi:x,functionName:"getOrder",args:[e],blockNumber:n.number}),l.readContract({address:I,abi:x,functionName:"quoteFill",args:[e],blockNumber:n.number})]);if(!t||typeof t!="object"||typeof t.bounty!="bigint"||typeof t.minAmountOut!="bigint"||typeof t.amountIn!="bigint"||!t.key||typeof t.owner!="string"||typeof t.recipient!="string"||typeof t.zeroForOne!="boolean"||typeof t.expiry!="number"&&typeof t.expiry!="bigint"||typeof n.timestamp!="bigint"||!Array.isArray(r)||typeof r[0]!="boolean"||typeof r[1]!="bigint")throw new Error("Invalid order");if(Number(t.status)!==1||BigInt(t.expiry)<n.timestamp||!r[0]||r[1]<=0n||r[1]<t.minAmountOut||t.amountIn<=0n||t.minAmountOut<=0n||t.bounty===0n)return;let d=B({abi:x,functionName:"fill",args:[e]}),a=await O(f,e,n.number),s=await C(I,d,t.bounty,a);BigInt(s.netWei)>0n&&y.push({type:"fill",orderId:o.id,rewardWei:t.bounty.toString(),...s,action:"hookr_fill",note:"Bounty accrues on a successful fill; later claim gas is excluded from this net."})}),await E("hookr_revenue_tokens","tokens",50,/^(?:v1|v1:[1-9][0-9]{0,19}|v2:[1-9][0-9]{0,19})$/,async o=>{if(typeof o.address!="string")throw new Error("Invalid token");let e=k(o.address),t=!1;for(let i=0;i<_.length;i++){let c=await l.readContract({address:_[i],abi:W[i],functionName:"tokenizations",args:[e],blockNumber:n.number});if(!c||typeof c.creator!="string"||i===0&&typeof c.createdAt!="bigint")throw new Error("Invalid record");if(k(c.creator)!==R&&(i!==0||c.createdAt>0n)){t=!0;break}}if(!t)throw new Error("Unregistered");let r=await l.simulateContract({address:e,abi:G,functionName:"sync",account:v,blockNumber:n.number});if(typeof r.result!="bigint"||r.result<0n)throw new Error("Invalid tip");if(r.result===0n)return;let d=B({abi:G,functionName:"sync"}),a=null;try{a=(await j(l,e,v,d,n.number)).pendingPull.toString()}catch{}let s=await C(e,d,r.result);BigInt(s.netWei)>0n&&y.push({type:"sync",token:e,rewardWei:r.result.toString(),pendingPull:a??"unknown",...s,action:"hookr_revenue_action"})}),(await l.getBlock({blockNumber:n.number})).hash!==n.hash)throw new g("Hookr job block changed; retry the complete read.");let z=b.length?"partial: some jobs are unknown":y.length?"paying jobs found":"nothing pays right now";return{chainId:A,blockNumber:n.number.toString(),status:z,jobs:y,unknown:b,relay:"relay: no public list",notice:"Paid only on success; someone may get there first. Net uses the signed gas ceiling: buffered gas limit times (2 times base fee plus priority fee). Candidate coverage comes from Hookr\u2019s directory, with at most two pages per family; this is not an exhaustive chain-wide search."}}}}export{U as a};
@@ -1 +1 @@
1
- import{e as y,g as a,i as l,l as h,m as A,n as g}from"./NWNYJ26T.js";import{b as f,j as k}from"./TI727O2H.js";import{a as s}from"./XSD5NL7J.js";import{encodeAbiParameters as S,keccak256 as I,parseAbi as _,parseAbiParameters as P}from"viem";var u=k[f].clanker,O={type:"string",pattern:"^\\d+$"},$={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},R=_(["function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))","function tokenRewards(address) view returns ((address token,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,uint256 positionId,uint256 numPositions,uint16[] rewardBps,address[] rewardAdmins,address[] rewardRecipients))","function feePreferences(address,uint256) view returns (uint8)","function updateRewardRecipient(address,uint256,address)","function updateRewardAdmin(address,uint256,address)","function updateFeePreference(address,uint256,uint8)"]),x="Provide a valid nonzero address.";function c(e,o=!1){let r=l(e,x);return o?r:h(r,x)}function F(e){return g(e,"Amount exceeds uint256.")}function w(e,o,r){if(typeof e!="number"||!Number.isSafeInteger(e)||e<o||e>r)throw new s(`Choose an integer from ${o} to ${r}.`);return e}function H(e,o){let r=Object.keys(e).find(n=>!o.includes(n));if(r)throw new s(`Unsupported Clanker input: ${r}.`)}function T(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new s("Provide bytes32 hexadecimal data.");return e}function b(e){return A(e,"Clanker returned an invalid amount.").toString()}async function v(e,o){let r=await e.clientFor(f).readContract({address:u.factory.address,abi:R,functionName:"tokenDeploymentInfo",args:[o]});if(!Array.isArray(r)||r.length!==4||typeof r[0]!="string"||!a(r[0],o)||!Array.isArray(r[3]))throw new s("The pinned factory did not identify this Clanker token.");let n=c(r[1]),d=c(r[2]);if(![u.locker.address,u.legacy_locker_v1.address].some(t=>a(t,d))||![u.fee_static_hook_v2.address,u.fee_dynamic_hook_v2.address].some(t=>a(t,n)))throw new s("This Clanker locker or hook has not been verified by Oak.");return{hook:n,locker:d,extensions:r[3].map(t=>c(t))}}async function K(e,o){let r=await v(e,o),n=await e.clientFor(f).readContract({address:r.locker,abi:R,functionName:"tokenRewards",args:[o]});if(!y(n)||typeof n.token!="string"||!a(n.token,o)||!y(n.poolKey)||!Array.isArray(n.rewardBps)||!Array.isArray(n.rewardAdmins)||!Array.isArray(n.rewardRecipients))throw new s("Clanker returned invalid reward configuration.");let d=n.poolKey,t={currency0:c(d.currency0),currency1:c(d.currency1),fee:w(d.fee,0,16777215),tickSpacing:w(d.tickSpacing,1,32767),hooks:c(d.hooks)};if(BigInt(t.currency0)>=BigInt(t.currency1)||!a(t.hooks,r.hook)||![t.currency0,t.currency1].some(i=>a(i,o)))throw new s("Clanker returned a mismatched pool key.");let p=n.rewardBps.length;if(!p||p>7||p!==n.rewardAdmins.length||p!==n.rewardRecipients.length)throw new s("Clanker returned mismatched rewards.");let m=n.rewardBps.map(i=>w(i,1,1e4));if(m.reduce((i,C)=>i+C,0)!==1e4)throw new s("Clanker returned invalid reward splits.");return{...r,poolKey:t,poolId:I(S(P("address,address,uint24,int24,address"),[t.currency0,t.currency1,t.fee,t.tickSpacing,t.hooks])),positionId:b(n.positionId),numPositions:b(n.numPositions),rewardBps:m,rewardAdmins:n.rewardAdmins.map(i=>c(i)),rewardRecipients:n.rewardRecipients.map(i=>c(i)),pairedToken:a(t.currency0,o)?t.currency1:t.currency0}}export{u as a,O as b,$ as c,R as d,x as e,c as f,F as g,w as h,H as i,T as j,b as k,v as l,K as m};
1
+ import{e as y,g as a,i as l,l as h,m as A,n as g}from"./NWNYJ26T.js";import{b as f,j as k}from"./EWZFZUVF.js";import{a as s}from"./XSD5NL7J.js";import{encodeAbiParameters as S,keccak256 as I,parseAbi as _,parseAbiParameters as P}from"viem";var u=k[f].clanker,O={type:"string",pattern:"^\\d+$"},$={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},R=_(["function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))","function tokenRewards(address) view returns ((address token,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,uint256 positionId,uint256 numPositions,uint16[] rewardBps,address[] rewardAdmins,address[] rewardRecipients))","function feePreferences(address,uint256) view returns (uint8)","function updateRewardRecipient(address,uint256,address)","function updateRewardAdmin(address,uint256,address)","function updateFeePreference(address,uint256,uint8)"]),x="Provide a valid nonzero address.";function c(e,o=!1){let r=l(e,x);return o?r:h(r,x)}function F(e){return g(e,"Amount exceeds uint256.")}function w(e,o,r){if(typeof e!="number"||!Number.isSafeInteger(e)||e<o||e>r)throw new s(`Choose an integer from ${o} to ${r}.`);return e}function H(e,o){let r=Object.keys(e).find(n=>!o.includes(n));if(r)throw new s(`Unsupported Clanker input: ${r}.`)}function T(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new s("Provide bytes32 hexadecimal data.");return e}function b(e){return A(e,"Clanker returned an invalid amount.").toString()}async function v(e,o){let r=await e.clientFor(f).readContract({address:u.factory.address,abi:R,functionName:"tokenDeploymentInfo",args:[o]});if(!Array.isArray(r)||r.length!==4||typeof r[0]!="string"||!a(r[0],o)||!Array.isArray(r[3]))throw new s("The pinned factory did not identify this Clanker token.");let n=c(r[1]),d=c(r[2]);if(![u.locker.address,u.legacy_locker_v1.address].some(t=>a(t,d))||![u.fee_static_hook_v2.address,u.fee_dynamic_hook_v2.address].some(t=>a(t,n)))throw new s("This Clanker locker or hook has not been verified by Oak.");return{hook:n,locker:d,extensions:r[3].map(t=>c(t))}}async function K(e,o){let r=await v(e,o),n=await e.clientFor(f).readContract({address:r.locker,abi:R,functionName:"tokenRewards",args:[o]});if(!y(n)||typeof n.token!="string"||!a(n.token,o)||!y(n.poolKey)||!Array.isArray(n.rewardBps)||!Array.isArray(n.rewardAdmins)||!Array.isArray(n.rewardRecipients))throw new s("Clanker returned invalid reward configuration.");let d=n.poolKey,t={currency0:c(d.currency0),currency1:c(d.currency1),fee:w(d.fee,0,16777215),tickSpacing:w(d.tickSpacing,1,32767),hooks:c(d.hooks)};if(BigInt(t.currency0)>=BigInt(t.currency1)||!a(t.hooks,r.hook)||![t.currency0,t.currency1].some(i=>a(i,o)))throw new s("Clanker returned a mismatched pool key.");let p=n.rewardBps.length;if(!p||p>7||p!==n.rewardAdmins.length||p!==n.rewardRecipients.length)throw new s("Clanker returned mismatched rewards.");let m=n.rewardBps.map(i=>w(i,1,1e4));if(m.reduce((i,C)=>i+C,0)!==1e4)throw new s("Clanker returned invalid reward splits.");return{...r,poolKey:t,poolId:I(S(P("address,address,uint24,int24,address"),[t.currency0,t.currency1,t.fee,t.tickSpacing,t.hooks])),positionId:b(n.positionId),numPositions:b(n.numPositions),rewardBps:m,rewardAdmins:n.rewardAdmins.map(i=>c(i)),rewardRecipients:n.rewardRecipients.map(i=>c(i)),pairedToken:a(t.currency0,o)?t.currency1:t.currency0}}export{u as a,O as b,$ as c,R as d,x as e,c as f,F as g,w as h,H as i,T as j,b as k,v as l,K as m};
@@ -1 +1 @@
1
- import{a}from"./O2J5I4VA.js";import{a as I}from"./FXOFR432.js";import{a as w}from"./XSD5NL7J.js";import{a as v}from"./JXOEJPJ4.js";import{isAddress as P,isHex as E,parseAbi as U}from"viem";var x=86400;function H(n){return Math.round((n+Number.EPSILON)*10)/10}function W(n,t,b,l,d,i=Math.floor(Date.now()/1e3)){let u=n.policy,f=(b.length>=1&&u.guardianThreshold>=1?12:0)+(u.timelock>=3600?10:0)+(u.ownerApprovalRequired||u.guardianThreshold>=2?4:0)+(t.length?4:0),p=n.checkpointCount===0n?0:Math.min(30,H(30*Math.log10(Number(n.checkpointCount)+1)/Math.log10(101))),m=n.status!==0||n.checkpointCount===0n||!d?0:i-Number(d.timestamp)<=x?20:i-Number(d.timestamp)<=7*x?12:i-Number(d.timestamp)<=30*x?6:0,r=l?Math.min(20,H(20*Math.max(0,i-Number(l.timestamp))/(30*x))):0,h=Math.round(f+p+m+r);return{total:h,grade:h>=80?"A":h>=60?"B":h>=40?"C":"D",breakdown:{recoveryProtection:{points:f,max:30},checkpointHistory:{points:Math.round(p),rawPoints:p,max:30},activity:{points:m,max:20},timeOnChain:{points:Math.round(r),rawPoints:r,max:20}},note:I}}function R(n){let t=v(n.slice(0,4096)),b,l=/^data:application\/json;base64,([A-Za-z0-9+/]*={0,2})$/.exec(n.slice(0,5500));if(l)try{let i=atob(l[1]);if(i.length<=4096){let u=JSON.parse(new TextDecoder().decode(Uint8Array.from(i,f=>f.charCodeAt(0))));u&&typeof u=="object"&&!Array.isArray(u)&&(b=u)}}catch{}let d=i=>typeof b?.[i]=="string"?v(b[i]):void 0;return{rawUri:t,name:d("name"),agentType:d("agentType"),description:d("description")}}function q(n){if(n===void 0)return 20;if(!Number.isSafeInteger(n)||Number(n)<1||Number(n)>50)throw new w("Explorer limit must be an integer from 1 to 50.");return Number(n)}var c=U(["function workflowCount() view returns (uint256)","function getWorkflow(uint256) view returns ((address owner,address pendingOwner,uint8 status,(uint8 guardianThreshold,bool ownerApprovalRequired,uint32 ownerFallbackDelay,uint32 timelock,uint32 approvalWindow,uint32 executionWindow) policy,uint64 checkpointCount,uint64 headSequence,bytes32 headHash,uint256 activeProposalId,string metadataURI))","function getExecutors(uint256) view returns (address[])","function getGuardians(uint256) view returns (address[])","function getCheckpoint(uint256,uint64) view returns ((bytes32 checkpointHash,bytes32 parentHash,uint64 parentSequence,bytes32 stateHash,bytes32 traceHash,bytes32 dataURIHash,address submitter,uint64 timestamp))","function getCheckpoints(uint256,uint64,uint256) view returns ((bytes32 checkpointHash,bytes32 parentHash,uint64 parentSequence,bytes32 stateHash,bytes32 traceHash,bytes32 dataURIHash,address submitter,uint64 timestamp)[])","function getCheckpointById(bytes32) view returns (uint256 workflowId,uint64 sequence,(bytes32 checkpointHash,bytes32 parentHash,uint64 parentSequence,bytes32 stateHash,bytes32 traceHash,bytes32 dataURIHash,address submitter,uint64 timestamp) checkpoint)","function activeProposalId(uint256) view returns (uint256)","function proposalCount(uint256) view returns (uint256)","function rollbackCount(uint256) view returns (uint256)","function recoveryOutcomeCount(uint256) view returns (uint256)","function getRollbackRecords(uint256,uint256,uint256) view returns ((uint256 proposalId,uint64 fromSequence,uint64 toSequence,uint64 executedAt)[])","function getRecoveryOutcomes(uint256,uint256,uint256) view returns ((bytes32 recoveryId,uint64 checkpointSequence,uint8 outcome,bytes32 resultHash,address recorder,uint64 recordedAt)[])"]);function T(n){if(n===void 0)return a.defaultCheckpointLimit;if(!Number.isInteger(n)||Number(n)<1||Number(n)>a.maxCheckpointLimit)throw new w("Checkpoint limit must be an integer from 1 to 25.");return Number(n)}async function D(n,t){if([t.workflowId!==void 0,t.address!==void 0,t.checkpointHash!==void 0].filter(Boolean).length>1)throw new w("Choose one Upoch selector: workflowId, address, or checkpointHash.");if(await n.getChainId()!==a.chainId)throw new w("Upoch reads require Robinhood Chain 4663.");if(t.checkpointHash!==void 0){if(typeof t.checkpointHash!="string"||!E(t.checkpointHash,{strict:!0})||t.checkpointHash.length!==66)throw new w("Provide a 32-byte Upoch checkpoint hash.");let[r]=await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:[{address:a.epoch,abi:c,functionName:"getCheckpointById",args:[t.checkpointHash]}]});return{workflowId:r[0],selectedCheckpoint:r[2],matchingWorkflowIds:[r[0]],workflowScanTruncated:!1}}if(t.workflowId!==void 0){if(!Number.isSafeInteger(t.workflowId)||Number(t.workflowId)<1)throw new w("Workflow IDs are positive 1-indexed integers.");let r=BigInt(Number(t.workflowId));return{workflowId:r,matchingWorkflowIds:[r],workflowScanTruncated:!1}}let l=t.address===void 0?t.wallet:t.address;if(typeof l!="string"||!P(l))throw new w("Provide a valid Upoch owner, executor, or guardian address.");let[d]=await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:[{address:a.epoch,abi:c,functionName:"workflowCount"}]}),i=Number(d);if(!Number.isSafeInteger(i)||i<0)throw new w("Epoch returned an invalid workflow count.");let u=Math.min(i,a.maxWorkflows);if(!u)throw new w("No Upoch workflow matched this address.");let f=Array.from({length:u},(r,h)=>h+1).flatMap(r=>[{address:a.epoch,abi:c,functionName:"getWorkflow",args:[BigInt(r)]},{address:a.epoch,abi:c,functionName:"getExecutors",args:[BigInt(r)]},{address:a.epoch,abi:c,functionName:"getGuardians",args:[BigInt(r)]}]),p=await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:f}),m=[];for(let r=0;r<u;r++){let h=p[r*3],g=p[r*3+1],o=p[r*3+2];[h.owner,...g,...o].some(y=>y.toLowerCase()===l.toLowerCase())&&m.push(BigInt(r+1))}if(!m.length)throw new w(`No Upoch workflow matched address ${l}${i>u?" within the first 100 workflows":""}.`);return{workflowId:m[m.length-1],matchingWorkflowIds:m,workflowScanTruncated:i>u}}async function L(n,t,b,l,d={}){let i=T(b),[u,f,p,m,r,h,g]=await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:[{address:a.epoch,abi:c,functionName:"getWorkflow",args:[t]},{address:a.epoch,abi:c,functionName:"getExecutors",args:[t]},{address:a.epoch,abi:c,functionName:"getGuardians",args:[t]},{address:a.epoch,abi:c,functionName:"activeProposalId",args:[t]},{address:a.epoch,abi:c,functionName:"proposalCount",args:[t]},{address:a.epoch,abi:c,functionName:"rollbackCount",args:[t]},{address:a.epoch,abi:c,functionName:"recoveryOutcomeCount",args:[t]}]}),o=u,y=o.checkpointCount>0n?[{address:a.epoch,abi:c,functionName:"getCheckpoint",args:[t,0n]},{address:a.epoch,abi:c,functionName:"getCheckpoints",args:[t,o.checkpointCount>BigInt(i)?o.checkpointCount-BigInt(i):0n,BigInt(i)]}]:[],S=[...h>0n?[{address:a.epoch,abi:c,functionName:"getRollbackRecords",args:[t,h>5n?h-5n:0n,5n]}]:[],...g>0n?[{address:a.epoch,abi:c,functionName:"getRecoveryOutcomes",args:[t,g>5n?g-5n:0n,5n]}]:[]],[e,s]=await Promise.all([y.length?n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:y}):Promise.resolve([]),S.length?n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:S}):Promise.resolve([])]),k=e[0],A=e[1]??[];return{workflowId:t.toString(),status:o.status===0?"Active":o.status===1?"Paused":"unknown",owner:o.owner,pendingOwner:o.pendingOwner,executors:f,guardians:p,policy:{guardianThreshold:o.policy.guardianThreshold,ownerApprovalRequired:o.policy.ownerApprovalRequired,ownerFallbackDelaySeconds:o.policy.ownerFallbackDelay,timelockSeconds:o.policy.timelock,approvalWindowSeconds:o.policy.approvalWindow,executionWindowSeconds:o.policy.executionWindow},metadata:R(o.metadataURI),metadataTruncated:o.metadataURI.length>4096,upochScore:W(o,f,p,k,A[A.length-1]??k),checkpoints:{total:o.checkpointCount.toString(),headSequence:o.checkpointCount>0n?o.headSequence.toString():null,headHash:o.checkpointCount>0n?o.headHash:null,firstCheckpointAt:k?k.timestamp.toString():null,recent:A.map(C=>({...C,timestamp:C.timestamp.toString()})),selected:l?{...l,timestamp:l.timestamp.toString()}:void 0},recovery:{activeProposalId:m>0n?m.toString():null,proposalCount:r.toString(),rollbackCount:h.toString(),recoveryOutcomeCount:g.toString(),recent:s},matchingWorkflowIds:(d.matchingWorkflowIds??[t]).map(C=>C.toString()),coverage:{checkpointHistory:"complete",recoveryHistory:S.length?"recent-five":"complete",workflowScan:d.workflowScanTruncated?"partial-first-100":"complete"}}}async function _(n,t={}){let b=q(t.limit);if(t.status!==void 0&&!["all","Active","Paused"].includes(String(t.status)))throw new w("Explorer status must be all, Active, or Paused.");if(await n.getChainId()!==a.chainId)throw new w("Upoch reads require Robinhood Chain 4663.");let[l]=await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:[{address:a.epoch,abi:c,functionName:"workflowCount"}]}),d=Number(l);if(!Number.isSafeInteger(d)||d<0)throw new w("Epoch returned an invalid workflow count.");let i=Math.min(d,a.maxWorkflows),u=Array.from({length:i},(e,s)=>BigInt(s+1)).flatMap(e=>[{address:a.epoch,abi:c,functionName:"getWorkflow",args:[e]},{address:a.epoch,abi:c,functionName:"getExecutors",args:[e]},{address:a.epoch,abi:c,functionName:"getGuardians",args:[e]}]),f=u.length?await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:u}):[],p=Array.from({length:i},(e,s)=>({id:BigInt(s+1),workflow:f[s*3],executors:f[s*3+1],guardians:f[s*3+2]})),m=p.flatMap(({id:e,workflow:s})=>s.checkpointCount>0n?[{address:a.epoch,abi:c,functionName:"getCheckpoint",args:[e,0n]},{address:a.epoch,abi:c,functionName:"getCheckpoint",args:[e,s.headSequence]}]:[]),r=m.length?await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:m}):[],h=0,g=Math.floor(Date.now()/1e3),o=p.map(({id:e,workflow:s,executors:k,guardians:A})=>{let C=s.checkpointCount>0n?r[h++]:void 0,N=s.checkpointCount>0n?r[h++]:void 0;return{id:e,workflow:s,executors:k,guardians:A,first:C,head:N,score:W(s,k,A,C,N,g)}}).filter(e=>t.status===void 0||t.status==="all"||(t.status==="Active"?e.workflow.status===0:e.workflow.status===1));o.sort((e,s)=>s.score.total-e.score.total||Number(e.id-s.id));let y=o.reduce((e,s)=>e+(s.head&&g-Number(s.head.timestamp)<=x?1:0),0),S=o.slice(0,b).map((e,s)=>({rank:s+1,workflowId:e.id.toString(),...R(e.workflow.metadataURI),status:e.workflow.status===0?"Active":"Paused",owner:e.workflow.owner,upochScore:{total:e.score.total,grade:e.score.grade},checkpointCount:e.workflow.checkpointCount.toString(),lastCheckpointAt:e.head?.timestamp.toString()??null,guardianCount:e.guardians.length,executorCount:e.executors.length,agentUrl:`https://upoch.tech/app/agents/${e.id}`}));return{summary:{totalWorkflows:d,scannedWorkflows:i,totalCheckpoints:p.reduce((e,s)=>e+Number(s.workflow.checkpointCount),0),checkpointsLast24h:null,workflowsWithCheckpointLast24h:y,averageScore:o.length?Math.round(o.reduce((e,s)=>e+s.score.total,0)/o.length):0},agents:S,coverage:{workflows:i<d?"partial-first-100":"complete",recentCheckpointCount:"unavailable-head-only-read",statusFilter:t.status??"all"}}}export{W as a,c as b,T as c,D as d,L as e,_ as f};
1
+ import{a as I}from"./FXOFR432.js";import{a}from"./O2J5I4VA.js";import{a as w}from"./XSD5NL7J.js";import{a as v}from"./JXOEJPJ4.js";import{isAddress as P,isHex as E,parseAbi as U}from"viem";var x=86400;function H(n){return Math.round((n+Number.EPSILON)*10)/10}function W(n,t,b,l,d,i=Math.floor(Date.now()/1e3)){let u=n.policy,f=(b.length>=1&&u.guardianThreshold>=1?12:0)+(u.timelock>=3600?10:0)+(u.ownerApprovalRequired||u.guardianThreshold>=2?4:0)+(t.length?4:0),p=n.checkpointCount===0n?0:Math.min(30,H(30*Math.log10(Number(n.checkpointCount)+1)/Math.log10(101))),m=n.status!==0||n.checkpointCount===0n||!d?0:i-Number(d.timestamp)<=x?20:i-Number(d.timestamp)<=7*x?12:i-Number(d.timestamp)<=30*x?6:0,r=l?Math.min(20,H(20*Math.max(0,i-Number(l.timestamp))/(30*x))):0,h=Math.round(f+p+m+r);return{total:h,grade:h>=80?"A":h>=60?"B":h>=40?"C":"D",breakdown:{recoveryProtection:{points:f,max:30},checkpointHistory:{points:Math.round(p),rawPoints:p,max:30},activity:{points:m,max:20},timeOnChain:{points:Math.round(r),rawPoints:r,max:20}},note:I}}function R(n){let t=v(n.slice(0,4096)),b,l=/^data:application\/json;base64,([A-Za-z0-9+/]*={0,2})$/.exec(n.slice(0,5500));if(l)try{let i=atob(l[1]);if(i.length<=4096){let u=JSON.parse(new TextDecoder().decode(Uint8Array.from(i,f=>f.charCodeAt(0))));u&&typeof u=="object"&&!Array.isArray(u)&&(b=u)}}catch{}let d=i=>typeof b?.[i]=="string"?v(b[i]):void 0;return{rawUri:t,name:d("name"),agentType:d("agentType"),description:d("description")}}function q(n){if(n===void 0)return 20;if(!Number.isSafeInteger(n)||Number(n)<1||Number(n)>50)throw new w("Explorer limit must be an integer from 1 to 50.");return Number(n)}var c=U(["function workflowCount() view returns (uint256)","function getWorkflow(uint256) view returns ((address owner,address pendingOwner,uint8 status,(uint8 guardianThreshold,bool ownerApprovalRequired,uint32 ownerFallbackDelay,uint32 timelock,uint32 approvalWindow,uint32 executionWindow) policy,uint64 checkpointCount,uint64 headSequence,bytes32 headHash,uint256 activeProposalId,string metadataURI))","function getExecutors(uint256) view returns (address[])","function getGuardians(uint256) view returns (address[])","function getCheckpoint(uint256,uint64) view returns ((bytes32 checkpointHash,bytes32 parentHash,uint64 parentSequence,bytes32 stateHash,bytes32 traceHash,bytes32 dataURIHash,address submitter,uint64 timestamp))","function getCheckpoints(uint256,uint64,uint256) view returns ((bytes32 checkpointHash,bytes32 parentHash,uint64 parentSequence,bytes32 stateHash,bytes32 traceHash,bytes32 dataURIHash,address submitter,uint64 timestamp)[])","function getCheckpointById(bytes32) view returns (uint256 workflowId,uint64 sequence,(bytes32 checkpointHash,bytes32 parentHash,uint64 parentSequence,bytes32 stateHash,bytes32 traceHash,bytes32 dataURIHash,address submitter,uint64 timestamp) checkpoint)","function activeProposalId(uint256) view returns (uint256)","function proposalCount(uint256) view returns (uint256)","function rollbackCount(uint256) view returns (uint256)","function recoveryOutcomeCount(uint256) view returns (uint256)","function getRollbackRecords(uint256,uint256,uint256) view returns ((uint256 proposalId,uint64 fromSequence,uint64 toSequence,uint64 executedAt)[])","function getRecoveryOutcomes(uint256,uint256,uint256) view returns ((bytes32 recoveryId,uint64 checkpointSequence,uint8 outcome,bytes32 resultHash,address recorder,uint64 recordedAt)[])"]);function T(n){if(n===void 0)return a.defaultCheckpointLimit;if(!Number.isInteger(n)||Number(n)<1||Number(n)>a.maxCheckpointLimit)throw new w("Checkpoint limit must be an integer from 1 to 25.");return Number(n)}async function D(n,t){if([t.workflowId!==void 0,t.address!==void 0,t.checkpointHash!==void 0].filter(Boolean).length>1)throw new w("Choose one Upoch selector: workflowId, address, or checkpointHash.");if(await n.getChainId()!==a.chainId)throw new w("Upoch reads require Robinhood Chain 4663.");if(t.checkpointHash!==void 0){if(typeof t.checkpointHash!="string"||!E(t.checkpointHash,{strict:!0})||t.checkpointHash.length!==66)throw new w("Provide a 32-byte Upoch checkpoint hash.");let[r]=await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:[{address:a.epoch,abi:c,functionName:"getCheckpointById",args:[t.checkpointHash]}]});return{workflowId:r[0],selectedCheckpoint:r[2],matchingWorkflowIds:[r[0]],workflowScanTruncated:!1}}if(t.workflowId!==void 0){if(!Number.isSafeInteger(t.workflowId)||Number(t.workflowId)<1)throw new w("Workflow IDs are positive 1-indexed integers.");let r=BigInt(Number(t.workflowId));return{workflowId:r,matchingWorkflowIds:[r],workflowScanTruncated:!1}}let l=t.address===void 0?t.wallet:t.address;if(typeof l!="string"||!P(l))throw new w("Provide a valid Upoch owner, executor, or guardian address.");let[d]=await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:[{address:a.epoch,abi:c,functionName:"workflowCount"}]}),i=Number(d);if(!Number.isSafeInteger(i)||i<0)throw new w("Epoch returned an invalid workflow count.");let u=Math.min(i,a.maxWorkflows);if(!u)throw new w("No Upoch workflow matched this address.");let f=Array.from({length:u},(r,h)=>h+1).flatMap(r=>[{address:a.epoch,abi:c,functionName:"getWorkflow",args:[BigInt(r)]},{address:a.epoch,abi:c,functionName:"getExecutors",args:[BigInt(r)]},{address:a.epoch,abi:c,functionName:"getGuardians",args:[BigInt(r)]}]),p=await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:f}),m=[];for(let r=0;r<u;r++){let h=p[r*3],g=p[r*3+1],o=p[r*3+2];[h.owner,...g,...o].some(y=>y.toLowerCase()===l.toLowerCase())&&m.push(BigInt(r+1))}if(!m.length)throw new w(`No Upoch workflow matched address ${l}${i>u?" within the first 100 workflows":""}.`);return{workflowId:m[m.length-1],matchingWorkflowIds:m,workflowScanTruncated:i>u}}async function L(n,t,b,l,d={}){let i=T(b),[u,f,p,m,r,h,g]=await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:[{address:a.epoch,abi:c,functionName:"getWorkflow",args:[t]},{address:a.epoch,abi:c,functionName:"getExecutors",args:[t]},{address:a.epoch,abi:c,functionName:"getGuardians",args:[t]},{address:a.epoch,abi:c,functionName:"activeProposalId",args:[t]},{address:a.epoch,abi:c,functionName:"proposalCount",args:[t]},{address:a.epoch,abi:c,functionName:"rollbackCount",args:[t]},{address:a.epoch,abi:c,functionName:"recoveryOutcomeCount",args:[t]}]}),o=u,y=o.checkpointCount>0n?[{address:a.epoch,abi:c,functionName:"getCheckpoint",args:[t,0n]},{address:a.epoch,abi:c,functionName:"getCheckpoints",args:[t,o.checkpointCount>BigInt(i)?o.checkpointCount-BigInt(i):0n,BigInt(i)]}]:[],S=[...h>0n?[{address:a.epoch,abi:c,functionName:"getRollbackRecords",args:[t,h>5n?h-5n:0n,5n]}]:[],...g>0n?[{address:a.epoch,abi:c,functionName:"getRecoveryOutcomes",args:[t,g>5n?g-5n:0n,5n]}]:[]],[e,s]=await Promise.all([y.length?n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:y}):Promise.resolve([]),S.length?n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:S}):Promise.resolve([])]),k=e[0],A=e[1]??[];return{workflowId:t.toString(),status:o.status===0?"Active":o.status===1?"Paused":"unknown",owner:o.owner,pendingOwner:o.pendingOwner,executors:f,guardians:p,policy:{guardianThreshold:o.policy.guardianThreshold,ownerApprovalRequired:o.policy.ownerApprovalRequired,ownerFallbackDelaySeconds:o.policy.ownerFallbackDelay,timelockSeconds:o.policy.timelock,approvalWindowSeconds:o.policy.approvalWindow,executionWindowSeconds:o.policy.executionWindow},metadata:R(o.metadataURI),metadataTruncated:o.metadataURI.length>4096,upochScore:W(o,f,p,k,A[A.length-1]??k),checkpoints:{total:o.checkpointCount.toString(),headSequence:o.checkpointCount>0n?o.headSequence.toString():null,headHash:o.checkpointCount>0n?o.headHash:null,firstCheckpointAt:k?k.timestamp.toString():null,recent:A.map(C=>({...C,timestamp:C.timestamp.toString()})),selected:l?{...l,timestamp:l.timestamp.toString()}:void 0},recovery:{activeProposalId:m>0n?m.toString():null,proposalCount:r.toString(),rollbackCount:h.toString(),recoveryOutcomeCount:g.toString(),recent:s},matchingWorkflowIds:(d.matchingWorkflowIds??[t]).map(C=>C.toString()),coverage:{checkpointHistory:"complete",recoveryHistory:S.length?"recent-five":"complete",workflowScan:d.workflowScanTruncated?"partial-first-100":"complete"}}}async function _(n,t={}){let b=q(t.limit);if(t.status!==void 0&&!["all","Active","Paused"].includes(String(t.status)))throw new w("Explorer status must be all, Active, or Paused.");if(await n.getChainId()!==a.chainId)throw new w("Upoch reads require Robinhood Chain 4663.");let[l]=await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:[{address:a.epoch,abi:c,functionName:"workflowCount"}]}),d=Number(l);if(!Number.isSafeInteger(d)||d<0)throw new w("Epoch returned an invalid workflow count.");let i=Math.min(d,a.maxWorkflows),u=Array.from({length:i},(e,s)=>BigInt(s+1)).flatMap(e=>[{address:a.epoch,abi:c,functionName:"getWorkflow",args:[e]},{address:a.epoch,abi:c,functionName:"getExecutors",args:[e]},{address:a.epoch,abi:c,functionName:"getGuardians",args:[e]}]),f=u.length?await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:u}):[],p=Array.from({length:i},(e,s)=>({id:BigInt(s+1),workflow:f[s*3],executors:f[s*3+1],guardians:f[s*3+2]})),m=p.flatMap(({id:e,workflow:s})=>s.checkpointCount>0n?[{address:a.epoch,abi:c,functionName:"getCheckpoint",args:[e,0n]},{address:a.epoch,abi:c,functionName:"getCheckpoint",args:[e,s.headSequence]}]:[]),r=m.length?await n.multicall({multicallAddress:"0xcA11bde05977b3631167028862bE2a173976CA11",allowFailure:!1,batchSize:0,contracts:m}):[],h=0,g=Math.floor(Date.now()/1e3),o=p.map(({id:e,workflow:s,executors:k,guardians:A})=>{let C=s.checkpointCount>0n?r[h++]:void 0,N=s.checkpointCount>0n?r[h++]:void 0;return{id:e,workflow:s,executors:k,guardians:A,first:C,head:N,score:W(s,k,A,C,N,g)}}).filter(e=>t.status===void 0||t.status==="all"||(t.status==="Active"?e.workflow.status===0:e.workflow.status===1));o.sort((e,s)=>s.score.total-e.score.total||Number(e.id-s.id));let y=o.reduce((e,s)=>e+(s.head&&g-Number(s.head.timestamp)<=x?1:0),0),S=o.slice(0,b).map((e,s)=>({rank:s+1,workflowId:e.id.toString(),...R(e.workflow.metadataURI),status:e.workflow.status===0?"Active":"Paused",owner:e.workflow.owner,upochScore:{total:e.score.total,grade:e.score.grade},checkpointCount:e.workflow.checkpointCount.toString(),lastCheckpointAt:e.head?.timestamp.toString()??null,guardianCount:e.guardians.length,executorCount:e.executors.length,agentUrl:`https://upoch.tech/app/agents/${e.id}`}));return{summary:{totalWorkflows:d,scannedWorkflows:i,totalCheckpoints:p.reduce((e,s)=>e+Number(s.workflow.checkpointCount),0),checkpointsLast24h:null,workflowsWithCheckpointLast24h:y,averageScore:o.length?Math.round(o.reduce((e,s)=>e+s.score.total,0)/o.length):0},agents:S,coverage:{workflows:i<d?"partial-first-100":"complete",recentCheckpointCount:"unavailable-head-only-read",statusFilter:t.status??"all"}}}export{W as a,c as b,T as c,D as d,L as e,_ as f};
@@ -1 +1 @@
1
- import{b as W}from"./N624NR7Y.js";import{c as K}from"./SCG5HWMN.js";import{a as N}from"./WWYAAIE2.js";import{g as S}from"./NWNYJ26T.js";import{a as j,b as M,c as O}from"./IX3GZMTM.js";import{b as q,j as z}from"./TI727O2H.js";import{a}from"./XSD5NL7J.js";import{a as $}from"./JXOEJPJ4.js";import{encodeAbiParameters as ce,encodeFunctionData as J,erc20Abi as V,getAddress as Z,isAddress as me,keccak256 as X,parseAbi as ue,parseAbiParameters as ye,zeroAddress as ee}from"viem";var x=q,C=Z(z[x].hoodlock.airdrop.address),oe="https://hoodlock.tech",P=25e4,ge=256,fe=604800n,pe=30n,Q=250000000000000000n,Y=0xffffffffn,be=(1n<<64n)-1n,ne=(1n<<128n)-1n,re="0x0000000000000000000000000000000000000000000000000000000000000000",xe="0x1111111111111111111111111111111111111111",Ae=ye("uint256, address, uint256"),T=ue(["function quote(uint32 maxClaims) view returns (uint256)","function create(address token, bytes32 merkleRoot, uint256 total, uint32 maxClaims, uint64 endTime, string uri) payable returns (uint256 id)","function claim(uint256 id, uint256 index, address account, uint256 amount, bytes32[] proof)","function getAirdrop(uint256 id) view returns (address creator, uint64 endTime, uint32 maxClaims, address token, uint32 claims, bool swept, bytes32 merkleRoot, uint128 total, uint128 remaining)","function isClaimed(uint256 id, uint256 index) view returns (bool)"]);function he(o,e,r){let n=e.trim();if(n.startsWith("-")){let t=n.slice(1);return`-${o.formatAmount(t,r)}`}let d=n.startsWith("+")?n.slice(1):n;return o.formatAmount(d,r)}function te(o,e){if(!e.changes.length)return e.summary;let r=e.changes.map(n=>`${he(o,n.amount,n.token.decimals)} ${$(n.token.symbol)}`).join(", ");return`${e.summary} (${r})`}async function we(o,e){try{let[r,n]=await Promise.all([o.readContract({address:e,abi:V,functionName:"symbol"}),o.readContract({address:e,abi:V,functionName:"decimals"})]),d=typeof r=="string"&&r.trim()?r.trim():"TOKEN",t=Number(n);return{symbol:d,decimals:Number.isInteger(t)&&t>=0&&t<=255?t:18}}catch{return{symbol:"TOKEN",decimals:18}}}function w(o,e,r){if(typeof e=="string"&&e.includes(".")){if(r?.decimals===void 0)throw new a(`Decimal string amount "${e}" requires explicit token decimals; amount inputs are base-unit integer strings by default.`);let d=r.rounding!==void 0?O(e,r.decimals,r.rounding):o?o.parseAmount(e,r.decimals):O(e,r.decimals),t=M(d);if(t<=0n)throw new a("Airdrop entry amount must be positive.");return t}let n;try{if(typeof e=="bigint")n=e;else if(typeof e=="string")n=M(e.trim());else throw j()}catch(d){throw d instanceof a?d:new a(`Invalid airdrop amount "${String(e)}".`,{cause:d})}if(n<=0n)throw new a("Airdrop entry amount must be strictly positive (> 0).");return n}function H(o,e){try{let r=typeof o=="bigint"?o:BigInt(String(o).trim());if(r<0n)throw new a(`${e} must be non-negative.`);return r}catch(r){throw r instanceof a?r:new a(`Invalid ${e}: ${String(o)}`,{cause:r})}}function A(o,e){if(typeof o!="string"||!me(o,{strict:!1}))throw new a(`Invalid ${e} address "${String(o)}": token/account must be a valid EVM address, never a symbol.`);return Z(o)}function L(o,e,r){let n=typeof o=="bigint"?o:BigInt(o);if(n<0n||n>Y)throw new a(`Airdrop leaf index must be in 0..${Y.toString()}.`);let d=A(e,"account"),t=w(void 0,r),s=ce(Ae,[n,d,t]);return X(X(s))}function ie(o,e){let r=o;for(let n of e)r=N(r,n);return r}function Ne(o){try{let e=L(o.index,o.account,o.amount),r=ie(e,o.proof);return S(r,o.root)}catch{return!1}}function U(o,e){if(!Array.isArray(o)||o.length===0)throw new a("Airdrop entries list cannot be empty; maxClaims must be in 1..250000.");if(o.length>P)throw new a(`Airdrop entries length (${o.length}) exceeds maxClaims limit of ${P}.`);let r=[],n=0n;for(let i=0;i<o.length;i+=1){let l=o[i];if(!l)throw new a(`Missing airdrop entry at position ${i}.`);let c=l.index??i;if(!Number.isInteger(c)||c!==i)throw new a(`Airdrop entry index at position ${i} must be contiguous ${i} (got ${String(c)}).`);let u=A(l.account,`entries[${i}].account`),g=w(e?.context,l.amount,e);n+=g,r.push({index:c,account:u,amount:g.toString()})}if(n<=0n||n>ne)throw new a("Airdrop total amount must be > 0 and fit in uint128.");let d=r.map(i=>L(i.index,i.account,i.amount)),t=[d];for(;t[t.length-1].length>1;){let i=t[t.length-1],l=[];for(let c=0;c<i.length;c+=2){let u=i[c],g=i[c+1];g===void 0?l.push(u):l.push(N(u,g))}t.push(l)}let s=t[t.length-1][0];if(s.toLowerCase()===re)throw new a("Computed Merkle root cannot be zero.");let f=t.length>1?t[1]:t[0],m=r.map((i,l)=>{let c=[],u=l;for(let g=0;g<t.length-1;g+=1){let y=t[g],b=u^1;b<y.length&&c.push(y[b]),u=Math.floor(u/2)}return{index:i.index,account:i.account,amount:i.amount,leaf:d[l],proof:c}}),p={format:"openzeppelin-standard-merkle-tree-v1",leafEncoding:["uint256","address","uint256"],root:s,totalAmount:n.toString(),maxClaims:r.length,values:r.map(i=>[i.index,i.account,i.amount]),entries:r};return{root:s,leaves:d,level1:f,totalAmount:n.toString(),maxClaims:r.length,entries:r,proofs:m,list:p}}function ke(o){if(!o||!Array.isArray(o.entries)&&!Array.isArray(o.values))throw new a("Saved airdrop list is missing entries/values.");let e=Array.isArray(o.entries)&&o.entries.length>0?o.entries:o.values.map(([n,d,t])=>({index:n,account:d,amount:t})),r=U(e);if(o.root&&!S(r.root,o.root))throw new a(`Rebuilt tree root ${r.root} does not match saved list root ${o.root}.`);if(o.maxClaims!==void 0&&r.maxClaims!==o.maxClaims)throw new a(`Rebuilt maxClaims (${r.maxClaims}) does not match saved list maxClaims (${o.maxClaims}).`);if(o.totalAmount!==void 0&&r.totalAmount!==o.totalAmount)throw new a(`Rebuilt totalAmount (${r.totalAmount}) does not match saved list totalAmount (${o.totalAmount}).`);return r}async function ae(o,e){return K(o.http,e,{method:"GET"},r=>r!==null&&typeof r=="object")}async function $e(o,e,r){let n=A(e.token,"token");if(n===ee)throw new a("Airdrop token cannot be the zero address.");let d=U(e.entries,{decimals:e.decimals,rounding:e.rounding,context:o}),t=e.maxClaims??d.maxClaims;if(!Number.isInteger(t)||t<1||t>P||t!==d.maxClaims)throw new a(`maxClaims (${String(t)}) must equal entries.length (${d.maxClaims}) and be in 1..${P}.`);let s=BigInt(d.totalAmount),f=e.total!==void 0?w(o,e.total,{decimals:e.decimals,rounding:e.rounding}):s;if(f<s)throw new a(`Airdrop total (${f.toString()}) is less than the sum of entry amounts (${s.toString()}).`);if(f<=0n||f>ne)throw new a("Airdrop total must be positive and fit in uint128.");let m=e.uri??"",p=new TextEncoder().encode(m).byteLength;if(p>ge)throw new a(`Airdrop URI length (${p} bytes) exceeds 256-byte limit.`);let i=e.endTime!==void 0?H(e.endTime,"endTime"):0n;if(i>be)throw new a("endTime exceeds uint64 maximum.");let l=o.clientFor(x),c=await l.getCode({address:n});if(!c||c==="0x")throw new a(`Token ${n} has no contract code on chain ${x}.`);let u;if(i!==0n){let _=(await l.getBlock()).timestamp,B=e.inclusionMargin!==void 0?H(e.inclusionMargin,"inclusionMargin"):pe;if(B<=0n)throw new a("inclusionMargin must be at least 1 second to leave room for signing and inclusion after the already-mined block.");let D=_+B,I=e.inclusionTime!==void 0?H(e.inclusionTime,"inclusionTime"):D;if(I<D)throw new a(`inclusionTime (${I.toString()}) must be after the already-mined block (${_.toString()}) with room for signing and inclusion (>= ${D.toString()}).`);u=I;let F=I+fe;if(i<F)throw new a(`endTime (${i.toString()}) is too short (window too short): must be 0 or at least inclusion time (${I.toString()}) + 604800 (7 days >= ${F.toString()}, after already-mined block.timestamp ${_.toString()}).`)}let g=await l.readContract({address:C,abi:T,functionName:"quote",args:[t]}),y=typeof g=="bigint"?g:BigInt(String(g));if(y<0n||y>Q)throw new a(`HoodLock quote(uint32) fee (${y.toString()}) exceeds max fee cap (${Q.toString()}).`);let b=o.formatAmount(y.toString(),W.decimals),h=o.approval(n,C,f.toString(),x),k=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"create",args:[n,d.root,f,t,i,m]}),value:y.toString(),description:`Create HoodLock airdrop (${t} claims, total ${f.toString()}, quote fee ${b} ETH (${y.toString()} wei))`}),v=[h,k],E=A(e.account??r??xe,"wallet"),R=await o.preview(v,E),le=y>0n?` Quote fee: -${b} ETH (${b} ETH / ${y.toString()} wei).`:" Quote fee: 0 ETH (0 wei).",se=`${te(o,R)}${le}`;return{kind:"hoodlock_airdrop_create",chainId:x,token:n,merkleRoot:d.root,totalAmount:d.totalAmount,total:f.toString(),maxClaims:t,endTime:i,...u!==void 0?{inclusionTime:u}:{},uri:m,quoteFee:y,list:d.list,proofs:d.proofs,txs:v,preview:R,summary:se}}async function G(o,e,r,n){if(n.savedProof){let m=A(n.savedProof.account,"savedProof.account");if(m!==r)throw new a(`savedProof account (${m}) does not match claim account (${r}).`);return{index:n.savedProof.index,amount:w(o,n.savedProof.amount),proof:n.savedProof.proof}}if(n.proof!==void 0&&n.index!==void 0&&n.amount!==void 0){let m=Number(n.index);if(!Number.isInteger(m)||m<0)throw new a(`Invalid claim index: ${String(n.index)}`);return{index:m,amount:w(o,n.amount),proof:n.proof}}if(n.list||n.entries){let p=(n.list?ke(n.list):U(n.entries,{context:o})).proofs.find(i=>!(!S(i.account,r)||n.index!==void 0&&i.index!==Number(n.index)));if(!p)throw new a(`Account ${r} was not found in the saved airdrop list.`);return{index:p.index,amount:w(o,p.amount),proof:p.proof}}let d=`${oe}/api/airdrop/${e.toString()}/proof?address=${r}`,t=await ae(o,d),s=t?.data??t;if(!s||s.index===void 0||s.amount===void 0||!Array.isArray(s.proof))throw new a(`No valid proof returned from HoodLock API for airdrop ${e.toString()} and account ${r}.`);let f=Number(s.index);if(!Number.isInteger(f)||f<0)throw new a(`Invalid index in API proof: ${String(s.index)}`);return{index:f,amount:w(o,s.amount),proof:s.proof}}async function de(o,e){let r=o.clientFor(x),n=await r.readContract({address:C,abi:T,functionName:"getAirdrop",args:[e.id]}),[d,t,s,f,m,p,i,,l]=n,c=BigInt(t),u=Number(s),g=Number(m),y=BigInt(l),b=A(f,"airdrop.token");if(d===ee||i.toLowerCase()===re)throw new a(`Airdrop ${e.id.toString()} does not exist.`);if(p)throw new a(`Airdrop ${e.id.toString()} has already been swept.`);if(c>0n&&(await r.getBlock()).timestamp>=c)throw new a(`Airdrop ${e.id.toString()} expired at timestamp ${c.toString()}.`);if(g>=u)throw new a(`Airdrop ${e.id.toString()} has reached maxClaims (${u}).`);let[h,k]=await Promise.all([r.readContract({address:C,abi:T,functionName:"isClaimed",args:[e.id,BigInt(e.index)]}),we(r,b)]);if(h)throw new a(`Airdrop ${e.id.toString()} index ${e.index} has already been claimed.`);if(y<e.amount)throw new a(`Airdrop ${e.id.toString()} remaining balance (${y.toString()}) is less than claim amount (${e.amount.toString()}).`);let v=L(e.index,e.account,e.amount),E=ie(v,e.proof);if(!S(E,i))throw new a(`Computed Merkle root ${E} does not match on-chain airdrop root ${i} (bad proof).`);return{tokenAddress:b,tokenMeta:k,merkleRoot:i,leaf:v}}async function Se(o,e){let{tokenAddress:r,tokenMeta:n,merkleRoot:d,leaf:t}=await de(o,e),s=e.caller??e.account,f=!S(s,e.account),m=o.formatAmount(e.amount.toString(),n.decimals),p=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"claim",args:[e.id,BigInt(e.index),e.account,e.amount,[...e.proof]]}),value:"0",description:f?`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for recipient ${e.account} (caller ${s} pays gas only, token delta 0)`:`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for ${e.account}`}),i=[p],l=await o.preview(i,s),c,u,g=e.amount.toString(),y;if(f){let b=l.changes.filter(h=>h.amount.trim().startsWith("-"));c={...l,changes:b,summary:`${l.summary} Recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units); caller ${s} change is 0 (gas only).`},u=`Third-party claim from HoodLock airdrop #${e.id.toString()} (index ${e.index}): recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}); caller ${s} own token change is 0 (gas only). ${l.summary}`,y="0"}else c=l,u=`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}) from HoodLock airdrop #${e.id.toString()} (index ${e.index}) for recipient ${e.account}. ${te(o,c)}`,y=e.amount.toString();return{kind:"hoodlock_airdrop_claim",chainId:x,id:e.id,index:e.index,account:e.account,recipient:e.account,caller:e.caller,token:r,amount:e.amount.toString(),recipientDelta:g,senderDelta:y,leaf:t,merkleRoot:d,proof:[...e.proof],tx:p,txs:i,preview:c,summary:u}}async function Ce(o,e,r){let n=A(e.account??r??"","account"),d=e.caller!==void 0?A(e.caller,"caller"):r!==void 0?A(r,"wallet"):void 0;if(e.id!==void 0){let l=H(e.id,"id"),c=await G(o,l,n,e);return Se(o,{id:l,index:c.index,account:n,caller:d,amount:c.amount,proof:c.proof})}let t=`${oe}/api/airdrop/eligible?address=${n}`,s=await ae(o,t),f=Array.isArray(s)?s:s?.claimable??s?.eligible??s?.airdrops??s?.claims??[],m=[];for(let l of f){let c=l.id??l.airdropId;if(c!==void 0)try{let u=H(c,"eligible.id"),g,y,b;if(l.index!==void 0&&l.amount!==void 0&&Array.isArray(l.proof))g=Number(l.index),y=w(o,l.amount),b=l.proof;else{let k=await G(o,u,n,{id:u,account:n});g=k.index,y=k.amount,b=k.proof}let h=await de(o,{id:u,index:g,account:n,amount:y,proof:b});m.push({id:u.toString(),index:g,account:n,token:h.tokenAddress,amount:y.toString(),proof:[...b],merkleRoot:h.merkleRoot})}catch{continue}}let p=m.length===0?`No verified eligible HoodLock airdrops were returned by the index for ${n}. Discovery can lag after creation; this does not prove there are no claims. If you know the airdrop id, call hoodlock_airdrop_claim with id and account to resolve its list/proof and verify it on-chain.`:`Found ${m.length} eligible HoodLock airdrop(s) for ${n}: ${m.map(l=>`#${l.id}`).join(", ")}. Discovery can lag after creation. Choose an id, or pass a known new id, to hoodlock_airdrop_claim to verify and build a claim transaction.`;return{kind:"hoodlock_airdrop_eligible",chainId:x,account:n,recipient:n,caller:d,recipientDelta:"0",senderDelta:"0",eligible:m,claims:[],tx:void 0,txs:[],preview:{txs:[],changes:[],summary:p},summary:p}}var ve=o=>({tools:[{name:"hoodlock_airdrop_create",inputSchema:{type:"object",required:["token","entries"],additionalProperties:!1,properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663"},entries:{type:"array",description:"Ordered airdrop entries [{ index?, account, amount }] with base-unit integer string amounts"},total:{type:"string",description:"Optional total funded token amount as a base-unit integer string (>= sum of entries)"},maxClaims:{type:"number",description:"Optional claim count (must equal entries.length in 1..250000)"},endTime:{type:"number",description:"Unix timestamp in seconds (0 for non-sweepable or >= inclusion time + 604800)"},inclusionTime:{type:"number",description:"Optional expected transaction inclusion Unix timestamp in seconds (> already-mined block.timestamp)"},inclusionMargin:{type:"number",description:"Optional signing and inclusion margin in seconds above the already-mined block.timestamp (>= 1, default 30)"},uri:{type:"string",description:"Metadata URI (<= 256 UTF-8 bytes)"},decimals:{type:"number",description:"Optional token decimals when converting human decimal entry amounts via parseAmount"},rounding:{type:"string",enum:["floor","ceil"],description:"Optional rounding mode (floor or ceil) when converting decimal amounts"},account:{type:"string",description:"Optional creator wallet address for preview simulation"}}},execute:async(e,r)=>$e(o,e,r)},{name:"hoodlock_airdrop_claim",inputSchema:{type:"object",required:["account"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional airdrop ID (omit to query eligible airdrops)"},account:{type:"string",description:"Leaf recipient address that receives the tokens"},caller:{type:"string",description:"Optional caller/relayer address submitting the tx (pays gas only, receives 0 tokens)"},index:{type:"number",description:"Optional leaf index when supplying proof directly or selecting from list/entries"},amount:{type:"string",description:"Optional leaf amount as a base-unit integer string"},proof:{type:"array",items:{type:"string"},description:"Optional Merkle sibling proof array of 32-byte hex strings"},savedProof:{type:"object",description:"Optional saved proof item ({ index, account, amount, leaf?, proof }) from hoodlock_airdrop_create"},list:{type:"object",description:"Optional saved airdrop list ({ format, leafEncoding, root, totalAmount, maxClaims, values, entries }) to rebuild proof locally"},entries:{type:"array",description:"Optional airdrop entries array ([{ index?, account, amount }]) to rebuild proof locally"}}},execute:async(e,r)=>Ce(o,e,r)}]}),Le=ve;export{V as a,x as b,C as c,oe as d,P as e,ge as f,fe as g,pe as h,Q as i,T as j,he as k,L as l,ie as m,Ne as n,U as o,ke as p,ve as q,Le as r};
1
+ import{b as W}from"./5PNFV7HH.js";import{c as K}from"./SCG5HWMN.js";import{a as N}from"./WWYAAIE2.js";import{g as S}from"./NWNYJ26T.js";import{a as j,b as M,c as O}from"./IX3GZMTM.js";import{b as q,j as z}from"./EWZFZUVF.js";import{a}from"./XSD5NL7J.js";import{a as $}from"./JXOEJPJ4.js";import{encodeAbiParameters as ce,encodeFunctionData as J,erc20Abi as V,getAddress as Z,isAddress as me,keccak256 as X,parseAbi as ue,parseAbiParameters as ye,zeroAddress as ee}from"viem";var x=q,C=Z(z[x].hoodlock.airdrop.address),oe="https://hoodlock.tech",P=25e4,ge=256,fe=604800n,pe=30n,Q=250000000000000000n,Y=0xffffffffn,be=(1n<<64n)-1n,ne=(1n<<128n)-1n,re="0x0000000000000000000000000000000000000000000000000000000000000000",xe="0x1111111111111111111111111111111111111111",Ae=ye("uint256, address, uint256"),T=ue(["function quote(uint32 maxClaims) view returns (uint256)","function create(address token, bytes32 merkleRoot, uint256 total, uint32 maxClaims, uint64 endTime, string uri) payable returns (uint256 id)","function claim(uint256 id, uint256 index, address account, uint256 amount, bytes32[] proof)","function getAirdrop(uint256 id) view returns (address creator, uint64 endTime, uint32 maxClaims, address token, uint32 claims, bool swept, bytes32 merkleRoot, uint128 total, uint128 remaining)","function isClaimed(uint256 id, uint256 index) view returns (bool)"]);function he(o,e,r){let n=e.trim();if(n.startsWith("-")){let t=n.slice(1);return`-${o.formatAmount(t,r)}`}let d=n.startsWith("+")?n.slice(1):n;return o.formatAmount(d,r)}function te(o,e){if(!e.changes.length)return e.summary;let r=e.changes.map(n=>`${he(o,n.amount,n.token.decimals)} ${$(n.token.symbol)}`).join(", ");return`${e.summary} (${r})`}async function we(o,e){try{let[r,n]=await Promise.all([o.readContract({address:e,abi:V,functionName:"symbol"}),o.readContract({address:e,abi:V,functionName:"decimals"})]),d=typeof r=="string"&&r.trim()?r.trim():"TOKEN",t=Number(n);return{symbol:d,decimals:Number.isInteger(t)&&t>=0&&t<=255?t:18}}catch{return{symbol:"TOKEN",decimals:18}}}function w(o,e,r){if(typeof e=="string"&&e.includes(".")){if(r?.decimals===void 0)throw new a(`Decimal string amount "${e}" requires explicit token decimals; amount inputs are base-unit integer strings by default.`);let d=r.rounding!==void 0?O(e,r.decimals,r.rounding):o?o.parseAmount(e,r.decimals):O(e,r.decimals),t=M(d);if(t<=0n)throw new a("Airdrop entry amount must be positive.");return t}let n;try{if(typeof e=="bigint")n=e;else if(typeof e=="string")n=M(e.trim());else throw j()}catch(d){throw d instanceof a?d:new a(`Invalid airdrop amount "${String(e)}".`,{cause:d})}if(n<=0n)throw new a("Airdrop entry amount must be strictly positive (> 0).");return n}function H(o,e){try{let r=typeof o=="bigint"?o:BigInt(String(o).trim());if(r<0n)throw new a(`${e} must be non-negative.`);return r}catch(r){throw r instanceof a?r:new a(`Invalid ${e}: ${String(o)}`,{cause:r})}}function A(o,e){if(typeof o!="string"||!me(o,{strict:!1}))throw new a(`Invalid ${e} address "${String(o)}": token/account must be a valid EVM address, never a symbol.`);return Z(o)}function L(o,e,r){let n=typeof o=="bigint"?o:BigInt(o);if(n<0n||n>Y)throw new a(`Airdrop leaf index must be in 0..${Y.toString()}.`);let d=A(e,"account"),t=w(void 0,r),s=ce(Ae,[n,d,t]);return X(X(s))}function ie(o,e){let r=o;for(let n of e)r=N(r,n);return r}function Ne(o){try{let e=L(o.index,o.account,o.amount),r=ie(e,o.proof);return S(r,o.root)}catch{return!1}}function U(o,e){if(!Array.isArray(o)||o.length===0)throw new a("Airdrop entries list cannot be empty; maxClaims must be in 1..250000.");if(o.length>P)throw new a(`Airdrop entries length (${o.length}) exceeds maxClaims limit of ${P}.`);let r=[],n=0n;for(let i=0;i<o.length;i+=1){let l=o[i];if(!l)throw new a(`Missing airdrop entry at position ${i}.`);let c=l.index??i;if(!Number.isInteger(c)||c!==i)throw new a(`Airdrop entry index at position ${i} must be contiguous ${i} (got ${String(c)}).`);let u=A(l.account,`entries[${i}].account`),g=w(e?.context,l.amount,e);n+=g,r.push({index:c,account:u,amount:g.toString()})}if(n<=0n||n>ne)throw new a("Airdrop total amount must be > 0 and fit in uint128.");let d=r.map(i=>L(i.index,i.account,i.amount)),t=[d];for(;t[t.length-1].length>1;){let i=t[t.length-1],l=[];for(let c=0;c<i.length;c+=2){let u=i[c],g=i[c+1];g===void 0?l.push(u):l.push(N(u,g))}t.push(l)}let s=t[t.length-1][0];if(s.toLowerCase()===re)throw new a("Computed Merkle root cannot be zero.");let f=t.length>1?t[1]:t[0],m=r.map((i,l)=>{let c=[],u=l;for(let g=0;g<t.length-1;g+=1){let y=t[g],b=u^1;b<y.length&&c.push(y[b]),u=Math.floor(u/2)}return{index:i.index,account:i.account,amount:i.amount,leaf:d[l],proof:c}}),p={format:"openzeppelin-standard-merkle-tree-v1",leafEncoding:["uint256","address","uint256"],root:s,totalAmount:n.toString(),maxClaims:r.length,values:r.map(i=>[i.index,i.account,i.amount]),entries:r};return{root:s,leaves:d,level1:f,totalAmount:n.toString(),maxClaims:r.length,entries:r,proofs:m,list:p}}function ke(o){if(!o||!Array.isArray(o.entries)&&!Array.isArray(o.values))throw new a("Saved airdrop list is missing entries/values.");let e=Array.isArray(o.entries)&&o.entries.length>0?o.entries:o.values.map(([n,d,t])=>({index:n,account:d,amount:t})),r=U(e);if(o.root&&!S(r.root,o.root))throw new a(`Rebuilt tree root ${r.root} does not match saved list root ${o.root}.`);if(o.maxClaims!==void 0&&r.maxClaims!==o.maxClaims)throw new a(`Rebuilt maxClaims (${r.maxClaims}) does not match saved list maxClaims (${o.maxClaims}).`);if(o.totalAmount!==void 0&&r.totalAmount!==o.totalAmount)throw new a(`Rebuilt totalAmount (${r.totalAmount}) does not match saved list totalAmount (${o.totalAmount}).`);return r}async function ae(o,e){return K(o.http,e,{method:"GET"},r=>r!==null&&typeof r=="object")}async function $e(o,e,r){let n=A(e.token,"token");if(n===ee)throw new a("Airdrop token cannot be the zero address.");let d=U(e.entries,{decimals:e.decimals,rounding:e.rounding,context:o}),t=e.maxClaims??d.maxClaims;if(!Number.isInteger(t)||t<1||t>P||t!==d.maxClaims)throw new a(`maxClaims (${String(t)}) must equal entries.length (${d.maxClaims}) and be in 1..${P}.`);let s=BigInt(d.totalAmount),f=e.total!==void 0?w(o,e.total,{decimals:e.decimals,rounding:e.rounding}):s;if(f<s)throw new a(`Airdrop total (${f.toString()}) is less than the sum of entry amounts (${s.toString()}).`);if(f<=0n||f>ne)throw new a("Airdrop total must be positive and fit in uint128.");let m=e.uri??"",p=new TextEncoder().encode(m).byteLength;if(p>ge)throw new a(`Airdrop URI length (${p} bytes) exceeds 256-byte limit.`);let i=e.endTime!==void 0?H(e.endTime,"endTime"):0n;if(i>be)throw new a("endTime exceeds uint64 maximum.");let l=o.clientFor(x),c=await l.getCode({address:n});if(!c||c==="0x")throw new a(`Token ${n} has no contract code on chain ${x}.`);let u;if(i!==0n){let _=(await l.getBlock()).timestamp,B=e.inclusionMargin!==void 0?H(e.inclusionMargin,"inclusionMargin"):pe;if(B<=0n)throw new a("inclusionMargin must be at least 1 second to leave room for signing and inclusion after the already-mined block.");let D=_+B,I=e.inclusionTime!==void 0?H(e.inclusionTime,"inclusionTime"):D;if(I<D)throw new a(`inclusionTime (${I.toString()}) must be after the already-mined block (${_.toString()}) with room for signing and inclusion (>= ${D.toString()}).`);u=I;let F=I+fe;if(i<F)throw new a(`endTime (${i.toString()}) is too short (window too short): must be 0 or at least inclusion time (${I.toString()}) + 604800 (7 days >= ${F.toString()}, after already-mined block.timestamp ${_.toString()}).`)}let g=await l.readContract({address:C,abi:T,functionName:"quote",args:[t]}),y=typeof g=="bigint"?g:BigInt(String(g));if(y<0n||y>Q)throw new a(`HoodLock quote(uint32) fee (${y.toString()}) exceeds max fee cap (${Q.toString()}).`);let b=o.formatAmount(y.toString(),W.decimals),h=o.approval(n,C,f.toString(),x),k=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"create",args:[n,d.root,f,t,i,m]}),value:y.toString(),description:`Create HoodLock airdrop (${t} claims, total ${f.toString()}, quote fee ${b} ETH (${y.toString()} wei))`}),v=[h,k],E=A(e.account??r??xe,"wallet"),R=await o.preview(v,E),le=y>0n?` Quote fee: -${b} ETH (${b} ETH / ${y.toString()} wei).`:" Quote fee: 0 ETH (0 wei).",se=`${te(o,R)}${le}`;return{kind:"hoodlock_airdrop_create",chainId:x,token:n,merkleRoot:d.root,totalAmount:d.totalAmount,total:f.toString(),maxClaims:t,endTime:i,...u!==void 0?{inclusionTime:u}:{},uri:m,quoteFee:y,list:d.list,proofs:d.proofs,txs:v,preview:R,summary:se}}async function G(o,e,r,n){if(n.savedProof){let m=A(n.savedProof.account,"savedProof.account");if(m!==r)throw new a(`savedProof account (${m}) does not match claim account (${r}).`);return{index:n.savedProof.index,amount:w(o,n.savedProof.amount),proof:n.savedProof.proof}}if(n.proof!==void 0&&n.index!==void 0&&n.amount!==void 0){let m=Number(n.index);if(!Number.isInteger(m)||m<0)throw new a(`Invalid claim index: ${String(n.index)}`);return{index:m,amount:w(o,n.amount),proof:n.proof}}if(n.list||n.entries){let p=(n.list?ke(n.list):U(n.entries,{context:o})).proofs.find(i=>!(!S(i.account,r)||n.index!==void 0&&i.index!==Number(n.index)));if(!p)throw new a(`Account ${r} was not found in the saved airdrop list.`);return{index:p.index,amount:w(o,p.amount),proof:p.proof}}let d=`${oe}/api/airdrop/${e.toString()}/proof?address=${r}`,t=await ae(o,d),s=t?.data??t;if(!s||s.index===void 0||s.amount===void 0||!Array.isArray(s.proof))throw new a(`No valid proof returned from HoodLock API for airdrop ${e.toString()} and account ${r}.`);let f=Number(s.index);if(!Number.isInteger(f)||f<0)throw new a(`Invalid index in API proof: ${String(s.index)}`);return{index:f,amount:w(o,s.amount),proof:s.proof}}async function de(o,e){let r=o.clientFor(x),n=await r.readContract({address:C,abi:T,functionName:"getAirdrop",args:[e.id]}),[d,t,s,f,m,p,i,,l]=n,c=BigInt(t),u=Number(s),g=Number(m),y=BigInt(l),b=A(f,"airdrop.token");if(d===ee||i.toLowerCase()===re)throw new a(`Airdrop ${e.id.toString()} does not exist.`);if(p)throw new a(`Airdrop ${e.id.toString()} has already been swept.`);if(c>0n&&(await r.getBlock()).timestamp>=c)throw new a(`Airdrop ${e.id.toString()} expired at timestamp ${c.toString()}.`);if(g>=u)throw new a(`Airdrop ${e.id.toString()} has reached maxClaims (${u}).`);let[h,k]=await Promise.all([r.readContract({address:C,abi:T,functionName:"isClaimed",args:[e.id,BigInt(e.index)]}),we(r,b)]);if(h)throw new a(`Airdrop ${e.id.toString()} index ${e.index} has already been claimed.`);if(y<e.amount)throw new a(`Airdrop ${e.id.toString()} remaining balance (${y.toString()}) is less than claim amount (${e.amount.toString()}).`);let v=L(e.index,e.account,e.amount),E=ie(v,e.proof);if(!S(E,i))throw new a(`Computed Merkle root ${E} does not match on-chain airdrop root ${i} (bad proof).`);return{tokenAddress:b,tokenMeta:k,merkleRoot:i,leaf:v}}async function Se(o,e){let{tokenAddress:r,tokenMeta:n,merkleRoot:d,leaf:t}=await de(o,e),s=e.caller??e.account,f=!S(s,e.account),m=o.formatAmount(e.amount.toString(),n.decimals),p=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"claim",args:[e.id,BigInt(e.index),e.account,e.amount,[...e.proof]]}),value:"0",description:f?`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for recipient ${e.account} (caller ${s} pays gas only, token delta 0)`:`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for ${e.account}`}),i=[p],l=await o.preview(i,s),c,u,g=e.amount.toString(),y;if(f){let b=l.changes.filter(h=>h.amount.trim().startsWith("-"));c={...l,changes:b,summary:`${l.summary} Recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units); caller ${s} change is 0 (gas only).`},u=`Third-party claim from HoodLock airdrop #${e.id.toString()} (index ${e.index}): recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}); caller ${s} own token change is 0 (gas only). ${l.summary}`,y="0"}else c=l,u=`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}) from HoodLock airdrop #${e.id.toString()} (index ${e.index}) for recipient ${e.account}. ${te(o,c)}`,y=e.amount.toString();return{kind:"hoodlock_airdrop_claim",chainId:x,id:e.id,index:e.index,account:e.account,recipient:e.account,caller:e.caller,token:r,amount:e.amount.toString(),recipientDelta:g,senderDelta:y,leaf:t,merkleRoot:d,proof:[...e.proof],tx:p,txs:i,preview:c,summary:u}}async function Ce(o,e,r){let n=A(e.account??r??"","account"),d=e.caller!==void 0?A(e.caller,"caller"):r!==void 0?A(r,"wallet"):void 0;if(e.id!==void 0){let l=H(e.id,"id"),c=await G(o,l,n,e);return Se(o,{id:l,index:c.index,account:n,caller:d,amount:c.amount,proof:c.proof})}let t=`${oe}/api/airdrop/eligible?address=${n}`,s=await ae(o,t),f=Array.isArray(s)?s:s?.claimable??s?.eligible??s?.airdrops??s?.claims??[],m=[];for(let l of f){let c=l.id??l.airdropId;if(c!==void 0)try{let u=H(c,"eligible.id"),g,y,b;if(l.index!==void 0&&l.amount!==void 0&&Array.isArray(l.proof))g=Number(l.index),y=w(o,l.amount),b=l.proof;else{let k=await G(o,u,n,{id:u,account:n});g=k.index,y=k.amount,b=k.proof}let h=await de(o,{id:u,index:g,account:n,amount:y,proof:b});m.push({id:u.toString(),index:g,account:n,token:h.tokenAddress,amount:y.toString(),proof:[...b],merkleRoot:h.merkleRoot})}catch{continue}}let p=m.length===0?`No verified eligible HoodLock airdrops were returned by the index for ${n}. Discovery can lag after creation; this does not prove there are no claims. If you know the airdrop id, call hoodlock_airdrop_claim with id and account to resolve its list/proof and verify it on-chain.`:`Found ${m.length} eligible HoodLock airdrop(s) for ${n}: ${m.map(l=>`#${l.id}`).join(", ")}. Discovery can lag after creation. Choose an id, or pass a known new id, to hoodlock_airdrop_claim to verify and build a claim transaction.`;return{kind:"hoodlock_airdrop_eligible",chainId:x,account:n,recipient:n,caller:d,recipientDelta:"0",senderDelta:"0",eligible:m,claims:[],tx:void 0,txs:[],preview:{txs:[],changes:[],summary:p},summary:p}}var ve=o=>({tools:[{name:"hoodlock_airdrop_create",inputSchema:{type:"object",required:["token","entries"],additionalProperties:!1,properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663"},entries:{type:"array",description:"Ordered airdrop entries [{ index?, account, amount }] with base-unit integer string amounts"},total:{type:"string",description:"Optional total funded token amount as a base-unit integer string (>= sum of entries)"},maxClaims:{type:"number",description:"Optional claim count (must equal entries.length in 1..250000)"},endTime:{type:"number",description:"Unix timestamp in seconds (0 for non-sweepable or >= inclusion time + 604800)"},inclusionTime:{type:"number",description:"Optional expected transaction inclusion Unix timestamp in seconds (> already-mined block.timestamp)"},inclusionMargin:{type:"number",description:"Optional signing and inclusion margin in seconds above the already-mined block.timestamp (>= 1, default 30)"},uri:{type:"string",description:"Metadata URI (<= 256 UTF-8 bytes)"},decimals:{type:"number",description:"Optional token decimals when converting human decimal entry amounts via parseAmount"},rounding:{type:"string",enum:["floor","ceil"],description:"Optional rounding mode (floor or ceil) when converting decimal amounts"},account:{type:"string",description:"Optional creator wallet address for preview simulation"}}},execute:async(e,r)=>$e(o,e,r)},{name:"hoodlock_airdrop_claim",inputSchema:{type:"object",required:["account"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional airdrop ID (omit to query eligible airdrops)"},account:{type:"string",description:"Leaf recipient address that receives the tokens"},caller:{type:"string",description:"Optional caller/relayer address submitting the tx (pays gas only, receives 0 tokens)"},index:{type:"number",description:"Optional leaf index when supplying proof directly or selecting from list/entries"},amount:{type:"string",description:"Optional leaf amount as a base-unit integer string"},proof:{type:"array",items:{type:"string"},description:"Optional Merkle sibling proof array of 32-byte hex strings"},savedProof:{type:"object",description:"Optional saved proof item ({ index, account, amount, leaf?, proof }) from hoodlock_airdrop_create"},list:{type:"object",description:"Optional saved airdrop list ({ format, leafEncoding, root, totalAmount, maxClaims, values, entries }) to rebuild proof locally"},entries:{type:"array",description:"Optional airdrop entries array ([{ index?, account, amount }]) to rebuild proof locally"}}},execute:async(e,r)=>Ce(o,e,r)}]}),Le=ve;export{V as a,x as b,C as c,oe as d,P as e,ge as f,fe as g,pe as h,Q as i,T as j,he as k,L as l,ie as m,Ne as n,U as o,ke as p,ve as q,Le as r};
@@ -1 +1 @@
1
- import{a as c,b as F,e as P,f as T,g as I}from"./ZXRIJG6H.js";import{a as l}from"./66F5ZH34.js";import{c as N,g,h as S}from"./NWNYJ26T.js";import{b as h}from"./TI727O2H.js";import{a as u}from"./XSD5NL7J.js";import{encodeFunctionData as w,getAddress as _,parseAbi as Q,parseAbiItem as j,zeroAddress as H}from"viem";var x=_("0x000000001f26a0044baa66024e7b6599c61963f8"),M=j("event AuctionCreated(address indexed auction,address indexed token,uint256 amount,bytes configData)"),o=Q(["function currency() view returns (address)","function token() view returns (address)","function startBlock() view returns (uint64)","function endBlock() view returns (uint64)","function claimBlock() view returns (uint64)","function validationHook() view returns (address)","function clearingPrice() view returns (uint256)","function isGraduated() view returns (bool)","function bids(uint256) view returns ((uint64 startBlock,uint24 startCumulativeMps,uint64 exitedBlock,uint256 maxPrice,address owner,uint256 amountQ96,uint256 tokensFilled))","function submitBid(uint256 maxPrice,uint128 amount,address owner,uint256 prevTickPrice,bytes hookData) payable returns (uint256)","function exitBid(uint256)","function exitPartiallyFilledBid(uint256,uint64,uint64)","function claimTokens(uint256)","function claimTokensBatch(address,uint256[])","function checkpoint()","function sweepCurrency()","function sweepUnsoldTokens()"]);async function D(s,y){let n=F(y.auction),t=c(y.creationBlock,"creationBlock",64,!0),e=await s.getLogs({address:x,event:M,args:{auction:n},fromBlock:t,toBlock:t,strict:!0});if(e.length!==1||!g(e[0].address,x)||!S(e[0].args.auction,n))throw new u("Auction has no matching AuctionCreated event at the pinned CCA factory and creationBlock.");return n}async function E(s,y){let n=s.clientFor(h),t=await D(n,y),e=await n.getBlockNumber(),[a,b,i,k,m,v,d,B]=await Promise.all([n.readContract({address:t,abi:o,functionName:"currency",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"token",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"startBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"endBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"claimBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"validationHook",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"clearingPrice",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"isGraduated",blockNumber:e})]);return{auction:t,currency:a,saleToken:b,startBlock:i,endBlock:k,claimBlock:m,validationHook:v,clearingPrice:d,graduated:B,blockNumber:e}}var L={auction:{...N,description:"Address of the continuous clearing auction to verify against the pinned factory."},creationBlock:l("Auction creation block number, as a decimal string, used to verify the factory event."),bidId:l('Identifier of the auction bid, as a decimal string. Example: "1".'),amount:l('Amount of payment currency in base units; use payment currency decimals. Example: "1000000" = 1 payment currency at 6 decimals.'),maxPrice:l("Maximum bid price in Q96 payment-currency base units per sale-token base unit."),prevTickPrice:l("Previous auction price tick in Q96 payment-currency base units per sale-token base unit; zero for the first tick."),lastFullyFilledCheckpointBlock:l("Last fully filled checkpoint block number for a partial bid exit, as a decimal string."),outbidBlock:l("Block number at which the bid was outbid, as a decimal string."),mode:{description:'Choose "full" to exit a bid, or "partial" to exit using checkpoint and outbid block hints.',type:"string",enum:["full","partial"]},bidIds:{description:'One to fifty unique auction bid identifiers as decimal strings. Example: ["1", "2"].',type:"array",minItems:1,maxItems:50,items:l()}};function R(s){let n=["status","bid","exit","claim","checkpoint","sweep_currency","sweep_tokens"].map(t=>({name:`uniswap_auction_${t}`,inputSchema:{type:"object",additionalProperties:!1,required:["auction","creationBlock",...t==="bid"?["amount","maxPrice","prevTickPrice"]:t==="exit"?["bidId","mode"]:[]],properties:L},async execute(e,a){I(e,["auction","creationBlock",...t==="bid"?["amount","maxPrice","prevTickPrice"]:t==="exit"?["bidId","mode","lastFullyFilledCheckpointBlock","outbidBlock"]:t==="claim"?["bidId","bidIds"]:t==="status"?["bidId"]:[]]);let i=await E(s,e),k=s.clientFor(h),[m,v]=await Promise.all([P(s,i.currency,i.blockNumber),P(s,i.saleToken,i.blockNumber)]),d=e.bidId===void 0?void 0:await k.readContract({address:i.auction,abi:o,functionName:"bids",args:[c(e.bidId,"bidId",256,!0)],blockNumber:i.blockNumber});if(t==="status")return{auction:i.auction,paymentToken:m,saleToken:v,startBlock:i.startBlock.toString(),endBlock:i.endBlock.toString(),claimBlock:i.claimBlock.toString(),validationHook:i.validationHook,clearingPrice:i.clearingPrice.toString(),graduated:i.graduated,...d?{bid:{...d,startBlock:d.startBlock.toString(),exitedBlock:d.exitedBlock.toString(),maxPrice:d.maxPrice.toString(),amountQ96:d.amountQ96.toString(),tokensFilled:d.tokensFilled.toString()}}:{},summary:"CCA prices use currency-base-units per sale-token-base-unit in Q96. Clearing price/graduation reflect the latest checkpoint and may lag the head."};let B=[],f,A=0n;if(t==="bid"){if(i.validationHook!==H)throw new u("This auction has a validation hook. Its validation/signing contract is not configured; do not pass an off-chain signature manually.");if(i.blockNumber<i.startBlock||i.blockNumber>=i.endBlock)throw new u("Auction is not in its bidding window.");let r=c(e.amount,"amount",128),p=c(e.maxPrice,"maxPrice"),C=c(e.prevTickPrice,"prevTickPrice",256,!0);if(p<=i.clearingPrice)throw new u("Bid maxPrice must be above the checkpoint clearing price.");i.currency===H?A=r:B.push(s.approval(i.currency,i.auction,r.toString(),h)),f=w({abi:o,functionName:"submitBid",args:[p,r,a,C,"0x"]})}else if(t==="exit"){if(!d||!g(d.owner,a))throw new u("Only exit a bid owned by the signing wallet.");let r=c(e.bidId,"bidId",256,!0);if(e.mode==="full"){if(e.lastFullyFilledCheckpointBlock!==void 0||e.outbidBlock!==void 0)throw new u("Full exit takes no checkpoint hints.");f=w({abi:o,functionName:"exitBid",args:[r]})}else if(e.mode==="partial")f=w({abi:o,functionName:"exitPartiallyFilledBid",args:[r,c(e.lastFullyFilledCheckpointBlock,"lastFullyFilledCheckpointBlock",64,!0),c(e.outbidBlock,"outbidBlock",64,!0)]});else throw new u("Choose full or partial exit explicitly; partial exits require checkpoint hints.")}else if(t==="claim"){if(e.bidId===void 0==(e.bidIds===void 0))throw new u("Provide bidId or bidIds, not both.");let r=e.bidIds===void 0?[c(e.bidId,"bidId",256,!0)]:Array.isArray(e.bidIds)?e.bidIds.map(p=>c(p,"bidIds",256,!0)):[];if(r.length<1||r.length>50||new Set(r.map(String)).size!==r.length)throw new u("Provide 1 to 50 unique bid IDs.");for(let p of r){let C=await k.readContract({address:i.auction,abi:o,functionName:"bids",args:[p],blockNumber:i.blockNumber});if(!g(C.owner,a))throw new u("Claimed tokens must belong to the signing wallet.")}f=w({abi:o,functionName:"claimTokensBatch",args:[a,r]})}else f=w({abi:o,functionName:t==="checkpoint"?"checkpoint":t==="sweep_currency"?"sweepCurrency":"sweepUnsoldTokens"});return B.push(s.unsignedTx({to:i.auction,data:f,value:A.toString(),chainId:h,description:`CCA ${t} on factory-verified auction ${i.auction}. Bid owner ${a}.`})),T(s,B,a,`CCA ${t}; checkpoint/exit/claim eligibility and creator-only sweeps are checked by the contract in preview. Sweeps pay the auction's immutable funds/tokens recipient, not an arbitrary recipient.`)}}));return n.push({name:"uniswap_auctions",inputSchema:{type:"object",additionalProperties:!1,properties:{fromBlock:l("First block number of the scan, as a decimal string; inclusive."),toBlock:l("Last block number of the scan, as a decimal string; inclusive.")}},async execute(t){I(t,["fromBlock","toBlock"]);let e=s.clientFor(h),a=await e.getBlockNumber(),b=t.fromBlock===void 0?a>9999n?a-9999n:0n:c(t.fromBlock,"fromBlock",64,!0),i=t.toBlock===void 0?a:c(t.toBlock,"toBlock",64,!0);if(b>i||i>a||i-b>=10000n)throw new u("Scan an ordered range of at most 10000 blocks, ending at or before the head.");let k=await e.getLogs({address:x,event:M,fromBlock:b,toBlock:i,strict:!0});return{factory:x,fromBlock:b.toString(),toBlock:i.toString(),auctions:k.map(m=>({auction:m.args.auction,token:m.args.token,amount:m.args.amount.toString(),creationBlock:m.blockNumber.toString()})),summary:"Factory-verified auctions in this block window only. An empty result does not establish that no auctions exist outside it. Scan earlier windows for older launches."}}}),{tools:n}}export{x as a,M as b,o as c,D as d,E as e,R as f};
1
+ import{a as c,b as F,e as P,f as T,g as I}from"./QP2B7AYX.js";import{a as l}from"./66F5ZH34.js";import{c as N,g,h as S}from"./NWNYJ26T.js";import{b as h}from"./EWZFZUVF.js";import{a as u}from"./XSD5NL7J.js";import{encodeFunctionData as w,getAddress as _,parseAbi as Q,parseAbiItem as j,zeroAddress as H}from"viem";var x=_("0x000000001f26a0044baa66024e7b6599c61963f8"),M=j("event AuctionCreated(address indexed auction,address indexed token,uint256 amount,bytes configData)"),o=Q(["function currency() view returns (address)","function token() view returns (address)","function startBlock() view returns (uint64)","function endBlock() view returns (uint64)","function claimBlock() view returns (uint64)","function validationHook() view returns (address)","function clearingPrice() view returns (uint256)","function isGraduated() view returns (bool)","function bids(uint256) view returns ((uint64 startBlock,uint24 startCumulativeMps,uint64 exitedBlock,uint256 maxPrice,address owner,uint256 amountQ96,uint256 tokensFilled))","function submitBid(uint256 maxPrice,uint128 amount,address owner,uint256 prevTickPrice,bytes hookData) payable returns (uint256)","function exitBid(uint256)","function exitPartiallyFilledBid(uint256,uint64,uint64)","function claimTokens(uint256)","function claimTokensBatch(address,uint256[])","function checkpoint()","function sweepCurrency()","function sweepUnsoldTokens()"]);async function D(s,y){let n=F(y.auction),t=c(y.creationBlock,"creationBlock",64,!0),e=await s.getLogs({address:x,event:M,args:{auction:n},fromBlock:t,toBlock:t,strict:!0});if(e.length!==1||!g(e[0].address,x)||!S(e[0].args.auction,n))throw new u("Auction has no matching AuctionCreated event at the pinned CCA factory and creationBlock.");return n}async function E(s,y){let n=s.clientFor(h),t=await D(n,y),e=await n.getBlockNumber(),[a,b,i,k,m,v,d,B]=await Promise.all([n.readContract({address:t,abi:o,functionName:"currency",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"token",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"startBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"endBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"claimBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"validationHook",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"clearingPrice",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"isGraduated",blockNumber:e})]);return{auction:t,currency:a,saleToken:b,startBlock:i,endBlock:k,claimBlock:m,validationHook:v,clearingPrice:d,graduated:B,blockNumber:e}}var L={auction:{...N,description:"Address of the continuous clearing auction to verify against the pinned factory."},creationBlock:l("Auction creation block number, as a decimal string, used to verify the factory event."),bidId:l('Identifier of the auction bid, as a decimal string. Example: "1".'),amount:l('Amount of payment currency in base units; use payment currency decimals. Example: "1000000" = 1 payment currency at 6 decimals.'),maxPrice:l("Maximum bid price in Q96 payment-currency base units per sale-token base unit."),prevTickPrice:l("Previous auction price tick in Q96 payment-currency base units per sale-token base unit; zero for the first tick."),lastFullyFilledCheckpointBlock:l("Last fully filled checkpoint block number for a partial bid exit, as a decimal string."),outbidBlock:l("Block number at which the bid was outbid, as a decimal string."),mode:{description:'Choose "full" to exit a bid, or "partial" to exit using checkpoint and outbid block hints.',type:"string",enum:["full","partial"]},bidIds:{description:'One to fifty unique auction bid identifiers as decimal strings. Example: ["1", "2"].',type:"array",minItems:1,maxItems:50,items:l()}};function R(s){let n=["status","bid","exit","claim","checkpoint","sweep_currency","sweep_tokens"].map(t=>({name:`uniswap_auction_${t}`,inputSchema:{type:"object",additionalProperties:!1,required:["auction","creationBlock",...t==="bid"?["amount","maxPrice","prevTickPrice"]:t==="exit"?["bidId","mode"]:[]],properties:L},async execute(e,a){I(e,["auction","creationBlock",...t==="bid"?["amount","maxPrice","prevTickPrice"]:t==="exit"?["bidId","mode","lastFullyFilledCheckpointBlock","outbidBlock"]:t==="claim"?["bidId","bidIds"]:t==="status"?["bidId"]:[]]);let i=await E(s,e),k=s.clientFor(h),[m,v]=await Promise.all([P(s,i.currency,i.blockNumber),P(s,i.saleToken,i.blockNumber)]),d=e.bidId===void 0?void 0:await k.readContract({address:i.auction,abi:o,functionName:"bids",args:[c(e.bidId,"bidId",256,!0)],blockNumber:i.blockNumber});if(t==="status")return{auction:i.auction,paymentToken:m,saleToken:v,startBlock:i.startBlock.toString(),endBlock:i.endBlock.toString(),claimBlock:i.claimBlock.toString(),validationHook:i.validationHook,clearingPrice:i.clearingPrice.toString(),graduated:i.graduated,...d?{bid:{...d,startBlock:d.startBlock.toString(),exitedBlock:d.exitedBlock.toString(),maxPrice:d.maxPrice.toString(),amountQ96:d.amountQ96.toString(),tokensFilled:d.tokensFilled.toString()}}:{},summary:"CCA prices use currency-base-units per sale-token-base-unit in Q96. Clearing price/graduation reflect the latest checkpoint and may lag the head."};let B=[],f,A=0n;if(t==="bid"){if(i.validationHook!==H)throw new u("This auction has a validation hook. Its validation/signing contract is not configured; do not pass an off-chain signature manually.");if(i.blockNumber<i.startBlock||i.blockNumber>=i.endBlock)throw new u("Auction is not in its bidding window.");let r=c(e.amount,"amount",128),p=c(e.maxPrice,"maxPrice"),C=c(e.prevTickPrice,"prevTickPrice",256,!0);if(p<=i.clearingPrice)throw new u("Bid maxPrice must be above the checkpoint clearing price.");i.currency===H?A=r:B.push(s.approval(i.currency,i.auction,r.toString(),h)),f=w({abi:o,functionName:"submitBid",args:[p,r,a,C,"0x"]})}else if(t==="exit"){if(!d||!g(d.owner,a))throw new u("Only exit a bid owned by the signing wallet.");let r=c(e.bidId,"bidId",256,!0);if(e.mode==="full"){if(e.lastFullyFilledCheckpointBlock!==void 0||e.outbidBlock!==void 0)throw new u("Full exit takes no checkpoint hints.");f=w({abi:o,functionName:"exitBid",args:[r]})}else if(e.mode==="partial")f=w({abi:o,functionName:"exitPartiallyFilledBid",args:[r,c(e.lastFullyFilledCheckpointBlock,"lastFullyFilledCheckpointBlock",64,!0),c(e.outbidBlock,"outbidBlock",64,!0)]});else throw new u("Choose full or partial exit explicitly; partial exits require checkpoint hints.")}else if(t==="claim"){if(e.bidId===void 0==(e.bidIds===void 0))throw new u("Provide bidId or bidIds, not both.");let r=e.bidIds===void 0?[c(e.bidId,"bidId",256,!0)]:Array.isArray(e.bidIds)?e.bidIds.map(p=>c(p,"bidIds",256,!0)):[];if(r.length<1||r.length>50||new Set(r.map(String)).size!==r.length)throw new u("Provide 1 to 50 unique bid IDs.");for(let p of r){let C=await k.readContract({address:i.auction,abi:o,functionName:"bids",args:[p],blockNumber:i.blockNumber});if(!g(C.owner,a))throw new u("Claimed tokens must belong to the signing wallet.")}f=w({abi:o,functionName:"claimTokensBatch",args:[a,r]})}else f=w({abi:o,functionName:t==="checkpoint"?"checkpoint":t==="sweep_currency"?"sweepCurrency":"sweepUnsoldTokens"});return B.push(s.unsignedTx({to:i.auction,data:f,value:A.toString(),chainId:h,description:`CCA ${t} on factory-verified auction ${i.auction}. Bid owner ${a}.`})),T(s,B,a,`CCA ${t}; checkpoint/exit/claim eligibility and creator-only sweeps are checked by the contract in preview. Sweeps pay the auction's immutable funds/tokens recipient, not an arbitrary recipient.`)}}));return n.push({name:"uniswap_auctions",inputSchema:{type:"object",additionalProperties:!1,properties:{fromBlock:l("First block number of the scan, as a decimal string; inclusive."),toBlock:l("Last block number of the scan, as a decimal string; inclusive.")}},async execute(t){I(t,["fromBlock","toBlock"]);let e=s.clientFor(h),a=await e.getBlockNumber(),b=t.fromBlock===void 0?a>9999n?a-9999n:0n:c(t.fromBlock,"fromBlock",64,!0),i=t.toBlock===void 0?a:c(t.toBlock,"toBlock",64,!0);if(b>i||i>a||i-b>=10000n)throw new u("Scan an ordered range of at most 10000 blocks, ending at or before the head.");let k=await e.getLogs({address:x,event:M,fromBlock:b,toBlock:i,strict:!0});return{factory:x,fromBlock:b.toString(),toBlock:i.toString(),auctions:k.map(m=>({auction:m.args.auction,token:m.args.token,amount:m.args.amount.toString(),creationBlock:m.blockNumber.toString()})),summary:"Factory-verified auctions in this block window only. An empty result does not establish that no auctions exist outside it. Scan earlier windows for older launches."}}}),{tools:n}}export{x as a,M as b,o as c,D as d,E as e,R as f};
@@ -0,0 +1 @@
1
+ import{i as u,m as y,n as l}from"./5Y457HYC.js";import{a as g}from"./IJVBCEA2.js";import{e as f,i as p}from"./UMY6SP7C.js";import{a as s}from"./XSD5NL7J.js";import{decodeAbiParameters as k,encodeAbiParameters as A,zeroAddress as w}from"viem";var Z="Zap Target requires its own advisory and a frozen list of factory-created feeder vaults; this launch uses the advisory slot for the agent gate.",h=[{type:"tuple",components:[{name:"factory",type:"address"},{name:"feeders",type:"address[]"}]}],b={id:"zap-target",address:"0x59834ed88E72c59EB4fB0eF3cB0D95eCA98223E3",minGas:3e5};function x(e){f(e,["factory","feeders"],["factory","feeders"]);let a=p(e.factory);if(!Array.isArray(e.feeders)||e.feeders.length<1||e.feeders.length>4)throw new s("Zap Target requires one to four feeder vaults.");let t=e.feeders.map(p);if(a===w||t.some(o=>o===w)||new Set(t.map(o=>o.toLowerCase())).size!==t.length)throw new s("Zap Target requires a nonzero factory and distinct nonzero feeders.");return A(h,[{factory:a,feeders:t}])}function T(e){let[a]=k(h,e);if(x(a).toLowerCase()!==e.toLowerCase())throw new s("Non-canonical Zap Target terms; session tiers are not supported.");return a}function S(e){let a=T(e);return`Zap Target: buys are gated to feeder vaults ${a.feeders.join(", ")} created by ${a.factory}; sells remain open. Only the liquidity owner and feeder vaults may add liquidity. Each vault's immutable route controls custody, protocol share, caller bounty, timing and target purchases and must be verified separately.`}var z={address:b.address,codeHash:"0xf9fb16725ac563c7684f22596e08450624230b66f58fd5872f37ff1699921037",schemaHash:"0x67fad64d676b583a8d694af1d0bfe44ab753db2e6eff0fcac13d6c25ed1b6b5e",phaseMask:1,feeOnly:!1,gasMin:3e5};async function B(e,a,t,o){if(f(t,["feeders","routes"],["feeders","routes"]),!Array.isArray(t.feeders)||!Array.isArray(t.routes)||t.feeders.length!==t.routes.length)throw new s("Zap Target requires one complete requested route per feeder.");let i=x({factory:u.address,feeders:t.feeders}),{feeders:m}=T(i);await g(e,a,u,1,{maxLpFeePips:0n,maxQuoteTakePips:0n,maxSubjectTakeBps:0n});let c=await Promise.all(m.map((r,d)=>y(e,a,r,t.routes[d]))),n=(r,d)=>String(r).toLowerCase()===String(d).toLowerCase();for(let{terms:r}of c)if(!o.rules||!n(r.targetId,o.poolId)||!n(r.gate,b.address)||!n(r.quote,o.quote)||!n(r.subject,o.subject)||!n(r.rules,o.rules)||r.tickSpacing!==BigInt(o.tickSpacing)||r.windowScope!==c[0].terms.windowScope)throw new s("Zap Target feeder pool, quote, rules, gate or impact-window scope differs from this launch.");return{data:i,descriptor:z,phases:1,bounds:{maxLpFeePips:0n,maxQuoteTakePips:0n,maxSubjectTakeBps:0n},summary:`${S(i)} Buys are feeder-only and require no agent identity; sells stay open. ${c.map((r,d)=>l(m[d],r.terms)).join(" ")}`}}export{Z as a,h as b,b as c,x as d,T as e,S as f,z as g,B as h};
@@ -1 +1 @@
1
- import{b as W,c as K}from"./A3BJSQ23.js";import{M as z}from"./MQXSCNUL.js";import{a as D}from"./IPU656WB.js";import{c as C}from"./LCH6F5HT.js";import{c as B,f as R,i as F,j as L,k as H}from"./X24YTJST.js";import{a as V}from"./43LI5NKJ.js";import{a as u}from"./66F5ZH34.js";import{g as O}from"./NWNYJ26T.js";import{b as A}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as I,erc20Abi as j,getAddress as P,parseAbi as k}from"viem";var f=k(["function asset() view returns (address)","function decimals() view returns (uint8)","function balanceOf(address) view returns (uint256)","function previewMint(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function mint(uint256 shares,address receiver) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256)"]);function U(t,n=!1){if(typeof t!="string"||!/^\d+$/.test(t)||t.length>78||BigInt(t)>=1n<<256n||!n&&BigInt(t)===0n)throw new o("Provide a positive uint256 decimal base-unit string.");return BigInt(t)}function ce(t,n,y){return["details","analytics","manage","mint",n==="netnet"?"redeem":"withdraw_assets","force_exit","in_kind_exit"].map(e=>{let $=[...n==="longbow"?["vault"]:[],...e==="mint"?["shares","maxAssets"]:e==="redeem"?["shares"]:e==="withdraw_assets"?["amount"]:e==="force_exit"?["maxPenaltyAssets","minAmountOut"]:[]],m={...n==="longbow"?{vault:{type:"string",enum:y.map(i=>i.vault),description:"Pinned vault address on chain 4663; use longbow_list to compare vault names."}}:{}};e==="in_kind_exit"&&(Object.assign(m,{amount:u(`Assets to receive, in base units of the vault's asset (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`),maxShares:u('Most vault shares you will burn, in share base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.'),maxPenaltyAssets:u(`Highest exit penalty you accept, in base units of the vault's asset (read its decimals). Example: "10000" = 0.01 USDG for a 6-decimal asset.`),deadline:u("Absolute Unix seconds deadline, no more than five minutes ahead. Example: 1800000000.")}),$.push("amount","maxShares","maxPenaltyAssets","deadline")),e==="mint"&&Object.assign(m,{shares:u('Vault shares to mint, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.'),maxAssets:u(`Most of the vault's asset you will pay, in base units (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`)}),e==="redeem"&&(m.shares=u('Vault shares to redeem, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.')),e==="withdraw_assets"&&(m.amount=u(`Assets to withdraw, in base units of the vault's asset (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`)),e==="force_exit"&&Object.assign(m,{maxPenaltyAssets:u(`Highest exit penalty you accept, in base units of the vault's asset (read its decimals). Example: "10000" = 0.01 USDG for a 6-decimal asset.`),minAmountOut:u(`Least of the vault's asset you must receive, in base units (read its decimals). Example: "1000000" = 1 USDG.`)});let J=C(t,`${n}_manage`,y[0].vault,y[0].asset),N=D(t,`${n}_analytics`,y[0].vault);if(e==="manage"||e==="analytics"){let i=e==="manage"?J.inputSchema:N.inputSchema;Object.assign(m,i.properties),e==="analytics"&&n==="longbow"&&(m.view={type:"string",enum:["apy","published_apy"],description:"Report: apy (realized yield from share price) or published_apy (yield published by the project)."}),$.push(...i.required)}return{name:`${n}_${e}`,inputSchema:{type:"object",properties:m,required:$,additionalProperties:!1,...e==="analytics"&&n==="netnet"?{allOf:N.inputSchema.allOf}:{}},execute:async(i,r)=>{try{if(V(r),Object.keys(i).some(c=>!Object.hasOwn(m,c)))throw new o("Unsupported vault feature argument.");let _=n==="netnet"?y[0]:y.find(c=>typeof i.vault=="string"&&O(c.vault,i.vault));if(!_)throw new o("Choose a current vault returned by the project list tool.");let{vault:s,asset:a}=_,b={...i};if(delete b.vault,e==="details")return F(t,`${n}_details`,s,a).execute(b,r);if(e==="manage")return C(t,`${n}_manage`,s,a).execute(b,r);if(e==="analytics"){if(n==="longbow"&&i.view==="published_apy")return K(t,s,a,b);if(n==="longbow"&&i.view==="apy")return W(t,s,a,b);if(n==="longbow")throw new o("Choose apy or published_apy; the Longbow vault is not indexed by Morpho for other analytics views.");return{...await D(t,`${n}_analytics`,s).execute(b,r),asset:{...a,address:P(a.address)}}}if(e==="in_kind_exit")return z(t,s,a,i,r);let h=t.clientFor(A);if(await h.getChainId()!==A)throw new o("Vault actions require chain 4663.");let[Q,X,Y]=await Promise.all([h.readContract({address:s,abi:f,functionName:"asset"}),h.readContract({address:s,abi:f,functionName:"decimals"}),h.readContract({address:a.address,abi:j,functionName:"decimals"})]);if(P(Q)!==P(a.address)||X!==18||Y!==a.decimals)throw new o("Vault metadata does not match the pinned asset and shares.");let T=e==="force_exit"?await h.readContract({address:s,abi:f,functionName:"balanceOf",args:[r]}):void 0;if(e==="force_exit"){let c=await R(t,h,s,r,T,B(i.maxPenaltyAssets),a),E=U(i.minAmountOut),w=[c.tx],v=await t.preview(w,r);return H(v.changes,s,T,E,a),{txs:w,preview:v,summary:`${L(c.plan,a.symbol)} ${v.summary}`}}let d=e==="mint",g=e==="redeem",l=U(d||g?i.shares:i.amount),x=await h.readContract({address:s,abi:f,functionName:d?"previewMint":g?"previewRedeem":"previewWithdraw",args:[l]});if(x<=0n||d&&x>U(i.maxAssets))throw new o("Vault quote is zero or exceeds maxAssets.");let q=d?void 0:await h.readContract({address:s,abi:f,functionName:"balanceOf",args:[r]});if(!d&&(g?l:x)>q)throw new o("The wallet share balance cannot cover this exit.");let Z=d?I({abi:f,functionName:"mint",args:[l,r]}):g?I({abi:f,functionName:"redeem",args:[l,r,r]}):I({abi:f,functionName:"withdraw",args:[l,r,r]}),G=`${e} ${l} ${d||g?"18-decimal share":`${a.decimals}-decimal ${a.symbol}`} base units on ${s}; beneficiary ${r}.`,M=[...d?[t.approval(a.address,s,x.toString(),A)]:[],t.unsignedTx({to:s,data:Z,value:"0",chainId:A,description:G})],S=await t.preview(M,r),p=(c,E)=>S.changes.filter(w=>w.token.chainId===A&&O(w.token.address,c)).reduce((w,v)=>{if(v.token.decimals!==E||!/^-?\d+$/.test(v.amount))throw new o("Invalid vault preview metadata.");return w+BigInt(v.amount)},0n);if(d?p(a.address,a.decimals)!==-x||p(s,18)!==l:g?p(s,18)!==-l||p(a.address,a.decimals)<=0n:p(a.address,a.decimals)!==l||-p(s,18)<=0n||-p(s,18)>q)throw new o("Vault preview does not match the requested amount and beneficiary.");return{txs:M,preview:S,summary:`${G} Counterpart quote ${x} base units. Mint approval is exact; accrual may require a fresh quote. Standard ERC-4626 calls encode no minimum receipt. ${S.summary}`}}catch(_){throw new o(t.plainError(_))}}}})}export{ce as a};
1
+ import{b as W,c as K}from"./7VU5VCTL.js";import{M as z}from"./DPSFR3ZS.js";import{a as D}from"./QKH7ED6B.js";import{c as C}from"./342OZP53.js";import{c as B,f as R,i as F,j as L,k as H}from"./IY7FWTAL.js";import{a as V}from"./43LI5NKJ.js";import{a as u}from"./66F5ZH34.js";import{g as O}from"./NWNYJ26T.js";import{b as A}from"./EWZFZUVF.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as I,erc20Abi as j,getAddress as P,parseAbi as k}from"viem";var f=k(["function asset() view returns (address)","function decimals() view returns (uint8)","function balanceOf(address) view returns (uint256)","function previewMint(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function mint(uint256 shares,address receiver) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256)"]);function U(t,n=!1){if(typeof t!="string"||!/^\d+$/.test(t)||t.length>78||BigInt(t)>=1n<<256n||!n&&BigInt(t)===0n)throw new o("Provide a positive uint256 decimal base-unit string.");return BigInt(t)}function ce(t,n,y){return["details","analytics","manage","mint",n==="netnet"?"redeem":"withdraw_assets","force_exit","in_kind_exit"].map(e=>{let $=[...n==="longbow"?["vault"]:[],...e==="mint"?["shares","maxAssets"]:e==="redeem"?["shares"]:e==="withdraw_assets"?["amount"]:e==="force_exit"?["maxPenaltyAssets","minAmountOut"]:[]],m={...n==="longbow"?{vault:{type:"string",enum:y.map(i=>i.vault),description:"Pinned vault address on chain 4663; use longbow_list to compare vault names."}}:{}};e==="in_kind_exit"&&(Object.assign(m,{amount:u(`Assets to receive, in base units of the vault's asset (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`),maxShares:u('Most vault shares you will burn, in share base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.'),maxPenaltyAssets:u(`Highest exit penalty you accept, in base units of the vault's asset (read its decimals). Example: "10000" = 0.01 USDG for a 6-decimal asset.`),deadline:u("Absolute Unix seconds deadline, no more than five minutes ahead. Example: 1800000000.")}),$.push("amount","maxShares","maxPenaltyAssets","deadline")),e==="mint"&&Object.assign(m,{shares:u('Vault shares to mint, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.'),maxAssets:u(`Most of the vault's asset you will pay, in base units (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`)}),e==="redeem"&&(m.shares=u('Vault shares to redeem, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.')),e==="withdraw_assets"&&(m.amount=u(`Assets to withdraw, in base units of the vault's asset (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`)),e==="force_exit"&&Object.assign(m,{maxPenaltyAssets:u(`Highest exit penalty you accept, in base units of the vault's asset (read its decimals). Example: "10000" = 0.01 USDG for a 6-decimal asset.`),minAmountOut:u(`Least of the vault's asset you must receive, in base units (read its decimals). Example: "1000000" = 1 USDG.`)});let J=C(t,`${n}_manage`,y[0].vault,y[0].asset),N=D(t,`${n}_analytics`,y[0].vault);if(e==="manage"||e==="analytics"){let i=e==="manage"?J.inputSchema:N.inputSchema;Object.assign(m,i.properties),e==="analytics"&&n==="longbow"&&(m.view={type:"string",enum:["apy","published_apy"],description:"Report: apy (realized yield from share price) or published_apy (yield published by the project)."}),$.push(...i.required)}return{name:`${n}_${e}`,inputSchema:{type:"object",properties:m,required:$,additionalProperties:!1,...e==="analytics"&&n==="netnet"?{allOf:N.inputSchema.allOf}:{}},execute:async(i,r)=>{try{if(V(r),Object.keys(i).some(c=>!Object.hasOwn(m,c)))throw new o("Unsupported vault feature argument.");let _=n==="netnet"?y[0]:y.find(c=>typeof i.vault=="string"&&O(c.vault,i.vault));if(!_)throw new o("Choose a current vault returned by the project list tool.");let{vault:s,asset:a}=_,b={...i};if(delete b.vault,e==="details")return F(t,`${n}_details`,s,a).execute(b,r);if(e==="manage")return C(t,`${n}_manage`,s,a).execute(b,r);if(e==="analytics"){if(n==="longbow"&&i.view==="published_apy")return K(t,s,a,b);if(n==="longbow"&&i.view==="apy")return W(t,s,a,b);if(n==="longbow")throw new o("Choose apy or published_apy; the Longbow vault is not indexed by Morpho for other analytics views.");return{...await D(t,`${n}_analytics`,s).execute(b,r),asset:{...a,address:P(a.address)}}}if(e==="in_kind_exit")return z(t,s,a,i,r);let h=t.clientFor(A);if(await h.getChainId()!==A)throw new o("Vault actions require chain 4663.");let[Q,X,Y]=await Promise.all([h.readContract({address:s,abi:f,functionName:"asset"}),h.readContract({address:s,abi:f,functionName:"decimals"}),h.readContract({address:a.address,abi:j,functionName:"decimals"})]);if(P(Q)!==P(a.address)||X!==18||Y!==a.decimals)throw new o("Vault metadata does not match the pinned asset and shares.");let T=e==="force_exit"?await h.readContract({address:s,abi:f,functionName:"balanceOf",args:[r]}):void 0;if(e==="force_exit"){let c=await R(t,h,s,r,T,B(i.maxPenaltyAssets),a),E=U(i.minAmountOut),w=[c.tx],v=await t.preview(w,r);return H(v.changes,s,T,E,a),{txs:w,preview:v,summary:`${L(c.plan,a.symbol)} ${v.summary}`}}let d=e==="mint",g=e==="redeem",l=U(d||g?i.shares:i.amount),x=await h.readContract({address:s,abi:f,functionName:d?"previewMint":g?"previewRedeem":"previewWithdraw",args:[l]});if(x<=0n||d&&x>U(i.maxAssets))throw new o("Vault quote is zero or exceeds maxAssets.");let q=d?void 0:await h.readContract({address:s,abi:f,functionName:"balanceOf",args:[r]});if(!d&&(g?l:x)>q)throw new o("The wallet share balance cannot cover this exit.");let Z=d?I({abi:f,functionName:"mint",args:[l,r]}):g?I({abi:f,functionName:"redeem",args:[l,r,r]}):I({abi:f,functionName:"withdraw",args:[l,r,r]}),G=`${e} ${l} ${d||g?"18-decimal share":`${a.decimals}-decimal ${a.symbol}`} base units on ${s}; beneficiary ${r}.`,M=[...d?[t.approval(a.address,s,x.toString(),A)]:[],t.unsignedTx({to:s,data:Z,value:"0",chainId:A,description:G})],S=await t.preview(M,r),p=(c,E)=>S.changes.filter(w=>w.token.chainId===A&&O(w.token.address,c)).reduce((w,v)=>{if(v.token.decimals!==E||!/^-?\d+$/.test(v.amount))throw new o("Invalid vault preview metadata.");return w+BigInt(v.amount)},0n);if(d?p(a.address,a.decimals)!==-x||p(s,18)!==l:g?p(s,18)!==-l||p(a.address,a.decimals)<=0n:p(a.address,a.decimals)!==l||-p(s,18)<=0n||-p(s,18)>q)throw new o("Vault preview does not match the requested amount and beneficiary.");return{txs:M,preview:S,summary:`${G} Counterpart quote ${x} base units. Mint approval is exact; accrual may require a fresh quote. Standard ERC-4626 calls encode no minimum receipt. ${S.summary}`}}catch(_){throw new o(t.plainError(_))}}}})}export{ce as a};
@@ -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{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};
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"./EWZFZUVF.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};