@oakagentkit/core 0.3.4 → 0.3.5

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 (247) hide show
  1. package/build/dist/api/history.js +1 -1
  2. package/build/dist/api/modules/borro/index.js +1 -1
  3. package/build/dist/api/modules/borro/positions.js +1 -1
  4. package/build/dist/api/modules/borro/reader.js +1 -1
  5. package/build/dist/api/modules/chop/actions.d.ts +13 -1
  6. package/build/dist/api/modules/chop/actions.js +1 -1
  7. package/build/dist/api/modules/chop/checks.js +1 -1
  8. package/build/dist/api/modules/chop/copy.d.ts +1 -0
  9. package/build/dist/api/modules/chop/copy.js +1 -1
  10. package/build/dist/api/modules/chop/display.d.ts +36 -0
  11. package/build/dist/api/modules/chop/display.js +1 -0
  12. package/build/dist/api/modules/chop/guard.js +1 -1
  13. package/build/dist/api/modules/chop/index.js +1 -1
  14. package/build/dist/api/modules/chop/pins.d.ts +1 -0
  15. package/build/dist/api/modules/chop/pins.js +1 -1
  16. package/build/dist/api/modules/chop/positions.js +1 -1
  17. package/build/dist/api/modules/chop/reader.d.ts +6 -1
  18. package/build/dist/api/modules/chop/reader.js +1 -1
  19. package/build/dist/api/modules/chop/types.d.ts +7 -0
  20. package/build/dist/api/modules/chop/unfarm.d.ts +16 -0
  21. package/build/dist/api/modules/chop/unfarm.js +1 -0
  22. package/build/dist/api/modules/clanker/index.js +1 -1
  23. package/build/dist/api/modules/earn/index.js +1 -1
  24. package/build/dist/api/modules/erc8004/index.js +1 -1
  25. package/build/dist/api/modules/factor/actions.js +1 -1
  26. package/build/dist/api/modules/factor/api.js +1 -1
  27. package/build/dist/api/modules/factor/checks.js +1 -1
  28. package/build/dist/api/modules/factor/copy.d.ts +11 -11
  29. package/build/dist/api/modules/factor/copy.js +1 -1
  30. package/build/dist/api/modules/factor/guard.js +1 -1
  31. package/build/dist/api/modules/factor/index.js +1 -1
  32. package/build/dist/api/modules/factor/reader.js +1 -1
  33. package/build/dist/api/modules/fobo/client.js +1 -1
  34. package/build/dist/api/modules/fobo/index.js +1 -1
  35. package/build/dist/api/modules/gloam/index.js +1 -1
  36. package/build/dist/api/modules/grove/index.js +1 -1
  37. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  38. package/build/dist/api/modules/heyresearch/index.js +1 -1
  39. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  40. package/build/dist/api/modules/heyresearch/scan.js +1 -1
  41. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  42. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  43. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  44. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  45. package/build/dist/api/modules/hoodlock/index.js +1 -1
  46. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  47. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  48. package/build/dist/api/modules/hoodlock/public.js +1 -1
  49. package/build/dist/api/modules/hookr/actions.js +1 -1
  50. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  51. package/build/dist/api/modules/hookr/discovery.js +1 -1
  52. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  53. package/build/dist/api/modules/hookr/index.js +1 -1
  54. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  55. package/build/dist/api/modules/hookr/launch.js +1 -1
  56. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  57. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  58. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  59. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  60. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  61. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  62. package/build/dist/api/modules/hookr/relay.js +1 -1
  63. package/build/dist/api/modules/layerbank/actions.js +1 -1
  64. package/build/dist/api/modules/layerbank/index.js +1 -1
  65. package/build/dist/api/modules/layerbank/reader.js +1 -1
  66. package/build/dist/api/modules/longbow/administration.js +1 -1
  67. package/build/dist/api/modules/longbow/fixed.js +1 -1
  68. package/build/dist/api/modules/longbow/index.js +1 -1
  69. package/build/dist/api/modules/meridian/index.js +1 -1
  70. package/build/dist/api/modules/merkl/discovery.js +1 -1
  71. package/build/dist/api/modules/merkl/index.js +1 -1
  72. package/build/dist/api/modules/merkl/manage.js +1 -1
  73. package/build/dist/api/modules/morpho/bundles.js +1 -1
  74. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  75. package/build/dist/api/modules/morpho/index.js +1 -1
  76. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  77. package/build/dist/api/modules/morpho/midnight.js +1 -1
  78. package/build/dist/api/modules/morpho/protocol.js +1 -1
  79. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  80. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  81. package/build/dist/api/modules/netnet/card-read.js +1 -1
  82. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  83. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  84. package/build/dist/api/modules/netnet/financial.js +1 -1
  85. package/build/dist/api/modules/netnet/index.js +1 -1
  86. package/build/dist/api/modules/pendle/index.js +1 -1
  87. package/build/dist/api/modules/pendle/reader.js +1 -1
  88. package/build/dist/api/modules/pendle/trade.js +1 -1
  89. package/build/dist/api/modules/pons/index.js +1 -1
  90. package/build/dist/api/modules/priors/coverage.js +1 -1
  91. package/build/dist/api/modules/priors/discovery.js +1 -1
  92. package/build/dist/api/modules/priors/index.js +1 -1
  93. package/build/dist/api/modules/priors/integration.js +1 -1
  94. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  95. package/build/dist/api/modules/raeto/index.js +1 -1
  96. package/build/dist/api/modules/relay/index.js +1 -1
  97. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  98. package/build/dist/api/modules/spark/index.js +1 -1
  99. package/build/dist/api/modules/steakhouse/index.js +1 -1
  100. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  101. package/build/dist/api/modules/steakhouse/management.js +1 -1
  102. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  103. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  104. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  105. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  106. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  107. package/build/dist/api/modules/tickerspring/index.js +1 -1
  108. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  109. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  110. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  111. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  112. package/build/dist/api/modules/tickerspring/research.js +1 -1
  113. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  114. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  115. package/build/dist/api/modules/uniswap/auction.js +1 -1
  116. package/build/dist/api/modules/uniswap/batch.js +1 -1
  117. package/build/dist/api/modules/uniswap/common.js +1 -1
  118. package/build/dist/api/modules/uniswap/fees.js +1 -1
  119. package/build/dist/api/modules/uniswap/index.js +1 -1
  120. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  121. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  122. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  123. package/build/dist/api/modules/uniswap/pools.js +1 -1
  124. package/build/dist/api/modules/uniswap/position.js +1 -1
  125. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  126. package/build/dist/api/modules/uniswap/quote-guard.js +1 -1
  127. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  128. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  129. package/build/dist/api/modules/uniswap/trade.js +1 -1
  130. package/build/dist/api/modules/uniswap/v2.js +1 -1
  131. package/build/dist/api/modules/uniswap/v3.js +1 -1
  132. package/build/dist/api/modules/uniswap/v4.js +1 -1
  133. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  134. package/build/dist/api/modules/upoch/index.js +1 -1
  135. package/build/dist/api/modules/upoch/reads.js +1 -1
  136. package/build/dist/api/modules/wormhole/index.js +1 -1
  137. package/build/dist/api/prices.d.ts +5 -0
  138. package/build/dist/api/prices.js +1 -1
  139. package/build/dist/api/send.js +1 -1
  140. package/build/dist/api/signing-registry.js +1 -1
  141. package/build/dist/api/tokens.d.ts +1 -0
  142. package/build/dist/api/tokens.js +1 -1
  143. package/build/dist/api/usd-estimate.d.ts +2 -0
  144. package/build/dist/api/usd-estimate.js +1 -1
  145. package/build/dist/chunks/{UBVE2U6X.js → 2FOI2625.js} +1 -1
  146. package/build/dist/chunks/{5OTQCE2E.js → 2I7XHRTI.js} +1 -1
  147. package/build/dist/chunks/{SGHSCK22.js → 2PS4GCOZ.js} +1 -1
  148. package/build/dist/chunks/3BQ5XHDJ.js +1 -0
  149. package/build/dist/chunks/{PRBIC3UK.js → 3YH5B5NQ.js} +1 -1
  150. package/build/dist/chunks/{RUSXMQSJ.js → 4HQEJHCD.js} +1 -1
  151. package/build/dist/chunks/{ZFRTBBIW.js → 4IOHSX3Z.js} +1 -1
  152. package/build/dist/chunks/5H7NVE6O.js +1 -0
  153. package/build/dist/chunks/{JJGZ7W3V.js → 6AS3TGOX.js} +1 -1
  154. package/build/dist/chunks/{RK3PPFRX.js → 6CKCZJ3F.js} +1 -1
  155. package/build/dist/chunks/{HU2JXDLH.js → 6LVHN33V.js} +1 -1
  156. package/build/dist/chunks/7OOCAZBE.js +1 -0
  157. package/build/dist/chunks/{O3XWE4FO.js → 7TRO6MBQ.js} +1 -1
  158. package/build/dist/chunks/{WX7OYCNS.js → A4FLWHLP.js} +1 -1
  159. package/build/dist/chunks/{FP7DHVK2.js → A4K5GXVO.js} +1 -1
  160. package/build/dist/chunks/{AOX6DKYU.js → AL6UXNGH.js} +1 -1
  161. package/build/dist/chunks/{FQTO7VJG.js → C57DITTF.js} +1 -1
  162. package/build/dist/chunks/{ZTX4WT62.js → CFPJDLTZ.js} +1 -1
  163. package/build/dist/chunks/{SRHVSNPX.js → CNDIAF3P.js} +1 -1
  164. package/build/dist/chunks/{LEHBRAZX.js → CW37EGPL.js} +1 -1
  165. package/build/dist/chunks/{PQG3ULRT.js → DBOGRUPS.js} +1 -1
  166. package/build/dist/chunks/{T3QEN3S6.js → E47UYYK4.js} +1 -1
  167. package/build/dist/chunks/EPOIAXCV.js +3 -0
  168. package/build/dist/chunks/{DWQJ7NSX.js → FCVH4FYH.js} +1 -1
  169. package/build/dist/chunks/{V6EVQWAL.js → FHB7QYJO.js} +1 -1
  170. package/build/dist/chunks/FRT6AC6M.js +1 -0
  171. package/build/dist/chunks/{Z5YI6KLN.js → FRVCSDKU.js} +1 -1
  172. package/build/dist/chunks/{EIE2U4OX.js → G5AMH4IP.js} +1 -1
  173. package/build/dist/chunks/{EQEMI54U.js → GDUKZYE2.js} +1 -1
  174. package/build/dist/chunks/{GNOHIL4Q.js → GKUPC4DO.js} +1 -1
  175. package/build/dist/chunks/{K7HTDKAT.js → GMMTHTCP.js} +1 -1
  176. package/build/dist/chunks/{XHFAF5PZ.js → HDBZZOHJ.js} +1 -1
  177. package/build/dist/chunks/{Q4HSQL65.js → HPS4KOU4.js} +1 -1
  178. package/build/dist/chunks/IZP3EKKS.js +1 -0
  179. package/build/dist/chunks/{P6MPKIU2.js → J7OZLXSG.js} +1 -1
  180. package/build/dist/chunks/{PXUML7HJ.js → JDHPMS7X.js} +1 -1
  181. package/build/dist/chunks/{MOZBDCVV.js → JJSCDDQO.js} +1 -1
  182. package/build/dist/chunks/{EFESPGA2.js → KCZUJ57H.js} +1 -1
  183. package/build/dist/chunks/{2ILYVUFA.js → KKTOBXIT.js} +1 -1
  184. package/build/dist/chunks/{L6CVMDWQ.js → KO7ANIKY.js} +1 -1
  185. package/build/dist/chunks/{2T6O77QZ.js → LKUZAJPZ.js} +1 -1
  186. package/build/dist/chunks/{5GQJVKVY.js → LZM3DO5Q.js} +1 -1
  187. package/build/dist/chunks/M6JNGU4E.js +1 -0
  188. package/build/dist/chunks/{MEB727X5.js → M7OVMIIE.js} +1 -1
  189. package/build/dist/chunks/{RKM62HC5.js → MJGEGNDU.js} +1 -1
  190. package/build/dist/chunks/{SYERFEJ4.js → MQXSCNUL.js} +1 -1
  191. package/build/dist/chunks/N624NR7Y.js +1 -0
  192. package/build/dist/chunks/{X3YEDVRN.js → N65J3L2H.js} +1 -1
  193. package/build/dist/chunks/{2TX7HP6M.js → N742W5KX.js} +1 -1
  194. package/build/dist/chunks/{365B4YEV.js → NIWAVMDR.js} +1 -1
  195. package/build/dist/chunks/O2QBSINK.js +1 -0
  196. package/build/dist/chunks/{FA3GBXQP.js → O4P5IQCP.js} +1 -1
  197. package/build/dist/chunks/{HUKDISRE.js → OB3YMTDI.js} +1 -1
  198. package/build/dist/chunks/{WXZ4LAKO.js → PV7FEVBD.js} +1 -1
  199. package/build/dist/chunks/{4M6XBG6X.js → Q3Q3YHEX.js} +1 -1
  200. package/build/dist/chunks/QA6Z2CYP.js +2 -0
  201. package/build/dist/chunks/{BDLV42SD.js → QBNASL3T.js} +1 -1
  202. package/build/dist/chunks/{AHUCYDBC.js → QKIQ7ZKD.js} +1 -1
  203. package/build/dist/chunks/{7FYM7FJA.js → QMIH6HXH.js} +1 -1
  204. package/build/dist/chunks/{2QP6WGKZ.js → QQD4PV64.js} +1 -1
  205. package/build/dist/chunks/{KNBNKG7P.js → R66NSNNQ.js} +1 -1
  206. package/build/dist/chunks/{VQJXQLFW.js → RP5VCG54.js} +1 -1
  207. package/build/dist/chunks/{OKXKDDBX.js → RUHNLNVX.js} +1 -1
  208. package/build/dist/chunks/{VKNKVUAA.js → S37D7HOK.js} +1 -1
  209. package/build/dist/chunks/S47M3IPR.js +1 -0
  210. package/build/dist/chunks/S65KXMZ7.js +3 -0
  211. package/build/dist/chunks/{NYHKIXJR.js → SX5YNFHG.js} +1 -1
  212. package/build/dist/chunks/{MHONMLF6.js → TGXEKBLV.js} +1 -1
  213. package/build/dist/chunks/{VHK5AYC2.js → TJU644I7.js} +1 -1
  214. package/build/dist/chunks/{O56EZB5Y.js → TOIKOIY6.js} +1 -1
  215. package/build/dist/chunks/{YR44GQG4.js → TZ7S5KRB.js} +1 -1
  216. package/build/dist/chunks/UEOS6SHR.js +1 -0
  217. package/build/dist/chunks/{USZCTSPI.js → USGMGKAG.js} +1 -1
  218. package/build/dist/chunks/{W5FM2OVB.js → UUF4Z6K6.js} +1 -1
  219. package/build/dist/chunks/{PMFR47H3.js → VREGY7E6.js} +1 -1
  220. package/build/dist/chunks/{2YYKQGJZ.js → W7BFM6CK.js} +1 -1
  221. package/build/dist/chunks/{3D7FXI6G.js → WQ2XTDHO.js} +1 -1
  222. package/build/dist/chunks/WRA3ZC6W.js +1 -0
  223. package/build/dist/chunks/{K3TZYPSV.js → XADHV2DT.js} +1 -1
  224. package/build/dist/chunks/{LVFI74ST.js → XNJ6NDQQ.js} +1 -1
  225. package/build/dist/chunks/{DD47RZFU.js → XTXXWRN2.js} +1 -1
  226. package/build/dist/chunks/{CZ66MYKR.js → XWC6IC5E.js} +1 -1
  227. package/build/dist/chunks/{DMB64UIN.js → YWVPK3DV.js} +1 -1
  228. package/build/dist/chunks/{WNWRF4HE.js → YZHJ4BAP.js} +1 -1
  229. package/build/dist/chunks/{4PB6MSGZ.js → ZKBOPZH5.js} +1 -1
  230. package/build/dist/chunks/{5ZVIAGLX.js → ZQPC54J5.js} +1 -1
  231. package/build/dist/chunks/{HDBDBKEA.js → ZVY7GGSP.js} +1 -1
  232. package/build/dist/chunks/{LQSPWRHN.js → ZX43P4BK.js} +1 -1
  233. package/build/dist/chunks/{PQOWIRKQ.js → ZXFJKW6H.js} +1 -1
  234. package/build/dist/chunks/{N6PHSHBE.js → ZXRIJG6H.js} +1 -1
  235. package/package.json +1 -1
  236. package/build/dist/chunks/3AOTYJPX.js +0 -1
  237. package/build/dist/chunks/4E7FJQLL.js +0 -1
  238. package/build/dist/chunks/4J245N3F.js +0 -1
  239. package/build/dist/chunks/BA66J5YQ.js +0 -1
  240. package/build/dist/chunks/BIY2F6MO.js +0 -1
  241. package/build/dist/chunks/DGCJZ3HO.js +0 -1
  242. package/build/dist/chunks/DHX3Q5RV.js +0 -2
  243. package/build/dist/chunks/EFUACKDK.js +0 -1
  244. package/build/dist/chunks/JW7GLNLB.js +0 -3
  245. package/build/dist/chunks/MIKQWF6Q.js +0 -3
  246. package/build/dist/chunks/P7C3TYI4.js +0 -1
  247. package/build/dist/chunks/ZNX3YVF2.js +0 -1
@@ -1 +1 @@
1
- import{c as Te,d as $e,e as be,f as ie,i as ke,j as Me}from"./P7C3TYI4.js";import{b as ne,o as we}from"./GYPMUYB5.js";import{a as F,b as ge}from"./43LI5NKJ.js";import{a as Ne}from"./IOYRL6AY.js";import{b as z,d as Ue}from"./IX3GZMTM.js";import{b as y,j as O}from"./TI727O2H.js";import{a,b as me,e as q}from"./XSD5NL7J.js";import{decodeFunctionResult as ve,encodeFunctionData as B,getAddress as m,parseAbi as J,zeroAddress as $}from"viem";var re=-887272,se=887272,G=(1n<<128n)-1n,je="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",Ke="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",Qe="0x3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f",oe=2000n,Ye=5,Le=64n,Ze=1800n,Be="^v3:(0x[0-9a-fA-F]{40}):(0|[1-9][0-9]{0,19}):(0|[1-9][0-9]{0,19})$",Je=new RegExp(Be),et=Object.freeze({type:"string",pattern:Be,description:"v3 only. Pass the nextCursor of the previous page to read the next 64 owner indices at the same block. Cannot be combined with tokenIds."}),w=Object.freeze({factory:m(O[4663].uniswap.v3_factory.address),positionManager:m(O[4663].uniswap.v3_position_manager.address),swapRouter02:m(O[4663].uniswap.swap_router02.address),permit2:m(O[4663].uniswap.permit2.address),weth:m(O[4663].uniswap.WETH.address),usdg:m(O[4663].uniswap.USDG.address),ethUsdgPool:m(O[4663].oracle.ethUsdgPool.address)}),Pe=Object.freeze({100:1,500:10,3e3:60,1e4:200}),qt=Object.freeze([{fee:100,tickSpacing:1,address:m("0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"),token0:w.weth,token1:w.usdg,recordedLiquidity:"1957537485734736219",recordedSqrtPriceX96:"3839219776288481168641554",recordedTick:-198707,feeProtocol:68},{fee:500,tickSpacing:10,address:m("0x69bfaf19c9f377bb306a89aed9f6b07e2c1a8d9a"),token0:w.weth,token1:w.usdg,recordedLiquidity:"714542894544667104",recordedSqrtPriceX96:"3839644024453020182443671",recordedTick:-198705,feeProtocol:68},{fee:3e3,tickSpacing:60,address:m("0xa9188730fe85be88ad499d7d52b099e800fb0334"),token0:w.weth,token1:w.usdg,recordedLiquidity:"310559629687003603",recordedSqrtPriceX96:"3843235825752878635548672",recordedTick:-198686,feeProtocol:102},{fee:1e4,tickSpacing:200,address:m("0x5f009e071f07e92b6c624e83f52f17bbda34680d"),token0:w.weth,token1:w.usdg,recordedLiquidity:"5822966536584155",recordedSqrtPriceX96:"3853297838190389678059735",recordedTick:-198634,feeProtocol:102}]),P=J(["function positions(uint256 tokenId) view returns (uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1)","function ownerOf(uint256 tokenId) view returns (address)","function balanceOf(address owner) view returns (uint256)","function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)","function mint((address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline) params) payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)","function increaseLiquidity((uint256 tokenId, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint128 liquidity, uint256 amount0, uint256 amount1)","function decreaseLiquidity((uint256 tokenId, uint128 liquidity, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint256 amount0, uint256 amount1)","function collect((uint256 tokenId, address recipient, uint128 amount0Max, uint128 amount1Max) params) payable returns (uint256 amount0, uint256 amount1)","function burn(uint256 tokenId) payable","function createAndInitializePoolIfNecessary(address token0, address token1, uint24 fee, uint160 sqrtPriceX96) payable returns (address pool)"]),Y=J(["function getPool(address tokenA, address tokenB, uint24 fee) view returns (address pool)","function feeAmountTickSpacing(uint24 fee) view returns (int24)"]),he=J(["function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)","function liquidity() view returns (uint128)","function tickSpacing() view returns (int24)","function fee() view returns (uint24)","function token0() view returns (address)","function token1() view returns (address)"]),tt=J(["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)"]),xe=J(["function decimals() view returns (uint8)","function symbol() view returns (string)","function allowance(address owner, address spender) view returns (uint256)"]),nt="0xd0e30db0";function it(t){if(typeof t!="string")return!1;let e=t.trim().toLowerCase();return e===$||e===je||e==="eth"||e==="native"}function D(t,e){if(it(t))throw new a(`Uniswap v3 requires wrapped ERC-20 WETH (${w.weth}) rather than native ETH in ${e}.`);if(typeof t!="string")throw new a(`${e} must be a valid 20-byte hex address.`);return F(t),m(t)}function ot(t,e,n){let s=Number(t),o=Number(e),i=Number(n);if(!Number.isInteger(i)||i<=0)throw new a("Uniswap v3 tickSpacing must be a positive integer.");if(!Number.isInteger(s)||!Number.isInteger(o))throw new a("Uniswap v3 tickLower and tickUpper must be integers.");if(s<re||o>se||s>se||o<re)throw new a(`Uniswap v3 ticks are out of bounds [${re}, ${se}].`);if(s>=o)throw new a("Uniswap v3 tickLower must be strictly less than tickUpper.");if(s%i!==0||o%i!==0)throw new a(`Uniswap v3 tickLower (${s}) and tickUpper (${o}) must be divisible by tickSpacing (${i}).`);return{tickLower:s,tickUpper:o,tickSpacing:i}}function rt(t,e){let n=t.trim(),s=n.startsWith("-"),o=s||n.startsWith("+")?n.slice(1):n,i=Ue(z(o).toString(),e);return s&&i!=="0"?`-${i}`:i}function st(t){let e=typeof t=="string"?ve({abi:P,functionName:"positions",data:t}):t;return{nonce:BigInt(e[0]),operator:m(String(e[1])),token0:m(String(e[2])),token1:m(String(e[3])),fee:Number(e[4]),tickLower:Number(e[5]),tickUpper:Number(e[6]),liquidity:BigInt(e[7]),feeGrowthInside0LastX128:BigInt(e[8]),feeGrowthInside1LastX128:BigInt(e[9]),tokensOwed0:BigInt(e[10]),tokensOwed1:BigInt(e[11])}}function Re(t,e){if(!t||!Array.isArray(t.logs))return[];let n=e?m(e).toLowerCase():void 0,s=w.positionManager.toLowerCase(),o=new Set;for(let i of t.logs){if(!i||typeof i.address!="string"||i.address.toLowerCase()!==s)continue;let c=Array.isArray(i.topics)?i.topics.map(p=>String(p).toLowerCase()):[],r=c[0];if(r===Ke&&c.length>=4){let d=`0x${c[2].slice(-40)}`;if(!n||d===n){let u=BigInt(c[3]).toString();u!=="0"&&o.add(u)}}else if(r===Qe&&c.length>=2&&!n){let p=BigInt(c[1]).toString();p!=="0"&&o.add(p)}}return[...o]}function Ut(t){let e=n=>typeof n=="bigint"?n:z(n);return B({abi:tt,functionName:"exactInputSingle",args:[{tokenIn:m(t.tokenIn),tokenOut:m(t.tokenOut),fee:t.fee,recipient:m(t.recipient),amountIn:e(t.amountIn),amountOutMinimum:e(t.amountOutMinimum),sqrtPriceLimitX96:t.sqrtPriceLimitX96!==void 0?e(t.sqrtPriceLimitX96):0n}]})}var Ee=1n<<96n;function _e(t){let e=Math.abs(t),n=(e&1)!==0?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;return(e&2)!==0&&(n=n*0xfff97272373d413259a46990580e213an>>128n),(e&4)!==0&&(n=n*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(e&8)!==0&&(n=n*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(e&16)!==0&&(n=n*0xffcb9843d60f6159c9db58835c926644n>>128n),(e&32)!==0&&(n=n*0xff973b41fa98c081472e6896dfb254c0n>>128n),(e&64)!==0&&(n=n*0xff2ea16466c96a3843ec78b326b52861n>>128n),(e&128)!==0&&(n=n*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(e&256)!==0&&(n=n*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(e&512)!==0&&(n=n*0xf987a7253ac413176f2b074cf7815e54n>>128n),(e&1024)!==0&&(n=n*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(e&2048)!==0&&(n=n*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(e&4096)!==0&&(n=n*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(e&8192)!==0&&(n=n*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(e&16384)!==0&&(n=n*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(e&32768)!==0&&(n=n*0x31be135f97d08fd981231505542fcfa6n>>128n),(e&65536)!==0&&(n=n*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(e&131072)!==0&&(n=n*0x5d6af8dedb81196699c329225ee604n>>128n),(e&262144)!==0&&(n=n*0x2216e584f5fa1ea926041bedfe98n>>128n),(e&524288)!==0&&(n=n*0x48a170391f7dc42444e8fa2n>>128n),t>0&&(n=((1n<<256n)-1n)/n),(n>>32n)+(n%(1n<<32n)===0n?0n:1n)}function at(t,e,n,s){if(s<=0n)return{amount0:0n,amount1:0n};let[o,i]=e<n?[e,n]:[n,e];if(t<=o)return{amount0:(s<<96n)*(i-o)/i/o,amount1:0n};if(t<i){let r=(s<<96n)*(i-t)/i/t,p=s*(t-o)/Ee;return{amount0:r,amount1:p}}return{amount0:0n,amount1:s*(i-o)/Ee}}async function M(t,e,n,s){let o=m(e),i,c;if(n===y&&o===w.weth?(i=18,c="WETH"):n===y&&o===w.usdg&&(i=6,c="USDG"),i===void 0){let r=await t.readContract({address:o,abi:xe,functionName:"decimals"});i=Number(r)}if(c===void 0)try{let r=await t.readContract({address:o,abi:xe,functionName:"symbol"});if(typeof r!="string"||!r.trim())throw new a("Token symbol is unavailable.");c=Me(r.trim(),o)}catch(r){throw new a(`Could not read token metadata. ${q(r)}`)}if(!Number.isInteger(i)||i<0||i>255)throw new a("Token decimals are invalid.");if(s!=null){let r=Number(s);if(!Number.isInteger(r)||r!==i)throw new a(`Token ${o} on chain ${n} has ${i} decimals, not ${String(s)}.`)}return{address:o,symbol:c,decimals:i,chainId:n}}async function ct(t){try{if(!t.getBlock)throw new a("Block timestamps are unavailable.");let e=await t.getBlock();if(typeof e.timestamp!="bigint")throw new a("Invalid block timestamp.");return e.timestamp}catch(e){throw new a(`Could not read the current block timestamp. ${q(e)}`)}}function ee(t,e){if(typeof t=="bigint"){if(t<0n)throw new a(`${e} must be a non-negative integer.`);return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<0)throw new a(`${e} must be a non-negative integer.`);return BigInt(t)}if(typeof t=="string")return z(t);throw new a(`${e} must be a non-negative integer.`)}async function Oe(t,e){let n=await ct(t);if(e==null)return n+Ze;let s=ee(e,"deadline");if(s<=n)throw new a(`Uniswap v3 deadline (${s.toString()}) has expired at timestamp ${n.toString()}.`);return s}function W(t,e){if(typeof t!="string"||!/^\d+$/.test(t))throw new a(`${e} must be a non-negative integer string in base units.`);return z(t)}function De(t){let e=t.slippageBps??ne;if(typeof e!="number")throw new a("Slippage must be an integer from 0 to 9999 bps.");return we("0",e),e}function ae(t,e,n,s){let o=t===void 0?z(we(e.toString(),n)):W(t,s);if(o<=1n)throw new a(`${s} must exceed 1 base unit; the simulated amount may be too small.`);return o}function H(t,e){return ge({to:w.positionManager,data:t,value:"0",chainId:y,description:e})}async function Z(t,e,n){try{if(!t.request)throw new a("Sequential transaction simulation is unavailable.");let o=await t.request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:e.map(i=>({from:n,gas:`0x${Ne.toString(16)}`,to:i.to,data:i.data,value:`0x${BigInt(i.value).toString(16)}`}))}],validation:!1,traceTransfers:!0},"latest"]},{retryCount:0});if(!Array.isArray(o)||o.length!==1||!Array.isArray(o[0]?.calls)||o[0].calls.length!==e.length)throw new a("Unexpected batch simulation response.");return o[0].calls.map((i,c)=>{if(i.status!=="0x1"||i.error||typeof i.returnData!="string"||!/^0x([a-fA-F0-9]{2})*$/.test(i.returnData))throw new a(`Simulation call ${c+1} failed. ${q(i.error)}`);return i.returnData})}catch(s){throw new a(`Uniswap v3 simulation failed. ${q(s)}`)}}function ce(t,e){try{return ve({abi:P,functionName:t,data:e})}catch{throw new a(`Uniswap v3 ${t} simulation returned invalid amounts.`)}}function Ve(t,e,n){if(t.initialPrice!==void 0&&t.sqrtPriceX96!==void 0)throw new a("Provide initialPrice or sqrtPriceX96, not both.");if(t.sqrtPriceX96!==void 0){if(typeof t.sqrtPriceX96!="string"||!/^\d+$/.test(t.sqrtPriceX96))throw new a("sqrtPriceX96 must be a non-negative integer string.");return $e(BigInt(t.sqrtPriceX96))}if(t.initialPrice===void 0)throw new a("A new pool needs initialPrice (token1 per 1 token0, human units) or sqrtPriceX96.");return Te(t.initialPrice,e,n)}async function Xe(t,e,n,s){let o=[];for(let i of Object.keys(Pe).map(Number)){if(i===s)continue;let c=m(String(await t.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[e,n,i]})));if(c===$||BigInt(await t.readContract({address:c,abi:he,functionName:"liquidity"}))===0n)continue;let p=await t.readContract({address:c,abi:he,functionName:"slot0"});o.push({label:`v3 fee ${i} pool ${c}`,sqrtPriceX96:BigInt(p[0])})}return o}function j(t,e={}){if(e.chainId!==void 0&&Number(e.chainId)!==y)throw new a(`Uniswap v3 is only supported on Robinhood Chain (${y}).`);if(e.version!==void 0&&e.version!=="v3")throw new a(`Uniswap v3 handler received unsupported version "${String(e.version)}".`);let n=t.clientFor(y);return{...n,readContract:async s=>{try{return await n.readContract(s)}catch(o){throw new a(`Could not read Uniswap v3 ${s.functionName}. ${q(o)}`,{cause:o})}}}}async function Ie(t,e,n){let s;try{s=await t.readContract({address:w.positionManager,abi:P,functionName:"ownerOf",args:[e]})}catch(c){throw new a(`Could not verify owner of Uniswap v3 position #${e}. ${q(c)}`)}let o=m(String(s)),i=m(n);if(o!==i)throw new a(`Wallet ${i} is not the owner of Uniswap v3 position #${e.toString()} (owned by ${o}).`);return o}async function de(t,e){let n=await t.readContract({address:w.positionManager,abi:P,functionName:"positions",args:[e]});return st(n)}function Se(t,e){if(!Array.isArray(e.changes)||!e.changes.length)return t;let n=e.changes.map(s=>`${rt(s.amount,s.token.decimals)} ${s.token.symbol}`);return`${t} (${n.join(", ")})`}async function dt(t,e,n){F(n);let s=m(n),o=j(t,e),i=await Oe(o,e.deadline),c=De(e),r=e.tokenId===void 0?void 0:ee(e.tokenId,"tokenId"),p;if(r!==void 0){if(r<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,r,s),p=await de(o,r)}let d=p?.token0??D(e.token0,"token0"),u=p?.token1??D(e.token1,"token1");if(BigInt(d)>=BigInt(u))throw new a("Uniswap v3 requires distinct sorted token addresses.");let g=p?.fee??Number(e.fee??100),f=Pe[g];if(!f)throw new a("Unsupported Uniswap v3 fee tier.");let b=m(String(await o.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[d,u,g]}))),l=e.initialPrice!==void 0||e.sqrtPriceX96!==void 0;if(b===$&&!l)throw new a("No Uniswap v3 pool exists for these tokens and fee tier. To create it and add the first liquidity in one tool call with separately confirmed transactions, add initialPrice (token1 per 1 token0, human units) to this call; to create it without liquidity use uniswap_create_pool.");if(b!==$&&l)throw new a(`The Uniswap v3 pool already exists at ${b}; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);if(r!==void 0&&l)throw new a("initialPrice cannot be combined with tokenId.");if(e.fullRange!==void 0&&typeof e.fullRange!="boolean")throw new a("fullRange must be a boolean.");if(e.fullRange===!0&&(e.tickLower!==void 0||e.tickUpper!==void 0||p))throw new a("Use fullRange only for a new position, without explicit ticks. Existing position ticks cannot change.");let{tickLower:k,tickUpper:U,tickSpacing:A}=ot(p?.tickLower??(e.fullRange===!0?Math.ceil(re/f)*f:e.tickLower),p?.tickUpper??(e.fullRange===!0?Math.floor(se/f)*f:e.tickUpper),f),v=await M(o,d,y,e.token0Decimals),h=await M(o,u,y,e.token1Decimals),C;if(b===$){let T=Ve(e,v.decimals,h.decimals),_=ke(T,await Xe(o,d,u,g),e.acceptPriceDeviation===!0,v.decimals,h.decimals);C={sqrtPriceX96:T,note:_}}let I=W(e.amount0Desired,"amount0Desired"),S=W(e.amount1Desired,"amount1Desired");if(I===0n&&S===0n)throw new a("Liquidity addition requires a positive desired amount.");let x=e.recipient===void 0?s:D(e.recipient,"recipient");if(x!==s)throw new a("Uniswap recipient must be the signing wallet.");if(e.wrapNative===!0&&d!==w.weth&&u!==w.weth)throw new a("Wrapping requires a positive WETH desired amount.");let V=await Promise.all([d,u].map(async T=>BigInt(await o.readContract({address:T,abi:xe,functionName:"allowance",args:[s,w.positionManager]})))),X=(T,_)=>{let pe=[];if(e.wrapNative===!0){let Q=d===w.weth?T:_;Q>0n&&pe.push(ge({to:w.weth,data:nt,value:Q.toString(),chainId:y,description:"Wrap ETH into WETH."}))}for(let[Q,Ge]of[d,u].entries()){let fe=Q===0?T:_;fe>0n&&V[Q]<fe&&pe.push(t.approval(Ge,w.positionManager,fe.toString(),y))}return pe},L=r===void 0?"mint":"increaseLiquidity",R=(T,_)=>H(r===void 0?B({abi:P,functionName:"mint",args:[{token0:d,token1:u,fee:g,tickLower:k,tickUpper:U,amount0Desired:I,amount1Desired:S,amount0Min:T,amount1Min:_,recipient:x,deadline:i}]}):B({abi:P,functionName:"increaseLiquidity",args:[{tokenId:r,amount0Desired:I,amount1Desired:S,amount0Min:T,amount1Min:_,deadline:i}]}),`${L==="mint"?"Mint":"Increase"} Uniswap v3 ${v.symbol}/${h.symbol} liquidity.`),E=C&&H(B({abi:P,functionName:"createAndInitializePoolIfNecessary",args:[d,u,g,C.sqrtPriceX96]}),`Create and initialize the Uniswap v3 ${v.symbol}/${h.symbol} fee ${g} pool at ${ie(C.sqrtPriceX96,v.decimals,h.decimals)} ${h.symbol} per ${v.symbol}.`),K=E?[E]:[],Ae=await Z(o,[...K,...X(I,S),R(0n,0n)],s),N=ce(L,Ae[Ae.length-1]),We=N[N.length-2],ze=N[N.length-1];if(We>I||ze>S)throw new a("Simulated liquidity spend exceeds the desired amounts.");let te=[...K,...X(I,S)],ue=ae(e.amount0Min,N[N.length-2],c,"amount0Min"),le=ae(e.amount1Min,N[N.length-1],c,"amount1Min");if(ue>I||le>S)throw new a("Uniswap v3 minimum amount cannot exceed desired amount.");let Ce=R(ue,le);te.push(Ce);for(let[T,_]of[d,u].entries())(T===0?I:S)>0n&&te.push(t.approval(_,w.positionManager,"0",y));let qe=await t.preview(te,s);return{txs:te,preview:qe,summary:Se(Ce.description,qe),details:{version:"v3",action:L,...r===void 0?{}:{tokenId:r.toString()},pool:b===$?null:b,fee:g,tickSpacing:A,tickLower:k,tickUpper:U,token0:v,token1:h,amount0Desired:I.toString(),amount1Desired:S.toString(),amount0Min:ue.toString(),amount1Min:le.toString(),deadline:i.toString(),recipient:x,expectedAmount0:N[N.length-2].toString(),expectedAmount1:N[N.length-1].toString(),...C?{poolCreated:!0,sqrtPriceX96:C.sqrtPriceX96.toString(),initialPrice:ie(C.sqrtPriceX96,v.decimals,h.decimals),initialTick:be(C.sqrtPriceX96),priceCheck:C.note}:{}}}}async function ut(t,e,n){F(n);let s=m(n),o=j(t,e),i=D(e.token0,"token0"),c=D(e.token1,"token1");if(BigInt(i)>=BigInt(c))throw new a(`Uniswap v3 requires sorted token addresses (token0 < token1). Use token0=${BigInt(i)<BigInt(c)?i:c}, token1=${BigInt(i)<BigInt(c)?c:i}; initialPrice is token1 per 1 token0 in that order.`);let r=Number(e.fee),p=Pe[r];if(!p){let h=Number(await o.readContract({address:w.factory,abi:Y,functionName:"feeAmountTickSpacing",args:[r]}));if(!Number.isInteger(r)||h<=0)throw new a("Unsupported Uniswap v3 fee tier. Enabled tiers: 100, 500, 3000, 10000.");p=h}let d=m(String(await o.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[i,c,r]})));if(d!==$)throw new a(`The Uniswap v3 pool already exists at ${d}. Use uniswap_add to provide liquidity.`);let u=await M(o,i,y,e.token0Decimals),g=await M(o,c,y,e.token1Decimals),f=Ve(e,u.decimals,g.decimals),b=ke(f,await Xe(o,i,c,r),e.acceptPriceDeviation===!0,u.decimals,g.decimals),l=ie(f,u.decimals,g.decimals),k=[H(B({abi:P,functionName:"createAndInitializePoolIfNecessary",args:[i,c,r,f]}),`Create and initialize the Uniswap v3 ${u.symbol}/${g.symbol} fee ${r} pool at ${l} ${g.symbol} per ${u.symbol}.`)],U=await Z(o,k,s),A;try{A=m(String(ve({abi:P,functionName:"createAndInitializePoolIfNecessary",data:U[0]})))}catch{throw new a("Uniswap v3 pool creation simulation returned an invalid pool address.")}if(A===$)throw new a("Uniswap v3 pool creation simulation returned no pool.");let v=await t.preview(k,s);return{txs:k,preview:v,summary:`${k[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add.`,details:{version:"v3",action:"createPool",pool:A,fee:r,tickSpacing:p,token0:u,token1:g,sqrtPriceX96:f.toString(),initialPrice:l,initialTick:be(f),priceCheck:b}}}async function lt(t,e,n){F(n);let s=m(n),o=j(t,e),i=ee(e.tokenId,"tokenId");if(i<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,i,s);let c=await de(o,i),r=await M(o,c.token0,y),p=await M(o,c.token1,y),d=e.recipient===void 0?s:D(e.recipient,"recipient");if(d!==s)throw new a("Uniswap recipient must be the signing wallet.");let u=e.amount0Max===void 0?G:W(e.amount0Max,"amount0Max"),g=e.amount1Max===void 0?G:W(e.amount1Max,"amount1Max");if(u===0n&&g===0n||u>G||g>G)throw new a("Collect requires a positive amountMax within uint128.");let f=[H(B({abi:P,functionName:"collect",args:[{tokenId:i,recipient:d,amount0Max:u,amount1Max:g}]}),`Collect Uniswap v3 fees from position #${i}.`)],b=ce("collect",(await Z(o,f,s))[0]),l=await t.preview(f,s);return{txs:f,preview:l,summary:Se(f[0].description,l),details:{version:"v3",action:"collect",tokenId:i.toString(),recipient:d,token0:r,token1:p,amount0Max:u.toString(),amount1Max:g.toString(),expectedAmount0:b[0].toString(),expectedAmount1:b[1].toString()}}}async function pt(t,e,n){F(n);let s=m(n),o=j(t,e),i=ee(e.tokenId,"tokenId");if(i<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,i,s);let c=await de(o,i),r=c.liquidity===0n&&e.burn===!0;if(c.liquidity<=0n&&!r)throw new a("Position has zero active liquidity to remove.");if(e.liquidity===void 0&&!r)throw new a('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let p=e.liquidity==="all"||e.liquidity===void 0?c.liquidity:W(e.liquidity,"liquidity");if(p<=0n&&!r)throw new a("Liquidity to remove must be positive.");if(p>c.liquidity)throw new a("Requested liquidity exceeds position liquidity.");let d=await Oe(o,e.deadline),u=De(e),g=await M(o,c.token0,y),f=await M(o,c.token1,y),b=e.recipient===void 0?s:D(e.recipient,"recipient");if(b!==s)throw new a("Uniswap recipient must be the signing wallet.");let l=(R,E)=>H(B({abi:P,functionName:"decreaseLiquidity",args:[{tokenId:i,liquidity:p,amount0Min:R,amount1Min:E,deadline:d}]}),`Decrease ${p} liquidity on Uniswap v3 position #${i}.`),k=r?[0n,0n]:ce("decreaseLiquidity",(await Z(o,[l(0n,0n)],s))[0]),U=(R,E)=>{if(R!==void 0&&W(R,E)!==0n)throw new a(`${E} must be zero for an empty position burn.`);return 0n},A=r?U(e.amount0Min,"amount0Min"):ae(e.amount0Min,k[0],u,"amount0Min"),v=r?U(e.amount1Min,"amount1Min"):ae(e.amount1Min,k[1],u,"amount1Min"),h=r?[]:[l(A,v)],C=h.length,I=!r||c.tokensOwed0>0n||c.tokensOwed1>0n;I&&h.push(H(B({abi:P,functionName:"collect",args:[{tokenId:i,recipient:b,amount0Max:G,amount1Max:G}]}),`Collect principal and fees from Uniswap v3 position #${i}.`));let S=p===c.liquidity,x=S&&e.burn===!0;x&&h.push(H(B({abi:P,functionName:"burn",args:[i]}),`Burn empty Uniswap v3 position #${i}.`));let V=await Z(o,h,s),X=I?ce("collect",V[C]):[0n,0n],L=await t.preview(h,s);return{txs:h,preview:L,summary:Se(`Remove Uniswap v3 liquidity from position #${i}${x?`; burns position #${i} at ${w.positionManager}`:""}`,L),details:{version:"v3",action:"remove",tokenId:i.toString(),recipient:b,token0:g,token1:f,liquidityRemoved:p.toString(),amount0Min:A.toString(),amount1Min:v.toString(),deadline:d.toString(),expectedAmount0:X[0].toString(),expectedAmount1:X[1].toString(),fullExit:S,burned:x}}}function ft(t,e){let n=typeof t=="string"?Je.exec(t):null;if(!n)throw new a('cursor is not a Uniswap v3 position cursor. Pass the nextCursor exactly as a previous uniswap_list_positions {"version":"v3"} page returned it.');if(m(n[1])!==e)throw new a("This cursor was issued for a different wallet. Start again without a cursor to page this wallet.");return{block:BigInt(n[2]),next:BigInt(n[3])}}function mt(t,e,n){return`v3:${t.toLowerCase()}:${e}:${n}`}function gt(t,e){return{...t,readContract:n=>t.readContract({...n,blockNumber:e})}}var ye=t=>me(t,3,-32601,-32004);async function wt(t,e,n={}){let s=m(e),o=new Set;if(Array.isArray(n.tokenIds))for(let d of n.tokenIds){let u=ee(d,"tokenId");u>0n&&o.add(u.toString())}if(Array.isArray(n.receipts))for(let d of n.receipts)for(let u of Re(d,s))o.add(u);if(Array.isArray(n.tokenIds)&&n.tokenIds.length>0)return[...o].map(d=>BigInt(d)).sort((d,u)=>d<u?-1:d>u?1:0);let i=n.cursor,c=()=>new a("This Uniswap v3 position manager cannot enumerate NFTs by owner, so there are no pages to continue. Pass tokenIds to check specific positions."),r=!1,p=!1;try{let d;try{d=BigInt(await t.readContract({address:w.positionManager,abi:P,functionName:"balanceOf",args:[s]}))}catch(l){throw ye(l)||!i?l:new a(`Could not read this wallet's Uniswap v3 holdings at the cursor's snapshot block ${i.block}; the node may no longer serve it. Start again without a cursor. ${q(l)}`)}let u=i?.next??0n;if(u>d)throw new a(`This cursor starts at owner index ${u}, but the wallet held ${d} Uniswap v3 NFTs at block ${i?.block}. Start again without a cursor.`);let g=d-u>Le?u+Le:d,f=[],b=!0;for(let l=u;l<g;l++)try{f.push(BigInt(await t.readContract({address:w.positionManager,abi:P,functionName:"tokenOfOwnerByIndex",args:[s,l]})))}catch(k){if(!ye(k))throw k;b=!1;break}if(b){r=!0,p=u===0n&&g===d;for(let k of f)k>0n&&o.add(k.toString());let l=n.blockNumber;n.onPage?.({balance:d,from:u,to:g,blockNumber:l,...g<d&&l!==void 0?{nextCursor:mt(s,l,g)}:{}})}}catch(d){if(!ye(d))throw d}if(i&&!r)throw c();if((!r||p)&&typeof t.getLogs=="function"&&typeof t.getBlockNumber=="function")try{let d=n.toBlock??await t.getBlockNumber(),u=n.maxChunks??Ye,g=n.fromBlock??(d>oe*BigInt(u)?d-oe*BigInt(u)+1n:0n),f=d,b=0;for(;f>=g&&b<u;){let l=f>=oe-1n?f-(oe-1n):0n,k=l<g?g:l,U=await t.getLogs({address:w.positionManager,fromBlock:k,toBlock:f});for(let A of Re({logs:U},s))o.add(A);if(b+=1,k===0n||k<=g)break;f=k-1n}}catch(d){throw new a(`Could not discover Uniswap v3 positions from logs. ${q(d)}`)}else if(!r&&n.tokenIds===void 0&&n.receipts===void 0)throw new a("Uniswap v3 position discovery is unavailable; supply candidate token IDs or receipts.");return[...o].map(d=>BigInt(d)).sort((d,u)=>d<u?-1:d>u?1:0)}async function Fe(t,e,n={}){F(e);let s=m(e),o=j(t),i=Array.isArray(n.tokenIds)&&n.tokenIds.length>0,c=Array.isArray(n.receipts)&&n.receipts.length>0;if(n.cursor!==void 0&&(i||c))throw new a(`${i?"tokenIds":"receipts"} and cursor cannot be combined: ${i?"tokenIds":"receipts"} inspects exactly those NFTs and has no pages. Send one or the other.`);let r=n.cursor===void 0?void 0:ft(n.cursor,s),p=o,d;if(!i){let f;if(typeof o.getBlockNumber=="function")try{f=await o.getBlockNumber()}catch(b){throw new a(`Could not read the latest block for the Uniswap v3 listing. ${q(b)}`)}if(r&&f!==void 0&&r.block>f)throw new a(`This cursor is from block ${r.block}, ahead of the chain's latest block ${f}. Start again without a cursor.`);d=r?.block??f,d!==void 0&&(p=gt(o,d))}let u=await wt(p,s,{...n,cursor:r,blockNumber:d}),g=[];for(let f of u){let b;try{let x=await p.readContract({address:w.positionManager,abi:P,functionName:"ownerOf",args:[f]});b=m(String(x))}catch(x){if(me(x,3))continue;throw new a(`Could not verify owner of position #${f}. ${q(x)}`)}if(b!==s)continue;let l;try{l=await de(p,f)}catch(x){throw new a(`Could not read position #${f}. ${q(x)}`)}if(l.liquidity===0n&&l.tokensOwed0===0n&&l.tokensOwed1===0n&&!n.includeEmpty)continue;let U=await M(p,l.token0,y),A=await M(p,l.token1,y),v=0n,h=0n;if(l.liquidity>0n)try{let x=await p.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[l.token0,l.token1,l.fee]}),V=m(String(x));if(V===$)throw new a("Position pool was not found.");if(V!==$){let X=await p.readContract({address:V,abi:he,functionName:"slot0"}),L=BigInt(X[0]);if(L<=0n)throw new a("Position pool has no initialized price.");let R=_e(l.tickLower),E=_e(l.tickUpper),K=at(L,R,E,l.liquidity);v=K.amount0,h=K.amount1}}catch(x){throw new a(`Could not value Uniswap v3 position #${f}. ${q(x)}`)}let C=v+l.tokensOwed0,I=h+l.tokensOwed1,S=[{token:U,amount:C.toString()},{token:A,amount:I.toString()}];g.push({module:"uniswap",id:`uniswap:v3:${f.toString()}`,chainId:y,assets:S,description:`Uniswap v3 LP position #${f.toString()} (${U.symbol}/${A.symbol} fee ${l.fee} ticks [${l.tickLower}, ${l.tickUpper}] liquidity ${l.liquidity.toString()})`})}return g}function bt(t){let e=t.nextCursor?`Pass cursor "${t.nextCursor}" to read the next page, or tokenIds to check specific positions.`:"Pass tokenIds to check specific positions.";return t.from===0n?`This wallet holds ${t.balance} Uniswap v3 position NFTs and only the first ${t.to} were checked, so later positions are not listed. ${e}`:`This page checked owner indices ${t.from}-${t.to-1n} of ${t.balance} Uniswap v3 position NFTs, so later positions are not listed. ${e}`}async function kt(t,e,n){j(t,e);let s=e.wallet!==void 0?D(e.wallet,"wallet"):m(n),o=Array.isArray(e.tokenIds)?e.tokenIds:void 0,i=Array.isArray(e.receipts)?e.receipts:void 0,c=e.includeZero===!0||e.includeEmpty===!0,r,p=await Fe(t,s,{tokenIds:o,receipts:i,includeEmpty:c,cursor:e.cursor,onPage:u=>{r=u}}),d=r!==void 0&&r.to<r.balance;return{positions:p,...r?.nextCursor?{nextCursor:r.nextCursor}:{},details:{version:"v3",wallet:s,count:p.length,positionManager:w.positionManager,...r?{balance:Number(r.balance),from:Number(r.from),to:Number(r.to),examined:Number(r.to-r.from),...r.blockNumber!==void 0?{blockNumber:r.blockNumber.toString()}:{}}:{},...r&&d?{truncated:!0,incomplete:!0,note:bt(r)}:{}}}}function yt(t){return[{name:"uniswap_add",inputSchema:{type:"object",description:"Mint a new Uniswap v3 concentrated liquidity position or increase liquidity on an existing v3 NFT position on Robinhood Chain (4663).",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:'Optional existing v3 position NFT identifier to increase, as a decimal string; omit to mint. Example: "1".'},token0:{type:"string",description:"Sorted ERC-20 token0 address (e.g. WETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address (e.g. USDG)."},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"integer",enum:[100,500,3e3,1e4],default:100},fullRange:{type:"boolean",description:"For a new v3 position, use the widest ticks aligned to the pool fee tier; omit explicit ticks."},tickLower:{type:"integer",description:"Lower tick boundary divisible by tickSpacing."},tickUpper:{type:"integer",description:"Upper tick boundary divisible by tickSpacing."},amount0Desired:{type:"string",description:'Desired amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Desired:{type:"string",description:'Desired amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'},amount0Min:{type:"string",description:'Minimum amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Min:{type:"string",description:'Minimum amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."},wrapNative:{type:"boolean",description:"Optional: wrap native ETH into WETH before minting."},initialPrice:{type:"string",description:"Starting price as token1 per one token0 in human units; used only for a new pool. Pool creation and the first liquidity add require separate confirmations."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},execute:(c,r)=>dt(t,c,r)},{name:"uniswap_collect",inputSchema:{type:"object",description:"Collect accrued Uniswap v3 LP fees for an owned NonfungiblePositionManager NFT.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:'Identifier of the position NFT, as a decimal string. Example: "1".'},recipient:{type:"string",description:"Optional fee recipient; must be the signing wallet."},amount0Max:{type:"string",description:'Maximum amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Max:{type:"string",description:'Maximum amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'}},required:["tokenId"]},execute:(c,r)=>lt(t,c,r)},{name:"uniswap_remove",inputSchema:{type:"object",description:"Decrease liquidity on an owned Uniswap v3 NFT position, collect principal and fees, and optionally burn the empty NFT.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:'Identifier of the position NFT, as a decimal string. Example: "1".'},liquidity:{type:"string",description:'Liquidity in protocol base units, or "all" for a full exit where supported; not a token amount. Example: "1000" = 1000 liquidity units.'},amount0Min:{type:"string",description:'Minimum amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Min:{type:"string",description:'Minimum amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."},burn:{type:"boolean",description:"Whether to burn the NFT after removing 100% of liquidity, or burn an already-empty position."}},required:["tokenId"]},execute:(c,r)=>pt(t,c,r)},{name:"uniswap_list_positions",inputSchema:{type:"object",description:"List active Uniswap v3 LP positions owned by the wallet, 64 owner indices per page at one pinned block; follow nextCursor for more. Falls back to a bounded Transfer-log scan for managers that cannot enumerate by owner.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},wallet:{type:"string",description:"Optional wallet address override."},tokenIds:{type:"array",items:{type:"string"},description:'Optional v3 NFT identifiers as decimal strings, e.g. ["1", "2"]. Inspects exactly these NFTs without paging.'},cursor:et}},execute:(c,r)=>kt(t,c,r)},{name:"uniswap_create_pool",inputSchema:{type:"object",description:"Create and initialize an empty Uniswap v3 pool on Robinhood Chain (4663). Add liquidity afterwards with uniswap_add.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},token0:{type:"string",description:"Sorted ERC-20 token0 address (WETH, not native ETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address."},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"integer",enum:[100,500,3e3,1e4]},initialPrice:{type:"string",description:"Starting pool price as token1 per one token0 in human units. Add liquidity separately after initialization."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}},required:["token0","token1","fee"]},execute:(c,r)=>ut(t,c,r)}]}var He=t=>({tools:yt(t),positions:async e=>{let n,s=await Fe(t,e,{onPage:o=>{o.to>=o.balance||(n={module:"uniswap",id:"uniswap-v3-discovery-truncated",chainId:y,assets:[],incomplete:!0,description:`This wallet holds ${o.balance} Uniswap v3 position NFTs and only the first ${o.to} were checked, so later positions may be missing. Pass tokenIds to uniswap_list_positions to check the others, or page through them with uniswap_list_positions {"version":"v3"} and each nextCursor.`})}});return n?[...s,n]:s}}),Nt=He,Tt=He;export{re as a,se as b,G as c,et as d,w as e,Pe as f,qt as g,P as h,Y as i,he as j,tt as k,ot as l,rt as m,st as n,Re as o,Ut as p,Ve as q,dt as r,ut as s,lt as t,pt as u,Fe as v,kt as w,yt as x,He as y,Nt as z,Tt as A};
1
+ import{c as Te,d as $e,e as be,f as ie,i as ke,j as Me}from"./3BQ5XHDJ.js";import{b as ne,o as we}from"./GYPMUYB5.js";import{a as F,b as ge}from"./43LI5NKJ.js";import{a as Ne}from"./IOYRL6AY.js";import{b as z,d as Ue}from"./IX3GZMTM.js";import{b as y,j as O}from"./TI727O2H.js";import{a,b as me,e as q}from"./XSD5NL7J.js";import{decodeFunctionResult as ve,encodeFunctionData as B,getAddress as m,parseAbi as J,zeroAddress as $}from"viem";var re=-887272,se=887272,G=(1n<<128n)-1n,je="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",Ke="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",Qe="0x3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f",oe=2000n,Ye=5,Le=64n,Ze=1800n,Be="^v3:(0x[0-9a-fA-F]{40}):(0|[1-9][0-9]{0,19}):(0|[1-9][0-9]{0,19})$",Je=new RegExp(Be),et=Object.freeze({type:"string",pattern:Be,description:"v3 only. Pass the nextCursor of the previous page to read the next 64 owner indices at the same block. Cannot be combined with tokenIds."}),w=Object.freeze({factory:m(O[4663].uniswap.v3_factory.address),positionManager:m(O[4663].uniswap.v3_position_manager.address),swapRouter02:m(O[4663].uniswap.swap_router02.address),permit2:m(O[4663].uniswap.permit2.address),weth:m(O[4663].uniswap.WETH.address),usdg:m(O[4663].uniswap.USDG.address),ethUsdgPool:m(O[4663].oracle.ethUsdgPool.address)}),Pe=Object.freeze({100:1,500:10,3e3:60,1e4:200}),qt=Object.freeze([{fee:100,tickSpacing:1,address:m("0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"),token0:w.weth,token1:w.usdg,recordedLiquidity:"1957537485734736219",recordedSqrtPriceX96:"3839219776288481168641554",recordedTick:-198707,feeProtocol:68},{fee:500,tickSpacing:10,address:m("0x69bfaf19c9f377bb306a89aed9f6b07e2c1a8d9a"),token0:w.weth,token1:w.usdg,recordedLiquidity:"714542894544667104",recordedSqrtPriceX96:"3839644024453020182443671",recordedTick:-198705,feeProtocol:68},{fee:3e3,tickSpacing:60,address:m("0xa9188730fe85be88ad499d7d52b099e800fb0334"),token0:w.weth,token1:w.usdg,recordedLiquidity:"310559629687003603",recordedSqrtPriceX96:"3843235825752878635548672",recordedTick:-198686,feeProtocol:102},{fee:1e4,tickSpacing:200,address:m("0x5f009e071f07e92b6c624e83f52f17bbda34680d"),token0:w.weth,token1:w.usdg,recordedLiquidity:"5822966536584155",recordedSqrtPriceX96:"3853297838190389678059735",recordedTick:-198634,feeProtocol:102}]),P=J(["function positions(uint256 tokenId) view returns (uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1)","function ownerOf(uint256 tokenId) view returns (address)","function balanceOf(address owner) view returns (uint256)","function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)","function mint((address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline) params) payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)","function increaseLiquidity((uint256 tokenId, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint128 liquidity, uint256 amount0, uint256 amount1)","function decreaseLiquidity((uint256 tokenId, uint128 liquidity, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint256 amount0, uint256 amount1)","function collect((uint256 tokenId, address recipient, uint128 amount0Max, uint128 amount1Max) params) payable returns (uint256 amount0, uint256 amount1)","function burn(uint256 tokenId) payable","function createAndInitializePoolIfNecessary(address token0, address token1, uint24 fee, uint160 sqrtPriceX96) payable returns (address pool)"]),Y=J(["function getPool(address tokenA, address tokenB, uint24 fee) view returns (address pool)","function feeAmountTickSpacing(uint24 fee) view returns (int24)"]),he=J(["function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)","function liquidity() view returns (uint128)","function tickSpacing() view returns (int24)","function fee() view returns (uint24)","function token0() view returns (address)","function token1() view returns (address)"]),tt=J(["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)"]),xe=J(["function decimals() view returns (uint8)","function symbol() view returns (string)","function allowance(address owner, address spender) view returns (uint256)"]),nt="0xd0e30db0";function it(t){if(typeof t!="string")return!1;let e=t.trim().toLowerCase();return e===$||e===je||e==="eth"||e==="native"}function D(t,e){if(it(t))throw new a(`Uniswap v3 requires wrapped ERC-20 WETH (${w.weth}) rather than native ETH in ${e}.`);if(typeof t!="string")throw new a(`${e} must be a valid 20-byte hex address.`);return F(t),m(t)}function ot(t,e,n){let s=Number(t),o=Number(e),i=Number(n);if(!Number.isInteger(i)||i<=0)throw new a("Uniswap v3 tickSpacing must be a positive integer.");if(!Number.isInteger(s)||!Number.isInteger(o))throw new a("Uniswap v3 tickLower and tickUpper must be integers.");if(s<re||o>se||s>se||o<re)throw new a(`Uniswap v3 ticks are out of bounds [${re}, ${se}].`);if(s>=o)throw new a("Uniswap v3 tickLower must be strictly less than tickUpper.");if(s%i!==0||o%i!==0)throw new a(`Uniswap v3 tickLower (${s}) and tickUpper (${o}) must be divisible by tickSpacing (${i}).`);return{tickLower:s,tickUpper:o,tickSpacing:i}}function rt(t,e){let n=t.trim(),s=n.startsWith("-"),o=s||n.startsWith("+")?n.slice(1):n,i=Ue(z(o).toString(),e);return s&&i!=="0"?`-${i}`:i}function st(t){let e=typeof t=="string"?ve({abi:P,functionName:"positions",data:t}):t;return{nonce:BigInt(e[0]),operator:m(String(e[1])),token0:m(String(e[2])),token1:m(String(e[3])),fee:Number(e[4]),tickLower:Number(e[5]),tickUpper:Number(e[6]),liquidity:BigInt(e[7]),feeGrowthInside0LastX128:BigInt(e[8]),feeGrowthInside1LastX128:BigInt(e[9]),tokensOwed0:BigInt(e[10]),tokensOwed1:BigInt(e[11])}}function Re(t,e){if(!t||!Array.isArray(t.logs))return[];let n=e?m(e).toLowerCase():void 0,s=w.positionManager.toLowerCase(),o=new Set;for(let i of t.logs){if(!i||typeof i.address!="string"||i.address.toLowerCase()!==s)continue;let c=Array.isArray(i.topics)?i.topics.map(p=>String(p).toLowerCase()):[],r=c[0];if(r===Ke&&c.length>=4){let d=`0x${c[2].slice(-40)}`;if(!n||d===n){let u=BigInt(c[3]).toString();u!=="0"&&o.add(u)}}else if(r===Qe&&c.length>=2&&!n){let p=BigInt(c[1]).toString();p!=="0"&&o.add(p)}}return[...o]}function Ut(t){let e=n=>typeof n=="bigint"?n:z(n);return B({abi:tt,functionName:"exactInputSingle",args:[{tokenIn:m(t.tokenIn),tokenOut:m(t.tokenOut),fee:t.fee,recipient:m(t.recipient),amountIn:e(t.amountIn),amountOutMinimum:e(t.amountOutMinimum),sqrtPriceLimitX96:t.sqrtPriceLimitX96!==void 0?e(t.sqrtPriceLimitX96):0n}]})}var Ee=1n<<96n;function _e(t){let e=Math.abs(t),n=(e&1)!==0?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;return(e&2)!==0&&(n=n*0xfff97272373d413259a46990580e213an>>128n),(e&4)!==0&&(n=n*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(e&8)!==0&&(n=n*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(e&16)!==0&&(n=n*0xffcb9843d60f6159c9db58835c926644n>>128n),(e&32)!==0&&(n=n*0xff973b41fa98c081472e6896dfb254c0n>>128n),(e&64)!==0&&(n=n*0xff2ea16466c96a3843ec78b326b52861n>>128n),(e&128)!==0&&(n=n*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(e&256)!==0&&(n=n*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(e&512)!==0&&(n=n*0xf987a7253ac413176f2b074cf7815e54n>>128n),(e&1024)!==0&&(n=n*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(e&2048)!==0&&(n=n*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(e&4096)!==0&&(n=n*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(e&8192)!==0&&(n=n*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(e&16384)!==0&&(n=n*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(e&32768)!==0&&(n=n*0x31be135f97d08fd981231505542fcfa6n>>128n),(e&65536)!==0&&(n=n*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(e&131072)!==0&&(n=n*0x5d6af8dedb81196699c329225ee604n>>128n),(e&262144)!==0&&(n=n*0x2216e584f5fa1ea926041bedfe98n>>128n),(e&524288)!==0&&(n=n*0x48a170391f7dc42444e8fa2n>>128n),t>0&&(n=((1n<<256n)-1n)/n),(n>>32n)+(n%(1n<<32n)===0n?0n:1n)}function at(t,e,n,s){if(s<=0n)return{amount0:0n,amount1:0n};let[o,i]=e<n?[e,n]:[n,e];if(t<=o)return{amount0:(s<<96n)*(i-o)/i/o,amount1:0n};if(t<i){let r=(s<<96n)*(i-t)/i/t,p=s*(t-o)/Ee;return{amount0:r,amount1:p}}return{amount0:0n,amount1:s*(i-o)/Ee}}async function M(t,e,n,s){let o=m(e),i,c;if(n===y&&o===w.weth?(i=18,c="WETH"):n===y&&o===w.usdg&&(i=6,c="USDG"),i===void 0){let r=await t.readContract({address:o,abi:xe,functionName:"decimals"});i=Number(r)}if(c===void 0)try{let r=await t.readContract({address:o,abi:xe,functionName:"symbol"});if(typeof r!="string"||!r.trim())throw new a("Token symbol is unavailable.");c=Me(r.trim(),o)}catch(r){throw new a(`Could not read token metadata. ${q(r)}`)}if(!Number.isInteger(i)||i<0||i>255)throw new a("Token decimals are invalid.");if(s!=null){let r=Number(s);if(!Number.isInteger(r)||r!==i)throw new a(`Token ${o} on chain ${n} has ${i} decimals, not ${String(s)}.`)}return{address:o,symbol:c,decimals:i,chainId:n}}async function ct(t){try{if(!t.getBlock)throw new a("Block timestamps are unavailable.");let e=await t.getBlock();if(typeof e.timestamp!="bigint")throw new a("Invalid block timestamp.");return e.timestamp}catch(e){throw new a(`Could not read the current block timestamp. ${q(e)}`)}}function ee(t,e){if(typeof t=="bigint"){if(t<0n)throw new a(`${e} must be a non-negative integer.`);return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<0)throw new a(`${e} must be a non-negative integer.`);return BigInt(t)}if(typeof t=="string")return z(t);throw new a(`${e} must be a non-negative integer.`)}async function Oe(t,e){let n=await ct(t);if(e==null)return n+Ze;let s=ee(e,"deadline");if(s<=n)throw new a(`Uniswap v3 deadline (${s.toString()}) has expired at timestamp ${n.toString()}.`);return s}function W(t,e){if(typeof t!="string"||!/^\d+$/.test(t))throw new a(`${e} must be a non-negative integer string in base units.`);return z(t)}function De(t){let e=t.slippageBps??ne;if(typeof e!="number")throw new a("Slippage must be an integer from 0 to 9999 bps.");return we("0",e),e}function ae(t,e,n,s){let o=t===void 0?z(we(e.toString(),n)):W(t,s);if(o<=1n)throw new a(`${s} must exceed 1 base unit; the simulated amount may be too small.`);return o}function H(t,e){return ge({to:w.positionManager,data:t,value:"0",chainId:y,description:e})}async function Z(t,e,n){try{if(!t.request)throw new a("Sequential transaction simulation is unavailable.");let o=await t.request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:e.map(i=>({from:n,gas:`0x${Ne.toString(16)}`,to:i.to,data:i.data,value:`0x${BigInt(i.value).toString(16)}`}))}],validation:!1,traceTransfers:!0},"latest"]},{retryCount:0});if(!Array.isArray(o)||o.length!==1||!Array.isArray(o[0]?.calls)||o[0].calls.length!==e.length)throw new a("Unexpected batch simulation response.");return o[0].calls.map((i,c)=>{if(i.status!=="0x1"||i.error||typeof i.returnData!="string"||!/^0x([a-fA-F0-9]{2})*$/.test(i.returnData))throw new a(`Simulation call ${c+1} failed. ${q(i.error)}`);return i.returnData})}catch(s){throw new a(`Uniswap v3 simulation failed. ${q(s)}`)}}function ce(t,e){try{return ve({abi:P,functionName:t,data:e})}catch{throw new a(`Uniswap v3 ${t} simulation returned invalid amounts.`)}}function Ve(t,e,n){if(t.initialPrice!==void 0&&t.sqrtPriceX96!==void 0)throw new a("Provide initialPrice or sqrtPriceX96, not both.");if(t.sqrtPriceX96!==void 0){if(typeof t.sqrtPriceX96!="string"||!/^\d+$/.test(t.sqrtPriceX96))throw new a("sqrtPriceX96 must be a non-negative integer string.");return $e(BigInt(t.sqrtPriceX96))}if(t.initialPrice===void 0)throw new a("A new pool needs initialPrice (token1 per 1 token0, human units) or sqrtPriceX96.");return Te(t.initialPrice,e,n)}async function Xe(t,e,n,s){let o=[];for(let i of Object.keys(Pe).map(Number)){if(i===s)continue;let c=m(String(await t.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[e,n,i]})));if(c===$||BigInt(await t.readContract({address:c,abi:he,functionName:"liquidity"}))===0n)continue;let p=await t.readContract({address:c,abi:he,functionName:"slot0"});o.push({label:`v3 fee ${i} pool ${c}`,sqrtPriceX96:BigInt(p[0])})}return o}function j(t,e={}){if(e.chainId!==void 0&&Number(e.chainId)!==y)throw new a(`Uniswap v3 is only supported on Robinhood Chain (${y}).`);if(e.version!==void 0&&e.version!=="v3")throw new a(`Uniswap v3 handler received unsupported version "${String(e.version)}".`);let n=t.clientFor(y);return{...n,readContract:async s=>{try{return await n.readContract(s)}catch(o){throw new a(`Could not read Uniswap v3 ${s.functionName}. ${q(o)}`,{cause:o})}}}}async function Ie(t,e,n){let s;try{s=await t.readContract({address:w.positionManager,abi:P,functionName:"ownerOf",args:[e]})}catch(c){throw new a(`Could not verify owner of Uniswap v3 position #${e}. ${q(c)}`)}let o=m(String(s)),i=m(n);if(o!==i)throw new a(`Wallet ${i} is not the owner of Uniswap v3 position #${e.toString()} (owned by ${o}).`);return o}async function de(t,e){let n=await t.readContract({address:w.positionManager,abi:P,functionName:"positions",args:[e]});return st(n)}function Se(t,e){if(!Array.isArray(e.changes)||!e.changes.length)return t;let n=e.changes.map(s=>`${rt(s.amount,s.token.decimals)} ${s.token.symbol}`);return`${t} (${n.join(", ")})`}async function dt(t,e,n){F(n);let s=m(n),o=j(t,e),i=await Oe(o,e.deadline),c=De(e),r=e.tokenId===void 0?void 0:ee(e.tokenId,"tokenId"),p;if(r!==void 0){if(r<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,r,s),p=await de(o,r)}let d=p?.token0??D(e.token0,"token0"),u=p?.token1??D(e.token1,"token1");if(BigInt(d)>=BigInt(u))throw new a("Uniswap v3 requires distinct sorted token addresses.");let g=p?.fee??Number(e.fee??100),f=Pe[g];if(!f)throw new a("Unsupported Uniswap v3 fee tier.");let b=m(String(await o.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[d,u,g]}))),l=e.initialPrice!==void 0||e.sqrtPriceX96!==void 0;if(b===$&&!l)throw new a("No Uniswap v3 pool exists for these tokens and fee tier. To create it and add the first liquidity in one tool call with separately confirmed transactions, add initialPrice (token1 per 1 token0, human units) to this call; to create it without liquidity use uniswap_create_pool.");if(b!==$&&l)throw new a(`The Uniswap v3 pool already exists at ${b}; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);if(r!==void 0&&l)throw new a("initialPrice cannot be combined with tokenId.");if(e.fullRange!==void 0&&typeof e.fullRange!="boolean")throw new a("fullRange must be a boolean.");if(e.fullRange===!0&&(e.tickLower!==void 0||e.tickUpper!==void 0||p))throw new a("Use fullRange only for a new position, without explicit ticks. Existing position ticks cannot change.");let{tickLower:k,tickUpper:U,tickSpacing:A}=ot(p?.tickLower??(e.fullRange===!0?Math.ceil(re/f)*f:e.tickLower),p?.tickUpper??(e.fullRange===!0?Math.floor(se/f)*f:e.tickUpper),f),v=await M(o,d,y,e.token0Decimals),h=await M(o,u,y,e.token1Decimals),C;if(b===$){let T=Ve(e,v.decimals,h.decimals),_=ke(T,await Xe(o,d,u,g),e.acceptPriceDeviation===!0,v.decimals,h.decimals);C={sqrtPriceX96:T,note:_}}let I=W(e.amount0Desired,"amount0Desired"),S=W(e.amount1Desired,"amount1Desired");if(I===0n&&S===0n)throw new a("Liquidity addition requires a positive desired amount.");let x=e.recipient===void 0?s:D(e.recipient,"recipient");if(x!==s)throw new a("Uniswap recipient must be the signing wallet.");if(e.wrapNative===!0&&d!==w.weth&&u!==w.weth)throw new a("Wrapping requires a positive WETH desired amount.");let V=await Promise.all([d,u].map(async T=>BigInt(await o.readContract({address:T,abi:xe,functionName:"allowance",args:[s,w.positionManager]})))),X=(T,_)=>{let pe=[];if(e.wrapNative===!0){let Q=d===w.weth?T:_;Q>0n&&pe.push(ge({to:w.weth,data:nt,value:Q.toString(),chainId:y,description:"Wrap ETH into WETH."}))}for(let[Q,Ge]of[d,u].entries()){let fe=Q===0?T:_;fe>0n&&V[Q]<fe&&pe.push(t.approval(Ge,w.positionManager,fe.toString(),y))}return pe},L=r===void 0?"mint":"increaseLiquidity",R=(T,_)=>H(r===void 0?B({abi:P,functionName:"mint",args:[{token0:d,token1:u,fee:g,tickLower:k,tickUpper:U,amount0Desired:I,amount1Desired:S,amount0Min:T,amount1Min:_,recipient:x,deadline:i}]}):B({abi:P,functionName:"increaseLiquidity",args:[{tokenId:r,amount0Desired:I,amount1Desired:S,amount0Min:T,amount1Min:_,deadline:i}]}),`${L==="mint"?"Mint":"Increase"} Uniswap v3 ${v.symbol}/${h.symbol} liquidity.`),E=C&&H(B({abi:P,functionName:"createAndInitializePoolIfNecessary",args:[d,u,g,C.sqrtPriceX96]}),`Create and initialize the Uniswap v3 ${v.symbol}/${h.symbol} fee ${g} pool at ${ie(C.sqrtPriceX96,v.decimals,h.decimals)} ${h.symbol} per ${v.symbol}.`),K=E?[E]:[],Ae=await Z(o,[...K,...X(I,S),R(0n,0n)],s),N=ce(L,Ae[Ae.length-1]),We=N[N.length-2],ze=N[N.length-1];if(We>I||ze>S)throw new a("Simulated liquidity spend exceeds the desired amounts.");let te=[...K,...X(I,S)],ue=ae(e.amount0Min,N[N.length-2],c,"amount0Min"),le=ae(e.amount1Min,N[N.length-1],c,"amount1Min");if(ue>I||le>S)throw new a("Uniswap v3 minimum amount cannot exceed desired amount.");let Ce=R(ue,le);te.push(Ce);for(let[T,_]of[d,u].entries())(T===0?I:S)>0n&&te.push(t.approval(_,w.positionManager,"0",y));let qe=await t.preview(te,s);return{txs:te,preview:qe,summary:Se(Ce.description,qe),details:{version:"v3",action:L,...r===void 0?{}:{tokenId:r.toString()},pool:b===$?null:b,fee:g,tickSpacing:A,tickLower:k,tickUpper:U,token0:v,token1:h,amount0Desired:I.toString(),amount1Desired:S.toString(),amount0Min:ue.toString(),amount1Min:le.toString(),deadline:i.toString(),recipient:x,expectedAmount0:N[N.length-2].toString(),expectedAmount1:N[N.length-1].toString(),...C?{poolCreated:!0,sqrtPriceX96:C.sqrtPriceX96.toString(),initialPrice:ie(C.sqrtPriceX96,v.decimals,h.decimals),initialTick:be(C.sqrtPriceX96),priceCheck:C.note}:{}}}}async function ut(t,e,n){F(n);let s=m(n),o=j(t,e),i=D(e.token0,"token0"),c=D(e.token1,"token1");if(BigInt(i)>=BigInt(c))throw new a(`Uniswap v3 requires sorted token addresses (token0 < token1). Use token0=${BigInt(i)<BigInt(c)?i:c}, token1=${BigInt(i)<BigInt(c)?c:i}; initialPrice is token1 per 1 token0 in that order.`);let r=Number(e.fee),p=Pe[r];if(!p){let h=Number(await o.readContract({address:w.factory,abi:Y,functionName:"feeAmountTickSpacing",args:[r]}));if(!Number.isInteger(r)||h<=0)throw new a("Unsupported Uniswap v3 fee tier. Enabled tiers: 100, 500, 3000, 10000.");p=h}let d=m(String(await o.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[i,c,r]})));if(d!==$)throw new a(`The Uniswap v3 pool already exists at ${d}. Use uniswap_add to provide liquidity.`);let u=await M(o,i,y,e.token0Decimals),g=await M(o,c,y,e.token1Decimals),f=Ve(e,u.decimals,g.decimals),b=ke(f,await Xe(o,i,c,r),e.acceptPriceDeviation===!0,u.decimals,g.decimals),l=ie(f,u.decimals,g.decimals),k=[H(B({abi:P,functionName:"createAndInitializePoolIfNecessary",args:[i,c,r,f]}),`Create and initialize the Uniswap v3 ${u.symbol}/${g.symbol} fee ${r} pool at ${l} ${g.symbol} per ${u.symbol}.`)],U=await Z(o,k,s),A;try{A=m(String(ve({abi:P,functionName:"createAndInitializePoolIfNecessary",data:U[0]})))}catch{throw new a("Uniswap v3 pool creation simulation returned an invalid pool address.")}if(A===$)throw new a("Uniswap v3 pool creation simulation returned no pool.");let v=await t.preview(k,s);return{txs:k,preview:v,summary:`${k[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add.`,details:{version:"v3",action:"createPool",pool:A,fee:r,tickSpacing:p,token0:u,token1:g,sqrtPriceX96:f.toString(),initialPrice:l,initialTick:be(f),priceCheck:b}}}async function lt(t,e,n){F(n);let s=m(n),o=j(t,e),i=ee(e.tokenId,"tokenId");if(i<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,i,s);let c=await de(o,i),r=await M(o,c.token0,y),p=await M(o,c.token1,y),d=e.recipient===void 0?s:D(e.recipient,"recipient");if(d!==s)throw new a("Uniswap recipient must be the signing wallet.");let u=e.amount0Max===void 0?G:W(e.amount0Max,"amount0Max"),g=e.amount1Max===void 0?G:W(e.amount1Max,"amount1Max");if(u===0n&&g===0n||u>G||g>G)throw new a("Collect requires a positive amountMax within uint128.");let f=[H(B({abi:P,functionName:"collect",args:[{tokenId:i,recipient:d,amount0Max:u,amount1Max:g}]}),`Collect Uniswap v3 fees from position #${i}.`)],b=ce("collect",(await Z(o,f,s))[0]),l=await t.preview(f,s);return{txs:f,preview:l,summary:Se(f[0].description,l),details:{version:"v3",action:"collect",tokenId:i.toString(),recipient:d,token0:r,token1:p,amount0Max:u.toString(),amount1Max:g.toString(),expectedAmount0:b[0].toString(),expectedAmount1:b[1].toString()}}}async function pt(t,e,n){F(n);let s=m(n),o=j(t,e),i=ee(e.tokenId,"tokenId");if(i<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,i,s);let c=await de(o,i),r=c.liquidity===0n&&e.burn===!0;if(c.liquidity<=0n&&!r)throw new a("Position has zero active liquidity to remove.");if(e.liquidity===void 0&&!r)throw new a('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let p=e.liquidity==="all"||e.liquidity===void 0?c.liquidity:W(e.liquidity,"liquidity");if(p<=0n&&!r)throw new a("Liquidity to remove must be positive.");if(p>c.liquidity)throw new a("Requested liquidity exceeds position liquidity.");let d=await Oe(o,e.deadline),u=De(e),g=await M(o,c.token0,y),f=await M(o,c.token1,y),b=e.recipient===void 0?s:D(e.recipient,"recipient");if(b!==s)throw new a("Uniswap recipient must be the signing wallet.");let l=(R,E)=>H(B({abi:P,functionName:"decreaseLiquidity",args:[{tokenId:i,liquidity:p,amount0Min:R,amount1Min:E,deadline:d}]}),`Decrease ${p} liquidity on Uniswap v3 position #${i}.`),k=r?[0n,0n]:ce("decreaseLiquidity",(await Z(o,[l(0n,0n)],s))[0]),U=(R,E)=>{if(R!==void 0&&W(R,E)!==0n)throw new a(`${E} must be zero for an empty position burn.`);return 0n},A=r?U(e.amount0Min,"amount0Min"):ae(e.amount0Min,k[0],u,"amount0Min"),v=r?U(e.amount1Min,"amount1Min"):ae(e.amount1Min,k[1],u,"amount1Min"),h=r?[]:[l(A,v)],C=h.length,I=!r||c.tokensOwed0>0n||c.tokensOwed1>0n;I&&h.push(H(B({abi:P,functionName:"collect",args:[{tokenId:i,recipient:b,amount0Max:G,amount1Max:G}]}),`Collect principal and fees from Uniswap v3 position #${i}.`));let S=p===c.liquidity,x=S&&e.burn===!0;x&&h.push(H(B({abi:P,functionName:"burn",args:[i]}),`Burn empty Uniswap v3 position #${i}.`));let V=await Z(o,h,s),X=I?ce("collect",V[C]):[0n,0n],L=await t.preview(h,s);return{txs:h,preview:L,summary:Se(`Remove Uniswap v3 liquidity from position #${i}${x?`; burns position #${i} at ${w.positionManager}`:""}`,L),details:{version:"v3",action:"remove",tokenId:i.toString(),recipient:b,token0:g,token1:f,liquidityRemoved:p.toString(),amount0Min:A.toString(),amount1Min:v.toString(),deadline:d.toString(),expectedAmount0:X[0].toString(),expectedAmount1:X[1].toString(),fullExit:S,burned:x}}}function ft(t,e){let n=typeof t=="string"?Je.exec(t):null;if(!n)throw new a('cursor is not a Uniswap v3 position cursor. Pass the nextCursor exactly as a previous uniswap_list_positions {"version":"v3"} page returned it.');if(m(n[1])!==e)throw new a("This cursor was issued for a different wallet. Start again without a cursor to page this wallet.");return{block:BigInt(n[2]),next:BigInt(n[3])}}function mt(t,e,n){return`v3:${t.toLowerCase()}:${e}:${n}`}function gt(t,e){return{...t,readContract:n=>t.readContract({...n,blockNumber:e})}}var ye=t=>me(t,3,-32601,-32004);async function wt(t,e,n={}){let s=m(e),o=new Set;if(Array.isArray(n.tokenIds))for(let d of n.tokenIds){let u=ee(d,"tokenId");u>0n&&o.add(u.toString())}if(Array.isArray(n.receipts))for(let d of n.receipts)for(let u of Re(d,s))o.add(u);if(Array.isArray(n.tokenIds)&&n.tokenIds.length>0)return[...o].map(d=>BigInt(d)).sort((d,u)=>d<u?-1:d>u?1:0);let i=n.cursor,c=()=>new a("This Uniswap v3 position manager cannot enumerate NFTs by owner, so there are no pages to continue. Pass tokenIds to check specific positions."),r=!1,p=!1;try{let d;try{d=BigInt(await t.readContract({address:w.positionManager,abi:P,functionName:"balanceOf",args:[s]}))}catch(l){throw ye(l)||!i?l:new a(`Could not read this wallet's Uniswap v3 holdings at the cursor's snapshot block ${i.block}; the node may no longer serve it. Start again without a cursor. ${q(l)}`)}let u=i?.next??0n;if(u>d)throw new a(`This cursor starts at owner index ${u}, but the wallet held ${d} Uniswap v3 NFTs at block ${i?.block}. Start again without a cursor.`);let g=d-u>Le?u+Le:d,f=[],b=!0;for(let l=u;l<g;l++)try{f.push(BigInt(await t.readContract({address:w.positionManager,abi:P,functionName:"tokenOfOwnerByIndex",args:[s,l]})))}catch(k){if(!ye(k))throw k;b=!1;break}if(b){r=!0,p=u===0n&&g===d;for(let k of f)k>0n&&o.add(k.toString());let l=n.blockNumber;n.onPage?.({balance:d,from:u,to:g,blockNumber:l,...g<d&&l!==void 0?{nextCursor:mt(s,l,g)}:{}})}}catch(d){if(!ye(d))throw d}if(i&&!r)throw c();if((!r||p)&&typeof t.getLogs=="function"&&typeof t.getBlockNumber=="function")try{let d=n.toBlock??await t.getBlockNumber(),u=n.maxChunks??Ye,g=n.fromBlock??(d>oe*BigInt(u)?d-oe*BigInt(u)+1n:0n),f=d,b=0;for(;f>=g&&b<u;){let l=f>=oe-1n?f-(oe-1n):0n,k=l<g?g:l,U=await t.getLogs({address:w.positionManager,fromBlock:k,toBlock:f});for(let A of Re({logs:U},s))o.add(A);if(b+=1,k===0n||k<=g)break;f=k-1n}}catch(d){throw new a(`Could not discover Uniswap v3 positions from logs. ${q(d)}`)}else if(!r&&n.tokenIds===void 0&&n.receipts===void 0)throw new a("Uniswap v3 position discovery is unavailable; supply candidate token IDs or receipts.");return[...o].map(d=>BigInt(d)).sort((d,u)=>d<u?-1:d>u?1:0)}async function Fe(t,e,n={}){F(e);let s=m(e),o=j(t),i=Array.isArray(n.tokenIds)&&n.tokenIds.length>0,c=Array.isArray(n.receipts)&&n.receipts.length>0;if(n.cursor!==void 0&&(i||c))throw new a(`${i?"tokenIds":"receipts"} and cursor cannot be combined: ${i?"tokenIds":"receipts"} inspects exactly those NFTs and has no pages. Send one or the other.`);let r=n.cursor===void 0?void 0:ft(n.cursor,s),p=o,d;if(!i){let f;if(typeof o.getBlockNumber=="function")try{f=await o.getBlockNumber()}catch(b){throw new a(`Could not read the latest block for the Uniswap v3 listing. ${q(b)}`)}if(r&&f!==void 0&&r.block>f)throw new a(`This cursor is from block ${r.block}, ahead of the chain's latest block ${f}. Start again without a cursor.`);d=r?.block??f,d!==void 0&&(p=gt(o,d))}let u=await wt(p,s,{...n,cursor:r,blockNumber:d}),g=[];for(let f of u){let b;try{let x=await p.readContract({address:w.positionManager,abi:P,functionName:"ownerOf",args:[f]});b=m(String(x))}catch(x){if(me(x,3))continue;throw new a(`Could not verify owner of position #${f}. ${q(x)}`)}if(b!==s)continue;let l;try{l=await de(p,f)}catch(x){throw new a(`Could not read position #${f}. ${q(x)}`)}if(l.liquidity===0n&&l.tokensOwed0===0n&&l.tokensOwed1===0n&&!n.includeEmpty)continue;let U=await M(p,l.token0,y),A=await M(p,l.token1,y),v=0n,h=0n;if(l.liquidity>0n)try{let x=await p.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[l.token0,l.token1,l.fee]}),V=m(String(x));if(V===$)throw new a("Position pool was not found.");if(V!==$){let X=await p.readContract({address:V,abi:he,functionName:"slot0"}),L=BigInt(X[0]);if(L<=0n)throw new a("Position pool has no initialized price.");let R=_e(l.tickLower),E=_e(l.tickUpper),K=at(L,R,E,l.liquidity);v=K.amount0,h=K.amount1}}catch(x){throw new a(`Could not value Uniswap v3 position #${f}. ${q(x)}`)}let C=v+l.tokensOwed0,I=h+l.tokensOwed1,S=[{token:U,amount:C.toString()},{token:A,amount:I.toString()}];g.push({module:"uniswap",id:`uniswap:v3:${f.toString()}`,chainId:y,assets:S,description:`Uniswap v3 LP position #${f.toString()} (${U.symbol}/${A.symbol} fee ${l.fee} ticks [${l.tickLower}, ${l.tickUpper}] liquidity ${l.liquidity.toString()})`})}return g}function bt(t){let e=t.nextCursor?`Pass cursor "${t.nextCursor}" to read the next page, or tokenIds to check specific positions.`:"Pass tokenIds to check specific positions.";return t.from===0n?`This wallet holds ${t.balance} Uniswap v3 position NFTs and only the first ${t.to} were checked, so later positions are not listed. ${e}`:`This page checked owner indices ${t.from}-${t.to-1n} of ${t.balance} Uniswap v3 position NFTs, so later positions are not listed. ${e}`}async function kt(t,e,n){j(t,e);let s=e.wallet!==void 0?D(e.wallet,"wallet"):m(n),o=Array.isArray(e.tokenIds)?e.tokenIds:void 0,i=Array.isArray(e.receipts)?e.receipts:void 0,c=e.includeZero===!0||e.includeEmpty===!0,r,p=await Fe(t,s,{tokenIds:o,receipts:i,includeEmpty:c,cursor:e.cursor,onPage:u=>{r=u}}),d=r!==void 0&&r.to<r.balance;return{positions:p,...r?.nextCursor?{nextCursor:r.nextCursor}:{},details:{version:"v3",wallet:s,count:p.length,positionManager:w.positionManager,...r?{balance:Number(r.balance),from:Number(r.from),to:Number(r.to),examined:Number(r.to-r.from),...r.blockNumber!==void 0?{blockNumber:r.blockNumber.toString()}:{}}:{},...r&&d?{truncated:!0,incomplete:!0,note:bt(r)}:{}}}}function yt(t){return[{name:"uniswap_add",inputSchema:{type:"object",description:"Mint a new Uniswap v3 concentrated liquidity position or increase liquidity on an existing v3 NFT position on Robinhood Chain (4663).",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:'Optional existing v3 position NFT identifier to increase, as a decimal string; omit to mint. Example: "1".'},token0:{type:"string",description:"Sorted ERC-20 token0 address (e.g. WETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address (e.g. USDG)."},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"integer",enum:[100,500,3e3,1e4],default:100},fullRange:{type:"boolean",description:"For a new v3 position, use the widest ticks aligned to the pool fee tier; omit explicit ticks."},tickLower:{type:"integer",description:"Lower tick boundary divisible by tickSpacing."},tickUpper:{type:"integer",description:"Upper tick boundary divisible by tickSpacing."},amount0Desired:{type:"string",description:'Desired amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Desired:{type:"string",description:'Desired amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'},amount0Min:{type:"string",description:'Minimum amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Min:{type:"string",description:'Minimum amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."},wrapNative:{type:"boolean",description:"Optional: wrap native ETH into WETH before minting."},initialPrice:{type:"string",description:"Starting price as token1 per one token0 in human units; used only for a new pool. Pool creation and the first liquidity add require separate confirmations."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},execute:(c,r)=>dt(t,c,r)},{name:"uniswap_collect",inputSchema:{type:"object",description:"Collect accrued Uniswap v3 LP fees for an owned NonfungiblePositionManager NFT.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:'Identifier of the position NFT, as a decimal string. Example: "1".'},recipient:{type:"string",description:"Optional fee recipient; must be the signing wallet."},amount0Max:{type:"string",description:'Maximum amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Max:{type:"string",description:'Maximum amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'}},required:["tokenId"]},execute:(c,r)=>lt(t,c,r)},{name:"uniswap_remove",inputSchema:{type:"object",description:"Decrease liquidity on an owned Uniswap v3 NFT position, collect principal and fees, and optionally burn the empty NFT.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:'Identifier of the position NFT, as a decimal string. Example: "1".'},liquidity:{type:"string",description:'Liquidity in protocol base units, or "all" for a full exit where supported; not a token amount. Example: "1000" = 1000 liquidity units.'},amount0Min:{type:"string",description:'Minimum amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Min:{type:"string",description:'Minimum amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."},burn:{type:"boolean",description:"Whether to burn the NFT after removing 100% of liquidity, or burn an already-empty position."}},required:["tokenId"]},execute:(c,r)=>pt(t,c,r)},{name:"uniswap_list_positions",inputSchema:{type:"object",description:"List active Uniswap v3 LP positions owned by the wallet, 64 owner indices per page at one pinned block; follow nextCursor for more. Falls back to a bounded Transfer-log scan for managers that cannot enumerate by owner.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},wallet:{type:"string",description:"Optional wallet address override."},tokenIds:{type:"array",items:{type:"string"},description:'Optional v3 NFT identifiers as decimal strings, e.g. ["1", "2"]. Inspects exactly these NFTs without paging.'},cursor:et}},execute:(c,r)=>kt(t,c,r)},{name:"uniswap_create_pool",inputSchema:{type:"object",description:"Create and initialize an empty Uniswap v3 pool on Robinhood Chain (4663). Add liquidity afterwards with uniswap_add.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},token0:{type:"string",description:"Sorted ERC-20 token0 address (WETH, not native ETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address."},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"integer",enum:[100,500,3e3,1e4]},initialPrice:{type:"string",description:"Starting pool price as token1 per one token0 in human units. Add liquidity separately after initialization."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}},required:["token0","token1","fee"]},execute:(c,r)=>ut(t,c,r)}]}var He=t=>({tools:yt(t),positions:async e=>{let n,s=await Fe(t,e,{onPage:o=>{o.to>=o.balance||(n={module:"uniswap",id:"uniswap-v3-discovery-truncated",chainId:y,assets:[],incomplete:!0,description:`This wallet holds ${o.balance} Uniswap v3 position NFTs and only the first ${o.to} were checked, so later positions may be missing. Pass tokenIds to uniswap_list_positions to check the others, or page through them with uniswap_list_positions {"version":"v3"} and each nextCursor.`})}});return n?[...s,n]:s}}),Nt=He,Tt=He;export{re as a,se as b,G as c,et as d,w as e,Pe as f,qt as g,P as h,Y as i,he as j,tt as k,ot as l,rt as m,st as n,Re as o,Ut as p,Ve as q,dt as r,ut as s,lt as t,pt as u,Fe as v,kt as w,yt as x,He as y,Nt as z,Tt as A};
@@ -1 +1 @@
1
- import{b as z,c as I}from"./LFSJDFMY.js";import{b as W}from"./DMDOSHV7.js";import{d as R,e as _}from"./XV6F3RET.js";import{L as E}from"./SYERFEJ4.js";import{a as F}from"./43LI5NKJ.js";import{d as H,g as A,i as j}from"./NWNYJ26T.js";import{b as C,t as S}from"./TI727O2H.js";import{a as s}from"./XSD5NL7J.js";import{encodeFunctionData as M,erc20Abi as V,getAddress as Z,keccak256 as K,zeroAddress as x}from"viem";var r=R.turbo,h=R.blackjack,g=m=>j(m,"Provide an explicit card address.",H);function G(m,d){if(/^uint\d*\[\]$/.test(m.type)&&Array.isArray(d))return d.map(c=>G({...m,type:m.type.slice(0,-2)},c));if(/^uint\d*$/.test(m.type)&&(typeof d!="string"||!/^(0|[1-9]\d*)$/.test(d)))throw new s("Card integers must be canonical decimal strings, without leading zeros.");return W(m,d)}var J=["buy","cashOut","claimExpiry","refund","safeTransferFrom","safeBatchTransferFrom"],X=["liquidate","recordKnock","liquidateKnock","clearKnock","recordDrift","settle","markVoid","depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries","haltSales","resumeSales","sweepFees","skim"],Q=m=>m==="netnet_turbo_action"||m.startsWith("netnet_blackjack_")&&["netnet_blackjack_finalize","netnet_blackjack_expire","netnet_blackjack_claim"].includes(m);async function de(m,d,c,k){if(F(c),!Q(m))throw new s("No local NetNet card action builder exists.");let v=m!=="netnet_turbo_action";if(Object.keys(d).some(e=>!(v?["sessionId","seriesId"]:["operation","values","minimum","allowZeroPayout"]).includes(e)))throw new s("Unexpected card action argument.");if(v&&!z(m,d))throw new s("Recovery accepts exactly one positive decimal session or series ID.");if(await k.getChainId()!==C)throw new s("NetNet cards require chain 4663.");let w=await k.getBlock();if(w.number===null||!w.hash)throw new s("Card action block is unavailable.");let p=(e,t,i=[])=>k.readContract({address:e.address,abi:e.abi,functionName:t,args:i,blockNumber:w.number});for(let e of v?[r,h]:[r]){let t=await k.getCode({address:e.address,blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet card runtime changed or is unavailable. Requalify this deployment before signing.")}for(let e of v?Object.values(_):[_.turbo]){let t=await k.getCode({address:Z(e.address),blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet linked card library changed or is unavailable. Requalify before signing.")}let l={txs:[],inputs:[],cards:[],decision:"",blockNumber:w.number,blockHash:w.hash},$=(e,t,i,a,o)=>({chainId:4663,collection:r.address,operator:e,from:t,to:i,id:a,amount:o,operation:t===x?"mint":i===x?"burn":"transfer"}),T=(e,t,i,a,o=[])=>{l.txs.push({to:e,chainId:C,value:"0",data:M({abi:t,functionName:i,args:a}),description:l.decision}),l.cards.push(o)},D=(e,t)=>{if(t<=0n||t>=1n<<128n)throw new s("Card payment must be positive and below the exact-approval ceiling.");l.inputs.push({token:e,amount:t,to:r.address}),T(e,V,"approve",[r.address,t])};if(v){if(g(await p(h,"cards"))!==r.address||g(await p(h,"turbo"))!==r.address)throw new s("Blackjack card wiring changed.");let e=m==="netnet_blackjack_claim";if(Object.keys(d).some(b=>b!==(e?"seriesId":"sessionId")))throw new s("Recovery accepts only its one exact session or series ID.");let t=E(e?d.seriesId:d.sessionId),i,a,o,u="Original-series parked payout; self-claim only.";if(e){if(i=t,a=await p(h,"unclaimedChips",[t,c]),o="claimUnclaimedChips",a===0n)throw new s("This wallet has no parked chips for that series.")}else{let b=await p(h,"sessionOf",[t]);if(!b||!A(b.player,c))throw new s("Recovery is limited to this wallet\u2019s recorded blackjack session.");let y=m==="netnet_blackjack_finalize";if(o=y?"finalize":"expireSession",b.state!==(y?2:1))throw new s(y?"Session is not Closing. Use its current on-chain state to choose recovery.":"Session is not Open. A Closing session uses finalize after its challenge window.");let N=y?b.closeAt:b.deadline;if(u=y?`Challenge ends ${new Date(Number(N)*1e3).toISOString()}.`:`Session deadline ${new Date(Number(N)*1e3).toISOString()}; player-only expiry until ${new Date(Number(N+3600n)*1e3).toISOString()}.`,w.timestamp<N)throw new s(`Recovery is not due until ${N} Unix seconds.`);i=await p(h,"tableSeries"),a=b.chips}if(i<=0n||a<0n)throw new s("Blackjack recovery accounting is unavailable.");return l.decision=`${o} ${e?"series":"session"} ${t} at ${h.address}: return ${a} whole cards of collection ${r.address}, series ${i}, to ${Z(c)}. ${u} Last on-chain chips may omit off-chain winnings; cards may be worthless. A failed receiver parks the payout at ${h.address}; self-claim only. ETH gas extra.`,T(h.address,h.abi,o,[t],a===0n?[]:[$(h.address,h.address,c,i,a)]),l.recovery={...e?{}:{sessionId:t.toString()},seriesId:i.toString(),count:a.toString(),player:c,operation:o},l}let n=String(d.operation);if(n==="setApprovalForAll")throw new s(I.setApprovalForAll);if(["convertPremiums","convertSleeveFees"].includes(n))throw new s(I.conversion);if(![...J,...X].includes(n))throw new s("Choose a qualified finite TURBO operation.");if(!Array.isArray(d.values))throw new s("Provide ordered TURBO values using decimal integer strings.");let U=n==="safeTransferFrom"||n==="safeBatchTransferFrom",B=r.abi.find(e=>e.name===n),q=U?B.inputs.slice(1,-1):B.inputs;if(d.values.length!==q.length)throw new s("TURBO values do not match the exact operation inputs.");let f=q.map((e,t)=>G(e,d.values[t])),O=g(await p(r,"manager")),L=g(await p(r,"sleeve")),P=[];if(U){if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Transfer has no payout floor.");let e=g(f[0]);if(e===x||A(e,c))throw new s("Name a nonzero, non-self card recipient.");let t=await k.getCode({address:e,blockNumber:w.number});if(t&&t!=="0x")throw new s("Card transfer to a contract requires qualified credit and recovery. New blackjack seating remains disabled.");let i=n==="safeTransferFrom"?[f[1]]:f[1],a=n==="safeTransferFrom"?[f[2]]:f[2];if(!i.length||i.length>8||i.length!==a.length||new Set(i.map(String)).size!==i.length||i.some((o,u)=>o<=0n||a[u]<=0n||u>0&&o<=i[u-1]))throw new s("Use at most eight unique positive series IDs in increasing order and exact positive counts.");for(let o=0;o<i.length;o++){if(await p(r,"balanceOf",[c,i[o]])<a[o])throw new s("Card transfer exceeds this wallet\u2019s balance.");P.push($(c,c,e,i[o],a[o])),l.inputs.push({token:r.address,id:i[o],amount:a[o],to:e,exact:!0})}l.decision=`Transfer whole cards of collection ${r.address}: ${i.map((o,u)=>`series ${o} count ${a[u]}`).join(", ")} to ${e}. Basis does not travel with cards; no operator approval. No payout; transfer is irreversible. ETH gas extra.`,f=[c,...f,"0x"]}else if(["buy","cashOut","claimExpiry","refund"].includes(n)){let e=f[0],t=f[1],i=await p(r,"seriesOf",[e]);if(!i||i.asset===x||t<=0n)throw new s("Choose a known series and positive whole-card count.");let a=i.side===0?g(i.asset):S.mainnet.usdg,o=await k.readContract({address:a,abi:V,functionName:"decimals",blockNumber:w.number});if((n==="buy"||n==="cashOut")&&(i.state!==1||w.timestamp>=i.expiry))throw new s("This TURBO series is not OPEN and unexpired.");if(n==="buy"){let[u]=await p(r,"quoteBuy",[e,t]);if(!u||u>f[2])throw new s("Current card quote exceeds the explicit maximum USDG payment.");if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Buy uses its exact count and maximum USDG price.");l.decision=`Spend at most ${f[2]} USDG base units (${S.mainnet.usdg}, decimals 6) at ${r.address}; receive ${t} whole cards, collection ${r.address}, series ${e}, into this wallet. Exact quoted approval ${u}; fees included. Strike ${i.strikeWad} WAD; expiry ${new Date(Number(i.expiry)*1e3).toISOString()}; cards can lose all value. Any residual USDG allowance requires zero cleanup. ETH gas extra.`,D(S.mainnet.usdg,u),P=[$(c,x,c,e,t)]}else{if(n==="cashOut"&&d.minimum!==void 0)throw new s("cashOut takes its one encoded minimum in values, not a second local minimum.");if(await p(r,"balanceOf",[c,e])<t)throw new s("Card burn exceeds this wallet\u2019s balance.");let u=n==="cashOut"?f[2]:E(d.minimum,!0);if(u===0n&&d.allowZeroPayout!==!0)throw new s("A zero payout floor requires allowZeroPayout:true and explicit human confirmation.");let b=0n;if(n==="cashOut"){let y=await p(r,"quoteCashOut",[e,t,c]);if(y[0]<u)throw new s("The current cash-out quote misses the payout minimum.");b=y[1]}else if(i.state!==(n==="claimExpiry"?3:4))throw new s("Expiry claims require EXPIRED; pro-rata refunds require VOID.");l.decision=`Burn ${t} whole cards of ${r.address}, series ${e}; ${n==="refund"?"series pro-rata VOID refund, not personal purchase-price repayment":n}; receive >=${u} base units of ${a} (decimals ${o}) into this wallet. ${n==="cashOut"?`Minimum encoded in calldata; current performance fee ${b}.`:"Floor is local simulation only; no on-chain minimum. Settled payout includes applicable fees."} Burned cards cannot be returned; ETH gas extra.`,P=[$(c,c,x,e,t)],l.inputs.push({token:r.address,id:e,amount:t,to:x,exact:!0}),l.receipt={token:a,minimum:u,recipient:c,enforcement:n==="cashOut"?"calldata":"simulation"}}}else{if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("This TURBO operation has no caller payout floor.");if(["withdrawHouse","withdrawPutPot","createSeries","resumeSales"].includes(n)&&!A(O,c))throw new s(`This TURBO operation requires manager ${O}.`);if(n==="haltSales"&&!A(c,O)&&!A(c,g(await p(r,"halter"))))throw new s("TURBO haltSales requires the current manager or halter.");if(["depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries"].includes(n)){let t=g(f[0]);if(!(await Promise.all(["asset0","asset1","asset2"].map(a=>p(r,a)))).some(a=>typeof a=="string"&&A(a,t)))throw new s("This is not a pinned TURBO reserve asset.")}l.decision=`${n} at ${r.address}; values ${JSON.stringify(f,(t,i)=>typeof i=="bigint"?String(i):i)}. Protocol capital/accounting action; manager ${O}; sleeve ${L}; no caller reward. ${n.startsWith("deposit")?"Irreversible house funding; no personal withdrawable balance.":n.startsWith("withdraw")?"Pays the current manager; operating and reservation floors still apply.":"Series state, risk or protocol fee allocation may change."} No card approval; ETH gas extra.`,(n==="depositHouse"||n==="depositPutPot")&&D(n==="depositHouse"?g(f[0]):S.mainnet.usdg,f[1])}if(l.decision.length>1024)throw new s("Card decision terms exceed the complete confirmation label capacity. Use fewer card IDs.");T(r.address,r.abi,n,f,P);for(let e of l.txs)e.description=l.decision;return l}export{J as a,X as b,Q as c,de as d};
1
+ import{b as W}from"./DMDOSHV7.js";import{d as R,e as _}from"./XV6F3RET.js";import{b as z,c as I}from"./LFSJDFMY.js";import{L as E}from"./MQXSCNUL.js";import{a as F}from"./43LI5NKJ.js";import{d as H,g as A,i as j}from"./NWNYJ26T.js";import{b as C,t as S}from"./TI727O2H.js";import{a as s}from"./XSD5NL7J.js";import{encodeFunctionData as M,erc20Abi as V,getAddress as Z,keccak256 as K,zeroAddress as x}from"viem";var r=R.turbo,h=R.blackjack,g=m=>j(m,"Provide an explicit card address.",H);function G(m,d){if(/^uint\d*\[\]$/.test(m.type)&&Array.isArray(d))return d.map(c=>G({...m,type:m.type.slice(0,-2)},c));if(/^uint\d*$/.test(m.type)&&(typeof d!="string"||!/^(0|[1-9]\d*)$/.test(d)))throw new s("Card integers must be canonical decimal strings, without leading zeros.");return W(m,d)}var J=["buy","cashOut","claimExpiry","refund","safeTransferFrom","safeBatchTransferFrom"],X=["liquidate","recordKnock","liquidateKnock","clearKnock","recordDrift","settle","markVoid","depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries","haltSales","resumeSales","sweepFees","skim"],Q=m=>m==="netnet_turbo_action"||m.startsWith("netnet_blackjack_")&&["netnet_blackjack_finalize","netnet_blackjack_expire","netnet_blackjack_claim"].includes(m);async function de(m,d,c,k){if(F(c),!Q(m))throw new s("No local NetNet card action builder exists.");let v=m!=="netnet_turbo_action";if(Object.keys(d).some(e=>!(v?["sessionId","seriesId"]:["operation","values","minimum","allowZeroPayout"]).includes(e)))throw new s("Unexpected card action argument.");if(v&&!z(m,d))throw new s("Recovery accepts exactly one positive decimal session or series ID.");if(await k.getChainId()!==C)throw new s("NetNet cards require chain 4663.");let w=await k.getBlock();if(w.number===null||!w.hash)throw new s("Card action block is unavailable.");let p=(e,t,i=[])=>k.readContract({address:e.address,abi:e.abi,functionName:t,args:i,blockNumber:w.number});for(let e of v?[r,h]:[r]){let t=await k.getCode({address:e.address,blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet card runtime changed or is unavailable. Requalify this deployment before signing.")}for(let e of v?Object.values(_):[_.turbo]){let t=await k.getCode({address:Z(e.address),blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet linked card library changed or is unavailable. Requalify before signing.")}let l={txs:[],inputs:[],cards:[],decision:"",blockNumber:w.number,blockHash:w.hash},$=(e,t,i,a,o)=>({chainId:4663,collection:r.address,operator:e,from:t,to:i,id:a,amount:o,operation:t===x?"mint":i===x?"burn":"transfer"}),T=(e,t,i,a,o=[])=>{l.txs.push({to:e,chainId:C,value:"0",data:M({abi:t,functionName:i,args:a}),description:l.decision}),l.cards.push(o)},D=(e,t)=>{if(t<=0n||t>=1n<<128n)throw new s("Card payment must be positive and below the exact-approval ceiling.");l.inputs.push({token:e,amount:t,to:r.address}),T(e,V,"approve",[r.address,t])};if(v){if(g(await p(h,"cards"))!==r.address||g(await p(h,"turbo"))!==r.address)throw new s("Blackjack card wiring changed.");let e=m==="netnet_blackjack_claim";if(Object.keys(d).some(b=>b!==(e?"seriesId":"sessionId")))throw new s("Recovery accepts only its one exact session or series ID.");let t=E(e?d.seriesId:d.sessionId),i,a,o,u="Original-series parked payout; self-claim only.";if(e){if(i=t,a=await p(h,"unclaimedChips",[t,c]),o="claimUnclaimedChips",a===0n)throw new s("This wallet has no parked chips for that series.")}else{let b=await p(h,"sessionOf",[t]);if(!b||!A(b.player,c))throw new s("Recovery is limited to this wallet\u2019s recorded blackjack session.");let y=m==="netnet_blackjack_finalize";if(o=y?"finalize":"expireSession",b.state!==(y?2:1))throw new s(y?"Session is not Closing. Use its current on-chain state to choose recovery.":"Session is not Open. A Closing session uses finalize after its challenge window.");let N=y?b.closeAt:b.deadline;if(u=y?`Challenge ends ${new Date(Number(N)*1e3).toISOString()}.`:`Session deadline ${new Date(Number(N)*1e3).toISOString()}; player-only expiry until ${new Date(Number(N+3600n)*1e3).toISOString()}.`,w.timestamp<N)throw new s(`Recovery is not due until ${N} Unix seconds.`);i=await p(h,"tableSeries"),a=b.chips}if(i<=0n||a<0n)throw new s("Blackjack recovery accounting is unavailable.");return l.decision=`${o} ${e?"series":"session"} ${t} at ${h.address}: return ${a} whole cards of collection ${r.address}, series ${i}, to ${Z(c)}. ${u} Last on-chain chips may omit off-chain winnings; cards may be worthless. A failed receiver parks the payout at ${h.address}; self-claim only. ETH gas extra.`,T(h.address,h.abi,o,[t],a===0n?[]:[$(h.address,h.address,c,i,a)]),l.recovery={...e?{}:{sessionId:t.toString()},seriesId:i.toString(),count:a.toString(),player:c,operation:o},l}let n=String(d.operation);if(n==="setApprovalForAll")throw new s(I.setApprovalForAll);if(["convertPremiums","convertSleeveFees"].includes(n))throw new s(I.conversion);if(![...J,...X].includes(n))throw new s("Choose a qualified finite TURBO operation.");if(!Array.isArray(d.values))throw new s("Provide ordered TURBO values using decimal integer strings.");let U=n==="safeTransferFrom"||n==="safeBatchTransferFrom",B=r.abi.find(e=>e.name===n),q=U?B.inputs.slice(1,-1):B.inputs;if(d.values.length!==q.length)throw new s("TURBO values do not match the exact operation inputs.");let f=q.map((e,t)=>G(e,d.values[t])),O=g(await p(r,"manager")),L=g(await p(r,"sleeve")),P=[];if(U){if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Transfer has no payout floor.");let e=g(f[0]);if(e===x||A(e,c))throw new s("Name a nonzero, non-self card recipient.");let t=await k.getCode({address:e,blockNumber:w.number});if(t&&t!=="0x")throw new s("Card transfer to a contract requires qualified credit and recovery. New blackjack seating remains disabled.");let i=n==="safeTransferFrom"?[f[1]]:f[1],a=n==="safeTransferFrom"?[f[2]]:f[2];if(!i.length||i.length>8||i.length!==a.length||new Set(i.map(String)).size!==i.length||i.some((o,u)=>o<=0n||a[u]<=0n||u>0&&o<=i[u-1]))throw new s("Use at most eight unique positive series IDs in increasing order and exact positive counts.");for(let o=0;o<i.length;o++){if(await p(r,"balanceOf",[c,i[o]])<a[o])throw new s("Card transfer exceeds this wallet\u2019s balance.");P.push($(c,c,e,i[o],a[o])),l.inputs.push({token:r.address,id:i[o],amount:a[o],to:e,exact:!0})}l.decision=`Transfer whole cards of collection ${r.address}: ${i.map((o,u)=>`series ${o} count ${a[u]}`).join(", ")} to ${e}. Basis does not travel with cards; no operator approval. No payout; transfer is irreversible. ETH gas extra.`,f=[c,...f,"0x"]}else if(["buy","cashOut","claimExpiry","refund"].includes(n)){let e=f[0],t=f[1],i=await p(r,"seriesOf",[e]);if(!i||i.asset===x||t<=0n)throw new s("Choose a known series and positive whole-card count.");let a=i.side===0?g(i.asset):S.mainnet.usdg,o=await k.readContract({address:a,abi:V,functionName:"decimals",blockNumber:w.number});if((n==="buy"||n==="cashOut")&&(i.state!==1||w.timestamp>=i.expiry))throw new s("This TURBO series is not OPEN and unexpired.");if(n==="buy"){let[u]=await p(r,"quoteBuy",[e,t]);if(!u||u>f[2])throw new s("Current card quote exceeds the explicit maximum USDG payment.");if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Buy uses its exact count and maximum USDG price.");l.decision=`Spend at most ${f[2]} USDG base units (${S.mainnet.usdg}, decimals 6) at ${r.address}; receive ${t} whole cards, collection ${r.address}, series ${e}, into this wallet. Exact quoted approval ${u}; fees included. Strike ${i.strikeWad} WAD; expiry ${new Date(Number(i.expiry)*1e3).toISOString()}; cards can lose all value. Any residual USDG allowance requires zero cleanup. ETH gas extra.`,D(S.mainnet.usdg,u),P=[$(c,x,c,e,t)]}else{if(n==="cashOut"&&d.minimum!==void 0)throw new s("cashOut takes its one encoded minimum in values, not a second local minimum.");if(await p(r,"balanceOf",[c,e])<t)throw new s("Card burn exceeds this wallet\u2019s balance.");let u=n==="cashOut"?f[2]:E(d.minimum,!0);if(u===0n&&d.allowZeroPayout!==!0)throw new s("A zero payout floor requires allowZeroPayout:true and explicit human confirmation.");let b=0n;if(n==="cashOut"){let y=await p(r,"quoteCashOut",[e,t,c]);if(y[0]<u)throw new s("The current cash-out quote misses the payout minimum.");b=y[1]}else if(i.state!==(n==="claimExpiry"?3:4))throw new s("Expiry claims require EXPIRED; pro-rata refunds require VOID.");l.decision=`Burn ${t} whole cards of ${r.address}, series ${e}; ${n==="refund"?"series pro-rata VOID refund, not personal purchase-price repayment":n}; receive >=${u} base units of ${a} (decimals ${o}) into this wallet. ${n==="cashOut"?`Minimum encoded in calldata; current performance fee ${b}.`:"Floor is local simulation only; no on-chain minimum. Settled payout includes applicable fees."} Burned cards cannot be returned; ETH gas extra.`,P=[$(c,c,x,e,t)],l.inputs.push({token:r.address,id:e,amount:t,to:x,exact:!0}),l.receipt={token:a,minimum:u,recipient:c,enforcement:n==="cashOut"?"calldata":"simulation"}}}else{if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("This TURBO operation has no caller payout floor.");if(["withdrawHouse","withdrawPutPot","createSeries","resumeSales"].includes(n)&&!A(O,c))throw new s(`This TURBO operation requires manager ${O}.`);if(n==="haltSales"&&!A(c,O)&&!A(c,g(await p(r,"halter"))))throw new s("TURBO haltSales requires the current manager or halter.");if(["depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries"].includes(n)){let t=g(f[0]);if(!(await Promise.all(["asset0","asset1","asset2"].map(a=>p(r,a)))).some(a=>typeof a=="string"&&A(a,t)))throw new s("This is not a pinned TURBO reserve asset.")}l.decision=`${n} at ${r.address}; values ${JSON.stringify(f,(t,i)=>typeof i=="bigint"?String(i):i)}. Protocol capital/accounting action; manager ${O}; sleeve ${L}; no caller reward. ${n.startsWith("deposit")?"Irreversible house funding; no personal withdrawable balance.":n.startsWith("withdraw")?"Pays the current manager; operating and reservation floors still apply.":"Series state, risk or protocol fee allocation may change."} No card approval; ETH gas extra.`,(n==="depositHouse"||n==="depositPutPot")&&D(n==="depositHouse"?g(f[0]):S.mainnet.usdg,f[1])}if(l.decision.length>1024)throw new s("Card decision terms exceed the complete confirmation label capacity. Use fewer card IDs.");T(r.address,r.abi,n,f,P);for(let e of l.txs)e.description=l.decision;return l}export{J as a,X as b,Q as c,de as d};
@@ -1 +1 @@
1
- import{a,g as i}from"./LVFI74ST.js";import{a as n}from"./SPJCSEKP.js";import{a as t}from"./XSD5NL7J.js";async function m(r,c,o){if(!Object.hasOwn(a,r.name))throw new t("Local Factor guard cannot rebuild this action; nothing was signed.");if(r.chainId!==void 0&&r.chainId!==4663)throw new t("Local Factor guard requires chain 4663; nothing was signed.");let e=async()=>{throw new t("Local Factor reconstruction uses no swap or preview service.")},s=n({clientFor:d=>{if(d!==4663)throw new t("Local Factor guard requires chain 4663.");return o.client},http:o.http??fetch,preview:e,quoteSwap:e,buildSwap:e});return i(s,r.name,r.args,c)}export{m as a};
1
+ import{a,g as i}from"./XNJ6NDQQ.js";import{a as n}from"./SPJCSEKP.js";import{a as t}from"./XSD5NL7J.js";async function m(r,c,o){if(!Object.hasOwn(a,r.name))throw new t("Local Factor guard cannot rebuild this action; nothing was signed.");if(r.chainId!==void 0&&r.chainId!==4663)throw new t("Local Factor guard requires chain 4663; nothing was signed.");let e=async()=>{throw new t("Local Factor reconstruction uses no swap or preview service.")},s=n({clientFor:d=>{if(d!==4663)throw new t("Local Factor guard requires chain 4663.");return o.client},http:o.http??fetch,preview:e,quoteSwap:e,buildSwap:e});return i(s,r.name,r.args,c)}export{m as a};
@@ -1 +1 @@
1
- import{b as T}from"./QMNUB2GM.js";import{c as A}from"./FAH7FKUT.js";import{i as b}from"./NMJVQX5M.js";import{n as P}from"./BA66J5YQ.js";import{b as f,j as g}from"./TI727O2H.js";var U=.5,E=394930n,C=315200n,R=1000000000n,x=10000n*10n**18n,M="fees estimated high because the live price was unavailable";function I(s,r){if(s.impliedApy===void 0)return{reason:"Pendle's service gave no rate, so Oak won't show one."};let t=Math.expm1(Number(r)/1e18)*100,n=s.impliedApy*100;return!Number.isFinite(t)||!Number.isFinite(n)?{reason:"the rate could not be checked against the chain, so Oak won't show one."}:Math.abs(n-t)>U?{reason:`The rate Pendle's service lists (${n.toFixed(2)}% a year) differs from the chain's (${t.toFixed(2)}% a year) by more than ${U} points, so Oak won't show one.`}:{ratePct:n}}async function S(s,r){let t=s.clientFor(f),n=await t.getGasPrice().catch(()=>{}),i=r;i===void 0&&(i=await P(g[f].tokens.WETH.address,{client:t}).then(a=>BigInt(a.usdE18),()=>{}));let o=n!==void 0&&n>0n&&i!==void 0&&i>0n?{gasPrice:n,ethUsd:i}:void 0,{gasPrice:u,ethUsd:h}=o??{gasPrice:R,ethUsd:x},m=a=>Number(a*u*h)/1e36;return{inUsd:m(E),outUsd:m(C),checks:o?[]:[M]}}async function v(s,r,t={}){let n=s.clientFor(f),i=t.now??Math.floor(Date.now()/1e3),o=await b(s,{allowChain:!1}),u=await T(n,r,o.rows),h=e=>(u.get(e.pt.toLowerCase())??0n)>0n,m=o.rows.filter(e=>e.active&&e.expiry>i||h(e)),[{ok:a,dropped:_},p]=await Promise.all([A(n,m,{now:i}),S(s,t.ethUsdE18)]),y=[...o.dropped,..._],l=[];for(let{row:e,facts:d}of a){let c=d.verified,k={market:e.market,kind:c.kind,unitSymbol:c.inputSymbol,unitDecimals:c.inputDecimals,endsAt:c.expiry,liquidityUsd:e.liquidityUsd??0,ptBalanceBase:u.get(e.pt.toLowerCase())??0n,gasInUsd:p.inUsd,gasOutUsd:p.outUsd};if(c.expired){k.ptBalanceBase>0n&&l.push({...k,ratePct:0,matured:!0,checks:["this term has ended",...p.checks]});continue}if(!e.active)continue;let w=I(e,d.lnImpliedRate);if("reason"in w){y.push(`${e.market}: ${w.reason}`);continue}l.push({...k,ratePct:w.ratePct,matured:!1,checks:[...e.liquidityUsd===void 0?["liquidity was not reported"]:[],...p.checks]})}return l.sort((e,d)=>e.kind===d.kind?e.endsAt-d.endsAt:e.kind==="stable"?-1:1),{terms:l,dropped:y}}async function L(s,r,t={}){return(await v(s,r,t)).terms}export{I as a,v as b,L as c};
1
+ import{b as T}from"./QMNUB2GM.js";import{c as A}from"./FAH7FKUT.js";import{i as b}from"./NMJVQX5M.js";import{o as P}from"./7OOCAZBE.js";import{b as f,j as g}from"./TI727O2H.js";var U=.5,E=394930n,C=315200n,R=1000000000n,x=10000n*10n**18n,M="fees estimated high because the live price was unavailable";function I(s,r){if(s.impliedApy===void 0)return{reason:"Pendle's service gave no rate, so Oak won't show one."};let t=Math.expm1(Number(r)/1e18)*100,n=s.impliedApy*100;return!Number.isFinite(t)||!Number.isFinite(n)?{reason:"the rate could not be checked against the chain, so Oak won't show one."}:Math.abs(n-t)>U?{reason:`The rate Pendle's service lists (${n.toFixed(2)}% a year) differs from the chain's (${t.toFixed(2)}% a year) by more than ${U} points, so Oak won't show one.`}:{ratePct:n}}async function S(s,r){let t=s.clientFor(f),n=await t.getGasPrice().catch(()=>{}),i=r;i===void 0&&(i=await P(g[f].tokens.WETH.address,{client:t}).then(a=>BigInt(a.usdE18),()=>{}));let o=n!==void 0&&n>0n&&i!==void 0&&i>0n?{gasPrice:n,ethUsd:i}:void 0,{gasPrice:u,ethUsd:h}=o??{gasPrice:R,ethUsd:x},m=a=>Number(a*u*h)/1e36;return{inUsd:m(E),outUsd:m(C),checks:o?[]:[M]}}async function v(s,r,t={}){let n=s.clientFor(f),i=t.now??Math.floor(Date.now()/1e3),o=await b(s,{allowChain:!1}),u=await T(n,r,o.rows),h=e=>(u.get(e.pt.toLowerCase())??0n)>0n,m=o.rows.filter(e=>e.active&&e.expiry>i||h(e)),[{ok:a,dropped:_},p]=await Promise.all([A(n,m,{now:i}),S(s,t.ethUsdE18)]),y=[...o.dropped,..._],l=[];for(let{row:e,facts:d}of a){let c=d.verified,k={market:e.market,kind:c.kind,unitSymbol:c.inputSymbol,unitDecimals:c.inputDecimals,endsAt:c.expiry,liquidityUsd:e.liquidityUsd??0,ptBalanceBase:u.get(e.pt.toLowerCase())??0n,gasInUsd:p.inUsd,gasOutUsd:p.outUsd};if(c.expired){k.ptBalanceBase>0n&&l.push({...k,ratePct:0,matured:!0,checks:["this term has ended",...p.checks]});continue}if(!e.active)continue;let w=I(e,d.lnImpliedRate);if("reason"in w){y.push(`${e.market}: ${w.reason}`);continue}l.push({...k,ratePct:w.ratePct,matured:!1,checks:[...e.liquidityUsd===void 0?["liquidity was not reported"]:[],...p.checks]})}return l.sort((e,d)=>e.kind===d.kind?e.endsAt-d.endsAt:e.kind==="stable"?-1:1),{terms:l,dropped:y}}async function L(s,r,t={}){return(await v(s,r,t)).terms}export{I as a,v as b,L as c};
@@ -1 +1 @@
1
- import{b as Z}from"./SRHVSNPX.js";import{a as I,b as J,d as V}from"./RUTSEGGD.js";import{a as Q}from"./CEQNXF6A.js";import{a as E}from"./QYKXWBZC.js";import{L as y}from"./SYERFEJ4.js";import{c as $}from"./4J245N3F.js";import{a as H}from"./43LI5NKJ.js";import{a as N}from"./66F5ZH34.js";import{d as M,g as O,i as K}from"./NWNYJ26T.js";import{b}from"./TI727O2H.js";import{a as e}from"./XSD5NL7J.js";import{encodeFunctionData as Y,erc20Abi as X,getAddress as W,parseAbi as ee,zeroAddress as te}from"viem";var v={address:W("0xCeF73866b088766DeD46Ba71d9Bd7591B5e931d2"),symbol:"tNET",decimals:9,chainId:b},_={pair_oracle:["checkpoint"],futures:["open","close","marginCall","accrueCarry","sweepCarrySkim"],underwriting:["subscribe","redeem"],prize:["enter","enterWithNet","exit","exitToUsdg","lockTranche","earlyUnlock","pokeRebase"]},fe=x=>({tools:[{name:"netnet_desk_action",inputSchema:{type:"object",additionalProperties:!1,required:["program","operation"],properties:{program:{type:"string",enum:Object.keys(_),description:"Desk program: pair_oracle (price checkpoint), futures, underwriting or prize (WinNET)."},operation:{type:"string",enum:[...new Set(Object.values(_).flat())],description:"Action to run; it must be one the chosen program supports (see the program list in this tool)."},amount:N('Amount in base units of the token the operation spends or moves: tNET 9 decimals for futures and underwriting, USDG 6 or NET 9 for prize. Example: "1000000000" = 1 NET.'),minAmountOut:N('Least output you must receive, in base units of the output token (USDG 6 decimals, NET 9, underwriting shares). Example: "1000000" = 1 USDG.'),maxPayment:N('Most tNET you will pay for futures open (margin plus fee), in tNET base units (9 decimals). Example: "1000000000" = 1 tNET.'),sizeUsdWad:N('Futures position notional in USD as an 18-decimal wad in base units (1e18 = 1 USD). Example: "100000000000000000000" = 100 USD.'),isLong:{type:"boolean",description:"Futures open only: true for a long position, false for a short."},account:{type:"string",description:"Futures marginCall only: address of the trader to margin-call; they must be liquidatable."},referrer:{type:"string",description:"Prize enter only: optional referrer address recorded at the first deposit; cannot be your own wallet."},trancheIndex:N('Zero-based index of your WinNET tranche to lock or unlock early, as a decimal string. Example: "0".'),lockDraws:{enum:["7","30"],description:"Prize lockTranche only: commit the tranche for 7 or 30 draws."},maxPenaltyAssets:N('Prize earlyUnlock only: highest forfeited principal you accept, in NET base units (9 decimals). Example: "1000000000" = 1 NET.')}},execute:async(t,m)=>{try{if(H(m),typeof t.program!="string"||!Object.hasOwn(_,t.program)||typeof t.operation!="string"||!_[t.program].includes(t.operation))throw new e("Choose a supported finite NetNet desk operation.");let p=t.program,r=t.operation,P=E[p],z=Q[p],T=x.clientFor(b);if(await T.getChainId()!==b)throw new e("NetNet desk actions require chain 4663.");let D=await T.getBlock(),q=new Set(["program","operation"]),u=(n,s=[])=>T.readContract({address:P.address,abi:z,functionName:n,args:s,blockNumber:D.number}),h=(...n)=>n.forEach(s=>q.add(s)),A=()=>(h("amount"),y(t.amount)),S=()=>(h("minAmountOut"),y(t.minAmountOut)),d=n=>K(n,"Provide an explicit checksummed account.",M),l=[],a,c=0n,w="",g;if(p==="pair_oracle"){if(d(await u("pairContract"))!==Z)throw new e("The oracle does not use the pinned canonical pair.");w="Permissionless oracle checkpoint; it sends no reward to this wallet and may not yet produce a valid TWAP."}else if(p==="futures"||p==="underwriting"){if(d(await u("token"))!==v.address||await T.readContract({address:v.address,abi:X,functionName:"decimals",blockNumber:D.number})!==9)throw new e("This desk does not use the pinned valueless 9-decimal tNET test collateral.");let n=E.futures.address,s=E.underwriting.address;if(p==="futures"?d(await u("vault"))!==s:d(await u("clearinghouse"))!==n)throw new e("Futures and underwriting counterparties do not match the published pins.");if(w="Experimental tNET test program; tNET has no monetary value. Futures margin and underwriting capital can be lost. Utilization/ADL can prevent redemption. Prices and fees are read from the contract oracle; these calls encode no price floor.",r==="open"){if(h("isLong","sizeUsdWad","maxPayment"),typeof t.isLong!="boolean")throw new e("Provide isLong as a boolean.");let o=A(),f=y(t.sizeUsdWad);if(o>=1n<<128n||f>=1n<<128n)throw new e("Position margin and notional must fit uint128.");let k=d(await u("oracle"));if(k!==W("0xc8a11E8793F8714a159061369173dc86A0A5E23F"))throw new e("The futures oracle is not the published deployment.");let C=await T.readContract({address:k,abi:ee(["function marginPriceWad() view returns (uint256)"]),functionName:"marginPriceWad",blockNumber:D.number});if(C<=0n)throw new e("Futures margin price is unavailable.");let i=f*5n/10000n*1000000000n/C;if(c=o+i,a=v,c>y(t.maxPayment))throw new e("Margin plus taker fee exceeds maxPayment.");l=[t.isLong,f,o],w+=` Entry fee ${i} tNET base units; exact approval caps price drift and may require a fresh preview.`}else if(r==="marginCall"){h("account");let o=d(t.account);if(await u("liquidatable",[o])!==!0)throw new e("The selected futures trader is not liquidatable.");l=[o]}else if(r==="subscribe"){c=A(),a=v,l=[c];let[o,f]=await Promise.all([u("totalShares"),u("equityTokens")]);if(typeof o!="bigint"||typeof f!="bigint"||o>0n&&f===0n)throw new e("Underwriting share price is invalid.");let k=o===0n?c:c*o/f;if(k===0n||k<S())throw new e("Underwriting subscription rounds to zero or misses the local share minimum.");w+=` Current quote ${k} underwriting share units; the share minimum is a local check, not encoded calldata.`}else if(r==="redeem"){let o=A();if(o>await u("sharesOf",[m]))throw new e("The wallet has insufficient underwriting shares.");l=[o],g={token:v,amount:S()}}}else{let[n,s,o,f,k,C]=await Promise.all(["net","usdg","staking","sNet","controller","book"].map(i=>u(i)));if(d(n)!==I.address||d(s)!==$.address||d(o)!==V||d(f)!==J.address||d(k)!==E.draw.address||d(C)!==E.bonus.address)throw new e("WinNET token, staking, book or controller does not match its published pins.");if(w="WinNET principal is a fixed NET claim, exposed to NET price changes. Entry commits through three staking epochs; locks commit for 7 or 30 draws. Early unlock forfeits 1% of principal and cancels streak credits. Pair buys and sells each incur the NET trading tax; no prize or return is guaranteed.",r==="enter"||r==="enterWithNet"){h("referrer");let i=t.referrer===void 0?te:d(t.referrer);if(i===W(m))throw new e("WinNET does not permit self-referral.");c=A(),a=r==="enter"?$:I,l=r==="enter"?[c,S(),i]:[c,i],w+=` Referrer ${i} is recorded at the first deposit and cannot later be changed.`}else if(r==="exit"||r==="exitToUsdg"){let i=A();if(i>await u("principalOf",[m]))throw new e("WinNET exit exceeds this wallet\u2019s fixed principal.");l=r==="exit"?[i,m]:[i,S(),m],g={token:r==="exit"?I:$,amount:r==="exit"?i:y(t.minAmountOut)}}else if(r==="lockTranche"||r==="earlyUnlock"){h("trancheIndex");let i=y(t.trancheIndex,!0),U=await u("trancheAt",[m,i]);if(!Array.isArray(U)||typeof U[0]!="bigint"||U[0]===0n)throw new e("Choose a nonempty WinNET tranche.");if(r==="lockTranche"){if(h("lockDraws"),t.lockDraws!=="7"&&t.lockDraws!=="30")throw new e("Choose a 7- or 30-draw lock.");l=[i,BigInt(t.lockDraws)]}else{h("maxPenaltyAssets");let j=(U[0]+99n)/100n;if(j>y(t.maxPenaltyAssets,!0))throw new e("Early unlock exceeds maxPenaltyAssets in NET base units.");l=[i],w+=` Current irreversible forfeiture ${j} NET base units.`}}}if(Object.keys(t).some(n=>!q.has(n)))throw new e("Unexpected fields for this desk operation.");if(a&&await T.readContract({address:a.address,abi:X,functionName:"balanceOf",args:[m],blockNumber:D.number})<c)throw new e(`Top up ${a.symbol}; this action needs ${c} base units.`);let F=`NetNet ${p}.${r}, contract ${P.address}, chain ${b}, ordered values ${JSON.stringify(l,(n,s)=>typeof s=="bigint"?String(s):s)}. ${a?`Approve exactly ${c} ${a.symbol} base units (token ${a.address}, decimals ${a.decimals}). `:""}${w}`,L=[...a?[x.approval(a.address,P.address,c.toString(),b)]:[],x.unsignedTx({to:P.address,data:Y({abi:z,functionName:r,args:l}),value:"0",chainId:b,description:F})],R=await x.preview(L,m),B=0n,G=0n;for(let n of R.changes){if(n.token.chainId!==b||!/^-?\d+$/.test(n.amount))throw new e("Invalid desk preview metadata.");let s=BigInt(n.amount);if(s<0n){if(!a||!O(n.token.address,a.address)||n.token.decimals!==a.decimals)throw new e("Desk preview spends an unexpected wallet asset.");B-=s}if(g&&O(n.token.address,g.token.address)){if(n.token.decimals!==g.token.decimals)throw new e("Desk receipt decimals mismatch.");G+=s}}if(B>c||g&&G<g.amount)throw new e("Desk preview exceeds its input budget or misses the requested receipt minimum.");return{txs:L,preview:R,summary:F}}catch(p){throw new e(x.plainError(p))}}}]});export{v as a,fe as b};
1
+ import{b as Z}from"./CNDIAF3P.js";import{a as I,b as J,d as V}from"./RUTSEGGD.js";import{a as E}from"./QYKXWBZC.js";import{a as Q}from"./CEQNXF6A.js";import{L as y}from"./MQXSCNUL.js";import{c as $}from"./N624NR7Y.js";import{a as H}from"./43LI5NKJ.js";import{a as N}from"./66F5ZH34.js";import{d as M,g as O,i as K}from"./NWNYJ26T.js";import{b}from"./TI727O2H.js";import{a as e}from"./XSD5NL7J.js";import{encodeFunctionData as Y,erc20Abi as X,getAddress as W,parseAbi as ee,zeroAddress as te}from"viem";var v={address:W("0xCeF73866b088766DeD46Ba71d9Bd7591B5e931d2"),symbol:"tNET",decimals:9,chainId:b},_={pair_oracle:["checkpoint"],futures:["open","close","marginCall","accrueCarry","sweepCarrySkim"],underwriting:["subscribe","redeem"],prize:["enter","enterWithNet","exit","exitToUsdg","lockTranche","earlyUnlock","pokeRebase"]},fe=x=>({tools:[{name:"netnet_desk_action",inputSchema:{type:"object",additionalProperties:!1,required:["program","operation"],properties:{program:{type:"string",enum:Object.keys(_),description:"Desk program: pair_oracle (price checkpoint), futures, underwriting or prize (WinNET)."},operation:{type:"string",enum:[...new Set(Object.values(_).flat())],description:"Action to run; it must be one the chosen program supports (see the program list in this tool)."},amount:N('Amount in base units of the token the operation spends or moves: tNET 9 decimals for futures and underwriting, USDG 6 or NET 9 for prize. Example: "1000000000" = 1 NET.'),minAmountOut:N('Least output you must receive, in base units of the output token (USDG 6 decimals, NET 9, underwriting shares). Example: "1000000" = 1 USDG.'),maxPayment:N('Most tNET you will pay for futures open (margin plus fee), in tNET base units (9 decimals). Example: "1000000000" = 1 tNET.'),sizeUsdWad:N('Futures position notional in USD as an 18-decimal wad in base units (1e18 = 1 USD). Example: "100000000000000000000" = 100 USD.'),isLong:{type:"boolean",description:"Futures open only: true for a long position, false for a short."},account:{type:"string",description:"Futures marginCall only: address of the trader to margin-call; they must be liquidatable."},referrer:{type:"string",description:"Prize enter only: optional referrer address recorded at the first deposit; cannot be your own wallet."},trancheIndex:N('Zero-based index of your WinNET tranche to lock or unlock early, as a decimal string. Example: "0".'),lockDraws:{enum:["7","30"],description:"Prize lockTranche only: commit the tranche for 7 or 30 draws."},maxPenaltyAssets:N('Prize earlyUnlock only: highest forfeited principal you accept, in NET base units (9 decimals). Example: "1000000000" = 1 NET.')}},execute:async(t,m)=>{try{if(H(m),typeof t.program!="string"||!Object.hasOwn(_,t.program)||typeof t.operation!="string"||!_[t.program].includes(t.operation))throw new e("Choose a supported finite NetNet desk operation.");let p=t.program,r=t.operation,P=E[p],z=Q[p],T=x.clientFor(b);if(await T.getChainId()!==b)throw new e("NetNet desk actions require chain 4663.");let D=await T.getBlock(),q=new Set(["program","operation"]),u=(n,s=[])=>T.readContract({address:P.address,abi:z,functionName:n,args:s,blockNumber:D.number}),h=(...n)=>n.forEach(s=>q.add(s)),A=()=>(h("amount"),y(t.amount)),S=()=>(h("minAmountOut"),y(t.minAmountOut)),d=n=>K(n,"Provide an explicit checksummed account.",M),l=[],a,c=0n,w="",g;if(p==="pair_oracle"){if(d(await u("pairContract"))!==Z)throw new e("The oracle does not use the pinned canonical pair.");w="Permissionless oracle checkpoint; it sends no reward to this wallet and may not yet produce a valid TWAP."}else if(p==="futures"||p==="underwriting"){if(d(await u("token"))!==v.address||await T.readContract({address:v.address,abi:X,functionName:"decimals",blockNumber:D.number})!==9)throw new e("This desk does not use the pinned valueless 9-decimal tNET test collateral.");let n=E.futures.address,s=E.underwriting.address;if(p==="futures"?d(await u("vault"))!==s:d(await u("clearinghouse"))!==n)throw new e("Futures and underwriting counterparties do not match the published pins.");if(w="Experimental tNET test program; tNET has no monetary value. Futures margin and underwriting capital can be lost. Utilization/ADL can prevent redemption. Prices and fees are read from the contract oracle; these calls encode no price floor.",r==="open"){if(h("isLong","sizeUsdWad","maxPayment"),typeof t.isLong!="boolean")throw new e("Provide isLong as a boolean.");let o=A(),f=y(t.sizeUsdWad);if(o>=1n<<128n||f>=1n<<128n)throw new e("Position margin and notional must fit uint128.");let k=d(await u("oracle"));if(k!==W("0xc8a11E8793F8714a159061369173dc86A0A5E23F"))throw new e("The futures oracle is not the published deployment.");let C=await T.readContract({address:k,abi:ee(["function marginPriceWad() view returns (uint256)"]),functionName:"marginPriceWad",blockNumber:D.number});if(C<=0n)throw new e("Futures margin price is unavailable.");let i=f*5n/10000n*1000000000n/C;if(c=o+i,a=v,c>y(t.maxPayment))throw new e("Margin plus taker fee exceeds maxPayment.");l=[t.isLong,f,o],w+=` Entry fee ${i} tNET base units; exact approval caps price drift and may require a fresh preview.`}else if(r==="marginCall"){h("account");let o=d(t.account);if(await u("liquidatable",[o])!==!0)throw new e("The selected futures trader is not liquidatable.");l=[o]}else if(r==="subscribe"){c=A(),a=v,l=[c];let[o,f]=await Promise.all([u("totalShares"),u("equityTokens")]);if(typeof o!="bigint"||typeof f!="bigint"||o>0n&&f===0n)throw new e("Underwriting share price is invalid.");let k=o===0n?c:c*o/f;if(k===0n||k<S())throw new e("Underwriting subscription rounds to zero or misses the local share minimum.");w+=` Current quote ${k} underwriting share units; the share minimum is a local check, not encoded calldata.`}else if(r==="redeem"){let o=A();if(o>await u("sharesOf",[m]))throw new e("The wallet has insufficient underwriting shares.");l=[o],g={token:v,amount:S()}}}else{let[n,s,o,f,k,C]=await Promise.all(["net","usdg","staking","sNet","controller","book"].map(i=>u(i)));if(d(n)!==I.address||d(s)!==$.address||d(o)!==V||d(f)!==J.address||d(k)!==E.draw.address||d(C)!==E.bonus.address)throw new e("WinNET token, staking, book or controller does not match its published pins.");if(w="WinNET principal is a fixed NET claim, exposed to NET price changes. Entry commits through three staking epochs; locks commit for 7 or 30 draws. Early unlock forfeits 1% of principal and cancels streak credits. Pair buys and sells each incur the NET trading tax; no prize or return is guaranteed.",r==="enter"||r==="enterWithNet"){h("referrer");let i=t.referrer===void 0?te:d(t.referrer);if(i===W(m))throw new e("WinNET does not permit self-referral.");c=A(),a=r==="enter"?$:I,l=r==="enter"?[c,S(),i]:[c,i],w+=` Referrer ${i} is recorded at the first deposit and cannot later be changed.`}else if(r==="exit"||r==="exitToUsdg"){let i=A();if(i>await u("principalOf",[m]))throw new e("WinNET exit exceeds this wallet\u2019s fixed principal.");l=r==="exit"?[i,m]:[i,S(),m],g={token:r==="exit"?I:$,amount:r==="exit"?i:y(t.minAmountOut)}}else if(r==="lockTranche"||r==="earlyUnlock"){h("trancheIndex");let i=y(t.trancheIndex,!0),U=await u("trancheAt",[m,i]);if(!Array.isArray(U)||typeof U[0]!="bigint"||U[0]===0n)throw new e("Choose a nonempty WinNET tranche.");if(r==="lockTranche"){if(h("lockDraws"),t.lockDraws!=="7"&&t.lockDraws!=="30")throw new e("Choose a 7- or 30-draw lock.");l=[i,BigInt(t.lockDraws)]}else{h("maxPenaltyAssets");let j=(U[0]+99n)/100n;if(j>y(t.maxPenaltyAssets,!0))throw new e("Early unlock exceeds maxPenaltyAssets in NET base units.");l=[i],w+=` Current irreversible forfeiture ${j} NET base units.`}}}if(Object.keys(t).some(n=>!q.has(n)))throw new e("Unexpected fields for this desk operation.");if(a&&await T.readContract({address:a.address,abi:X,functionName:"balanceOf",args:[m],blockNumber:D.number})<c)throw new e(`Top up ${a.symbol}; this action needs ${c} base units.`);let F=`NetNet ${p}.${r}, contract ${P.address}, chain ${b}, ordered values ${JSON.stringify(l,(n,s)=>typeof s=="bigint"?String(s):s)}. ${a?`Approve exactly ${c} ${a.symbol} base units (token ${a.address}, decimals ${a.decimals}). `:""}${w}`,L=[...a?[x.approval(a.address,P.address,c.toString(),b)]:[],x.unsignedTx({to:P.address,data:Y({abi:z,functionName:r,args:l}),value:"0",chainId:b,description:F})],R=await x.preview(L,m),B=0n,G=0n;for(let n of R.changes){if(n.token.chainId!==b||!/^-?\d+$/.test(n.amount))throw new e("Invalid desk preview metadata.");let s=BigInt(n.amount);if(s<0n){if(!a||!O(n.token.address,a.address)||n.token.decimals!==a.decimals)throw new e("Desk preview spends an unexpected wallet asset.");B-=s}if(g&&O(n.token.address,g.token.address)){if(n.token.decimals!==g.token.decimals)throw new e("Desk receipt decimals mismatch.");G+=s}}if(B>c||g&&G<g.amount)throw new e("Desk preview exceeds its input budget or misses the requested receipt minimum.");return{txs:L,preview:R,summary:F}}catch(p){throw new e(x.plainError(p))}}}]});export{v as a,fe as b};
@@ -1 +1 @@
1
- import{a as p,e as y}from"./VXCGMALF.js";import{a as m}from"./DFM4T6ZE.js";import{p as v}from"./4J245N3F.js";import{a as f}from"./66F5ZH34.js";import{b as l}from"./TI727O2H.js";import{a as u}from"./XSD5NL7J.js";import{encodeFunctionData as w,getAddress as a,parseAbi as I}from"viem";var P="(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)",$="(address tokenIn,address tokenOut,uint24 fee,address recipient,uint256 amountIn,uint256 amountOutMinimum,uint160 sqrtPriceLimitX96)",g=I([`function swapExactIn(${P} key,bool zeroForOne,uint128 amountIn,uint256 minOut,uint160 sqrtPriceLimitX96,address to,uint256 deadline) returns (uint256 paid,uint256 out)`,`function exactInputSingle(${$} params) payable returns (uint256 amountOut)`,"function multicall(uint256 deadline,bytes[] data) payable returns (bytes[] results)"]),E=I(["function quoteExactInputSingle((address tokenIn,address tokenOut,uint256 amountIn,uint24 fee,uint160 sqrtPriceLimitX96) params) returns (uint256 amountOut,uint160 sqrtPriceX96After,uint32 initializedTicksCrossed,uint256 gasEstimate)"]),_=I([`function quoteExactInputSingle((${P} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256 amountOut,uint256 gasEstimate)`]),C="0x0000000000000000000000000000000000000000",h={symbol:{type:"string",enum:m.tokens.map(e=>e.symbol),description:'Official stock ticker with a published Priors pool. Example: "TSLA".'},side:{type:"string",enum:["buy","sell"],description:'Choose "buy": pay USDG for the stock token; "sell": pay the stock token for USDG.'},amountIn:f('Input amount in base units: USDG (6 decimals) to buy, or the stock token (its decimals) to sell. Example: "1000000" = 1 USDG.')};async function O(e,o){let n=m.tokens.find(s=>s.symbol===e.symbol);if(!n||e.side!=="buy"&&e.side!=="sell")throw new u("Choose a published stock symbol and buy or sell.");let t=await v(String(e.symbol),{context:o});if(t.kind!=="official_stock"||t.address!==a(n.token))throw new u("Published Priors stock pool does not match the official stock contract address. Retry after the pool mapping is updated.");let r=y(e.amountIn,"amountIn",128);if(r===0n)throw new u("amountIn must be positive base units.");return{token:n,identity:t,amount:r,input:e.side==="buy"?p.usdg:a(n.token),output:e.side==="buy"?a(n.token):p.usdg}}function x(e,o,n){let[t,r]=BigInt(p.usdg)<BigInt(e)?[p.usdg,e]:[e,p.usdg];return{currency0:t,currency1:r,fee:o,tickSpacing:n,hooks:C}}function R(e){return{tools:[{name:"priors_stock_quote",inputSchema:{type:"object",properties:h,required:Object.keys(h),additionalProperties:!1},async execute(o,n){if(e.network==="testnet")throw new u("Priors stock swaps require mainnet chain 4663.");let t=await O(o,e),r=e.clientFor(l),s=await r.getBlockNumber({cacheTime:0}),k=await Promise.all(t.token.pools.map(async(i,d)=>{try{let c=x(a(t.token.token),i.fee,"tickSpacing"in i?i.tickSpacing:0),b=i.v===3?await r.simulateContract({address:a(m.v3.quoter),abi:E,functionName:"quoteExactInputSingle",args:[{tokenIn:t.input,tokenOut:t.output,amountIn:t.amount,fee:i.fee,sqrtPriceLimitX96:0n}],account:n,blockNumber:s}):await r.simulateContract({address:a(m.v4.quoter),abi:_,functionName:"quoteExactInputSingle",args:[{poolKey:c,zeroForOne:t.input===c.currency0,exactAmount:t.amount,hookData:"0x"}],account:n,blockNumber:s});return{poolIndex:d,version:i.v,amountOut:b.result[0].toString()}}catch(c){return{poolIndex:d,version:i.v,error:e.plainError(c)}}}));return{chainId:l,blockNumber:s.toString(),token:t.identity,quotes:k,warning:"Use explicit minimum output with priors_stock_swap and inspect its preview. Issuer restrictions can prevent sale. Quote is no promise of an exit; local regional eligibility remains required."}}},{name:"priors_stock_swap",inputSchema:{type:"object",properties:{...h,poolIndex:{type:"integer",minimum:0,maximum:2,description:"Index of the published pool to use, from priors_stock_quote (0 to 2)."},minOut:f("Minimum output in base units: the stock token when buying, USDG (6 decimals) when selling. Must be positive."),deadline:f("Deadline in Unix seconds, within the next 30 minutes. Example: 1800000000."),eligible:{type:"boolean",description:"Operator/user affirms eligibility for this stock-token trade in their jurisdiction."}},required:[...Object.keys(h),"poolIndex","minOut","deadline","eligible"],additionalProperties:!1},async execute(o,n){if(e.network==="testnet")throw new u("Priors stock swaps require mainnet chain 4663.");if(n=a(n),o.eligible!==!0)throw new u("Confirm local eligibility for Robinhood stock tokens before trading.");let t=await O(o,e),r=y(o.minOut,"minOut"),s=y(o.deadline,"deadline"),k=BigInt(Math.floor(Date.now()/1e3));if(r===0n||s<=k||s>k+1800n||!Number.isSafeInteger(o.poolIndex))throw new u("Provide positive minOut, poolIndex and a deadline within 30 minutes.");let i=t.token.pools[o.poolIndex];if(!i)throw new u("No published pool at that index. Read priors_stock_quote.");let d=x(a(t.token.token),i.fee,"tickSpacing"in i?i.tickSpacing:0),c=t.input===d.currency0,b=a(i.v===3?m.v3.router:m.v4.swapper),q=i.v===3?w({abi:g,functionName:"multicall",args:[s,[w({abi:g,functionName:"exactInputSingle",args:[{tokenIn:t.input,tokenOut:t.output,fee:i.fee,recipient:n,amountIn:t.amount,amountOutMinimum:r,sqrtPriceLimitX96:0n}]})]]}):w({abi:g,functionName:"swapExactIn",args:[d,c,t.amount,r,c?4295128740n:1461446703485210103287273052203988822378723970341n,n,s]}),S=[e.approval(t.input,b,t.amount.toString(),l),e.unsignedTx({to:b,data:q,value:"0",chainId:l,description:`Priors stock ${o.side}: ${t.amount} input base units; minimum ${r}; pinned V${i.v} pool.`})],A=await e.preview(S,n);return{txs:S,expiresAt:s.toString(),summary:`Stock ${o.side} ${o.symbol}: input ${t.amount} base units (${t.input}), minimum output ${r} (${t.output}), receiver ${n}, deadline ${s}. Issuer transfer/sale restrictions apply. Price impact is not measured by this builder; inspect minOut and the preview. ${A.summary}`}}}]}}export{g as a,R as b};
1
+ import{a as p,e as y}from"./VXCGMALF.js";import{a as m}from"./DFM4T6ZE.js";import{q as v}from"./N624NR7Y.js";import{a as f}from"./66F5ZH34.js";import{b as l}from"./TI727O2H.js";import{a as u}from"./XSD5NL7J.js";import{encodeFunctionData as w,getAddress as a,parseAbi as I}from"viem";var P="(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)",$="(address tokenIn,address tokenOut,uint24 fee,address recipient,uint256 amountIn,uint256 amountOutMinimum,uint160 sqrtPriceLimitX96)",g=I([`function swapExactIn(${P} key,bool zeroForOne,uint128 amountIn,uint256 minOut,uint160 sqrtPriceLimitX96,address to,uint256 deadline) returns (uint256 paid,uint256 out)`,`function exactInputSingle(${$} params) payable returns (uint256 amountOut)`,"function multicall(uint256 deadline,bytes[] data) payable returns (bytes[] results)"]),E=I(["function quoteExactInputSingle((address tokenIn,address tokenOut,uint256 amountIn,uint24 fee,uint160 sqrtPriceLimitX96) params) returns (uint256 amountOut,uint160 sqrtPriceX96After,uint32 initializedTicksCrossed,uint256 gasEstimate)"]),_=I([`function quoteExactInputSingle((${P} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256 amountOut,uint256 gasEstimate)`]),C="0x0000000000000000000000000000000000000000",h={symbol:{type:"string",enum:m.tokens.map(e=>e.symbol),description:'Official stock ticker with a published Priors pool. Example: "TSLA".'},side:{type:"string",enum:["buy","sell"],description:'Choose "buy": pay USDG for the stock token; "sell": pay the stock token for USDG.'},amountIn:f('Input amount in base units: USDG (6 decimals) to buy, or the stock token (its decimals) to sell. Example: "1000000" = 1 USDG.')};async function O(e,o){let n=m.tokens.find(s=>s.symbol===e.symbol);if(!n||e.side!=="buy"&&e.side!=="sell")throw new u("Choose a published stock symbol and buy or sell.");let t=await v(String(e.symbol),{context:o});if(t.kind!=="official_stock"||t.address!==a(n.token))throw new u("Published Priors stock pool does not match the official stock contract address. Retry after the pool mapping is updated.");let r=y(e.amountIn,"amountIn",128);if(r===0n)throw new u("amountIn must be positive base units.");return{token:n,identity:t,amount:r,input:e.side==="buy"?p.usdg:a(n.token),output:e.side==="buy"?a(n.token):p.usdg}}function x(e,o,n){let[t,r]=BigInt(p.usdg)<BigInt(e)?[p.usdg,e]:[e,p.usdg];return{currency0:t,currency1:r,fee:o,tickSpacing:n,hooks:C}}function R(e){return{tools:[{name:"priors_stock_quote",inputSchema:{type:"object",properties:h,required:Object.keys(h),additionalProperties:!1},async execute(o,n){if(e.network==="testnet")throw new u("Priors stock swaps require mainnet chain 4663.");let t=await O(o,e),r=e.clientFor(l),s=await r.getBlockNumber({cacheTime:0}),k=await Promise.all(t.token.pools.map(async(i,d)=>{try{let c=x(a(t.token.token),i.fee,"tickSpacing"in i?i.tickSpacing:0),b=i.v===3?await r.simulateContract({address:a(m.v3.quoter),abi:E,functionName:"quoteExactInputSingle",args:[{tokenIn:t.input,tokenOut:t.output,amountIn:t.amount,fee:i.fee,sqrtPriceLimitX96:0n}],account:n,blockNumber:s}):await r.simulateContract({address:a(m.v4.quoter),abi:_,functionName:"quoteExactInputSingle",args:[{poolKey:c,zeroForOne:t.input===c.currency0,exactAmount:t.amount,hookData:"0x"}],account:n,blockNumber:s});return{poolIndex:d,version:i.v,amountOut:b.result[0].toString()}}catch(c){return{poolIndex:d,version:i.v,error:e.plainError(c)}}}));return{chainId:l,blockNumber:s.toString(),token:t.identity,quotes:k,warning:"Use explicit minimum output with priors_stock_swap and inspect its preview. Issuer restrictions can prevent sale. Quote is no promise of an exit; local regional eligibility remains required."}}},{name:"priors_stock_swap",inputSchema:{type:"object",properties:{...h,poolIndex:{type:"integer",minimum:0,maximum:2,description:"Index of the published pool to use, from priors_stock_quote (0 to 2)."},minOut:f("Minimum output in base units: the stock token when buying, USDG (6 decimals) when selling. Must be positive."),deadline:f("Deadline in Unix seconds, within the next 30 minutes. Example: 1800000000."),eligible:{type:"boolean",description:"Operator/user affirms eligibility for this stock-token trade in their jurisdiction."}},required:[...Object.keys(h),"poolIndex","minOut","deadline","eligible"],additionalProperties:!1},async execute(o,n){if(e.network==="testnet")throw new u("Priors stock swaps require mainnet chain 4663.");if(n=a(n),o.eligible!==!0)throw new u("Confirm local eligibility for Robinhood stock tokens before trading.");let t=await O(o,e),r=y(o.minOut,"minOut"),s=y(o.deadline,"deadline"),k=BigInt(Math.floor(Date.now()/1e3));if(r===0n||s<=k||s>k+1800n||!Number.isSafeInteger(o.poolIndex))throw new u("Provide positive minOut, poolIndex and a deadline within 30 minutes.");let i=t.token.pools[o.poolIndex];if(!i)throw new u("No published pool at that index. Read priors_stock_quote.");let d=x(a(t.token.token),i.fee,"tickSpacing"in i?i.tickSpacing:0),c=t.input===d.currency0,b=a(i.v===3?m.v3.router:m.v4.swapper),q=i.v===3?w({abi:g,functionName:"multicall",args:[s,[w({abi:g,functionName:"exactInputSingle",args:[{tokenIn:t.input,tokenOut:t.output,fee:i.fee,recipient:n,amountIn:t.amount,amountOutMinimum:r,sqrtPriceLimitX96:0n}]})]]}):w({abi:g,functionName:"swapExactIn",args:[d,c,t.amount,r,c?4295128740n:1461446703485210103287273052203988822378723970341n,n,s]}),S=[e.approval(t.input,b,t.amount.toString(),l),e.unsignedTx({to:b,data:q,value:"0",chainId:l,description:`Priors stock ${o.side}: ${t.amount} input base units; minimum ${r}; pinned V${i.v} pool.`})],A=await e.preview(S,n);return{txs:S,expiresAt:s.toString(),summary:`Stock ${o.side} ${o.symbol}: input ${t.amount} base units (${t.input}), minimum output ${r} (${t.output}), receiver ${n}, deadline ${s}. Issuer transfer/sale restrictions apply. Price impact is not measured by this builder; inspect minOut and the preview. ${A.summary}`}}}]}}export{g as a,R as b};
@@ -1 +1 @@
1
- import{b as C}from"./WNWRF4HE.js";import{a as O,c as P,g as B}from"./GQ3XZFRL.js";import{b as h,e as r,g as F}from"./NWNYJ26T.js";import{b as g}from"./TI727O2H.js";import{a as y}from"./XSD5NL7J.js";import{a as E,b as x}from"./JXOEJPJ4.js";import{getAddress as T}from"viem";var q=["pons_status","pons_holders","pons_launch_info"],v=["getPartnerScanCard","getProjectSnapshot"],V=/^[a-z0-9][a-z0-9-]{0,79}$/,$=/^[0-9]{1,78}$/,K=/\b(?:unsafe|safe|safety|risks?|risky|recommend\w*|buy\w*|sell\w*)\b/i,z="https://heyresearch.xyz",D=["curve","pending pool creation","graduated","rescued"],G="This describes the project, not this token. HEY Research Lab does not tie this token to that activity.",X="Buyback-vault vesting only. It is not proof of vesting for any other address and not a liquidity lock. Unread figures say not read.",Z="An empty or missing source proves nothing; unread figures say not read, never zero. Address counts are Pons index figures, not on-chain counts; addresses are not people.",M=/rank|scor|trend|market|lock|sell|rating|price|signal|verdict|safe/i,c=(n,e)=>typeof n=="string"&&n.length>0&&n.length<=e&&!x(n)?n:null,k=n=>typeof n=="string"&&$.test(n)?n:null,Q=n=>typeof n=="number"&&Number.isSafeInteger(n)&&n>=0?n:null,L=n=>typeof n=="number"&&Number.isSafeInteger(n)?n:null,m=n=>typeof n=="string"&&h.test(n)?T(n):null,w=n=>(r(n)?k(n.amount):null)??"not read",d=n=>k(n)??"not read",R=n=>Q(n)??"not read",J=n=>L(n)??"not read";function W(n){if(typeof n!="string"||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/.test(n))return null;let e=Date.parse(n);return Number.isFinite(e)&&new Date(e).toISOString().slice(0,19)===n.slice(0,19)&&e<=Date.now()+3e5?n:null}function nn(n,e){if(typeof n!="string"||n.length>2048||/[\s<>\\]/.test(n)||x(n))return null;try{let t=new URL(n);return t.origin===z&&!t.username&&!t.password&&t.pathname===`/project/${e}`?n:null}catch{return null}}function tn(n){return typeof n!="string"?null:/^untrusted "(?:[^"\\]|\\.)*"$/.test(n)?n:E(n)}function en(n){return n instanceof Error&&/supported Pons factory/i.test(n.message)}function N(n,e){if(!r(n)||n.chainId!==g||typeof n.address!="string"||!h.test(n.address)||!F(n.address,e))return null;let t=n.decimals,s=tn(n.symbol);return typeof t!="number"||!Number.isInteger(t)||t<0||t>255||!s?null:{address:T(e),chainId:g,symbol:s,decimals:t}}function _(n){if(!r(n)||!r(n.token))return null;let e=m(n.token.address);return e?N(n.token,e):null}function sn(n,e){if(!r(n))return;let t=N(n.token,e),s=k(n.blockNumber),o=L(n.phase);if(!t||!s||o===null||o<0||o>3||n.phaseName!==D[o])return;let a=n.pool,l=r(a)&&typeof a.id=="string"&&/^0x[0-9a-fA-F]{1,64}$/.test(a.id)?a.id:null,i=r(a)?k(a.liquidity):null,p=r(a)&&l&&i?{id:l,liquidity:i,sqrtPriceX96:d(a.sqrtPriceX96),tick:J(a.tick),lpFee:R(a.lpFee),protocolFee:R(a.protocolFee)}:null;return{token:t,block:s,launch:{phase:o,phaseName:D[o],curve:m(n.curve),creatorFeeRecipient:m(n.creatorFeeRecipient),progressPpm:d(n.progressPpm),graduationThreshold:w(n.graduationThreshold),raised:w(n.raised),totalSupply:w(n.totalSupply),amountUnits:{graduationThreshold:_(n.graduationThreshold),raised:_(n.raised),totalSupply:_(n.totalSupply)},pool:p}}}function on(n,e){if(!r(n))return;let t=N(n.token,e),s=k(n.statusBlock);if(!t||!s)return;let o=r(n.sources)?n.sources:{},a=(Array.isArray(n.exclusions)?n.exclusions.slice(0,10):[]).flatMap(i=>{let p=r(i)?c(i.reason,120):null;return r(i)&&p?[{reason:p,indexedBalance:d(i.indexedBalance),countedInIndex:typeof i.countedInIndex=="boolean"?i.countedInIndex:null}]:[]}),l=r(n.indexAsOf)?n.indexAsOf:null;return{token:t,addresses:{statusBlock:s,addressCountKind:"indexed",addressCount:R(n.holderCount),indexAddressCount:R(n.indexHolderCount),totalSupply:d(n.totalSupply),indexSupply:d(n.indexSupply),burned:d(n.burned),circulating:d(n.circulating),amountUnits:{totalSupply:t,indexSupply:t,burned:t,circulating:t,indexedBalance:t},exclusions:a,indexAsOf:l?{rollupBucket:c(l.rollupBucket,40),tailFromBlock:d(l.tailFromBlock)}:null,sources:{addressCount:c(o.holderCount,300)??"Pons balances index (an indexed figure, not an on-chain count)",totalSupply:c(o.totalSupply,300),burned:c(o.burned,300),circulating:c(o.circulating,300)}}}}function rn(n,e){if(!r(n)||!r(n.buybackVest))return;let t=N(n.token,e),s=k(n.statusBlock);if(!t||!s)return;let o=n.buybackVest,a={locked:d(o.locked),released:d(o.released),vested:d(o.vested),releasable:d(o.releasable),vestingStart:d(o.vestingStart),vestingDurationSeconds:d(o.vestingDurationSeconds)};return{token:t,vest:{statusBlock:s,vault:m(o.vault),enabled:typeof o.enabled=="boolean"?o.enabled:null,...a,amountUnits:{locked:t,released:t,vested:t,releasable:t},unknownFields:Object.entries(a).filter(([,l])=>l==="not read").map(([l])=>l),scope:X,source:`On-chain reads of the Pons buyback vault at block ${s}.`}}}async function I(n,e,t,s){if(!q.includes(e))throw new y("Unsupported Pons read.");try{let o=s(await n(e,{token:t}),t);return o===void 0?{state:"unavailable",value:null}:{state:"available",value:o}}catch(o){return{state:en(o)?"unsupported-origin":"unavailable",value:null}}}async function H(n,e,t){if(!v.includes(e))throw new y("Unsupported HEY read.");try{let s=await n("heyresearch_read",{operation:e,parameters:t,detail:"full"});return r(s)&&s.operation===e&&r(s.data)?s.data:null}catch{return null}}function an(n){let e={};if(!r(n))return e;for(let[t,s]of Object.entries(n).slice(0,40))!/^[A-Za-z][A-Za-z0-9_]{0,39}$/.test(t)||M.test(t)||(s===null?e[t]="not read":(typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s)||c(s,300)!==null&&!K.test(s))&&(e[t]=s));return e}function ln(n,e){let t=n?W(n.asOf):null;if(!n||!t)return null;let s=r(n.links)?n.links:{};return{asOf:t,page:nn(s.page,e),disclaimer:c(n.disclaimer,1e3),build:an(n.build),textIsData:!0}}async function bn(n,e){if(typeof n!="string"||!h.test(n)||/^0x(?:0{40}|e{40})$/i.test(n))throw new y("Provide a full token contract address on Robinhood Chain 4663.");let t=T(n),[s,o,a,l]=await Promise.all([H(e,"getPartnerScanCard",{chain:g,token:t}),I(e,"pons_status",t,sn),I(e,"pons_holders",t,on),I(e,"pons_launch_info",t,rn)]),i=s?C(s.found===!1&&s.contractAddress===void 0?{...s,contractAddress:t}:s,g,t):void 0,p=i?i.found?"available":"not-indexed":"unavailable",f=i?.found&&r(s?.project)?s.project:null,b=f&&typeof f.slug=="string"&&V.test(f.slug)?f.slug:null,U="not-read",S=null;b&&(S=ln(await H(e,"getProjectSnapshot",{slug:b}),b),U=S?"available":"unavailable");let u=i?.found?i:null,A=u?u.activity_applies_to_token&&u.token_verification==="VERIFIED"?"token":"project-only":null,j=u?.activity.last_ship&&u.activity.last_ship_url?{date:u.activity.last_ship,url:u.activity.last_ship_url,sourceHost:new URL(u.activity.last_ship_url).hostname}:null,Y=o.value?.token??a.value?.token??l.value?.token??null;return{chainId:g,token:t,checkedAt:new Date().toISOString(),hey:{provider:"HEY Research Lab",statusNote:"show exactly",status:u?B(u.status_label,u.status_help):i?.found===!1?P:"HEY Research Lab context unavailable",tie:A,qualification:A==="project-only"?G:null,tieLabel:A==="token"?O:null,verifiedBuilder:u?.verified_builder??null,projectSlug:b,projectLink:u?.project_link??null,asOf:u?.as_of??null,lastShip:j,snapshot:S},oak:{token:Y,statusBlock:o.value?.block??"not read",launch:o.value?.launch??null,addresses:a.value?.addresses??null,buybackVest:l.value?.vest??null},coverage:{hey:{scan:p,snapshot:U},oak:{status:o.state,addresses:a.state,launchInfo:l.state},note:Z}}}export{on as a,bn as b};
1
+ import{b as C}from"./YZHJ4BAP.js";import{a as O,c as P,g as B}from"./GQ3XZFRL.js";import{b as h,e as r,g as F}from"./NWNYJ26T.js";import{b as g}from"./TI727O2H.js";import{a as y}from"./XSD5NL7J.js";import{a as E,b as x}from"./JXOEJPJ4.js";import{getAddress as T}from"viem";var q=["pons_status","pons_holders","pons_launch_info"],v=["getPartnerScanCard","getProjectSnapshot"],V=/^[a-z0-9][a-z0-9-]{0,79}$/,$=/^[0-9]{1,78}$/,K=/\b(?:unsafe|safe|safety|risks?|risky|recommend\w*|buy\w*|sell\w*)\b/i,z="https://heyresearch.xyz",D=["curve","pending pool creation","graduated","rescued"],G="This describes the project, not this token. HEY Research Lab does not tie this token to that activity.",X="Buyback-vault vesting only. It is not proof of vesting for any other address and not a liquidity lock. Unread figures say not read.",Z="An empty or missing source proves nothing; unread figures say not read, never zero. Address counts are Pons index figures, not on-chain counts; addresses are not people.",M=/rank|scor|trend|market|lock|sell|rating|price|signal|verdict|safe/i,c=(n,e)=>typeof n=="string"&&n.length>0&&n.length<=e&&!x(n)?n:null,k=n=>typeof n=="string"&&$.test(n)?n:null,Q=n=>typeof n=="number"&&Number.isSafeInteger(n)&&n>=0?n:null,L=n=>typeof n=="number"&&Number.isSafeInteger(n)?n:null,m=n=>typeof n=="string"&&h.test(n)?T(n):null,w=n=>(r(n)?k(n.amount):null)??"not read",d=n=>k(n)??"not read",R=n=>Q(n)??"not read",J=n=>L(n)??"not read";function W(n){if(typeof n!="string"||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/.test(n))return null;let e=Date.parse(n);return Number.isFinite(e)&&new Date(e).toISOString().slice(0,19)===n.slice(0,19)&&e<=Date.now()+3e5?n:null}function nn(n,e){if(typeof n!="string"||n.length>2048||/[\s<>\\]/.test(n)||x(n))return null;try{let t=new URL(n);return t.origin===z&&!t.username&&!t.password&&t.pathname===`/project/${e}`?n:null}catch{return null}}function tn(n){return typeof n!="string"?null:/^untrusted "(?:[^"\\]|\\.)*"$/.test(n)?n:E(n)}function en(n){return n instanceof Error&&/supported Pons factory/i.test(n.message)}function N(n,e){if(!r(n)||n.chainId!==g||typeof n.address!="string"||!h.test(n.address)||!F(n.address,e))return null;let t=n.decimals,s=tn(n.symbol);return typeof t!="number"||!Number.isInteger(t)||t<0||t>255||!s?null:{address:T(e),chainId:g,symbol:s,decimals:t}}function _(n){if(!r(n)||!r(n.token))return null;let e=m(n.token.address);return e?N(n.token,e):null}function sn(n,e){if(!r(n))return;let t=N(n.token,e),s=k(n.blockNumber),o=L(n.phase);if(!t||!s||o===null||o<0||o>3||n.phaseName!==D[o])return;let a=n.pool,l=r(a)&&typeof a.id=="string"&&/^0x[0-9a-fA-F]{1,64}$/.test(a.id)?a.id:null,i=r(a)?k(a.liquidity):null,p=r(a)&&l&&i?{id:l,liquidity:i,sqrtPriceX96:d(a.sqrtPriceX96),tick:J(a.tick),lpFee:R(a.lpFee),protocolFee:R(a.protocolFee)}:null;return{token:t,block:s,launch:{phase:o,phaseName:D[o],curve:m(n.curve),creatorFeeRecipient:m(n.creatorFeeRecipient),progressPpm:d(n.progressPpm),graduationThreshold:w(n.graduationThreshold),raised:w(n.raised),totalSupply:w(n.totalSupply),amountUnits:{graduationThreshold:_(n.graduationThreshold),raised:_(n.raised),totalSupply:_(n.totalSupply)},pool:p}}}function on(n,e){if(!r(n))return;let t=N(n.token,e),s=k(n.statusBlock);if(!t||!s)return;let o=r(n.sources)?n.sources:{},a=(Array.isArray(n.exclusions)?n.exclusions.slice(0,10):[]).flatMap(i=>{let p=r(i)?c(i.reason,120):null;return r(i)&&p?[{reason:p,indexedBalance:d(i.indexedBalance),countedInIndex:typeof i.countedInIndex=="boolean"?i.countedInIndex:null}]:[]}),l=r(n.indexAsOf)?n.indexAsOf:null;return{token:t,addresses:{statusBlock:s,addressCountKind:"indexed",addressCount:R(n.holderCount),indexAddressCount:R(n.indexHolderCount),totalSupply:d(n.totalSupply),indexSupply:d(n.indexSupply),burned:d(n.burned),circulating:d(n.circulating),amountUnits:{totalSupply:t,indexSupply:t,burned:t,circulating:t,indexedBalance:t},exclusions:a,indexAsOf:l?{rollupBucket:c(l.rollupBucket,40),tailFromBlock:d(l.tailFromBlock)}:null,sources:{addressCount:c(o.holderCount,300)??"Pons balances index (an indexed figure, not an on-chain count)",totalSupply:c(o.totalSupply,300),burned:c(o.burned,300),circulating:c(o.circulating,300)}}}}function rn(n,e){if(!r(n)||!r(n.buybackVest))return;let t=N(n.token,e),s=k(n.statusBlock);if(!t||!s)return;let o=n.buybackVest,a={locked:d(o.locked),released:d(o.released),vested:d(o.vested),releasable:d(o.releasable),vestingStart:d(o.vestingStart),vestingDurationSeconds:d(o.vestingDurationSeconds)};return{token:t,vest:{statusBlock:s,vault:m(o.vault),enabled:typeof o.enabled=="boolean"?o.enabled:null,...a,amountUnits:{locked:t,released:t,vested:t,releasable:t},unknownFields:Object.entries(a).filter(([,l])=>l==="not read").map(([l])=>l),scope:X,source:`On-chain reads of the Pons buyback vault at block ${s}.`}}}async function I(n,e,t,s){if(!q.includes(e))throw new y("Unsupported Pons read.");try{let o=s(await n(e,{token:t}),t);return o===void 0?{state:"unavailable",value:null}:{state:"available",value:o}}catch(o){return{state:en(o)?"unsupported-origin":"unavailable",value:null}}}async function H(n,e,t){if(!v.includes(e))throw new y("Unsupported HEY read.");try{let s=await n("heyresearch_read",{operation:e,parameters:t,detail:"full"});return r(s)&&s.operation===e&&r(s.data)?s.data:null}catch{return null}}function an(n){let e={};if(!r(n))return e;for(let[t,s]of Object.entries(n).slice(0,40))!/^[A-Za-z][A-Za-z0-9_]{0,39}$/.test(t)||M.test(t)||(s===null?e[t]="not read":(typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s)||c(s,300)!==null&&!K.test(s))&&(e[t]=s));return e}function ln(n,e){let t=n?W(n.asOf):null;if(!n||!t)return null;let s=r(n.links)?n.links:{};return{asOf:t,page:nn(s.page,e),disclaimer:c(n.disclaimer,1e3),build:an(n.build),textIsData:!0}}async function bn(n,e){if(typeof n!="string"||!h.test(n)||/^0x(?:0{40}|e{40})$/i.test(n))throw new y("Provide a full token contract address on Robinhood Chain 4663.");let t=T(n),[s,o,a,l]=await Promise.all([H(e,"getPartnerScanCard",{chain:g,token:t}),I(e,"pons_status",t,sn),I(e,"pons_holders",t,on),I(e,"pons_launch_info",t,rn)]),i=s?C(s.found===!1&&s.contractAddress===void 0?{...s,contractAddress:t}:s,g,t):void 0,p=i?i.found?"available":"not-indexed":"unavailable",f=i?.found&&r(s?.project)?s.project:null,b=f&&typeof f.slug=="string"&&V.test(f.slug)?f.slug:null,U="not-read",S=null;b&&(S=ln(await H(e,"getProjectSnapshot",{slug:b}),b),U=S?"available":"unavailable");let u=i?.found?i:null,A=u?u.activity_applies_to_token&&u.token_verification==="VERIFIED"?"token":"project-only":null,j=u?.activity.last_ship&&u.activity.last_ship_url?{date:u.activity.last_ship,url:u.activity.last_ship_url,sourceHost:new URL(u.activity.last_ship_url).hostname}:null,Y=o.value?.token??a.value?.token??l.value?.token??null;return{chainId:g,token:t,checkedAt:new Date().toISOString(),hey:{provider:"HEY Research Lab",statusNote:"show exactly",status:u?B(u.status_label,u.status_help):i?.found===!1?P:"HEY Research Lab context unavailable",tie:A,qualification:A==="project-only"?G:null,tieLabel:A==="token"?O:null,verifiedBuilder:u?.verified_builder??null,projectSlug:b,projectLink:u?.project_link??null,asOf:u?.as_of??null,lastShip:j,snapshot:S},oak:{token:Y,statusBlock:o.value?.block??"not read",launch:o.value?.launch??null,addresses:a.value?.addresses??null,buybackVest:l.value?.vest??null},coverage:{hey:{scan:p,snapshot:U},oak:{status:o.state,addresses:a.state,launchInfo:l.state},note:Z}}}export{on as a,bn as b};
@@ -0,0 +1 @@
1
+ import{c as t}from"./LCH6F5HT.js";import{c as o}from"./N624NR7Y.js";function s(e,n,a){return t(e,n,a,o)}export{s as a};
@@ -1 +1 @@
1
- import{B as Pe,t as re,y as qe}from"./4E7FJQLL.js";import{a as Re}from"./UHIJMDD2.js";import{a as y}from"./WWNAGOCD.js";import{a as k,b as ie,d as He,e as R,f as p,h as C,i as q,j as f,k as $,l as H,m as A,n as se,o as w,p as c,q as F,r as j,s as Se,t as Be}from"./XRDLMTBJ.js";import{b as K,f as ve,g as V,h as Te,i as Le}from"./MQK6OP7S.js";import{a as z}from"./G2LAO23N.js";import{l as oe}from"./BA66J5YQ.js";import{a as xe}from"./Z7FGEWO2.js";import{t as be}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as Qe,encodeFunctionData as We,erc20Abi as Ge,formatUnits as Ae,getAddress as ce,parseAbi as Q,zeroAddress as b,zeroHash as ae}from"viem";var Je="hookr_launch",g=ce(K.launcherV1),X=ce(K.rulesV1),Ye=[{type:"tuple",components:[{name:"flags",type:"uint16"},{name:"minScore",type:"uint32"},{name:"tierScore",type:"uint32"},{name:"tierPips",type:"uint24"},{name:"reviewers",type:"bytes32"}]}],_=(a,n=Object.keys(a))=>({type:"object",properties:a,required:n,additionalProperties:!1}),Fe={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},ue=_({token:{description:'Token to launch: kind "new" creates a fresh token; kind "existing" is reserved and currently refused.',oneOf:[_({kind:{const:"new",type:"string",description:z.enumValues({new:"create and launch a fresh token"})},name:{type:"string",minLength:1,maxLength:48,description:"Public token name, 1 to 48 UTF-8 bytes, no control characters."},symbol:{type:"string",minLength:1,maxLength:12,description:"Public token ticker symbol, 1 to 12 UTF-8 bytes, no control characters."},supply:{...k,description:'Total supply of the new token in base units (18 decimals: "1000000000000000000" = 1 token); positive, below 2^108.'},salt:{...ie,description:"Bytes32 hex salt (0x plus 64 hex digits) that fixes the new token address."}}),_({kind:{const:"existing",type:"string",description:z.enumValues({existing:"reserved for an already deployed token; launching it is not supported yet"})},address:{...Fe,description:z.address("existing token contract")}})]},quote:{...Fe,description:"Qualified ETH (zero address) or pinned USDG quote. Other quote funding routes await qualification."},sqrtPriceX96:{...k,description:"Integer sqrt(currency1/currency0) times 2^96 for the sorted PoolKey."},tickLower:{type:"integer",minimum:-887272,maximum:887272,description:"Lower tick of the launch range, a signed integer and a multiple of the tick spacing 200; below tickUpper."},tickUpper:{type:"integer",minimum:-887272,maximum:887272,description:"Upper tick of the launch range, a signed integer and a multiple of the tick spacing 200; above tickLower."},liquidity:{...k,description:"Initial liquidity in v4 liquidity base units (not a token amount), positive and below 2^127; its rounded-up token debts must fit amount0Max and amount1Max."},amount0Max:{...k,description:`Maximum of the pool's currency0 to fund, in base units of that token (18 decimals: "1000000000000000000" = 1 token).`},amount1Max:{...k,description:`Maximum of the pool's currency1 to fund, in base units of that token (18 decimals: "1000000000000000000" = 1 token).`},agentGate:{description:"Who may buy: all zeros means identity-only; nonzero minScore or tier values add a reputation gate checked by the reviewer set.",..._({minScore:{...k,description:"Minimum agent reputation score required to buy; 0 means no minimum."},tierScore:{...k,description:"Agent score at or above which the reduced tier fee applies; 0 only when tierPips is 0."},tierPips:{...k,description:"Reduced pool fee in pips for agents at tierScore (3000 = 0.3%); at most 50000, and 0 only when tierScore is 0."},reviewerSetId:{...ie,description:"Bytes32 id of a registered reviewer set that scores agents; all zeros unless the gate uses a score."}})},lpRewardsBps:{...k,description:"LP Rewards rate in basis points (50 = 0.5%); at most 1000. This launch profile has zero burn."},arbRecapture:{type:"boolean",description:"True turns on Hookr arb recapture, with recaptured value to LPs; refused while the recapture lane is unavailable. False leaves it off."},deadline:{...k,description:"Latest time this launch may execute, as Unix seconds; must be within the next 300 seconds of chain time."}});function Ze(a){let n=R(a,Object.keys(ue.properties),ue.required),r=A(n.token);if(r.kind==="existing")throw R(r,["kind","address"],["kind","address"]),q(r.address),new o("Existing-token Hookr launches await a qualified funding route. Use token.kind new.");if(R(r,["kind","name","symbol","supply","salt"],["kind","name","symbol","supply","salt"]),r.kind!=="new")throw new o("Choose token.kind new; existing tokens are not supported yet.");let e=(P,O)=>{if(typeof P!="string"||!P.trim()||new TextEncoder().encode(P).length>O||[...P].some(W=>W.codePointAt(0)<32)||/[\u007f-\u009f\u2028-\u202e\u2066-\u2069\ud800-\udfff]/u.test(P))throw new o(`Use nonempty public token text within ${O} UTF-8 bytes without control characters.`);return P},i=p(r.supply,108);if(!i)throw new o("Hookr new-token supply must be positive and at most 2^108-1 base units.");let t=q(n.quote);if(![b,ce(be.mainnet.usdg)].includes(t))throw new o("Use native ETH (zero address) or the pinned USDG quote; other quote funding routes await qualification.");let l=n.tickLower,u=n.tickUpper;if(typeof l!="number"||typeof u!="number")throw new o("Provide integer aligned Hookr ticks.");qe(l,u,y.tickSpacing);let s=p(n.sqrtPriceX96,160);if(s<=oe(l)||s>=oe(u))throw new o("Hookr opening price must be strictly inside the aligned tick range.");let d=p(n.liquidity,127);if(!d)throw new o("Hookr liquidity must be positive and at most int128 max.");let m=p(n.amount0Max,128),T=p(n.amount1Max,128),x=Pe({liquidity:d,tickLower:l,tickUpper:u,sqrtPriceX96:s,roundUp:!0});if(x.amount0>=1n<<127n||x.amount1>=1n<<127n||!x.amount0||!x.amount1||x.amount0>m||x.amount1>T)throw new o("Hookr exact rounded-up debts must be positive and fit both approved funding caps. Reduce liquidity or increase the caps.");let h=R(n.agentGate,["minScore","tierScore","tierPips","reviewerSetId"],["minScore","tierScore","tierPips","reviewerSetId"]),I=Number(p(h.minScore,32)),S=Number(p(h.tierScore,32)),B=Number(p(h.tierPips,24)),M=C(h.reviewerSetId);if(B>5e4||S===0!=(B===0)||(I!==0||S!==0)!=(M!==ae))throw new o("Use tierPips at most 50000, paired nonzero tier score/pips, and a registered reviewer set only for scored gates. Identity-only uses all zero values.");let N=Number(p(n.lpRewardsBps,16));if(N>1e3)throw new o("Hookr LP Rewards plus burn must not exceed 1000 bps; this profile has zero burn.");if(typeof n.arbRecapture!="boolean")throw new o("Choose arbRecapture true or false explicitly.");return{token:{existing:b,name:e(r.name,48),symbol:e(r.symbol,12),supply:i,salt:C(r.salt)},quote:t,sqrtPriceX96:s,tickLower:l,tickUpper:u,liquidity:d,amount0Max:m,amount1Max:T,debts:x,gateTerms:{flags:1,minScore:I,tierScore:S,tierPips:B,reviewers:M},lpRewardsBps:N,arbRecapture:n.arbRecapture,deadline:p(n.deadline,64)}}async function et(a,n,r,e){return q(await c(a,g,w("launcherV1"),"predictToken",[n,r],e))}async function tt(a,n,r,e,i){let t=r.gate;if(!t.walletAgent||!(e?t.healthyForScores:t.healthyIdentityOnly))throw new o("Hookr needs a healthy on-chain agent identity. Own an ERC-8004 identity or link its current agent wallet on the Hookr gate; Oak setup linking alone is insufficient.");let l=(d,m)=>c(a,t.identity,Q(["function balanceOf(address) view returns (uint256)","function ownerOf(uint256) view returns (address)","function getAgentWallet(uint256) view returns (address)"]),d,m,i),u=f(await l("balanceOf",[n])),s=!1;if(t.link.linked){let d=BigInt(t.link.agentId);s=q(await l("getAgentWallet",[d]))===n,!s&&u>0n&&(s=q(await l("ownerOf",[d]))===n)}if(!u&&!s||e&&!s)throw new o("Hookr on-chain identity ownership or gate link is missing or stale. Link a current ERC-8004 agent ID on the Hookr gate before launching; scored gates require that link even for an NFT owner.")}async function nt(a,n,r){let e=Ze(n);if(a.network==="testnet")throw new o("Hookr launch requires Robinhood Chain 4663.");let i=a.clientFor(4663),t=await Te(i);if(e.deadline<=t.timestamp||e.deadline>t.timestamp+y.deadlineSeconds)throw new o("Set a fresh Hookr deadline within the next 300 seconds of chain time.");let l=e.gateTerms.reviewers!==ae,u=await Re(i,r,t.number,l?[e.gateTerms.reviewers]:[]);if(!u.rootOpenForWallet||u.newMarketsPaused||!u.launcherAdmitted)throw new o("Hookr new markets or the reviewed Launcher are closed. Retry only after registry admission is restored.");await tt(i,r,u,l,t.number);let s=await et(i,r,e.token,t.number);if(s===b||s===e.quote)throw new o("Hookr predicted token collides with its quote. Choose a fresh salt.");let d={currency0:BigInt(s)<BigInt(e.quote)?s:e.quote,currency1:BigInt(s)<BigInt(e.quote)?e.quote:s,fee:8388608,tickSpacing:y.tickSpacing,hooks:F},m=re(d),T=d.currency0===s,x=T?e.amount0Max:e.amount1Max,h=T?e.amount1Max:e.amount0Max,I=T?e.debts.amount0:e.debts.amount1,S=T?e.debts.amount1:e.debts.amount0;if(x>e.token.supply)throw new o("Hookr new-token deposit cap exceeds its fixed supply.");let[B,M,N,P,O,W,Ie,Ue]=await Promise.all([i.getCode({address:s,blockNumber:t.number}),i.getTransactionCount({address:s,blockNumber:t.number}),c(i,g,w("launcherV1"),"memberKey",[s,e.quote,y.tickSpacing,F],t.number),c(i,F,w("rootV1"),"knownPool",[m],t.number),c(i,g,w("launcherV1"),"SKIP_TAKEN",[],t.number),c(i,j,w("registry"),"isQuote",[e.quote],t.number),c(i,j,w("registry"),"quoteIsBraked",[e.quote],t.number),c(i,X,w("rulesV1"),"minProtocolShareBps",[],t.number)]),[Ce,$e]=H(N,2);if(e.token.salt===C(O))throw new o("SKIP_TAKEN is unsupported. Choose an ordinary new-token salt.");if(B&&B!=="0x"||M!==0||$(P)||!$($e)||re(A(Ce))!==m)throw new o("Hookr token address or pool is already taken or its predicted key differs. Choose a fresh salt and rebuild.");if(!$(W)||$(H(Ie,2)[0]))throw new o("The Hookr quote is not currently qualified or is braked. Choose an admitted quote.");let de=A(u.gate.admission),Me=A(de.caps),pe=p(Me.maxLpFeePips,24),Ne=BigInt(u.coreAdmission.caps.maxLpFeePips),G=BigInt(y.baseLpFeePips)+pe;if(BigInt(e.gateTerms.tierPips)>pe||G>Ne||G>600000n)throw new o("Hookr gate tier or total LP fee exceeds the live admission cap. Lower the tier or wait for compatible admission.");let le=q(await c(i,X,w("rulesV1"),"protocolRecipient",[],t.number));await V(i,t.number,[le]);let[Oe,Ee,De]=H(await c(i,le,Q(["function feeTerms(address,bool,bytes32) view returns (uint16,uint16,uint16)"]),"feeTerms",[b,e.arbRecapture,m],t.number),3),me=f(Oe,16),J=f(De,16);if(f(Ee,16)!==0n||J>10000n)throw new o("Hookr treasury minimum or integrator terms exceed the reviewed profile.");let he=f(Ue,16),E=me>he?me:he;if(E<2000n||E>5000n)throw new o("Hookr protocol share is outside the reviewed 2000\u20135000 bps profile.");let Y=BigInt(e.lpRewardsBps)*100n+(!e.arbRecapture&&e.lpRewardsBps===0?J:0n);if(Y>BigInt(u.coreAdmission.caps.maxQuoteTakePips))throw new o("Hookr LP Rewards and minimum quote charge exceed the live quote-take cap. Lower LP Rewards.");let Z={on:e.arbRecapture,traderBps:0,lpBps:e.arbRecapture?1e4:0,period:0,maxPrizeBps:0,potReleaseBps:0,minBuyQuote:0n,releaseBlocks:0},ke=null;if(e.arbRecapture){let[D,ge]=await Promise.all([c(i,X,Q(["function recaptureDefaults() view returns ((bool on,uint16 traderBps,uint16 lpBps,uint32 period,uint16 maxPrizeBps,uint16 potReleaseBps,uint128 minBuyQuote,uint32 releaseBlocks) rc,uint16 potBps)"]),"recaptureDefaults",[],t.number),c(i,j,w("registry"),"activeLaneOf",[F],t.number)]);Z.releaseBlocks=Number(f(A(H(D,2)[0]).releaseBlocks,32));let[Ve,je,Xe,_e]=H(ge,4),ne=q(Ve);if(await V(i,t.number,[ne]),ne===b||C(je)!==ve(ne).codeHash||f(Xe,32)===0n||f(_e,16)>10000n||!Z.releaseBlocks)throw new o("Hookr recapture lane is unavailable. Use arbRecapture false until its executor and gas floor are reviewed.");ke=se(ge)}let fe={quote:e.quote,tickSpacing:y.tickSpacing,sqrtPriceX96:e.sqrtPriceX96,tickLower:e.tickLower,tickUpper:e.tickUpper,liquidity:e.liquidity,amount0Max:e.amount0Max,amount1Max:e.amount1Max,config:{subject:s,quote:e.quote,rules:X,advisory:Be,liquidityOwner:g,baseLpFeePips:y.baseLpFeePips,caps:{maxLpFeePips:Number(G),maxQuoteTakePips:Number(Y),maxSubjectTakeBps:0},rulesGasLimit:Number(u.coreAdmission.gasLimit),advisoryGasLimit:Number(p(de.gasLimit,32)),advisoryPhases:1,advisoryFailOpen:!1,policyId:ae},rules:{guardEndBlock:0,maxFeePips:y.baseLpFeePips,snipeTaxPips:0,snipeFloorPips:0,snipeDecaySeconds:0,dynamicFeeSens:0,burnBps:0,lpBps:e.lpRewardsBps,potBps:0,royaltyBps:0,protocolShareBps:Number(E),potEveryNBuys:0,maxBuyQuoteAmount:0n,potMinBuyQuote:0n,royaltyTo:b,integrator:b},recapture:Z},L=BigInt(u.launchFee.amount);if(L>10000000000000000n)throw new o("Hookr launch fee exceeds the reviewed 0.01 ETH maximum.");let v=b;if(L&&(await V(i,t.number,[u.launchFee.treasury]),v=q(await c(i,u.launchFee.treasury,Q(["function target() view returns (address)"]),"target",[],t.number)),v===b||v===g||v===r||v===Se))throw new o("Hookr launch fee recipient is outside the reviewed payment profile.");let ee=L+(e.quote===b?h:0n),te=[],U=[];if(e.quote!==b){let D=f(await c(i,e.quote,Ge,"allowance",[r,g],t.number));D!==0n&&D!==h&&U.push(a.approval(e.quote,g,"0",4663)),U.push(a.approval(e.quote,g,h.toString(),4663)),te.push({token:e.quote,amount:h})}ee&&te.push({token:xe,amount:ee,to:g});let we=`Launch public, permanent token ${JSON.stringify(e.token.name)} (${JSON.stringify(e.token.symbol)}), fixed supply ${Ae(e.token.supply,18)} (18 decimals). Create one agents-only pool (identity check on every buy). Price currency1/currency0 = ${e.sqrtPriceX96*e.sqrtPriceX96}/${1n<<192n}; sqrtPriceX96 ${e.sqrtPriceX96}, ticks ${e.tickLower} to ${e.tickUpper}, spacing ${y.tickSpacing}. Deposit at most ${e.amount0Max} currency0 and ${e.amount1Max} currency1 base units; exact launch debts ${e.debts.amount0} and ${e.debts.amount1}. Currency0 ${d.currency0}; currency1 ${d.currency1}. Launch fee ${L} wei to ${v} (${Ae(L,18)} ETH). Unused quote funding (${h-S} base units) and retained token supply (${e.token.supply-I} base units) return to ${r} in this transaction. Family owner ${r}; token ${s}; pool ${m}. LP base fee 3000 pips; gate flags 1, scores ${e.gateTerms.minScore}/${e.gateTerms.tierScore}, tier ${e.gateTerms.tierPips} pips; LP Rewards ${e.lpRewardsBps} bps; burn 0; quote-take cap ${Y} pips (includes Hookr minimum); protocol share ${E} bps. Arb recapture ${e.arbRecapture}; deadline ${e.deadline}. No lock.`;U.push(a.unsignedTx({to:g,data:We({abi:w("launcherV1"),functionName:"launchAdvised",args:[e.token,F,[fe],[Qe(Ye,[e.gateTerms])],e.deadline]}),value:ee.toString(),chainId:4663,description:we}));let[ye,ze,Ke]=await Promise.all([i.getCode({address:s}),i.getTransactionCount({address:s}),i.readContract({address:g,abi:He,functionName:"launchFee"})]);if(ye&&ye!=="0x"||ze!==0||f(H(Ke,5)[0])!==L)throw new o("Hookr collision state or launch fee changed. Request a fresh launch preview.");return await Le(i,t),{txs:U,inputs:te,summary:we,tokenAddress:s,poolId:m,feeTarget:v,feeTreasury:u.launchFee.treasury,terms:se({request:n,blockNumber:t.number,blockHash:t.hash,owner:r,tokenAddress:s,poolId:m,poolKey:d,member:fe,gateTerms:e.gateTerms,launchFee:L,feeTarget:v,feeTreasury:u.launchFee.treasury,hookrMinimumPips:J,exactApprovals:U.slice(0,-1),refunds:{quote:h-S,retainedSupply:e.token.supply-I},gasEstimate:null,gasEstimateReason:"The local sender estimates the ordered exact calls after funding approvals and confirms the gas limit and maximum fee.",lane:ke,pins:K})}}function ot(a){if(!Array.isArray(a)||a.length<1||a.length>3)throw new o("Hookr launch requires only the locally reconstructed finite approvals and one launch transaction.");for(let n of a)R(n,["to","data","value","chainId","description"],["to","data","value","chainId","description"])}function kt(a,n){if(ot(a),a.length!==n.length||a.some((r,e)=>r.to.toLowerCase()!==n[e].to.toLowerCase()||r.data.toLowerCase()!==n[e].data.toLowerCase()||r.value!==n[e].value||r.chainId!==4663))throw new o("Hookr launch differs from the locally reconstructed exact parameters, approvals and funding.")}function ft(a){return[{name:Je,inputSchema:ue,execute:async(n,r)=>{let e=await nt(a,n,r);return{txs:e.txs,preview:await a.preview(e.txs,r),terms:e.terms,summary:e.summary}}}]}export{Je as a,g as b,X as c,ue as d,Ze as e,nt as f,ot as g,kt as h,ft as i};
1
+ import{B as Pe,t as re,y as qe}from"./FRT6AC6M.js";import{a as Re}from"./UHIJMDD2.js";import{a as y}from"./WWNAGOCD.js";import{a as k,b as ie,d as He,e as R,f as p,h as C,i as q,j as f,k as $,l as H,m as A,n as se,o as w,p as c,q as F,r as j,s as Se,t as Be}from"./XRDLMTBJ.js";import{b as K,f as ve,g as V,h as Te,i as Le}from"./MQK6OP7S.js";import{a as z}from"./G2LAO23N.js";import{m as oe}from"./7OOCAZBE.js";import{a as xe}from"./Z7FGEWO2.js";import{t as be}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as Qe,encodeFunctionData as We,erc20Abi as Ge,formatUnits as Ae,getAddress as ce,parseAbi as Q,zeroAddress as b,zeroHash as ae}from"viem";var Je="hookr_launch",g=ce(K.launcherV1),X=ce(K.rulesV1),Ye=[{type:"tuple",components:[{name:"flags",type:"uint16"},{name:"minScore",type:"uint32"},{name:"tierScore",type:"uint32"},{name:"tierPips",type:"uint24"},{name:"reviewers",type:"bytes32"}]}],_=(a,n=Object.keys(a))=>({type:"object",properties:a,required:n,additionalProperties:!1}),Fe={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},ue=_({token:{description:'Token to launch: kind "new" creates a fresh token; kind "existing" is reserved and currently refused.',oneOf:[_({kind:{const:"new",type:"string",description:z.enumValues({new:"create and launch a fresh token"})},name:{type:"string",minLength:1,maxLength:48,description:"Public token name, 1 to 48 UTF-8 bytes, no control characters."},symbol:{type:"string",minLength:1,maxLength:12,description:"Public token ticker symbol, 1 to 12 UTF-8 bytes, no control characters."},supply:{...k,description:'Total supply of the new token in base units (18 decimals: "1000000000000000000" = 1 token); positive, below 2^108.'},salt:{...ie,description:"Bytes32 hex salt (0x plus 64 hex digits) that fixes the new token address."}}),_({kind:{const:"existing",type:"string",description:z.enumValues({existing:"reserved for an already deployed token; launching it is not supported yet"})},address:{...Fe,description:z.address("existing token contract")}})]},quote:{...Fe,description:"Qualified ETH (zero address) or pinned USDG quote. Other quote funding routes await qualification."},sqrtPriceX96:{...k,description:"Integer sqrt(currency1/currency0) times 2^96 for the sorted PoolKey."},tickLower:{type:"integer",minimum:-887272,maximum:887272,description:"Lower tick of the launch range, a signed integer and a multiple of the tick spacing 200; below tickUpper."},tickUpper:{type:"integer",minimum:-887272,maximum:887272,description:"Upper tick of the launch range, a signed integer and a multiple of the tick spacing 200; above tickLower."},liquidity:{...k,description:"Initial liquidity in v4 liquidity base units (not a token amount), positive and below 2^127; its rounded-up token debts must fit amount0Max and amount1Max."},amount0Max:{...k,description:`Maximum of the pool's currency0 to fund, in base units of that token (18 decimals: "1000000000000000000" = 1 token).`},amount1Max:{...k,description:`Maximum of the pool's currency1 to fund, in base units of that token (18 decimals: "1000000000000000000" = 1 token).`},agentGate:{description:"Who may buy: all zeros means identity-only; nonzero minScore or tier values add a reputation gate checked by the reviewer set.",..._({minScore:{...k,description:"Minimum agent reputation score required to buy; 0 means no minimum."},tierScore:{...k,description:"Agent score at or above which the reduced tier fee applies; 0 only when tierPips is 0."},tierPips:{...k,description:"Reduced pool fee in pips for agents at tierScore (3000 = 0.3%); at most 50000, and 0 only when tierScore is 0."},reviewerSetId:{...ie,description:"Bytes32 id of a registered reviewer set that scores agents; all zeros unless the gate uses a score."}})},lpRewardsBps:{...k,description:"LP Rewards rate in basis points (50 = 0.5%); at most 1000. This launch profile has zero burn."},arbRecapture:{type:"boolean",description:"True turns on Hookr arb recapture, with recaptured value to LPs; refused while the recapture lane is unavailable. False leaves it off."},deadline:{...k,description:"Latest time this launch may execute, as Unix seconds; must be within the next 300 seconds of chain time."}});function Ze(a){let n=R(a,Object.keys(ue.properties),ue.required),r=A(n.token);if(r.kind==="existing")throw R(r,["kind","address"],["kind","address"]),q(r.address),new o("Existing-token Hookr launches await a qualified funding route. Use token.kind new.");if(R(r,["kind","name","symbol","supply","salt"],["kind","name","symbol","supply","salt"]),r.kind!=="new")throw new o("Choose token.kind new; existing tokens are not supported yet.");let e=(P,O)=>{if(typeof P!="string"||!P.trim()||new TextEncoder().encode(P).length>O||[...P].some(W=>W.codePointAt(0)<32)||/[\u007f-\u009f\u2028-\u202e\u2066-\u2069\ud800-\udfff]/u.test(P))throw new o(`Use nonempty public token text within ${O} UTF-8 bytes without control characters.`);return P},i=p(r.supply,108);if(!i)throw new o("Hookr new-token supply must be positive and at most 2^108-1 base units.");let t=q(n.quote);if(![b,ce(be.mainnet.usdg)].includes(t))throw new o("Use native ETH (zero address) or the pinned USDG quote; other quote funding routes await qualification.");let l=n.tickLower,u=n.tickUpper;if(typeof l!="number"||typeof u!="number")throw new o("Provide integer aligned Hookr ticks.");qe(l,u,y.tickSpacing);let s=p(n.sqrtPriceX96,160);if(s<=oe(l)||s>=oe(u))throw new o("Hookr opening price must be strictly inside the aligned tick range.");let d=p(n.liquidity,127);if(!d)throw new o("Hookr liquidity must be positive and at most int128 max.");let m=p(n.amount0Max,128),T=p(n.amount1Max,128),x=Pe({liquidity:d,tickLower:l,tickUpper:u,sqrtPriceX96:s,roundUp:!0});if(x.amount0>=1n<<127n||x.amount1>=1n<<127n||!x.amount0||!x.amount1||x.amount0>m||x.amount1>T)throw new o("Hookr exact rounded-up debts must be positive and fit both approved funding caps. Reduce liquidity or increase the caps.");let h=R(n.agentGate,["minScore","tierScore","tierPips","reviewerSetId"],["minScore","tierScore","tierPips","reviewerSetId"]),I=Number(p(h.minScore,32)),S=Number(p(h.tierScore,32)),B=Number(p(h.tierPips,24)),M=C(h.reviewerSetId);if(B>5e4||S===0!=(B===0)||(I!==0||S!==0)!=(M!==ae))throw new o("Use tierPips at most 50000, paired nonzero tier score/pips, and a registered reviewer set only for scored gates. Identity-only uses all zero values.");let N=Number(p(n.lpRewardsBps,16));if(N>1e3)throw new o("Hookr LP Rewards plus burn must not exceed 1000 bps; this profile has zero burn.");if(typeof n.arbRecapture!="boolean")throw new o("Choose arbRecapture true or false explicitly.");return{token:{existing:b,name:e(r.name,48),symbol:e(r.symbol,12),supply:i,salt:C(r.salt)},quote:t,sqrtPriceX96:s,tickLower:l,tickUpper:u,liquidity:d,amount0Max:m,amount1Max:T,debts:x,gateTerms:{flags:1,minScore:I,tierScore:S,tierPips:B,reviewers:M},lpRewardsBps:N,arbRecapture:n.arbRecapture,deadline:p(n.deadline,64)}}async function et(a,n,r,e){return q(await c(a,g,w("launcherV1"),"predictToken",[n,r],e))}async function tt(a,n,r,e,i){let t=r.gate;if(!t.walletAgent||!(e?t.healthyForScores:t.healthyIdentityOnly))throw new o("Hookr needs a healthy on-chain agent identity. Own an ERC-8004 identity or link its current agent wallet on the Hookr gate; Oak setup linking alone is insufficient.");let l=(d,m)=>c(a,t.identity,Q(["function balanceOf(address) view returns (uint256)","function ownerOf(uint256) view returns (address)","function getAgentWallet(uint256) view returns (address)"]),d,m,i),u=f(await l("balanceOf",[n])),s=!1;if(t.link.linked){let d=BigInt(t.link.agentId);s=q(await l("getAgentWallet",[d]))===n,!s&&u>0n&&(s=q(await l("ownerOf",[d]))===n)}if(!u&&!s||e&&!s)throw new o("Hookr on-chain identity ownership or gate link is missing or stale. Link a current ERC-8004 agent ID on the Hookr gate before launching; scored gates require that link even for an NFT owner.")}async function nt(a,n,r){let e=Ze(n);if(a.network==="testnet")throw new o("Hookr launch requires Robinhood Chain 4663.");let i=a.clientFor(4663),t=await Te(i);if(e.deadline<=t.timestamp||e.deadline>t.timestamp+y.deadlineSeconds)throw new o("Set a fresh Hookr deadline within the next 300 seconds of chain time.");let l=e.gateTerms.reviewers!==ae,u=await Re(i,r,t.number,l?[e.gateTerms.reviewers]:[]);if(!u.rootOpenForWallet||u.newMarketsPaused||!u.launcherAdmitted)throw new o("Hookr new markets or the reviewed Launcher are closed. Retry only after registry admission is restored.");await tt(i,r,u,l,t.number);let s=await et(i,r,e.token,t.number);if(s===b||s===e.quote)throw new o("Hookr predicted token collides with its quote. Choose a fresh salt.");let d={currency0:BigInt(s)<BigInt(e.quote)?s:e.quote,currency1:BigInt(s)<BigInt(e.quote)?e.quote:s,fee:8388608,tickSpacing:y.tickSpacing,hooks:F},m=re(d),T=d.currency0===s,x=T?e.amount0Max:e.amount1Max,h=T?e.amount1Max:e.amount0Max,I=T?e.debts.amount0:e.debts.amount1,S=T?e.debts.amount1:e.debts.amount0;if(x>e.token.supply)throw new o("Hookr new-token deposit cap exceeds its fixed supply.");let[B,M,N,P,O,W,Ie,Ue]=await Promise.all([i.getCode({address:s,blockNumber:t.number}),i.getTransactionCount({address:s,blockNumber:t.number}),c(i,g,w("launcherV1"),"memberKey",[s,e.quote,y.tickSpacing,F],t.number),c(i,F,w("rootV1"),"knownPool",[m],t.number),c(i,g,w("launcherV1"),"SKIP_TAKEN",[],t.number),c(i,j,w("registry"),"isQuote",[e.quote],t.number),c(i,j,w("registry"),"quoteIsBraked",[e.quote],t.number),c(i,X,w("rulesV1"),"minProtocolShareBps",[],t.number)]),[Ce,$e]=H(N,2);if(e.token.salt===C(O))throw new o("SKIP_TAKEN is unsupported. Choose an ordinary new-token salt.");if(B&&B!=="0x"||M!==0||$(P)||!$($e)||re(A(Ce))!==m)throw new o("Hookr token address or pool is already taken or its predicted key differs. Choose a fresh salt and rebuild.");if(!$(W)||$(H(Ie,2)[0]))throw new o("The Hookr quote is not currently qualified or is braked. Choose an admitted quote.");let de=A(u.gate.admission),Me=A(de.caps),pe=p(Me.maxLpFeePips,24),Ne=BigInt(u.coreAdmission.caps.maxLpFeePips),G=BigInt(y.baseLpFeePips)+pe;if(BigInt(e.gateTerms.tierPips)>pe||G>Ne||G>600000n)throw new o("Hookr gate tier or total LP fee exceeds the live admission cap. Lower the tier or wait for compatible admission.");let le=q(await c(i,X,w("rulesV1"),"protocolRecipient",[],t.number));await V(i,t.number,[le]);let[Oe,Ee,De]=H(await c(i,le,Q(["function feeTerms(address,bool,bytes32) view returns (uint16,uint16,uint16)"]),"feeTerms",[b,e.arbRecapture,m],t.number),3),me=f(Oe,16),J=f(De,16);if(f(Ee,16)!==0n||J>10000n)throw new o("Hookr treasury minimum or integrator terms exceed the reviewed profile.");let he=f(Ue,16),E=me>he?me:he;if(E<2000n||E>5000n)throw new o("Hookr protocol share is outside the reviewed 2000\u20135000 bps profile.");let Y=BigInt(e.lpRewardsBps)*100n+(!e.arbRecapture&&e.lpRewardsBps===0?J:0n);if(Y>BigInt(u.coreAdmission.caps.maxQuoteTakePips))throw new o("Hookr LP Rewards and minimum quote charge exceed the live quote-take cap. Lower LP Rewards.");let Z={on:e.arbRecapture,traderBps:0,lpBps:e.arbRecapture?1e4:0,period:0,maxPrizeBps:0,potReleaseBps:0,minBuyQuote:0n,releaseBlocks:0},ke=null;if(e.arbRecapture){let[D,ge]=await Promise.all([c(i,X,Q(["function recaptureDefaults() view returns ((bool on,uint16 traderBps,uint16 lpBps,uint32 period,uint16 maxPrizeBps,uint16 potReleaseBps,uint128 minBuyQuote,uint32 releaseBlocks) rc,uint16 potBps)"]),"recaptureDefaults",[],t.number),c(i,j,w("registry"),"activeLaneOf",[F],t.number)]);Z.releaseBlocks=Number(f(A(H(D,2)[0]).releaseBlocks,32));let[Ve,je,Xe,_e]=H(ge,4),ne=q(Ve);if(await V(i,t.number,[ne]),ne===b||C(je)!==ve(ne).codeHash||f(Xe,32)===0n||f(_e,16)>10000n||!Z.releaseBlocks)throw new o("Hookr recapture lane is unavailable. Use arbRecapture false until its executor and gas floor are reviewed.");ke=se(ge)}let fe={quote:e.quote,tickSpacing:y.tickSpacing,sqrtPriceX96:e.sqrtPriceX96,tickLower:e.tickLower,tickUpper:e.tickUpper,liquidity:e.liquidity,amount0Max:e.amount0Max,amount1Max:e.amount1Max,config:{subject:s,quote:e.quote,rules:X,advisory:Be,liquidityOwner:g,baseLpFeePips:y.baseLpFeePips,caps:{maxLpFeePips:Number(G),maxQuoteTakePips:Number(Y),maxSubjectTakeBps:0},rulesGasLimit:Number(u.coreAdmission.gasLimit),advisoryGasLimit:Number(p(de.gasLimit,32)),advisoryPhases:1,advisoryFailOpen:!1,policyId:ae},rules:{guardEndBlock:0,maxFeePips:y.baseLpFeePips,snipeTaxPips:0,snipeFloorPips:0,snipeDecaySeconds:0,dynamicFeeSens:0,burnBps:0,lpBps:e.lpRewardsBps,potBps:0,royaltyBps:0,protocolShareBps:Number(E),potEveryNBuys:0,maxBuyQuoteAmount:0n,potMinBuyQuote:0n,royaltyTo:b,integrator:b},recapture:Z},L=BigInt(u.launchFee.amount);if(L>10000000000000000n)throw new o("Hookr launch fee exceeds the reviewed 0.01 ETH maximum.");let v=b;if(L&&(await V(i,t.number,[u.launchFee.treasury]),v=q(await c(i,u.launchFee.treasury,Q(["function target() view returns (address)"]),"target",[],t.number)),v===b||v===g||v===r||v===Se))throw new o("Hookr launch fee recipient is outside the reviewed payment profile.");let ee=L+(e.quote===b?h:0n),te=[],U=[];if(e.quote!==b){let D=f(await c(i,e.quote,Ge,"allowance",[r,g],t.number));D!==0n&&D!==h&&U.push(a.approval(e.quote,g,"0",4663)),U.push(a.approval(e.quote,g,h.toString(),4663)),te.push({token:e.quote,amount:h})}ee&&te.push({token:xe,amount:ee,to:g});let we=`Launch public, permanent token ${JSON.stringify(e.token.name)} (${JSON.stringify(e.token.symbol)}), fixed supply ${Ae(e.token.supply,18)} (18 decimals). Create one agents-only pool (identity check on every buy). Price currency1/currency0 = ${e.sqrtPriceX96*e.sqrtPriceX96}/${1n<<192n}; sqrtPriceX96 ${e.sqrtPriceX96}, ticks ${e.tickLower} to ${e.tickUpper}, spacing ${y.tickSpacing}. Deposit at most ${e.amount0Max} currency0 and ${e.amount1Max} currency1 base units; exact launch debts ${e.debts.amount0} and ${e.debts.amount1}. Currency0 ${d.currency0}; currency1 ${d.currency1}. Launch fee ${L} wei to ${v} (${Ae(L,18)} ETH). Unused quote funding (${h-S} base units) and retained token supply (${e.token.supply-I} base units) return to ${r} in this transaction. Family owner ${r}; token ${s}; pool ${m}. LP base fee 3000 pips; gate flags 1, scores ${e.gateTerms.minScore}/${e.gateTerms.tierScore}, tier ${e.gateTerms.tierPips} pips; LP Rewards ${e.lpRewardsBps} bps; burn 0; quote-take cap ${Y} pips (includes Hookr minimum); protocol share ${E} bps. Arb recapture ${e.arbRecapture}; deadline ${e.deadline}. No lock.`;U.push(a.unsignedTx({to:g,data:We({abi:w("launcherV1"),functionName:"launchAdvised",args:[e.token,F,[fe],[Qe(Ye,[e.gateTerms])],e.deadline]}),value:ee.toString(),chainId:4663,description:we}));let[ye,ze,Ke]=await Promise.all([i.getCode({address:s}),i.getTransactionCount({address:s}),i.readContract({address:g,abi:He,functionName:"launchFee"})]);if(ye&&ye!=="0x"||ze!==0||f(H(Ke,5)[0])!==L)throw new o("Hookr collision state or launch fee changed. Request a fresh launch preview.");return await Le(i,t),{txs:U,inputs:te,summary:we,tokenAddress:s,poolId:m,feeTarget:v,feeTreasury:u.launchFee.treasury,terms:se({request:n,blockNumber:t.number,blockHash:t.hash,owner:r,tokenAddress:s,poolId:m,poolKey:d,member:fe,gateTerms:e.gateTerms,launchFee:L,feeTarget:v,feeTreasury:u.launchFee.treasury,hookrMinimumPips:J,exactApprovals:U.slice(0,-1),refunds:{quote:h-S,retainedSupply:e.token.supply-I},gasEstimate:null,gasEstimateReason:"The local sender estimates the ordered exact calls after funding approvals and confirms the gas limit and maximum fee.",lane:ke,pins:K})}}function ot(a){if(!Array.isArray(a)||a.length<1||a.length>3)throw new o("Hookr launch requires only the locally reconstructed finite approvals and one launch transaction.");for(let n of a)R(n,["to","data","value","chainId","description"],["to","data","value","chainId","description"])}function kt(a,n){if(ot(a),a.length!==n.length||a.some((r,e)=>r.to.toLowerCase()!==n[e].to.toLowerCase()||r.data.toLowerCase()!==n[e].data.toLowerCase()||r.value!==n[e].value||r.chainId!==4663))throw new o("Hookr launch differs from the locally reconstructed exact parameters, approvals and funding.")}function ft(a){return[{name:Je,inputSchema:ue,execute:async(n,r)=>{let e=await nt(a,n,r);return{txs:e.txs,preview:await a.preview(e.txs,r),terms:e.terms,summary:e.summary}}}]}export{Je as a,g as b,X as c,ue as d,Ze as e,nt as f,ot as g,kt as h,ft as i};
@@ -1 +1 @@
1
- import{d as n,f as a,i as s,j as l,k as u}from"./X24YTJST.js";import{c as e}from"./4J245N3F.js";var m="In-kind exits are a separate unsupported flow.";function b(t,i){return n(t,i,e)}function V(t,i,o,r,x,p){return a(t,i,o,r,x,p,e)}function A(t,i,o){return s(t,i,o,e,m)}function P(t){return l(t,e.symbol)}function S(t,i,o,r){u(t,i,o,r,e)}export{b as a,V as b,A as c,P as d,S as e};
1
+ import{d as n,f as a,i as s,j as l,k as u}from"./X24YTJST.js";import{c as e}from"./N624NR7Y.js";var m="In-kind exits are a separate unsupported flow.";function b(t,i){return n(t,i,e)}function V(t,i,o,r,x,p){return a(t,i,o,r,x,p,e)}function A(t,i,o){return s(t,i,o,e,m)}function P(t){return l(t,e.symbol)}function S(t,i,o,r){u(t,i,o,r,e)}export{b as a,V as b,A as c,P as d,S as e};