@oakagentkit/core 0.1.9 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/build/dist/api/deployments.d.ts +26 -0
  2. package/build/dist/api/deployments.js +1 -0
  3. package/build/dist/api/history.js +1 -1
  4. package/build/dist/api/modules/beefy/clm.js +1 -1
  5. package/build/dist/api/modules/beefy/guard.js +1 -1
  6. package/build/dist/api/modules/beefy/index.js +1 -1
  7. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  8. package/build/dist/api/modules/clanker/index.js +1 -1
  9. package/build/dist/api/modules/grove/index.js +1 -1
  10. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  11. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  12. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  13. package/build/dist/api/modules/hoodlock/index.js +1 -1
  14. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  15. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  16. package/build/dist/api/modules/hoodlock/public.js +1 -1
  17. package/build/dist/api/modules/hookr/actions.js +1 -1
  18. package/build/dist/api/modules/hookr/addons.js +1 -1
  19. package/build/dist/api/modules/hookr/contracts.js +1 -1
  20. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  21. package/build/dist/api/modules/hookr/discovery.js +1 -1
  22. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  23. package/build/dist/api/modules/hookr/index.js +1 -1
  24. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  25. package/build/dist/api/modules/hookr/relay.js +1 -1
  26. package/build/dist/api/modules/kyberswap/index.js +1 -1
  27. package/build/dist/api/modules/kyberswap/source-pools.d.ts +22 -3
  28. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  29. package/build/dist/api/modules/longbow/administration.js +1 -1
  30. package/build/dist/api/modules/longbow/fixed.js +1 -1
  31. package/build/dist/api/modules/longbow/index.js +1 -1
  32. package/build/dist/api/modules/meridian/index.js +1 -1
  33. package/build/dist/api/modules/meridian/rfq.js +1 -1
  34. package/build/dist/api/modules/morpho/bundles.js +1 -1
  35. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  36. package/build/dist/api/modules/morpho/index.js +1 -1
  37. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  38. package/build/dist/api/modules/morpho/midnight.js +1 -1
  39. package/build/dist/api/modules/morpho/protocol.js +1 -1
  40. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  41. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  42. package/build/dist/api/modules/netnet/card-read.js +1 -1
  43. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  44. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  45. package/build/dist/api/modules/netnet/financial.js +1 -1
  46. package/build/dist/api/modules/netnet/index.js +1 -1
  47. package/build/dist/api/modules/orbio/index.js +1 -1
  48. package/build/dist/api/modules/pons/claim.js +1 -1
  49. package/build/dist/api/modules/pons/index.js +1 -1
  50. package/build/dist/api/modules/pons/launch-status.js +1 -1
  51. package/build/dist/api/modules/pons/reads.js +1 -1
  52. package/build/dist/api/modules/pons/trade.js +1 -1
  53. package/build/dist/api/modules/poolstrade/index.js +1 -1
  54. package/build/dist/api/modules/priors/coverage.js +1 -1
  55. package/build/dist/api/modules/priors/discovery.js +1 -1
  56. package/build/dist/api/modules/priors/index.js +1 -1
  57. package/build/dist/api/modules/priors/integration.js +1 -1
  58. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  59. package/build/dist/api/modules/relay/discovery.js +1 -1
  60. package/build/dist/api/modules/relay/inbound.js +1 -1
  61. package/build/dist/api/modules/relay/index.js +1 -1
  62. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  63. package/build/dist/api/modules/steakhouse/index.js +1 -1
  64. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  65. package/build/dist/api/modules/steakhouse/management.js +1 -1
  66. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  67. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  68. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  69. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  70. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  71. package/build/dist/api/modules/tickerspring/index.js +1 -1
  72. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  73. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  74. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  75. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  76. package/build/dist/api/modules/tickerspring/research.js +1 -1
  77. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  78. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  79. package/build/dist/api/modules/uniswap/auction.js +1 -1
  80. package/build/dist/api/modules/uniswap/batch.js +1 -1
  81. package/build/dist/api/modules/uniswap/common.js +1 -1
  82. package/build/dist/api/modules/uniswap/fees.js +1 -1
  83. package/build/dist/api/modules/uniswap/index.js +1 -1
  84. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  85. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  86. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  87. package/build/dist/api/modules/uniswap/pools.js +1 -1
  88. package/build/dist/api/modules/uniswap/position.js +1 -1
  89. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  90. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  91. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  92. package/build/dist/api/modules/uniswap/trade.js +1 -1
  93. package/build/dist/api/modules/uniswap/v2.js +1 -1
  94. package/build/dist/api/modules/uniswap/v3.js +1 -1
  95. package/build/dist/api/modules/uniswap/v4.js +1 -1
  96. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  97. package/build/dist/api/modules/velora/claims.js +1 -1
  98. package/build/dist/api/modules/velora/index.js +1 -1
  99. package/build/dist/api/prices.js +1 -1
  100. package/build/dist/api/routes.d.ts +2 -0
  101. package/build/dist/api/routes.js +1 -1
  102. package/build/dist/api/send.js +1 -1
  103. package/build/dist/api/signing-registry.js +1 -1
  104. package/build/dist/api/simulate.js +1 -1
  105. package/build/dist/api/swap.js +1 -1
  106. package/build/dist/api/tokens.d.ts +4 -0
  107. package/build/dist/api/tokens.js +1 -1
  108. package/build/dist/chunks/{ZL3KVABO.js → 22S4SFD5.js} +1 -1
  109. package/build/dist/chunks/{MWWYIFXJ.js → 2CS3M32D.js} +1 -1
  110. package/build/dist/chunks/{JVTVOK6P.js → 3R3C3CU5.js} +1 -1
  111. package/build/dist/chunks/{QOY4AANB.js → 3ZVGHC6S.js} +1 -1
  112. package/build/dist/chunks/{2EGFALNH.js → 5LQBHXFA.js} +1 -1
  113. package/build/dist/chunks/{OJP7Y4AM.js → 5RKWSFD2.js} +1 -1
  114. package/build/dist/chunks/6L6DSMCU.js +1 -0
  115. package/build/dist/chunks/{FLXID6I3.js → 6LLOTPH2.js} +1 -1
  116. package/build/dist/chunks/{JOMK32QW.js → 72AWP4BM.js} +1 -1
  117. package/build/dist/chunks/{C5LR6F4B.js → 7T4BYFD4.js} +1 -1
  118. package/build/dist/chunks/{W6G2QGYF.js → AZGMF26W.js} +1 -1
  119. package/build/dist/chunks/{PHXWBC4O.js → BBVKWG65.js} +1 -1
  120. package/build/dist/chunks/{HYIEQG4X.js → BEPSWFJX.js} +1 -1
  121. package/build/dist/chunks/{YONRUWN7.js → BG4S6MSN.js} +1 -1
  122. package/build/dist/chunks/{QH3AL3UN.js → BV3AHLH5.js} +1 -1
  123. package/build/dist/chunks/CAU44UWP.js +1 -0
  124. package/build/dist/chunks/{BQLLTY4L.js → D4WURN33.js} +1 -1
  125. package/build/dist/chunks/{HACP2Q6D.js → D6VP3N27.js} +2 -2
  126. package/build/dist/chunks/{6SB3FB3P.js → DD7755AW.js} +1 -1
  127. package/build/dist/chunks/{4CDR7F4I.js → DGGOO4RN.js} +1 -1
  128. package/build/dist/chunks/{VCWDJQDE.js → DVKDWXEJ.js} +1 -1
  129. package/build/dist/chunks/{4X6JEMSF.js → E24S22BZ.js} +1 -1
  130. package/build/dist/chunks/EA6IYKIB.js +1 -0
  131. package/build/dist/chunks/{SYZ55RCX.js → EYYUWFUR.js} +1 -1
  132. package/build/dist/chunks/FBQWTWPT.js +1 -0
  133. package/build/dist/chunks/{P6ELT4ZV.js → FKAA7VUR.js} +1 -1
  134. package/build/dist/chunks/{NUWL6TJM.js → GECX5U3F.js} +1 -1
  135. package/build/dist/chunks/{B72Q2EQ2.js → GUBB5P6V.js} +1 -1
  136. package/build/dist/chunks/{EHVPRQHS.js → I7NUTSSX.js} +1 -1
  137. package/build/dist/chunks/{ITIIHCZK.js → IAXKPME3.js} +1 -1
  138. package/build/dist/chunks/{WQZLYX64.js → IRWEY7TQ.js} +1 -1
  139. package/build/dist/chunks/{2LM5C7FQ.js → IUETZH6I.js} +1 -1
  140. package/build/dist/chunks/{FL3EF72E.js → JG24LNUI.js} +1 -1
  141. package/build/dist/chunks/{IKP3Z3RX.js → K7HIKXNT.js} +1 -1
  142. package/build/dist/chunks/LFN3OODW.js +1 -0
  143. package/build/dist/chunks/{FYTF2QMS.js → MEMVFR7Z.js} +1 -1
  144. package/build/dist/chunks/{37QNUNED.js → MNFU7PO3.js} +1 -1
  145. package/build/dist/chunks/{REGJY5RC.js → N37ZLNCT.js} +1 -1
  146. package/build/dist/chunks/{UEYFMXV3.js → N3GWFLG6.js} +1 -1
  147. package/build/dist/chunks/{SEW7UP5U.js → NCEJZWGX.js} +1 -1
  148. package/build/dist/chunks/{OK3TQFXZ.js → NKY3DT34.js} +1 -1
  149. package/build/dist/chunks/NMFVXBTL.js +1 -0
  150. package/build/dist/chunks/{SS7U3CMZ.js → NUTHT4FE.js} +1 -1
  151. package/build/dist/chunks/{5H3MQWH7.js → O7PQDUVT.js} +1 -1
  152. package/build/dist/chunks/{CS55ERS3.js → OMTCWXQR.js} +1 -1
  153. package/build/dist/chunks/{JRZLKIYB.js → PR2QED25.js} +1 -1
  154. package/build/dist/chunks/{B7V7AA5A.js → Q4RZQCDS.js} +1 -1
  155. package/build/dist/chunks/{E2IVNGLC.js → QR7ALOR4.js} +1 -1
  156. package/build/dist/chunks/{SQH7A4O3.js → QXFJZGVB.js} +1 -1
  157. package/build/dist/chunks/{ZPNGV34U.js → QYHJWU5T.js} +1 -1
  158. package/build/dist/chunks/{NNZ4SZZ4.js → QZM7CWZW.js} +1 -1
  159. package/build/dist/chunks/{E2Q5IA67.js → RM5W63LO.js} +1 -1
  160. package/build/dist/chunks/{Z4LJ2GTX.js → RTBOMWCB.js} +1 -1
  161. package/build/dist/chunks/T3MGNKA6.js +1 -0
  162. package/build/dist/chunks/{L2MTPRU7.js → T3NPRRTY.js} +1 -1
  163. package/build/dist/chunks/{HF2AGJZC.js → TDN3C4IG.js} +1 -1
  164. package/build/dist/chunks/{WHT45EFX.js → UIIJWIR6.js} +1 -1
  165. package/build/dist/chunks/{CAYBSVA6.js → ULJ6E4HP.js} +1 -1
  166. package/build/dist/chunks/{K2LWX3PZ.js → UMK564HS.js} +1 -1
  167. package/build/dist/chunks/{AIWZGIZ6.js → UPPYXY74.js} +1 -1
  168. package/build/dist/chunks/{XCFA73P2.js → VJ3W2V3B.js} +1 -1
  169. package/build/dist/chunks/{RNEMTLQG.js → VY3P34PY.js} +1 -1
  170. package/build/dist/chunks/{EKGHKEKV.js → WLACEU2Y.js} +1 -1
  171. package/build/dist/chunks/{KEPQXFHU.js → X6G4BD35.js} +1 -1
  172. package/build/dist/chunks/{CXMC3T6B.js → XGUKLFBU.js} +1 -1
  173. package/build/dist/chunks/XUJSQV52.js +1 -0
  174. package/build/dist/chunks/{LFKSXD3S.js → YMB553OJ.js} +1 -1
  175. package/build/dist/chunks/{BBQVTEYB.js → ZGXNTWYG.js} +1 -1
  176. package/package.json +2 -2
  177. package/build/dist/chunks/2O6A6WEX.js +0 -1
  178. package/build/dist/chunks/3Z3U4YPA.js +0 -1
  179. package/build/dist/chunks/74BPMUAG.js +0 -1
  180. package/build/dist/chunks/E7ASOYQI.js +0 -1
  181. package/build/dist/chunks/EAEQOS7Y.js +0 -1
  182. package/build/dist/chunks/HZUWK5B2.js +0 -1
  183. package/build/dist/chunks/OJMYESQU.js +0 -1
  184. package/build/dist/chunks/ZQI7B2Z7.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as r,e as x}from"./HNMOB76J.js";import{n as F}from"./T3MGNKA6.js";import{a as k}from"./UWOFA6GV.js";import{a as p}from"./XPFVT2EA.js";import{a as d}from"./5YS5V2LK.js";import{encodeFunctionData as C,getAddress as b,parseAbi as E}from"viem";var s={chainId:4663,usdg:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",v4:{poolManager:"0x8366a39CC670B4001A1121B8F6A443A643e40951",swapper:"0x7Cd4E04E433E69e588728c86A3832753B5F846d4",quoter:"0x8dc178efb8111bb0973dd9d722ebeff267c98f94",stateView:"0xf3334192d15450cdd385c8b70e03f9a6bd9e673b"},v3:{router:"0xCaf681a66D020601342297493863E78C959E5cb2",quoter:"0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7",factory:"0x1f7d7550B1b028f7571E69A784071F0205FD2EfA"},tokens:[{symbol:"AAPL",token:"0xaF3D76f1834A1d425780943C99Ea8A608f8a93f9",pools:[{v:3,fee:500,pool:"0xAae0d815EE56e4092a5E5C2911E676Fea50B2d6D"},{v:4,fee:3e3,tickSpacing:60,id:"0xc748f4671a867db48b552f6b7650bf3255e05f80f00e3f7aad1b17ccb7898fdb"},{v:3,fee:3e3,pool:"0x783C9bbB765047CFdD2b84b92b2Ca9F11D34b7Ed"}]},{symbol:"AMD",token:"0x86923f96303D656E4aa86D9d42D1e57ad2023fdC",pools:[{v:3,fee:3e3,pool:"0x48D284A2A4d3DC1b3Da08231Fe44317e7e7Aa51f"}]},{symbol:"AMZN",token:"0x12f190a9F9d7D37a250758b26824B97CE941bF54",pools:[{v:3,fee:3e3,pool:"0x8AC92DA74AB5F3b1d024Dc1943Ad7e15Dc4179Ef"},{v:4,fee:2400,tickSpacing:24,id:"0xefc94885c96b02696b9b45de43eeeb8ac53c0199cab42b4daae4911b96fb8825"}]},{symbol:"ASML",token:"0x47F93d52cBeC7C6D2CfC080e154002370a60dAEA",pools:[{v:3,fee:1e4,pool:"0xedb22516B14Eb2d1C86927Db373B0E8bF70F5cD1"}]},{symbol:"BABA",token:"0xad25Ac6C84D497db898fa1E8387bf6Af3532a1c4",pools:[{v:4,fee:1e3,tickSpacing:10,id:"0x1791fc651cc794a282e5dbcb56d0b2b38eff8754b677c8876e86901521ecc439"},{v:3,fee:3e3,pool:"0xa57ab582b310dd6f9e934EA1EEEa152741545E6A"}]},{symbol:"COIN",token:"0x6330D8C3178a418788dF01a47479c0ce7CCF450b",pools:[{v:4,fee:2500,tickSpacing:25,id:"0xe2e1a0e32205e854525e0fb1d3667a53bd3b4919f032b9bcd2a038b6b6dac314"},{v:4,fee:1e4,tickSpacing:200,id:"0x007a13fa152f6dc383cad20a8eaab4e1e2538b606936eae2a424f8aa47d6db31"}]},{symbol:"CRCL",token:"0xdF0992E440dD0be65BD8439b609d6D4366bf1CB5",pools:[{v:3,fee:3e3,pool:"0x654E4143e82a5824445Ade0824351C2A9ACD95a8"},{v:4,fee:3e3,tickSpacing:30,id:"0x628c98ab436ee34a6a7decd606242890582591bdf7c9a35d90e0d08021c31ea0"},{v:4,fee:1500,tickSpacing:15,id:"0x5177eac8c2176468bbf15e44081e151d35c2e7d068e96d3db94f496a4dc944b2"}]},{symbol:"CRWV",token:"0x5f10A1C971B69e47e059e1dC91901B59b3fB49C3",pools:[{v:4,fee:9e3,tickSpacing:90,id:"0x237014478f7ef98afbe7412ac35b6a3f96b8fb111de48b7c4dbf49dba4bd9c4b"}]},{symbol:"DELL",token:"0x941AE714EC6D8130c7B75d67160Ca08f1e7d11Dd",pools:[{v:3,fee:1e4,pool:"0xc30c89cB7815A1488b7998D15eEC73961707Fc5a"}]},{symbol:"GME",token:"0x1b0E319c6A659F002271B69dB8A7df2F911c153E",pools:[{v:3,fee:500,pool:"0xE2b46c905E12Ab8E2f864e4821a4325884C1B126"}]},{symbol:"GOOGL",token:"0x2e0847E8910a9732eB3fb1bb4b70a580ADAD4FE3",pools:[{v:3,fee:500,pool:"0x34D0dC122CF9A8Eb296fC5e0D3A233625D7d19b7"},{v:4,fee:300,tickSpacing:3,id:"0x43fe16b75cabbf38f5b185d16142b02d1d9200d8f1ba17cb6cf899f562c6197f"},{v:4,fee:3e3,tickSpacing:60,id:"0xd4ecb79fdc521d7725d22b33ed43cb4e47aa96bfad76aa29577e3151f723ac5e"}]},{symbol:"INTC",token:"0xc72b96e0E48ecd4DC75E1e45396e26300BC39681",pools:[{v:3,fee:3e3,pool:"0x2e5a92f5013a64661A49312111be2e8aBd33F56a"}]},{symbol:"META",token:"0xc0D6457C16Cc70d6790Dd43521C899C87ce02f35",pools:[{v:4,fee:310,tickSpacing:3,id:"0xc58bb68060bcb7b3ea0f6d4a4afef1e57f628722e808db12afb6d1733552872f"},{v:3,fee:3e3,pool:"0x107a7Cb40d8665360ba10E59471Af06150A50922"},{v:4,fee:3e3,tickSpacing:60,id:"0x5875d407a42965b0e768c8925cea290e06fa50603ef34fc99eb92a1050e6ae36"}]},{symbol:"MSFT",token:"0xe93237C50D904957Cf27E7B1133b510C669c2e74",pools:[{v:3,fee:3e3,pool:"0xeb60bCD1D920ad6E102690CCFC6fB488899E1510"},{v:4,fee:3e3,tickSpacing:60,id:"0x9194a557b6a6bb2236b49ea7e2bbccec5d3eeb705aef00903be4b3de1d949579"}]},{symbol:"MSTR",token:"0xec262a75e413fAfD0dF80480274532C79D42da09",pools:[{v:4,fee:2500,tickSpacing:25,id:"0x319bac87e616a89e241c10aeb8afd4892a852cdd8b373cd9765ecddc40b87cfe"},{v:4,fee:2400,tickSpacing:24,id:"0xc105b8300ff65d750a0e4e63c7a879e20504069b770713464a5315e797735326"}]},{symbol:"MU",token:"0xfF080c8ce2E5feadaCa0Da81314Ae59D232d4afD",pools:[{v:3,fee:3e3,pool:"0xd057B1Bc54917855BBee58eAd58647f47caB35E5"}]},{symbol:"NBIS",token:"0x9D9c6684F596F66a64C030B93A886D51Fd4D7931",pools:[{v:4,fee:9900,tickSpacing:99,id:"0x7c2f9ce1214ba9baf56d1b6a1fc640c1b63e9a711172c0c7d10e5a9c4a3d4f0c"}]},{symbol:"NVDA",token:"0xd0601CE157Db5bdC3162BbaC2a2C8aF5320D9EEC",pools:[{v:3,fee:500,pool:"0xd4EB21209C4D6093f80B5b84f5C45cc093EA14a3"},{v:4,fee:100,tickSpacing:1,id:"0x6444a8e0b267406a15db74ca00c4a24bdfa81ed3180f5b6d0851f8ed6f4f29c5"},{v:4,fee:3e3,tickSpacing:60,id:"0x3bb34a44f1b2b5f32c034c38a53065a521a47b199700fa9bd19d60985ff24bf1"}]},{symbol:"ORCL",token:"0xb0992820E760d836549ba69BC7598b4af75dEE03",pools:[{v:4,fee:1e4,tickSpacing:200,id:"0xc2ce4784e1e72cf0221b51b30c8aaadf6c0b12863cf03ab3687854fb7b1d850a"}]},{symbol:"PLTR",token:"0x894E1EC2D74FFE5AEF8Dc8A9e84686acCB964F2A",pools:[{v:4,fee:1500,tickSpacing:15,id:"0xc59eaeda6d1a6f031bc7e1d039772f2d675e7b4de2c8668610f4471bd60b3802"},{v:3,fee:3e3,pool:"0x851680416A4f4E1c463d45171d61ACDdBc8554c0"}]},{symbol:"QQQ",token:"0xD5f3879160bc7c32ebb4dC785F8a4F505888de68",pools:[{v:3,fee:500,pool:"0xD60A5d14dB690B7Afad71F76B108071D7175597d"}]},{symbol:"SGOV",token:"0x92FD66527192E3e61d4DDd13322Aa222DE86F9B5",pools:[{v:3,fee:500,pool:"0x6Ba50150B17Ffd0972915Aaf04fFd5E8f4Fa49b4"},{v:3,fee:3e3,pool:"0xfAb520051f96F4D2a32c22B6a3dD7fFfdf231bFe"}]},{symbol:"SLV",token:"0x411eFb0E7f985935DAec3D4C3ebaEa0d0AD7D89f",pools:[{v:3,fee:3e3,pool:"0x8cB787e6c315D464775289BaD00FDD67d53Ecb3D"},{v:3,fee:1e4,pool:"0x0Fa7BC480885DCf58Ad2ef63eC7289cF2481D51c"}]},{symbol:"SNDK",token:"0xB90A19fF0Af67f7779afF50A882A9CfF42446400",pools:[{v:4,fee:1e4,tickSpacing:200,id:"0x2707cb88a6a40fa0f948f58958051ba097d6f6a3cf7f87929bd68ccc5becea24"}]},{symbol:"SPCX",token:"0x4a0E65A3EcceC6dBe60AE065F2e7bb85Fae35eEa",pools:[{v:3,fee:500,pool:"0xc61284332117c3FB23A2A56cceFFD07F7aF60029"},{v:3,fee:3e3,pool:"0xEb07d9587eFD1778dFb9c385Ec43EF6d5F9fE401"}]},{symbol:"SPY",token:"0x117cc2133c37B721F49dE2A7a74833232B3B4C0C",pools:[{v:4,fee:100,tickSpacing:1,id:"0xe1ae6a4c6ccc9f037389a8d50a4f577bde1a9fe01d85d88ecbbd39955ce53288"},{v:3,fee:500,pool:"0xa7Bb1AC63BBaB0C44316E6c8C455213441689167"},{v:4,fee:500,tickSpacing:5,id:"0xe5923c8a8be481ec89a2ca784a2bbfa4235de6d88f92260fd66b660c4babf907"}]},{symbol:"TSLA",token:"0x322F0929c4625eD5bAd873c95208D54E1c003b2d",pools:[{v:3,fee:3e3,pool:"0xf4ACdAEEB7022862A763C9B1B885e11191c889E3"},{v:4,fee:3e3,tickSpacing:60,id:"0x8517f8071ae5b831b738052f12125e8e3d6c158b78728aa44ce3b25e5104d32e"}]},{symbol:"TSM",token:"0x58FfE4a942d3885bAa22D7520691F611EF09e7AA",pools:[{v:4,fee:7500,tickSpacing:75,id:"0x0ba5d53d2f6255f334b7c8ead4f56b6aef5af3402c5e4d11180afd38c6b85fb1"},{v:3,fee:1e4,pool:"0x07e8Ea83D4C1340774c8965125e26e12bf943bf1"}]},{symbol:"USAR",token:"0xd917B029C761D264c6A312BBbcDA868658eF86a6",pools:[{v:3,fee:3e3,pool:"0x04391780F519B7d3ba59c9590459D76e23d225C4"}]},{symbol:"USO",token:"0xa30FA36Db767ad9eD3f7a60fC79526fB4d56D344",pools:[{v:4,fee:1200,tickSpacing:15,id:"0x1f2ad5a274a776d8e1408292bde1d92d8fa7b6444acf14ad60b9c3e4e5b66420"},{v:3,fee:3e3,pool:"0x02175608F1b5E6b5ed221cCFdC7Be197D111D915"}]}],notOffered:{CLSK:"thin",EWY:"thin",IONQ:"thin",RGTI:"thin",RKLB:"thin"},sourceCommit:"02230282d8888e00794207ed271ee01b4ce30309"};var S="(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)",w="(address tokenIn,address tokenOut,uint24 fee,address recipient,uint256 amountIn,uint256 amountOutMinimum,uint160 sqrtPriceLimitX96)",D=E([`function swapExactIn(${S} key,bool zeroForOne,uint128 amountIn,uint256 minOut,uint160 sqrtPriceLimitX96,address to,uint256 deadline) returns (uint256 paid,uint256 out)`,`function exactInputSingle(${w} params) payable returns (uint256 amountOut)`,"function multicall(uint256 deadline,bytes[] data) payable returns (bytes[] results)"]),O=E(["function quoteExactInputSingle((address tokenIn,address tokenOut,uint256 amountIn,uint24 fee,uint160 sqrtPriceLimitX96) params) returns (uint256 amountOut,uint160 sqrtPriceX96After,uint32 initializedTicksCrossed,uint256 gasEstimate)"]),P=E([`function quoteExactInputSingle((${S} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256 amountOut,uint256 gasEstimate)`]),q="0x0000000000000000000000000000000000000000",A={symbol:{type:"string",enum:s.tokens.map(o=>o.symbol)},side:{type:"string",enum:["buy","sell"]},amountIn:k()};async function v(o,i){let t=s.tokens.find(c=>c.symbol===o.symbol);if(!t||o.side!=="buy"&&o.side!=="sell")throw new d("Choose a published stock symbol and buy or sell.");let e=await F(String(o.symbol),{context:i});if(e.kind!=="official_stock"||e.address!==b(t.token))throw new d("Published Priors stock pool does not match the official stock contract address. Retry after the pool mapping is updated.");let n=x(o.amountIn,"amountIn",128);if(n===0n)throw new d("amountIn must be positive base units.");return{token:t,identity:e,amount:n,input:o.side==="buy"?r.usdg:b(t.token),output:o.side==="buy"?b(t.token):r.usdg}}function B(o,i,t){let[e,n]=BigInt(r.usdg)<BigInt(o)?[r.usdg,o]:[o,r.usdg];return{currency0:e,currency1:n,fee:i,tickSpacing:t,hooks:q}}function j(o){return{tools:[{name:"priors_stock_quote",inputSchema:{type:"object",properties:A,required:Object.keys(A),additionalProperties:!1},async execute(i,t){if(o.network==="testnet")throw new d("Priors stock swaps require mainnet chain 4663.");let e=await v(i,o),n=o.clientFor(p),c=await n.getBlockNumber({cacheTime:0}),l=await Promise.all(e.token.pools.map(async(a,u)=>{try{let f=B(b(e.token.token),a.fee,"tickSpacing"in a?a.tickSpacing:0),m=a.v===3?await n.simulateContract({address:b(s.v3.quoter),abi:O,functionName:"quoteExactInputSingle",args:[{tokenIn:e.input,tokenOut:e.output,amountIn:e.amount,fee:a.fee,sqrtPriceLimitX96:0n}],account:t,blockNumber:c}):await n.simulateContract({address:b(s.v4.quoter),abi:P,functionName:"quoteExactInputSingle",args:[{poolKey:f,zeroForOne:e.input===f.currency0,exactAmount:e.amount,hookData:"0x"}],account:t,blockNumber:c});return{poolIndex:u,version:a.v,amountOut:m.result[0].toString()}}catch(f){return{poolIndex:u,version:a.v,error:o.plainError(f)}}}));return{chainId:p,blockNumber:c.toString(),token:e.identity,quotes:l,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:{...A,poolIndex:{type:"integer",minimum:0,maximum:2},minOut:k(),deadline:k(),eligible:{type:"boolean",description:"Operator/user affirms eligibility for this stock-token trade in their jurisdiction."}},required:[...Object.keys(A),"poolIndex","minOut","deadline","eligible"],additionalProperties:!1},async execute(i,t){if(o.network==="testnet")throw new d("Priors stock swaps require mainnet chain 4663.");if(t=b(t),i.eligible!==!0)throw new d("Confirm local eligibility for Robinhood stock tokens before trading.");let e=await v(i,o),n=x(i.minOut,"minOut"),c=x(i.deadline,"deadline"),l=BigInt(Math.floor(Date.now()/1e3));if(n===0n||c<=l||c>l+1800n||!Number.isSafeInteger(i.poolIndex))throw new d("Provide positive minOut, poolIndex and a deadline within 30 minutes.");let a=e.token.pools[i.poolIndex];if(!a)throw new d("No published pool at that index. Read priors_stock_quote.");let u=B(b(e.token.token),a.fee,"tickSpacing"in a?a.tickSpacing:0),f=e.input===u.currency0,m=b(a.v===3?s.v3.router:s.v4.swapper),g=a.v===3?C({abi:D,functionName:"multicall",args:[c,[C({abi:D,functionName:"exactInputSingle",args:[{tokenIn:e.input,tokenOut:e.output,fee:a.fee,recipient:t,amountIn:e.amount,amountOutMinimum:n,sqrtPriceLimitX96:0n}]})]]}):C({abi:D,functionName:"swapExactIn",args:[u,f,e.amount,n,f?4295128740n:1461446703485210103287273052203988822378723970341n,t,c]}),y=[o.approval(e.input,m,e.amount.toString(),p),o.unsignedTx({to:m,data:g,value:"0",chainId:p,description:`Priors stock ${i.side}: ${e.amount} input base units; minimum ${n}; pinned V${a.v} pool.`})],h=await o.preview(y,t);return{txs:y,expiresAt:c.toString(),summary:`Stock ${i.side} ${i.symbol}: input ${e.amount} base units (${e.input}), minimum output ${n} (${e.output}), receiver ${t}, deadline ${c}. Issuer transfer/sale restrictions apply. Price impact is not measured by this builder; inspect minOut and the preview. ${h.summary}`}}}]}}export{D as a,j as b};
@@ -1 +1 @@
1
- import{d as _,e as oe,f as M,h as te,i as N}from"./JVTVOK6P.js";import{E as P,a as Z,b as J,c as v,f as C,h as b,m as A,q as x,s as Q,u as ee}from"./FL3EF72E.js";import{f as D,g as Y}from"./FYTF2QMS.js";import{a as $}from"./XCFA73P2.js";import{a as G}from"./6IM6A5VA.js";import{g as S}from"./73N3TOJL.js";import{a as w}from"./XPFVT2EA.js";import{a as k,b as X,d as j}from"./5YS5V2LK.js";import{decodeAbiParameters as fe,getAddress as y,pad as se,parseAbi as ae,parseAbiParameters as me,toEventSelector as he,toHex as ne,zeroAddress as de}from"viem";var ge=he("Initialize(bytes32,address,address,uint24,int24,address,uint160,int24)"),ke=me("uint24 fee, int24 tickSpacing, address hooks, uint160 sqrtPriceX96, int24 tick"),V=10000000n,ce=25,H=200,L=16,we=3e3,Pe=500,ye=500n,E=100,B=ae(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),be=ae(["function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)"]);function Ae(o){let e=o.trim().toLowerCase();return e==="eth"||e==="native"||e===de||e===$.toLowerCase()}function ie(o,e){if(o!=null){if(typeof o!="string")throw new k(`${e} must be a token address, or "eth" for native ETH.`);return Ae(o)?{eth:!0}:(G(o),{eth:!1,address:y(o)})}}var le=(o,e)=>BigInt(o)<BigInt(e)?-1:BigInt(o)>BigInt(e)?1:0;function T(o){return{address:o.address,symbol:o.symbol,decimals:o.decimals}}async function ue(o,e,r,i,d){let[t,n,u]=await Promise.all([o.readContract({address:e,abi:N,functionName:"slot0"}),o.readContract({address:e,abi:N,functionName:"liquidity"}),o.readContract({address:e,abi:N,functionName:"tickSpacing"})]),s=BigInt(t[0]);return{version:"v3",id:e,token0:T(r),token1:T(i),fee:d,tickSpacing:Number(u),initialized:s>0n,liquidity:BigInt(n).toString(),sqrtPriceX96:s.toString(),tick:Number(t[1]),price:s>0n?D(s,r.decimals,i.decimals):"0",addSupported:!0}}async function q(o,e,r){let i=r??Q(e),[d,t]=await Promise.all([P(o,e.currency0,w),P(o,e.currency1,w)]),[n,u]=await Promise.all([o.readContract({address:v,abi:B,functionName:"getSlot0",args:[i]}),o.readContract({address:v,abi:B,functionName:"getLiquidity",args:[i]})]),s=BigInt(n[0]),m=ee(e,Number(n[3]));return{version:"v4",id:i,token0:T(d),token1:T(t),fee:e.fee,tickSpacing:e.tickSpacing,hooks:y(e.hooks),initialized:s>0n,liquidity:BigInt(u).toString(),sqrtPriceX96:s.toString(),tick:Number(n[1]),price:s>0n?D(s,d.decimals,t.decimals):"0",addSupported:x.has(e.hooks.toLowerCase()),feeNote:m.feeNote,...x.has(e.hooks.toLowerCase())?{}:{note:`Hook ${y(e.hooks)} is not one Oak has measured, so uniswap_add will refuse this pool.`}}}async function Ie(o,e,r){let i=await o.getBlockNumber(),d=new Map;for(let t=0n;t<=i;t+=V){let n=t+V-1n<i?t+V-1n:i,u=await o.request({method:"eth_getLogs",params:[{address:Z.toLowerCase(),topics:[ge,null,e?se(e):null,r?se(r):null],fromBlock:ne(t),toBlock:ne(n)}]});if(!Array.isArray(u))throw new k("Invalid v4 Initialize log response.");for(let s of u){if(!Array.isArray(s.topics)||s.topics.length!==4||typeof s.data!="string")throw new k("Invalid v4 Initialize log.");let[m,a,p]=fe(ke,s.data),h={currency0:y(`0x${s.topics[2].slice(-40)}`),currency1:y(`0x${s.topics[3].slice(-40)}`),fee:Number(m),tickSpacing:Number(a),hooks:y(p)};d.set(s.topics[1].toLowerCase(),{key:h,id:s.topics[1]})}}return[...d.values()]}async function ve(o,e,r){let i=e.eth?_.weth:e.address,d=r.eth?_.weth:r.address;if(i===d)return[];let[t,n]=le(i,d)<0?[i,d]:[d,i],[u,s]=await Promise.all([P(o,t,w),P(o,n,w)]),m=[];for(let a of Object.keys(oe).map(Number)){let p=y(String(await o.readContract({address:_.factory,abi:te,functionName:"getPool",args:[t,n,a]})));p!==de&&m.push(await ue(o,p,u,s,a))}return m}function re(o){return o?o.eth?[b,C]:o.address===C?[C,b]:[o.address]:null}async function Ce(o,e){let r=new Map;if(e.length===0)return r;if(typeof o.multicall=="function"&&o.chain?.contracts?.multicall3)try{return(await o.multicall({allowFailure:!0,contracts:e.map(d=>({address:v,abi:B,functionName:"getLiquidity",args:[d]}))})).forEach((d,t)=>r.set(e[t].toLowerCase(),d.status==="success"?BigInt(d.result):0n)),r}catch{}for(let i=0;i<e.length;i+=L)(await Promise.allSettled(e.slice(i,i+L).map(async t=>BigInt(await o.readContract({address:v,abi:B,functionName:"getLiquidity",args:[t]}))))).forEach((t,n)=>r.set(e[i+n].toLowerCase(),t.status==="fulfilled"?t.value:0n));return r}async function Se(o,e,r,i){let d=re(e),t=re(r),n=new Map,u=(c,f)=>{if(c&&f){if(c===f)return;let[l,g]=le(c,f)<0?[c,f]:[f,c];n.set(`${l}/${g}`,[l,g])}else if(c||f){let l=c??f;n.set(`${l}/*0`,[l,null]),n.set(`${l}/*1`,[null,l])}};for(let c of d??[null])for(let f of t??[null])u(c,f);let s=new Map;for(let c of A)[...n.values()].some(([l,g])=>(!l||S(c.key.currency0,l))&&(!g||S(c.key.currency1,g)))&&s.set(c.poolId.toLowerCase(),{key:c.key,id:c.poolId});for(let[c,f]of n.values())for(let l of await Ie(o,c,f))s.set(l.id.toLowerCase(),l);let m=new Set(A.map(c=>c.poolId.toLowerCase())),a=[...s.values()],p=a.filter(c=>m.has(c.id.toLowerCase())),h=a.filter(c=>!m.has(c.id.toLowerCase())).reverse(),I=typeof o.multicall=="function"&&!!o.chain?.contracts?.multicall3?we:Pe;h.length>I&&i.push(`${h.length} v4 pools match; only the newest ${I} non-measured ones were considered. Pass both tokens, or a poolId, to narrow.`);let U=h.slice(0,I),z=await Ce(o,U.map(c=>c.id)),pe=U.sort((c,f)=>{let l=z.get(c.id.toLowerCase())??0n,g=z.get(f.id.toLowerCase())??0n;return l===g?0:l<g?1:-1}),R=[...p,...pe];R.length>H&&i.push(`${R.length} v4 pools match; full state was read for Oak's measured pools plus the deepest of the rest (${H} total). Pass both tokens, or a poolId, to narrow.`);let K=[],O=0,W=R.slice(0,H);for(let c=0;c<W.length;c+=L){let f=await Promise.allSettled(W.slice(c,c+L).map(({key:l,id:g})=>q(o,l,g)));for(let l of f)l.status==="fulfilled"?K.push(l.value):O++}return O>0&&i.push(`${O} pool(s) were skipped because a token or pool state could not be read.`),K}async function _e(o,e){let r=A.find(s=>S(s.poolId,e));if(r)return q(o,r.key,r.poolId);let[i,d,t,n,u]=await o.readContract({address:J,abi:be,functionName:"poolKeys",args:[e.slice(0,52)]});if(i===b&&d===b&&Number(n)===0)throw new k(`No Uniswap v4 pool ${e} is known to the PositionManager (no position was ever minted in it, or it is not initialized). Search by token pair instead.`);return q(o,{currency0:i,currency1:d,fee:Number(t),tickSpacing:Number(n),hooks:u},e)}function Ne(o){let e=new Set([...A.map(t=>t.poolId.toLowerCase()),...M.map(t=>t.address.toLowerCase())]),r=new Set([b,$.toLowerCase(),C.toLowerCase()]),i=t=>r.has(t.address.toLowerCase())?"ETH":t.address.toLowerCase(),d=new Map;for(let t of o.filter(n=>n.initialized&&BigInt(n.liquidity)>0n)){let n=`${i(t.token0)}/${i(t.token1)}`;d.set(n,[...d.get(n)??[],t])}for(let t of d.values()){let n=t.filter(a=>e.has(a.id.toLowerCase()));if(n.length===0&&t.length<3)continue;let s=(n.length>0?n:t).map(a=>BigInt(a.sqrtPriceX96)).sort((a,p)=>a<p?-1:a>p?1:0),m=s[Math.floor(s.length/2)];for(let a of t){if(e.has(a.id.toLowerCase()))continue;let p=Y(BigInt(a.sqrtPriceX96),m);p>ye&&(a.priceOutlierBps=Number(p),a.note=`${a.note?`${a.note} `:""}Price differs ${p} bps from the ${n.length>0?"Oak-measured":"median"} price for this pair; do not treat this pool as the market price.`)}}}async function Ee(o,e){let r=e.version;if(r!==void 0&&r!=="v3"&&r!=="v4")throw new k('version must be "v3" or "v4"; omit it to search both.');let i=e.limit===void 0?ce:Number(e.limit);if(!Number.isInteger(i)||i<1||i>E)throw new k(`limit must be an integer from 1 to ${E}.`);let d=ie(e.tokenA,"tokenA"),t=ie(e.tokenB,"tokenB");if(!d&&t)throw new k("Provide tokenA when searching by token; tokenB narrows the search to a pair.");let n=o.clientFor(w),u=[],s=[];if(e.poolId!==void 0){if(typeof e.poolId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e.poolId))throw new k("poolId must be a 32-byte hex v4 poolId. For v3 search by tokenA/tokenB.");s=[await _e(n,e.poolId)]}else if(d){if(r!=="v4"&&(t?s.push(...await ve(n,d,t)):u.push("v3 pools are looked up per pair; pass tokenB to include them.")),r!=="v3")try{s.push(...await Se(n,d,t,u))}catch(a){throw X(a,-32601)?a:new k(`Could not search v4 pools. ${j(a)}`)}}else{u.push("No token filter given: showing the pools Oak has measured. Pass tokenA (and tokenB) to search the chain for every pool of a pair.");let a=await Promise.all(M.map(async h=>{let[F,I]=await Promise.all([P(n,h.token0,w),P(n,h.token1,w)]);return ue(n,h.address,F,I,h.fee)})),p=await Promise.all(A.map(h=>q(n,h.key,h.poolId)));s=[...r==="v4"?[]:a,...r==="v3"?[]:p]}Ne(s),s.sort((a,p)=>BigInt(p.liquidity)>BigInt(a.liquidity)?1:BigInt(p.liquidity)<BigInt(a.liquidity)?-1:0),s.length>i&&u.push(`Showing the ${i} deepest of ${s.length} pools found; raise limit (max ${E}) to see more.`),s=s.slice(0,i);let m=s.filter(a=>a.initialized&&BigInt(a.liquidity)>0n).length;return s.length===0&&u.push("No pool exists for this pair. Create one with uniswap_create_pool, or create it and add the first liquidity together with uniswap_add plus initialPrice."),{pools:s,notes:u,summary:`Found ${s.length} Uniswap pool(s), ${m} with active liquidity. price is token1 per 1 token0.`}}function Me(o){return{tools:[{name:"uniswap_pools",inputSchema:{type:"object",description:"Read-only pool discovery on Robinhood Chain (4663): every Uniswap v3 and v4 pool for a token pair with fee, tick spacing, hook, liquidity and price, or one v4 pool by poolId. No tokens given: the measured pools.",properties:{version:{type:"string",enum:["v3","v4"],description:"Limit to one version; omit to search both."},tokenA:{type:"string",description:'Token address, or "eth" for native ETH (searches v3 WETH and v4 native/WETH pools).'},tokenB:{type:"string",description:"Second token of the pair. Required for v3 lookups."},poolId:{type:"string",description:"32-byte v4 poolId to inspect."},limit:{type:"integer",minimum:1,maximum:E,default:ce}}},execute:async r=>Ee(o,r)}]}}export{Ee as a,Me as b};
1
+ import{d as _,e as oe,f as M,h as te,i as N}from"./3R3C3CU5.js";import{E as P,a as Z,b as J,c as v,f as C,h as b,m as A,q as x,s as Q,u as ee}from"./JG24LNUI.js";import{f as D,g as Y}from"./MEMVFR7Z.js";import{a as $}from"./VJ3W2V3B.js";import{a as G}from"./6IM6A5VA.js";import{g as S}from"./73N3TOJL.js";import{a as w}from"./XPFVT2EA.js";import{a as k,b as X,d as j}from"./5YS5V2LK.js";import{decodeAbiParameters as fe,getAddress as y,pad as se,parseAbi as ae,parseAbiParameters as me,toEventSelector as he,toHex as ne,zeroAddress as de}from"viem";var ge=he("Initialize(bytes32,address,address,uint24,int24,address,uint160,int24)"),ke=me("uint24 fee, int24 tickSpacing, address hooks, uint160 sqrtPriceX96, int24 tick"),V=10000000n,ce=25,H=200,L=16,we=3e3,Pe=500,ye=500n,E=100,B=ae(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),be=ae(["function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)"]);function Ae(o){let e=o.trim().toLowerCase();return e==="eth"||e==="native"||e===de||e===$.toLowerCase()}function ie(o,e){if(o!=null){if(typeof o!="string")throw new k(`${e} must be a token address, or "eth" for native ETH.`);return Ae(o)?{eth:!0}:(G(o),{eth:!1,address:y(o)})}}var le=(o,e)=>BigInt(o)<BigInt(e)?-1:BigInt(o)>BigInt(e)?1:0;function T(o){return{address:o.address,symbol:o.symbol,decimals:o.decimals}}async function ue(o,e,r,i,d){let[t,n,u]=await Promise.all([o.readContract({address:e,abi:N,functionName:"slot0"}),o.readContract({address:e,abi:N,functionName:"liquidity"}),o.readContract({address:e,abi:N,functionName:"tickSpacing"})]),s=BigInt(t[0]);return{version:"v3",id:e,token0:T(r),token1:T(i),fee:d,tickSpacing:Number(u),initialized:s>0n,liquidity:BigInt(n).toString(),sqrtPriceX96:s.toString(),tick:Number(t[1]),price:s>0n?D(s,r.decimals,i.decimals):"0",addSupported:!0}}async function q(o,e,r){let i=r??Q(e),[d,t]=await Promise.all([P(o,e.currency0,w),P(o,e.currency1,w)]),[n,u]=await Promise.all([o.readContract({address:v,abi:B,functionName:"getSlot0",args:[i]}),o.readContract({address:v,abi:B,functionName:"getLiquidity",args:[i]})]),s=BigInt(n[0]),m=ee(e,Number(n[3]));return{version:"v4",id:i,token0:T(d),token1:T(t),fee:e.fee,tickSpacing:e.tickSpacing,hooks:y(e.hooks),initialized:s>0n,liquidity:BigInt(u).toString(),sqrtPriceX96:s.toString(),tick:Number(n[1]),price:s>0n?D(s,d.decimals,t.decimals):"0",addSupported:x.has(e.hooks.toLowerCase()),feeNote:m.feeNote,...x.has(e.hooks.toLowerCase())?{}:{note:`Hook ${y(e.hooks)} is not one Oak has measured, so uniswap_add will refuse this pool.`}}}async function Ie(o,e,r){let i=await o.getBlockNumber(),d=new Map;for(let t=0n;t<=i;t+=V){let n=t+V-1n<i?t+V-1n:i,u=await o.request({method:"eth_getLogs",params:[{address:Z.toLowerCase(),topics:[ge,null,e?se(e):null,r?se(r):null],fromBlock:ne(t),toBlock:ne(n)}]});if(!Array.isArray(u))throw new k("Invalid v4 Initialize log response.");for(let s of u){if(!Array.isArray(s.topics)||s.topics.length!==4||typeof s.data!="string")throw new k("Invalid v4 Initialize log.");let[m,a,p]=fe(ke,s.data),h={currency0:y(`0x${s.topics[2].slice(-40)}`),currency1:y(`0x${s.topics[3].slice(-40)}`),fee:Number(m),tickSpacing:Number(a),hooks:y(p)};d.set(s.topics[1].toLowerCase(),{key:h,id:s.topics[1]})}}return[...d.values()]}async function ve(o,e,r){let i=e.eth?_.weth:e.address,d=r.eth?_.weth:r.address;if(i===d)return[];let[t,n]=le(i,d)<0?[i,d]:[d,i],[u,s]=await Promise.all([P(o,t,w),P(o,n,w)]),m=[];for(let a of Object.keys(oe).map(Number)){let p=y(String(await o.readContract({address:_.factory,abi:te,functionName:"getPool",args:[t,n,a]})));p!==de&&m.push(await ue(o,p,u,s,a))}return m}function re(o){return o?o.eth?[b,C]:o.address===C?[C,b]:[o.address]:null}async function Ce(o,e){let r=new Map;if(e.length===0)return r;if(typeof o.multicall=="function"&&o.chain?.contracts?.multicall3)try{return(await o.multicall({allowFailure:!0,contracts:e.map(d=>({address:v,abi:B,functionName:"getLiquidity",args:[d]}))})).forEach((d,t)=>r.set(e[t].toLowerCase(),d.status==="success"?BigInt(d.result):0n)),r}catch{}for(let i=0;i<e.length;i+=L)(await Promise.allSettled(e.slice(i,i+L).map(async t=>BigInt(await o.readContract({address:v,abi:B,functionName:"getLiquidity",args:[t]}))))).forEach((t,n)=>r.set(e[i+n].toLowerCase(),t.status==="fulfilled"?t.value:0n));return r}async function Se(o,e,r,i){let d=re(e),t=re(r),n=new Map,u=(c,f)=>{if(c&&f){if(c===f)return;let[l,g]=le(c,f)<0?[c,f]:[f,c];n.set(`${l}/${g}`,[l,g])}else if(c||f){let l=c??f;n.set(`${l}/*0`,[l,null]),n.set(`${l}/*1`,[null,l])}};for(let c of d??[null])for(let f of t??[null])u(c,f);let s=new Map;for(let c of A)[...n.values()].some(([l,g])=>(!l||S(c.key.currency0,l))&&(!g||S(c.key.currency1,g)))&&s.set(c.poolId.toLowerCase(),{key:c.key,id:c.poolId});for(let[c,f]of n.values())for(let l of await Ie(o,c,f))s.set(l.id.toLowerCase(),l);let m=new Set(A.map(c=>c.poolId.toLowerCase())),a=[...s.values()],p=a.filter(c=>m.has(c.id.toLowerCase())),h=a.filter(c=>!m.has(c.id.toLowerCase())).reverse(),I=typeof o.multicall=="function"&&!!o.chain?.contracts?.multicall3?we:Pe;h.length>I&&i.push(`${h.length} v4 pools match; only the newest ${I} non-measured ones were considered. Pass both tokens, or a poolId, to narrow.`);let U=h.slice(0,I),z=await Ce(o,U.map(c=>c.id)),pe=U.sort((c,f)=>{let l=z.get(c.id.toLowerCase())??0n,g=z.get(f.id.toLowerCase())??0n;return l===g?0:l<g?1:-1}),R=[...p,...pe];R.length>H&&i.push(`${R.length} v4 pools match; full state was read for Oak's measured pools plus the deepest of the rest (${H} total). Pass both tokens, or a poolId, to narrow.`);let K=[],O=0,W=R.slice(0,H);for(let c=0;c<W.length;c+=L){let f=await Promise.allSettled(W.slice(c,c+L).map(({key:l,id:g})=>q(o,l,g)));for(let l of f)l.status==="fulfilled"?K.push(l.value):O++}return O>0&&i.push(`${O} pool(s) were skipped because a token or pool state could not be read.`),K}async function _e(o,e){let r=A.find(s=>S(s.poolId,e));if(r)return q(o,r.key,r.poolId);let[i,d,t,n,u]=await o.readContract({address:J,abi:be,functionName:"poolKeys",args:[e.slice(0,52)]});if(i===b&&d===b&&Number(n)===0)throw new k(`No Uniswap v4 pool ${e} is known to the PositionManager (no position was ever minted in it, or it is not initialized). Search by token pair instead.`);return q(o,{currency0:i,currency1:d,fee:Number(t),tickSpacing:Number(n),hooks:u},e)}function Ne(o){let e=new Set([...A.map(t=>t.poolId.toLowerCase()),...M.map(t=>t.address.toLowerCase())]),r=new Set([b,$.toLowerCase(),C.toLowerCase()]),i=t=>r.has(t.address.toLowerCase())?"ETH":t.address.toLowerCase(),d=new Map;for(let t of o.filter(n=>n.initialized&&BigInt(n.liquidity)>0n)){let n=`${i(t.token0)}/${i(t.token1)}`;d.set(n,[...d.get(n)??[],t])}for(let t of d.values()){let n=t.filter(a=>e.has(a.id.toLowerCase()));if(n.length===0&&t.length<3)continue;let s=(n.length>0?n:t).map(a=>BigInt(a.sqrtPriceX96)).sort((a,p)=>a<p?-1:a>p?1:0),m=s[Math.floor(s.length/2)];for(let a of t){if(e.has(a.id.toLowerCase()))continue;let p=Y(BigInt(a.sqrtPriceX96),m);p>ye&&(a.priceOutlierBps=Number(p),a.note=`${a.note?`${a.note} `:""}Price differs ${p} bps from the ${n.length>0?"Oak-measured":"median"} price for this pair; do not treat this pool as the market price.`)}}}async function Ee(o,e){let r=e.version;if(r!==void 0&&r!=="v3"&&r!=="v4")throw new k('version must be "v3" or "v4"; omit it to search both.');let i=e.limit===void 0?ce:Number(e.limit);if(!Number.isInteger(i)||i<1||i>E)throw new k(`limit must be an integer from 1 to ${E}.`);let d=ie(e.tokenA,"tokenA"),t=ie(e.tokenB,"tokenB");if(!d&&t)throw new k("Provide tokenA when searching by token; tokenB narrows the search to a pair.");let n=o.clientFor(w),u=[],s=[];if(e.poolId!==void 0){if(typeof e.poolId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e.poolId))throw new k("poolId must be a 32-byte hex v4 poolId. For v3 search by tokenA/tokenB.");s=[await _e(n,e.poolId)]}else if(d){if(r!=="v4"&&(t?s.push(...await ve(n,d,t)):u.push("v3 pools are looked up per pair; pass tokenB to include them.")),r!=="v3")try{s.push(...await Se(n,d,t,u))}catch(a){throw X(a,-32601)?a:new k(`Could not search v4 pools. ${j(a)}`)}}else{u.push("No token filter given: showing the pools Oak has measured. Pass tokenA (and tokenB) to search the chain for every pool of a pair.");let a=await Promise.all(M.map(async h=>{let[F,I]=await Promise.all([P(n,h.token0,w),P(n,h.token1,w)]);return ue(n,h.address,F,I,h.fee)})),p=await Promise.all(A.map(h=>q(n,h.key,h.poolId)));s=[...r==="v4"?[]:a,...r==="v3"?[]:p]}Ne(s),s.sort((a,p)=>BigInt(p.liquidity)>BigInt(a.liquidity)?1:BigInt(p.liquidity)<BigInt(a.liquidity)?-1:0),s.length>i&&u.push(`Showing the ${i} deepest of ${s.length} pools found; raise limit (max ${E}) to see more.`),s=s.slice(0,i);let m=s.filter(a=>a.initialized&&BigInt(a.liquidity)>0n).length;return s.length===0&&u.push("No pool exists for this pair. Create one with uniswap_create_pool, or create it and add the first liquidity together with uniswap_add plus initialPrice."),{pools:s,notes:u,summary:`Found ${s.length} Uniswap pool(s), ${m} with active liquidity. price is token1 per 1 token0.`}}function Me(o){return{tools:[{name:"uniswap_pools",inputSchema:{type:"object",description:"Read-only pool discovery on Robinhood Chain (4663): every Uniswap v3 and v4 pool for a token pair with fee, tick spacing, hook, liquidity and price, or one v4 pool by poolId. No tokens given: the measured pools.",properties:{version:{type:"string",enum:["v3","v4"],description:"Limit to one version; omit to search both."},tokenA:{type:"string",description:'Token address, or "eth" for native ETH (searches v3 WETH and v4 native/WETH pools).'},tokenB:{type:"string",description:"Second token of the pair. Required for v3 lookups."},poolId:{type:"string",description:"32-byte v4 poolId to inspect."},limit:{type:"integer",minimum:1,maximum:E,default:ce}}},execute:async r=>Ee(o,r)}]}}export{Ee as a,Me as b};
@@ -1 +1 @@
1
- import{a as $}from"./B7V7AA5A.js";import{a as U}from"./EKGHKEKV.js";import{b as I}from"./KEPQXFHU.js";import{c as k}from"./JRZLKIYB.js";import{g as S}from"./65QFM4JU.js";import{c as G}from"./HL2MLC3O.js";import{a as b}from"./CXMC3T6B.js";import{b as E}from"./AXYOJBX6.js";import{a as h}from"./6IM6A5VA.js";import{a as D}from"./UWOFA6GV.js";import{g as y,n as C}from"./73N3TOJL.js";import{a as s,d as P,i as w}from"./XPFVT2EA.js";import{a as m}from"./5YS5V2LK.js";import{encodeFunctionData as v,parseAbi as j}from"viem";var a=w[s].vaults.netnet.address,d={address:w[s].tokens.USDG.address,chainId:s,decimals:P,symbol:"USDG"},N={address:a,chainId:s,decimals:18,symbol:"nnUSDG"},o=j(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function balanceOf(address owner) view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),_=D("Positive USDG amount in integer base units (6 decimals)."),O="Preview amounts are estimates; these ERC-4626 calls have no on-chain minimum output argument. No transaction was sent.";function M(e){return C(e,"Amount must be positive and fit in uint256.",{notString:"Provide an integer amount string in base units.",positive:!0})}function g(e,f){if(Object.keys(e).some(l=>!f.includes(l)))throw new m("Unsupported NetNet argument.")}var q=e=>{async function f(t){try{return await t()}catch(n){throw new m(e.plainError(n))}}async function l(){let t=e.clientFor(s);if(await t.getChainId()!==s)throw new m("NetNet requires chain 4663.");let[n,r]=await Promise.all([t.readContract({address:a,abi:o,functionName:"asset"}),t.readContract({address:a,abi:o,functionName:"decimals"})]);if(!y(n,d.address))throw new m("NetNet does not report the pinned USDG asset.");if(r!==N.decimals)throw new m("NetNet share decimals do not match the pinned metadata.");return t}async function A(t,n,r){let i=await e.preview(t,n),p=i.changes.map(({token:u,amount:c})=>{let T=c.startsWith("-");return`${T?"-":"+"}${e.formatAmount(T?c.slice(1):c,u.decimals)} ${u.symbol}`}).join(", ");return{txs:t,preview:i,summary:`${r} ${i.summary} ${p?`Estimated changes: ${p}. `:""}${O}`}}async function R(t){return f(async()=>{h(t);let n=await l(),r=await n.readContract({address:a,abi:o,functionName:"balanceOf",args:[t]});if(r===0n)return[];let i=await n.readContract({address:a,abi:o,functionName:"convertToAssets",args:[r]});return[{module:"netnet",id:`${s}:${a}`,chainId:s,assets:[{token:{...d},amount:i.toString()}],description:`${e.formatAmount(r.toString(),N.decimals)} nnUSDG shares in NetNet Credit (${a}); underlying USDG is an estimate, not a liquidity guarantee.`}]})}return{positions:R,tools:[{name:"netnet_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:t=>f(async()=>{g(t,[]);let r=await(await l()).readContract({address:a,abi:o,functionName:"totalAssets"});return[{address:a,name:"NetNet Credit",chainId:s,asset:{...d},shares:{...N},totalAssets:{token:{...d},amount:r.toString()}}]})},{name:"netnet_deposit",inputSchema:{type:"object",properties:{amount:_},required:["amount"],additionalProperties:!1},execute:(t,n)=>f(async()=>{g(t,["amount"]),h(n);let r=M(t.amount);await l();let i=[e.approval(d.address,a,r.toString(),s),e.unsignedTx({to:a,data:v({abi:o,functionName:"deposit",args:[r,n]}),value:"0",chainId:s,description:`Deposit ${e.formatAmount(r.toString(),d.decimals)} USDG into NetNet Credit.`})];return A(i,n,"Approve the exact USDG amount, then deposit into NetNet Credit.")})},{name:"netnet_withdraw",inputSchema:{type:"object",properties:{amount:{anyOf:[_,{const:"max",description:"Redeem the fresh full nnUSDG share balance."}]}},required:["amount"],additionalProperties:!1},execute:(t,n)=>f(async()=>{g(t,["amount"]),h(n);let r=t.amount==="max"?void 0:M(t.amount),i=await l(),p,u;if(r===void 0){let c=await i.readContract({address:a,abi:o,functionName:"balanceOf",args:[n]});if(c===0n)throw new m("This wallet has no NetNet shares to redeem.");p=v({abi:o,functionName:"redeem",args:[c,n,n]}),u=`Redeem all ${e.formatAmount(c.toString(),N.decimals)} nnUSDG shares for USDG.`}else p=v({abi:o,functionName:"withdraw",args:[r,n,n]}),u=`Withdraw ${e.formatAmount(r.toString(),d.decimals)} USDG from NetNet Credit (unmeasured on the recorded fork; full exit uses amount "max" redeem).`;return A([e.unsignedTx({to:a,data:p,value:"0",chainId:s,description:u})],n,u)})}]}};function ie(e){return E("netnet",[q(e),S(e),k(e),G(e),$(e),U(e),I(e),{tools:b(e,"netnet",[{vault:a,asset:d}])}])}export{q as a,ie as b};
1
+ import{a as $}from"./Q4RZQCDS.js";import{a as U}from"./WLACEU2Y.js";import{c as G}from"./HL2MLC3O.js";import{b as I}from"./X6G4BD35.js";import{c as k}from"./PR2QED25.js";import{g as S}from"./65QFM4JU.js";import{a as b}from"./XGUKLFBU.js";import{b as E}from"./AXYOJBX6.js";import{a as h}from"./6IM6A5VA.js";import{a as D}from"./UWOFA6GV.js";import{g as y,n as C}from"./73N3TOJL.js";import{a as s,d as P,i as w}from"./XPFVT2EA.js";import{a as m}from"./5YS5V2LK.js";import{encodeFunctionData as v,parseAbi as j}from"viem";var a=w[s].vaults.netnet.address,d={address:w[s].tokens.USDG.address,chainId:s,decimals:P,symbol:"USDG"},N={address:a,chainId:s,decimals:18,symbol:"nnUSDG"},o=j(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function balanceOf(address owner) view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),_=D("Positive USDG amount in integer base units (6 decimals)."),O="Preview amounts are estimates; these ERC-4626 calls have no on-chain minimum output argument. No transaction was sent.";function M(e){return C(e,"Amount must be positive and fit in uint256.",{notString:"Provide an integer amount string in base units.",positive:!0})}function g(e,f){if(Object.keys(e).some(l=>!f.includes(l)))throw new m("Unsupported NetNet argument.")}var q=e=>{async function f(t){try{return await t()}catch(n){throw new m(e.plainError(n))}}async function l(){let t=e.clientFor(s);if(await t.getChainId()!==s)throw new m("NetNet requires chain 4663.");let[n,r]=await Promise.all([t.readContract({address:a,abi:o,functionName:"asset"}),t.readContract({address:a,abi:o,functionName:"decimals"})]);if(!y(n,d.address))throw new m("NetNet does not report the pinned USDG asset.");if(r!==N.decimals)throw new m("NetNet share decimals do not match the pinned metadata.");return t}async function A(t,n,r){let i=await e.preview(t,n),p=i.changes.map(({token:u,amount:c})=>{let T=c.startsWith("-");return`${T?"-":"+"}${e.formatAmount(T?c.slice(1):c,u.decimals)} ${u.symbol}`}).join(", ");return{txs:t,preview:i,summary:`${r} ${i.summary} ${p?`Estimated changes: ${p}. `:""}${O}`}}async function R(t){return f(async()=>{h(t);let n=await l(),r=await n.readContract({address:a,abi:o,functionName:"balanceOf",args:[t]});if(r===0n)return[];let i=await n.readContract({address:a,abi:o,functionName:"convertToAssets",args:[r]});return[{module:"netnet",id:`${s}:${a}`,chainId:s,assets:[{token:{...d},amount:i.toString()}],description:`${e.formatAmount(r.toString(),N.decimals)} nnUSDG shares in NetNet Credit (${a}); underlying USDG is an estimate, not a liquidity guarantee.`}]})}return{positions:R,tools:[{name:"netnet_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:t=>f(async()=>{g(t,[]);let r=await(await l()).readContract({address:a,abi:o,functionName:"totalAssets"});return[{address:a,name:"NetNet Credit",chainId:s,asset:{...d},shares:{...N},totalAssets:{token:{...d},amount:r.toString()}}]})},{name:"netnet_deposit",inputSchema:{type:"object",properties:{amount:_},required:["amount"],additionalProperties:!1},execute:(t,n)=>f(async()=>{g(t,["amount"]),h(n);let r=M(t.amount);await l();let i=[e.approval(d.address,a,r.toString(),s),e.unsignedTx({to:a,data:v({abi:o,functionName:"deposit",args:[r,n]}),value:"0",chainId:s,description:`Deposit ${e.formatAmount(r.toString(),d.decimals)} USDG into NetNet Credit.`})];return A(i,n,"Approve the exact USDG amount, then deposit into NetNet Credit.")})},{name:"netnet_withdraw",inputSchema:{type:"object",properties:{amount:{anyOf:[_,{const:"max",description:"Redeem the fresh full nnUSDG share balance."}]}},required:["amount"],additionalProperties:!1},execute:(t,n)=>f(async()=>{g(t,["amount"]),h(n);let r=t.amount==="max"?void 0:M(t.amount),i=await l(),p,u;if(r===void 0){let c=await i.readContract({address:a,abi:o,functionName:"balanceOf",args:[n]});if(c===0n)throw new m("This wallet has no NetNet shares to redeem.");p=v({abi:o,functionName:"redeem",args:[c,n,n]}),u=`Redeem all ${e.formatAmount(c.toString(),N.decimals)} nnUSDG shares for USDG.`}else p=v({abi:o,functionName:"withdraw",args:[r,n,n]}),u=`Withdraw ${e.formatAmount(r.toString(),d.decimals)} USDG from NetNet Credit (unmeasured on the recorded fork; full exit uses amount "max" redeem).`;return A([e.unsignedTx({to:a,data:p,value:"0",chainId:s,description:u})],n,u)})}]}};function ie(e){return E("netnet",[q(e),S(e),k(e),G(e),$(e),U(e),I(e),{tools:b(e,"netnet",[{vault:a,asset:d}])}])}export{q as a,ie as b};
@@ -1 +1 @@
1
- import{a as j}from"./XW7RH7YY.js";import{a as V}from"./2O6A6WEX.js";import{b as H,c as Z,d as z,e as J}from"./VCWDJQDE.js";import{a as L}from"./JRVTSGAT.js";import{c as W}from"./EC5W3UZD.js";import{b as $,o as q}from"./EAEQOS7Y.js";import{b as _}from"./AXYOJBX6.js";import{a as x,d as B,e as E}from"./6IM6A5VA.js";import{a as D}from"./UWOFA6GV.js";import{g as A,m as R,n as U}from"./73N3TOJL.js";import{a as h,d as N,i as I,j as S}from"./XPFVT2EA.js";import{a as o}from"./5YS5V2LK.js";import{getAddress as F,parseAbi as ee}from"viem";var a=F(I[4663].vaults.groveAlm.address),te="0x29626c2d8ca49a51e4deceec5499e52983c42bd5",d=ee(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)","function maxDeposit(address) view returns (uint256)","function maxWithdraw(address) view returns (uint256)","function previewDeposit(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)"]),T=D("Positive integer in token base units."),M={type:"string",description:`Public Grove vault only: ${a}. Defaults to this vault.`},K={type:"integer",minimum:0,maximum:9999,default:$};function C(t){return U(t,"Amount must be positive and within the uint256 range.",{notString:"Amount must be a positive integer string in base units.",positive:!0})}function v(t){return R(t,"Grove returned an invalid integer read.")}function O(t,m,l){if(x(m),Object.keys(t).some(u=>!["vault",...l].includes(u)))throw new o("Unsupported Grove argument.");if(t.vault!==void 0){if(typeof t.vault!="string")throw new o("Provide the public Grove vault address.");if(t.vault.toLowerCase()===te)throw new o("The Grove ALM proxy is allocator infrastructure, not the public ERC-4626 vault.");if(x(t.vault),!A(t.vault,a))throw new o("Only the public Grove ERC-4626 vault is supported.")}}function Q(t,m,l){let u=l===void 0?$:l;if(typeof u!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");let e=BigInt(q(t.toString(),u)),n=m===void 0?e:C(m);if(n<=0n||n>t)throw new o("The minimum output must be positive and no greater than the quoted output.");return n}function X(t,m){let l=0n;for(let u of t.changes)if(!(u.token.chainId!==m.chainId||!A(u.token.address,m.address))){if(u.token.decimals!==m.decimals||typeof u.amount!="string"||!/^-?\d+$/.test(u.amount))throw new o("Grove preview returned invalid token metadata or amounts.");l+=BigInt(u.amount)}return l}var ne=t=>{async function m(e){try{return await e()}catch(n){throw new o(t.plainError(n))}}async function l(){let e=t.clientFor(h);if(await e.getChainId()!==h)throw new o("Grove requires an RPC endpoint on chain 4663.");let n=await e.readContract({address:a,abi:d,functionName:"asset"});if(typeof n!="string"||!A(n,S))throw new o("The public Grove vault must use canonical USDG on chain 4663.");let[i,s]=await Promise.all([e.readContract({address:F(S),abi:d,functionName:"decimals"}),e.readContract({address:a,abi:d,functionName:"decimals"})]);if(i!==N||s!==18)throw new o("Grove token decimals differ from the evidenced USDG/share interface.");let r={address:F(S),chainId:h,decimals:i,symbol:"USDG"};return{client:e,asset:r,shareToken:{address:a,chainId:h,decimals:s,symbol:"Grove shares"}}}async function u(e,n,i,s,r,p){let f=await t.preview(e,n);if(X(f,i)!==-s)throw new o("Grove simulation did not show the exact requested token outflow.");if(X(f,r)<p)throw new o("Grove simulated output is below the minimum.");let g=f.changes.map(({token:w,amount:b})=>{let y=b.startsWith("-");return`${y?"-":"+"}${t.formatAmount(y?b.slice(1):b,w.decimals)} ${w.symbol} (${w.address}, chain ${w.chainId})`}).join("; ");return{txs:e,summary:`${f.summary} ${g}. Minimum ${p} base units of ${r.address} is a preview check, not enforced on-chain by standard ERC-4626. Re-preview before signing; execution output can change.`}}return{tools:[Z(t,"grove_details",a),L(t,"grove_analytics",a),V(t,"grove_manage",a),...j(t,"grove",a),{name:"grove_list",inputSchema:{type:"object",properties:{vault:M},additionalProperties:!1},execute:(e,n)=>m(async()=>{O(e,n,[]);let{client:i,asset:s,shareToken:r}=await l(),[p,f,c,g,w,b]=await Promise.all([i.readContract({address:a,abi:d,functionName:"totalAssets"}),i.readContract({address:a,abi:d,functionName:"totalSupply"}),i.readContract({address:a,abi:d,functionName:"maxDeposit",args:[n]}),i.readContract({address:a,abi:d,functionName:"maxWithdraw",args:[n]}),i.readContract({address:a,abi:d,functionName:"performanceFee"}),i.readContract({address:a,abi:d,functionName:"managementFee"})]);return[{vault:a,chainId:h,name:"Grove x Steakhouse USDG",asset:s,shareToken:r,totalAssets:{token:s,amount:v(p).toString()},totalSupply:{token:r,amount:v(f).toString()},maxDeposit:v(c)===0n?null:c.toString(),maxWithdraw:v(g)===0n?null:g.toString(),maxViewCaveat:"Zero Morpho V2 maximum views mean unknown capacity. Simulate the requested action; full exits use the fresh share balance.",fees:{performanceFeeRaw:v(w).toString(),managementFeeRaw:v(b).toString(),scale:"1000000000000000000",managementFeeTimeUnit:"second",performanceFeeBasis:"accrued interest"}}]})},{name:"grove_deposit",inputSchema:{type:"object",properties:{vault:M,amount:T,minSharesOut:T,slippageBps:K},required:["amount"],additionalProperties:!1},execute:(e,n)=>m(async()=>{O(e,n,["amount","minSharesOut","slippageBps"]);let i=C(e.amount),{client:s,asset:r,shareToken:p}=await l(),f=v(await s.readContract({address:a,abi:d,functionName:"previewDeposit",args:[i]})),c=Q(f,e.minSharesOut,e.slippageBps),g=B(a,r.address,i.toString(),n,h),w=[t.approval(r.address,a,i.toString(),h),t.unsignedTx(g.txs[1])];return u(w,n,r,i,p,c)})},{name:"grove_withdraw",inputSchema:{type:"object",properties:{vault:M,shares:{oneOf:[T,{const:"all",description:"Redeem the fresh full share balance."}]},minAmountOut:T,slippageBps:K,force:{type:"boolean"},maxPenaltyAssets:D()},required:["shares"],additionalProperties:!1},execute:(e,n)=>m(async()=>{O(e,n,["shares","minAmountOut","slippageBps","force","maxPenaltyAssets"]);let i=e.shares==="all"?void 0:C(e.shares),{client:s,asset:r,shareToken:p}=await l(),f=v(await s.readContract({address:a,abi:d,functionName:"balanceOf",args:[n]})),c=i??f;if(c===0n||c>f)throw new o("The Grove share balance is insufficient for this withdrawal.");if(e.force!==void 0&&typeof e.force!="boolean")throw new o("force must be a boolean.");if(e.force===!0){if(e.shares!=="all"||e.slippageBps!==void 0)throw new o("Force exit requires shares all and an explicit minAmountOut; omit slippageBps.");let k=W(e.maxPenaltyAssets),Y=C(e.minAmountOut),G=await H(t,s,a,n,c,k),P=await t.preview([G.tx],n);return J(P.changes,a,c,Y),{txs:[G.tx],preview:P,summary:`${z(G.plan)} ${P.summary}`}}if(e.maxPenaltyAssets!==void 0)throw new o("maxPenaltyAssets requires force true.");let g=v(await s.readContract({address:a,abi:d,functionName:"previewRedeem",args:[c]})),w=Q(g,e.minAmountOut,e.slippageBps),y=E(a,c.toString(),n,h).txs.map(k=>t.unsignedTx({...k,description:`Redeem ${c} Grove share base units to the wallet.`}));return u(y,n,p,c,r,w)})}],positions:e=>m(async()=>{x(e);let{client:n,asset:i,shareToken:s}=await l(),r=v(await n.readContract({address:a,abi:d,functionName:"balanceOf",args:[e]}));if(r===0n)return[];let p=v(await n.readContract({address:a,abi:d,functionName:"previewRedeem",args:[r]}));return[{module:"grove",id:`${h}:${a.toLowerCase()}`,chainId:h,assets:[{token:i,amount:p.toString()}],description:`${t.formatAmount(r.toString(),s.decimals)} Grove shares (${r} base units, ${s.decimals} decimals, ${a}); estimated USDG redemption, subject to simulation.`}]})}},he=t=>_("grove",[ne(t)]);export{ne as a,he as b};
1
+ import{a as j}from"./XW7RH7YY.js";import{a as V}from"./XUJSQV52.js";import{b as H,c as Z,d as z,e as J}from"./DVKDWXEJ.js";import{a as L}from"./JRVTSGAT.js";import{c as W}from"./EC5W3UZD.js";import{b as $,o as q}from"./CAU44UWP.js";import{b as _}from"./AXYOJBX6.js";import{a as x,d as B,e as E}from"./6IM6A5VA.js";import{a as D}from"./UWOFA6GV.js";import{g as A,m as R,n as U}from"./73N3TOJL.js";import{a as h,d as N,i as I,j as S}from"./XPFVT2EA.js";import{a as o}from"./5YS5V2LK.js";import{getAddress as F,parseAbi as ee}from"viem";var a=F(I[4663].vaults.groveAlm.address),te="0x29626c2d8ca49a51e4deceec5499e52983c42bd5",d=ee(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)","function maxDeposit(address) view returns (uint256)","function maxWithdraw(address) view returns (uint256)","function previewDeposit(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)"]),T=D("Positive integer in token base units."),M={type:"string",description:`Public Grove vault only: ${a}. Defaults to this vault.`},K={type:"integer",minimum:0,maximum:9999,default:$};function C(t){return U(t,"Amount must be positive and within the uint256 range.",{notString:"Amount must be a positive integer string in base units.",positive:!0})}function v(t){return R(t,"Grove returned an invalid integer read.")}function O(t,m,l){if(x(m),Object.keys(t).some(u=>!["vault",...l].includes(u)))throw new o("Unsupported Grove argument.");if(t.vault!==void 0){if(typeof t.vault!="string")throw new o("Provide the public Grove vault address.");if(t.vault.toLowerCase()===te)throw new o("The Grove ALM proxy is allocator infrastructure, not the public ERC-4626 vault.");if(x(t.vault),!A(t.vault,a))throw new o("Only the public Grove ERC-4626 vault is supported.")}}function Q(t,m,l){let u=l===void 0?$:l;if(typeof u!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");let e=BigInt(q(t.toString(),u)),n=m===void 0?e:C(m);if(n<=0n||n>t)throw new o("The minimum output must be positive and no greater than the quoted output.");return n}function X(t,m){let l=0n;for(let u of t.changes)if(!(u.token.chainId!==m.chainId||!A(u.token.address,m.address))){if(u.token.decimals!==m.decimals||typeof u.amount!="string"||!/^-?\d+$/.test(u.amount))throw new o("Grove preview returned invalid token metadata or amounts.");l+=BigInt(u.amount)}return l}var ne=t=>{async function m(e){try{return await e()}catch(n){throw new o(t.plainError(n))}}async function l(){let e=t.clientFor(h);if(await e.getChainId()!==h)throw new o("Grove requires an RPC endpoint on chain 4663.");let n=await e.readContract({address:a,abi:d,functionName:"asset"});if(typeof n!="string"||!A(n,S))throw new o("The public Grove vault must use canonical USDG on chain 4663.");let[i,s]=await Promise.all([e.readContract({address:F(S),abi:d,functionName:"decimals"}),e.readContract({address:a,abi:d,functionName:"decimals"})]);if(i!==N||s!==18)throw new o("Grove token decimals differ from the evidenced USDG/share interface.");let r={address:F(S),chainId:h,decimals:i,symbol:"USDG"};return{client:e,asset:r,shareToken:{address:a,chainId:h,decimals:s,symbol:"Grove shares"}}}async function u(e,n,i,s,r,p){let f=await t.preview(e,n);if(X(f,i)!==-s)throw new o("Grove simulation did not show the exact requested token outflow.");if(X(f,r)<p)throw new o("Grove simulated output is below the minimum.");let g=f.changes.map(({token:w,amount:b})=>{let y=b.startsWith("-");return`${y?"-":"+"}${t.formatAmount(y?b.slice(1):b,w.decimals)} ${w.symbol} (${w.address}, chain ${w.chainId})`}).join("; ");return{txs:e,summary:`${f.summary} ${g}. Minimum ${p} base units of ${r.address} is a preview check, not enforced on-chain by standard ERC-4626. Re-preview before signing; execution output can change.`}}return{tools:[Z(t,"grove_details",a),L(t,"grove_analytics",a),V(t,"grove_manage",a),...j(t,"grove",a),{name:"grove_list",inputSchema:{type:"object",properties:{vault:M},additionalProperties:!1},execute:(e,n)=>m(async()=>{O(e,n,[]);let{client:i,asset:s,shareToken:r}=await l(),[p,f,c,g,w,b]=await Promise.all([i.readContract({address:a,abi:d,functionName:"totalAssets"}),i.readContract({address:a,abi:d,functionName:"totalSupply"}),i.readContract({address:a,abi:d,functionName:"maxDeposit",args:[n]}),i.readContract({address:a,abi:d,functionName:"maxWithdraw",args:[n]}),i.readContract({address:a,abi:d,functionName:"performanceFee"}),i.readContract({address:a,abi:d,functionName:"managementFee"})]);return[{vault:a,chainId:h,name:"Grove x Steakhouse USDG",asset:s,shareToken:r,totalAssets:{token:s,amount:v(p).toString()},totalSupply:{token:r,amount:v(f).toString()},maxDeposit:v(c)===0n?null:c.toString(),maxWithdraw:v(g)===0n?null:g.toString(),maxViewCaveat:"Zero Morpho V2 maximum views mean unknown capacity. Simulate the requested action; full exits use the fresh share balance.",fees:{performanceFeeRaw:v(w).toString(),managementFeeRaw:v(b).toString(),scale:"1000000000000000000",managementFeeTimeUnit:"second",performanceFeeBasis:"accrued interest"}}]})},{name:"grove_deposit",inputSchema:{type:"object",properties:{vault:M,amount:T,minSharesOut:T,slippageBps:K},required:["amount"],additionalProperties:!1},execute:(e,n)=>m(async()=>{O(e,n,["amount","minSharesOut","slippageBps"]);let i=C(e.amount),{client:s,asset:r,shareToken:p}=await l(),f=v(await s.readContract({address:a,abi:d,functionName:"previewDeposit",args:[i]})),c=Q(f,e.minSharesOut,e.slippageBps),g=B(a,r.address,i.toString(),n,h),w=[t.approval(r.address,a,i.toString(),h),t.unsignedTx(g.txs[1])];return u(w,n,r,i,p,c)})},{name:"grove_withdraw",inputSchema:{type:"object",properties:{vault:M,shares:{oneOf:[T,{const:"all",description:"Redeem the fresh full share balance."}]},minAmountOut:T,slippageBps:K,force:{type:"boolean"},maxPenaltyAssets:D()},required:["shares"],additionalProperties:!1},execute:(e,n)=>m(async()=>{O(e,n,["shares","minAmountOut","slippageBps","force","maxPenaltyAssets"]);let i=e.shares==="all"?void 0:C(e.shares),{client:s,asset:r,shareToken:p}=await l(),f=v(await s.readContract({address:a,abi:d,functionName:"balanceOf",args:[n]})),c=i??f;if(c===0n||c>f)throw new o("The Grove share balance is insufficient for this withdrawal.");if(e.force!==void 0&&typeof e.force!="boolean")throw new o("force must be a boolean.");if(e.force===!0){if(e.shares!=="all"||e.slippageBps!==void 0)throw new o("Force exit requires shares all and an explicit minAmountOut; omit slippageBps.");let k=W(e.maxPenaltyAssets),Y=C(e.minAmountOut),G=await H(t,s,a,n,c,k),P=await t.preview([G.tx],n);return J(P.changes,a,c,Y),{txs:[G.tx],preview:P,summary:`${z(G.plan)} ${P.summary}`}}if(e.maxPenaltyAssets!==void 0)throw new o("maxPenaltyAssets requires force true.");let g=v(await s.readContract({address:a,abi:d,functionName:"previewRedeem",args:[c]})),w=Q(g,e.minAmountOut,e.slippageBps),y=E(a,c.toString(),n,h).txs.map(k=>t.unsignedTx({...k,description:`Redeem ${c} Grove share base units to the wallet.`}));return u(y,n,p,c,r,w)})}],positions:e=>m(async()=>{x(e);let{client:n,asset:i,shareToken:s}=await l(),r=v(await n.readContract({address:a,abi:d,functionName:"balanceOf",args:[e]}));if(r===0n)return[];let p=v(await n.readContract({address:a,abi:d,functionName:"previewRedeem",args:[r]}));return[{module:"grove",id:`${h}:${a.toLowerCase()}`,chainId:h,assets:[{token:i,amount:p.toString()}],description:`${t.formatAmount(r.toString(),s.decimals)} Grove shares (${r} base units, ${s.decimals} decimals, ${a}); estimated USDG redemption, subject to simulation.`}]})}},he=t=>_("grove",[ne(t)]);export{ne as a,he as b};
@@ -1 +1 @@
1
- import{j as s}from"./E7ASOYQI.js";import{formatUnits as c}from"viem";function l(e){return`HoodLock creation fee: ${e.eth} ETH (${e.amount} wei; ${e.usd===null?"USD unavailable: no fresh ETH/USD reference":`approximately $${e.usd} USD`}), not refundable after creation. Paid to ${e.contract}; separate from network gas.`}async function p(e,t,d,r){let o=r===0n?"0":null;if(r>0n)try{let a=await s("ETH",{client:e.clientFor(4663),chainId:4663});BigInt(a.usdE18)>0n&&(o=c(r*BigInt(a.usdE18)/10n**18n,18))}catch{}let n={contract:d,amount:r.toString(),eth:c(r,18),usd:o,refundable:!1},i=l(n);return{...t,summary:`${t.summary} ${i}`,preview:{...t.preview,summary:`${t.preview.summary} ${i}`},protocolFee:n}}export{l as a,p as b};
1
+ import{j as s}from"./LFN3OODW.js";import{formatUnits as c}from"viem";function l(e){return`HoodLock creation fee: ${e.eth} ETH (${e.amount} wei; ${e.usd===null?"USD unavailable: no fresh ETH/USD reference":`approximately $${e.usd} USD`}), not refundable after creation. Paid to ${e.contract}; separate from network gas.`}async function p(e,t,d,r){let o=r===0n?"0":null;if(r>0n)try{let a=await s("ETH",{client:e.clientFor(4663),chainId:4663});BigInt(a.usdE18)>0n&&(o=c(r*BigInt(a.usdE18)/10n**18n,18))}catch{}let n={contract:d,amount:r.toString(),eth:c(r,18),usd:o,refundable:!1},i=l(n);return{...t,summary:`${t.summary} ${i}`,preview:{...t.preview,summary:`${t.preview.summary} ${i}`},protocolFee:n}}export{l as a,p as b};
@@ -1 +1 @@
1
- import{j as p}from"./FYTF2QMS.js";import{a as d}from"./XCFA73P2.js";import{a as f}from"./6IM6A5VA.js";import{d as a,i as c}from"./73N3TOJL.js";import{a as m}from"./RETS2ZEK.js";import{a as i}from"./XPFVT2EA.js";import{a as s}from"./5YS5V2LK.js";import{erc20Abi as u,zeroAddress as b}from"viem";function T(r,n,e=256,t=!1){if(typeof r!="string"||!/^[0-9]+$/.test(r))throw new s(`${n} must be a decimal base-unit string.`);let o=m(r);if(!t&&o===0n||o>=1n<<BigInt(e))throw new s(`${n} must be ${t?"a":"a positive"} uint${e}.`);return o}function g(r){return c(r,"Provide a token or contract address.",a)}function E(r){return typeof r=="string"&&["eth",d.toLowerCase()].includes(r.toLowerCase())?b:g(r)}function D(r){let n=r??50;if(typeof n!="number"||!Number.isInteger(n)||n<0||n>=1e4)throw new s("Slippage must be an integer from 0 to 9999 bps.");return n}async function N(r,n,e){if(n===b)return{address:d,symbol:"ETH",decimals:18,chainId:i};let t=r.clientFor(i),[o,w]=await Promise.all([t.readContract({address:n,abi:u,functionName:"symbol",blockNumber:e}),t.readContract({address:n,abi:u,functionName:"decimals",blockNumber:e})]);return{address:n,symbol:p(o,n),decimals:w,chainId:i}}async function S(r,n,e,t){return f(e),{txs:n,preview:await r.preview(n,e),summary:t}}function $(r,n){if(Object.keys(r).some(e=>!n.includes(e)))throw new s(`Provide only ${n.join(", ")}.`)}export{T as a,g as b,E as c,D as d,N as e,S as f,$ as g};
1
+ import{j as p}from"./MEMVFR7Z.js";import{a as d}from"./VJ3W2V3B.js";import{a as f}from"./6IM6A5VA.js";import{d as a,i as c}from"./73N3TOJL.js";import{a as m}from"./RETS2ZEK.js";import{a as i}from"./XPFVT2EA.js";import{a as s}from"./5YS5V2LK.js";import{erc20Abi as u,zeroAddress as b}from"viem";function T(r,n,e=256,t=!1){if(typeof r!="string"||!/^[0-9]+$/.test(r))throw new s(`${n} must be a decimal base-unit string.`);let o=m(r);if(!t&&o===0n||o>=1n<<BigInt(e))throw new s(`${n} must be ${t?"a":"a positive"} uint${e}.`);return o}function g(r){return c(r,"Provide a token or contract address.",a)}function E(r){return typeof r=="string"&&["eth",d.toLowerCase()].includes(r.toLowerCase())?b:g(r)}function D(r){let n=r??50;if(typeof n!="number"||!Number.isInteger(n)||n<0||n>=1e4)throw new s("Slippage must be an integer from 0 to 9999 bps.");return n}async function N(r,n,e){if(n===b)return{address:d,symbol:"ETH",decimals:18,chainId:i};let t=r.clientFor(i),[o,w]=await Promise.all([t.readContract({address:n,abi:u,functionName:"symbol",blockNumber:e}),t.readContract({address:n,abi:u,functionName:"decimals",blockNumber:e})]);return{address:n,symbol:p(o,n),decimals:w,chainId:i}}async function S(r,n,e,t){return f(e),{txs:n,preview:await r.preview(n,e),summary:t}}function $(r,n){if(Object.keys(r).some(e=>!n.includes(e)))throw new s(`Provide only ${n.join(", ")}.`)}export{T as a,g as b,E as c,D as d,N as e,S as f,$ as g};
@@ -1 +1 @@
1
- import{b as s}from"./OJMYESQU.js";import{a as o,c as t}from"./HNMOB76J.js";import{getAddress as i}from"viem";var u=new Set(["priors_status",...s,...t.filter(r=>r.read).map(r=>r.name),"priors_ethos_status","priors_request_borrow","priors_request_repay","priors_request_stock","priors_request_backing","priors_pt_quote","priors_pt_position","priors_stock_quote","priors_savings_liquidity","priors_market_origin","priors_market_pins","priors_capabilities"]),p=new Set(["priors_sign_consent",...t.filter(r=>r.consentRoot).map(r=>r.name)]),d=new Set([...p,"priors_starter_line"]),R=new Set([...t.filter(r=>!r.read).map(r=>r.name),"priors_root_offer","priors_autopay_on","priors_autopay_off","priors_pt_buy","priors_pt_sell","priors_pt_redeem","priors_savings_force_withdraw","priors_stock_swap","priors_market_clear_bid_budget","priors_market_revoke_nft","priors_x_link"]);function S(r){let _=t.find(e=>e.name===r);return _?[o[_.contract],..._.approval==="bid"?[o.bidSpender]:[]]:r==="priors_root_offer"?[o.pool]:r==="priors_autopay_on"||r==="priors_autopay_off"?[o.autopay]:r==="priors_savings_force_withdraw"?[o.savings]:r==="priors_stock_swap"?[i("0xCaf681a66D020601342297493863E78C959E5cb2"),i("0x7Cd4E04E433E69e588728c86A3832753B5F846d4")]:r==="priors_pt_buy"||r==="priors_pt_sell"||r==="priors_pt_redeem"?[i("0x888888888889758F76e7103c6CbF23ABbF58F946")]:r==="priors_market_clear_bid_budget"?[o.bidSpender]:r==="priors_market_revoke_nft"?[o.registry,"0x0000000000000000000000000000000000000000"]:r==="priors_x_link"?[o.registry]:[]}export{u as a,p as b,d as c,R as d,S as e};
1
+ import{b as s}from"./6L6DSMCU.js";import{a as o,c as t}from"./HNMOB76J.js";import{getAddress as i}from"viem";var u=new Set(["priors_status",...s,...t.filter(r=>r.read).map(r=>r.name),"priors_ethos_status","priors_request_borrow","priors_request_repay","priors_request_stock","priors_request_backing","priors_pt_quote","priors_pt_position","priors_stock_quote","priors_savings_liquidity","priors_market_origin","priors_market_pins","priors_capabilities"]),p=new Set(["priors_sign_consent",...t.filter(r=>r.consentRoot).map(r=>r.name)]),d=new Set([...p,"priors_starter_line"]),R=new Set([...t.filter(r=>!r.read).map(r=>r.name),"priors_root_offer","priors_autopay_on","priors_autopay_off","priors_pt_buy","priors_pt_sell","priors_pt_redeem","priors_savings_force_withdraw","priors_stock_swap","priors_market_clear_bid_budget","priors_market_revoke_nft","priors_x_link"]);function S(r){let _=t.find(e=>e.name===r);return _?[o[_.contract],..._.approval==="bid"?[o.bidSpender]:[]]:r==="priors_root_offer"?[o.pool]:r==="priors_autopay_on"||r==="priors_autopay_off"?[o.autopay]:r==="priors_savings_force_withdraw"?[o.savings]:r==="priors_stock_swap"?[i("0xCaf681a66D020601342297493863E78C959E5cb2"),i("0x7Cd4E04E433E69e588728c86A3832753B5F846d4")]:r==="priors_pt_buy"||r==="priors_pt_sell"||r==="priors_pt_redeem"?[i("0x888888888889758F76e7103c6CbF23ABbF58F946")]:r==="priors_market_clear_bid_budget"?[o.bidSpender]:r==="priors_market_revoke_nft"?[o.registry,"0x0000000000000000000000000000000000000000"]:r==="priors_x_link"?[o.registry]:[]}export{u as a,p as b,d as c,R as d,S as e};
@@ -1 +1 @@
1
- import{b as q}from"./EHVPRQHS.js";import{b as S}from"./HZUWK5B2.js";import{b as le}from"./AXYOJBX6.js";import{a as _}from"./6IM6A5VA.js";import{g as B,i as ue}from"./73N3TOJL.js";import{a as H}from"./RETS2ZEK.js";import{a as u,i as N}from"./XPFVT2EA.js";import{a as c}from"./5YS5V2LK.js";import{a as ce}from"./JXOEJPJ4.js";import{encodeFunctionData as z,erc20Abi as me,getAddress as m,isAddress as he,parseAbi as U,zeroAddress as ke}from"viem";var T=m(N[u].hoodlock.locker.address),C=m(N[u].hoodlock.burner.address),v=m(N[u].hoodlock.liquidityLocker.address),j=m(N[u].uniswap.v3_position_manager.address),K=m(N[u].uniswap.v4_position_manager.address),qe="0x000000000000000000000000000000000000dEaD",Ae=3153600000n,Te=1000000000000n,fe=65535,D=U(["function fee() view returns (uint256)","function lock(address token, uint256 amount, uint256 unlockTime) payable returns (uint256 lockId)","function getLock(uint256 lockId) view returns (address owner, address token, uint256 amount, uint256 unlockTime, bool withdrawn)","function locksByOwner(address owner) view returns (uint256[])","function locksByToken(address token) view returns (uint256[])"]),ee=U(["function fee() view returns (uint256)","function burn(address token, uint256 amount) payable returns (uint256 burnId)","function DEAD() view returns (address)","function getBurn(uint256 burnId) view returns (address burner, address token, uint256 amount, uint256 timestamp)","function totalBurnedOf(address token) view returns (uint256)"]),O=U(["function fixedFee() view returns (uint256)","function collectFeeBps() view returns (uint16)","function paused() view returns (bool)","function lock(address manager, uint256 tokenId, uint256 unlockTime, address feeRecipient, bool acceptUnverifiedHook, uint16 maxCollectFeeBps) payable returns (uint256 lockId)","function lockIdOf(address manager, uint256 tokenId) view returns (uint256)","function getLock(uint256 lockId) view returns (address owner, uint40 unlockTime, uint16 collectFeeBps, bool isV4, bool hookVerified, bool withdrawn, address feeRecipient, address token0, address token1, uint256 tokenId)","function locksOf(address owner) view returns (uint256[])"]),ye=U(["function approve(address to, uint256 tokenId)"]);function $e(e,o,t){let a=o.trim();if(a.startsWith("-")){let k=a.slice(1),i=e(k,t);return i==="0"?"0":`-${i}`}return e(a,t)}function pe(e,o){return o.length===0?"no ERC-20 transfer deltas":o.map(t=>`${$e(e.formatAmount,t.amount,t.token.decimals)} ${t.token.symbol}`).join(", ")}function E(e,o="token"){if(typeof e!="string"||!e.trim())throw new c(`Provide a valid ${o} contract address.`);if(!he(e,{strict:!1}))throw new c(`Identify ${o} by chain and contract address, not by symbol.`);return m(e)}async function W(e,o){try{return await o()}catch(t){throw new c(e.plainError(t))}}function we(e){if(typeof e!="string")throw new c("Amount must be a non-negative integer string in base units.");let o=H(e);if(o<=0n)throw new c("Amount must be greater than zero.");return o}async function ge(e){let o=await e.getBlock();if(!o||typeof o.timestamp!="bigint")throw new c("Could not read the current chain timestamp. Please try again.");return o.timestamp}function ve(e,o){if(typeof e!="string"||!/^\d+$/.test(e.trim()))throw new c("unlockTime must be a non-negative integer string in Unix seconds.");let t=BigInt(e.trim());if(t>=Te)throw new c("unlockTime appears to be in milliseconds; provide Unix seconds at most 100 years (3153600000 seconds) in the future.");if(t<=o)throw new c(`unlockTime (${t}) must be in the future (greater than current timestamp ${o}).`);let a=o+Ae;if(t>a)throw new c(`unlockTime (${t}) exceeds the 100-year maximum lock duration (3153600000 seconds; max ${a}).`);return t}async function oe(e,o,t=u){let a=m(o),[k,i]=await Promise.all([e.readContract({address:a,abi:me,functionName:"symbol"}),e.readContract({address:a,abi:me,functionName:"decimals"})]);return{address:a,symbol:ce(String(k)),decimals:Number(i),chainId:t}}function Se(e,o){if(e==null)return o;let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/.test(e.trim())?Number(e.trim()):NaN;if(!Number.isInteger(t)||t<0||t>fe)throw new c("maxCollectFeeBps must be an integer between 0 and 65535.");if(t<o)throw new c(`Live collectFeeBps (${o}) exceeds maxCollectFeeBps (${t}): collect fee changed.`);return Math.min(t,o)}function Le(e){return e.tokenId!==void 0||e.manager!==void 0||e.feeRecipient!==void 0||e.maxCollectFeeBps!==void 0||e.acceptUnverifiedHook!==void 0||e.kind==="v3"||e.kind==="lp"||e.kind==="v4"||e.version==="v3"||e.version==="v4"}async function xe(e,o,t){_(t);let a=m(t),k=o.kind==="v4"||o.version==="v4",i=o.manager!==void 0?E(o.manager,"manager"):k?K:j,g=i===K;if(i!==j&&!g)throw new c(`Unsupported position manager ${i}; use the configured Uniswap v3 or v4 manager.`);if(k&&!g||g&&(o.kind==="v3"||o.version==="v3"))throw new c("The requested version disagrees with the position manager.");if(o.acceptUnverifiedHook!==void 0&&typeof o.acceptUnverifiedHook!="boolean")throw new c("acceptUnverifiedHook must be a boolean.");let b=o.acceptUnverifiedHook===!0;if(!g&&b)throw new c("Uniswap v3 has no hooks; omit acceptUnverifiedHook.");let s=g?"v4":"v3";if(typeof o.tokenId!="string")throw new c("Provide an NFT tokenId as a decimal string.");let f=String(o.tokenId).trim(),d=H(f),l=ue(o.feeRecipient,"Provide an explicit feeRecipient address for LP position locks."),p=e.clientFor(u),[x,I,h]=await Promise.all([ge(p),p.readContract({address:v,abi:O,functionName:"fixedFee"}),p.readContract({address:v,abi:O,functionName:"collectFeeBps"})]),y,$=!0;if(g){let P=U(["function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey, uint256 info)","function getPositionLiquidity(uint256 tokenId) view returns (uint128)","function ownerOf(uint256 tokenId) view returns (address)"]),[Y,J,M]=await Promise.all([p.readContract({address:i,abi:P,functionName:"getPoolAndPositionInfo",args:[d]}),p.readContract({address:i,abi:P,functionName:"getPositionLiquidity",args:[d]}),p.readContract({address:i,abi:P,functionName:"ownerOf",args:[d]})]);if(m(M)!==a)throw new c("This wallet does not own that v4 position NFT.");if(J<=0n)throw new c("The v4 position has no liquidity to lock.");if(y=m(Y[0].hooks),$=y===ke||await p.readContract({address:v,abi:U(["function hookAllowed(address) view returns (bool)"]),functionName:"hookAllowed",args:[y]}),!$&&!b)throw new c(`Unverified v4 hook ${y}; review its risks and explicitly set acceptUnverifiedHook: true to proceed.`)}let A=ve(o.unlockTime,x),n=BigInt(I),r=Number(h);if(!Number.isInteger(r)||r<0||r>fe)throw new c(`Invalid on-chain collectFeeBps (${String(h)}).`);if(o.maxFee!==void 0){let P=H(String(o.maxFee));if(n>P)throw new c(`Live fixedFee (${n}) exceeds maxFee (${P}).`)}let w=Se(o.maxCollectFeeBps,r),L=(r/100).toString(),R=e.unsignedTx({to:i,data:z({abi:ye,functionName:"approve",args:[v,d]}),value:"0",chainId:u,description:`Approve Uniswap ${s} position NFT #${d} on ${i} for HoodLock LiquidityLocker ${v}.`}),F=e.unsignedTx({to:v,data:z({abi:O,functionName:"lock",args:[i,d,A,l,b,w]}),value:n.toString(),chainId:u,description:`Lock Uniswap ${s} NFT #${d} in HoodLock LiquidityLocker (${v}) until ${A} with feeRecipient ${l}, upfront fixedFee ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei), and ongoing collect fee ${r} bps (${L}% of collected LP fees, frozen per lock).`}),X=[R,F],V=await e.preview(X,a),Q=`Approve and lock Uniswap ${s} NFT #${d} (manager ${i}) in HoodLock LiquidityLocker ${v} until Unix ${A}. Upfront fixedFee: ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei). Ongoing LP fee share: ${r} bps (${L}% of collected LP fees, frozen per lock; maxCollectFeeBps=${w}) with feeRecipient ${l}. V4 hook: ${y??"none"}, reviewed: ${$}; acceptUnverifiedHook=${b}.`;return q(e,{txs:V.txs,summary:Q,preview:V,kind:s,contract:v,manager:i,tokenId:d.toString(),unlockTime:A.toString(),feeRecipient:l,acceptUnverifiedHook:b,collectFeeBps:r,maxCollectFeeBps:w,fixedFee:{token:S,amount:n.toString()}},v,n)}async function Ie(e,o,t){_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(u),[g,b,s]=await Promise.all([ge(i),i.readContract({address:T,abi:D,functionName:"fee"}),oe(i,k,u)]),f=we(o.amount),d=ve(o.unlockTime,g),l=BigInt(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(l>A)throw new c(`Live lock fee (${l}) exceeds maxFee (${A}).`)}let p=e.approval(s.address,T,f.toString(),u),x=e.unsignedTx({to:T,data:z({abi:D,functionName:"lock",args:[s.address,f,d]}),value:l.toString(),chainId:u,description:`Lock ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) in HoodLock Locker ${T} until ${d} with exact fee ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei).`}),I=[p,x],h=await e.preview(I,a),y=pe(e,h.changes),$=`Approve and lock ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) in HoodLock Locker ${T} until Unix ${d}. Exact fee: ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei). Preview changes: ${y}.`;return q(e,{txs:h.txs,summary:$,preview:h,kind:"token",contract:T,token:s,amount:f.toString(),unlockTime:d.toString(),fee:{token:S,amount:l.toString()}},T,l)}function Pe(e){return{name:"hoodlock_lock",inputSchema:{type:"object",properties:{kind:{type:"string",enum:["token","v2","v3","v4"],description:"Lock mode: token/v2 LP via Locker, or Uniswap v3/v4 NFT via LiquidityLocker."},token:{type:"string",description:"ERC-20 token or v2 LP token contract address on chain 4663 (for token/v2 locks)."},amount:{type:"string",description:"Token amount as an integer string in base units (for token/v2 locks)."},manager:{type:"string",description:"Configured Uniswap v3 or v4 position manager; inferred from kind when omitted."},tokenId:{type:"string",description:"Uniswap NFT position tokenId as a decimal string."},feeRecipient:{type:"string",description:"Explicit recipient address for collected LP fees during a position lock."},acceptUnverifiedHook:{type:"boolean",description:"Explicit v4 unreviewed-hook consent; default false. A reviewed hook is not a safety guarantee."},maxFee:{type:"string",description:"Maximum upfront ETH fee in wei; the exact live fee is sent."},maxCollectFeeBps:{type:"number",description:"Maximum acceptable ongoing LP collect fee in bps (uint16, must be >= live collectFeeBps)."},unlockTime:{type:"string",description:"Unlock timestamp in Unix seconds (must be > now and <= now + 100 years)."}},required:["unlockTime"],additionalProperties:!1},async execute(o,t){return W(e,async()=>Le(o)?xe(e,o,t):Ie(e,o,t))}}}function Ce(e){return{name:"hoodlock_burn",inputSchema:{type:"object",properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663 to send to the dead address via HoodLock Burner."},amount:{type:"string",description:"Amount to burn as an integer string in base units."}},required:["token","amount"],additionalProperties:!1},async execute(o,t){return W(e,async()=>{_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(u),[g,b,s]=await Promise.all([i.readContract({address:C,abi:ee,functionName:"fee"}),i.readContract({address:C,abi:ee,functionName:"DEAD"}),oe(i,k,u)]),f=we(o.amount),d=BigInt(g),l=m(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(d>A)throw new c(`Live burn fee (${d}) exceeds maxFee (${A}).`)}let p=e.approval(s.address,C,f.toString(),u),x=e.unsignedTx({to:C,data:z({abi:ee,functionName:"burn",args:[s.address,f]}),value:d.toString(),chainId:u,description:`Send ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${C} (totalSupply is unchanged) with exact fee ${e.formatAmount(d.toString(),S.decimals)} ETH (${d} wei).`}),I=[p,x],h=await e.preview(I,a),y=pe(e,h.changes),$=`Approve and send ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${C}. Note: tokens are transferred to ${l} and totalSupply is unchanged. Exact fee: ${e.formatAmount(d.toString(),S.decimals)} ETH (${d} wei). Preview changes: ${y}.`;return q(e,{txs:h.txs,summary:$,preview:h,contract:C,deadAddress:l,token:s,amount:f.toString(),fee:{token:S,amount:d.toString()},totalSupplyReduced:!1},C,d)})}}}async function be(e,o,t){_(o);let a=m(o),k=t?E(t,"token"):void 0,i=e.clientFor(u),g=[],b=new Set,s=n=>{for(let r of n){let w=r.toString();b.has(w)||(b.add(w),g.push(r))}};if(k){let[n,r]=await Promise.all([i.readContract({address:T,abi:D,functionName:"locksByToken",args:[k]}),i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]})]);s(n),s(r)}else{let n=await i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]});s(n)}let d=(await Promise.all(g.map(async n=>{let r=await i.readContract({address:T,abi:D,functionName:"getLock",args:[n]});return{id:n,owner:m(r[0]),token:m(r[1]),amount:BigInt(r[2]),unlockTime:BigInt(r[3]),withdrawn:!!r[4]}}))).filter(n=>!n.withdrawn&&n.amount>0n&&B(n.owner,a)&&(!k||B(n.token,k))),l=new Map,p=async n=>{let r=n.toLowerCase(),w=l.get(r);if(w)return w;let L=n===ke?S:await oe(i,n,u);return l.set(r,L),L},x=[],I=[];for(let n of d){let r=await p(n.token),w=n.amount.toString(),L=n.unlockTime.toString(),R={token:r,amount:w};x.push({lockId:n.id.toString(),kind:"token",contract:T,chainId:u,owner:n.owner,token:r,amount:w,asset:R,unlockTime:L,withdrawn:!1}),I.push({module:"hoodlock",id:`lock:${n.id.toString()}`,chainId:u,assets:[R],description:`HoodLock token lock #${n.id} of ${e.formatAmount(w,r.decimals)} ${r.symbol} (${r.address}) until Unix ${L}.`})}let h=await i.readContract({address:v,abi:O,functionName:"locksOf",args:[a]}),y=[...new Set(h.map(n=>n.toString()))].map(n=>BigInt(n)),$=[];for(let n of y){let r=await i.readContract({address:v,abi:O,functionName:"getLock",args:[n]}),[w,L,R,F,X,V,Q,P,Y,J]=r,M=m(w);if(V||!B(M,a))continue;let ne=m(P),te=m(Y);if(k&&!B(ne,k)&&!B(te,k))continue;let[ie,re]=await Promise.all([p(ne),p(te)]),se=m(Q),ae=Number(R),de=BigInt(L).toString(),Z=BigInt(J).toString();$.push({lockId:n.toString(),kind:F?"v4":"v3",contract:v,manager:F?K:j,chainId:u,owner:M,tokenId:Z,unlockTime:de,collectFeeBps:ae,feeRecipient:se,hookVerified:!!X,token0:ie,token1:re,withdrawn:!1}),I.push({module:"hoodlock",id:`lp-lock:${n.toString()}`,chainId:u,assets:[{token:{address:F?K:j,symbol:`UNI-${F?"V4":"V3"} #${Z}`,decimals:0,chainId:u},amount:"1"}],description:`HoodLock Uniswap ${F?"v4":"v3"} LP lock #${n} (NFT #${Z}, ${ie.symbol}/${re.symbol}, feeRecipient ${se}, collectFeeBps ${ae}) until Unix ${de}. One NFT held in LiquidityLocker custody for ${M}. Underlying token amounts are not valued.`})}let A=`Found ${x.length} active token lock(s) and ${$.length} active Uniswap v3/v4 LP lock(s) for ${a}.`;return{locks:x,lpLocks:$,positions:I,summary:A}}function Fe(e){return{name:"hoodlock_list_locks",inputSchema:{type:"object",properties:{owner:{type:"string",description:"Optional owner wallet address to query (defaults to the authenticated wallet)."},token:{type:"string",description:"Optional ERC-20 or LP token address to filter active locks owned by the wallet."}},additionalProperties:!1},async execute(o,t){let a=o.owner!==void 0?E(o.owner,"owner"):m(t),k=o.token!==void 0?E(o.token,"token"):void 0;return W(e,()=>be(e,a,k))}}}function Re(e){return async o=>(await W(e,()=>be(e,o))).positions}var G=e=>({tools:[Pe(e),Ce(e),Fe(e)],positions:Re(e)}),ze=G,je=G,Ke=e=>le("hoodlock",[G(e)]),We=G;export{T as a,C as b,v as c,j as d,K as e,qe as f,Ae as g,$e as h,Pe as i,Ce as j,Fe as k,Re as l,G as m,ze as n,je as o,Ke as p,We as q};
1
+ import{b as q}from"./I7NUTSSX.js";import{b as S}from"./T3MGNKA6.js";import{b as le}from"./AXYOJBX6.js";import{a as _}from"./6IM6A5VA.js";import{g as B,i as ue}from"./73N3TOJL.js";import{a as H}from"./RETS2ZEK.js";import{a as u,i as N}from"./XPFVT2EA.js";import{a as c}from"./5YS5V2LK.js";import{a as ce}from"./JXOEJPJ4.js";import{encodeFunctionData as z,erc20Abi as me,getAddress as m,isAddress as he,parseAbi as U,zeroAddress as ke}from"viem";var T=m(N[u].hoodlock.locker.address),C=m(N[u].hoodlock.burner.address),v=m(N[u].hoodlock.liquidityLocker.address),j=m(N[u].uniswap.v3_position_manager.address),K=m(N[u].uniswap.v4_position_manager.address),qe="0x000000000000000000000000000000000000dEaD",Ae=3153600000n,Te=1000000000000n,fe=65535,D=U(["function fee() view returns (uint256)","function lock(address token, uint256 amount, uint256 unlockTime) payable returns (uint256 lockId)","function getLock(uint256 lockId) view returns (address owner, address token, uint256 amount, uint256 unlockTime, bool withdrawn)","function locksByOwner(address owner) view returns (uint256[])","function locksByToken(address token) view returns (uint256[])"]),ee=U(["function fee() view returns (uint256)","function burn(address token, uint256 amount) payable returns (uint256 burnId)","function DEAD() view returns (address)","function getBurn(uint256 burnId) view returns (address burner, address token, uint256 amount, uint256 timestamp)","function totalBurnedOf(address token) view returns (uint256)"]),O=U(["function fixedFee() view returns (uint256)","function collectFeeBps() view returns (uint16)","function paused() view returns (bool)","function lock(address manager, uint256 tokenId, uint256 unlockTime, address feeRecipient, bool acceptUnverifiedHook, uint16 maxCollectFeeBps) payable returns (uint256 lockId)","function lockIdOf(address manager, uint256 tokenId) view returns (uint256)","function getLock(uint256 lockId) view returns (address owner, uint40 unlockTime, uint16 collectFeeBps, bool isV4, bool hookVerified, bool withdrawn, address feeRecipient, address token0, address token1, uint256 tokenId)","function locksOf(address owner) view returns (uint256[])"]),ye=U(["function approve(address to, uint256 tokenId)"]);function $e(e,o,t){let a=o.trim();if(a.startsWith("-")){let k=a.slice(1),i=e(k,t);return i==="0"?"0":`-${i}`}return e(a,t)}function pe(e,o){return o.length===0?"no ERC-20 transfer deltas":o.map(t=>`${$e(e.formatAmount,t.amount,t.token.decimals)} ${t.token.symbol}`).join(", ")}function E(e,o="token"){if(typeof e!="string"||!e.trim())throw new c(`Provide a valid ${o} contract address.`);if(!he(e,{strict:!1}))throw new c(`Identify ${o} by chain and contract address, not by symbol.`);return m(e)}async function W(e,o){try{return await o()}catch(t){throw new c(e.plainError(t))}}function we(e){if(typeof e!="string")throw new c("Amount must be a non-negative integer string in base units.");let o=H(e);if(o<=0n)throw new c("Amount must be greater than zero.");return o}async function ge(e){let o=await e.getBlock();if(!o||typeof o.timestamp!="bigint")throw new c("Could not read the current chain timestamp. Please try again.");return o.timestamp}function ve(e,o){if(typeof e!="string"||!/^\d+$/.test(e.trim()))throw new c("unlockTime must be a non-negative integer string in Unix seconds.");let t=BigInt(e.trim());if(t>=Te)throw new c("unlockTime appears to be in milliseconds; provide Unix seconds at most 100 years (3153600000 seconds) in the future.");if(t<=o)throw new c(`unlockTime (${t}) must be in the future (greater than current timestamp ${o}).`);let a=o+Ae;if(t>a)throw new c(`unlockTime (${t}) exceeds the 100-year maximum lock duration (3153600000 seconds; max ${a}).`);return t}async function oe(e,o,t=u){let a=m(o),[k,i]=await Promise.all([e.readContract({address:a,abi:me,functionName:"symbol"}),e.readContract({address:a,abi:me,functionName:"decimals"})]);return{address:a,symbol:ce(String(k)),decimals:Number(i),chainId:t}}function Se(e,o){if(e==null)return o;let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/.test(e.trim())?Number(e.trim()):NaN;if(!Number.isInteger(t)||t<0||t>fe)throw new c("maxCollectFeeBps must be an integer between 0 and 65535.");if(t<o)throw new c(`Live collectFeeBps (${o}) exceeds maxCollectFeeBps (${t}): collect fee changed.`);return Math.min(t,o)}function Le(e){return e.tokenId!==void 0||e.manager!==void 0||e.feeRecipient!==void 0||e.maxCollectFeeBps!==void 0||e.acceptUnverifiedHook!==void 0||e.kind==="v3"||e.kind==="lp"||e.kind==="v4"||e.version==="v3"||e.version==="v4"}async function xe(e,o,t){_(t);let a=m(t),k=o.kind==="v4"||o.version==="v4",i=o.manager!==void 0?E(o.manager,"manager"):k?K:j,g=i===K;if(i!==j&&!g)throw new c(`Unsupported position manager ${i}; use the configured Uniswap v3 or v4 manager.`);if(k&&!g||g&&(o.kind==="v3"||o.version==="v3"))throw new c("The requested version disagrees with the position manager.");if(o.acceptUnverifiedHook!==void 0&&typeof o.acceptUnverifiedHook!="boolean")throw new c("acceptUnverifiedHook must be a boolean.");let b=o.acceptUnverifiedHook===!0;if(!g&&b)throw new c("Uniswap v3 has no hooks; omit acceptUnverifiedHook.");let s=g?"v4":"v3";if(typeof o.tokenId!="string")throw new c("Provide an NFT tokenId as a decimal string.");let f=String(o.tokenId).trim(),d=H(f),l=ue(o.feeRecipient,"Provide an explicit feeRecipient address for LP position locks."),p=e.clientFor(u),[x,I,h]=await Promise.all([ge(p),p.readContract({address:v,abi:O,functionName:"fixedFee"}),p.readContract({address:v,abi:O,functionName:"collectFeeBps"})]),y,$=!0;if(g){let P=U(["function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey, uint256 info)","function getPositionLiquidity(uint256 tokenId) view returns (uint128)","function ownerOf(uint256 tokenId) view returns (address)"]),[Y,J,M]=await Promise.all([p.readContract({address:i,abi:P,functionName:"getPoolAndPositionInfo",args:[d]}),p.readContract({address:i,abi:P,functionName:"getPositionLiquidity",args:[d]}),p.readContract({address:i,abi:P,functionName:"ownerOf",args:[d]})]);if(m(M)!==a)throw new c("This wallet does not own that v4 position NFT.");if(J<=0n)throw new c("The v4 position has no liquidity to lock.");if(y=m(Y[0].hooks),$=y===ke||await p.readContract({address:v,abi:U(["function hookAllowed(address) view returns (bool)"]),functionName:"hookAllowed",args:[y]}),!$&&!b)throw new c(`Unverified v4 hook ${y}; review its risks and explicitly set acceptUnverifiedHook: true to proceed.`)}let A=ve(o.unlockTime,x),n=BigInt(I),r=Number(h);if(!Number.isInteger(r)||r<0||r>fe)throw new c(`Invalid on-chain collectFeeBps (${String(h)}).`);if(o.maxFee!==void 0){let P=H(String(o.maxFee));if(n>P)throw new c(`Live fixedFee (${n}) exceeds maxFee (${P}).`)}let w=Se(o.maxCollectFeeBps,r),L=(r/100).toString(),R=e.unsignedTx({to:i,data:z({abi:ye,functionName:"approve",args:[v,d]}),value:"0",chainId:u,description:`Approve Uniswap ${s} position NFT #${d} on ${i} for HoodLock LiquidityLocker ${v}.`}),F=e.unsignedTx({to:v,data:z({abi:O,functionName:"lock",args:[i,d,A,l,b,w]}),value:n.toString(),chainId:u,description:`Lock Uniswap ${s} NFT #${d} in HoodLock LiquidityLocker (${v}) until ${A} with feeRecipient ${l}, upfront fixedFee ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei), and ongoing collect fee ${r} bps (${L}% of collected LP fees, frozen per lock).`}),X=[R,F],V=await e.preview(X,a),Q=`Approve and lock Uniswap ${s} NFT #${d} (manager ${i}) in HoodLock LiquidityLocker ${v} until Unix ${A}. Upfront fixedFee: ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei). Ongoing LP fee share: ${r} bps (${L}% of collected LP fees, frozen per lock; maxCollectFeeBps=${w}) with feeRecipient ${l}. V4 hook: ${y??"none"}, reviewed: ${$}; acceptUnverifiedHook=${b}.`;return q(e,{txs:V.txs,summary:Q,preview:V,kind:s,contract:v,manager:i,tokenId:d.toString(),unlockTime:A.toString(),feeRecipient:l,acceptUnverifiedHook:b,collectFeeBps:r,maxCollectFeeBps:w,fixedFee:{token:S,amount:n.toString()}},v,n)}async function Ie(e,o,t){_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(u),[g,b,s]=await Promise.all([ge(i),i.readContract({address:T,abi:D,functionName:"fee"}),oe(i,k,u)]),f=we(o.amount),d=ve(o.unlockTime,g),l=BigInt(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(l>A)throw new c(`Live lock fee (${l}) exceeds maxFee (${A}).`)}let p=e.approval(s.address,T,f.toString(),u),x=e.unsignedTx({to:T,data:z({abi:D,functionName:"lock",args:[s.address,f,d]}),value:l.toString(),chainId:u,description:`Lock ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) in HoodLock Locker ${T} until ${d} with exact fee ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei).`}),I=[p,x],h=await e.preview(I,a),y=pe(e,h.changes),$=`Approve and lock ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) in HoodLock Locker ${T} until Unix ${d}. Exact fee: ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei). Preview changes: ${y}.`;return q(e,{txs:h.txs,summary:$,preview:h,kind:"token",contract:T,token:s,amount:f.toString(),unlockTime:d.toString(),fee:{token:S,amount:l.toString()}},T,l)}function Pe(e){return{name:"hoodlock_lock",inputSchema:{type:"object",properties:{kind:{type:"string",enum:["token","v2","v3","v4"],description:"Lock mode: token/v2 LP via Locker, or Uniswap v3/v4 NFT via LiquidityLocker."},token:{type:"string",description:"ERC-20 token or v2 LP token contract address on chain 4663 (for token/v2 locks)."},amount:{type:"string",description:"Token amount as an integer string in base units (for token/v2 locks)."},manager:{type:"string",description:"Configured Uniswap v3 or v4 position manager; inferred from kind when omitted."},tokenId:{type:"string",description:"Uniswap NFT position tokenId as a decimal string."},feeRecipient:{type:"string",description:"Explicit recipient address for collected LP fees during a position lock."},acceptUnverifiedHook:{type:"boolean",description:"Explicit v4 unreviewed-hook consent; default false. A reviewed hook is not a safety guarantee."},maxFee:{type:"string",description:"Maximum upfront ETH fee in wei; the exact live fee is sent."},maxCollectFeeBps:{type:"number",description:"Maximum acceptable ongoing LP collect fee in bps (uint16, must be >= live collectFeeBps)."},unlockTime:{type:"string",description:"Unlock timestamp in Unix seconds (must be > now and <= now + 100 years)."}},required:["unlockTime"],additionalProperties:!1},async execute(o,t){return W(e,async()=>Le(o)?xe(e,o,t):Ie(e,o,t))}}}function Ce(e){return{name:"hoodlock_burn",inputSchema:{type:"object",properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663 to send to the dead address via HoodLock Burner."},amount:{type:"string",description:"Amount to burn as an integer string in base units."}},required:["token","amount"],additionalProperties:!1},async execute(o,t){return W(e,async()=>{_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(u),[g,b,s]=await Promise.all([i.readContract({address:C,abi:ee,functionName:"fee"}),i.readContract({address:C,abi:ee,functionName:"DEAD"}),oe(i,k,u)]),f=we(o.amount),d=BigInt(g),l=m(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(d>A)throw new c(`Live burn fee (${d}) exceeds maxFee (${A}).`)}let p=e.approval(s.address,C,f.toString(),u),x=e.unsignedTx({to:C,data:z({abi:ee,functionName:"burn",args:[s.address,f]}),value:d.toString(),chainId:u,description:`Send ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${C} (totalSupply is unchanged) with exact fee ${e.formatAmount(d.toString(),S.decimals)} ETH (${d} wei).`}),I=[p,x],h=await e.preview(I,a),y=pe(e,h.changes),$=`Approve and send ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${C}. Note: tokens are transferred to ${l} and totalSupply is unchanged. Exact fee: ${e.formatAmount(d.toString(),S.decimals)} ETH (${d} wei). Preview changes: ${y}.`;return q(e,{txs:h.txs,summary:$,preview:h,contract:C,deadAddress:l,token:s,amount:f.toString(),fee:{token:S,amount:d.toString()},totalSupplyReduced:!1},C,d)})}}}async function be(e,o,t){_(o);let a=m(o),k=t?E(t,"token"):void 0,i=e.clientFor(u),g=[],b=new Set,s=n=>{for(let r of n){let w=r.toString();b.has(w)||(b.add(w),g.push(r))}};if(k){let[n,r]=await Promise.all([i.readContract({address:T,abi:D,functionName:"locksByToken",args:[k]}),i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]})]);s(n),s(r)}else{let n=await i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]});s(n)}let d=(await Promise.all(g.map(async n=>{let r=await i.readContract({address:T,abi:D,functionName:"getLock",args:[n]});return{id:n,owner:m(r[0]),token:m(r[1]),amount:BigInt(r[2]),unlockTime:BigInt(r[3]),withdrawn:!!r[4]}}))).filter(n=>!n.withdrawn&&n.amount>0n&&B(n.owner,a)&&(!k||B(n.token,k))),l=new Map,p=async n=>{let r=n.toLowerCase(),w=l.get(r);if(w)return w;let L=n===ke?S:await oe(i,n,u);return l.set(r,L),L},x=[],I=[];for(let n of d){let r=await p(n.token),w=n.amount.toString(),L=n.unlockTime.toString(),R={token:r,amount:w};x.push({lockId:n.id.toString(),kind:"token",contract:T,chainId:u,owner:n.owner,token:r,amount:w,asset:R,unlockTime:L,withdrawn:!1}),I.push({module:"hoodlock",id:`lock:${n.id.toString()}`,chainId:u,assets:[R],description:`HoodLock token lock #${n.id} of ${e.formatAmount(w,r.decimals)} ${r.symbol} (${r.address}) until Unix ${L}.`})}let h=await i.readContract({address:v,abi:O,functionName:"locksOf",args:[a]}),y=[...new Set(h.map(n=>n.toString()))].map(n=>BigInt(n)),$=[];for(let n of y){let r=await i.readContract({address:v,abi:O,functionName:"getLock",args:[n]}),[w,L,R,F,X,V,Q,P,Y,J]=r,M=m(w);if(V||!B(M,a))continue;let ne=m(P),te=m(Y);if(k&&!B(ne,k)&&!B(te,k))continue;let[ie,re]=await Promise.all([p(ne),p(te)]),se=m(Q),ae=Number(R),de=BigInt(L).toString(),Z=BigInt(J).toString();$.push({lockId:n.toString(),kind:F?"v4":"v3",contract:v,manager:F?K:j,chainId:u,owner:M,tokenId:Z,unlockTime:de,collectFeeBps:ae,feeRecipient:se,hookVerified:!!X,token0:ie,token1:re,withdrawn:!1}),I.push({module:"hoodlock",id:`lp-lock:${n.toString()}`,chainId:u,assets:[{token:{address:F?K:j,symbol:`UNI-${F?"V4":"V3"} #${Z}`,decimals:0,chainId:u},amount:"1"}],description:`HoodLock Uniswap ${F?"v4":"v3"} LP lock #${n} (NFT #${Z}, ${ie.symbol}/${re.symbol}, feeRecipient ${se}, collectFeeBps ${ae}) until Unix ${de}. One NFT held in LiquidityLocker custody for ${M}. Underlying token amounts are not valued.`})}let A=`Found ${x.length} active token lock(s) and ${$.length} active Uniswap v3/v4 LP lock(s) for ${a}.`;return{locks:x,lpLocks:$,positions:I,summary:A}}function Fe(e){return{name:"hoodlock_list_locks",inputSchema:{type:"object",properties:{owner:{type:"string",description:"Optional owner wallet address to query (defaults to the authenticated wallet)."},token:{type:"string",description:"Optional ERC-20 or LP token address to filter active locks owned by the wallet."}},additionalProperties:!1},async execute(o,t){let a=o.owner!==void 0?E(o.owner,"owner"):m(t),k=o.token!==void 0?E(o.token,"token"):void 0;return W(e,()=>be(e,a,k))}}}function Re(e){return async o=>(await W(e,()=>be(e,o))).positions}var G=e=>({tools:[Pe(e),Ce(e),Fe(e)],positions:Re(e)}),ze=G,je=G,Ke=e=>le("hoodlock",[G(e)]),We=G;export{T as a,C as b,v as c,j as d,K as e,qe as f,Ae as g,$e as h,Pe as i,Ce as j,Fe as k,Re as l,G as m,ze as n,je as o,Ke as p,We as q};
@@ -1 +1 @@
1
- import{c as Re,d as je,e as qe,f as be,i as Le,j as ze}from"./FYTF2QMS.js";import{i as ue}from"./E7ASOYQI.js";import{b as Ie,o as Ce}from"./EAEQOS7Y.js";import{a as de}from"./XCFA73P2.js";import{a as $,b as Oe}from"./6IM6A5VA.js";import{a as L}from"./UWOFA6GV.js";import{a as D}from"./RETS2ZEK.js";import{a as f,d as Xe,i as ee,j as Be}from"./XPFVT2EA.js";import{a as o,b as He,d as oe}from"./5YS5V2LK.js";import{encodeAbiParameters as A,encodeFunctionData as re,erc20Abi as We,getAddress as y,isAddress as An,keccak256 as xn,pad as Sn,parseAbi as Ae,parseAbiParameters as j,toEventSelector as In,toHex as Ge}from"viem";var Cn=y(ee[4663].uniswap.v4_pool_manager.address),T=y(ee[4663].uniswap.v4_position_manager.address),fe=y(ee[4663].uniswap.v4_state_view.address),_e=y(ee[4663].uniswap.permit2.address),at=y(ee[4663].ponsTrade.universal_router.address),se=y(ee[4663].uniswap.WETH.address),_=y(Be),g="0x0000000000000000000000000000000000000000",De=8388608,Ee=-887272,Pe=887272,pn=(1n<<48n)-1n,ne=(1n<<128n)-1n,qn=(1n<<160n)-1n,pe=1n<<96n,Ze=1800n,Ln="0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",Ke=[{poolId:"0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",key:{currency0:g,currency1:_,fee:8388608,tickSpacing:10,hooks:y("0x06a889870c8f83640d6816319f72e2aa579b6080")},liquidity:"5532026605872066941",sqrtPriceX96:"3839897026469220985301794",tick:-198703,protocolFee:0,lpFee:0},{poolId:"0x387bf619da4d3fb62bb276482693dba1b9b3520f573cabdfe033384a24125982",key:{currency0:g,currency1:_,fee:500,tickSpacing:10,hooks:g},liquidity:"225820987949255613",sqrtPriceX96:"3840577772610961024680304",tick:-198700,protocolFee:512125,lpFee:500},{poolId:"0x54f7883914619af9105355bf83ed678bcf9f63560218ac61c9963b9503d0ba32",key:{currency0:g,currency1:_,fee:460,tickSpacing:9,hooks:g},liquidity:"85654324417347171",sqrtPriceX96:"3840419018843648722761192",tick:-198701,protocolFee:479349,lpFee:460},{poolId:"0xc7b615a3721594f73664eb3f62d8290d0fcc8d9d1156aed1ddecbd7f32efd9f5",key:{currency0:g,currency1:_,fee:8388608,tickSpacing:10,hooks:y("0xcb787a5cdea8b3715d984d82f1203fd7bfebe0c4")},liquidity:"50517446454827887",sqrtPriceX96:"3840495145865430860317598",tick:-198700,protocolFee:0,lpFee:0},{poolId:"0x24107d152f14a76d292123265ae3f3c71f863fc2f4ef7ba49d64e78d28ea379e",key:{currency0:g,currency1:_,fee:100,tickSpacing:1,hooks:g},liquidity:"36478878201789434",sqrtPriceX96:"3840363370720475418748563",tick:-198701,protocolFee:102425,lpFee:100},{poolId:"0x84bd4e2d8be11aeb0afc1195b38f587b61e90068548f1063fdbe448fb8cad0b6",key:{currency0:se,currency1:_,fee:200,tickSpacing:4,hooks:g},liquidity:"5980655057479791",sqrtPriceX96:"3839891926195366283625355",tick:-198703,protocolFee:213044,lpFee:200},{poolId:"0x3b0cbf0603ecc67b5fc9bb4fbb6ac9e08d3b2f406b63d1662a36063a7fe5e866",key:{currency0:g,currency1:_,fee:87,tickSpacing:1,hooks:g},liquidity:"5486760264498148",sqrtPriceX96:"3840563617639470134132117",tick:-198700,protocolFee:90134,lpFee:87}],Ne=y("0x987e330f00b79864a07fe81dfac344d0078abcc0"),fn="0xa791e5169faf703c0b63fd9552c33ec1128a773a00f5dc33a640da62a022cd35",Tn={currency0:g,currency1:_,fee:De,tickSpacing:1,hooks:Ne},$n=new Set([...Ke.map(e=>e.key.hooks.toLowerCase()),Ne.toLowerCase()]),Mn=j("address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks"),_n=j("(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, int24 tickLower, int24 tickUpper, uint256 liquidity, uint128 amount0Max, uint128 amount1Max, address owner, bytes hookData"),En=j("address currency0, address currency1"),Un=j("address currency, address recipient"),ge=j("uint256 tokenId, uint256 liquidity, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Dn=j("uint256 tokenId, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Te=j("address currency0, address currency1, address recipient"),le=j("bytes actions, bytes[] params"),H=Ae(["function modifyLiquidities(bytes unlockData, uint256 deadline) payable","function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)","function getPositionLiquidity(uint256 tokenId) view returns (uint128 liquidity)","function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, uint256 info)","function positionInfo(uint256 tokenId) view returns (uint256 info)","function ownerOf(uint256 tokenId) view returns (address owner)","function nextTokenId() view returns (uint256 tokenId)"]),Kn=Ae(["function initialize((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint160 sqrtPriceX96) returns (int24 tick)"]),Ye=j("address currency"),Qe=1e6,me=Ae(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Nn=Ae(["function approve(address token, address spender, uint160 amount, uint48 expiration)"]),Fn=In("Transfer(address,address,uint256)");function ve(e){if(typeof e!="string"||!An(e,{strict:!1}))throw new o("Provide a valid v4 currency address.");let n=e.toLowerCase();return n===g||n===de.toLowerCase()?g:y(e)}function R(e){let n=e.toLowerCase();return n===g||n===de.toLowerCase()}function ye(e){let n=ve(e.currency0),i=ve(e.currency1);$(e.hooks);let r=y(e.hooks);return xn(A(Mn,[n,i,e.fee,e.tickSpacing,r]))}function mn(e){return((typeof e=="number"?e:e.fee)&De)!==0}function Je(e,n){return mn(e)?{dynamicFee:!0,storedLpFee:n,swapsAreFree:!1,feeNote:"Pool uses dynamic fee flag 0x800000; stored lpFee=0 does not mean swaps are free. The hook determines the swap fee; a past observation is not a current quote."}:{dynamicFee:!1,storedLpFee:n,swapsAreFree:n===0,feeNote:`Static LP fee ${n} pips.`}}function ke(e,n){if(!e||typeof e!="object")throw new o("Provide a valid v4 PoolKey.");let i=ve(e.currency0),r=ve(e.currency1);if(BigInt(i)>=BigInt(r))throw new o("PoolKey currencies must be strictly sorted (currency0 < currency1).");if(!Number.isInteger(e.tickSpacing)||e.tickSpacing<=0||e.tickSpacing>32767)throw new o("PoolKey tickSpacing must be a positive integer.");if(!Number.isInteger(e.fee)||e.fee<0||e.fee>16777215)throw new o("PoolKey fee must be a valid uint24.");$(e.hooks);let c=y(e.hooks),s=mn(e.fee);if(!s&&e.fee>Qe)throw new o(`PoolKey static fee ${e.fee} exceeds the v4 maximum of ${Qe} pips (100%).`);if(s&&e.fee!==De)throw new o("Dynamic-fee PoolKey must use exact fee flag 0x800000 (8388608).");if(s&&c.toLowerCase()===g)throw new o("Dynamic-fee PoolKey requires a non-zero hook address.");if(!$n.has(c.toLowerCase()))throw new o(`Unsupported v4 hook ${c}: Oak does not assure arbitrary v4 hooks outside measured PoolKeys.`);let t={currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c},d=ye(t);if(c===Ne&&d.toLowerCase()!==fn)throw new o("Only the documented VolatilePair ETH/USDG PoolKey is supported. Pool creation requires the Uniswap Labs role.");if(n!==void 0){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new o("Provide a 32-byte hex poolId.");if(d.toLowerCase()!==n.toLowerCase())throw new o(`PoolKey hash (${d}) does not match expected poolId (${n}).`)}return t}function Vn(e){if(!Number.isInteger(e)||e<=0||e>Pe)throw new o("tickSpacing must be a positive integer.");let n=Math.trunc(Ee/e)*e,i=Math.trunc(Pe/e)*e;return{tickLower:n===0?0:n,tickUpper:i===0?0:i}}function Hn(e,n,i){if(!Number.isInteger(i)||i<=0)throw new o("tickSpacing must be a positive integer.");if(!Number.isInteger(e)||!Number.isInteger(n))throw new o("tickLower and tickUpper must be integers.");if(e<Ee||n>Pe)throw new o(`Ticks [${e}, ${n}] are outside Uniswap bounds [${Ee}, ${Pe}].`);if(e>=n)throw new o("tickLower must be strictly less than tickUpper.");if(e%i!==0||n%i!==0)throw new o(`Ticks [${e}, ${n}] must be divisible by tickSpacing ${i}.`)}function en(e,n,i,r,c=f){if($(e),$(n),R(e))throw new o("Native ETH does not use Permit2 approval.");let s=D(i);if(s<=0n||s>qn)throw new o("Permit2 approval amount must be a positive integer within uint160.");let t=D(String(r));if(t<=0n||t>pn)throw new o("Permit2 expiration must be a positive timestamp within uint48.");let d=re({abi:Nn,functionName:"approve",args:[e,n,s,Number(t)]});return Oe({to:_e,data:d,value:"0",chainId:c,description:`Approve Permit2 allowance of ${s} base units of ${e} for ${n} until ${t}.`})}function nn(e){let n=Number(e&0xffffffn);return(n&8388608)!==0?n-16777216:n}function Xn(e){let n=(e&0xffn)!==0n,i=nn(e>>8n&0xffffffn),r=nn(e>>32n&0xffffffn);return{poolIdBytes25:`0x${(e>>56n&(1n<<200n)-1n).toString(16).padStart(50,"0")}`,tickLower:i,tickUpper:r,hasSubscriber:n}}function tn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e];if(c<=0n||s<=0n)return 0n;let t=(i<<96n)*(s-c),d=s*c;return r?(t+d-1n)/d:t/d}function on(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e],t=i*(s-c);return r?(t+pe-1n)/pe:t/pe}function yn(e){if(e.liquidity<=0n)return{amount0:0n,amount1:0n};let n=ue(e.tickLower),i=ue(e.tickUpper);return e.sqrtPriceX96<=n?{amount0:tn(n,i,e.liquidity,e.roundUp),amount1:0n}:e.sqrtPriceX96<i?{amount0:tn(e.sqrtPriceX96,i,e.liquidity,e.roundUp),amount1:on(n,e.sqrtPriceX96,e.liquidity,e.roundUp)}:{amount0:0n,amount1:on(n,i,e.liquidity,e.roundUp)}}function Bn(e){let n=ue(e.tickLower),i=ue(e.tickUpper),r=(s,t,d)=>t<=s||d<=0n?0n:d*s*t/pe/(t-s),c=(s,t,d)=>t<=s||d<=0n?0n:d*pe/(t-s);if(e.sqrtPriceX96<=n)return r(n,i,e.amount0);if(e.sqrtPriceX96<i){let s=r(e.sqrtPriceX96,i,e.amount0),t=c(n,e.sqrtPriceX96,e.amount1);return s<t?s:t}return c(n,i,e.amount1)}function $e(e,n){return e.map(i=>{let r=i.amount.trim(),c=r.startsWith("-"),s=c||r.startsWith("+")?r.slice(1):r,t=n(s,i.token.decimals);return`${c?"-":""}${t} ${i.token.symbol}`})}function rn(e,n=f){if(R(e))return{address:de,symbol:"ETH",decimals:18,chainId:n};let i=y(e);return i.toLowerCase()===_.toLowerCase()?{address:_,symbol:"USDG",decimals:Xe,chainId:n}:i.toLowerCase()===se.toLowerCase()?{address:se,symbol:"WETH",decimals:18,chainId:n}:{address:i,symbol:i.slice(0,10),decimals:18,chainId:n}}async function V(e,n,i=f){if(R(n))return rn(n,i);let r=y(n);if(r.toLowerCase()===_.toLowerCase()||r.toLowerCase()===se.toLowerCase())return rn(r,i);let[c,s]=await Promise.all([e.readContract({address:r,abi:We,functionName:"symbol"}),e.readContract({address:r,abi:We,functionName:"decimals"})]);if(!Number.isInteger(Number(s))||Number(s)<0||Number(s)>77)throw new o(`Token ${r} reports invalid decimals.`);return{address:r,symbol:ze(c,r),decimals:Number(s),chainId:i}}function W(e,n){if(typeof e!="string"||!/^\d+$/.test(e))throw new o(`${n} must be a non-negative integer string in base units.`);return D(e)}function sn(e,n,i,r){let c=e===void 0?D(Ce(n.toString(),i)):W(e,r);if(c<=1n||c>ne)throw new o(`${r} must exceed 1 base unit and fit in uint128; the simulated amount may be too small.`);return c}async function wn(e,n){if(typeof n=="number"&&Number.isFinite(n)&&n>0)return BigInt(Math.floor(n>1e11?n/1e3:n));if(typeof n=="string"&&/^\d+$/.test(n.trim()))return BigInt(n.trim());try{let i=await e.request({method:"eth_getBlockByNumber",params:["latest",!1]});if(i&&typeof i.timestamp=="string")return BigInt(i.timestamp)}catch{}return BigInt(Math.floor(Date.now()/1e3))}async function Me(e,n,i){let r=await wn(e,i);if(n==null)return r+1800n;let c=D(String(n));if(c<=r)throw new o(`Transaction deadline ${c} has expired (current timestamp ${r}).`);return c}async function Ue(e,n){let i=typeof n.poolId=="string"?n.poolId.trim():void 0,r=n.poolKey&&typeof n.poolKey=="object"&&!Array.isArray(n.poolKey)?n.poolKey:void 0,c=r?{currency0:String(r.currency0??g),currency1:String(r.currency1??_),fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:String(r.hooks??g)}:n.currency0!==void 0&&n.currency1!==void 0&&n.fee!==void 0&&n.tickSpacing!==void 0?{currency0:String(n.currency0),currency1:String(n.currency1),fee:Number(n.fee),tickSpacing:Number(n.tickSpacing),hooks:String(n.hooks??g)}:void 0;if(c){if(R(c.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");let b=ke(c,i);return{poolId:ye(b),poolKey:b}}let s=(i??Ln).toLowerCase();if(s===fn)return{poolId:s,poolKey:ke(Tn,s)};let t=Ke.find(b=>b.poolId.toLowerCase()===s);if(t){if(R(t.key.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");return{poolId:t.poolId,poolKey:t.key}}let d=s.slice(0,52),a=await e.readContract({address:T,abi:H,functionName:"poolKeys",args:[d]}),[p,l,m,u,k]=a;if(p.toLowerCase()===g&&l.toLowerCase()===g&&Number(u)===0)throw new o(`Unknown or uninitialized v4 poolId ${s}.`);let w=ke({currency0:p,currency1:l,fee:Number(m),tickSpacing:Number(u),hooks:k},s);return{poolId:s,poolKey:w}}async function he(e,n,i){try{let[r,c]=await e.readContract({address:T,abi:H,functionName:"getPoolAndPositionInfo",args:[n]}),s=ke({currency0:r.currency0,currency1:r.currency1,fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:r.hooks});if((i.poolKey||i.poolId)&&(await Ue(e,i)).poolId.toLowerCase()!==ye(s).toLowerCase())throw new o("The supplied PoolKey does not match this v4 position.");let t=Xn(BigInt(c));return{poolKey:s,poolId:ye(s),tickLower:t.tickLower,tickUpper:t.tickUpper}}catch(r){throw new o(`Could not read v4 position #${n}. ${oe(r)}`)}}async function an(e,n,i={}){$(n);let r=y(n),c=e.clientFor(f),s=new Set;if(i.tokenIds)for(let d of i.tokenIds)s.add(D(String(d)).toString());try{let d=await c.getBlockNumber(),a=10000000n;for(let p=0n;p<=d;p+=a){let l=p+a-1n<d?p+a-1n:d,m=await c.request({method:"eth_getLogs",params:[{address:T.toLowerCase(),topics:[Fn,null,Sn(r)],fromBlock:Ge(p),toBlock:Ge(l)}]});if(!Array.isArray(m))throw new o("Invalid v4 position log response.");for(let u of m){if(!Array.isArray(u.topics)||u.topics.length!==4||!/^0x[0-9a-fA-F]{64}$/.test(u.topics[3]??""))throw new o("Invalid v4 position transfer log.");s.add(BigInt(u.topics[3]).toString())}}}catch(d){if(!i.tokenIds)throw new o(`Could not discover v4 positions. ${oe(d)}`)}let t=[];for(let d of s){let a=BigInt(d);try{let p;try{p=await c.readContract({address:T,abi:H,functionName:"ownerOf",args:[a]})}catch(P){if(He(P,3))continue;throw P}if(p.toLowerCase()!==r.toLowerCase())continue;let l=await c.readContract({address:T,abi:H,functionName:"getPositionLiquidity",args:[a]}),m=BigInt(l);if(m===0n&&!i.includeZero)continue;let{poolKey:u,poolId:k,tickLower:w,tickUpper:b}=await he(c,a,{}),S=await c.readContract({address:fe,abi:me,functionName:"getSlot0",args:[k]}),I=BigInt(S[0]),{amount0:h,amount1:x}=yn({liquidity:m,tickLower:w,tickUpper:b,sqrtPriceX96:I}),[v,E]=await Promise.all([V(c,u.currency0,f),V(c,u.currency1,f)]);t.push({module:"uniswap",id:`uniswap:v4:${a.toString()}`,chainId:f,assets:[{token:v,amount:h.toString()},{token:E,amount:x.toString()}],description:`Uniswap v4 LP position #${a.toString()} (${v.symbol}/${E.symbol}, liquidity=${m.toString()}, ticks=[${w},${b}], poolId=${k})`})}catch(p){throw new o(`Could not read v4 position #${a}. ${oe(p)}`)}}return t}var On={type:"object",properties:{version:{type:"string",enum:["v4"]},poolId:{type:"string",description:"32-byte Uniswap v4 poolId hex string."},poolKey:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"},tickLower:{type:"number"},tickUpper:{type:"number"},fullRange:{type:"boolean"},liquidity:L("Position liquidity in base units."),amount0Max:L("Maximum currency0 base units to spend."),amount1Max:L("Maximum currency1 base units to spend."),recipient:{type:"string"},deadline:L(),permit2Expiration:{type:"string"},hookData:{type:"string"},tokenId:L("Existing v4 position NFT to increase (keeps its tick range). Omit to mint a new position."),initialPrice:{type:"string",description:"Only when the pool does not exist: starting price as token1 per 1 token0 in human units (native ETH is 18 decimals). Needs the full poolKey. Creates the pool then mints the first position in separately confirmed transactions."},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}}},Rn={type:"object",description:"Create and initialize an empty Uniswap v4 pool (permissionless PoolManager.initialize). Add liquidity afterwards with uniswap_add.",properties:{version:{type:"string",enum:["v4"]},poolKey:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},currency0:{type:"string",description:"Lower sorted currency; the zero address is native ETH."},currency1:{type:"string"},fee:{type:"number",description:"Static LP fee in pips (3000 = 0.30%), at most 1000000."},tickSpacing:{type:"number"},hooks:{type:"string",description:"Hook address; only hooks Oak has measured are accepted. Defaults to none."},initialPrice:{type:"string",description:'Starting price as token1 per 1 token0 in human units, e.g. "3000" for 1 ETH = 3000 USDG.'},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}}},jn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenId:L(),poolId:{type:"string"},poolKey:{type:"object"},amount0Min:L(),amount1Min:L(),recipient:{type:"string"},deadline:L(),hookData:{type:"string"}},required:["tokenId"]},zn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenId:L(),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$",description:"Positive base-unit liquidity amount, or all for a full burn."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:Ie},fullExit:{type:"boolean"},burn:{type:"boolean"},amount0Min:L(),amount1Min:L(),poolId:{type:"string"},poolKey:{type:"object"},recipient:{type:"string"},deadline:L(),hookData:{type:"string"}},required:["tokenId"]},Wn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenIds:{type:"array",items:L()},includeZero:{type:"boolean"}}};function cn(e){let n=e.poolKey&&typeof e.poolKey=="object"&&!Array.isArray(e.poolKey)?e.poolKey:e;for(let i of["currency0","currency1","fee","tickSpacing"])if(n[i]===void 0)throw new o(`Creating a pool needs the full poolKey (currency0, currency1, fee, tickSpacing, hooks); ${i} is missing. A poolId alone cannot describe a pool that does not exist yet.`)}function dn(e,n,i){if(e.initialPrice!==void 0&&e.sqrtPriceX96!==void 0)throw new o("Provide initialPrice or sqrtPriceX96, not both.");if(e.sqrtPriceX96!==void 0){if(typeof e.sqrtPriceX96!="string"||!/^\d+$/.test(e.sqrtPriceX96))throw new o("sqrtPriceX96 must be a non-negative integer string.");return je(BigInt(e.sqrtPriceX96))}return Re(e.initialPrice,n,i)}async function Gn(e,n,i){let r;try{r=await e.readContract({address:T,abi:H,functionName:"ownerOf",args:[n]})}catch(c){throw new o(`Could not verify owner of Uniswap v4 position #${n}. ${oe(c)}`)}if(y(r)!==y(i))throw new o(`Wallet ${y(i)} is not the owner of Uniswap v4 position #${n} (owned by ${y(r)}).`)}async function un(e,n){let i=ye(n).toLowerCase(),r=new Map;for(let s of Ke)s.key.currency0.toLowerCase()===n.currency0.toLowerCase()&&s.key.currency1.toLowerCase()===n.currency1.toLowerCase()&&r.set(s.poolId.toLowerCase(),s.key);let c=[];for(let[s,t]of r){if(s===i||BigInt(await e.readContract({address:fe,abi:me,functionName:"getLiquidity",args:[s]}))===0n)continue;let a=await e.readContract({address:fe,abi:me,functionName:"getSlot0",args:[s]});BigInt(a[0])>0n&&c.push({label:`v4 fee ${t.fee} spacing ${t.tickSpacing} pool ${s}`,sqrtPriceX96:BigInt(a[0])})}return c}function ln(e,n,i,r,c,s){return e.unsignedTx({to:Cn.toLowerCase(),data:re({abi:Kn,functionName:"initialize",args:[{currency0:n.currency0.toLowerCase(),currency1:n.currency1.toLowerCase(),fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks.toLowerCase()},r]}),value:"0",chainId:f,description:`Create and initialize Uniswap v4 pool ${i} (${c.symbol}/${s.symbol}, fee ${n.fee}, tickSpacing ${n.tickSpacing}) at ${be(r,c.decimals,s.decimals)} ${s.symbol} per ${c.symbol}.`})}var Zn=e=>({tools:[{name:"uniswap_add",inputSchema:On,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=t.tokenId===void 0?void 0:D(String(t.tokenId));if(a!==void 0&&a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=t.initialPrice!==void 0||t.sqrtPriceX96!==void 0;if(a!==void 0&&p)throw new o("initialPrice cannot be combined with tokenId.");if(t.amount0Min!==void 0||t.amount1Min!==void 0||t.slippageBps!==void 0)throw new o("V4 mint encodes fixed liquidity and amount0Max/amount1Max; amount minima and slippageBps are not supported for minting.");let l=e.clientFor(f);p&&cn(t);let m,u,k,w;if(a!==void 0){if(t.tickLower!==void 0||t.tickUpper!==void 0||t.fullRange!==void 0)throw new o("An existing v4 position keeps its tick range; omit tickLower, tickUpper and fullRange when increasing.");await Gn(l,a,d),{poolId:m,poolKey:u,tickLower:k,tickUpper:w}=await he(l,a,t)}else{({poolId:m,poolKey:u}=await Ue(l,t));let q=Vn(u.tickSpacing);k=t.fullRange===!0&&t.tickLower===void 0?q.tickLower:Number(t.tickLower),w=t.fullRange===!0&&t.tickUpper===void 0?q.tickUpper:Number(t.tickUpper),Hn(k,w,u.tickSpacing)}let[b,S]=await Promise.all([V(l,u.currency0,f),V(l,u.currency1,f)]),I=W(t.amount0Max??t.amount0Desired,"amount0Max"),h=W(t.amount1Max??t.amount1Desired,"amount1Max");if(I<=0n&&h<=0n||I>ne||h>ne)throw new o("Provide positive amount0Max/amount1Max within uint128.");let x=await l.readContract({address:fe,abi:me,functionName:"getSlot0",args:[m]}),v=BigInt(x[0]),E=Number(x[3]),P;if(p){if(v>0n)throw new o(`Pool ${m} already exists; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);let q=dn(t,b.decimals,S.decimals),F=Le(q,await un(l,u),t.acceptPriceDeviation===!0,b.decimals,S.decimals);P={sqrtPriceX96:q,note:F},v=q}else if(v<=0n)throw new o(`Pool ${m} is not initialized on StateView. To create it and add the first liquidity in one tool call with separately confirmed transactions, pass the full poolKey plus initialPrice (token1 per 1 token0, human units); to create it without liquidity use uniswap_create_pool.`);let C=t.liquidity!==void 0?W(t.liquidity,"liquidity"):Bn({amount0:I,amount1:h,tickLower:k,tickUpper:w,sqrtPriceX96:v});if(C<=0n||C>ne)throw new o("Position liquidity must be a positive integer within uint128.");let{amount0:U,amount1:X}=yn({liquidity:C,tickLower:k,tickUpper:w,sqrtPriceX96:v,roundUp:!0});if(U>I||X>h)throw new o("Liquidity requires more tokens than amount0Max or amount1Max.");let G=t.recipient!==void 0?String(t.recipient):d;if($(G),y(G)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let Z=await wn(l),te=await Me(l,t.deadline,Z.toString()),ae=te<Z+Ze?te:Z+Ze,Y=t.permit2Expiration===void 0?ae:D(String(t.permit2Expiration));if(Y<=Z||Y>ae||Y>pn)throw new o("Permit2 expiration must be in the next 30 minutes and no later than the transaction deadline.");let M=typeof t.hookData=="string"?t.hookData:"0x",K=(q,F)=>{let z=P?[ln(e,u,m,P.sqrtPriceX96,b,S)]:[];if(!R(u.currency0)&&q>0n){let ce=u.currency0.toLowerCase();z.push(e.approval(ce,_e.toLowerCase(),q.toString(),f)),z.push(en(ce,T.toLowerCase(),q.toString(),Y.toString(),f))}if(!R(u.currency1)&&F>0n){let ce=u.currency1.toLowerCase();z.push(e.approval(ce,_e.toLowerCase(),F.toString(),f)),z.push(en(ce,T.toLowerCase(),F.toString(),Y.toString(),f))}let O={currency0:u.currency0.toLowerCase(),currency1:u.currency1.toLowerCase(),fee:u.fee,tickSpacing:u.tickSpacing,hooks:u.hooks.toLowerCase()},Se=A(_n,[O,k,w,C,q,F,G.toLowerCase(),M]),gn=A(En,[O.currency0,O.currency1]),Ve=A(Un,[g,G.toLowerCase()]),kn=A(ge,[a??0n,C,q,F,M]),hn=a===void 0?A(le,["0x020d14",[Se,gn,Ve]]):A(le,["0x00121214",[kn,A(Ye,[O.currency0]),A(Ye,[O.currency1]),Ve]]),Pn=re({abi:H,functionName:"modifyLiquidities",args:[hn,te]}),vn=R(u.currency0)?q.toString():"0";return z.push(e.unsignedTx({to:T.toLowerCase(),data:Pn,value:vn,chainId:f,description:a!==void 0?`Increase Uniswap v4 position #${a} on pool ${m} (liquidity +${C}).`:`Mint Uniswap v4 position on pool ${m} (ticks [${k}, ${w}], liquidity ${C}).`})),z},Q=K(U,X),J=await e.preview(Q,d),B=(q,F)=>{let z=R(F)?de:F.toLowerCase();return-q.changes.filter(O=>O.token.address.toLowerCase()===z).reduce((O,Se)=>O+BigInt(Se.amount),0n)},N=B(J,u.currency0),ie=B(J,u.currency1);if(N<0n||ie<0n||N>U||ie>X||N===0n&&ie===0n&&a===void 0)throw new o("Invalid simulated v4 mint spend. Refresh the liquidity preview.");let Fe=a===void 0?K(N,ie):Q,we=a!==void 0||N===U&&ie===X?J:await e.preview(Fe,d);if(B(we,u.currency0)!==N||B(we,u.currency1)!==ie)throw new o("V4 mint spend changed. Refresh the liquidity preview.");let bn=$e(we.changes,e.formatAmount),xe=Je(u,E);return{txs:Fe,preview:we,poolId:m,poolKey:u,tickLower:k,tickUpper:w,liquidity:C.toString(),amount0Max:{token:b,amount:I.toString()},amount1Max:{token:S,amount:h.toString()},dynamicFee:xe.dynamicFee,swapsAreFree:xe.swapsAreFree,action:a!==void 0?"increase":P?"createAndMint":"mint",...a!==void 0?{tokenId:a.toString()}:{},...P?{poolCreated:!0,sqrtPriceX96:P.sqrtPriceX96.toString(),initialPrice:be(P.sqrtPriceX96,b.decimals,S.decimals),initialTick:qe(P.sqrtPriceX96),priceCheck:P.note}:{},summary:`${a!==void 0?`Increase Uniswap v4 position #${a}`:P?"Create Uniswap v4 pool and add first liquidity":"Add Uniswap v4 liquidity"} (${C} L, ticks [${k}, ${w}]) on pool ${m}. Preview deltas: ${bn.join(", ")||"none"}. ${xe.feeNote}${P?` ${P.note}`:""}`}}},{name:"uniswap_collect",inputSchema:jn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=D(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(f),l=t.recipient!==void 0?String(t.recipient):d;if($(l),y(l)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Me(p,t.deadline,t.now),u=t.amount0Min!==void 0?W(t.amount0Min,"amount0Min"):0n,k=t.amount1Min!==void 0?W(t.amount1Min,"amount1Min"):0n;if(u>ne||k>ne)throw new o("amount0Min and amount1Min must fit in uint128.");let w=typeof t.hookData=="string"?t.hookData:"0x",{poolKey:b,poolId:S}=await he(p,a,t),[I,h]=await Promise.all([V(p,b.currency0,f),V(p,b.currency1,f)]),x=A(ge,[a,0n,u,k,w]),v=A(Te,[b.currency0.toLowerCase(),b.currency1.toLowerCase(),l.toLowerCase()]),E=A(le,["0x0111",[x,v]]),P=re({abi:H,functionName:"modifyLiquidities",args:[E,m]}),C=[e.unsignedTx({to:T.toLowerCase(),data:P,value:"0",chainId:f,description:`Collect Uniswap v4 fees from position #${a} to ${l}.`})],U=await e.preview(C,d),X=$e(U.changes,e.formatAmount);return{txs:C,preview:U,tokenId:a.toString(),poolId:S,recipient:l,currencies:[I,h],summary:`Collect Uniswap v4 fees for position #${a} (actions 0x0111). Preview deltas: ${X.join(", ")||"0"}.`}}},{name:"uniswap_remove",inputSchema:zn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=D(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(f),l=t.recipient!==void 0?String(t.recipient):d;if($(l),y(l)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Me(p,t.deadline,t.now),{poolKey:u,poolId:k}=await he(p,a,t),[w,b]=await Promise.all([V(p,u.currency0,f),V(p,u.currency1,f)]),S=t.slippageBps??Ie;if(typeof S!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");Ce("0",S);let I=typeof t.hookData=="string"?t.hookData:"0x",h=t.fullExit===!0||t.burn===!0||t.liquidity==="all";if(!h&&t.liquidity===void 0)throw new o('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let x=t.liquidity===void 0||t.liquidity==="all"?void 0:W(t.liquidity,"liquidity");if(x!==void 0&&(x<0n||x===0n&&!h||x>ne))throw new o("Provide positive liquidity within uint128 for v4 removal.");let v;try{v=BigInt(await p.readContract({address:T,abi:H,functionName:"getPositionLiquidity",args:[a]}))}catch(M){throw new o(`Could not read v4 position liquidity. ${oe(M)}`)}if(v<0n||v===0n&&!h||x!==void 0&&x>v)throw new o("Removal requires a nonempty position and cannot exceed its liquidity.");if(h&&x!==void 0&&x!==v)throw new o("A full burn must match the position liquidity; omit the amount when explicitly choosing all.");let E=h?"0x0311":"0x0111",P=(M,K,Q)=>{let J=h?A(Dn,[a,M,K,I]):A(ge,[a,x,M,K,I]),B=A(Te,[u.currency0,u.currency1,Q]);return e.unsignedTx({to:T.toLowerCase(),data:re({abi:H,functionName:"modifyLiquidities",args:[A(le,[E,[J,B]]),m]}),value:"0",chainId:f,description:`${h?"Burn and exit":"Decrease"} Uniswap v4 position #${a} (${E}).`})},C=0n,U=0n;if(v>0n&&(t.amount0Min===void 0||t.amount1Min===void 0)){let M=e.unsignedTx({to:T.toLowerCase(),data:re({abi:H,functionName:"modifyLiquidities",args:[A(le,["0x0111",[A(ge,[a,0n,0n,0n,I]),A(Te,[u.currency0,u.currency1,T])]]),m]}),value:"0",chainId:f,description:"Simulation only: separate fees from removal principal."}),K=await e.preview([M,P(2n,2n,d)],d),Q=J=>K.changes.reduce((B,N)=>N.token.chainId===f&&N.token.address.toLowerCase()===J.address.toLowerCase()?B+BigInt(N.amount):B,0n);if(C=Q(w),U=Q(b),C<0n||U<0n)throw new o("Removal simulation did not return the expected currencies.")}let X=(M,K)=>{if(M!==void 0&&W(M,K)!==0n)throw new o(`${K} must be zero for an empty position burn.`);return 0n},G=v===0n?X(t.amount0Min,"amount0Min"):sn(t.amount0Min,C,S,"amount0Min"),Z=v===0n?X(t.amount1Min,"amount1Min"):sn(t.amount1Min,U,S,"amount1Min"),te=[P(G,Z,l)],ae=await e.preview(te,d),Y=$e(ae.changes,e.formatAmount);return{txs:te,preview:ae,action:E,tokenId:a.toString(),poolId:k,amount0Min:{token:w,amount:G.toString()},amount1Min:{token:b,amount:Z.toString()},summary:`${h?"Full exit":"Partial remove"} Uniswap v4 position #${a} (${E})${h?`; burns position #${a} at ${T}`:""}. Preview deltas: ${Y.join(", ")||"none"}.`}}},{name:"uniswap_list_positions",inputSchema:Wn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=Array.isArray(t.tokenIds)?t.tokenIds:void 0,p=t.includeZero===!0,l=await an(e,d,{tokenIds:a,includeZero:p});return{version:"v4",positions:l,summary:`Found ${l.length} active Uniswap v4 position(s) for ${d}.`}}},{name:"uniswap_create_pool",inputSchema:Rn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');cn(t);let a=e.clientFor(f),{poolId:p,poolKey:l}=await Ue(a,t),[m,u]=await Promise.all([V(a,l.currency0,f),V(a,l.currency1,f)]),k=await a.readContract({address:fe,abi:me,functionName:"getSlot0",args:[p]});if(BigInt(k[0])>0n)throw new o(`Uniswap v4 pool ${p} already exists. Use uniswap_add to provide liquidity.`);let w=dn(t,m.decimals,u.decimals),b=Le(w,await un(a,l),t.acceptPriceDeviation===!0,m.decimals,u.decimals),S=be(w,m.decimals,u.decimals),I=[ln(e,l,p,w,m,u)],h=await e.preview(I,d),x=Je(l,l.fee);return{txs:I,preview:h,poolId:p,poolKey:l,sqrtPriceX96:w.toString(),initialPrice:S,initialTick:qe(w),priceCheck:b,action:"createPool",summary:`${I[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add. ${x.feeNote} ${b}`}}}],positions:t=>an(e,t)}),ct=Zn;export{Cn as a,T as b,fe as c,_e as d,at as e,se as f,_ as g,g as h,De as i,Ee as j,Pe as k,Ln as l,Ke as m,Ne as n,fn as o,Tn as p,$n as q,R as r,ye as s,mn as t,Je as u,ke as v,Vn as w,Hn as x,en as y,Xn as z,yn as A,Bn as B,$e as C,rn as D,V as E,he as F,an as G,On as H,Rn as I,jn as J,zn as K,Wn as L,un as M,Zn as N,ct as O};
1
+ import{c as Re,d as je,e as qe,f as be,i as Le,j as ze}from"./MEMVFR7Z.js";import{i as ue}from"./LFN3OODW.js";import{b as Ie,o as Ce}from"./CAU44UWP.js";import{a as de}from"./VJ3W2V3B.js";import{a as $,b as Oe}from"./6IM6A5VA.js";import{a as L}from"./UWOFA6GV.js";import{a as D}from"./RETS2ZEK.js";import{a as f,d as Xe,i as ee,j as Be}from"./XPFVT2EA.js";import{a as o,b as He,d as oe}from"./5YS5V2LK.js";import{encodeAbiParameters as A,encodeFunctionData as re,erc20Abi as We,getAddress as y,isAddress as An,keccak256 as xn,pad as Sn,parseAbi as Ae,parseAbiParameters as j,toEventSelector as In,toHex as Ge}from"viem";var Cn=y(ee[4663].uniswap.v4_pool_manager.address),T=y(ee[4663].uniswap.v4_position_manager.address),fe=y(ee[4663].uniswap.v4_state_view.address),_e=y(ee[4663].uniswap.permit2.address),at=y(ee[4663].ponsTrade.universal_router.address),se=y(ee[4663].uniswap.WETH.address),_=y(Be),g="0x0000000000000000000000000000000000000000",De=8388608,Ee=-887272,Pe=887272,pn=(1n<<48n)-1n,ne=(1n<<128n)-1n,qn=(1n<<160n)-1n,pe=1n<<96n,Ze=1800n,Ln="0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",Ke=[{poolId:"0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",key:{currency0:g,currency1:_,fee:8388608,tickSpacing:10,hooks:y("0x06a889870c8f83640d6816319f72e2aa579b6080")},liquidity:"5532026605872066941",sqrtPriceX96:"3839897026469220985301794",tick:-198703,protocolFee:0,lpFee:0},{poolId:"0x387bf619da4d3fb62bb276482693dba1b9b3520f573cabdfe033384a24125982",key:{currency0:g,currency1:_,fee:500,tickSpacing:10,hooks:g},liquidity:"225820987949255613",sqrtPriceX96:"3840577772610961024680304",tick:-198700,protocolFee:512125,lpFee:500},{poolId:"0x54f7883914619af9105355bf83ed678bcf9f63560218ac61c9963b9503d0ba32",key:{currency0:g,currency1:_,fee:460,tickSpacing:9,hooks:g},liquidity:"85654324417347171",sqrtPriceX96:"3840419018843648722761192",tick:-198701,protocolFee:479349,lpFee:460},{poolId:"0xc7b615a3721594f73664eb3f62d8290d0fcc8d9d1156aed1ddecbd7f32efd9f5",key:{currency0:g,currency1:_,fee:8388608,tickSpacing:10,hooks:y("0xcb787a5cdea8b3715d984d82f1203fd7bfebe0c4")},liquidity:"50517446454827887",sqrtPriceX96:"3840495145865430860317598",tick:-198700,protocolFee:0,lpFee:0},{poolId:"0x24107d152f14a76d292123265ae3f3c71f863fc2f4ef7ba49d64e78d28ea379e",key:{currency0:g,currency1:_,fee:100,tickSpacing:1,hooks:g},liquidity:"36478878201789434",sqrtPriceX96:"3840363370720475418748563",tick:-198701,protocolFee:102425,lpFee:100},{poolId:"0x84bd4e2d8be11aeb0afc1195b38f587b61e90068548f1063fdbe448fb8cad0b6",key:{currency0:se,currency1:_,fee:200,tickSpacing:4,hooks:g},liquidity:"5980655057479791",sqrtPriceX96:"3839891926195366283625355",tick:-198703,protocolFee:213044,lpFee:200},{poolId:"0x3b0cbf0603ecc67b5fc9bb4fbb6ac9e08d3b2f406b63d1662a36063a7fe5e866",key:{currency0:g,currency1:_,fee:87,tickSpacing:1,hooks:g},liquidity:"5486760264498148",sqrtPriceX96:"3840563617639470134132117",tick:-198700,protocolFee:90134,lpFee:87}],Ne=y("0x987e330f00b79864a07fe81dfac344d0078abcc0"),fn="0xa791e5169faf703c0b63fd9552c33ec1128a773a00f5dc33a640da62a022cd35",Tn={currency0:g,currency1:_,fee:De,tickSpacing:1,hooks:Ne},$n=new Set([...Ke.map(e=>e.key.hooks.toLowerCase()),Ne.toLowerCase()]),Mn=j("address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks"),_n=j("(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, int24 tickLower, int24 tickUpper, uint256 liquidity, uint128 amount0Max, uint128 amount1Max, address owner, bytes hookData"),En=j("address currency0, address currency1"),Un=j("address currency, address recipient"),ge=j("uint256 tokenId, uint256 liquidity, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Dn=j("uint256 tokenId, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Te=j("address currency0, address currency1, address recipient"),le=j("bytes actions, bytes[] params"),H=Ae(["function modifyLiquidities(bytes unlockData, uint256 deadline) payable","function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)","function getPositionLiquidity(uint256 tokenId) view returns (uint128 liquidity)","function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, uint256 info)","function positionInfo(uint256 tokenId) view returns (uint256 info)","function ownerOf(uint256 tokenId) view returns (address owner)","function nextTokenId() view returns (uint256 tokenId)"]),Kn=Ae(["function initialize((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint160 sqrtPriceX96) returns (int24 tick)"]),Ye=j("address currency"),Qe=1e6,me=Ae(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Nn=Ae(["function approve(address token, address spender, uint160 amount, uint48 expiration)"]),Fn=In("Transfer(address,address,uint256)");function ve(e){if(typeof e!="string"||!An(e,{strict:!1}))throw new o("Provide a valid v4 currency address.");let n=e.toLowerCase();return n===g||n===de.toLowerCase()?g:y(e)}function R(e){let n=e.toLowerCase();return n===g||n===de.toLowerCase()}function ye(e){let n=ve(e.currency0),i=ve(e.currency1);$(e.hooks);let r=y(e.hooks);return xn(A(Mn,[n,i,e.fee,e.tickSpacing,r]))}function mn(e){return((typeof e=="number"?e:e.fee)&De)!==0}function Je(e,n){return mn(e)?{dynamicFee:!0,storedLpFee:n,swapsAreFree:!1,feeNote:"Pool uses dynamic fee flag 0x800000; stored lpFee=0 does not mean swaps are free. The hook determines the swap fee; a past observation is not a current quote."}:{dynamicFee:!1,storedLpFee:n,swapsAreFree:n===0,feeNote:`Static LP fee ${n} pips.`}}function ke(e,n){if(!e||typeof e!="object")throw new o("Provide a valid v4 PoolKey.");let i=ve(e.currency0),r=ve(e.currency1);if(BigInt(i)>=BigInt(r))throw new o("PoolKey currencies must be strictly sorted (currency0 < currency1).");if(!Number.isInteger(e.tickSpacing)||e.tickSpacing<=0||e.tickSpacing>32767)throw new o("PoolKey tickSpacing must be a positive integer.");if(!Number.isInteger(e.fee)||e.fee<0||e.fee>16777215)throw new o("PoolKey fee must be a valid uint24.");$(e.hooks);let c=y(e.hooks),s=mn(e.fee);if(!s&&e.fee>Qe)throw new o(`PoolKey static fee ${e.fee} exceeds the v4 maximum of ${Qe} pips (100%).`);if(s&&e.fee!==De)throw new o("Dynamic-fee PoolKey must use exact fee flag 0x800000 (8388608).");if(s&&c.toLowerCase()===g)throw new o("Dynamic-fee PoolKey requires a non-zero hook address.");if(!$n.has(c.toLowerCase()))throw new o(`Unsupported v4 hook ${c}: Oak does not assure arbitrary v4 hooks outside measured PoolKeys.`);let t={currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c},d=ye(t);if(c===Ne&&d.toLowerCase()!==fn)throw new o("Only the documented VolatilePair ETH/USDG PoolKey is supported. Pool creation requires the Uniswap Labs role.");if(n!==void 0){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new o("Provide a 32-byte hex poolId.");if(d.toLowerCase()!==n.toLowerCase())throw new o(`PoolKey hash (${d}) does not match expected poolId (${n}).`)}return t}function Vn(e){if(!Number.isInteger(e)||e<=0||e>Pe)throw new o("tickSpacing must be a positive integer.");let n=Math.trunc(Ee/e)*e,i=Math.trunc(Pe/e)*e;return{tickLower:n===0?0:n,tickUpper:i===0?0:i}}function Hn(e,n,i){if(!Number.isInteger(i)||i<=0)throw new o("tickSpacing must be a positive integer.");if(!Number.isInteger(e)||!Number.isInteger(n))throw new o("tickLower and tickUpper must be integers.");if(e<Ee||n>Pe)throw new o(`Ticks [${e}, ${n}] are outside Uniswap bounds [${Ee}, ${Pe}].`);if(e>=n)throw new o("tickLower must be strictly less than tickUpper.");if(e%i!==0||n%i!==0)throw new o(`Ticks [${e}, ${n}] must be divisible by tickSpacing ${i}.`)}function en(e,n,i,r,c=f){if($(e),$(n),R(e))throw new o("Native ETH does not use Permit2 approval.");let s=D(i);if(s<=0n||s>qn)throw new o("Permit2 approval amount must be a positive integer within uint160.");let t=D(String(r));if(t<=0n||t>pn)throw new o("Permit2 expiration must be a positive timestamp within uint48.");let d=re({abi:Nn,functionName:"approve",args:[e,n,s,Number(t)]});return Oe({to:_e,data:d,value:"0",chainId:c,description:`Approve Permit2 allowance of ${s} base units of ${e} for ${n} until ${t}.`})}function nn(e){let n=Number(e&0xffffffn);return(n&8388608)!==0?n-16777216:n}function Xn(e){let n=(e&0xffn)!==0n,i=nn(e>>8n&0xffffffn),r=nn(e>>32n&0xffffffn);return{poolIdBytes25:`0x${(e>>56n&(1n<<200n)-1n).toString(16).padStart(50,"0")}`,tickLower:i,tickUpper:r,hasSubscriber:n}}function tn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e];if(c<=0n||s<=0n)return 0n;let t=(i<<96n)*(s-c),d=s*c;return r?(t+d-1n)/d:t/d}function on(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e],t=i*(s-c);return r?(t+pe-1n)/pe:t/pe}function yn(e){if(e.liquidity<=0n)return{amount0:0n,amount1:0n};let n=ue(e.tickLower),i=ue(e.tickUpper);return e.sqrtPriceX96<=n?{amount0:tn(n,i,e.liquidity,e.roundUp),amount1:0n}:e.sqrtPriceX96<i?{amount0:tn(e.sqrtPriceX96,i,e.liquidity,e.roundUp),amount1:on(n,e.sqrtPriceX96,e.liquidity,e.roundUp)}:{amount0:0n,amount1:on(n,i,e.liquidity,e.roundUp)}}function Bn(e){let n=ue(e.tickLower),i=ue(e.tickUpper),r=(s,t,d)=>t<=s||d<=0n?0n:d*s*t/pe/(t-s),c=(s,t,d)=>t<=s||d<=0n?0n:d*pe/(t-s);if(e.sqrtPriceX96<=n)return r(n,i,e.amount0);if(e.sqrtPriceX96<i){let s=r(e.sqrtPriceX96,i,e.amount0),t=c(n,e.sqrtPriceX96,e.amount1);return s<t?s:t}return c(n,i,e.amount1)}function $e(e,n){return e.map(i=>{let r=i.amount.trim(),c=r.startsWith("-"),s=c||r.startsWith("+")?r.slice(1):r,t=n(s,i.token.decimals);return`${c?"-":""}${t} ${i.token.symbol}`})}function rn(e,n=f){if(R(e))return{address:de,symbol:"ETH",decimals:18,chainId:n};let i=y(e);return i.toLowerCase()===_.toLowerCase()?{address:_,symbol:"USDG",decimals:Xe,chainId:n}:i.toLowerCase()===se.toLowerCase()?{address:se,symbol:"WETH",decimals:18,chainId:n}:{address:i,symbol:i.slice(0,10),decimals:18,chainId:n}}async function V(e,n,i=f){if(R(n))return rn(n,i);let r=y(n);if(r.toLowerCase()===_.toLowerCase()||r.toLowerCase()===se.toLowerCase())return rn(r,i);let[c,s]=await Promise.all([e.readContract({address:r,abi:We,functionName:"symbol"}),e.readContract({address:r,abi:We,functionName:"decimals"})]);if(!Number.isInteger(Number(s))||Number(s)<0||Number(s)>77)throw new o(`Token ${r} reports invalid decimals.`);return{address:r,symbol:ze(c,r),decimals:Number(s),chainId:i}}function W(e,n){if(typeof e!="string"||!/^\d+$/.test(e))throw new o(`${n} must be a non-negative integer string in base units.`);return D(e)}function sn(e,n,i,r){let c=e===void 0?D(Ce(n.toString(),i)):W(e,r);if(c<=1n||c>ne)throw new o(`${r} must exceed 1 base unit and fit in uint128; the simulated amount may be too small.`);return c}async function wn(e,n){if(typeof n=="number"&&Number.isFinite(n)&&n>0)return BigInt(Math.floor(n>1e11?n/1e3:n));if(typeof n=="string"&&/^\d+$/.test(n.trim()))return BigInt(n.trim());try{let i=await e.request({method:"eth_getBlockByNumber",params:["latest",!1]});if(i&&typeof i.timestamp=="string")return BigInt(i.timestamp)}catch{}return BigInt(Math.floor(Date.now()/1e3))}async function Me(e,n,i){let r=await wn(e,i);if(n==null)return r+1800n;let c=D(String(n));if(c<=r)throw new o(`Transaction deadline ${c} has expired (current timestamp ${r}).`);return c}async function Ue(e,n){let i=typeof n.poolId=="string"?n.poolId.trim():void 0,r=n.poolKey&&typeof n.poolKey=="object"&&!Array.isArray(n.poolKey)?n.poolKey:void 0,c=r?{currency0:String(r.currency0??g),currency1:String(r.currency1??_),fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:String(r.hooks??g)}:n.currency0!==void 0&&n.currency1!==void 0&&n.fee!==void 0&&n.tickSpacing!==void 0?{currency0:String(n.currency0),currency1:String(n.currency1),fee:Number(n.fee),tickSpacing:Number(n.tickSpacing),hooks:String(n.hooks??g)}:void 0;if(c){if(R(c.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");let b=ke(c,i);return{poolId:ye(b),poolKey:b}}let s=(i??Ln).toLowerCase();if(s===fn)return{poolId:s,poolKey:ke(Tn,s)};let t=Ke.find(b=>b.poolId.toLowerCase()===s);if(t){if(R(t.key.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");return{poolId:t.poolId,poolKey:t.key}}let d=s.slice(0,52),a=await e.readContract({address:T,abi:H,functionName:"poolKeys",args:[d]}),[p,l,m,u,k]=a;if(p.toLowerCase()===g&&l.toLowerCase()===g&&Number(u)===0)throw new o(`Unknown or uninitialized v4 poolId ${s}.`);let w=ke({currency0:p,currency1:l,fee:Number(m),tickSpacing:Number(u),hooks:k},s);return{poolId:s,poolKey:w}}async function he(e,n,i){try{let[r,c]=await e.readContract({address:T,abi:H,functionName:"getPoolAndPositionInfo",args:[n]}),s=ke({currency0:r.currency0,currency1:r.currency1,fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:r.hooks});if((i.poolKey||i.poolId)&&(await Ue(e,i)).poolId.toLowerCase()!==ye(s).toLowerCase())throw new o("The supplied PoolKey does not match this v4 position.");let t=Xn(BigInt(c));return{poolKey:s,poolId:ye(s),tickLower:t.tickLower,tickUpper:t.tickUpper}}catch(r){throw new o(`Could not read v4 position #${n}. ${oe(r)}`)}}async function an(e,n,i={}){$(n);let r=y(n),c=e.clientFor(f),s=new Set;if(i.tokenIds)for(let d of i.tokenIds)s.add(D(String(d)).toString());try{let d=await c.getBlockNumber(),a=10000000n;for(let p=0n;p<=d;p+=a){let l=p+a-1n<d?p+a-1n:d,m=await c.request({method:"eth_getLogs",params:[{address:T.toLowerCase(),topics:[Fn,null,Sn(r)],fromBlock:Ge(p),toBlock:Ge(l)}]});if(!Array.isArray(m))throw new o("Invalid v4 position log response.");for(let u of m){if(!Array.isArray(u.topics)||u.topics.length!==4||!/^0x[0-9a-fA-F]{64}$/.test(u.topics[3]??""))throw new o("Invalid v4 position transfer log.");s.add(BigInt(u.topics[3]).toString())}}}catch(d){if(!i.tokenIds)throw new o(`Could not discover v4 positions. ${oe(d)}`)}let t=[];for(let d of s){let a=BigInt(d);try{let p;try{p=await c.readContract({address:T,abi:H,functionName:"ownerOf",args:[a]})}catch(P){if(He(P,3))continue;throw P}if(p.toLowerCase()!==r.toLowerCase())continue;let l=await c.readContract({address:T,abi:H,functionName:"getPositionLiquidity",args:[a]}),m=BigInt(l);if(m===0n&&!i.includeZero)continue;let{poolKey:u,poolId:k,tickLower:w,tickUpper:b}=await he(c,a,{}),S=await c.readContract({address:fe,abi:me,functionName:"getSlot0",args:[k]}),I=BigInt(S[0]),{amount0:h,amount1:x}=yn({liquidity:m,tickLower:w,tickUpper:b,sqrtPriceX96:I}),[v,E]=await Promise.all([V(c,u.currency0,f),V(c,u.currency1,f)]);t.push({module:"uniswap",id:`uniswap:v4:${a.toString()}`,chainId:f,assets:[{token:v,amount:h.toString()},{token:E,amount:x.toString()}],description:`Uniswap v4 LP position #${a.toString()} (${v.symbol}/${E.symbol}, liquidity=${m.toString()}, ticks=[${w},${b}], poolId=${k})`})}catch(p){throw new o(`Could not read v4 position #${a}. ${oe(p)}`)}}return t}var On={type:"object",properties:{version:{type:"string",enum:["v4"]},poolId:{type:"string",description:"32-byte Uniswap v4 poolId hex string."},poolKey:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"},tickLower:{type:"number"},tickUpper:{type:"number"},fullRange:{type:"boolean"},liquidity:L("Position liquidity in base units."),amount0Max:L("Maximum currency0 base units to spend."),amount1Max:L("Maximum currency1 base units to spend."),recipient:{type:"string"},deadline:L(),permit2Expiration:{type:"string"},hookData:{type:"string"},tokenId:L("Existing v4 position NFT to increase (keeps its tick range). Omit to mint a new position."),initialPrice:{type:"string",description:"Only when the pool does not exist: starting price as token1 per 1 token0 in human units (native ETH is 18 decimals). Needs the full poolKey. Creates the pool then mints the first position in separately confirmed transactions."},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}}},Rn={type:"object",description:"Create and initialize an empty Uniswap v4 pool (permissionless PoolManager.initialize). Add liquidity afterwards with uniswap_add.",properties:{version:{type:"string",enum:["v4"]},poolKey:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},currency0:{type:"string",description:"Lower sorted currency; the zero address is native ETH."},currency1:{type:"string"},fee:{type:"number",description:"Static LP fee in pips (3000 = 0.30%), at most 1000000."},tickSpacing:{type:"number"},hooks:{type:"string",description:"Hook address; only hooks Oak has measured are accepted. Defaults to none."},initialPrice:{type:"string",description:'Starting price as token1 per 1 token0 in human units, e.g. "3000" for 1 ETH = 3000 USDG.'},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}}},jn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenId:L(),poolId:{type:"string"},poolKey:{type:"object"},amount0Min:L(),amount1Min:L(),recipient:{type:"string"},deadline:L(),hookData:{type:"string"}},required:["tokenId"]},zn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenId:L(),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$",description:"Positive base-unit liquidity amount, or all for a full burn."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:Ie},fullExit:{type:"boolean"},burn:{type:"boolean"},amount0Min:L(),amount1Min:L(),poolId:{type:"string"},poolKey:{type:"object"},recipient:{type:"string"},deadline:L(),hookData:{type:"string"}},required:["tokenId"]},Wn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenIds:{type:"array",items:L()},includeZero:{type:"boolean"}}};function cn(e){let n=e.poolKey&&typeof e.poolKey=="object"&&!Array.isArray(e.poolKey)?e.poolKey:e;for(let i of["currency0","currency1","fee","tickSpacing"])if(n[i]===void 0)throw new o(`Creating a pool needs the full poolKey (currency0, currency1, fee, tickSpacing, hooks); ${i} is missing. A poolId alone cannot describe a pool that does not exist yet.`)}function dn(e,n,i){if(e.initialPrice!==void 0&&e.sqrtPriceX96!==void 0)throw new o("Provide initialPrice or sqrtPriceX96, not both.");if(e.sqrtPriceX96!==void 0){if(typeof e.sqrtPriceX96!="string"||!/^\d+$/.test(e.sqrtPriceX96))throw new o("sqrtPriceX96 must be a non-negative integer string.");return je(BigInt(e.sqrtPriceX96))}return Re(e.initialPrice,n,i)}async function Gn(e,n,i){let r;try{r=await e.readContract({address:T,abi:H,functionName:"ownerOf",args:[n]})}catch(c){throw new o(`Could not verify owner of Uniswap v4 position #${n}. ${oe(c)}`)}if(y(r)!==y(i))throw new o(`Wallet ${y(i)} is not the owner of Uniswap v4 position #${n} (owned by ${y(r)}).`)}async function un(e,n){let i=ye(n).toLowerCase(),r=new Map;for(let s of Ke)s.key.currency0.toLowerCase()===n.currency0.toLowerCase()&&s.key.currency1.toLowerCase()===n.currency1.toLowerCase()&&r.set(s.poolId.toLowerCase(),s.key);let c=[];for(let[s,t]of r){if(s===i||BigInt(await e.readContract({address:fe,abi:me,functionName:"getLiquidity",args:[s]}))===0n)continue;let a=await e.readContract({address:fe,abi:me,functionName:"getSlot0",args:[s]});BigInt(a[0])>0n&&c.push({label:`v4 fee ${t.fee} spacing ${t.tickSpacing} pool ${s}`,sqrtPriceX96:BigInt(a[0])})}return c}function ln(e,n,i,r,c,s){return e.unsignedTx({to:Cn.toLowerCase(),data:re({abi:Kn,functionName:"initialize",args:[{currency0:n.currency0.toLowerCase(),currency1:n.currency1.toLowerCase(),fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks.toLowerCase()},r]}),value:"0",chainId:f,description:`Create and initialize Uniswap v4 pool ${i} (${c.symbol}/${s.symbol}, fee ${n.fee}, tickSpacing ${n.tickSpacing}) at ${be(r,c.decimals,s.decimals)} ${s.symbol} per ${c.symbol}.`})}var Zn=e=>({tools:[{name:"uniswap_add",inputSchema:On,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=t.tokenId===void 0?void 0:D(String(t.tokenId));if(a!==void 0&&a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=t.initialPrice!==void 0||t.sqrtPriceX96!==void 0;if(a!==void 0&&p)throw new o("initialPrice cannot be combined with tokenId.");if(t.amount0Min!==void 0||t.amount1Min!==void 0||t.slippageBps!==void 0)throw new o("V4 mint encodes fixed liquidity and amount0Max/amount1Max; amount minima and slippageBps are not supported for minting.");let l=e.clientFor(f);p&&cn(t);let m,u,k,w;if(a!==void 0){if(t.tickLower!==void 0||t.tickUpper!==void 0||t.fullRange!==void 0)throw new o("An existing v4 position keeps its tick range; omit tickLower, tickUpper and fullRange when increasing.");await Gn(l,a,d),{poolId:m,poolKey:u,tickLower:k,tickUpper:w}=await he(l,a,t)}else{({poolId:m,poolKey:u}=await Ue(l,t));let q=Vn(u.tickSpacing);k=t.fullRange===!0&&t.tickLower===void 0?q.tickLower:Number(t.tickLower),w=t.fullRange===!0&&t.tickUpper===void 0?q.tickUpper:Number(t.tickUpper),Hn(k,w,u.tickSpacing)}let[b,S]=await Promise.all([V(l,u.currency0,f),V(l,u.currency1,f)]),I=W(t.amount0Max??t.amount0Desired,"amount0Max"),h=W(t.amount1Max??t.amount1Desired,"amount1Max");if(I<=0n&&h<=0n||I>ne||h>ne)throw new o("Provide positive amount0Max/amount1Max within uint128.");let x=await l.readContract({address:fe,abi:me,functionName:"getSlot0",args:[m]}),v=BigInt(x[0]),E=Number(x[3]),P;if(p){if(v>0n)throw new o(`Pool ${m} already exists; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);let q=dn(t,b.decimals,S.decimals),F=Le(q,await un(l,u),t.acceptPriceDeviation===!0,b.decimals,S.decimals);P={sqrtPriceX96:q,note:F},v=q}else if(v<=0n)throw new o(`Pool ${m} is not initialized on StateView. To create it and add the first liquidity in one tool call with separately confirmed transactions, pass the full poolKey plus initialPrice (token1 per 1 token0, human units); to create it without liquidity use uniswap_create_pool.`);let C=t.liquidity!==void 0?W(t.liquidity,"liquidity"):Bn({amount0:I,amount1:h,tickLower:k,tickUpper:w,sqrtPriceX96:v});if(C<=0n||C>ne)throw new o("Position liquidity must be a positive integer within uint128.");let{amount0:U,amount1:X}=yn({liquidity:C,tickLower:k,tickUpper:w,sqrtPriceX96:v,roundUp:!0});if(U>I||X>h)throw new o("Liquidity requires more tokens than amount0Max or amount1Max.");let G=t.recipient!==void 0?String(t.recipient):d;if($(G),y(G)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let Z=await wn(l),te=await Me(l,t.deadline,Z.toString()),ae=te<Z+Ze?te:Z+Ze,Y=t.permit2Expiration===void 0?ae:D(String(t.permit2Expiration));if(Y<=Z||Y>ae||Y>pn)throw new o("Permit2 expiration must be in the next 30 minutes and no later than the transaction deadline.");let M=typeof t.hookData=="string"?t.hookData:"0x",K=(q,F)=>{let z=P?[ln(e,u,m,P.sqrtPriceX96,b,S)]:[];if(!R(u.currency0)&&q>0n){let ce=u.currency0.toLowerCase();z.push(e.approval(ce,_e.toLowerCase(),q.toString(),f)),z.push(en(ce,T.toLowerCase(),q.toString(),Y.toString(),f))}if(!R(u.currency1)&&F>0n){let ce=u.currency1.toLowerCase();z.push(e.approval(ce,_e.toLowerCase(),F.toString(),f)),z.push(en(ce,T.toLowerCase(),F.toString(),Y.toString(),f))}let O={currency0:u.currency0.toLowerCase(),currency1:u.currency1.toLowerCase(),fee:u.fee,tickSpacing:u.tickSpacing,hooks:u.hooks.toLowerCase()},Se=A(_n,[O,k,w,C,q,F,G.toLowerCase(),M]),gn=A(En,[O.currency0,O.currency1]),Ve=A(Un,[g,G.toLowerCase()]),kn=A(ge,[a??0n,C,q,F,M]),hn=a===void 0?A(le,["0x020d14",[Se,gn,Ve]]):A(le,["0x00121214",[kn,A(Ye,[O.currency0]),A(Ye,[O.currency1]),Ve]]),Pn=re({abi:H,functionName:"modifyLiquidities",args:[hn,te]}),vn=R(u.currency0)?q.toString():"0";return z.push(e.unsignedTx({to:T.toLowerCase(),data:Pn,value:vn,chainId:f,description:a!==void 0?`Increase Uniswap v4 position #${a} on pool ${m} (liquidity +${C}).`:`Mint Uniswap v4 position on pool ${m} (ticks [${k}, ${w}], liquidity ${C}).`})),z},Q=K(U,X),J=await e.preview(Q,d),B=(q,F)=>{let z=R(F)?de:F.toLowerCase();return-q.changes.filter(O=>O.token.address.toLowerCase()===z).reduce((O,Se)=>O+BigInt(Se.amount),0n)},N=B(J,u.currency0),ie=B(J,u.currency1);if(N<0n||ie<0n||N>U||ie>X||N===0n&&ie===0n&&a===void 0)throw new o("Invalid simulated v4 mint spend. Refresh the liquidity preview.");let Fe=a===void 0?K(N,ie):Q,we=a!==void 0||N===U&&ie===X?J:await e.preview(Fe,d);if(B(we,u.currency0)!==N||B(we,u.currency1)!==ie)throw new o("V4 mint spend changed. Refresh the liquidity preview.");let bn=$e(we.changes,e.formatAmount),xe=Je(u,E);return{txs:Fe,preview:we,poolId:m,poolKey:u,tickLower:k,tickUpper:w,liquidity:C.toString(),amount0Max:{token:b,amount:I.toString()},amount1Max:{token:S,amount:h.toString()},dynamicFee:xe.dynamicFee,swapsAreFree:xe.swapsAreFree,action:a!==void 0?"increase":P?"createAndMint":"mint",...a!==void 0?{tokenId:a.toString()}:{},...P?{poolCreated:!0,sqrtPriceX96:P.sqrtPriceX96.toString(),initialPrice:be(P.sqrtPriceX96,b.decimals,S.decimals),initialTick:qe(P.sqrtPriceX96),priceCheck:P.note}:{},summary:`${a!==void 0?`Increase Uniswap v4 position #${a}`:P?"Create Uniswap v4 pool and add first liquidity":"Add Uniswap v4 liquidity"} (${C} L, ticks [${k}, ${w}]) on pool ${m}. Preview deltas: ${bn.join(", ")||"none"}. ${xe.feeNote}${P?` ${P.note}`:""}`}}},{name:"uniswap_collect",inputSchema:jn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=D(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(f),l=t.recipient!==void 0?String(t.recipient):d;if($(l),y(l)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Me(p,t.deadline,t.now),u=t.amount0Min!==void 0?W(t.amount0Min,"amount0Min"):0n,k=t.amount1Min!==void 0?W(t.amount1Min,"amount1Min"):0n;if(u>ne||k>ne)throw new o("amount0Min and amount1Min must fit in uint128.");let w=typeof t.hookData=="string"?t.hookData:"0x",{poolKey:b,poolId:S}=await he(p,a,t),[I,h]=await Promise.all([V(p,b.currency0,f),V(p,b.currency1,f)]),x=A(ge,[a,0n,u,k,w]),v=A(Te,[b.currency0.toLowerCase(),b.currency1.toLowerCase(),l.toLowerCase()]),E=A(le,["0x0111",[x,v]]),P=re({abi:H,functionName:"modifyLiquidities",args:[E,m]}),C=[e.unsignedTx({to:T.toLowerCase(),data:P,value:"0",chainId:f,description:`Collect Uniswap v4 fees from position #${a} to ${l}.`})],U=await e.preview(C,d),X=$e(U.changes,e.formatAmount);return{txs:C,preview:U,tokenId:a.toString(),poolId:S,recipient:l,currencies:[I,h],summary:`Collect Uniswap v4 fees for position #${a} (actions 0x0111). Preview deltas: ${X.join(", ")||"0"}.`}}},{name:"uniswap_remove",inputSchema:zn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=D(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(f),l=t.recipient!==void 0?String(t.recipient):d;if($(l),y(l)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Me(p,t.deadline,t.now),{poolKey:u,poolId:k}=await he(p,a,t),[w,b]=await Promise.all([V(p,u.currency0,f),V(p,u.currency1,f)]),S=t.slippageBps??Ie;if(typeof S!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");Ce("0",S);let I=typeof t.hookData=="string"?t.hookData:"0x",h=t.fullExit===!0||t.burn===!0||t.liquidity==="all";if(!h&&t.liquidity===void 0)throw new o('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let x=t.liquidity===void 0||t.liquidity==="all"?void 0:W(t.liquidity,"liquidity");if(x!==void 0&&(x<0n||x===0n&&!h||x>ne))throw new o("Provide positive liquidity within uint128 for v4 removal.");let v;try{v=BigInt(await p.readContract({address:T,abi:H,functionName:"getPositionLiquidity",args:[a]}))}catch(M){throw new o(`Could not read v4 position liquidity. ${oe(M)}`)}if(v<0n||v===0n&&!h||x!==void 0&&x>v)throw new o("Removal requires a nonempty position and cannot exceed its liquidity.");if(h&&x!==void 0&&x!==v)throw new o("A full burn must match the position liquidity; omit the amount when explicitly choosing all.");let E=h?"0x0311":"0x0111",P=(M,K,Q)=>{let J=h?A(Dn,[a,M,K,I]):A(ge,[a,x,M,K,I]),B=A(Te,[u.currency0,u.currency1,Q]);return e.unsignedTx({to:T.toLowerCase(),data:re({abi:H,functionName:"modifyLiquidities",args:[A(le,[E,[J,B]]),m]}),value:"0",chainId:f,description:`${h?"Burn and exit":"Decrease"} Uniswap v4 position #${a} (${E}).`})},C=0n,U=0n;if(v>0n&&(t.amount0Min===void 0||t.amount1Min===void 0)){let M=e.unsignedTx({to:T.toLowerCase(),data:re({abi:H,functionName:"modifyLiquidities",args:[A(le,["0x0111",[A(ge,[a,0n,0n,0n,I]),A(Te,[u.currency0,u.currency1,T])]]),m]}),value:"0",chainId:f,description:"Simulation only: separate fees from removal principal."}),K=await e.preview([M,P(2n,2n,d)],d),Q=J=>K.changes.reduce((B,N)=>N.token.chainId===f&&N.token.address.toLowerCase()===J.address.toLowerCase()?B+BigInt(N.amount):B,0n);if(C=Q(w),U=Q(b),C<0n||U<0n)throw new o("Removal simulation did not return the expected currencies.")}let X=(M,K)=>{if(M!==void 0&&W(M,K)!==0n)throw new o(`${K} must be zero for an empty position burn.`);return 0n},G=v===0n?X(t.amount0Min,"amount0Min"):sn(t.amount0Min,C,S,"amount0Min"),Z=v===0n?X(t.amount1Min,"amount1Min"):sn(t.amount1Min,U,S,"amount1Min"),te=[P(G,Z,l)],ae=await e.preview(te,d),Y=$e(ae.changes,e.formatAmount);return{txs:te,preview:ae,action:E,tokenId:a.toString(),poolId:k,amount0Min:{token:w,amount:G.toString()},amount1Min:{token:b,amount:Z.toString()},summary:`${h?"Full exit":"Partial remove"} Uniswap v4 position #${a} (${E})${h?`; burns position #${a} at ${T}`:""}. Preview deltas: ${Y.join(", ")||"none"}.`}}},{name:"uniswap_list_positions",inputSchema:Wn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=Array.isArray(t.tokenIds)?t.tokenIds:void 0,p=t.includeZero===!0,l=await an(e,d,{tokenIds:a,includeZero:p});return{version:"v4",positions:l,summary:`Found ${l.length} active Uniswap v4 position(s) for ${d}.`}}},{name:"uniswap_create_pool",inputSchema:Rn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');cn(t);let a=e.clientFor(f),{poolId:p,poolKey:l}=await Ue(a,t),[m,u]=await Promise.all([V(a,l.currency0,f),V(a,l.currency1,f)]),k=await a.readContract({address:fe,abi:me,functionName:"getSlot0",args:[p]});if(BigInt(k[0])>0n)throw new o(`Uniswap v4 pool ${p} already exists. Use uniswap_add to provide liquidity.`);let w=dn(t,m.decimals,u.decimals),b=Le(w,await un(a,l),t.acceptPriceDeviation===!0,m.decimals,u.decimals),S=be(w,m.decimals,u.decimals),I=[ln(e,l,p,w,m,u)],h=await e.preview(I,d),x=Je(l,l.fee);return{txs:I,preview:h,poolId:p,poolKey:l,sqrtPriceX96:w.toString(),initialPrice:S,initialTick:qe(w),priceCheck:b,action:"createPool",summary:`${I[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add. ${x.feeNote} ${b}`}}}],positions:t=>an(e,t)}),ct=Zn;export{Cn as a,T as b,fe as c,_e as d,at as e,se as f,_ as g,g as h,De as i,Ee as j,Pe as k,Ln as l,Ke as m,Ne as n,fn as o,Tn as p,$n as q,R as r,ye as s,mn as t,Je as u,ke as v,Vn as w,Hn as x,en as y,Xn as z,yn as A,Bn as B,$e as C,rn as D,V as E,he as F,an as G,On as H,Rn as I,jn as J,zn as K,Wn as L,un as M,Zn as N,ct as O};
@@ -1 +1 @@
1
- import{a as h}from"./JOMK32QW.js";import{c as p}from"./73N3TOJL.js";import{a as l}from"./XPFVT2EA.js";import{a}from"./5YS5V2LK.js";import{getAddress as v}from"viem";var f={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},w=[["hookr_release",{},[],"Read verified release contracts, block and recapture lane."],["hookr_blocks",{},[],"Read all Hook Blocks and their current availability."],["hookr_kings",{poolId:f},[],"Read King of the Pool rounds, leaders, pots and endings."],["hookr_claims",{poolId:f},[],"Read the signing wallet's prizes, royalties, recapture and PoolManager claims."],["hookr_revenue_tokens",{limit:{type:"integer",minimum:1,maximum:50},cursor:{type:"string",pattern:"^(v1|v1:[1-9][0-9]{0,19}|v2:[1-9][0-9]{0,19})$"}},[],"Read revenue tokens, tokenizer provenance, streams and income, page by page."],["hookr_revenue_token",{token:p},["token"],"Read a revenue token, stream endings, income, drops and the signing wallet's claims."],["hookr_hook",{address:p},["address"],"Read shared or owned hook provenance, ownership, allowed blocks, opening and pools."]],H=[...w.map(d=>d[0]),"hookr_contracts","hookr_read","hookr_revenue_read","hookr_addon_read","hookr_api_read"];function j(d){return[...w.map(([t,c,s,o])=>({name:t,inputSchema:{type:"object",description:o,properties:c,required:s,additionalProperties:!1},execute:async(r,g)=>{if(Object.keys(r).some(n=>!Object.hasOwn(c,n))||s.some(n=>r[n]===void 0))throw new a(`Provide the documented arguments for ${t}.`);let k={};for(let[n,i]of Object.entries(r)){let u=c[n];if(u.type==="integer"){if(typeof i!="number"||!Number.isInteger(i)||i<Number(u.minimum)||i>Number(u.maximum))throw new a("Hookr revenue page limit must be an integer from 1 to 50.")}else if(typeof i!="string"||!new RegExp(String(u.pattern)).test(i))throw new a(`Provide a valid Hookr ${n}.`);k[n]=n==="token"||n==="address"?v(String(i)):i}return(t==="hookr_claims"||t==="hookr_revenue_token")&&(k.account=g),{...await h(d,t,k),chainId:l,source:"https://hookr.fun/api/mcp"}}})),y(d)]}var m={catalog:"/api/hooks/catalog",stats:"/api/protocol-stats",poolApr:"/api/pool-apr",revenueTokens:"/api/revenue-tokens",revenueIncome:"/api/revenue-tokens/income"};function y(d){return{name:"hookr_api_read",inputSchema:{type:"object",description:"Read Hookr public catalog, protocol stats, pool APR, revenue directory/income, or one token's doors/mark. Marks are project metadata, not investment or security endorsements.",properties:{resource:{type:"string",enum:[...Object.keys(m),"revenueDoors","revenueMark"]},token:p},required:["resource"],additionalProperties:!1},execute:async e=>{if(Object.keys(e).some(o=>!["resource","token"].includes(o))||typeof e.resource!="string")throw new a("Choose a documented Hookr public resource.");let t=["revenueDoors","revenueMark"].includes(e.resource);if(!t&&e.token!==void 0||t&&typeof e.token!="string")throw new a("Only the revenueDoors and revenueMark resources take a token address.");let c;if(t){let o;try{o=v(String(e.token))}catch{throw new a("Provide a valid revenue token address.")}c=`/api/revenue-tokens/${o}/${e.resource==="revenueDoors"?"doors":"mark"}`}else{if(!Object.hasOwn(m,e.resource))throw new a("Choose a documented Hookr public resource.");c=m[e.resource]}let s=`https://hookr.fun${c}`;try{let o=await d.http(s,{method:"GET",redirect:"error",signal:AbortSignal.timeout(15e3)});if(!o.ok)throw new Error("Unavailable");if(e.resource==="revenueMark"){if(!o.headers.get("content-type")?.includes("image/svg+xml"))throw new Error("Invalid mark");return{chainId:l,source:s,imageUrl:s,pngUrl:`${s}.png`,note:"Official SVG mark URL; SVG code is not executed or returned. The PNG URL has not been fetched."}}let r=await o.json();if(!r||typeof r!="object"||"error"in r||"status"in r&&r.status==="unavailable")throw new Error("Unavailable");return{chainId:l,source:s,data:r}}catch{throw new a("Hookr public resource is unavailable. Retry later; no empty or zero result is implied.")}}}}export{H as a,j as b,y as c};
1
+ import{a as h}from"./72AWP4BM.js";import{c as p}from"./73N3TOJL.js";import{a as l}from"./XPFVT2EA.js";import{a}from"./5YS5V2LK.js";import{getAddress as v}from"viem";var f={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},w=[["hookr_release",{},[],"Read verified release contracts, block and recapture lane."],["hookr_blocks",{},[],"Read all Hook Blocks and their current availability."],["hookr_kings",{poolId:f},[],"Read King of the Pool rounds, leaders, pots and endings."],["hookr_claims",{poolId:f},[],"Read the signing wallet's prizes, royalties, recapture and PoolManager claims."],["hookr_revenue_tokens",{limit:{type:"integer",minimum:1,maximum:50},cursor:{type:"string",pattern:"^(v1|v1:[1-9][0-9]{0,19}|v2:[1-9][0-9]{0,19})$"}},[],"Read revenue tokens, tokenizer provenance, streams and income, page by page."],["hookr_revenue_token",{token:p},["token"],"Read a revenue token, stream endings, income, drops and the signing wallet's claims."],["hookr_hook",{address:p},["address"],"Read shared or owned hook provenance, ownership, allowed blocks, opening and pools."]],H=[...w.map(d=>d[0]),"hookr_contracts","hookr_read","hookr_revenue_read","hookr_addon_read","hookr_api_read"];function j(d){return[...w.map(([t,c,s,o])=>({name:t,inputSchema:{type:"object",description:o,properties:c,required:s,additionalProperties:!1},execute:async(r,g)=>{if(Object.keys(r).some(n=>!Object.hasOwn(c,n))||s.some(n=>r[n]===void 0))throw new a(`Provide the documented arguments for ${t}.`);let k={};for(let[n,i]of Object.entries(r)){let u=c[n];if(u.type==="integer"){if(typeof i!="number"||!Number.isInteger(i)||i<Number(u.minimum)||i>Number(u.maximum))throw new a("Hookr revenue page limit must be an integer from 1 to 50.")}else if(typeof i!="string"||!new RegExp(String(u.pattern)).test(i))throw new a(`Provide a valid Hookr ${n}.`);k[n]=n==="token"||n==="address"?v(String(i)):i}return(t==="hookr_claims"||t==="hookr_revenue_token")&&(k.account=g),{...await h(d,t,k),chainId:l,source:"https://hookr.fun/api/mcp"}}})),y(d)]}var m={catalog:"/api/hooks/catalog",stats:"/api/protocol-stats",poolApr:"/api/pool-apr",revenueTokens:"/api/revenue-tokens",revenueIncome:"/api/revenue-tokens/income"};function y(d){return{name:"hookr_api_read",inputSchema:{type:"object",description:"Read Hookr public catalog, protocol stats, pool APR, revenue directory/income, or one token's doors/mark. Marks are project metadata, not investment or security endorsements.",properties:{resource:{type:"string",enum:[...Object.keys(m),"revenueDoors","revenueMark"]},token:p},required:["resource"],additionalProperties:!1},execute:async e=>{if(Object.keys(e).some(o=>!["resource","token"].includes(o))||typeof e.resource!="string")throw new a("Choose a documented Hookr public resource.");let t=["revenueDoors","revenueMark"].includes(e.resource);if(!t&&e.token!==void 0||t&&typeof e.token!="string")throw new a("Only the revenueDoors and revenueMark resources take a token address.");let c;if(t){let o;try{o=v(String(e.token))}catch{throw new a("Provide a valid revenue token address.")}c=`/api/revenue-tokens/${o}/${e.resource==="revenueDoors"?"doors":"mark"}`}else{if(!Object.hasOwn(m,e.resource))throw new a("Choose a documented Hookr public resource.");c=m[e.resource]}let s=`https://hookr.fun${c}`;try{let o=await d.http(s,{method:"GET",redirect:"error",signal:AbortSignal.timeout(15e3)});if(!o.ok)throw new Error("Unavailable");if(e.resource==="revenueMark"){if(!o.headers.get("content-type")?.includes("image/svg+xml"))throw new Error("Invalid mark");return{chainId:l,source:s,imageUrl:s,pngUrl:`${s}.png`,note:"Official SVG mark URL; SVG code is not executed or returned. The PNG URL has not been fetched."}}let r=await o.json();if(!r||typeof r!="object"||"error"in r||"status"in r&&r.status==="unavailable")throw new Error("Unavailable");return{chainId:l,source:s,data:r}}catch{throw new a("Hookr public resource is unavailable. Retry later; no empty or zero result is implied.")}}}}export{H as a,j as b,y as c};
@@ -0,0 +1 @@
1
+ import{m as v,n as F}from"./D3OWLDVB.js";import{b as A,i as U,n as X,o as V,q as j}from"./CCEWSOBT.js";import{a as q}from"./RFJCG4NA.js";import{b as z,e as C,n as Y}from"./T3MGNKA6.js";import{a as w,b as S}from"./VJ3W2V3B.js";import{a as k}from"./LIUXNOLP.js";import{a as x}from"./OG5HRQU4.js";import{a as B}from"./AXYOJBX6.js";import{b as $}from"./MYBDO5SA.js";import{a as T}from"./RETS2ZEK.js";import{o as y}from"./IWALIX7Q.js";import{a as u,b as f,c as H,d as P,i as g,j as R,k as W,p as K}from"./XPFVT2EA.js";import{a as o}from"./5YS5V2LK.js";import{a as N,b as L}from"./JXOEJPJ4.js";import{getAddress as b,isAddress as J,parseAbi as se}from"viem";var Q=[{inputs:[],name:"available",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"ethUsdE18",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"liquidityUsdgE6",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"phase",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"priceSigner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"signer",type:"address"}],name:"setPriceSigner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"spotOakPerEthE18",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"supplyNet",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"syncPhase",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"wallet",type:"address"},{internalType:"uint256",name:"oakPerEthE18",type:"uint256"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"bytes32",name:"nonce",type:"bytes32"}],internalType:"struct PriceNote",name:"n",type:"tuple"},{internalType:"bytes",name:"sig",type:"bytes"},{internalType:"address",name:"boundWallet",type:"address"}],name:"verifyNote",outputs:[{internalType:"uint256",name:"oakPerEthE18",type:"uint256"}],stateMutability:"view",type:"function"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"signer",type:"address"}],name:"PriceSignerSet",type:"event"},{inputs:[],name:"NotReady",type:"error"},{inputs:[],name:"NoteBadSignature",type:"error"},{inputs:[],name:"NoteExpired",type:"error"},{inputs:[],name:"NoteNotYetValid",type:"error"},{inputs:[{internalType:"uint256",name:"spot",type:"uint256"},{internalType:"uint256",name:"note",type:"uint256"}],name:"NoteOutsideGuard",type:"error"},{inputs:[],name:"NoteWrongWallet",type:"error"},{inputs:[{internalType:"address",name:"source",type:"address"}],name:"OracleUnreadable",type:"error"}];var M=300,oe="1000000000000000000",ee=b(g[u].tokens.USDG.address),te=b(g[f].deployments.test_USDG.address),O=b(g[u].tokens.WETH.address),_=b(g[f].deployments.test_WETH.address);function ne(n){let e=n.address.toLowerCase();return n.chainId===u?e===ee.toLowerCase():n.chainId===f?e===te.toLowerCase():!1}function re(n){return n.chainId!==u&&n.chainId!==f?!1:S(n.address)===w}function ie(n){let e=n.address.toLowerCase();return n.chainId===u?e===O.toLowerCase():n.chainId===f?e===_.toLowerCase():!1}function de(n){return re(n)||ie(n)}var ce=-887272,me=887272,ue=(1n<<256n)-1n,fe=se(["function observe(uint32[] secondsAgos) view returns (int56[] tickCumulatives, uint160[] secondsPerLiquidityCumulativeX128s)","function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)"]);function I(n,e){if(typeof n=="bigint")return n;if(typeof n=="number"){if(!Number.isSafeInteger(n))throw new o(`Invalid ${e} timestamp.`);return BigInt(n)}if(typeof n=="string"&&/^-?\d+$/.test(n.trim()))return BigInt(n.trim());throw new o(`Invalid ${e} timestamp.`)}function Oe(n,e=BigInt(Math.floor(Date.now()/1e3)),t=M){try{return l(n,e,t),!0}catch{return!1}}function l(n,e=BigInt(Math.floor(Date.now()/1e3)),t=M){if(!Number.isInteger(t)||t<0)throw new o("Maximum price age must be a non-negative integer.");let s=I(n,"price"),a=I(e,"current");if(s<=0n)throw new o("Price timestamp must be positive.");if(s>a)throw new o("Price timestamp is in the future.");let r=a-s;if(r>BigInt(t))throw new o(`Price is stale: age ${r}s exceeds ${t}s.`);return s.toString()}function le(n){if(!Number.isInteger(n)||n<ce||n>me)throw new o(`Tick ${n} is outside valid Uniswap bounds.`);let e=BigInt(n<0?-n:n),t=(e&0x1n)!==0n?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;return(e&0x2n)!==0n&&(t=t*0xfff97272373d413259a46990580e213an>>128n),(e&0x4n)!==0n&&(t=t*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(e&0x8n)!==0n&&(t=t*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(e&0x10n)!==0n&&(t=t*0xffcb9843d60f6159c9db58835c926644n>>128n),(e&0x20n)!==0n&&(t=t*0xff973b41fa98c081472e6896dfb254c0n>>128n),(e&0x40n)!==0n&&(t=t*0xff2ea16466c96a3843ec78b326b52861n>>128n),(e&0x80n)!==0n&&(t=t*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(e&0x100n)!==0n&&(t=t*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(e&0x200n)!==0n&&(t=t*0xf987a7253ac413176f2b074cf7815e54n>>128n),(e&0x400n)!==0n&&(t=t*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(e&0x800n)!==0n&&(t=t*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(e&0x1000n)!==0n&&(t=t*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(e&0x2000n)!==0n&&(t=t*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(e&0x4000n)!==0n&&(t=t*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(e&0x8000n)!==0n&&(t=t*0x31be135f97d08fd981231505542fcfa6n>>128n),(e&0x10000n)!==0n&&(t=t*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(e&0x20000n)!==0n&&(t=t*0x5d6af8dedb81196699c329225ee604n>>128n),(e&0x40000n)!==0n&&(t=t*0x2216e584f5fa1ea926041bedfe98n>>128n),(e&0x80000n)!==0n&&(t=t*0x48a170391f7dc42444e8fa2n>>128n),n>0&&(t=ue/t),(t>>32n)+(t%(1n<<32n)===0n?0n:1n)}async function Z(n,e,t,s){let a=async()=>{throw new o("Price identity resolution is read-only.")},r=B({network:e===f?"testnet":"mainnet",clientFor:i=>t.client??y(t.rpcUrl,i),http:t.http??$(),preview:a,quoteSwap:a,buildSwap:a}),c=await Y(n,{context:r,oakTokenAddress:t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS,officialStockTokens:t.officialStockTokens,tokenMetadata:s,blockNumber:t.blockNumber,readMetadata:async i=>{let d=t.client??y(t.rpcUrl,e),[m,p]=await Promise.all([x(d,e,i,"symbol",t.blockNumber),x(d,e,i,"decimals",t.blockNumber)]);return{address:i,symbol:m,decimals:p,chainId:e}}});return{address:c.address,symbol:c.kind==="erc20"&&s?s.symbol:c.symbol,decimals:c.decimals,chainId:c.chainId}}async function be(n,e,t){if(typeof n=="object"&&n!==null){let i=n.chainId??e,d=S(n.address)===w?w:b(n.address),m={address:d,symbol:n.symbol,decimals:n.decimals,chainId:i};return ne(m)?{address:d,symbol:"USDG",decimals:P,chainId:i}:re(m)?{address:w,symbol:"ETH",decimals:18,chainId:i}:ie(m)?{address:d,symbol:"WETH",decimals:18,chainId:i}:Z(m.address,i,t,m)}let s=n.trim(),a=s.toUpperCase(),r=s.toLowerCase();if(a==="ETH"||J(s,{strict:!1})&&S(s)===w)return{...z,chainId:e};if(a==="WETH"||e===u&&r===O.toLowerCase()||e===f&&r===_.toLowerCase()){if(e!==u&&e!==f)throw new o(`No canonical WETH address configured for chain ${e}.`);return{address:e===f?_:O,symbol:"WETH",decimals:18,chainId:e}}if(a==="USDG"||e===u&&r===R.toLowerCase()||e===f&&r===W.toLowerCase()){if(e!==u&&e!==f)throw new o(`No canonical USDG address configured for chain ${e}.`);return{address:e===f?te:ee,symbol:"USDG",decimals:P,chainId:e}}if(e===u&&(a==="USDE"||r===C.address.toLowerCase()))return{...C,chainId:e};let c=t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS;if(a==="OAK"||c&&s.toLowerCase()===c.toLowerCase()){if(!c&&!J(s,{strict:!1}))throw new o("OAK token address is required to price OAK.");return{address:b(c??s),symbol:"OAK",decimals:H,chainId:e}}return Z(n,e,t)}async function h(n,e,t){if(e)return(await n.readContract({address:e,abi:Q,functionName:"ethUsdE18",blockNumber:t})).toString();let a=(await n.readContract({address:b(K),abi:fe,functionName:"observe",args:[[A,0]],blockNumber:t}))[0];if(!a||a.length<2)throw new o("ETH/USDG pool observation returned insufficient tick cumulatives.");let r=X(a[0],a[1],A),c=le(r);return V(c)}async function D(n,e,t,s){if(n.timestamp!==void 0)return l(n.timestamp,t(),s);if(e&&typeof e.getBlock=="function"){let r=await k(e,n.blockNumber);return l(r.timestamp,t(),s)}let a=t();return l(a,a,s)}async function _e(n,e={}){let t=e.chainId??u,s=e.maxAgeSeconds??M,a=()=>e.now!==void 0?I(e.now,"current"):BigInt(Math.floor(Date.now()/1e3)),r=await be(n,t,e);if((L(r.symbol)||r.symbol.length>256)&&(r.symbol=N(r.symbol)),e.signedNote||e.priceNote){let i=e.signedNote?e.signedNote.note:e.priceNote,d=l(i.timestamp,a(),s);if(e.spotOakPerEthE18!==void 0&&!v(i.oakPerEthE18,e.spotOakPerEthE18))throw new o("Price note is outside the 50% spot guard band.");let m=e.signedNote?.signature??e.signature,p=e.signedNote?.consumer??e.consumer;if(m&&p){let G=await F({note:i,signature:m,consumer:p,signer:e.signer,now:a(),spotOakPerEthE18:e.spotOakPerEthE18,chainId:t});if(!G.valid)throw new o(G.error??"Price note verification failed.")}let E=e.ethUsdE18!==void 0?e.ethUsdE18.toString():await h(e.client??y(e.rpcUrl,t),e.oracleAddress);return{token:r,usdE18:U(E,i.oakPerEthE18),timestamp:d}}if(e.trades){let i=await D(e,e.client,a,s),d=j(e.trades,{now:a(),windowStart:e.windowStart,windowEnd:e.windowEnd});if(e.spotOakPerEthE18!==void 0&&!v(d,e.spotOakPerEthE18))throw new o("30-minute average is outside the 50% spot guard band.");let m=e.ethUsdE18!==void 0?e.ethUsdE18.toString():await h(e.client??y(e.rpcUrl,t),e.oracleAddress);return{token:r,usdE18:U(m,d),timestamp:i}}if(e.usdE18!==void 0){let i=await D(e,e.client,a,s),d=T(e.usdE18.toString());if(d<=0n)throw new o("USD price must be positive.");return{token:r,usdE18:d.toString(),timestamp:i}}if(e.resolver){let i=await e.resolver(r),d=l(i.timestamp,a(),s),m=T(i.usdE18);if(m<=0n)throw new o("USD price must be positive.");return{token:r,usdE18:m.toString(),timestamp:d}}let c=e.client??y(e.rpcUrl,t);if(ne(r)){let i=await D(e,c,a,s);return{token:r,usdE18:oe,timestamp:i}}if(de(r)){let i=await D(e,c,a,s),d=await h(c,e.oracleAddress,e.blockNumber);return{token:r,usdE18:d,timestamp:i}}if(r.chainId===u)try{let i=await k(c,e.blockNumber),d=l(i.timestamp,a(),s);if(i.number===null)throw new o("Pons reference requires a mined block.");let[m,p]=await Promise.all([q(r,c,i.number),h(c,e.oracleAddress,i.number)]),E=T(p)*m.numerator/m.denominator;if(E<=0n)throw new o("Pons USD reference price must be positive.");return{token:r,usdE18:E.toString(),timestamp:d}}catch{}throw new o(`No fresh on-chain price source available for token ${N(r.symbol)} (${r.address}).`)}export{M as a,oe as b,ne as c,re as d,ie as e,de as f,Oe as g,l as h,le as i,_e as j};
@@ -1 +1 @@
1
- import{i as l}from"./E7ASOYQI.js";import{a}from"./5YS5V2LK.js";var m=4295128739n,h=1461446703485210103287273052203988822378723970342n,d=-887272,$=887272;function I(t){if(t<2n)return t;let n=t,i=n+1n>>1n;for(;i<n;)n=i,i=n+t/n>>1n;return n}function w(t,n){if(typeof t!="string"||!/^\d+(?:\.\d+)?$/.test(t.trim()))throw new a(`${n} must be a positive decimal string such as "3000.5".`);let[i,e=""]=t.trim().split("."),r=BigInt(`${i}${e}`);if(r<=0n)throw new a(`${n} must be greater than zero.`);return{n:r,d:10n**BigInt(e.length)}}function _(t,n,i){let{n:e,d:r}=w(t,"initialPrice"),s=e*10n**BigInt(i),o=r*10n**BigInt(n),c=I((s<<192n)/o);return b(c)}function b(t){if(t<m||t>=h)throw new a("Initial price is outside the range Uniswap can represent.");return t}function S(t){b(t);let n=d,i=$;for(;n<i;){let e=Math.ceil((n+i)/2);l(e)<=t?n=e:i=e-1}return n}function f(t,n,i){let r=(t*t*10n**BigInt(n+18)/((1n<<192n)*10n**BigInt(i))).toString().padStart(19,"0"),s=r.slice(0,-18),o=r.slice(-18).replace(/0+$/,"");return o?`${s}.${o}`:s}function x(t,n){let i=t*t,e=n*n;return(i>e?i-e:e-i)*10000n/e}var P=500n;function R(t,n,i,e,r){if(n.length===0)return"No other pool for this pair was found, so the starting price could not be checked against a market. Anyone can trade against a wrong price immediately.";let s=[...n].sort((p,u)=>p.sqrtPriceX96<u.sqrtPriceX96?-1:p.sqrtPriceX96>u.sqrtPriceX96?1:0),o=s[Math.floor(s.length/2)],c=x(t,o.sqrtPriceX96),g=`${f(o.sqrtPriceX96,e,r)} (${o.label})`;if(c>P&&!i)throw new a(`Initial price ${f(t,e,r)} is ${c} bps from the existing market price ${g}. A mispriced new pool is arbitraged against your deposit. Fix the price, or pass acceptPriceDeviation:true if this is intentional.`);return`Existing market price ${g}; starting price deviates ${c} bps.`}function T(t,n){return typeof t=="string"&&/^[A-Za-z0-9][A-Za-z0-9.$_-]{0,15}$/.test(t)?t:`${n.slice(0,6)}\u2026${n.slice(-4)}`}export{m as a,h as b,_ as c,b as d,S as e,f,x as g,P as h,R as i,T as j};
1
+ import{i as l}from"./LFN3OODW.js";import{a}from"./5YS5V2LK.js";var m=4295128739n,h=1461446703485210103287273052203988822378723970342n,d=-887272,$=887272;function I(t){if(t<2n)return t;let n=t,i=n+1n>>1n;for(;i<n;)n=i,i=n+t/n>>1n;return n}function w(t,n){if(typeof t!="string"||!/^\d+(?:\.\d+)?$/.test(t.trim()))throw new a(`${n} must be a positive decimal string such as "3000.5".`);let[i,e=""]=t.trim().split("."),r=BigInt(`${i}${e}`);if(r<=0n)throw new a(`${n} must be greater than zero.`);return{n:r,d:10n**BigInt(e.length)}}function _(t,n,i){let{n:e,d:r}=w(t,"initialPrice"),s=e*10n**BigInt(i),o=r*10n**BigInt(n),c=I((s<<192n)/o);return b(c)}function b(t){if(t<m||t>=h)throw new a("Initial price is outside the range Uniswap can represent.");return t}function S(t){b(t);let n=d,i=$;for(;n<i;){let e=Math.ceil((n+i)/2);l(e)<=t?n=e:i=e-1}return n}function f(t,n,i){let r=(t*t*10n**BigInt(n+18)/((1n<<192n)*10n**BigInt(i))).toString().padStart(19,"0"),s=r.slice(0,-18),o=r.slice(-18).replace(/0+$/,"");return o?`${s}.${o}`:s}function x(t,n){let i=t*t,e=n*n;return(i>e?i-e:e-i)*10000n/e}var P=500n;function R(t,n,i,e,r){if(n.length===0)return"No other pool for this pair was found, so the starting price could not be checked against a market. Anyone can trade against a wrong price immediately.";let s=[...n].sort((p,u)=>p.sqrtPriceX96<u.sqrtPriceX96?-1:p.sqrtPriceX96>u.sqrtPriceX96?1:0),o=s[Math.floor(s.length/2)],c=x(t,o.sqrtPriceX96),g=`${f(o.sqrtPriceX96,e,r)} (${o.label})`;if(c>P&&!i)throw new a(`Initial price ${f(t,e,r)} is ${c} bps from the existing market price ${g}. A mispriced new pool is arbitraged against your deposit. Fix the price, or pass acceptPriceDeviation:true if this is intentional.`);return`Existing market price ${g}; starting price deviates ${c} bps.`}function T(t,n){return typeof t=="string"&&/^[A-Za-z0-9][A-Za-z0-9.$_-]{0,15}$/.test(t)?t:`${n.slice(0,6)}\u2026${n.slice(-4)}`}export{m as a,h as b,_ as c,b as d,S as e,f,x as g,P as h,R as i,T as j};
@@ -1 +1 @@
1
- import{d as R}from"./6SB3FB3P.js";import{H as O,J as L,K as N,b as p,d as l,y as j}from"./FL3EF72E.js";import{a as D,f as H,g as b}from"./ITIIHCZK.js";import{g as d}from"./73N3TOJL.js";import{a as y}from"./XPFVT2EA.js";import{a as e}from"./5YS5V2LK.js";import{decodeAbiParameters as J,decodeFunctionData as A,encodeAbiParameters as K,encodeFunctionData as Q,erc20Abi as W,getAddress as Y,parseAbi as Z,parseAbiParameters as ee}from"viem";var U=Z(["function modifyLiquidities(bytes unlockData,uint256 deadline) payable"]),V=ee("bytes actions,bytes[] params");function de(f,$){return{tools:[{name:"uniswap_batch",inputSchema:{type:"object",additionalProperties:!1,required:["operations"],properties:{operations:{type:"array",minItems:1,maxItems:20,items:{type:"object",additionalProperties:!1,required:["name","arguments"],properties:{name:{type:"string",enum:["uniswap_add","uniswap_collect","uniswap_remove"]},arguments:{anyOf:[O,L,N]}}}}}},async execute(a,v){if(b(a,["operations"]),!Array.isArray(a.operations)||a.operations.length<1||a.operations.length>20)throw new e("Provide 1 to 20 v4 liquidity operations.");let s="0x",c,h=[],P=0n,g=new Map,_=new Set,E=new Set;for(let t of a.operations){if(!t||typeof t!="object"||Array.isArray(t))throw new e("Each operation needs name and arguments.");let o=t;if(b(o,["name","arguments"]),!["uniswap_add","uniswap_collect","uniswap_remove"].includes(String(o.name))||!o.arguments||typeof o.arguments!="object"||Array.isArray(o.arguments))throw new e("Batch supports v4 add, collect and remove operations only.");let r=o.arguments;if(r.version!=="v4")throw new e("Every batch operation must explicitly select version v4.");if(r.initialPrice!==void 0||r.sqrtPriceX96!==void 0)throw new e("Create a pool before batching its liquidity operations.");if(r.tokenId!==void 0){let n=D(r.tokenId,"tokenId").toString();if(E.has(n))throw new e("Batch tokenIds must be distinct decimal strings.");E.add(n)}else if(o.name!=="uniswap_add")throw new e("Existing-position operations require tokenId.");let I=await $.tools.find(n=>n.name===o.name).execute(r,v),u=I.txs.at(-1);if(!u||!d(u.to,p))throw new e("Batch operation returned an unexpected destination.");P+=BigInt(u.value);for(let n of I.txs.slice(0,-1)){if(BigInt(n.value)!==0n)throw new e("Batch prerequisite cannot send native currency.");if(d(n.to,l)){let i=A({abi:R,data:n.data}),[B,G,X,z]=i.args;if(!d(G,p))throw new e("Batch Permit2 spender must be PositionManager.");let T=B.toLowerCase(),m=g.get(T),q=BigInt(z),C=(m?.amount??0n)+X;if(C>=1n<<160n)throw new e("Batch approval exceeds uint160.");g.set(T,{token:B,amount:C,expiration:m&&m.expiration<q?m.expiration:q})}else{let i=A({abi:W,data:n.data});if(i.functionName!=="approve"||!d(i.args[0],l))throw new e("Unexpected batch prerequisite.")}}let S=A({abi:U,data:u.data}),[F,x]=J(V,S.args[0]),k=F.slice(2).match(/../g)??[];if(k.length!==x.length)throw new e("Batch action/parameter count differs.");k.forEach((n,i)=>{n==="14"?_.add(x[i]):(s=`${s}${n}`,h.push(x[i]))});let M=S.args[1];c=c===void 0||M<c?M:c}for(let t of _)s=`${s}14`,h.push(t);let w=[];for(let t of g.values())w.push(f.approval(Y(t.token),l,t.amount.toString(),y),j(t.token,p,t.amount.toString(),t.expiration.toString()));return w.push(f.unsignedTx({to:p,data:Q({abi:U,functionName:"modifyLiquidities",args:[K(V,[s,h]),c]}),value:P.toString(),chainId:y,description:`Atomically modify ${a.operations.length} v4 positions; recipients are the signing wallet.`})),H(f,w,v,"Atomic v4 batch: every operation must succeed. Each position retains its own minimums; preview covers the complete action stream.")}}]}}export{U as a,V as b,de as c};
1
+ import{d as R}from"./DD7755AW.js";import{H as O,J as L,K as N,b as p,d as l,y as j}from"./JG24LNUI.js";import{a as D,f as H,g as b}from"./IAXKPME3.js";import{g as d}from"./73N3TOJL.js";import{a as y}from"./XPFVT2EA.js";import{a as e}from"./5YS5V2LK.js";import{decodeAbiParameters as J,decodeFunctionData as A,encodeAbiParameters as K,encodeFunctionData as Q,erc20Abi as W,getAddress as Y,parseAbi as Z,parseAbiParameters as ee}from"viem";var U=Z(["function modifyLiquidities(bytes unlockData,uint256 deadline) payable"]),V=ee("bytes actions,bytes[] params");function de(f,$){return{tools:[{name:"uniswap_batch",inputSchema:{type:"object",additionalProperties:!1,required:["operations"],properties:{operations:{type:"array",minItems:1,maxItems:20,items:{type:"object",additionalProperties:!1,required:["name","arguments"],properties:{name:{type:"string",enum:["uniswap_add","uniswap_collect","uniswap_remove"]},arguments:{anyOf:[O,L,N]}}}}}},async execute(a,v){if(b(a,["operations"]),!Array.isArray(a.operations)||a.operations.length<1||a.operations.length>20)throw new e("Provide 1 to 20 v4 liquidity operations.");let s="0x",c,h=[],P=0n,g=new Map,_=new Set,E=new Set;for(let t of a.operations){if(!t||typeof t!="object"||Array.isArray(t))throw new e("Each operation needs name and arguments.");let o=t;if(b(o,["name","arguments"]),!["uniswap_add","uniswap_collect","uniswap_remove"].includes(String(o.name))||!o.arguments||typeof o.arguments!="object"||Array.isArray(o.arguments))throw new e("Batch supports v4 add, collect and remove operations only.");let r=o.arguments;if(r.version!=="v4")throw new e("Every batch operation must explicitly select version v4.");if(r.initialPrice!==void 0||r.sqrtPriceX96!==void 0)throw new e("Create a pool before batching its liquidity operations.");if(r.tokenId!==void 0){let n=D(r.tokenId,"tokenId").toString();if(E.has(n))throw new e("Batch tokenIds must be distinct decimal strings.");E.add(n)}else if(o.name!=="uniswap_add")throw new e("Existing-position operations require tokenId.");let I=await $.tools.find(n=>n.name===o.name).execute(r,v),u=I.txs.at(-1);if(!u||!d(u.to,p))throw new e("Batch operation returned an unexpected destination.");P+=BigInt(u.value);for(let n of I.txs.slice(0,-1)){if(BigInt(n.value)!==0n)throw new e("Batch prerequisite cannot send native currency.");if(d(n.to,l)){let i=A({abi:R,data:n.data}),[B,G,X,z]=i.args;if(!d(G,p))throw new e("Batch Permit2 spender must be PositionManager.");let T=B.toLowerCase(),m=g.get(T),q=BigInt(z),C=(m?.amount??0n)+X;if(C>=1n<<160n)throw new e("Batch approval exceeds uint160.");g.set(T,{token:B,amount:C,expiration:m&&m.expiration<q?m.expiration:q})}else{let i=A({abi:W,data:n.data});if(i.functionName!=="approve"||!d(i.args[0],l))throw new e("Unexpected batch prerequisite.")}}let S=A({abi:U,data:u.data}),[F,x]=J(V,S.args[0]),k=F.slice(2).match(/../g)??[];if(k.length!==x.length)throw new e("Batch action/parameter count differs.");k.forEach((n,i)=>{n==="14"?_.add(x[i]):(s=`${s}${n}`,h.push(x[i]))});let M=S.args[1];c=c===void 0||M<c?M:c}for(let t of _)s=`${s}14`,h.push(t);let w=[];for(let t of g.values())w.push(f.approval(Y(t.token),l,t.amount.toString(),y),j(t.token,p,t.amount.toString(),t.expiration.toString()));return w.push(f.unsignedTx({to:p,data:Q({abi:U,functionName:"modifyLiquidities",args:[K(V,[s,h]),c]}),value:P.toString(),chainId:y,description:`Atomically modify ${a.operations.length} v4 positions; recipients are the signing wallet.`})),H(f,w,v,"Atomic v4 batch: every operation must succeed. Each position retains its own minimums; preview covers the complete action stream.")}}]}}export{U as a,V as b,de as c};