@oakagentkit/core 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/build/dist/api/history.js +1 -1
  2. package/build/dist/api/modules/borro/actions.js +1 -1
  3. package/build/dist/api/modules/borro/checks.js +1 -1
  4. package/build/dist/api/modules/borro/copy.d.ts +4 -4
  5. package/build/dist/api/modules/borro/copy.js +1 -1
  6. package/build/dist/api/modules/borro/index.js +1 -1
  7. package/build/dist/api/modules/borro/liquidity.js +1 -1
  8. package/build/dist/api/modules/borro/positions.js +1 -1
  9. package/build/dist/api/modules/borro/reader.d.ts +6 -2
  10. package/build/dist/api/modules/borro/reader.js +1 -1
  11. package/build/dist/api/modules/borro/types.d.ts +6 -0
  12. package/build/dist/api/modules/chop/abi.d.ts +527 -0
  13. package/build/dist/api/modules/chop/abi.js +1 -0
  14. package/build/dist/api/modules/chop/actions.d.ts +24 -0
  15. package/build/dist/api/modules/chop/actions.js +1 -0
  16. package/build/dist/api/modules/chop/checks.d.ts +26 -0
  17. package/build/dist/api/modules/chop/checks.js +1 -0
  18. package/build/dist/api/modules/chop/copy.d.ts +5 -0
  19. package/build/dist/api/modules/chop/copy.js +1 -0
  20. package/build/dist/api/modules/chop/guard.d.ts +13 -0
  21. package/build/dist/api/modules/chop/guard.js +1 -0
  22. package/build/dist/api/modules/chop/index.d.ts +3 -0
  23. package/build/dist/api/modules/chop/index.js +1 -0
  24. package/build/dist/api/modules/chop/pins.d.ts +53 -0
  25. package/build/dist/api/modules/chop/pins.js +1 -0
  26. package/build/dist/api/modules/chop/positions.d.ts +3 -0
  27. package/build/dist/api/modules/chop/positions.js +1 -0
  28. package/build/dist/api/modules/chop/reader.d.ts +70 -0
  29. package/build/dist/api/modules/chop/reader.js +1 -0
  30. package/build/dist/api/modules/chop/types.d.ts +32 -0
  31. package/build/dist/api/modules/chop/types.js +0 -0
  32. package/build/dist/api/modules/clanker/index.js +1 -1
  33. package/build/dist/api/modules/earn/index.js +1 -1
  34. package/build/dist/api/modules/erc8004/index.js +1 -1
  35. package/build/dist/api/modules/gloam/abi.d.ts +89 -0
  36. package/build/dist/api/modules/gloam/abi.js +1 -0
  37. package/build/dist/api/modules/gloam/actions.d.ts +5 -0
  38. package/build/dist/api/modules/gloam/actions.js +1 -0
  39. package/build/dist/api/modules/gloam/checks.d.ts +17 -0
  40. package/build/dist/api/modules/gloam/checks.js +1 -0
  41. package/build/dist/api/modules/gloam/copy.d.ts +22 -0
  42. package/build/dist/api/modules/gloam/copy.js +2 -0
  43. package/build/dist/api/modules/gloam/index.d.ts +6 -0
  44. package/build/dist/api/modules/gloam/index.js +1 -0
  45. package/build/dist/api/modules/gloam/pins.d.ts +41 -0
  46. package/build/dist/api/modules/gloam/pins.js +1 -0
  47. package/build/dist/api/modules/gloam/types.d.ts +308 -0
  48. package/build/dist/api/modules/gloam/types.js +1 -0
  49. package/build/dist/api/modules/grove/index.js +1 -1
  50. package/build/dist/api/modules/heyresearch/index.js +1 -1
  51. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  52. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  53. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  54. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  55. package/build/dist/api/modules/hoodlock/index.js +1 -1
  56. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  57. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  58. package/build/dist/api/modules/hoodlock/public.js +1 -1
  59. package/build/dist/api/modules/hookr/actions.js +1 -1
  60. package/build/dist/api/modules/hookr/addons.js +1 -1
  61. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  62. package/build/dist/api/modules/hookr/contracts.js +1 -1
  63. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  64. package/build/dist/api/modules/hookr/discovery.js +1 -1
  65. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  66. package/build/dist/api/modules/hookr/index.js +1 -1
  67. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  68. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  69. package/build/dist/api/modules/hookr/launch.js +1 -1
  70. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  71. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  72. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  73. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  74. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  75. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  76. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  77. package/build/dist/api/modules/hookr/relay.js +1 -1
  78. package/build/dist/api/modules/kyberswap/index.js +1 -1
  79. package/build/dist/api/modules/layerbank/actions.js +1 -1
  80. package/build/dist/api/modules/layerbank/index.js +1 -1
  81. package/build/dist/api/modules/layerbank/reader.js +1 -1
  82. package/build/dist/api/modules/longbow/administration.js +1 -1
  83. package/build/dist/api/modules/longbow/fixed.js +1 -1
  84. package/build/dist/api/modules/longbow/index.js +1 -1
  85. package/build/dist/api/modules/meridian/index.js +1 -1
  86. package/build/dist/api/modules/meridian/rfq.js +1 -1
  87. package/build/dist/api/modules/merkl/discovery.js +1 -1
  88. package/build/dist/api/modules/merkl/index.js +1 -1
  89. package/build/dist/api/modules/merkl/manage.js +1 -1
  90. package/build/dist/api/modules/morpho/bundles.js +1 -1
  91. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  92. package/build/dist/api/modules/morpho/index.js +1 -1
  93. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  94. package/build/dist/api/modules/morpho/midnight.js +1 -1
  95. package/build/dist/api/modules/morpho/protocol.js +1 -1
  96. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  97. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  98. package/build/dist/api/modules/netnet/card-read.js +1 -1
  99. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  100. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  101. package/build/dist/api/modules/netnet/financial.js +1 -1
  102. package/build/dist/api/modules/netnet/index.js +1 -1
  103. package/build/dist/api/modules/orbio/index.js +1 -1
  104. package/build/dist/api/modules/pendle/index.js +1 -1
  105. package/build/dist/api/modules/pendle/reader.js +1 -1
  106. package/build/dist/api/modules/pons/claim.js +1 -1
  107. package/build/dist/api/modules/pons/index.js +1 -1
  108. package/build/dist/api/modules/pons/launch-status.d.ts +1 -0
  109. package/build/dist/api/modules/pons/launch-status.js +1 -1
  110. package/build/dist/api/modules/pons/reads.js +1 -1
  111. package/build/dist/api/modules/pons/trade.js +1 -1
  112. package/build/dist/api/modules/poolstrade/index.js +1 -1
  113. package/build/dist/api/modules/priors/coverage.js +1 -1
  114. package/build/dist/api/modules/priors/discovery.js +1 -1
  115. package/build/dist/api/modules/priors/index.js +1 -1
  116. package/build/dist/api/modules/priors/integration.js +1 -1
  117. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  118. package/build/dist/api/modules/relay/discovery.js +1 -1
  119. package/build/dist/api/modules/relay/inbound.js +1 -1
  120. package/build/dist/api/modules/relay/index.js +1 -1
  121. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  122. package/build/dist/api/modules/spark/index.js +1 -1
  123. package/build/dist/api/modules/steakhouse/index.js +1 -1
  124. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  125. package/build/dist/api/modules/steakhouse/management.js +1 -1
  126. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  127. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  128. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  129. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  130. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  131. package/build/dist/api/modules/tickerspring/index.js +1 -1
  132. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  133. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  134. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  135. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  136. package/build/dist/api/modules/tickerspring/research.js +1 -1
  137. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  138. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  139. package/build/dist/api/modules/uniswap/auction.js +1 -1
  140. package/build/dist/api/modules/uniswap/batch.js +1 -1
  141. package/build/dist/api/modules/uniswap/common.js +1 -1
  142. package/build/dist/api/modules/uniswap/fees.js +1 -1
  143. package/build/dist/api/modules/uniswap/index.js +1 -1
  144. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  145. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  146. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  147. package/build/dist/api/modules/uniswap/pools.js +1 -1
  148. package/build/dist/api/modules/uniswap/position.js +1 -1
  149. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  150. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  151. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  152. package/build/dist/api/modules/uniswap/trade.js +1 -1
  153. package/build/dist/api/modules/uniswap/v2.js +1 -1
  154. package/build/dist/api/modules/uniswap/v3.js +1 -1
  155. package/build/dist/api/modules/uniswap/v4.js +1 -1
  156. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  157. package/build/dist/api/modules/velora/claims.js +1 -1
  158. package/build/dist/api/modules/velora/index.js +1 -1
  159. package/build/dist/api/modules/wormhole/index.d.ts +3 -0
  160. package/build/dist/api/modules/wormhole/index.js +1 -1
  161. package/build/dist/api/modules/wormhole/swap-token-verdict.d.ts +11 -0
  162. package/build/dist/api/modules/wormhole/swap-token-verdict.js +1 -0
  163. package/build/dist/api/modules/wormhole/third-party-text.d.ts +13 -0
  164. package/build/dist/api/modules/wormhole/third-party-text.js +1 -0
  165. package/build/dist/api/modules/wormhole/token-check.d.ts +2 -0
  166. package/build/dist/api/modules/wormhole/token-check.js +1 -1
  167. package/build/dist/api/modules/wormhole/x402-client.d.ts +36 -0
  168. package/build/dist/api/modules/wormhole/x402-client.js +1 -0
  169. package/build/dist/api/prices.js +1 -1
  170. package/build/dist/api/send.js +1 -1
  171. package/build/dist/api/signing-registry.js +1 -1
  172. package/build/dist/api/simulate.js +1 -1
  173. package/build/dist/api/swap.js +1 -1
  174. package/build/dist/api/tokens.js +1 -1
  175. package/build/dist/api/tool-policy.js +1 -1
  176. package/build/dist/api/types.d.ts +6 -1
  177. package/build/dist/chunks/{3FUVMSCF.js → 2MT3G7YZ.js} +1 -1
  178. package/build/dist/chunks/{GEIFITAQ.js → 2THSW4QN.js} +1 -1
  179. package/build/dist/chunks/{GQ5GYUEH.js → 2VXLVXIB.js} +1 -1
  180. package/build/dist/chunks/{HCUHMCBW.js → 35KR3VSS.js} +1 -1
  181. package/build/dist/chunks/{P7I62KFR.js → 3GQ7A3VB.js} +1 -1
  182. package/build/dist/chunks/3VWVW7PX.js +1 -0
  183. package/build/dist/chunks/4DP2VPXR.js +3 -0
  184. package/build/dist/chunks/{MR5L7V6Z.js → 4EN6MQEI.js} +1 -1
  185. package/build/dist/chunks/{LSXUAHOE.js → 4I3OU56B.js} +1 -1
  186. package/build/dist/chunks/{NEEZBJBC.js → 5AXWBSPG.js} +1 -1
  187. package/build/dist/chunks/{VY7XRHZQ.js → 5N3O42X6.js} +1 -1
  188. package/build/dist/chunks/{X3PQMS4N.js → 5SZPNZG4.js} +1 -1
  189. package/build/dist/chunks/{VYN2NRAP.js → 6JAXZNZ3.js} +1 -1
  190. package/build/dist/chunks/{APGLZXIW.js → 6O3Q5B6M.js} +1 -1
  191. package/build/dist/chunks/6YB3VOUL.js +1 -0
  192. package/build/dist/chunks/77CLMPM7.js +1 -0
  193. package/build/dist/chunks/{GL4NCUMH.js → 7GJ6SLEV.js} +1 -1
  194. package/build/dist/chunks/{57MEFFCU.js → 7KWZ5QJU.js} +1 -1
  195. package/build/dist/chunks/{326QMOTR.js → 7QIO77VE.js} +1 -1
  196. package/build/dist/chunks/7QZOTRSA.js +2 -0
  197. package/build/dist/chunks/{UHVSINR5.js → A7I4IWUB.js} +1 -1
  198. package/build/dist/chunks/{6PBGEPUK.js → ACW63WIL.js} +4 -4
  199. package/build/dist/chunks/{P56RZC2M.js → AEL62KCG.js} +1 -1
  200. package/build/dist/chunks/{6B3VVISQ.js → ALLLYOUG.js} +1 -1
  201. package/build/dist/chunks/APQYLJGS.js +1 -0
  202. package/build/dist/chunks/{FQ6UZCM6.js → AW7AXQCZ.js} +1 -1
  203. package/build/dist/chunks/{T3AJSQYT.js → AXRL3REN.js} +1 -1
  204. package/build/dist/chunks/{INOZIE55.js → BBTPRZ6T.js} +1 -1
  205. package/build/dist/chunks/{WDK6VOG4.js → BND2UFVW.js} +1 -1
  206. package/build/dist/chunks/{3NJ5KQ3Q.js → BOVMED7R.js} +1 -1
  207. package/build/dist/chunks/{74Y2KDNR.js → CBLMQ5UU.js} +1 -1
  208. package/build/dist/chunks/CDPSMI3Z.js +1 -0
  209. package/build/dist/chunks/{XR7VK24E.js → CQEJSCFQ.js} +1 -1
  210. package/build/dist/chunks/{GW626GG2.js → DBNTZEAJ.js} +1 -1
  211. package/build/dist/chunks/{SSHCD6RZ.js → DHUDSOGR.js} +1 -1
  212. package/build/dist/chunks/{3GOHSYHW.js → DL6AEWEM.js} +1 -1
  213. package/build/dist/chunks/{UMIZMJWW.js → EGYVRQUR.js} +1 -1
  214. package/build/dist/chunks/{Y25EXZCO.js → FEYAY6OZ.js} +1 -1
  215. package/build/dist/chunks/FIO6VC2J.js +1 -0
  216. package/build/dist/chunks/FJ4S4GHY.js +1 -0
  217. package/build/dist/chunks/{X3BYCOWS.js → FUDAXV5X.js} +1 -1
  218. package/build/dist/chunks/{Z43BTOTE.js → GG6Y4OCJ.js} +1 -1
  219. package/build/dist/chunks/{ELSXLZN5.js → GGHBFLRC.js} +1 -1
  220. package/build/dist/chunks/{L4N2RSK2.js → GRQYTVNT.js} +1 -1
  221. package/build/dist/chunks/{2MAMJJJC.js → GSBIERZD.js} +1 -1
  222. package/build/dist/chunks/{J2OT4KAH.js → H6T5FXEX.js} +1 -1
  223. package/build/dist/chunks/HHXBUYHO.js +1 -0
  224. package/build/dist/chunks/{MJ6WEWMI.js → HQUVB7Z5.js} +1 -1
  225. package/build/dist/chunks/HS4DZPYT.js +1 -0
  226. package/build/dist/chunks/{S7IFAQPG.js → HU7IMNBI.js} +1 -1
  227. package/build/dist/chunks/{5APS4T2D.js → HWX36XJI.js} +1 -1
  228. package/build/dist/chunks/I55MURSJ.js +1 -0
  229. package/build/dist/chunks/I6PQW2JI.js +1 -0
  230. package/build/dist/chunks/{KIFSRO5K.js → IPN6Z4JM.js} +1 -1
  231. package/build/dist/chunks/{NDCLTVIU.js → IPRVIKYC.js} +1 -1
  232. package/build/dist/chunks/{VJS4DHQQ.js → IVX4R5OL.js} +1 -1
  233. package/build/dist/chunks/JFYBH3DX.js +1 -0
  234. package/build/dist/chunks/JQOQMFWD.js +3 -0
  235. package/build/dist/chunks/{BJ2VGRF4.js → JZS3E66E.js} +1 -1
  236. package/build/dist/chunks/{W6BS3T7S.js → KVFZKPJT.js} +1 -1
  237. package/build/dist/chunks/{QZZ4O34L.js → LKXO2BQS.js} +1 -1
  238. package/build/dist/chunks/{BBS3ODWZ.js → LKZX4CAA.js} +1 -1
  239. package/build/dist/chunks/{H2XDMFQQ.js → LYMNHO5T.js} +1 -1
  240. package/build/dist/chunks/{KPCY5V35.js → M2UXYCKH.js} +1 -1
  241. package/build/dist/chunks/{ZMFRMWHR.js → M6LC6DRE.js} +1 -1
  242. package/build/dist/chunks/{VOMGT5SG.js → MOE3EVAL.js} +1 -1
  243. package/build/dist/chunks/{2KYAMXTS.js → NOFUKKP5.js} +1 -1
  244. package/build/dist/chunks/{AVG4W3Y7.js → O6ROOKY2.js} +1 -1
  245. package/build/dist/chunks/{BTD5SMOW.js → OLSP46ZD.js} +1 -1
  246. package/build/dist/chunks/{E674J2MD.js → OOZSE2R7.js} +1 -1
  247. package/build/dist/chunks/{P3S4BR5G.js → P5AJSLZ7.js} +1 -1
  248. package/build/dist/chunks/{RQ4GHJXE.js → PACN53TR.js} +1 -1
  249. package/build/dist/chunks/{U67J4BCH.js → PAHXBLCS.js} +1 -1
  250. package/build/dist/chunks/PAY5PD4H.js +1 -0
  251. package/build/dist/chunks/{T2WHOZXM.js → PIIHOXWF.js} +1 -1
  252. package/build/dist/chunks/{HSCQZ66A.js → PNA6UIE5.js} +1 -1
  253. package/build/dist/chunks/{X2KFXCVD.js → PZGGE5D3.js} +1 -1
  254. package/build/dist/chunks/{553UE2ZQ.js → QA2RRIES.js} +1 -1
  255. package/build/dist/chunks/{Z4FZVJ5Z.js → QBIY6FQN.js} +1 -1
  256. package/build/dist/chunks/{D3YLXQPW.js → QFNT73OF.js} +1 -1
  257. package/build/dist/chunks/QHBS3PVU.js +1 -0
  258. package/build/dist/chunks/QW2OPEYJ.js +1 -0
  259. package/build/dist/chunks/{YWRDZQI6.js → QYVREJYC.js} +1 -1
  260. package/build/dist/chunks/{W2BYU5JQ.js → ROFPXEQ5.js} +1 -1
  261. package/build/dist/chunks/{OKUO3BVM.js → RTAHNWHN.js} +1 -1
  262. package/build/dist/chunks/{UHTRW2R6.js → RTGS7RIO.js} +1 -1
  263. package/build/dist/chunks/{CCTXCMH4.js → S5CBVFHY.js} +1 -1
  264. package/build/dist/chunks/{JVLLVNF2.js → T7TFUH5K.js} +1 -1
  265. package/build/dist/chunks/{OJPG45AC.js → TPBAFS7K.js} +1 -1
  266. package/build/dist/chunks/{B3RXD5ET.js → U2RMUVVY.js} +1 -1
  267. package/build/dist/chunks/{4MXM6Q4W.js → UD2XMNIT.js} +1 -1
  268. package/build/dist/chunks/V5JWGWXC.js +1 -0
  269. package/build/dist/chunks/VCOTCVKN.js +1 -0
  270. package/build/dist/chunks/{QO3KCJMP.js → VNV6ZISN.js} +1 -1
  271. package/build/dist/chunks/{TM2XCRU7.js → X2P55AC3.js} +1 -1
  272. package/build/dist/chunks/XD6X3KTC.js +1 -0
  273. package/build/dist/chunks/{C36BFZH6.js → XKSVTN5X.js} +1 -1
  274. package/build/dist/chunks/{IY7BXLT4.js → XL3LLGIR.js} +1 -1
  275. package/build/dist/chunks/XQA5LCL6.js +1 -0
  276. package/build/dist/chunks/{S47VUTHM.js → XSKFKBDR.js} +1 -1
  277. package/build/dist/chunks/{6D5DJA5B.js → YRNXGQJC.js} +1 -1
  278. package/build/dist/chunks/YWRLY5EA.js +1 -0
  279. package/build/dist/chunks/YWSX6IE6.js +1 -0
  280. package/build/dist/chunks/{QF52OIBS.js → Z6LZGCVW.js} +1 -1
  281. package/build/dist/chunks/{45BRW2ZF.js → ZQWZGH7V.js} +1 -1
  282. package/build/dist/chunks/{HAQPIBYR.js → ZXJ24B4L.js} +1 -1
  283. package/package.json +1 -1
  284. package/build/dist/chunks/3MLUCYCB.js +0 -1
  285. package/build/dist/chunks/3XXBLNEX.js +0 -1
  286. package/build/dist/chunks/4PY3UFNR.js +0 -1
  287. package/build/dist/chunks/EE64JSLY.js +0 -1
  288. package/build/dist/chunks/EJ7O75A7.js +0 -1
  289. package/build/dist/chunks/QC3HH5UD.js +0 -3
  290. package/build/dist/chunks/QSHCBASA.js +0 -1
  291. package/build/dist/chunks/XLOYBLFI.js +0 -1
@@ -1,6 +1,6 @@
1
- import{a as _,b as r}from"./JUZ5JU6D.js";function o(e){return{text:e}}var y="borro.markets",p=o("Borro: lend your {symbol} to borrowers through Borro's vault."),f=o("Borro is a separate project run by its own team. Oak didn't build it."),w=o("Borro keeps {fee_pct}% of the interest as its fee."),k=o("Borro keeps part of the interest as its fee, and I couldn't read how much."),R=o("Reward: about {borro_rate}% a year today, which changes. {fee_clause} {comparison_clause}"),E=o("Reward: lending {symbol} pays about {borro_rate}% a year today, which changes. {fee_clause}"),x=o("Reward: lending {symbol} pays about {borro_rate}% a year today, which is close to nothing and changes. {fee_clause}"),h=o("Borro's page didn't give a rate I can check, so I can't tell you what this pays today."),A=o(`Reward: ${h.text} {fee_clause}`),b=o("The catch: you are lending {symbol}, a stock token, not dollars. If its price falls, what you get back is worth less in dollars, even though the {symbol} count is what you lent. The company that issues the token can also pause or restrict it."),O=o("LayerBank on Robinhood Chain pays about {lb_rate}% a year on USDG today, so LayerBank pays more."),S=o("LayerBank on Robinhood Chain pays about {lb_rate}% a year on USDG today, so Borro pays more."),N=o("LayerBank on Robinhood Chain pays about {lb_rate}% a year on USDG today, so they pay about the same."),T=o("I couldn't read {the_other} rate, so I can't compare them right now."),C=o("Borro is {age_phrase} old and has had no outside security check"),I=o("Borro's age couldn't be read, and it has had no outside security check"),v=o("A {threshold}-of-{owners} group wallet"),B=o("A wallet Oak could not inspect"),D=o("{age_clause}; its own page says only internal reviews were done. {controller_clause} controls the vault and can change where the money is lent. If Borro's code fails, or the people who control it make a harmful change, you could lose money."),U=o("Risk: {risk_clause}"),L=o(`Taking it out: you can take your money out when the vault has cash on hand. Right now about {ready} {symbol} of the {total} {symbol} lent in is ready; the rest is out with borrowers and can take time to come back. You can also take it out on ${y} with this wallet.`),P=o(`Taking it out: you can take your money out when the vault has cash on hand. I couldn't read how much is ready to take out right now; money that is out with borrowers can take time to come back. You can also take it out on ${y} with this wallet.`),F=o("Cost: about {gas_in_usd} in network fees to put it in and about {gas_out_usd} to take it out."),K=o("Cost: I couldn't read the network fees right now."),W=o("Rates shown leave out any $BORRO incentive."),$=o(`Lend {amount} {symbol} to Borro?
1
+ import{a as _,b as r}from"./JUZ5JU6D.js";function o(e){return{text:e}}var y="borro.markets",p=o("Borro: lend your {symbol} to borrowers through Borro's vault."),f=o("Borro is an official Oak partner. Borro's own team runs its product and contracts; Oak didn't build them and doesn't run them."),w=o("Borro keeps {fee_pct}% of the interest as its fee."),k=o("Borro keeps part of the interest as its fee, and I couldn't read how much."),R=o("Reward: about {borro_rate}% a year today, which changes. {fee_clause} {comparison_clause}"),E=o("Reward: lending {symbol} pays about {borro_rate}% a year today, which changes. {fee_clause}"),x=o("Reward: lending {symbol} pays about {borro_rate}% a year today, which is close to nothing and changes. {fee_clause}"),h=o("Borro's page didn't give a rate I can check, so I can't tell you what this pays today."),A=o(`Reward: ${h.text} {fee_clause}`),b=o("The catch: you are lending {symbol}, a stock token, not dollars. If its price falls, what you get back is worth less in dollars, even though the {symbol} count is what you lent. The company that issues the token can also pause or restrict it."),O=o("LayerBank on Robinhood Chain pays about {lb_rate}% a year on USDG today, so LayerBank pays more."),S=o("LayerBank on Robinhood Chain pays about {lb_rate}% a year on USDG today, so Borro pays more."),N=o("LayerBank on Robinhood Chain pays about {lb_rate}% a year on USDG today, so they pay about the same."),T=o("I couldn't read {the_other} rate, so I can't compare them right now."),C=o("Borro is {age_phrase} old and has had no outside security check"),I=o("Borro's age couldn't be read, and it has had no outside security check"),v=o("A {threshold}-of-{owners} group wallet"),B=o("A wallet Oak could not inspect"),D=o("{age_clause}; its own page says only internal reviews were done. {controller_clause} controls the vault and can change where the money is lent. If Borro's code fails, or the people who control it make a harmful change, you could lose money."),U=o("Risk: {risk_clause}"),L=o(`Taking it out: you can take your money out when the vault has cash on hand. Right now about {ready} {symbol} of the {total} {symbol} lent in is ready; the rest is out with borrowers and can take time to come back. You can also take it out on ${y} with this wallet.`),P=o(`Taking it out: you can take your money out when the vault has cash on hand. I couldn't read how much is ready to take out right now; money that is out with borrowers can take time to come back. You can also take it out on ${y} with this wallet.`),F=o("Cost: about {gas_in_usd} in network fees to put it in and about {gas_out_usd} to take it out."),K=o("Cost: I couldn't read the network fees right now."),W=o("Rates shown leave out any $BORRO incentive."),$=o(`Lend {amount} {symbol} to Borro?
2
2
 
3
- Borro is a separate project run by its own team. Oak didn't build it.
3
+ Borro is an official Oak partner. Borro's own team runs its product and contracts; Oak didn't build them and doesn't run them.
4
4
  What you get: {reward_clause} {stock_catch_clause}
5
5
  What happens: {amount} {symbol} leaves your wallet and becomes about {shares} "{vault_symbol}" tokens, your receipt for money lent through Borro. Oak accepts no fewer than {shares_min}.
6
6
  The risk: {risk_clause}
@@ -14,7 +14,7 @@ You get back about {out} {symbol} for {shares} "{vault_symbol}" tokens (what you
14
14
  {drift_notice}
15
15
  {cost_line}
16
16
 
17
- Take it out? [Yes] [No]`),j=o("Borro's vault only has about {ready} {symbol} ready right now, so I can take out {max_now} {symbol} today. Say so if you want that smaller amount."),V=o("Cost: about {gas_out_usd} in network fees."),z=o("Borro's setup has changed since Oak checked it; the exit below was checked against the live contract."),Z=o("I could not verify {vault_label} on chain, so Oak won't offer it. Nothing was signed."),Q=o("Borro's setup no longer matches what Oak checked. Nothing was signed."),J=o("Borro only has {ready} {symbol} ready to take out right now, and you asked for {requested} {symbol}. I can take out {max_now} {symbol} now, or you can wait for more to come back."),X=o("Borro only has {ready} {symbol} ready to take out right now, and you asked for {requested} {symbol}. None can be taken out today, so you can wait for more to come back."),tt=o("This wallet has nothing lent on Borro for {symbol}."),et=o("Borro's vault wouldn't take this deposit right now (it may be full or paused). Nothing was signed."),ot=o("New on Borro: the {symbol} vault. Oak checked it on the chain just now and it passes Oak's checks."),nt=o(`If you also borrowed, shorted or used credit on ${y}, Oak's view doesn't include that.`),pt={CARD_INTRO:p,INDEPENDENCE:f,FEE_CLAUSE:w,FEE_CLAUSE_UNREADABLE:k,REWARD_USDG:R,REWARD_STOCK:E,REWARD_STOCK_LOW:x,RATE_UNREADABLE:h,REWARD_UNREADABLE:A,STOCK_CATCH:b,COMPARE_LAYERBANK_HIGHER:O,COMPARE_BORRO_HIGHER:S,COMPARE_SAME:N,COMPARE_UNREADABLE:T,AGE_CLAUSE:C,AGE_CLAUSE_UNKNOWN:I,CONTROLLER_SAFE:v,CONTROLLER_UNKNOWN:B,RISK_CLAUSE:D,RISK_LINE:U,TAKING_OUT:L,TAKING_OUT_UNREADABLE:P,CARD_COST:F,COST_UNREADABLE:K,NOTES_INCENTIVE:W,DEPOSIT_SCREEN:$,SCREEN_REWARD:M,SCREEN_TAKING_OUT:q,SCREEN_TAKING_OUT_UNREADABLE:G,DEPOSIT_COST:Y,WITHDRAW_SCREEN:H,LIQUIDITY_NOTE:j,WITHDRAW_COST:V,DRIFT_NOTICE:z,UNVERIFIED_REFUSAL:Z,SETUP_MISMATCH:Q,TOO_LITTLE_READY:J,NOTHING_READY:X,NO_SHARES:tt,DEPOSIT_WOULD_REVERT:et,NEW_VAULT_NOTICE:ot,POSITIONS_NOTE:nt},ft=[/\bours?\b/i,/\bpartner/i,/\bbuilt by\b/i,/\bOak's Borro\b/i,/\bour (?:vault|project)/i,/\bSafe\b/,/\bRobinhood\b(?! Chain)/,/\bfork\b/i,/\bpractice copy\b/i,/\banvil\b/i,/evm_increaseTime/i,/\bunlisted\b/i,/\bpinned\b/i];function c(e){return e.toFixed(2).replace(/\.?0+$/,"")}function l(e){return typeof e=="number"&&Number.isFinite(e)}var m=/^[A-Za-z0-9.$_-]{1,16}$/,lt=/^0x[0-9a-fA-F]{40}$/;function u(e){if(!m.test(e))throw new Error("Borro copy refused an asset symbol that is not a plain token symbol.");return e}function rt(e){return m.test(e)?e:"Borro vault shares"}function d(e,t){let n=t,s=[];for(let a of e.text.split(`
17
+ Take it out? [Yes] [No]`),V=o("Borro's vault only has about {ready} {symbol} ready right now, so I can take out {max_now} {symbol} today. Say so if you want that smaller amount."),j=o("Cost: about {gas_out_usd} in network fees."),z=o("Borro's setup has changed since Oak checked it; the exit below was checked against the live contract."),Z=o("I could not verify {vault_label} on chain, so Oak won't offer it. Nothing was signed."),Q=o("Borro's setup no longer matches what Oak checked. Nothing was signed."),J=o("Borro only has {ready} {symbol} ready to take out right now, and you asked for {requested} {symbol}. I can take out {max_now} {symbol} now, or you can wait for more to come back."),X=o("Borro only has {ready} {symbol} ready to take out right now, and you asked for {requested} {symbol}. None can be taken out today, so you can wait for more to come back."),tt=o("This wallet has nothing lent on Borro for {symbol}."),et=o("Borro's vault wouldn't take this deposit right now (it may be full or paused). Nothing was signed."),ot=o("New on Borro: the {symbol} vault. Oak checked it on the chain just now and it passes Oak's checks."),nt=o(`If you also borrowed, shorted or used credit on ${y}, Oak's view doesn't include that.`),pt={CARD_INTRO:p,INDEPENDENCE:f,FEE_CLAUSE:w,FEE_CLAUSE_UNREADABLE:k,REWARD_USDG:R,REWARD_STOCK:E,REWARD_STOCK_LOW:x,RATE_UNREADABLE:h,REWARD_UNREADABLE:A,STOCK_CATCH:b,COMPARE_LAYERBANK_HIGHER:O,COMPARE_BORRO_HIGHER:S,COMPARE_SAME:N,COMPARE_UNREADABLE:T,AGE_CLAUSE:C,AGE_CLAUSE_UNKNOWN:I,CONTROLLER_SAFE:v,CONTROLLER_UNKNOWN:B,RISK_CLAUSE:D,RISK_LINE:U,TAKING_OUT:L,TAKING_OUT_UNREADABLE:P,CARD_COST:F,COST_UNREADABLE:K,NOTES_INCENTIVE:W,DEPOSIT_SCREEN:$,SCREEN_REWARD:M,SCREEN_TAKING_OUT:q,SCREEN_TAKING_OUT_UNREADABLE:G,DEPOSIT_COST:Y,WITHDRAW_SCREEN:H,LIQUIDITY_NOTE:V,WITHDRAW_COST:j,DRIFT_NOTICE:z,UNVERIFIED_REFUSAL:Z,SETUP_MISMATCH:Q,TOO_LITTLE_READY:J,NOTHING_READY:X,NO_SHARES:tt,DEPOSIT_WOULD_REVERT:et,NEW_VAULT_NOTICE:ot,POSITIONS_NOTE:nt},ft=[/\bours?\b/i,/\bOak (?:owns?|runs?|operates?|built) Borro\b/i,/\bbuilt by\b/i,/\bOak's Borro\b/i,/\bour (?:vault|project)/i,/\bSafe\b/,/\bRobinhood\b(?! Chain)/,/\bfork\b/i,/\bpractice copy\b/i,/\banvil\b/i,/evm_increaseTime/i,/\bunlisted\b/i,/\bpinned\b/i];function c(e){return e.toFixed(2).replace(/\.?0+$/,"")}function l(e){return typeof e=="number"&&Number.isFinite(e)}var m=/^[A-Za-z0-9.$_-]{1,16}$/,lt=/^0x[0-9a-fA-F]{40}$/;function u(e){if(!m.test(e))throw new Error("Borro copy refused an asset symbol that is not a plain token symbol.");return e}function rt(e){return m.test(e)?e:"Borro vault shares"}function d(e,t){let n=t,s=[];for(let a of e.text.split(`
18
18
  `)){let i=/^\{([a-z][a-z0-9_]*)\}$/.exec(a);i&&n[i[1]]===""||s.push(r(o(a),n).trimEnd())}return s.join(`
19
19
  `)}var ut=86400;function dt(e,t){if(!l(e)||!Number.isFinite(t)||e<=0)return;let n=(t-e)/ut;if(!(n<0)){if(n<1)return"under a day";if(n<14){let s=Math.floor(n);return s===1?"1 day":`${s} days`}return n<45?"about a month":`about ${Math.max(2,Math.round(n/30))} months`}}var ct=.05;function yt(e,t){let n=l(e),s=l(t);if(!n||!s)return r(T,{the_other:!n&&!s?"either":n?"LayerBank's":"Borro's"});let a=c(t),i=e-t;return Math.abs(i)<ct?r(N,{lb_rate:a}):r(i>0?S:O,{lb_rate:a})}function st(e){let t=dt(e.deployedAtSeconds,e.nowSeconds),n=t===void 0?r(I,{}):r(C,{age_phrase:t}),a=Number.isInteger(e.threshold)&&Number.isInteger(e.owners)&&e.threshold>0&&e.owners>0&&e.threshold<=e.owners?r(v,{threshold:String(e.threshold),owners:String(e.owners)}):r(B,{});return r(D,{age_clause:n,controller_clause:a})}function ht(e){return l(e)?r(w,{fee_pct:c(e)}):r(k,{})}function g(e,t){let n={gas_in_usd:t.in,gas_out_usd:t.out};return _(e).some(a=>!n[a])?r(K,{}):r(e,n)}function bt(e){let t={...e,symbol:u(e.symbol)},n=l(t.borroRatePct),s=ht(t.feePct),a;n?t.kind==="usdg"?a=d(R,{borro_rate:c(t.borroRatePct),fee_clause:s,comparison_clause:yt(t.borroRatePct,t.layerbankRatePct)}):a=d(t.borroRatePct<1?x:E,{symbol:t.symbol,borro_rate:c(t.borroRatePct),fee_clause:s}):a=d(A,{fee_clause:s});let i=t.readyAmount!==void 0&&t.totalAmount!==void 0?r(L,{ready:t.readyAmount,total:t.totalAmount,symbol:t.symbol}):r(P,{});return{intro:r(p,{symbol:t.symbol}),independence:r(f,{}),reward:a,...t.kind==="stock"?{catch:r(b,{symbol:t.symbol})}:{},risk:r(U,{risk_clause:st(t)}),takingOut:i,cost:g(F,{in:t.gasInUsd,out:t.gasOutUsd}),notes:r(W,{})}}function wt(e){let t=bt(e),{intro:n,independence:s,reward:a,risk:i,takingOut:at,cost:it}=t;return[n,"",s,a,...t.catch?[t.catch]:[],i,at,it].join(`
20
- `)}function kt(e){let t={...e,symbol:u(e.symbol),vaultSymbol:rt(e.vaultSymbol)},n=l(t.borroRatePct),s=t.readyAmount!==void 0&&t.totalAmount!==void 0;return d($,{amount:t.amount,symbol:t.symbol,reward_clause:n?r(M,{borro_rate:c(t.borroRatePct)}):r(h,{}),stock_catch_clause:t.kind==="stock"?r(b,{symbol:t.symbol}):"",shares:t.shares,vault_symbol:t.vaultSymbol,shares_min:t.sharesMin,risk_clause:st(t),taking_out_clause:s?r(q,{ready:t.readyAmount,total:t.totalAmount,symbol:t.symbol}):r(G,{}),cost_line:g(Y,{in:t.gasInUsd,out:t.gasOutUsd})})}function Rt(e){let t={...e,symbol:u(e.symbol),vaultSymbol:rt(e.vaultSymbol)};return d(H,{amount_or_all:t.isAll?`all ${t.amount}`:t.amount,symbol:t.symbol,out:t.out,shares:t.shares,vault_symbol:t.vaultSymbol,liquidity_note:t.liquidity?r(j,{ready:t.liquidity.ready,symbol:t.symbol,max_now:t.liquidity.maxNow}):"",drift_notice:t.drift?r(z,{}):"",cost_line:g(V,{out:t.gasOutUsd})})}function Et(e){return r(ot,{symbol:u(e)})}function xt(){return r(nt,{})}function mt(e){return e===void 0||/^[0.,\s]*$/.test(e)}function At(e,t){switch(e){case"unverified":{let n=t.vaultLabel,s=n&&lt.test(n)?`the vault at ${n}`:n&&m.test(n)?`the ${n} vault`:"this vault";return r(Z,{vault_label:s})}case"setup-mismatch":return r(Q,{});case"too-little-ready":{let n=t,s=u(n.symbol);return mt(n.maxNow)?r(X,{ready:n.ready,requested:n.requested,symbol:s}):r(J,{ready:n.ready,requested:n.requested,max_now:n.maxNow,symbol:s})}case"no-shares":return r(tt,{symbol:u(t.symbol)});case"deposit-would-revert":return r(et,{});default:throw new Error(`Unknown Borro refusal kind: ${String(e)}`)}}export{y as a,p as b,f as c,w as d,k as e,R as f,E as g,x as h,h as i,A as j,b as k,O as l,S as m,N as n,T as o,C as p,I as q,v as r,B as s,D as t,U as u,L as v,P as w,F as x,K as y,W as z,$ as A,M as B,q as C,G as D,Y as E,H as F,j as G,V as H,z as I,Z as J,Q as K,J as L,X as M,tt as N,et as O,ot as P,nt as Q,pt as R,ft as S,c as T,dt as U,ct as V,yt as W,st as X,bt as Y,wt as Z,kt as _,Rt as $,Et as aa,xt as ba,At as ca};
20
+ `)}function kt(e){let t={...e,symbol:u(e.symbol),vaultSymbol:rt(e.vaultSymbol)},n=l(t.borroRatePct),s=t.readyAmount!==void 0&&t.totalAmount!==void 0;return d($,{amount:t.amount,symbol:t.symbol,reward_clause:n?r(M,{borro_rate:c(t.borroRatePct)}):r(h,{}),stock_catch_clause:t.kind==="stock"?r(b,{symbol:t.symbol}):"",shares:t.shares,vault_symbol:t.vaultSymbol,shares_min:t.sharesMin,risk_clause:st(t),taking_out_clause:s?r(q,{ready:t.readyAmount,total:t.totalAmount,symbol:t.symbol}):r(G,{}),cost_line:g(Y,{in:t.gasInUsd,out:t.gasOutUsd})})}function Rt(e){let t={...e,symbol:u(e.symbol),vaultSymbol:rt(e.vaultSymbol)};return d(H,{amount_or_all:t.isAll?`all ${t.amount}`:t.amount,symbol:t.symbol,out:t.out,shares:t.shares,vault_symbol:t.vaultSymbol,liquidity_note:t.liquidity?r(V,{ready:t.liquidity.ready,symbol:t.symbol,max_now:t.liquidity.maxNow}):"",drift_notice:t.drift?r(z,{}):"",cost_line:g(j,{out:t.gasOutUsd})})}function Et(e){return r(ot,{symbol:u(e)})}function xt(){return r(nt,{})}function mt(e){return e===void 0||/^[0.,\s]*$/.test(e)}function At(e,t){switch(e){case"unverified":{let n=t.vaultLabel,s=n&&lt.test(n)?`the vault at ${n}`:n&&m.test(n)?`the ${n} vault`:"this vault";return r(Z,{vault_label:s})}case"setup-mismatch":return r(Q,{});case"too-little-ready":{let n=t,s=u(n.symbol);return mt(n.maxNow)?r(X,{ready:n.ready,requested:n.requested,symbol:s}):r(J,{ready:n.ready,requested:n.requested,max_now:n.maxNow,symbol:s})}case"no-shares":return r(tt,{symbol:u(t.symbol)});case"deposit-would-revert":return r(et,{});default:throw new Error(`Unknown Borro refusal kind: ${String(e)}`)}}export{y as a,p as b,f as c,w as d,k as e,R as f,E as g,x as h,h as i,A as j,b as k,O as l,S as m,N as n,T as o,C as p,I as q,v as r,B as s,D as t,U as u,L as v,P as w,F as x,K as y,W as z,$ as A,M as B,q as C,G as D,Y as E,H as F,V as G,j as H,z as I,Z as J,Q as K,J as L,X as M,tt as N,et as O,ot as P,nt as Q,pt as R,ft as S,c as T,dt as U,ct as V,yt as W,st as X,bt as Y,wt as Z,kt as _,Rt as $,Et as aa,xt as ba,At as ca};
@@ -1 +1 @@
1
- import{a as fe}from"./TM2XCRU7.js";import{c as me}from"./MJ6WEWMI.js";import{a as Z}from"./L4N2RSK2.js";import{a as M,b as P}from"./3MLUCYCB.js";import{a as L}from"./U4JGEMKT.js";import{a as ue}from"./P4UQGWCP.js";import{a as x}from"./43LI5NKJ.js";import{b as de,c as le}from"./VEQBHI6O.js";import{a as re,b as X,c as j}from"./5HCXZWUH.js";import{l as ie,n as F,o as ce}from"./ABPL3ZZI.js";import{a as w,b as _,c as B,d as oe,i as E,j as ae,s as D}from"./FWD4L3CJ.js";import{a as k}from"./XSD5NL7J.js";import{a as p,b as V,c as se}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ne,encodeFunctionData as ve,erc20Abi as Y,getAddress as b,isAddress as G,parseAbi as te}from"viem";var z="https://api.robinhood.com/rhj/assets",Pe={address:M,symbol:"ETH",decimals:18,chainId:w},Q={address:b(ae),symbol:"USDG",decimals:oe,chainId:w},J={address:b(E[4663].tokens.WETH.address),symbol:"WETH",decimals:18,chainId:w},we={address:b(E[4663].meridian.CollateralToken_USDe.address),symbol:"USDe",decimals:18,chainId:w};function K(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function $(e,t=w,s={}){let n=Array.isArray(e)?e:K(e)&&Array.isArray(e.assets)?e.assets:void 0;if(!n)throw new k("Official stock asset list response is malformed.");let a=new Map,d=new Map;if(n.length>1e4)throw new k("Official stock asset list exceeds the lookup limit.");for(let o of n){if(!K(o))continue;let r=o;if(typeof r.tokenSymbol!="string"||!r.tokenSymbol.trim()||!Array.isArray(r.deployments))continue;if(r.deployments.length>100)throw new k("Official stock deployment list exceeds the lookup limit.");let l=r.tokenSymbol;if(!/^[A-Za-z0-9.$_-]{1,32}$/.test(l))throw new k(`Invalid official stock ticker ${p(l)}.`);if(r.tokenDecimals!==void 0&&(typeof r.tokenDecimals!="number"||!Number.isInteger(r.tokenDecimals)||r.tokenDecimals<0||r.tokenDecimals>255))throw new k("Official stock asset has invalid token decimals.");let u=typeof r.tokenDecimals=="number"&&Number.isInteger(r.tokenDecimals)&&r.tokenDecimals>=0&&r.tokenDecimals<=255?r.tokenDecimals:18;for(let m of r.deployments){if(!K(m))continue;let h=m;if(h.chainId!==t)continue;if(typeof h.contractAddress!="string"||!G(h.contractAddress,{strict:!1}))throw new k("Official stock deployment has an invalid contract address.");let y=b(h.contractAddress),f=y.toLowerCase(),g=l.toUpperCase(),i=d.get(g);if(!s.allowAmbiguousSymbols&&i&&i!==f)throw new k(`Ambiguous official stock ticker ${p(l)} across multiple addresses.`);let c=a.get(f);if(c&&(c.symbol!==l||c.decimals!==u))throw new k(`Conflicting official stock identity at ${y}.`);d.set(g,f),a.set(f,{address:y,symbol:l,decimals:u,chainId:t,...s.includeNames&&typeof r.tokenName=="string"&&r.tokenName.trim()?{name:r.tokenName.trim()}:{}})}}return[...a.values()]}function Ee(e,t){if(typeof e.address!="string"||!G(e.address,{strict:!1}))return!1;let s=e.chainId??w,n=e.address.toLowerCase();return t.some(a=>a.chainId===s&&a.address.toLowerCase()===n&&a.symbol===e.symbol)}function W(e,t){x(e.address);let s=e.chainId??w,n=b(e.address),a=n.toLowerCase(),d=O(e.symbol),o=t.find(l=>l.chainId===s&&l.address.toLowerCase()===a),r=t.find(l=>l.chainId===s&&O(l.symbol)===d);if(o){if(e.symbol!==o.symbol)throw new k(`Token at ${n} does not match official stock ticker ${p(o.symbol)} (received ${p(e.symbol)}).`);if(e.decimals!==void 0&&e.decimals!==o.decimals)throw new k(`Token ${p(o.symbol)} at ${n} does not match official decimals ${o.decimals}.`);return o}if(r)throw new k(`Token symbol ${p(e.symbol)} at ${n} does not match the official stock contract address ${r.address}.`);return{address:n,symbol:e.symbol.trim(),decimals:e.decimals??18,chainId:s}}var xe=["AAOI","AAPL","ABCL","ADBE","AEHR","AEIS","ALAB","AMAT","AMBA","AMC","AMD","AMKR","AMZN","ANET","APLD","APP","ASML","ASTS","AUR","AVAV","AVGO","AXON","AXTI","BA","BABA","BB","BE","BMNR","BND","BULL","CBRS","CCL","CEG","CELH","CIEN","CLOV","CLS","CLSK","COHR","COIN","COST","CRCL","CRDO","CRM","CRWD","CRWV","CSCO","CTSH","CVNA","DDOG","DELL","DIS","DJT","DOCN","ELF","EWT","EWY","F","FICO","FIG","FISV","FIX","FLNC","FLY","FTNT","FUTU","GDX","GE","GEV","GLD","GLW","GLXY","GME","GOOGL","HII","HIMS","HPE","HWM","IBM","IBRX","INDA","INFQ","INOD","INTC","INTU","IONQ","IREN","JBL","JNJ","JOBY","JPM","KLAC","KSS","KTOS","LHX","LITE","LLY","LMT","LRCX","LULU","LUNR","MCD","MDB","META","MOD","MPWR","MRNA","MRVL","MSFT","MSTR","MTSI","MU","MXL","NAVN","NBIS","NET","NFLX","NNE","NOW","NU","NVDA","NVTS","OKLO","ON","ONTO","ORCL","OUST","P","PANW","PATH","PENG","PFE","PL","PLTR","POET","POWL","PR","PWR","PYPL","QBTS","QCOM","QQQ","QUBT","RBLX","RCAT","RDDT","RDW","RGTI","RIVN","RKLB","RUN","SATS","SCHD","SGOV","SHOP","SHY","SIMO","SKHY","SLS","SLV","SMCI","SMH","SMR","SNAP","SNDK","SNOW","SOFI","SOUN","SOXX","SPCX","SPMO","SPY","TE","TEAM","TEM","TER","TSEM","TSLA","TSM","TTD","TTWO","UBER","UMC","UNH","UPS","USAR","USO","V","VICR","VRT","VSAT","VST","VTI","WDAY","WDC","WULF","WYFI","XLK","XNDU","XOM","ZETA","ZM","ZS"],q=new WeakMap,ke=new WeakMap,ge=3e4,he=Object.freeze([]),N;function nn(){if(!N)return he;let e=Date.now()-N.started;return e>=0&&e<ge?N.tokens:he}var ee=new WeakMap;function H(e,t){return(ee.get(e)??F)(t)}async function Ae(e){let t=e?.http??de(),s=e?.url??z,n=e?.chainId??w,a=j(t),d=ke.get(a);d||(d=new re(ge),ke.set(a,d));let{value:o,started:r}=await H(t,()=>d.read(`${n}:${s}`,async()=>{let u=await F(h=>le(a,s,{method:"GET",signal:h},y=>K(y)||Array.isArray(y))),m=$(u,n,{allowAmbiguousSymbols:!0});if(n===w&&m.length===0)throw new k("Official stock asset list has no mainnet deployments; retry when the list is available.");return u})),l=$(o,n,e);if(n===w&&s===z&&(!N||r>=N.started||Date.now()<N.started)&&(N={started:r,tokens:Object.freeze($(o,n,{allowAmbiguousSymbols:!0}).map(u=>Object.freeze(u)))}),n===w){let u=q.get(a);u||(u=new Set,q.set(a,u));for(let m of l)u.add(O(m.symbol))}return l}var Me=te(["function aggregate3((address target, bool allowFailure, bytes callData)[] calls) payable returns ((bool success, bytes returnData)[] returnData)"]);function ye(e){let t=e,s=new Set;for(;t&&typeof t=="object"&&!s.has(t)&&s.size<10;){s.add(t);let n=t;if(n.name==="ContractFunctionZeroDataError"||n.name==="AbiDecodingZeroDataError")return!0;let a=`${typeof n.shortMessage=="string"?n.shortMessage:""} ${typeof n.message=="string"?n.message:""}`;if(/returned no data \("0x"\)|Cannot decode zero data/i.test(a))return!0;t=n.cause}return!1}function Re(e){return e instanceof k?/RPC endpoint|too many requests|malformed JSON/i.test(e.message):e instanceof Error?/fetch failed|network|ECONNREFUSED|ETIMEDOUT|HTTP \d{3}|rate limit|too many requests/i.test(e.message):!1}async function Ue(e,t,s){if(typeof e.getCode=="function")try{let n=await e.getCode({address:t});return!n||n==="0x"}catch{return ye(s)}return ye(s)}async function Te(e,t,s){if(t.length===0)return[];let n=await Promise.allSettled(t.map(a=>e.readContract({address:a.address,abi:Y,functionName:"balanceOf",args:[s]})));if(n.every(a=>a.status==="rejected")&&n[0]?.status==="rejected"&&Re(n[0].reason))throw n[0].reason;return n.map(a=>{if(a.status!=="fulfilled"||a.value===void 0||a.value===null)return{ok:!1};try{let d=typeof a.value=="bigint"?a.value:BigInt(a.value);return d>=0n?{ok:!0,amount:d}:{ok:!1}}catch{return{ok:!1}}})}async function Se(e,t,s,n){if(s.length===0)return[];let a=ie(t,e);if(!a)return Te(e,s,n);let d=s.map(r=>({target:r.address,allowFailure:!0,callData:ve({abi:Y,functionName:"balanceOf",args:[n]})})),o;try{o=await e.readContract({address:a,abi:Me,functionName:"aggregate3",args:[d]})}catch(r){if(await Ue(e,a,r))return Te(e,s,n);throw r}if(!Array.isArray(o)||o.length!==s.length)throw new k("Multicall3 aggregate3 returned an invalid result list.");return o.map(r=>{let l=r,u=Array.isArray(l)?l[0]:l?.success,m=Array.isArray(l)?l[1]:l?.returnData;if(!u||typeof m!="string"||m==="0x")return{ok:!1};try{let h=Ne({abi:Y,functionName:"balanceOf",data:m}),y=typeof h=="bigint"?h:BigInt(h);return y>=0n?{ok:!0,amount:y}:{ok:!1}}catch{return{ok:!1}}})}async function tn(e,t={}){x(e);let s=b(e),n=t.chainId??w,a=t.client??ce(t.rpcUrl,n),d=[];if(t.stockTokens?d=[...t.stockTokens]:t.stockAssetsPayload!==void 0?d=$(t.stockAssetsPayload,n):t.includeStockTokens!==!1&&n!==_&&(d=await Ae({http:t.http,url:t.stockAssetsUrl,chainId:n})),t.tokens)for(let i of t.tokens)W(i,d);let o=n===w?[Q,J,we,...t.oakTokenAddress||process.env.OAK_TOKEN_ADDRESS?[{address:b(t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS),symbol:"OAK",decimals:B,chainId:n}]:[]]:n===_?[{...Q,address:b(D.testnet.usdg),chainId:n},{...J,address:b(D.testnet.weth),chainId:n},...t.oakTokenAddress?[{address:b(t.oakTokenAddress),symbol:"OAK",decimals:B,chainId:n}]:[]]:[],r=n===w&&t.includePoolTokens!==!1?ue.vaults.flatMap(i=>[{address:b(i.tokenAddress),symbol:b(i.tokenAddress),decimals:i.tokenDecimals,chainId:n},{address:b(i.earnContractAddress),symbol:b(i.earnContractAddress),decimals:18,chainId:n}]):[],l=new Set(r.map(i=>i.address.toLowerCase())),u=[],m=new Set;for(let i of[...o,...d,...t.tokens??[],...r]){if(i.chainId!==n||P(i.address)===M)continue;let c=W(i,d),T=c.address.toLowerCase();m.has(T)||(m.add(T),u.push(c))}let[h,y]=await Promise.all([a.getBalance({address:s}),Se(a,n,u,s)]),f=[],g={address:M,symbol:"ETH",decimals:18,chainId:n};(h>0n||t.includeZero)&&f.push({token:g,amount:h.toString()});for(let i=0;i<u.length;i++){let c=u[i],T=o.some(S=>C(S.address,c.address))||d.some(S=>C(S.address,c.address))?c.symbol:p(c.symbol),I=y[i]??{ok:!1};if(!I.ok){f.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:"unavailable"});continue}let A=I.amount;if(A>0n&&l.has(c.address.toLowerCase()))try{let[S,R]=await Promise.all([L(a,n,c.address,"symbol"),L(a,n,c.address,"decimals")]);T=p(S),c.decimals=R}catch{}(A>0n||t.includeZero)&&f.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:A.toString()})}return f}async function sn(e,t,s){if(x(e),t.length>1e4)throw new k("Journal token discovery exceeds the balance lookup limit.");let n=[...new Set(t.map(o=>(x(o),b(o))))].filter(o=>P(o)!==M).map(o=>({address:o,symbol:o,decimals:0,chainId:s.chainId})),a=await Se(s.client,s.chainId,n,b(e)),d=n.flatMap((o,r)=>{let l=a[r];return l.ok&&l.amount===0n?[]:[{token:o,amount:l.ok?l.amount.toString():"unavailable"}]});return Promise.all(d.map(async({token:o,amount:r})=>{let[l,u]=await Promise.all([L(s.client,s.chainId,o.address,"symbol").catch(()=>o.address),L(s.client,s.chainId,o.address,"decimals").catch(()=>{throw new k(`Token decimals are unavailable for journal-received token ${o.address}; retry balances when RPC metadata is available.`)})]);return{token:{...o,symbol:p(l),decimals:u},amount:r}}))}var C=(e,t)=>e.toLowerCase()===t.toLowerCase(),O=e=>se(e.normalize("NFKC")).toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");function Oe(e){let t=e.context.network??"mainnet",{chainId:s,usdg:n,weth:a}=D[t],d=(o,r,l)=>({...o,address:P(b(o.address)),name:r,kind:l,verified:!0,source:"Oak fixed addresses",warnings:[]});return[d({...Pe,chainId:s},"Ether","native"),d({...Q,address:n,chainId:s},"Global Dollar","stablecoin"),d({...J,address:a,chainId:s},"Wrapped Ether","wrapped"),...t==="mainnet"?[d(we,"USDe","stablecoin")]:[],...e.oakTokenAddress?[d({address:e.oakTokenAddress,symbol:"OAK",decimals:B,chainId:s},"Oak","oak")]:[]]}async function Ce(e){if(e.context.network==="testnet")return[];let t=e.officialStockTokens??await Ae({http:e.context.http,includeNames:!0,allowAmbiguousSymbols:!0});return t.filter(s=>Ee(s,t)).map(s=>({...s,name:s.name??s.symbol,kind:"official_stock",verified:!0,source:z,warnings:[]}))}async function ne(e,t,s=!0){let{chainId:n}=D[t.context.network??"mainnet"],a=t.context.clientFor(n);if(await a.getChainId()!==n)throw new k(`Token lookup requires Robinhood Chain ${n}.`);let[d,o,r]=await Promise.all([H(a,()=>L(a,n,e,"name",t.blockNumber)).catch(l=>{if(s)throw l;return""}),H(a,()=>L(a,n,e,"symbol",t.blockNumber)),H(a,()=>L(a,n,e,"decimals",t.blockNumber))]);if(typeof d!="string"||s&&!d.trim()||typeof o!="string"||!o.trim()||!Number.isInteger(r)||r<0||r>255)throw new k("The contract returned invalid token metadata.");return{address:b(e),name:d||o,symbol:o,decimals:r,chainId:n}}async function be(e,t){let s=await t.context.clientFor(w).readContract({address:E[w].clanker.factory.address,abi:te(["function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),functionName:"tokenDeploymentInfo",args:[e]});return Array.isArray(s)&&s.length===4&&typeof s[0]=="string"&&C(s[0],e)}async function _e(e,t){let s=t.context.clientFor(w),n=E[w].poolsTrade,a=[n.instantLaunchStrategyFeesOn.address,n.instantLaunchStrategyFeesOff.address],d=te(["event TokenLaunched(bytes32 indexed poolId,address indexed token,address indexed feeSplitter,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey)"])[0],o=await s.getBlockNumber(),r=new Set,l=0,u=0;for(let m=63127652n;m<=o;m+=10000000n){if(++l>Ie)throw new k("Token origin scan limit reached.");let h=m+9999999n>o?o:m+9999999n,y=await s.getLogs({address:a,event:d,args:{token:e},fromBlock:m,toBlock:h,strict:!0});for(let f of y){if(f.removed||!a.some(i=>C(i,f.address))||!f.args.token||!C(f.args.token,e)||!f.transactionHash||r.has(f.transactionHash))continue;if(r.add(f.transactionHash),++u>20)throw new k("Token origin receipt limit reached.");let g=await s.getTransactionReceipt({hash:f.transactionHash});if(fe(g).some(i=>C(i.token,e)))return b(g.from)}}}var Ie=5,Be=100,Fe=500,Ke=3e4;function Le(e){let t=Date.now()+Ke,s=0,n=new Map,a=o=>{let r=t-Date.now();if(r<=0)throw new k("Token lookup time budget reached; results are partial.");return F(o,Math.min(1e4,r))},d=X((o,r)=>a(async l=>{let u=await e.context.http(o,{...r,signal:l});return new Proxy(u,{get(m,h){if(h==="json")return()=>a(()=>m.json());let y=Reflect.get(m,h,m);return typeof y=="function"?y.bind(m):y}})}),e.context.http);return ee.set(d,a),{...e,context:{...e.context,http:d,clientFor:o=>{if(!n.has(o)){let r=e.context.clientFor(o),l=u=>{if(++s>Fe)throw new k("Token lookup RPC budget reached; results are partial.");return a(u)};n.set(o,X(new Proxy(r,{get(u,m){let h=Reflect.get(u,m);return typeof h!="function"?h:(...y)=>l(()=>h.apply(u,y))}}),r)),ee.set(n.get(o),l)}return n.get(o)}}}}function pe(e){return e.source==="Oak fixed addresses"?e:{...e,symbol:p(e.symbol),name:p(e.name)}}async function on(e,t){if(t=Le(t),typeof e!="string"||e.length>256||!O(e))throw new k("Provide a token name, symbol or address to find_token.");let s=O(e),n=G(e.trim(),{strict:!1})?P(b(e.trim())):void 0,{chainId:a}=D[t.context.network??"mainnet"],d=[],o=Oe(t),r=!1;try{o.push(...await Ce(t))}catch{r=!0,d.push("The official stock list is unavailable; results are partial and stock identities and lookalikes could not be checked.")}let l=i=>n?C(i.address,n):O(i.symbol).includes(s)||O(i.name).includes(s),u=o.filter(l),m=[],h=(i,c)=>[i.symbol,i.name??""].some(T=>[c.symbol,c.name].some(I=>{let A=O(T),S=O(I);return!!A&&!!S&&(A.includes(S)||S.includes(A))})),y=(i,c={})=>{if(m.some(A=>C(A.address,i.address)))return;let T=[`Token ${p(i.symbol)} at ${i.address} is an unverified ${c.launchpad?"launchpad token":"token"}. Use its address, not its name or symbol.`];(V(i.symbol)||V(i.name)||o.some(A=>!C(A.address,i.address)&&h(i,A)))&&T.push(`Lookalike warning: ${p(i.symbol)} at ${i.address} resembles a verified token's name or symbol.`);let I={...i,...c,kind:c.launchpad?"launchpad":"erc20",verified:!1,source:c.launchpad?`${c.launchpad} origin and on-chain metadata; not a verified token`:"On-chain metadata only",warnings:T};m.push(I),d.push(...T)};if(n&&!u.length){let i=await ne(n,t),c={};if(a===w){try{await be(n,t)&&(c.launchpad="clanker")}catch{d.push("Clanker origin lookup was unavailable for this address.")}if(c.launchpad==="clanker")try{let I=(await Z(t.context,{q:n,limit:20})).tokens.find(A=>C(A.contract_address,n));I&&(c.creator=b(I.msg_sender),c.creatorSource="Clanker indexer msg_sender")}catch{d.push("Clanker creator lookup is unavailable.")}else try{let T=await me(t.context,n);c.launchpad="pons",c.creator=b(T.creator),c.creatorSource="Pons factory deployer"}catch{d.push("Pons launch origin could not be confirmed for this address.")}if(!c.launchpad)try{let T=await _e(n,t);T&&(c.launchpad="pools.trade",c.creator=T,c.creatorSource="Launch transaction sender; may be a relayer")}catch{r=!0,d.push("pools.trade launch receipt lookup is unavailable; origin results are partial.")}}y(i,c)}else if(!n&&a===w){let i=new Set,c=new Set,T,I=0,A=0;try{do{if(++I>Ie)throw new k("Token search page limit reached.");let S=await Z(t.context,{q:e.trim(),limit:20,...T?{cursor:T}:{}});for(let R of S.tokens){if(++A>Be)throw new k("Token candidate limit reached.");let v=b(R.contract_address);if(!(c.has(v)||o.some(U=>C(U.address,v)))){c.add(v);try{let U=await ne(v,t);if(!l(U))continue;let De=await be(v,t)?{launchpad:"clanker",creator:b(R.msg_sender),creatorSource:"Clanker indexer msg_sender"}:{};y(U,De)}catch{r=!0,d.push(`Could not read Clanker candidate ${v}; it was omitted from these partial results.`)}}}if(S.cursor&&i.has(S.cursor))throw new k("The Clanker indexer repeated a pagination cursor.");S.cursor&&i.add(S.cursor),T=S.cursor??void 0}while(T)}catch{r=!0,d.push("Clanker name search is unavailable, incomplete or reached its scan limit; results are partial.")}d.push("Pons and pools.trade require a token address; name search does not cover those launchpads.")}a===_&&d.push("Testnet lookup covers pinned tokens and explicit token addresses; stock and launchpad discovery are unavailable.");let f=i=>[...new Map(i.map(c=>[c.address.toLowerCase(),c])).values()],g=f([...u,...m]);for(let i of g)if(g.some(c=>!C(c.address,i.address)&&(O(i.symbol)===O(c.symbol)||O(i.name)===O(c.name)))){let c=`Duplicate warning: several tokens share the symbol or name of ${i.address}. Choose the intended address; do not guess from the name.`;i.warnings.push(c),d.push(c)}return u.length>1&&d.push("Several verified tokens match this search, including possible substring matches. Choose an exact address; the search does not select a quote token."),{query:p(e.trim()),chainId:a,partial:r,matches:f(u).map(pe),unverified:f(m).map(pe),warnings:d}}async function an(e,t){if(typeof e!="string"||!e.trim())throw new k("Provide a token address or verified symbol; use find_token to look it up.");if(!/^[A-Za-z0-9.$_-]{1,42}$/.test(e))throw new k("Use an exact ASCII verified symbol or token address; use find_token to look it up.");let s=e,n=G(s,{strict:!1})?P(b(s)):void 0,a=Oe(t),d=n&&a.find(y=>C(y.address,n));if(d)return d;let o=s.toUpperCase()==="$OAK"?"OAK":s.toUpperCase(),r=!n&&a.find(y=>y.symbol.toUpperCase()===o),l=[],u=!1;try{l=await Ce(t)}catch{if(r)return r;if(!n)throw new k("The official stock list is unavailable; stock symbols cannot be checked. Use find_token and try again when the list is reachable.");u=!0}if(n){let y=l.find(i=>C(i.address,n));if(y)return t.tokenMetadata&&W(t.tokenMetadata,l),{...y,name:p(y.name)};let f=t.tokenMetadata??await t.readMetadata?.(n);if(f&&(!C(f.address,n)||f.chainId!==D[t.context.network??"mainnet"].chainId))throw new k("Token metadata does not match the requested address and chain.");if(f&&(typeof f.symbol!="string"||!f.symbol.trim()||!Number.isInteger(f.decimals)||f.decimals<0||f.decimals>255))throw new k("The contract returned invalid token metadata.");let g=f?{...f,name:f.symbol}:await ne(n,Le(t),!1);if(u){let i=O(g.symbol),c=q.get(j(t.context.http));if(xe.some(T=>O(T)===i)||c?.has(i))throw new k("The official stock list is unavailable; this address claims a stock ticker that cannot be checked. Try again when the list is reachable.")}return W(g,l),{...g,symbol:p(g.symbol),name:p(g.name),kind:"erc20",verified:!1,source:"On-chain metadata only",warnings:["This token address is unverified. On-chain names and symbols do not prove identity.",...u?["The official stock list is unavailable; stock identity could not be verified."]:[]]}}let m=[...a,...l].filter(y=>y.symbol.toUpperCase()===o);if(m.length!==1)throw new k(`Token symbol ${p(s)} is ${m.length?"ambiguous":"unverified"}; use find_token and choose an explicit address.`);let h=m[0];if(h.kind==="official_stock"&&s!==h.symbol)throw new k(`Use the exact official stock ticker ${p(h.symbol)}; case variants are refused.`);return h.source==="Oak fixed addresses"?h:{...h,name:p(h.name)}}export{z as a,Pe as b,Q as c,J as d,we as e,$ as f,Ee as g,W as h,nn as i,Ae as j,Me as k,tn as l,sn as m,on as n,an as o};
1
+ import{a as fe}from"./X2P55AC3.js";import{c as me}from"./HQUVB7Z5.js";import{a as Z}from"./GRQYTVNT.js";import{a as M,b as P}from"./QHBS3PVU.js";import{a as L}from"./U4JGEMKT.js";import{a as ue}from"./P4UQGWCP.js";import{a as x}from"./43LI5NKJ.js";import{b as de,c as le}from"./VEQBHI6O.js";import{a as re,b as X,c as j}from"./5HCXZWUH.js";import{l as ie,n as F,o as ce}from"./ABPL3ZZI.js";import{a as w,b as _,c as B,d as oe,i as E,j as ae,s as D}from"./FWD4L3CJ.js";import{a as k}from"./XSD5NL7J.js";import{a as p,b as V,c as se}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ne,encodeFunctionData as ve,erc20Abi as Y,getAddress as b,isAddress as G,parseAbi as te}from"viem";var z="https://api.robinhood.com/rhj/assets",Pe={address:M,symbol:"ETH",decimals:18,chainId:w},Q={address:b(ae),symbol:"USDG",decimals:oe,chainId:w},J={address:b(E[4663].tokens.WETH.address),symbol:"WETH",decimals:18,chainId:w},we={address:b(E[4663].meridian.CollateralToken_USDe.address),symbol:"USDe",decimals:18,chainId:w};function K(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function $(e,t=w,s={}){let n=Array.isArray(e)?e:K(e)&&Array.isArray(e.assets)?e.assets:void 0;if(!n)throw new k("Official stock asset list response is malformed.");let a=new Map,d=new Map;if(n.length>1e4)throw new k("Official stock asset list exceeds the lookup limit.");for(let o of n){if(!K(o))continue;let r=o;if(typeof r.tokenSymbol!="string"||!r.tokenSymbol.trim()||!Array.isArray(r.deployments))continue;if(r.deployments.length>100)throw new k("Official stock deployment list exceeds the lookup limit.");let l=r.tokenSymbol;if(!/^[A-Za-z0-9.$_-]{1,32}$/.test(l))throw new k(`Invalid official stock ticker ${p(l)}.`);if(r.tokenDecimals!==void 0&&(typeof r.tokenDecimals!="number"||!Number.isInteger(r.tokenDecimals)||r.tokenDecimals<0||r.tokenDecimals>255))throw new k("Official stock asset has invalid token decimals.");let u=typeof r.tokenDecimals=="number"&&Number.isInteger(r.tokenDecimals)&&r.tokenDecimals>=0&&r.tokenDecimals<=255?r.tokenDecimals:18;for(let m of r.deployments){if(!K(m))continue;let h=m;if(h.chainId!==t)continue;if(typeof h.contractAddress!="string"||!G(h.contractAddress,{strict:!1}))throw new k("Official stock deployment has an invalid contract address.");let y=b(h.contractAddress),f=y.toLowerCase(),g=l.toUpperCase(),i=d.get(g);if(!s.allowAmbiguousSymbols&&i&&i!==f)throw new k(`Ambiguous official stock ticker ${p(l)} across multiple addresses.`);let c=a.get(f);if(c&&(c.symbol!==l||c.decimals!==u))throw new k(`Conflicting official stock identity at ${y}.`);d.set(g,f),a.set(f,{address:y,symbol:l,decimals:u,chainId:t,...s.includeNames&&typeof r.tokenName=="string"&&r.tokenName.trim()?{name:r.tokenName.trim()}:{}})}}return[...a.values()]}function Ee(e,t){if(typeof e.address!="string"||!G(e.address,{strict:!1}))return!1;let s=e.chainId??w,n=e.address.toLowerCase();return t.some(a=>a.chainId===s&&a.address.toLowerCase()===n&&a.symbol===e.symbol)}function W(e,t){x(e.address);let s=e.chainId??w,n=b(e.address),a=n.toLowerCase(),d=O(e.symbol),o=t.find(l=>l.chainId===s&&l.address.toLowerCase()===a),r=t.find(l=>l.chainId===s&&O(l.symbol)===d);if(o){if(e.symbol!==o.symbol)throw new k(`Token at ${n} does not match official stock ticker ${p(o.symbol)} (received ${p(e.symbol)}).`);if(e.decimals!==void 0&&e.decimals!==o.decimals)throw new k(`Token ${p(o.symbol)} at ${n} does not match official decimals ${o.decimals}.`);return o}if(r)throw new k(`Token symbol ${p(e.symbol)} at ${n} does not match the official stock contract address ${r.address}.`);return{address:n,symbol:e.symbol.trim(),decimals:e.decimals??18,chainId:s}}var xe=["AAOI","AAPL","ABCL","ADBE","AEHR","AEIS","ALAB","AMAT","AMBA","AMC","AMD","AMKR","AMZN","ANET","APLD","APP","ASML","ASTS","AUR","AVAV","AVGO","AXON","AXTI","BA","BABA","BB","BE","BMNR","BND","BULL","CBRS","CCL","CEG","CELH","CIEN","CLOV","CLS","CLSK","COHR","COIN","COST","CRCL","CRDO","CRM","CRWD","CRWV","CSCO","CTSH","CVNA","DDOG","DELL","DIS","DJT","DOCN","ELF","EWT","EWY","F","FICO","FIG","FISV","FIX","FLNC","FLY","FTNT","FUTU","GDX","GE","GEV","GLD","GLW","GLXY","GME","GOOGL","HII","HIMS","HPE","HWM","IBM","IBRX","INDA","INFQ","INOD","INTC","INTU","IONQ","IREN","JBL","JNJ","JOBY","JPM","KLAC","KSS","KTOS","LHX","LITE","LLY","LMT","LRCX","LULU","LUNR","MCD","MDB","META","MOD","MPWR","MRNA","MRVL","MSFT","MSTR","MTSI","MU","MXL","NAVN","NBIS","NET","NFLX","NNE","NOW","NU","NVDA","NVTS","OKLO","ON","ONTO","ORCL","OUST","P","PANW","PATH","PENG","PFE","PL","PLTR","POET","POWL","PR","PWR","PYPL","QBTS","QCOM","QQQ","QUBT","RBLX","RCAT","RDDT","RDW","RGTI","RIVN","RKLB","RUN","SATS","SCHD","SGOV","SHOP","SHY","SIMO","SKHY","SLS","SLV","SMCI","SMH","SMR","SNAP","SNDK","SNOW","SOFI","SOUN","SOXX","SPCX","SPMO","SPY","TE","TEAM","TEM","TER","TSEM","TSLA","TSM","TTD","TTWO","UBER","UMC","UNH","UPS","USAR","USO","V","VICR","VRT","VSAT","VST","VTI","WDAY","WDC","WULF","WYFI","XLK","XNDU","XOM","ZETA","ZM","ZS"],q=new WeakMap,ke=new WeakMap,ge=3e4,he=Object.freeze([]),N;function nn(){if(!N)return he;let e=Date.now()-N.started;return e>=0&&e<ge?N.tokens:he}var ee=new WeakMap;function H(e,t){return(ee.get(e)??F)(t)}async function Ae(e){let t=e?.http??de(),s=e?.url??z,n=e?.chainId??w,a=j(t),d=ke.get(a);d||(d=new re(ge),ke.set(a,d));let{value:o,started:r}=await H(t,()=>d.read(`${n}:${s}`,async()=>{let u=await F(h=>le(a,s,{method:"GET",signal:h},y=>K(y)||Array.isArray(y))),m=$(u,n,{allowAmbiguousSymbols:!0});if(n===w&&m.length===0)throw new k("Official stock asset list has no mainnet deployments; retry when the list is available.");return u})),l=$(o,n,e);if(n===w&&s===z&&(!N||r>=N.started||Date.now()<N.started)&&(N={started:r,tokens:Object.freeze($(o,n,{allowAmbiguousSymbols:!0}).map(u=>Object.freeze(u)))}),n===w){let u=q.get(a);u||(u=new Set,q.set(a,u));for(let m of l)u.add(O(m.symbol))}return l}var Me=te(["function aggregate3((address target, bool allowFailure, bytes callData)[] calls) payable returns ((bool success, bytes returnData)[] returnData)"]);function ye(e){let t=e,s=new Set;for(;t&&typeof t=="object"&&!s.has(t)&&s.size<10;){s.add(t);let n=t;if(n.name==="ContractFunctionZeroDataError"||n.name==="AbiDecodingZeroDataError")return!0;let a=`${typeof n.shortMessage=="string"?n.shortMessage:""} ${typeof n.message=="string"?n.message:""}`;if(/returned no data \("0x"\)|Cannot decode zero data/i.test(a))return!0;t=n.cause}return!1}function Re(e){return e instanceof k?/RPC endpoint|too many requests|malformed JSON/i.test(e.message):e instanceof Error?/fetch failed|network|ECONNREFUSED|ETIMEDOUT|HTTP \d{3}|rate limit|too many requests/i.test(e.message):!1}async function Ue(e,t,s){if(typeof e.getCode=="function")try{let n=await e.getCode({address:t});return!n||n==="0x"}catch{return ye(s)}return ye(s)}async function Te(e,t,s){if(t.length===0)return[];let n=await Promise.allSettled(t.map(a=>e.readContract({address:a.address,abi:Y,functionName:"balanceOf",args:[s]})));if(n.every(a=>a.status==="rejected")&&n[0]?.status==="rejected"&&Re(n[0].reason))throw n[0].reason;return n.map(a=>{if(a.status!=="fulfilled"||a.value===void 0||a.value===null)return{ok:!1};try{let d=typeof a.value=="bigint"?a.value:BigInt(a.value);return d>=0n?{ok:!0,amount:d}:{ok:!1}}catch{return{ok:!1}}})}async function Se(e,t,s,n){if(s.length===0)return[];let a=ie(t,e);if(!a)return Te(e,s,n);let d=s.map(r=>({target:r.address,allowFailure:!0,callData:ve({abi:Y,functionName:"balanceOf",args:[n]})})),o;try{o=await e.readContract({address:a,abi:Me,functionName:"aggregate3",args:[d]})}catch(r){if(await Ue(e,a,r))return Te(e,s,n);throw r}if(!Array.isArray(o)||o.length!==s.length)throw new k("Multicall3 aggregate3 returned an invalid result list.");return o.map(r=>{let l=r,u=Array.isArray(l)?l[0]:l?.success,m=Array.isArray(l)?l[1]:l?.returnData;if(!u||typeof m!="string"||m==="0x")return{ok:!1};try{let h=Ne({abi:Y,functionName:"balanceOf",data:m}),y=typeof h=="bigint"?h:BigInt(h);return y>=0n?{ok:!0,amount:y}:{ok:!1}}catch{return{ok:!1}}})}async function tn(e,t={}){x(e);let s=b(e),n=t.chainId??w,a=t.client??ce(t.rpcUrl,n),d=[];if(t.stockTokens?d=[...t.stockTokens]:t.stockAssetsPayload!==void 0?d=$(t.stockAssetsPayload,n):t.includeStockTokens!==!1&&n!==_&&(d=await Ae({http:t.http,url:t.stockAssetsUrl,chainId:n})),t.tokens)for(let i of t.tokens)W(i,d);let o=n===w?[Q,J,we,...t.oakTokenAddress||process.env.OAK_TOKEN_ADDRESS?[{address:b(t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS),symbol:"OAK",decimals:B,chainId:n}]:[]]:n===_?[{...Q,address:b(D.testnet.usdg),chainId:n},{...J,address:b(D.testnet.weth),chainId:n},...t.oakTokenAddress?[{address:b(t.oakTokenAddress),symbol:"OAK",decimals:B,chainId:n}]:[]]:[],r=n===w&&t.includePoolTokens!==!1?ue.vaults.flatMap(i=>[{address:b(i.tokenAddress),symbol:b(i.tokenAddress),decimals:i.tokenDecimals,chainId:n},{address:b(i.earnContractAddress),symbol:b(i.earnContractAddress),decimals:18,chainId:n}]):[],l=new Set(r.map(i=>i.address.toLowerCase())),u=[],m=new Set;for(let i of[...o,...d,...t.tokens??[],...r]){if(i.chainId!==n||P(i.address)===M)continue;let c=W(i,d),T=c.address.toLowerCase();m.has(T)||(m.add(T),u.push(c))}let[h,y]=await Promise.all([a.getBalance({address:s}),Se(a,n,u,s)]),f=[],g={address:M,symbol:"ETH",decimals:18,chainId:n};(h>0n||t.includeZero)&&f.push({token:g,amount:h.toString()});for(let i=0;i<u.length;i++){let c=u[i],T=o.some(S=>C(S.address,c.address))||d.some(S=>C(S.address,c.address))?c.symbol:p(c.symbol),I=y[i]??{ok:!1};if(!I.ok){f.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:"unavailable"});continue}let A=I.amount;if(A>0n&&l.has(c.address.toLowerCase()))try{let[S,R]=await Promise.all([L(a,n,c.address,"symbol"),L(a,n,c.address,"decimals")]);T=p(S),c.decimals=R}catch{}(A>0n||t.includeZero)&&f.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:A.toString()})}return f}async function sn(e,t,s){if(x(e),t.length>1e4)throw new k("Journal token discovery exceeds the balance lookup limit.");let n=[...new Set(t.map(o=>(x(o),b(o))))].filter(o=>P(o)!==M).map(o=>({address:o,symbol:o,decimals:0,chainId:s.chainId})),a=await Se(s.client,s.chainId,n,b(e)),d=n.flatMap((o,r)=>{let l=a[r];return l.ok&&l.amount===0n?[]:[{token:o,amount:l.ok?l.amount.toString():"unavailable"}]});return Promise.all(d.map(async({token:o,amount:r})=>{let[l,u]=await Promise.all([L(s.client,s.chainId,o.address,"symbol").catch(()=>o.address),L(s.client,s.chainId,o.address,"decimals").catch(()=>{throw new k(`Token decimals are unavailable for journal-received token ${o.address}; retry balances when RPC metadata is available.`)})]);return{token:{...o,symbol:p(l),decimals:u},amount:r}}))}var C=(e,t)=>e.toLowerCase()===t.toLowerCase(),O=e=>se(e.normalize("NFKC")).toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");function Oe(e){let t=e.context.network??"mainnet",{chainId:s,usdg:n,weth:a}=D[t],d=(o,r,l)=>({...o,address:P(b(o.address)),name:r,kind:l,verified:!0,source:"Oak fixed addresses",warnings:[]});return[d({...Pe,chainId:s},"Ether","native"),d({...Q,address:n,chainId:s},"Global Dollar","stablecoin"),d({...J,address:a,chainId:s},"Wrapped Ether","wrapped"),...t==="mainnet"?[d(we,"USDe","stablecoin")]:[],...e.oakTokenAddress?[d({address:e.oakTokenAddress,symbol:"OAK",decimals:B,chainId:s},"Oak","oak")]:[]]}async function Ce(e){if(e.context.network==="testnet")return[];let t=e.officialStockTokens??await Ae({http:e.context.http,includeNames:!0,allowAmbiguousSymbols:!0});return t.filter(s=>Ee(s,t)).map(s=>({...s,name:s.name??s.symbol,kind:"official_stock",verified:!0,source:z,warnings:[]}))}async function ne(e,t,s=!0){let{chainId:n}=D[t.context.network??"mainnet"],a=t.context.clientFor(n);if(await a.getChainId()!==n)throw new k(`Token lookup requires Robinhood Chain ${n}.`);let[d,o,r]=await Promise.all([H(a,()=>L(a,n,e,"name",t.blockNumber)).catch(l=>{if(s)throw l;return""}),H(a,()=>L(a,n,e,"symbol",t.blockNumber)),H(a,()=>L(a,n,e,"decimals",t.blockNumber))]);if(typeof d!="string"||s&&!d.trim()||typeof o!="string"||!o.trim()||!Number.isInteger(r)||r<0||r>255)throw new k("The contract returned invalid token metadata.");return{address:b(e),name:d||o,symbol:o,decimals:r,chainId:n}}async function be(e,t){let s=await t.context.clientFor(w).readContract({address:E[w].clanker.factory.address,abi:te(["function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),functionName:"tokenDeploymentInfo",args:[e]});return Array.isArray(s)&&s.length===4&&typeof s[0]=="string"&&C(s[0],e)}async function _e(e,t){let s=t.context.clientFor(w),n=E[w].poolsTrade,a=[n.instantLaunchStrategyFeesOn.address,n.instantLaunchStrategyFeesOff.address],d=te(["event TokenLaunched(bytes32 indexed poolId,address indexed token,address indexed feeSplitter,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey)"])[0],o=await s.getBlockNumber(),r=new Set,l=0,u=0;for(let m=63127652n;m<=o;m+=10000000n){if(++l>Ie)throw new k("Token origin scan limit reached.");let h=m+9999999n>o?o:m+9999999n,y=await s.getLogs({address:a,event:d,args:{token:e},fromBlock:m,toBlock:h,strict:!0});for(let f of y){if(f.removed||!a.some(i=>C(i,f.address))||!f.args.token||!C(f.args.token,e)||!f.transactionHash||r.has(f.transactionHash))continue;if(r.add(f.transactionHash),++u>20)throw new k("Token origin receipt limit reached.");let g=await s.getTransactionReceipt({hash:f.transactionHash});if(fe(g).some(i=>C(i.token,e)))return b(g.from)}}}var Ie=5,Be=100,Fe=500,Ke=3e4;function Le(e){let t=Date.now()+Ke,s=0,n=new Map,a=o=>{let r=t-Date.now();if(r<=0)throw new k("Token lookup time budget reached; results are partial.");return F(o,Math.min(1e4,r))},d=X((o,r)=>a(async l=>{let u=await e.context.http(o,{...r,signal:l});return new Proxy(u,{get(m,h){if(h==="json")return()=>a(()=>m.json());let y=Reflect.get(m,h,m);return typeof y=="function"?y.bind(m):y}})}),e.context.http);return ee.set(d,a),{...e,context:{...e.context,http:d,clientFor:o=>{if(!n.has(o)){let r=e.context.clientFor(o),l=u=>{if(++s>Fe)throw new k("Token lookup RPC budget reached; results are partial.");return a(u)};n.set(o,X(new Proxy(r,{get(u,m){let h=Reflect.get(u,m);return typeof h!="function"?h:(...y)=>l(()=>h.apply(u,y))}}),r)),ee.set(n.get(o),l)}return n.get(o)}}}}function pe(e){return e.source==="Oak fixed addresses"?e:{...e,symbol:p(e.symbol),name:p(e.name)}}async function on(e,t){if(t=Le(t),typeof e!="string"||e.length>256||!O(e))throw new k("Provide a token name, symbol or address to find_token.");let s=O(e),n=G(e.trim(),{strict:!1})?P(b(e.trim())):void 0,{chainId:a}=D[t.context.network??"mainnet"],d=[],o=Oe(t),r=!1;try{o.push(...await Ce(t))}catch{r=!0,d.push("The official stock list is unavailable; results are partial and stock identities and lookalikes could not be checked.")}let l=i=>n?C(i.address,n):O(i.symbol).includes(s)||O(i.name).includes(s),u=o.filter(l),m=[],h=(i,c)=>[i.symbol,i.name??""].some(T=>[c.symbol,c.name].some(I=>{let A=O(T),S=O(I);return!!A&&!!S&&(A.includes(S)||S.includes(A))})),y=(i,c={})=>{if(m.some(A=>C(A.address,i.address)))return;let T=[`Token ${p(i.symbol)} at ${i.address} is an unverified ${c.launchpad?"launchpad token":"token"}. Use its address, not its name or symbol.`];(V(i.symbol)||V(i.name)||o.some(A=>!C(A.address,i.address)&&h(i,A)))&&T.push(`Lookalike warning: ${p(i.symbol)} at ${i.address} resembles a verified token's name or symbol.`);let I={...i,...c,kind:c.launchpad?"launchpad":"erc20",verified:!1,source:c.launchpad?`${c.launchpad} origin and on-chain metadata; not a verified token`:"On-chain metadata only",warnings:T};m.push(I),d.push(...T)};if(n&&!u.length){let i=await ne(n,t),c={};if(a===w){try{await be(n,t)&&(c.launchpad="clanker")}catch{d.push("Clanker origin lookup was unavailable for this address.")}if(c.launchpad==="clanker")try{let I=(await Z(t.context,{q:n,limit:20})).tokens.find(A=>C(A.contract_address,n));I&&(c.creator=b(I.msg_sender),c.creatorSource="Clanker indexer msg_sender")}catch{d.push("Clanker creator lookup is unavailable.")}else try{let T=await me(t.context,n);c.launchpad="pons",c.creator=b(T.creator),c.creatorSource="Pons factory deployer"}catch{d.push("Pons launch origin could not be confirmed for this address.")}if(!c.launchpad)try{let T=await _e(n,t);T&&(c.launchpad="pools.trade",c.creator=T,c.creatorSource="Launch transaction sender; may be a relayer")}catch{r=!0,d.push("pools.trade launch receipt lookup is unavailable; origin results are partial.")}}y(i,c)}else if(!n&&a===w){let i=new Set,c=new Set,T,I=0,A=0;try{do{if(++I>Ie)throw new k("Token search page limit reached.");let S=await Z(t.context,{q:e.trim(),limit:20,...T?{cursor:T}:{}});for(let R of S.tokens){if(++A>Be)throw new k("Token candidate limit reached.");let v=b(R.contract_address);if(!(c.has(v)||o.some(U=>C(U.address,v)))){c.add(v);try{let U=await ne(v,t);if(!l(U))continue;let De=await be(v,t)?{launchpad:"clanker",creator:b(R.msg_sender),creatorSource:"Clanker indexer msg_sender"}:{};y(U,De)}catch{r=!0,d.push(`Could not read Clanker candidate ${v}; it was omitted from these partial results.`)}}}if(S.cursor&&i.has(S.cursor))throw new k("The Clanker indexer repeated a pagination cursor.");S.cursor&&i.add(S.cursor),T=S.cursor??void 0}while(T)}catch{r=!0,d.push("Clanker name search is unavailable, incomplete or reached its scan limit; results are partial.")}d.push("Pons and pools.trade require a token address; name search does not cover those launchpads.")}a===_&&d.push("Testnet lookup covers pinned tokens and explicit token addresses; stock and launchpad discovery are unavailable.");let f=i=>[...new Map(i.map(c=>[c.address.toLowerCase(),c])).values()],g=f([...u,...m]);for(let i of g)if(g.some(c=>!C(c.address,i.address)&&(O(i.symbol)===O(c.symbol)||O(i.name)===O(c.name)))){let c=`Duplicate warning: several tokens share the symbol or name of ${i.address}. Choose the intended address; do not guess from the name.`;i.warnings.push(c),d.push(c)}return u.length>1&&d.push("Several verified tokens match this search, including possible substring matches. Choose an exact address; the search does not select a quote token."),{query:p(e.trim()),chainId:a,partial:r,matches:f(u).map(pe),unverified:f(m).map(pe),warnings:d}}async function an(e,t){if(typeof e!="string"||!e.trim())throw new k("Provide a token address or verified symbol; use find_token to look it up.");if(!/^[A-Za-z0-9.$_-]{1,42}$/.test(e))throw new k("Use an exact ASCII verified symbol or token address; use find_token to look it up.");let s=e,n=G(s,{strict:!1})?P(b(s)):void 0,a=Oe(t),d=n&&a.find(y=>C(y.address,n));if(d)return d;let o=s.toUpperCase()==="$OAK"?"OAK":s.toUpperCase(),r=!n&&a.find(y=>y.symbol.toUpperCase()===o),l=[],u=!1;try{l=await Ce(t)}catch{if(r)return r;if(!n)throw new k("The official stock list is unavailable; stock symbols cannot be checked. Use find_token and try again when the list is reachable.");u=!0}if(n){let y=l.find(i=>C(i.address,n));if(y)return t.tokenMetadata&&W(t.tokenMetadata,l),{...y,name:p(y.name)};let f=t.tokenMetadata??await t.readMetadata?.(n);if(f&&(!C(f.address,n)||f.chainId!==D[t.context.network??"mainnet"].chainId))throw new k("Token metadata does not match the requested address and chain.");if(f&&(typeof f.symbol!="string"||!f.symbol.trim()||!Number.isInteger(f.decimals)||f.decimals<0||f.decimals>255))throw new k("The contract returned invalid token metadata.");let g=f?{...f,name:f.symbol}:await ne(n,Le(t),!1);if(u){let i=O(g.symbol),c=q.get(j(t.context.http));if(xe.some(T=>O(T)===i)||c?.has(i))throw new k("The official stock list is unavailable; this address claims a stock ticker that cannot be checked. Try again when the list is reachable.")}return W(g,l),{...g,symbol:p(g.symbol),name:p(g.name),kind:"erc20",verified:!1,source:"On-chain metadata only",warnings:["This token address is unverified. On-chain names and symbols do not prove identity.",...u?["The official stock list is unavailable; stock identity could not be verified."]:[]]}}let m=[...a,...l].filter(y=>y.symbol.toUpperCase()===o);if(m.length!==1)throw new k(`Token symbol ${p(s)} is ${m.length?"ambiguous":"unverified"}; use find_token and choose an explicit address.`);let h=m[0];if(h.kind==="official_stock"&&s!==h.symbol)throw new k(`Use the exact official stock ticker ${p(h.symbol)}; case variants are refused.`);return h.source==="Oak fixed addresses"?h:{...h,name:p(h.name)}}export{z as a,Pe as b,Q as c,J as d,we as e,$ as f,Ee as g,W as h,nn as i,Ae as j,Me as k,tn as l,sn as m,on as n,an as o};
@@ -1 +1 @@
1
- import{i as l}from"./57MEFFCU.js";import{a}from"./XSD5NL7J.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"./7KWZ5QJU.js";import{a}from"./XSD5NL7J.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};
@@ -0,0 +1 @@
1
+ var e=1;export{e as a};
@@ -1 +1 @@
1
- import{b as me,c as De}from"./QA3UHEO3.js";import{c as Te,d as a,r as Ee}from"./64GOINYS.js";import{o as pe}from"./3NJ5KQ3Q.js";import{a as M}from"./3MLUCYCB.js";import{a as xe}from"./43LI5NKJ.js";import{a as te}from"./66F5ZH34.js";import{c as G,j as ve}from"./NWNYJ26T.js";import{b as ke}from"./IX3GZMTM.js";import{a as R,i as Ce}from"./FWD4L3CJ.js";import{a as t}from"./XSD5NL7J.js";import{decodeFunctionData as Se,erc20Abi as Oe}from"viem";var Fe="https://api.relay.link",q="0x0000000000000000000000000000000000000000",Le=60,Pe=30,n=Ce[R].relay.depository.address.toLowerCase(),ne="0x59916da825d2d2ec1bf878d71c88826f6633ecca",ie=new Map([[1,{chainId:"ethereum",depository:n}],[10,{chainId:"optimism",depository:n}],[25,{chainId:"cronos",depository:ne}],[56,{chainId:"bnb",depository:n}],[100,{chainId:"gnosis",depository:n}],[130,{chainId:"unichain",depository:n}],[137,{chainId:"polygon",depository:n}],[143,{chainId:"monad",depository:n}],[146,{chainId:"sonic",depository:n}],[169,{chainId:"manta",depository:n}],[196,{chainId:"xlayer",depository:n}],[288,{chainId:"boba",depository:n}],[324,{chainId:"zksync",depository:n}],[360,{chainId:"shape",depository:n}],[480,{chainId:"worldchain",depository:n}],[747,{chainId:"flow",depository:n}],[988,{chainId:"stable",depository:n}],[999,{chainId:"hyperevm",depository:n}],[1088,{chainId:"metis",depository:ne}],[1135,{chainId:"lisk",depository:n}],[1868,{chainId:"soneium",depository:n}],[2020,{chainId:"ronin",depository:n}],[2741,{chainId:"abstract",depository:n}],[2818,{chainId:"morph",depository:n}],[4217,{chainId:"tempo",depository:n}],[4326,{chainId:"megaeth",depository:n}],[5e3,{chainId:"mantle",depository:ne}],[5031,{chainId:"somnia",depository:n}],[5042,{chainId:"arc",depository:n}],[8453,{chainId:"base",depository:n}],[9745,{chainId:"plasma",depository:n}],[33139,{chainId:"apechain",depository:n}],[34443,{chainId:"mode",depository:n}],[42018,{chainId:"mythos",depository:n}],[42161,{chainId:"arbitrum",depository:n}],[42220,{chainId:"celo",depository:n}],[43114,{chainId:"avalanche",depository:n}],[48900,{chainId:"zircuit",depository:n}],[57073,{chainId:"ink",depository:n}],[59144,{chainId:"linea",depository:ne}],[60808,{chainId:"bob",depository:n}],[80094,{chainId:"berachain",depository:n}],[97477,{chainId:"doma",depository:n}],[98866,{chainId:"plume",depository:n}],[534352,{chainId:"scroll",depository:n}],[685689,{chainId:"gensyn",depository:n}],[747474,{chainId:"katana",depository:n}],[5064014,{chainId:"ethereal",depository:n}],[7777777,{chainId:"zora",depository:n}]]),nt=Object.freeze(["robinhood",...Array.from(ie.values(),e=>e.chainId)]);function ot(e){return e===R?"robinhood":ie.get(e)?.chainId}function it(e){return ie.get(e)?.depository}function j(e){return ve(e,"Provide a token or wallet address.")}function I(e){let o=j(e);return o===M?q:o}function f(e,o){return j(e)===j(o)}function l(e){if(typeof e!="string")throw new t("Provide a decimal base-unit amount string.");return ke(e),e}function oe(e){let o=l(e);if(BigInt(o)<=0n)throw new t("Provide a positive base-unit amount.");return o}function ze(e){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)throw new t("Provide a positive integer origin chain ID.");return e}function Ne(e,o){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)throw new t(`${o} is missing or invalid.`);return e}async function V(e,o,c,i,p){let r=a(c);if(r.chainId!==i||I(r.address)!==p||typeof r.symbol!="string"||!/^[A-Za-z0-9._-]{1,32}$/.test(r.symbol))throw new t("Relay quote token metadata does not match the requested chain and address.");if(p===q){if(r.decimals!==18)throw new t("Native token decimals must be 18.");return{address:M,chainId:i,symbol:r.symbol,decimals:18}}let g=`${i}:${p}`,m=o.get(g);if(m===void 0){let d=await e.clientFor(i).readContract({address:p,abi:Oe,functionName:"decimals"}),w=typeof d=="bigint"?Number(d):d;if(typeof w!="number"||!Number.isInteger(w)||w<0||w>255)throw new t("Could not read valid ERC-20 decimals() on-chain.");m=w,o.set(g,m)}return{address:p,chainId:i,symbol:r.symbol,decimals:m}}async function Ke(e,o,c,i,p,r,g){if(c.swap===void 0)return[];let m=a(c.swap),d=a(m.from);if(d.chainId!==p)throw new t("The swap prerequisite token must be on the origin chain.");let w=await V(e,o,d,p,I(d.address)),F=r===q?M:r;if(f(w.address,F))throw new t("The swap prerequisite must use a different input token.");let he=oe(m.amountIn),y=m.slippageBps;if(y!==void 0&&(typeof y!="number"||!Number.isInteger(y)||y<0||y>1e4))throw new t("Provide swap slippage in basis points from 0 to 10000.");let D=await e.quoteSwap({from:w.address,to:F,amountIn:he,...y===void 0?{}:{slippageBps:y}},i);if(BigInt(l(D.expiresAt))<=BigInt(Math.floor(Date.now()/1e3)))throw new t("The swap prerequisite quote expired. Request a fresh quote.");if(BigInt(l(D.minAmountOut))<BigInt(g))throw new t("The swap prerequisite minimum cannot cover the bridge amount.");let C=await e.buildSwap(D.quoteId,i);if(!("txs"in C)||!C.txs.length)throw new t("The swap prerequisite must return unsigned transactions.");if(C.txs.some(S=>S.chainId!==p))throw new t("The injected swap coordinator does not support this origin chain.");return C.txs.map(S=>e.unsignedTx(S))}async function Ue(e,o,c){xe(c);let i=ze(o.originChainId);if(i===R)throw new t("Inbound bridging requires an origin chain other than 4663.");let p=ie.get(i);if(!p)throw new t("Relay inbound does not support this origin chain.");if(o.destinationChainId!==void 0&&o.destinationChainId!==R)throw new t("Inbound bridge destination must be chain 4663.");let r=I(o.originCurrency??M),g=I(o.destinationCurrency??M),m=j(o.recipient??c),d=oe(o.amount),w=o.minAmountOut===void 0?void 0:l(o.minAmountOut),F=o.slippageBps===void 0?me:o.slippageBps;if(pe("0",F),await e.clientFor(i).getChainId()!==i)throw new t("The RPC chain does not match the inbound origin chain.");let y=new Map,D=await Ke(e,y,o,c,i,r,d),C,S=process.env.OAK_RELAY_API_KEY?.trim();if(!S)throw new t("Configure OAK_RELAY_API_KEY on the server: Relay quote/v2 requires a valid API key since October 2, 2026. Status and chain reads remain available without it.");try{let s=await e.http(`${Fe}/quote/v2`,{method:"POST",headers:{"content-type":"application/json","user-agent":"oak-core/0.1.0","x-api-key":S},body:JSON.stringify({user:c,recipient:m,originChainId:i,destinationChainId:R,originCurrency:r,destinationCurrency:g,amount:d,tradeType:"EXACT_INPUT",includeProtocolData:!0,...r===q?{}:{explicitDeposit:!0}})});if(!s.ok)throw new Error("Relay HTTP failure.");C=await s.json()}catch{throw new t("Relay quote request failed. Please try again.")}let b=a(C);if(typeof b.requestId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(b.requestId))throw new t("Relay returned an invalid request ID.");let P=b.requestId,ye=`/intents/status/v3?requestId=${P}`,L=a(b.details);if(!f(L.sender,c)||!f(L.recipient,m))throw new t("Relay quote sender or recipient does not match the request.");let le=a(L.currencyIn),re=a(L.currencyOut),N=await V(e,y,le.currency,i,r),O=await V(e,y,re.currency,R,g);if(l(le.amount)!==d)throw new t("Relay quote input amount does not match the request.");let _=oe(re.amount),k=oe(re.minimumAmount);if(BigInt(k)>BigInt(_))throw new t("Relay quote minimum output exceeds the expected output.");if(w!==void 0){if(k!==w)throw new t("Relay order minimum must exactly match minAmountOut. Request a new quote.")}else{let s=pe(_,F);if(BigInt(k)<BigInt(s))throw De(_,k)}let fe=a(a(b.fees).relayer),we=a(fe.currency),Q=await V(e,y,we,i,I(we.address)),Ie={token:Q,amount:l(fe.amount)},ge=a(L.refundCurrency),_e=a(ge.currency),z=await V(e,y,_e,i,r),se=l(ge.amount),K=a(a(b.protocol).v2);if(typeof K.orderId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(K.orderId))throw new t("Relay returned an invalid order ID.");let W=K.orderId.toLowerCase(),J=a(K.paymentDetails),$=j(J.depository);if(J.chainId!==p.chainId||$!==p.depository||I(J.currency)!==r||l(J.amount)!==d)throw new t("Relay payment details do not match the origin chain depository and input.");let U=a(K.orderData),v=a(U.output);if(v.chainId!=="robinhood"||!Array.isArray(v.calls)||v.calls.length!==0||!Array.isArray(v.payments)||v.payments.length!==1)throw new t("Relay order output does not match destination chain 4663.");let X=a(v.payments[0]);if(!f(X.recipient,m)||I(X.currency)!==g||l(X.minimumAmount)!==k||l(X.expectedAmount)!==_)throw new t("Relay order output payment does not match the quoted recipient and amounts.");let ae=Ne(v.deadline,"Relay order output deadline");if(!Array.isArray(U.inputs)||!U.inputs.length)throw new t("Relay order has no inputs.");let Z=[],de=[];for(let s of U.inputs){let u=a(s),T=a(u.payment);if(T.chainId!==p.chainId||I(T.currency)!==r||l(T.amount)!==d||!Array.isArray(u.refunds)||!u.refunds.length)throw new t("Relay order input does not match the quoted input.");for(let E of u.refunds){let h=a(E);if(!f(h.recipient,c))throw new t("Relay refund recipient does not match the agent wallet. Request a new quote.");if(Z.push(Ne(h.deadline,"Relay order refund deadline")),de.push(l(h.minimumAmount)),!(h.chainId===p.chainId?f(h.recipient,c)&&I(h.currency)===r:h.chainId==="robinhood"&&I(h.currency)===g))throw new t("Relay order refund terms do not match the sender or recipient.")}}let be=Math.min(ae,...Z),Y=0,Ae=()=>{let s=Math.floor(Date.now()/1e3),u=Y||s+Le;if(be-s<=Pe)throw new t("Relay order deadline is expired or too soon to sign safely. Request a new quote.");if(Y=Math.min(u,be-Pe),Y<=s)throw new t("Relay quote expired before signing. Request a new quote.")};if(Ae(),!Array.isArray(b.steps)||!b.steps.length)throw new t("Relay returned no origin transactions.");let x=[];for(let s of b.steps){let u=a(s);if(u.kind!=="transaction"||u.requestId!==P||!Array.isArray(u.items)||!u.items.length)throw new t("Relay returned an unsupported origin step.");for(let T of u.items){let E=a(T),h=a(E.data),ce=a(E.check);if(E.status!=="incomplete"||h.chainId!==i||!f(h.from,c))throw new t("Relay transaction does not match the origin chain and sender.");if(ce.method!=="GET"||ce.endpoint!==ye)throw new t("Relay status endpoint does not match the request ID.");x.push(e.unsignedTx({to:j(h.to),data:h.data,value:l(h.value),chainId:i,description:`Relay inbound deposit for request ${P}; destination chain 4663.`}))}}if(!x.length)throw new t("Relay returned no origin transactions.");if(r===q&&x.length!==1)throw new t("Relay native deposit must be a single depositNative transaction.");if(r!==q&&x.length>2)throw new t("Relay ERC-20 deposit allows at most one exact-amount approval before depositErc20.");for(let s of x.slice(0,-1)){if(!s.data.toLowerCase().startsWith("0x095ea7b3"))throw new t("Relay returned an unsupported prerequisite transaction.");let u=Se({abi:Oe,data:s.data});if(u.functionName!=="approve")throw new t("Relay returned an invalid approval.");let[T,E]=u.args;if(r===q||!f(s.to,r)||!f(T,$)||E!==BigInt(d)||s.value!=="0")throw new t("Relay approval must authorize the exact input amount for the origin depository.");s.description=`Approve exactly ${e.formatAmount(d,N.decimals)} ${N.symbol} (${d} base units of ${r}) for ${$} on chain ${i}.`}let B=x[x.length-1],H=r===q,ee=H?"depositNative":"depositErc20",Re=H?"depositNative(address,bytes32)":"depositErc20(address,address,uint256,bytes32)";if(!f(B.to,$)||B.value!==(H?d:"0")||!(H?/^0x[0-9a-fA-F]{136}$/:/^0x[0-9a-fA-F]{264}$/).test(B.data))throw new t(`Relay deposit transaction does not target the origin depository with ${ee} calldata.`);let A;try{A=Se({abi:Te,data:B.data})}catch{throw new t(`Relay deposit transaction must call ${Re}.`)}if(A.functionName!==ee)throw new t(`Relay deposit transaction must call ${Re}.`);let Be=A.args[0],Me=A.functionName==="depositErc20"?A.args[3]:A.args[1];if(A.functionName==="depositErc20"&&(!f(A.args[1],r)||A.args[2]!==BigInt(d)))throw new t("Relay depositErc20 token or amount does not match the quoted input.");if(!f(Be,c)||Me.toLowerCase()!==W)throw new t(`Relay ${ee} depositor or orderId does not match the wallet and quoted protocol.v2.orderId.`);B.description=`Relay inbound ${ee} for order ${W} (request ${P}); destination chain 4663.`;let ue=H?[]:await Ee(e,r,$,d,i,c);for(let[s,u]of ue.entries())u.description=ue.length===2&&s===0?`Reset the existing ${N.symbol} allowance for ${$} on chain ${i} to zero.`:`Approve exactly ${e.formatAmount(d,N.decimals)} ${N.symbol} (${d} base units of ${r}) for ${$} on chain ${i}.`;let $e=[...D,...ue,B],qe=await e.preview($e,c);Ae();let je=qe.changes.map(s=>{let u=s.amount.startsWith("-");return`${u?"-":""}${e.formatAmount(u?s.amount.slice(1):s.amount,s.token.decimals)} ${s.token.symbol} (${s.token.address}, chain ${s.token.chainId})`});return{txs:$e,preview:qe,requestId:P,orderId:W,orderData:U,depository:$,originChainId:i,destinationChainId:R,recipient:m,amountIn:{token:N,amount:d},amountOut:{token:O,amount:_},minAmountOut:k,relayerFee:Ie,refundCurrency:{token:z,amount:se,minimumAmounts:de},orderDeadline:String(ae),refundDeadlines:Z.map(String),expiresAt:String(Y),status:"pending",statusEndpoint:ye,summary:`${D.length?"Swap prerequisite first, then ":""}Relay inbound from chain ${i} to chain 4663 for ${m}; expected ${e.formatAmount(_,O.decimals)} ${O.symbol}, minimum ${e.formatAmount(k,O.decimals)} ${O.symbol} (${O.address}). Quoted relay fee ${e.formatAmount(Ie.amount,Q.decimals)} ${Q.symbol} (${Q.address}, chain ${i}); output is net of quoted fees. Order ${W} (request ${P}); output deadline ${ae}, refund deadlines ${Z.join(", ")}, quote expires ${Y}. Refund terms: details.refundCurrency quotes ${e.formatAmount(se,z.decimals)} ${z.symbol} (${se} base units) on chain ${z.chainId} (${z.address}), but protocol.v2 order refund floor is ${de.join(", ")} base units. ${je.join("; ")}. Unsigned origin transactions only; destination fulfillment remains pending. Track with relay_status; timeout or refund is not fulfillment.`}}var rt=e=>({tools:[{name:"relay_bridge_in",inputSchema:{type:"object",additionalProperties:!1,required:["originChainId","amount"],properties:{originChainId:{type:"integer",minimum:1},destinationChainId:{const:R},originCurrency:G,destinationCurrency:G,amount:te(),minAmountOut:te(),slippageBps:{type:"integer",minimum:0,maximum:9999,default:me},recipient:G,swap:{type:"object",additionalProperties:!1,required:["from","amountIn"],properties:{from:{type:"object",additionalProperties:!1,required:["address","chainId","symbol","decimals"],properties:{address:G,chainId:{type:"integer",minimum:1},symbol:{type:"string"},decimals:{type:"integer",minimum:0,maximum:255}}},amountIn:te(),slippageBps:{type:"integer",minimum:0,maximum:1e4}}}}},async execute(o,c){try{return await Ue(e,o,c)}catch(i){throw new t(e.plainError(i))}}}]});export{nt as a,ot as b,it as c,rt as d};
1
+ import{b as me,c as De}from"./QA3UHEO3.js";import{c as Te,d as a,r as Ee}from"./64GOINYS.js";import{o as pe}from"./BOVMED7R.js";import{a as M}from"./QHBS3PVU.js";import{a as xe}from"./43LI5NKJ.js";import{a as te}from"./66F5ZH34.js";import{c as G,j as ve}from"./NWNYJ26T.js";import{b as ke}from"./IX3GZMTM.js";import{a as R,i as Ce}from"./FWD4L3CJ.js";import{a as t}from"./XSD5NL7J.js";import{decodeFunctionData as Se,erc20Abi as Oe}from"viem";var Fe="https://api.relay.link",q="0x0000000000000000000000000000000000000000",Le=60,Pe=30,n=Ce[R].relay.depository.address.toLowerCase(),ne="0x59916da825d2d2ec1bf878d71c88826f6633ecca",ie=new Map([[1,{chainId:"ethereum",depository:n}],[10,{chainId:"optimism",depository:n}],[25,{chainId:"cronos",depository:ne}],[56,{chainId:"bnb",depository:n}],[100,{chainId:"gnosis",depository:n}],[130,{chainId:"unichain",depository:n}],[137,{chainId:"polygon",depository:n}],[143,{chainId:"monad",depository:n}],[146,{chainId:"sonic",depository:n}],[169,{chainId:"manta",depository:n}],[196,{chainId:"xlayer",depository:n}],[288,{chainId:"boba",depository:n}],[324,{chainId:"zksync",depository:n}],[360,{chainId:"shape",depository:n}],[480,{chainId:"worldchain",depository:n}],[747,{chainId:"flow",depository:n}],[988,{chainId:"stable",depository:n}],[999,{chainId:"hyperevm",depository:n}],[1088,{chainId:"metis",depository:ne}],[1135,{chainId:"lisk",depository:n}],[1868,{chainId:"soneium",depository:n}],[2020,{chainId:"ronin",depository:n}],[2741,{chainId:"abstract",depository:n}],[2818,{chainId:"morph",depository:n}],[4217,{chainId:"tempo",depository:n}],[4326,{chainId:"megaeth",depository:n}],[5e3,{chainId:"mantle",depository:ne}],[5031,{chainId:"somnia",depository:n}],[5042,{chainId:"arc",depository:n}],[8453,{chainId:"base",depository:n}],[9745,{chainId:"plasma",depository:n}],[33139,{chainId:"apechain",depository:n}],[34443,{chainId:"mode",depository:n}],[42018,{chainId:"mythos",depository:n}],[42161,{chainId:"arbitrum",depository:n}],[42220,{chainId:"celo",depository:n}],[43114,{chainId:"avalanche",depository:n}],[48900,{chainId:"zircuit",depository:n}],[57073,{chainId:"ink",depository:n}],[59144,{chainId:"linea",depository:ne}],[60808,{chainId:"bob",depository:n}],[80094,{chainId:"berachain",depository:n}],[97477,{chainId:"doma",depository:n}],[98866,{chainId:"plume",depository:n}],[534352,{chainId:"scroll",depository:n}],[685689,{chainId:"gensyn",depository:n}],[747474,{chainId:"katana",depository:n}],[5064014,{chainId:"ethereal",depository:n}],[7777777,{chainId:"zora",depository:n}]]),nt=Object.freeze(["robinhood",...Array.from(ie.values(),e=>e.chainId)]);function ot(e){return e===R?"robinhood":ie.get(e)?.chainId}function it(e){return ie.get(e)?.depository}function j(e){return ve(e,"Provide a token or wallet address.")}function I(e){let o=j(e);return o===M?q:o}function f(e,o){return j(e)===j(o)}function l(e){if(typeof e!="string")throw new t("Provide a decimal base-unit amount string.");return ke(e),e}function oe(e){let o=l(e);if(BigInt(o)<=0n)throw new t("Provide a positive base-unit amount.");return o}function ze(e){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)throw new t("Provide a positive integer origin chain ID.");return e}function Ne(e,o){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)throw new t(`${o} is missing or invalid.`);return e}async function V(e,o,c,i,p){let r=a(c);if(r.chainId!==i||I(r.address)!==p||typeof r.symbol!="string"||!/^[A-Za-z0-9._-]{1,32}$/.test(r.symbol))throw new t("Relay quote token metadata does not match the requested chain and address.");if(p===q){if(r.decimals!==18)throw new t("Native token decimals must be 18.");return{address:M,chainId:i,symbol:r.symbol,decimals:18}}let g=`${i}:${p}`,m=o.get(g);if(m===void 0){let d=await e.clientFor(i).readContract({address:p,abi:Oe,functionName:"decimals"}),w=typeof d=="bigint"?Number(d):d;if(typeof w!="number"||!Number.isInteger(w)||w<0||w>255)throw new t("Could not read valid ERC-20 decimals() on-chain.");m=w,o.set(g,m)}return{address:p,chainId:i,symbol:r.symbol,decimals:m}}async function Ke(e,o,c,i,p,r,g){if(c.swap===void 0)return[];let m=a(c.swap),d=a(m.from);if(d.chainId!==p)throw new t("The swap prerequisite token must be on the origin chain.");let w=await V(e,o,d,p,I(d.address)),F=r===q?M:r;if(f(w.address,F))throw new t("The swap prerequisite must use a different input token.");let he=oe(m.amountIn),y=m.slippageBps;if(y!==void 0&&(typeof y!="number"||!Number.isInteger(y)||y<0||y>1e4))throw new t("Provide swap slippage in basis points from 0 to 10000.");let D=await e.quoteSwap({from:w.address,to:F,amountIn:he,...y===void 0?{}:{slippageBps:y}},i);if(BigInt(l(D.expiresAt))<=BigInt(Math.floor(Date.now()/1e3)))throw new t("The swap prerequisite quote expired. Request a fresh quote.");if(BigInt(l(D.minAmountOut))<BigInt(g))throw new t("The swap prerequisite minimum cannot cover the bridge amount.");let C=await e.buildSwap(D.quoteId,i);if(!("txs"in C)||!C.txs.length)throw new t("The swap prerequisite must return unsigned transactions.");if(C.txs.some(S=>S.chainId!==p))throw new t("The injected swap coordinator does not support this origin chain.");return C.txs.map(S=>e.unsignedTx(S))}async function Ue(e,o,c){xe(c);let i=ze(o.originChainId);if(i===R)throw new t("Inbound bridging requires an origin chain other than 4663.");let p=ie.get(i);if(!p)throw new t("Relay inbound does not support this origin chain.");if(o.destinationChainId!==void 0&&o.destinationChainId!==R)throw new t("Inbound bridge destination must be chain 4663.");let r=I(o.originCurrency??M),g=I(o.destinationCurrency??M),m=j(o.recipient??c),d=oe(o.amount),w=o.minAmountOut===void 0?void 0:l(o.minAmountOut),F=o.slippageBps===void 0?me:o.slippageBps;if(pe("0",F),await e.clientFor(i).getChainId()!==i)throw new t("The RPC chain does not match the inbound origin chain.");let y=new Map,D=await Ke(e,y,o,c,i,r,d),C,S=process.env.OAK_RELAY_API_KEY?.trim();if(!S)throw new t("Configure OAK_RELAY_API_KEY on the server: Relay quote/v2 requires a valid API key since October 2, 2026. Status and chain reads remain available without it.");try{let s=await e.http(`${Fe}/quote/v2`,{method:"POST",headers:{"content-type":"application/json","user-agent":"oak-core/0.1.0","x-api-key":S},body:JSON.stringify({user:c,recipient:m,originChainId:i,destinationChainId:R,originCurrency:r,destinationCurrency:g,amount:d,tradeType:"EXACT_INPUT",includeProtocolData:!0,...r===q?{}:{explicitDeposit:!0}})});if(!s.ok)throw new Error("Relay HTTP failure.");C=await s.json()}catch{throw new t("Relay quote request failed. Please try again.")}let b=a(C);if(typeof b.requestId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(b.requestId))throw new t("Relay returned an invalid request ID.");let P=b.requestId,ye=`/intents/status/v3?requestId=${P}`,L=a(b.details);if(!f(L.sender,c)||!f(L.recipient,m))throw new t("Relay quote sender or recipient does not match the request.");let le=a(L.currencyIn),re=a(L.currencyOut),N=await V(e,y,le.currency,i,r),O=await V(e,y,re.currency,R,g);if(l(le.amount)!==d)throw new t("Relay quote input amount does not match the request.");let _=oe(re.amount),k=oe(re.minimumAmount);if(BigInt(k)>BigInt(_))throw new t("Relay quote minimum output exceeds the expected output.");if(w!==void 0){if(k!==w)throw new t("Relay order minimum must exactly match minAmountOut. Request a new quote.")}else{let s=pe(_,F);if(BigInt(k)<BigInt(s))throw De(_,k)}let fe=a(a(b.fees).relayer),we=a(fe.currency),Q=await V(e,y,we,i,I(we.address)),Ie={token:Q,amount:l(fe.amount)},ge=a(L.refundCurrency),_e=a(ge.currency),z=await V(e,y,_e,i,r),se=l(ge.amount),K=a(a(b.protocol).v2);if(typeof K.orderId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(K.orderId))throw new t("Relay returned an invalid order ID.");let W=K.orderId.toLowerCase(),J=a(K.paymentDetails),$=j(J.depository);if(J.chainId!==p.chainId||$!==p.depository||I(J.currency)!==r||l(J.amount)!==d)throw new t("Relay payment details do not match the origin chain depository and input.");let U=a(K.orderData),v=a(U.output);if(v.chainId!=="robinhood"||!Array.isArray(v.calls)||v.calls.length!==0||!Array.isArray(v.payments)||v.payments.length!==1)throw new t("Relay order output does not match destination chain 4663.");let X=a(v.payments[0]);if(!f(X.recipient,m)||I(X.currency)!==g||l(X.minimumAmount)!==k||l(X.expectedAmount)!==_)throw new t("Relay order output payment does not match the quoted recipient and amounts.");let ae=Ne(v.deadline,"Relay order output deadline");if(!Array.isArray(U.inputs)||!U.inputs.length)throw new t("Relay order has no inputs.");let Z=[],de=[];for(let s of U.inputs){let u=a(s),T=a(u.payment);if(T.chainId!==p.chainId||I(T.currency)!==r||l(T.amount)!==d||!Array.isArray(u.refunds)||!u.refunds.length)throw new t("Relay order input does not match the quoted input.");for(let E of u.refunds){let h=a(E);if(!f(h.recipient,c))throw new t("Relay refund recipient does not match the agent wallet. Request a new quote.");if(Z.push(Ne(h.deadline,"Relay order refund deadline")),de.push(l(h.minimumAmount)),!(h.chainId===p.chainId?f(h.recipient,c)&&I(h.currency)===r:h.chainId==="robinhood"&&I(h.currency)===g))throw new t("Relay order refund terms do not match the sender or recipient.")}}let be=Math.min(ae,...Z),Y=0,Ae=()=>{let s=Math.floor(Date.now()/1e3),u=Y||s+Le;if(be-s<=Pe)throw new t("Relay order deadline is expired or too soon to sign safely. Request a new quote.");if(Y=Math.min(u,be-Pe),Y<=s)throw new t("Relay quote expired before signing. Request a new quote.")};if(Ae(),!Array.isArray(b.steps)||!b.steps.length)throw new t("Relay returned no origin transactions.");let x=[];for(let s of b.steps){let u=a(s);if(u.kind!=="transaction"||u.requestId!==P||!Array.isArray(u.items)||!u.items.length)throw new t("Relay returned an unsupported origin step.");for(let T of u.items){let E=a(T),h=a(E.data),ce=a(E.check);if(E.status!=="incomplete"||h.chainId!==i||!f(h.from,c))throw new t("Relay transaction does not match the origin chain and sender.");if(ce.method!=="GET"||ce.endpoint!==ye)throw new t("Relay status endpoint does not match the request ID.");x.push(e.unsignedTx({to:j(h.to),data:h.data,value:l(h.value),chainId:i,description:`Relay inbound deposit for request ${P}; destination chain 4663.`}))}}if(!x.length)throw new t("Relay returned no origin transactions.");if(r===q&&x.length!==1)throw new t("Relay native deposit must be a single depositNative transaction.");if(r!==q&&x.length>2)throw new t("Relay ERC-20 deposit allows at most one exact-amount approval before depositErc20.");for(let s of x.slice(0,-1)){if(!s.data.toLowerCase().startsWith("0x095ea7b3"))throw new t("Relay returned an unsupported prerequisite transaction.");let u=Se({abi:Oe,data:s.data});if(u.functionName!=="approve")throw new t("Relay returned an invalid approval.");let[T,E]=u.args;if(r===q||!f(s.to,r)||!f(T,$)||E!==BigInt(d)||s.value!=="0")throw new t("Relay approval must authorize the exact input amount for the origin depository.");s.description=`Approve exactly ${e.formatAmount(d,N.decimals)} ${N.symbol} (${d} base units of ${r}) for ${$} on chain ${i}.`}let B=x[x.length-1],H=r===q,ee=H?"depositNative":"depositErc20",Re=H?"depositNative(address,bytes32)":"depositErc20(address,address,uint256,bytes32)";if(!f(B.to,$)||B.value!==(H?d:"0")||!(H?/^0x[0-9a-fA-F]{136}$/:/^0x[0-9a-fA-F]{264}$/).test(B.data))throw new t(`Relay deposit transaction does not target the origin depository with ${ee} calldata.`);let A;try{A=Se({abi:Te,data:B.data})}catch{throw new t(`Relay deposit transaction must call ${Re}.`)}if(A.functionName!==ee)throw new t(`Relay deposit transaction must call ${Re}.`);let Be=A.args[0],Me=A.functionName==="depositErc20"?A.args[3]:A.args[1];if(A.functionName==="depositErc20"&&(!f(A.args[1],r)||A.args[2]!==BigInt(d)))throw new t("Relay depositErc20 token or amount does not match the quoted input.");if(!f(Be,c)||Me.toLowerCase()!==W)throw new t(`Relay ${ee} depositor or orderId does not match the wallet and quoted protocol.v2.orderId.`);B.description=`Relay inbound ${ee} for order ${W} (request ${P}); destination chain 4663.`;let ue=H?[]:await Ee(e,r,$,d,i,c);for(let[s,u]of ue.entries())u.description=ue.length===2&&s===0?`Reset the existing ${N.symbol} allowance for ${$} on chain ${i} to zero.`:`Approve exactly ${e.formatAmount(d,N.decimals)} ${N.symbol} (${d} base units of ${r}) for ${$} on chain ${i}.`;let $e=[...D,...ue,B],qe=await e.preview($e,c);Ae();let je=qe.changes.map(s=>{let u=s.amount.startsWith("-");return`${u?"-":""}${e.formatAmount(u?s.amount.slice(1):s.amount,s.token.decimals)} ${s.token.symbol} (${s.token.address}, chain ${s.token.chainId})`});return{txs:$e,preview:qe,requestId:P,orderId:W,orderData:U,depository:$,originChainId:i,destinationChainId:R,recipient:m,amountIn:{token:N,amount:d},amountOut:{token:O,amount:_},minAmountOut:k,relayerFee:Ie,refundCurrency:{token:z,amount:se,minimumAmounts:de},orderDeadline:String(ae),refundDeadlines:Z.map(String),expiresAt:String(Y),status:"pending",statusEndpoint:ye,summary:`${D.length?"Swap prerequisite first, then ":""}Relay inbound from chain ${i} to chain 4663 for ${m}; expected ${e.formatAmount(_,O.decimals)} ${O.symbol}, minimum ${e.formatAmount(k,O.decimals)} ${O.symbol} (${O.address}). Quoted relay fee ${e.formatAmount(Ie.amount,Q.decimals)} ${Q.symbol} (${Q.address}, chain ${i}); output is net of quoted fees. Order ${W} (request ${P}); output deadline ${ae}, refund deadlines ${Z.join(", ")}, quote expires ${Y}. Refund terms: details.refundCurrency quotes ${e.formatAmount(se,z.decimals)} ${z.symbol} (${se} base units) on chain ${z.chainId} (${z.address}), but protocol.v2 order refund floor is ${de.join(", ")} base units. ${je.join("; ")}. Unsigned origin transactions only; destination fulfillment remains pending. Track with relay_status; timeout or refund is not fulfillment.`}}var rt=e=>({tools:[{name:"relay_bridge_in",inputSchema:{type:"object",additionalProperties:!1,required:["originChainId","amount"],properties:{originChainId:{type:"integer",minimum:1},destinationChainId:{const:R},originCurrency:G,destinationCurrency:G,amount:te(),minAmountOut:te(),slippageBps:{type:"integer",minimum:0,maximum:9999,default:me},recipient:G,swap:{type:"object",additionalProperties:!1,required:["from","amountIn"],properties:{from:{type:"object",additionalProperties:!1,required:["address","chainId","symbol","decimals"],properties:{address:G,chainId:{type:"integer",minimum:1},symbol:{type:"string"},decimals:{type:"integer",minimum:0,maximum:255}}},amountIn:te(),slippageBps:{type:"integer",minimum:0,maximum:1e4}}}}},async execute(o,c){try{return await Ue(e,o,c)}catch(i){throw new t(e.plainError(i))}}}]});export{nt as a,ot as b,it as c,rt as d};
@@ -1 +1 @@
1
- import{a as j}from"./NCQFWPAW.js";import{a as v}from"./6OGDTEGH.js";import{K as A}from"./SSHCD6RZ.js";import{c as k}from"./P56RZC2M.js";import{a as O}from"./43LI5NKJ.js";import{a as x}from"./66F5ZH34.js";import{d as F,g as M,i as q,m as $}from"./NWNYJ26T.js";import{a as y}from"./FWD4L3CJ.js";import{a}from"./XSD5NL7J.js";import{encodeFunctionData as G,erc20Abi as R,getAddress as g,zeroAddress as z}from"viem";var D={genesis:g("0x575b7B7c97Ef3E21C82DAeB427899d583e1E913f"),bond:g("0xff32a969A0c567129eECD926D04657728E1980C1"),inverse:g("0x92166e94Eea5B7799b761653881692f881dFC4C9"),treasury:g("0x04822Ea321A0DEE6F40656172F29312104855d66"),pteam:g("0x650F58079dAa17ee28928c2F92d22291d038B2B0"),rwa:g("0x99B6eE6eDe47d9a8a9bfd03F728a99B789df1961"),premium:g("0x346e1a31171A0f7aC73909010b5435768d3B5462"),tax:g("0x086C58400b8708Ef993f256E12e752dcF0AC918e")},H=g("0x59F95461E68e0c77605299791E1449f175165B54"),_={genesis:["purchase","finalize","refund","claim"],bond:["deposit","redeem"],inverse:["swap"],treasury:["rebalanceToMorpho","rebalanceFromMorpho","mintNet","spendUsdg"],pteam:["exercise"],rwa:["redeem","depositInventory","pokeHwm","setDiscount","setInventoryMax","setHalt","setMenu","skim"],premium:["execute"],tax:["convert"]},V={genesis:["wired","finalized","finalizeTime","saleStart","saleDeadline","raisedRaw","totalRaised","registryLength"],bond:["wired","enabled","startTime","marketCount"],inverse:["active","price","capacityRemaining","spreadBps"],treasury:["wired","rfv","backingPerToken","liquidUsdg","morphoAssets","polRfv","morphoCapBps","morphoVault","canonicalPair"],pteam:["wired","holder","vestedFraction","exercisableNow","exercised","strikeWad","capBps","circulatingSupply","excludedFromFloat"],rwa:["manager","halted","inventory","inventoryMax","owedNet","bHwm","deskDiscountBps","VEST","MAX_DISCOUNT_BPS","INVENTORY_HARD_CAP","menu","routerSource","sleeve"],premium:["active","clipSize","lastExecuteAt","premiumThresholdWad","router","pairContract"],tax:["wired","pendingNet","teamBps","treasuryBps","teamWallet","router","pairContract"]},T=h=>JSON.parse(JSON.stringify(h,(P,E)=>typeof E=="bigint"?E.toString():E));function N(h){return q(h,"Provide a checksummed address.",F)}var ae=h=>{async function P(t){if(typeof t!="string"||!Object.hasOwn(D,t))throw new a("Choose a published NetNet financial product.");let c=t,e=D[c],r=j[c],u=h.clientFor(y);if(await u.getChainId()!==y)throw new a("NetNet requires chain 4663.");let n=await u.getBlock(),o=(w,I=[])=>u.readContract({address:e,abi:r,functionName:w,args:I,blockNumber:n.number}),[i,s,l,p]=await Promise.all([o("net"),o("usdg"),u.readContract({address:v.address,abi:R,functionName:"decimals",blockNumber:n.number}),u.readContract({address:k.address,abi:R,functionName:"decimals",blockNumber:n.number})]);if(N(i)!==v.address||N(s)!==k.address||l!==v.decimals||p!==k.decimals)throw new a("NetNet financial token pins or decimals do not match the deployment.");return{product:c,contract:e,abi:r,rpc:u,block:n,read:o}}async function E(t){O(t);let c=(e,r)=>({module:"netnet",id:`4663:${D.bond.toLowerCase()}:${e}`,chainId:y,incomplete:!0,assets:[],description:`NetNet bond notes unreadable: ${h.plainError(r)} Use netnet_financial_status with product bond to inspect notes.`});try{let e=await P("bond"),r=$(await e.read("noteCount",[t]),"Invalid NetNet bond note count."),u=r<50n?Number(r):50,n=[];for(let o=0;o<u;o++)try{let i=await e.read("notes",[t,BigInt(o)]);if(!Array.isArray(i)||i.length!==4)throw new a("Invalid NetNet bond note.");let[s,l,p,w]=i.map(C=>$(C,"Invalid NetNet bond note amount or timestamp."));if(l>s||w<=p||w>=1n<<64n)throw new a("Invalid NetNet bond note vesting or claimed amount.");let I=s-l;if(I===0n)continue;let S=e.block.timestamp>=w?s:e.block.timestamp<=p?0n:s*(e.block.timestamp-p)/(w-p),B=S>l?S-l:0n;n.push({module:"netnet",id:`4663:${e.contract.toLowerCase()}:${o}`,chainId:y,matured:e.block.timestamp>=w,assets:[{token:v,amount:I.toString()}],description:`NetNet bond note ${o}: ${I} NET base units outstanding; ${B} claimable now, vesting ends at Unix ${w}. Redeem vested NET with netnet_financial_action product bond operation redeem. Payment cannot be withdrawn. Block ${e.block.number}.`})}catch(i){n.push(c(String(o),i))}return r>BigInt(u)&&n.push({module:"netnet",id:`4663:${e.contract.toLowerCase()}:coverage`,chainId:y,incomplete:!0,assets:[],description:`NetNet bond positions checked the first ${u} of ${r} notes. Use netnet_financial_status product bond offset ${u} to read the remaining notes.`}),n}catch(e){return[c("unreadable",e)]}}let U=(t,c,e,r)=>({name:t,inputSchema:{type:"object",properties:c,required:e,additionalProperties:!1},execute:async(u,n)=>{try{if(O(n),Object.keys(u).some(o=>!Object.hasOwn(c,o)))throw new a("Unsupported NetNet financial argument.");return await r(u,n)}catch(o){throw new a(h.plainError(o))}}}),W={type:"string",enum:Object.keys(D)};return{positions:E,tools:[U("netnet_financial_status",{product:W,offset:{type:"integer",minimum:0},limit:{type:"integer",minimum:1,maximum:50}},["product"],async(t,c)=>{let e=await P(t.product),r=V[e.product],u=t.offset??0,n=t.limit??20;if(!Number.isSafeInteger(u)||Number(u)<0||!Number.isSafeInteger(n)||Number(n)<1||Number(n)>50)throw new a("Use a nonnegative offset and limit 1..50.");let o=await Promise.all(r.map(async s=>{try{return[s,{value:T(await e.read(s))}]}catch(l){return[s,{unavailable:h.plainError(l)}]}})),i={};if(e.product==="genesis")for(let s of["purchasedRaw","purchasedNetOf","claimedNet","claimableNetOf"])i[s]=T(await e.read(s,[c]));if(e.product==="bond"||e.product==="rwa"){i.pending=T(await e.read("pendingFor",[c]));let s=await e.read("noteCount",[c]);if(typeof s!="bigint"||s<0n)throw new a("Invalid NetNet note count.");let l=s<BigInt(Number(u)+Number(n))?s:BigInt(Number(u)+Number(n));i.noteCount=s.toString(),i.notes=await Promise.all(Array.from({length:Math.max(0,Number(l-BigInt(Number(u))))},async(p,w)=>({id:String(Number(u)+w),note:T(await e.read(e.product==="bond"?"notes":"noteAt",[c,BigInt(Number(u)+w)]))}))),i.nextOffset=l<s?l.toString():null,e.product==="bond"&&(i.markets=await Promise.all([0n,1n].map(async p=>{try{return{id:p.toString(),quoteToken:N(await e.read("quoteToken",[p])),priceWad:String(await e.read("bondPrice",[p]))}}catch(w){return{id:p.toString(),unavailable:h.plainError(w)}}})))}return e.product==="treasury"&&(i.isMinter=await e.read("isMinter",[c]),i.isSpender=await e.read("isSpender",[c])),{chainId:y,contract:e.contract,product:e.product,blockNumber:String(e.block.number),tokens:[v,k],metrics:Object.fromEntries(o),wallet:i,units:"Raw token amounts use each token\u2019s decimals. Prices, NAV, reserve values and capacityRemaining use 18-decimal USDG WAD. Note timestamps are Unix seconds.",operations:_[e.product],caveat:"An unavailable metric is not zero. Formulaic eligibility, oracle liveness, caps and vesting are checked by the action preview. RWA entry/router calldata and initial deployment wiring remain unsupported."}}),U("netnet_financial_action",{product:W,operation:{type:"string",enum:[...new Set(Object.values(_).flat())]},amount:x(),minAmountOut:x(),maxPriceWad:x(),maxPayment:x(),marketId:{type:"integer",enum:[0,1]},recipient:{type:"string"},halted:{type:"boolean"},token:{type:"string"},noteIds:{type:"array",maxItems:50,items:x()},menu:{type:"array",maxItems:32,items:{type:"object"}}},["product","operation"],async(t,c)=>{let e=await P(t.product),r=t.operation;if(typeof r!="string"||!_[e.product].includes(r))throw new a("This operation is not supported by the selected financial product.");let u=new Set(["product","operation"]),n=[],o,i=0n,s="",l=(...d)=>d.forEach(m=>u.add(m)),p=()=>(l("amount"),A(t.amount)),w=()=>(l("minAmountOut"),A(t.minAmountOut));if(e.product==="genesis"){if(r==="purchase"&&(i=p(),o=k,n=[i],s="Founding subscription; NET is claimable only after successful finalization and vesting. A failed sale requires refund."),r==="claim"&&await e.read("claimableNetOf",[c])===0n)throw new a("No vested founding NET is claimable by this wallet.")}else if(e.product==="bond")if(r==="deposit"){if(l("marketId","maxPriceWad"),t.marketId!==0&&t.marketId!==1)throw new a("Bond marketId must be 0 (USDG) or 1 (canonical LP).");let d=BigInt(t.marketId);if(N(await e.read("quoteToken",[d]))!==(d===0n?k.address:H))throw new a("Bond quote token is not the pinned USDG or canonical LP.");i=p(),o=d===0n?k:{address:H,decimals:18,symbol:"NET/USDG LP",chainId:y};let f=A(t.maxPriceWad),b=await e.read("bondPrice",[d]);if(typeof b!="bigint"||b===0n||b>f)throw new a("Bond price exceeds maxPriceWad or is invalid.");n=[d,i,f,c],s="Payment is exchanged for a non-transferable NET note with two-day linear vesting. Redeem vested NET with the same product; payment cannot be withdrawn."}else n=[c];else if(e.product==="inverse"){if(i=p(),o=v,n=[i,w()],s="Purchased NET is burned permanently; USDG pays directly to this wallet. Capacity is denominated in USDG WAD, not raw USDG.",await e.read("active")!==!0)throw new a("NetNet buyback is inactive: oracle, finalization or capacity is unavailable.")}else if(e.product==="pteam"){if(N(await e.read("holder"))!==g(c))throw new a("This wallet is not the immutable pTEAM holder.");let d=p();if(l("maxPayment"),d>await e.read("exercisableNow"))throw new a("The NET exercise amount exceeds the vested cap.");let m=await e.read("strikeWad");if(i=(d*m/10n**BigInt(v.decimals)+10n**12n-1n)/10n**12n,i===0n||i>A(t.maxPayment))throw new a("The exercise payment exceeds maxPayment or rounds to zero.");o=k,n=[d],s=`Exercise pays ${i} USDG base units into treasury reserves and mints ${d} NET base units to the immutable holder. No withdrawal or exercise reversal exists.`}else if(e.product==="treasury"){let d=p();if(r==="mintNet"||r==="spendUsdg"){l("recipient");let m=N(t.recipient);if(await e.read(r==="mintNet"?"isMinter":"isSpender",[c])!==!0)throw new a("This wallet lacks the fixed NetNet treasury minter/spender role.");n=[m,d],s=`Protocol treasury operation sends ${d} base units to ${m}; it does not deposit into this wallet\u2019s savings.`}else n=[d],s="Permissionless protocol reserve rebalance; assets remain owned by the NetNet treasury. The deployed fraction is constrained by the immutable cap."}else if(e.product==="rwa"){if(["depositInventory","setDiscount","setInventoryMax","setHalt","setMenu"].includes(r)&&N(await e.read("manager"))!==g(c))throw new a("This wallet lacks the immutable RWA manager role.");if(r==="redeem")if(l("noteIds"),t.noteIds===void 0)n=[c];else{if(!Array.isArray(t.noteIds)||!t.noteIds.length||t.noteIds.length>50)throw new a("Provide 1..50 unique note IDs.");let m=t.noteIds.map(b=>A(b,!0));if(new Set(m.map(String)).size!==m.length)throw new a("Note IDs must be unique.");let f=await e.read("noteCount",[c]);if(m.some(b=>b>=f))throw new a("RWA note ID is out of range.");n=[c,m]}else if(r==="setHalt"){if(l("halted"),typeof t.halted!="boolean")throw new a("Provide halted as a boolean.");n=[t.halted]}else if(r==="setMenu"){if(l("menu"),!Array.isArray(t.menu)||!t.menu.length||t.menu.length>32)throw new a("Provide 1..32 explicit RWA menu entries.");let m=t.menu.map(f=>{if(!f||typeof f!="object"||Array.isArray(f)||Object.keys(f).some(L=>!["token","feed","targetWeightBps","active"].includes(L)))throw new a("Invalid RWA menu fields.");let b=f;if(typeof b.active!="boolean")throw new a("RWA active must be boolean.");return{token:N(b.token),feed:N(b.feed),targetWeightBps:A(b.targetWeightBps,!0),active:b.active}});if(new Set(m.map(f=>f.token)).size!==m.length||m.reduce((f,b)=>f+b.targetWeightBps,0n)!==10000n||m.some(f=>f.active&&(f.token===z||f.feed===z)))throw new a("RWA menu tokens must be unique, weights sum to 10000, active feeds/tokens nonzero.");n=[m],s=`Replace the complete RWA equity menu: ${JSON.stringify(T(m))}.`}else if(r==="skim")l("token"),n=[N(t.token)],s=`Sweep eligible stray assets to sleeve ${N(await e.read("sleeve"))}, not to this wallet.`;else if(r!=="pokeHwm"){let m=p();if(n=[m],r==="depositInventory"&&(o=v,i=m,s="Inventory funding is one-way. The manager cannot withdraw these NET; they are committed to bond obligations."),r==="setDiscount"&&m>await e.read("MAX_DISCOUNT_BPS")||r==="setInventoryMax"&&m>await e.read("INVENTORY_HARD_CAP"))throw new a("RWA setting exceeds its immutable maximum.")}}else e.product==="premium"?(n=[w()],s="Permissionless mint-and-sell keeper operation; all sale proceeds go to NetNet treasury. The caller receives no reward."):(n=[p(),w()],s="Convert NET already owned by the tax collector. Proceeds split to treasury and team; the caller receives no reward and supplies no NET.");if(Object.keys(t).some(d=>!u.has(d)))throw new a("Unexpected fields for this NetNet operation.");if(o&&await e.rpc.readContract({address:o.address,abi:R,functionName:"balanceOf",args:[c],blockNumber:e.block.number})<i)throw new a(`Top up ${o.symbol}: needs ${i} base units.`);let I=`NetNet ${e.product}.${r}, contract ${e.contract}, chain ${y}, values ${JSON.stringify(T(n))}. ${o?`Approve exactly ${i} ${o.symbol} base units (${o.address}, decimals ${o.decimals}). `:""}${s}`,S=[...o?[h.approval(o.address,e.contract,i.toString(),y)]:[],h.unsignedTx({to:e.contract,data:G({abi:e.abi,functionName:r,args:n}),value:"0",chainId:y,description:I})],B=await h.preview(S,c),C=0n;for(let d of B.changes){if(!/^-?\d+$/.test(d.amount))throw new a("Invalid NetNet preview amount.");if(BigInt(d.amount)<0n&&(C-=BigInt(d.amount)),BigInt(d.amount)<0n&&(!o||d.token.chainId!==y||!M(d.token.address,o.address)||d.token.decimals!==o.decimals||-BigInt(d.amount)>i))throw new a("NetNet preview spends outside the exact input budget.")}if(C>i)throw new a("NetNet preview exceeds the aggregate input budget.");return{txs:S,preview:B,summary:I}})]}};export{D as a,H as b,ae as c};
1
+ import{a as v}from"./6OGDTEGH.js";import{a as j}from"./NCQFWPAW.js";import{K as A}from"./DHUDSOGR.js";import{c as k}from"./AEL62KCG.js";import{a as O}from"./43LI5NKJ.js";import{a as x}from"./66F5ZH34.js";import{d as F,g as M,i as q,m as $}from"./NWNYJ26T.js";import{a as y}from"./FWD4L3CJ.js";import{a}from"./XSD5NL7J.js";import{encodeFunctionData as G,erc20Abi as R,getAddress as g,zeroAddress as z}from"viem";var D={genesis:g("0x575b7B7c97Ef3E21C82DAeB427899d583e1E913f"),bond:g("0xff32a969A0c567129eECD926D04657728E1980C1"),inverse:g("0x92166e94Eea5B7799b761653881692f881dFC4C9"),treasury:g("0x04822Ea321A0DEE6F40656172F29312104855d66"),pteam:g("0x650F58079dAa17ee28928c2F92d22291d038B2B0"),rwa:g("0x99B6eE6eDe47d9a8a9bfd03F728a99B789df1961"),premium:g("0x346e1a31171A0f7aC73909010b5435768d3B5462"),tax:g("0x086C58400b8708Ef993f256E12e752dcF0AC918e")},H=g("0x59F95461E68e0c77605299791E1449f175165B54"),_={genesis:["purchase","finalize","refund","claim"],bond:["deposit","redeem"],inverse:["swap"],treasury:["rebalanceToMorpho","rebalanceFromMorpho","mintNet","spendUsdg"],pteam:["exercise"],rwa:["redeem","depositInventory","pokeHwm","setDiscount","setInventoryMax","setHalt","setMenu","skim"],premium:["execute"],tax:["convert"]},V={genesis:["wired","finalized","finalizeTime","saleStart","saleDeadline","raisedRaw","totalRaised","registryLength"],bond:["wired","enabled","startTime","marketCount"],inverse:["active","price","capacityRemaining","spreadBps"],treasury:["wired","rfv","backingPerToken","liquidUsdg","morphoAssets","polRfv","morphoCapBps","morphoVault","canonicalPair"],pteam:["wired","holder","vestedFraction","exercisableNow","exercised","strikeWad","capBps","circulatingSupply","excludedFromFloat"],rwa:["manager","halted","inventory","inventoryMax","owedNet","bHwm","deskDiscountBps","VEST","MAX_DISCOUNT_BPS","INVENTORY_HARD_CAP","menu","routerSource","sleeve"],premium:["active","clipSize","lastExecuteAt","premiumThresholdWad","router","pairContract"],tax:["wired","pendingNet","teamBps","treasuryBps","teamWallet","router","pairContract"]},T=h=>JSON.parse(JSON.stringify(h,(P,E)=>typeof E=="bigint"?E.toString():E));function N(h){return q(h,"Provide a checksummed address.",F)}var ae=h=>{async function P(t){if(typeof t!="string"||!Object.hasOwn(D,t))throw new a("Choose a published NetNet financial product.");let c=t,e=D[c],r=j[c],u=h.clientFor(y);if(await u.getChainId()!==y)throw new a("NetNet requires chain 4663.");let n=await u.getBlock(),o=(w,I=[])=>u.readContract({address:e,abi:r,functionName:w,args:I,blockNumber:n.number}),[i,s,l,p]=await Promise.all([o("net"),o("usdg"),u.readContract({address:v.address,abi:R,functionName:"decimals",blockNumber:n.number}),u.readContract({address:k.address,abi:R,functionName:"decimals",blockNumber:n.number})]);if(N(i)!==v.address||N(s)!==k.address||l!==v.decimals||p!==k.decimals)throw new a("NetNet financial token pins or decimals do not match the deployment.");return{product:c,contract:e,abi:r,rpc:u,block:n,read:o}}async function E(t){O(t);let c=(e,r)=>({module:"netnet",id:`4663:${D.bond.toLowerCase()}:${e}`,chainId:y,incomplete:!0,assets:[],description:`NetNet bond notes unreadable: ${h.plainError(r)} Use netnet_financial_status with product bond to inspect notes.`});try{let e=await P("bond"),r=$(await e.read("noteCount",[t]),"Invalid NetNet bond note count."),u=r<50n?Number(r):50,n=[];for(let o=0;o<u;o++)try{let i=await e.read("notes",[t,BigInt(o)]);if(!Array.isArray(i)||i.length!==4)throw new a("Invalid NetNet bond note.");let[s,l,p,w]=i.map(C=>$(C,"Invalid NetNet bond note amount or timestamp."));if(l>s||w<=p||w>=1n<<64n)throw new a("Invalid NetNet bond note vesting or claimed amount.");let I=s-l;if(I===0n)continue;let S=e.block.timestamp>=w?s:e.block.timestamp<=p?0n:s*(e.block.timestamp-p)/(w-p),B=S>l?S-l:0n;n.push({module:"netnet",id:`4663:${e.contract.toLowerCase()}:${o}`,chainId:y,matured:e.block.timestamp>=w,assets:[{token:v,amount:I.toString()}],description:`NetNet bond note ${o}: ${I} NET base units outstanding; ${B} claimable now, vesting ends at Unix ${w}. Redeem vested NET with netnet_financial_action product bond operation redeem. Payment cannot be withdrawn. Block ${e.block.number}.`})}catch(i){n.push(c(String(o),i))}return r>BigInt(u)&&n.push({module:"netnet",id:`4663:${e.contract.toLowerCase()}:coverage`,chainId:y,incomplete:!0,assets:[],description:`NetNet bond positions checked the first ${u} of ${r} notes. Use netnet_financial_status product bond offset ${u} to read the remaining notes.`}),n}catch(e){return[c("unreadable",e)]}}let U=(t,c,e,r)=>({name:t,inputSchema:{type:"object",properties:c,required:e,additionalProperties:!1},execute:async(u,n)=>{try{if(O(n),Object.keys(u).some(o=>!Object.hasOwn(c,o)))throw new a("Unsupported NetNet financial argument.");return await r(u,n)}catch(o){throw new a(h.plainError(o))}}}),W={type:"string",enum:Object.keys(D)};return{positions:E,tools:[U("netnet_financial_status",{product:W,offset:{type:"integer",minimum:0},limit:{type:"integer",minimum:1,maximum:50}},["product"],async(t,c)=>{let e=await P(t.product),r=V[e.product],u=t.offset??0,n=t.limit??20;if(!Number.isSafeInteger(u)||Number(u)<0||!Number.isSafeInteger(n)||Number(n)<1||Number(n)>50)throw new a("Use a nonnegative offset and limit 1..50.");let o=await Promise.all(r.map(async s=>{try{return[s,{value:T(await e.read(s))}]}catch(l){return[s,{unavailable:h.plainError(l)}]}})),i={};if(e.product==="genesis")for(let s of["purchasedRaw","purchasedNetOf","claimedNet","claimableNetOf"])i[s]=T(await e.read(s,[c]));if(e.product==="bond"||e.product==="rwa"){i.pending=T(await e.read("pendingFor",[c]));let s=await e.read("noteCount",[c]);if(typeof s!="bigint"||s<0n)throw new a("Invalid NetNet note count.");let l=s<BigInt(Number(u)+Number(n))?s:BigInt(Number(u)+Number(n));i.noteCount=s.toString(),i.notes=await Promise.all(Array.from({length:Math.max(0,Number(l-BigInt(Number(u))))},async(p,w)=>({id:String(Number(u)+w),note:T(await e.read(e.product==="bond"?"notes":"noteAt",[c,BigInt(Number(u)+w)]))}))),i.nextOffset=l<s?l.toString():null,e.product==="bond"&&(i.markets=await Promise.all([0n,1n].map(async p=>{try{return{id:p.toString(),quoteToken:N(await e.read("quoteToken",[p])),priceWad:String(await e.read("bondPrice",[p]))}}catch(w){return{id:p.toString(),unavailable:h.plainError(w)}}})))}return e.product==="treasury"&&(i.isMinter=await e.read("isMinter",[c]),i.isSpender=await e.read("isSpender",[c])),{chainId:y,contract:e.contract,product:e.product,blockNumber:String(e.block.number),tokens:[v,k],metrics:Object.fromEntries(o),wallet:i,units:"Raw token amounts use each token\u2019s decimals. Prices, NAV, reserve values and capacityRemaining use 18-decimal USDG WAD. Note timestamps are Unix seconds.",operations:_[e.product],caveat:"An unavailable metric is not zero. Formulaic eligibility, oracle liveness, caps and vesting are checked by the action preview. RWA entry/router calldata and initial deployment wiring remain unsupported."}}),U("netnet_financial_action",{product:W,operation:{type:"string",enum:[...new Set(Object.values(_).flat())]},amount:x(),minAmountOut:x(),maxPriceWad:x(),maxPayment:x(),marketId:{type:"integer",enum:[0,1]},recipient:{type:"string"},halted:{type:"boolean"},token:{type:"string"},noteIds:{type:"array",maxItems:50,items:x()},menu:{type:"array",maxItems:32,items:{type:"object"}}},["product","operation"],async(t,c)=>{let e=await P(t.product),r=t.operation;if(typeof r!="string"||!_[e.product].includes(r))throw new a("This operation is not supported by the selected financial product.");let u=new Set(["product","operation"]),n=[],o,i=0n,s="",l=(...d)=>d.forEach(m=>u.add(m)),p=()=>(l("amount"),A(t.amount)),w=()=>(l("minAmountOut"),A(t.minAmountOut));if(e.product==="genesis"){if(r==="purchase"&&(i=p(),o=k,n=[i],s="Founding subscription; NET is claimable only after successful finalization and vesting. A failed sale requires refund."),r==="claim"&&await e.read("claimableNetOf",[c])===0n)throw new a("No vested founding NET is claimable by this wallet.")}else if(e.product==="bond")if(r==="deposit"){if(l("marketId","maxPriceWad"),t.marketId!==0&&t.marketId!==1)throw new a("Bond marketId must be 0 (USDG) or 1 (canonical LP).");let d=BigInt(t.marketId);if(N(await e.read("quoteToken",[d]))!==(d===0n?k.address:H))throw new a("Bond quote token is not the pinned USDG or canonical LP.");i=p(),o=d===0n?k:{address:H,decimals:18,symbol:"NET/USDG LP",chainId:y};let f=A(t.maxPriceWad),b=await e.read("bondPrice",[d]);if(typeof b!="bigint"||b===0n||b>f)throw new a("Bond price exceeds maxPriceWad or is invalid.");n=[d,i,f,c],s="Payment is exchanged for a non-transferable NET note with two-day linear vesting. Redeem vested NET with the same product; payment cannot be withdrawn."}else n=[c];else if(e.product==="inverse"){if(i=p(),o=v,n=[i,w()],s="Purchased NET is burned permanently; USDG pays directly to this wallet. Capacity is denominated in USDG WAD, not raw USDG.",await e.read("active")!==!0)throw new a("NetNet buyback is inactive: oracle, finalization or capacity is unavailable.")}else if(e.product==="pteam"){if(N(await e.read("holder"))!==g(c))throw new a("This wallet is not the immutable pTEAM holder.");let d=p();if(l("maxPayment"),d>await e.read("exercisableNow"))throw new a("The NET exercise amount exceeds the vested cap.");let m=await e.read("strikeWad");if(i=(d*m/10n**BigInt(v.decimals)+10n**12n-1n)/10n**12n,i===0n||i>A(t.maxPayment))throw new a("The exercise payment exceeds maxPayment or rounds to zero.");o=k,n=[d],s=`Exercise pays ${i} USDG base units into treasury reserves and mints ${d} NET base units to the immutable holder. No withdrawal or exercise reversal exists.`}else if(e.product==="treasury"){let d=p();if(r==="mintNet"||r==="spendUsdg"){l("recipient");let m=N(t.recipient);if(await e.read(r==="mintNet"?"isMinter":"isSpender",[c])!==!0)throw new a("This wallet lacks the fixed NetNet treasury minter/spender role.");n=[m,d],s=`Protocol treasury operation sends ${d} base units to ${m}; it does not deposit into this wallet\u2019s savings.`}else n=[d],s="Permissionless protocol reserve rebalance; assets remain owned by the NetNet treasury. The deployed fraction is constrained by the immutable cap."}else if(e.product==="rwa"){if(["depositInventory","setDiscount","setInventoryMax","setHalt","setMenu"].includes(r)&&N(await e.read("manager"))!==g(c))throw new a("This wallet lacks the immutable RWA manager role.");if(r==="redeem")if(l("noteIds"),t.noteIds===void 0)n=[c];else{if(!Array.isArray(t.noteIds)||!t.noteIds.length||t.noteIds.length>50)throw new a("Provide 1..50 unique note IDs.");let m=t.noteIds.map(b=>A(b,!0));if(new Set(m.map(String)).size!==m.length)throw new a("Note IDs must be unique.");let f=await e.read("noteCount",[c]);if(m.some(b=>b>=f))throw new a("RWA note ID is out of range.");n=[c,m]}else if(r==="setHalt"){if(l("halted"),typeof t.halted!="boolean")throw new a("Provide halted as a boolean.");n=[t.halted]}else if(r==="setMenu"){if(l("menu"),!Array.isArray(t.menu)||!t.menu.length||t.menu.length>32)throw new a("Provide 1..32 explicit RWA menu entries.");let m=t.menu.map(f=>{if(!f||typeof f!="object"||Array.isArray(f)||Object.keys(f).some(L=>!["token","feed","targetWeightBps","active"].includes(L)))throw new a("Invalid RWA menu fields.");let b=f;if(typeof b.active!="boolean")throw new a("RWA active must be boolean.");return{token:N(b.token),feed:N(b.feed),targetWeightBps:A(b.targetWeightBps,!0),active:b.active}});if(new Set(m.map(f=>f.token)).size!==m.length||m.reduce((f,b)=>f+b.targetWeightBps,0n)!==10000n||m.some(f=>f.active&&(f.token===z||f.feed===z)))throw new a("RWA menu tokens must be unique, weights sum to 10000, active feeds/tokens nonzero.");n=[m],s=`Replace the complete RWA equity menu: ${JSON.stringify(T(m))}.`}else if(r==="skim")l("token"),n=[N(t.token)],s=`Sweep eligible stray assets to sleeve ${N(await e.read("sleeve"))}, not to this wallet.`;else if(r!=="pokeHwm"){let m=p();if(n=[m],r==="depositInventory"&&(o=v,i=m,s="Inventory funding is one-way. The manager cannot withdraw these NET; they are committed to bond obligations."),r==="setDiscount"&&m>await e.read("MAX_DISCOUNT_BPS")||r==="setInventoryMax"&&m>await e.read("INVENTORY_HARD_CAP"))throw new a("RWA setting exceeds its immutable maximum.")}}else e.product==="premium"?(n=[w()],s="Permissionless mint-and-sell keeper operation; all sale proceeds go to NetNet treasury. The caller receives no reward."):(n=[p(),w()],s="Convert NET already owned by the tax collector. Proceeds split to treasury and team; the caller receives no reward and supplies no NET.");if(Object.keys(t).some(d=>!u.has(d)))throw new a("Unexpected fields for this NetNet operation.");if(o&&await e.rpc.readContract({address:o.address,abi:R,functionName:"balanceOf",args:[c],blockNumber:e.block.number})<i)throw new a(`Top up ${o.symbol}: needs ${i} base units.`);let I=`NetNet ${e.product}.${r}, contract ${e.contract}, chain ${y}, values ${JSON.stringify(T(n))}. ${o?`Approve exactly ${i} ${o.symbol} base units (${o.address}, decimals ${o.decimals}). `:""}${s}`,S=[...o?[h.approval(o.address,e.contract,i.toString(),y)]:[],h.unsignedTx({to:e.contract,data:G({abi:e.abi,functionName:r,args:n}),value:"0",chainId:y,description:I})],B=await h.preview(S,c),C=0n;for(let d of B.changes){if(!/^-?\d+$/.test(d.amount))throw new a("Invalid NetNet preview amount.");if(BigInt(d.amount)<0n&&(C-=BigInt(d.amount)),BigInt(d.amount)<0n&&(!o||d.token.chainId!==y||!M(d.token.address,o.address)||d.token.decimals!==o.decimals||-BigInt(d.amount)>i))throw new a("NetNet preview spends outside the exact input budget.")}if(C>i)throw new a("NetNet preview exceeds the aggregate input budget.");return{txs:S,preview:B,summary:I}})]}};export{D as a,H as b,ae as c};
@@ -1 +1 @@
1
- import{b as U,c as G}from"./YDNTY67T.js";import{L as K}from"./SSHCD6RZ.js";import{a as N}from"./K3RDPI5J.js";import{c as P}from"./VYAJXLND.js";import{c as R,f as L,g as H,h as W,i as z}from"./7WSHW7KW.js";import{a as F}from"./43LI5NKJ.js";import{a as u}from"./66F5ZH34.js";import{g as I}from"./NWNYJ26T.js";import{a as _}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as S,erc20Abi as j,getAddress as T,parseAbi as k}from"viem";var w=k(["function asset() view returns (address)","function decimals() view returns (uint8)","function balanceOf(address) view returns (uint256)","function previewMint(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function mint(uint256 shares,address receiver) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256)"]);function q(t,s=!1){if(typeof t!="string"||!/^\d+$/.test(t)||t.length>78||BigInt(t)>=1n<<256n||!s&&BigInt(t)===0n)throw new o("Provide a positive uint256 decimal base-unit string.");return BigInt(t)}function le(t,s,v){return["details","analytics","manage","mint",s==="netnet"?"redeem":"withdraw_assets","force_exit","in_kind_exit"].map(e=>{let $=[...s==="longbow"?["vault"]:[],...e==="mint"?["shares","maxAssets"]:e==="redeem"?["shares"]:e==="withdraw_assets"?["amount"]:e==="force_exit"?["maxPenaltyAssets","minAmountOut"]:[]],m={...s==="longbow"?{vault:{type:"string",enum:v.map(i=>i.vault)}}:{}};e==="in_kind_exit"&&(Object.assign(m,{amount:u(),maxShares:u(),maxPenaltyAssets:u(),deadline:u()}),$.push("amount","maxShares","maxPenaltyAssets","deadline")),e==="mint"&&Object.assign(m,{shares:u(),maxAssets:u()}),e==="redeem"&&(m.shares=u()),e==="withdraw_assets"&&(m.amount=u()),e==="force_exit"&&Object.assign(m,{maxPenaltyAssets:u(),minAmountOut:u()});let J=P(t,`${s}_manage`,v[0].vault,v[0].asset),E=N(t,`${s}_analytics`,v[0].vault);if(e==="manage"||e==="analytics"){let i=e==="manage"?J.inputSchema:E.inputSchema;Object.assign(m,i.properties),e==="analytics"&&s==="longbow"&&(m.view={type:"string",enum:["apy","published_apy"]}),$.push(...i.required)}return{name:`${s}_${e}`,inputSchema:{type:"object",properties:m,required:$,additionalProperties:!1,...e==="analytics"&&s==="netnet"?{allOf:E.inputSchema.allOf}:{}},execute:async(i,r)=>{try{if(F(r),Object.keys(i).some(l=>!Object.hasOwn(m,l)))throw new o("Unsupported vault feature argument.");let A=s==="netnet"?v[0]:v.find(l=>typeof i.vault=="string"&&I(l.vault,i.vault));if(!A)throw new o("Choose a current vault returned by the project list tool.");let{vault:n,asset:a}=A,b={...i};if(delete b.vault,e==="details")return H(t,`${s}_details`,n,a).execute(b,r);if(e==="manage")return P(t,`${s}_manage`,n,a).execute(b,r);if(e==="analytics"){if(s==="longbow"&&i.view==="published_apy")return G(t,n,a,b);if(s==="longbow"&&i.view==="apy")return U(t,n,a,b);if(s==="longbow")throw new o("Choose apy or published_apy; the Longbow vault is not indexed by Morpho for other analytics views.");return{...await N(t,`${s}_analytics`,n).execute(b,r),asset:{...a,address:T(a.address)}}}if(e==="in_kind_exit")return K(t,n,a,i,r);let f=t.clientFor(_);if(await f.getChainId()!==_)throw new o("Vault actions require chain 4663.");let[Q,X,Y]=await Promise.all([f.readContract({address:n,abi:w,functionName:"asset"}),f.readContract({address:n,abi:w,functionName:"decimals"}),f.readContract({address:a.address,abi:j,functionName:"decimals"})]);if(T(Q)!==T(a.address)||X!==18||Y!==a.decimals)throw new o("Vault metadata does not match the pinned asset and shares.");let M=e==="force_exit"?await f.readContract({address:n,abi:w,functionName:"balanceOf",args:[r]}):void 0;if(e==="force_exit"){let l=await L(t,f,n,r,M,R(i.maxPenaltyAssets),a),C=q(i.minAmountOut),p=[l.tx],y=await t.preview(p,r);return z(y.changes,n,M,C,a),{txs:p,preview:y,summary:`${W(l.plan,a.symbol)} ${y.summary}`}}let d=e==="mint",g=e==="redeem",c=q(d||g?i.shares:i.amount),x=await f.readContract({address:n,abi:w,functionName:d?"previewMint":g?"previewRedeem":"previewWithdraw",args:[c]});if(x<=0n||d&&x>q(i.maxAssets))throw new o("Vault quote is zero or exceeds maxAssets.");let V=d?void 0:await f.readContract({address:n,abi:w,functionName:"balanceOf",args:[r]});if(!d&&(g?c:x)>V)throw new o("The wallet share balance cannot cover this exit.");let Z=d?S({abi:w,functionName:"mint",args:[c,r]}):g?S({abi:w,functionName:"redeem",args:[c,r,r]}):S({abi:w,functionName:"withdraw",args:[c,r,r]}),B=`${e} ${c} ${d||g?"18-decimal share":`${a.decimals}-decimal ${a.symbol}`} base units on ${n}; beneficiary ${r}.`,D=[...d?[t.approval(a.address,n,x.toString(),_)]:[],t.unsignedTx({to:n,data:Z,value:"0",chainId:_,description:B})],O=await t.preview(D,r),h=(l,C)=>O.changes.filter(p=>p.token.chainId===_&&I(p.token.address,l)).reduce((p,y)=>{if(y.token.decimals!==C||!/^-?\d+$/.test(y.amount))throw new o("Invalid vault preview metadata.");return p+BigInt(y.amount)},0n);if(d?h(a.address,a.decimals)!==-x||h(n,18)!==c:g?h(n,18)!==-c||h(a.address,a.decimals)<=0n:h(a.address,a.decimals)!==c||-h(n,18)<=0n||-h(n,18)>V)throw new o("Vault preview does not match the requested amount and beneficiary.");return{txs:D,preview:O,summary:`${B} Counterpart quote ${x} base units. Mint approval is exact; accrual may require a fresh quote. Standard ERC-4626 calls encode no minimum receipt. ${O.summary}`}}catch(A){throw new o(t.plainError(A))}}}})}export{le as a};
1
+ import{b as U,c as G}from"./YDNTY67T.js";import{L as K}from"./DHUDSOGR.js";import{a as N}from"./K3RDPI5J.js";import{c as P}from"./VYAJXLND.js";import{c as R,f as L,g as H,h as W,i as z}from"./7WSHW7KW.js";import{a as F}from"./43LI5NKJ.js";import{a as u}from"./66F5ZH34.js";import{g as I}from"./NWNYJ26T.js";import{a as _}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as S,erc20Abi as j,getAddress as T,parseAbi as k}from"viem";var w=k(["function asset() view returns (address)","function decimals() view returns (uint8)","function balanceOf(address) view returns (uint256)","function previewMint(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function mint(uint256 shares,address receiver) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256)"]);function q(t,s=!1){if(typeof t!="string"||!/^\d+$/.test(t)||t.length>78||BigInt(t)>=1n<<256n||!s&&BigInt(t)===0n)throw new o("Provide a positive uint256 decimal base-unit string.");return BigInt(t)}function le(t,s,v){return["details","analytics","manage","mint",s==="netnet"?"redeem":"withdraw_assets","force_exit","in_kind_exit"].map(e=>{let $=[...s==="longbow"?["vault"]:[],...e==="mint"?["shares","maxAssets"]:e==="redeem"?["shares"]:e==="withdraw_assets"?["amount"]:e==="force_exit"?["maxPenaltyAssets","minAmountOut"]:[]],m={...s==="longbow"?{vault:{type:"string",enum:v.map(i=>i.vault)}}:{}};e==="in_kind_exit"&&(Object.assign(m,{amount:u(),maxShares:u(),maxPenaltyAssets:u(),deadline:u()}),$.push("amount","maxShares","maxPenaltyAssets","deadline")),e==="mint"&&Object.assign(m,{shares:u(),maxAssets:u()}),e==="redeem"&&(m.shares=u()),e==="withdraw_assets"&&(m.amount=u()),e==="force_exit"&&Object.assign(m,{maxPenaltyAssets:u(),minAmountOut:u()});let J=P(t,`${s}_manage`,v[0].vault,v[0].asset),E=N(t,`${s}_analytics`,v[0].vault);if(e==="manage"||e==="analytics"){let i=e==="manage"?J.inputSchema:E.inputSchema;Object.assign(m,i.properties),e==="analytics"&&s==="longbow"&&(m.view={type:"string",enum:["apy","published_apy"]}),$.push(...i.required)}return{name:`${s}_${e}`,inputSchema:{type:"object",properties:m,required:$,additionalProperties:!1,...e==="analytics"&&s==="netnet"?{allOf:E.inputSchema.allOf}:{}},execute:async(i,r)=>{try{if(F(r),Object.keys(i).some(l=>!Object.hasOwn(m,l)))throw new o("Unsupported vault feature argument.");let A=s==="netnet"?v[0]:v.find(l=>typeof i.vault=="string"&&I(l.vault,i.vault));if(!A)throw new o("Choose a current vault returned by the project list tool.");let{vault:n,asset:a}=A,b={...i};if(delete b.vault,e==="details")return H(t,`${s}_details`,n,a).execute(b,r);if(e==="manage")return P(t,`${s}_manage`,n,a).execute(b,r);if(e==="analytics"){if(s==="longbow"&&i.view==="published_apy")return G(t,n,a,b);if(s==="longbow"&&i.view==="apy")return U(t,n,a,b);if(s==="longbow")throw new o("Choose apy or published_apy; the Longbow vault is not indexed by Morpho for other analytics views.");return{...await N(t,`${s}_analytics`,n).execute(b,r),asset:{...a,address:T(a.address)}}}if(e==="in_kind_exit")return K(t,n,a,i,r);let f=t.clientFor(_);if(await f.getChainId()!==_)throw new o("Vault actions require chain 4663.");let[Q,X,Y]=await Promise.all([f.readContract({address:n,abi:w,functionName:"asset"}),f.readContract({address:n,abi:w,functionName:"decimals"}),f.readContract({address:a.address,abi:j,functionName:"decimals"})]);if(T(Q)!==T(a.address)||X!==18||Y!==a.decimals)throw new o("Vault metadata does not match the pinned asset and shares.");let M=e==="force_exit"?await f.readContract({address:n,abi:w,functionName:"balanceOf",args:[r]}):void 0;if(e==="force_exit"){let l=await L(t,f,n,r,M,R(i.maxPenaltyAssets),a),C=q(i.minAmountOut),p=[l.tx],y=await t.preview(p,r);return z(y.changes,n,M,C,a),{txs:p,preview:y,summary:`${W(l.plan,a.symbol)} ${y.summary}`}}let d=e==="mint",g=e==="redeem",c=q(d||g?i.shares:i.amount),x=await f.readContract({address:n,abi:w,functionName:d?"previewMint":g?"previewRedeem":"previewWithdraw",args:[c]});if(x<=0n||d&&x>q(i.maxAssets))throw new o("Vault quote is zero or exceeds maxAssets.");let V=d?void 0:await f.readContract({address:n,abi:w,functionName:"balanceOf",args:[r]});if(!d&&(g?c:x)>V)throw new o("The wallet share balance cannot cover this exit.");let Z=d?S({abi:w,functionName:"mint",args:[c,r]}):g?S({abi:w,functionName:"redeem",args:[c,r,r]}):S({abi:w,functionName:"withdraw",args:[c,r,r]}),B=`${e} ${c} ${d||g?"18-decimal share":`${a.decimals}-decimal ${a.symbol}`} base units on ${n}; beneficiary ${r}.`,D=[...d?[t.approval(a.address,n,x.toString(),_)]:[],t.unsignedTx({to:n,data:Z,value:"0",chainId:_,description:B})],O=await t.preview(D,r),h=(l,C)=>O.changes.filter(p=>p.token.chainId===_&&I(p.token.address,l)).reduce((p,y)=>{if(y.token.decimals!==C||!/^-?\d+$/.test(y.amount))throw new o("Invalid vault preview metadata.");return p+BigInt(y.amount)},0n);if(d?h(a.address,a.decimals)!==-x||h(n,18)!==c:g?h(n,18)!==-c||h(a.address,a.decimals)<=0n:h(a.address,a.decimals)!==c||-h(n,18)<=0n||-h(n,18)>V)throw new o("Vault preview does not match the requested amount and beneficiary.");return{txs:D,preview:O,summary:`${B} Counterpart quote ${x} base units. Mint approval is exact; accrual may require a fresh quote. Standard ERC-4626 calls encode no minimum receipt. ${O.summary}`}}catch(A){throw new o(t.plainError(A))}}}})}export{le as a};
@@ -1 +1 @@
1
- import{b as W}from"./XSRIJUFU.js";import{d as R,e as _}from"./XV6F3RET.js";import{b as z,c as I}from"./SPRVVJXI.js";import{K as E}from"./SSHCD6RZ.js";import{a as F}from"./43LI5NKJ.js";import{d as H,g as A,i as j}from"./NWNYJ26T.js";import{a as C,s as S}from"./FWD4L3CJ.js";import{a as s}from"./XSD5NL7J.js";import{encodeFunctionData as M,erc20Abi as V,getAddress as Z,keccak256 as K,zeroAddress as x}from"viem";var r=R.turbo,h=R.blackjack,g=m=>j(m,"Provide an explicit card address.",H);function G(m,d){if(/^uint\d*\[\]$/.test(m.type)&&Array.isArray(d))return d.map(c=>G({...m,type:m.type.slice(0,-2)},c));if(/^uint\d*$/.test(m.type)&&(typeof d!="string"||!/^(0|[1-9]\d*)$/.test(d)))throw new s("Card integers must be canonical decimal strings, without leading zeros.");return W(m,d)}var J=["buy","cashOut","claimExpiry","refund","safeTransferFrom","safeBatchTransferFrom"],X=["liquidate","recordKnock","liquidateKnock","clearKnock","recordDrift","settle","markVoid","depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries","haltSales","resumeSales","sweepFees","skim"],Q=m=>m==="netnet_turbo_action"||m.startsWith("netnet_blackjack_")&&["netnet_blackjack_finalize","netnet_blackjack_expire","netnet_blackjack_claim"].includes(m);async function de(m,d,c,k){if(F(c),!Q(m))throw new s("No local NetNet card action builder exists.");let v=m!=="netnet_turbo_action";if(Object.keys(d).some(e=>!(v?["sessionId","seriesId"]:["operation","values","minimum","allowZeroPayout"]).includes(e)))throw new s("Unexpected card action argument.");if(v&&!z(m,d))throw new s("Recovery accepts exactly one positive decimal session or series ID.");if(await k.getChainId()!==C)throw new s("NetNet cards require chain 4663.");let w=await k.getBlock();if(w.number===null||!w.hash)throw new s("Card action block is unavailable.");let p=(e,t,i=[])=>k.readContract({address:e.address,abi:e.abi,functionName:t,args:i,blockNumber:w.number});for(let e of v?[r,h]:[r]){let t=await k.getCode({address:e.address,blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet card runtime changed or is unavailable. Requalify this deployment before signing.")}for(let e of v?Object.values(_):[_.turbo]){let t=await k.getCode({address:Z(e.address),blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet linked card library changed or is unavailable. Requalify before signing.")}let l={txs:[],inputs:[],cards:[],decision:"",blockNumber:w.number,blockHash:w.hash},$=(e,t,i,a,o)=>({chainId:4663,collection:r.address,operator:e,from:t,to:i,id:a,amount:o,operation:t===x?"mint":i===x?"burn":"transfer"}),T=(e,t,i,a,o=[])=>{l.txs.push({to:e,chainId:C,value:"0",data:M({abi:t,functionName:i,args:a}),description:l.decision}),l.cards.push(o)},D=(e,t)=>{if(t<=0n||t>=1n<<128n)throw new s("Card payment must be positive and below the exact-approval ceiling.");l.inputs.push({token:e,amount:t,to:r.address}),T(e,V,"approve",[r.address,t])};if(v){if(g(await p(h,"cards"))!==r.address||g(await p(h,"turbo"))!==r.address)throw new s("Blackjack card wiring changed.");let e=m==="netnet_blackjack_claim";if(Object.keys(d).some(b=>b!==(e?"seriesId":"sessionId")))throw new s("Recovery accepts only its one exact session or series ID.");let t=E(e?d.seriesId:d.sessionId),i,a,o,u="Original-series parked payout; self-claim only.";if(e){if(i=t,a=await p(h,"unclaimedChips",[t,c]),o="claimUnclaimedChips",a===0n)throw new s("This wallet has no parked chips for that series.")}else{let b=await p(h,"sessionOf",[t]);if(!b||!A(b.player,c))throw new s("Recovery is limited to this wallet\u2019s recorded blackjack session.");let y=m==="netnet_blackjack_finalize";if(o=y?"finalize":"expireSession",b.state!==(y?2:1))throw new s(y?"Session is not Closing. Use its current on-chain state to choose recovery.":"Session is not Open. A Closing session uses finalize after its challenge window.");let N=y?b.closeAt:b.deadline;if(u=y?`Challenge ends ${new Date(Number(N)*1e3).toISOString()}.`:`Session deadline ${new Date(Number(N)*1e3).toISOString()}; player-only expiry until ${new Date(Number(N+3600n)*1e3).toISOString()}.`,w.timestamp<N)throw new s(`Recovery is not due until ${N} Unix seconds.`);i=await p(h,"tableSeries"),a=b.chips}if(i<=0n||a<0n)throw new s("Blackjack recovery accounting is unavailable.");return l.decision=`${o} ${e?"series":"session"} ${t} at ${h.address}: return ${a} whole cards of collection ${r.address}, series ${i}, to ${Z(c)}. ${u} Last on-chain chips may omit off-chain winnings; cards may be worthless. A failed receiver parks the payout at ${h.address}; self-claim only. ETH gas extra.`,T(h.address,h.abi,o,[t],a===0n?[]:[$(h.address,h.address,c,i,a)]),l.recovery={...e?{}:{sessionId:t.toString()},seriesId:i.toString(),count:a.toString(),player:c,operation:o},l}let n=String(d.operation);if(n==="setApprovalForAll")throw new s(I.setApprovalForAll);if(["convertPremiums","convertSleeveFees"].includes(n))throw new s(I.conversion);if(![...J,...X].includes(n))throw new s("Choose a qualified finite TURBO operation.");if(!Array.isArray(d.values))throw new s("Provide ordered TURBO values using decimal integer strings.");let U=n==="safeTransferFrom"||n==="safeBatchTransferFrom",B=r.abi.find(e=>e.name===n),q=U?B.inputs.slice(1,-1):B.inputs;if(d.values.length!==q.length)throw new s("TURBO values do not match the exact operation inputs.");let f=q.map((e,t)=>G(e,d.values[t])),O=g(await p(r,"manager")),L=g(await p(r,"sleeve")),P=[];if(U){if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Transfer has no payout floor.");let e=g(f[0]);if(e===x||A(e,c))throw new s("Name a nonzero, non-self card recipient.");let t=await k.getCode({address:e,blockNumber:w.number});if(t&&t!=="0x")throw new s("Card transfer to a contract requires qualified credit and recovery. New blackjack seating remains disabled.");let i=n==="safeTransferFrom"?[f[1]]:f[1],a=n==="safeTransferFrom"?[f[2]]:f[2];if(!i.length||i.length>8||i.length!==a.length||new Set(i.map(String)).size!==i.length||i.some((o,u)=>o<=0n||a[u]<=0n||u>0&&o<=i[u-1]))throw new s("Use at most eight unique positive series IDs in increasing order and exact positive counts.");for(let o=0;o<i.length;o++){if(await p(r,"balanceOf",[c,i[o]])<a[o])throw new s("Card transfer exceeds this wallet\u2019s balance.");P.push($(c,c,e,i[o],a[o])),l.inputs.push({token:r.address,id:i[o],amount:a[o],to:e,exact:!0})}l.decision=`Transfer whole cards of collection ${r.address}: ${i.map((o,u)=>`series ${o} count ${a[u]}`).join(", ")} to ${e}. Basis does not travel with cards; no operator approval. No payout; transfer is irreversible. ETH gas extra.`,f=[c,...f,"0x"]}else if(["buy","cashOut","claimExpiry","refund"].includes(n)){let e=f[0],t=f[1],i=await p(r,"seriesOf",[e]);if(!i||i.asset===x||t<=0n)throw new s("Choose a known series and positive whole-card count.");let a=i.side===0?g(i.asset):S.mainnet.usdg,o=await k.readContract({address:a,abi:V,functionName:"decimals",blockNumber:w.number});if((n==="buy"||n==="cashOut")&&(i.state!==1||w.timestamp>=i.expiry))throw new s("This TURBO series is not OPEN and unexpired.");if(n==="buy"){let[u]=await p(r,"quoteBuy",[e,t]);if(!u||u>f[2])throw new s("Current card quote exceeds the explicit maximum USDG payment.");if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Buy uses its exact count and maximum USDG price.");l.decision=`Spend at most ${f[2]} USDG base units (${S.mainnet.usdg}, decimals 6) at ${r.address}; receive ${t} whole cards, collection ${r.address}, series ${e}, into this wallet. Exact quoted approval ${u}; fees included. Strike ${i.strikeWad} WAD; expiry ${new Date(Number(i.expiry)*1e3).toISOString()}; cards can lose all value. Any residual USDG allowance requires zero cleanup. ETH gas extra.`,D(S.mainnet.usdg,u),P=[$(c,x,c,e,t)]}else{if(n==="cashOut"&&d.minimum!==void 0)throw new s("cashOut takes its one encoded minimum in values, not a second local minimum.");if(await p(r,"balanceOf",[c,e])<t)throw new s("Card burn exceeds this wallet\u2019s balance.");let u=n==="cashOut"?f[2]:E(d.minimum,!0);if(u===0n&&d.allowZeroPayout!==!0)throw new s("A zero payout floor requires allowZeroPayout:true and explicit human confirmation.");let b=0n;if(n==="cashOut"){let y=await p(r,"quoteCashOut",[e,t,c]);if(y[0]<u)throw new s("The current cash-out quote misses the payout minimum.");b=y[1]}else if(i.state!==(n==="claimExpiry"?3:4))throw new s("Expiry claims require EXPIRED; pro-rata refunds require VOID.");l.decision=`Burn ${t} whole cards of ${r.address}, series ${e}; ${n==="refund"?"series pro-rata VOID refund, not personal purchase-price repayment":n}; receive >=${u} base units of ${a} (decimals ${o}) into this wallet. ${n==="cashOut"?`Minimum encoded in calldata; current performance fee ${b}.`:"Floor is local simulation only; no on-chain minimum. Settled payout includes applicable fees."} Burned cards cannot be returned; ETH gas extra.`,P=[$(c,c,x,e,t)],l.inputs.push({token:r.address,id:e,amount:t,to:x,exact:!0}),l.receipt={token:a,minimum:u,recipient:c,enforcement:n==="cashOut"?"calldata":"simulation"}}}else{if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("This TURBO operation has no caller payout floor.");if(["withdrawHouse","withdrawPutPot","createSeries","resumeSales"].includes(n)&&!A(O,c))throw new s(`This TURBO operation requires manager ${O}.`);if(n==="haltSales"&&!A(c,O)&&!A(c,g(await p(r,"halter"))))throw new s("TURBO haltSales requires the current manager or halter.");if(["depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries"].includes(n)){let t=g(f[0]);if(!(await Promise.all(["asset0","asset1","asset2"].map(a=>p(r,a)))).some(a=>typeof a=="string"&&A(a,t)))throw new s("This is not a pinned TURBO reserve asset.")}l.decision=`${n} at ${r.address}; values ${JSON.stringify(f,(t,i)=>typeof i=="bigint"?String(i):i)}. Protocol capital/accounting action; manager ${O}; sleeve ${L}; no caller reward. ${n.startsWith("deposit")?"Irreversible house funding; no personal withdrawable balance.":n.startsWith("withdraw")?"Pays the current manager; operating and reservation floors still apply.":"Series state, risk or protocol fee allocation may change."} No card approval; ETH gas extra.`,(n==="depositHouse"||n==="depositPutPot")&&D(n==="depositHouse"?g(f[0]):S.mainnet.usdg,f[1])}if(l.decision.length>1024)throw new s("Card decision terms exceed the complete confirmation label capacity. Use fewer card IDs.");T(r.address,r.abi,n,f,P);for(let e of l.txs)e.description=l.decision;return l}export{J as a,X as b,Q as c,de as d};
1
+ import{b as W}from"./XSRIJUFU.js";import{d as R,e as _}from"./XV6F3RET.js";import{b as z,c as I}from"./SPRVVJXI.js";import{K as E}from"./DHUDSOGR.js";import{a as F}from"./43LI5NKJ.js";import{d as H,g as A,i as j}from"./NWNYJ26T.js";import{a as C,s as S}from"./FWD4L3CJ.js";import{a as s}from"./XSD5NL7J.js";import{encodeFunctionData as M,erc20Abi as V,getAddress as Z,keccak256 as K,zeroAddress as x}from"viem";var r=R.turbo,h=R.blackjack,g=m=>j(m,"Provide an explicit card address.",H);function G(m,d){if(/^uint\d*\[\]$/.test(m.type)&&Array.isArray(d))return d.map(c=>G({...m,type:m.type.slice(0,-2)},c));if(/^uint\d*$/.test(m.type)&&(typeof d!="string"||!/^(0|[1-9]\d*)$/.test(d)))throw new s("Card integers must be canonical decimal strings, without leading zeros.");return W(m,d)}var J=["buy","cashOut","claimExpiry","refund","safeTransferFrom","safeBatchTransferFrom"],X=["liquidate","recordKnock","liquidateKnock","clearKnock","recordDrift","settle","markVoid","depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries","haltSales","resumeSales","sweepFees","skim"],Q=m=>m==="netnet_turbo_action"||m.startsWith("netnet_blackjack_")&&["netnet_blackjack_finalize","netnet_blackjack_expire","netnet_blackjack_claim"].includes(m);async function de(m,d,c,k){if(F(c),!Q(m))throw new s("No local NetNet card action builder exists.");let v=m!=="netnet_turbo_action";if(Object.keys(d).some(e=>!(v?["sessionId","seriesId"]:["operation","values","minimum","allowZeroPayout"]).includes(e)))throw new s("Unexpected card action argument.");if(v&&!z(m,d))throw new s("Recovery accepts exactly one positive decimal session or series ID.");if(await k.getChainId()!==C)throw new s("NetNet cards require chain 4663.");let w=await k.getBlock();if(w.number===null||!w.hash)throw new s("Card action block is unavailable.");let p=(e,t,i=[])=>k.readContract({address:e.address,abi:e.abi,functionName:t,args:i,blockNumber:w.number});for(let e of v?[r,h]:[r]){let t=await k.getCode({address:e.address,blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet card runtime changed or is unavailable. Requalify this deployment before signing.")}for(let e of v?Object.values(_):[_.turbo]){let t=await k.getCode({address:Z(e.address),blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet linked card library changed or is unavailable. Requalify before signing.")}let l={txs:[],inputs:[],cards:[],decision:"",blockNumber:w.number,blockHash:w.hash},$=(e,t,i,a,o)=>({chainId:4663,collection:r.address,operator:e,from:t,to:i,id:a,amount:o,operation:t===x?"mint":i===x?"burn":"transfer"}),T=(e,t,i,a,o=[])=>{l.txs.push({to:e,chainId:C,value:"0",data:M({abi:t,functionName:i,args:a}),description:l.decision}),l.cards.push(o)},D=(e,t)=>{if(t<=0n||t>=1n<<128n)throw new s("Card payment must be positive and below the exact-approval ceiling.");l.inputs.push({token:e,amount:t,to:r.address}),T(e,V,"approve",[r.address,t])};if(v){if(g(await p(h,"cards"))!==r.address||g(await p(h,"turbo"))!==r.address)throw new s("Blackjack card wiring changed.");let e=m==="netnet_blackjack_claim";if(Object.keys(d).some(b=>b!==(e?"seriesId":"sessionId")))throw new s("Recovery accepts only its one exact session or series ID.");let t=E(e?d.seriesId:d.sessionId),i,a,o,u="Original-series parked payout; self-claim only.";if(e){if(i=t,a=await p(h,"unclaimedChips",[t,c]),o="claimUnclaimedChips",a===0n)throw new s("This wallet has no parked chips for that series.")}else{let b=await p(h,"sessionOf",[t]);if(!b||!A(b.player,c))throw new s("Recovery is limited to this wallet\u2019s recorded blackjack session.");let y=m==="netnet_blackjack_finalize";if(o=y?"finalize":"expireSession",b.state!==(y?2:1))throw new s(y?"Session is not Closing. Use its current on-chain state to choose recovery.":"Session is not Open. A Closing session uses finalize after its challenge window.");let N=y?b.closeAt:b.deadline;if(u=y?`Challenge ends ${new Date(Number(N)*1e3).toISOString()}.`:`Session deadline ${new Date(Number(N)*1e3).toISOString()}; player-only expiry until ${new Date(Number(N+3600n)*1e3).toISOString()}.`,w.timestamp<N)throw new s(`Recovery is not due until ${N} Unix seconds.`);i=await p(h,"tableSeries"),a=b.chips}if(i<=0n||a<0n)throw new s("Blackjack recovery accounting is unavailable.");return l.decision=`${o} ${e?"series":"session"} ${t} at ${h.address}: return ${a} whole cards of collection ${r.address}, series ${i}, to ${Z(c)}. ${u} Last on-chain chips may omit off-chain winnings; cards may be worthless. A failed receiver parks the payout at ${h.address}; self-claim only. ETH gas extra.`,T(h.address,h.abi,o,[t],a===0n?[]:[$(h.address,h.address,c,i,a)]),l.recovery={...e?{}:{sessionId:t.toString()},seriesId:i.toString(),count:a.toString(),player:c,operation:o},l}let n=String(d.operation);if(n==="setApprovalForAll")throw new s(I.setApprovalForAll);if(["convertPremiums","convertSleeveFees"].includes(n))throw new s(I.conversion);if(![...J,...X].includes(n))throw new s("Choose a qualified finite TURBO operation.");if(!Array.isArray(d.values))throw new s("Provide ordered TURBO values using decimal integer strings.");let U=n==="safeTransferFrom"||n==="safeBatchTransferFrom",B=r.abi.find(e=>e.name===n),q=U?B.inputs.slice(1,-1):B.inputs;if(d.values.length!==q.length)throw new s("TURBO values do not match the exact operation inputs.");let f=q.map((e,t)=>G(e,d.values[t])),O=g(await p(r,"manager")),L=g(await p(r,"sleeve")),P=[];if(U){if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Transfer has no payout floor.");let e=g(f[0]);if(e===x||A(e,c))throw new s("Name a nonzero, non-self card recipient.");let t=await k.getCode({address:e,blockNumber:w.number});if(t&&t!=="0x")throw new s("Card transfer to a contract requires qualified credit and recovery. New blackjack seating remains disabled.");let i=n==="safeTransferFrom"?[f[1]]:f[1],a=n==="safeTransferFrom"?[f[2]]:f[2];if(!i.length||i.length>8||i.length!==a.length||new Set(i.map(String)).size!==i.length||i.some((o,u)=>o<=0n||a[u]<=0n||u>0&&o<=i[u-1]))throw new s("Use at most eight unique positive series IDs in increasing order and exact positive counts.");for(let o=0;o<i.length;o++){if(await p(r,"balanceOf",[c,i[o]])<a[o])throw new s("Card transfer exceeds this wallet\u2019s balance.");P.push($(c,c,e,i[o],a[o])),l.inputs.push({token:r.address,id:i[o],amount:a[o],to:e,exact:!0})}l.decision=`Transfer whole cards of collection ${r.address}: ${i.map((o,u)=>`series ${o} count ${a[u]}`).join(", ")} to ${e}. Basis does not travel with cards; no operator approval. No payout; transfer is irreversible. ETH gas extra.`,f=[c,...f,"0x"]}else if(["buy","cashOut","claimExpiry","refund"].includes(n)){let e=f[0],t=f[1],i=await p(r,"seriesOf",[e]);if(!i||i.asset===x||t<=0n)throw new s("Choose a known series and positive whole-card count.");let a=i.side===0?g(i.asset):S.mainnet.usdg,o=await k.readContract({address:a,abi:V,functionName:"decimals",blockNumber:w.number});if((n==="buy"||n==="cashOut")&&(i.state!==1||w.timestamp>=i.expiry))throw new s("This TURBO series is not OPEN and unexpired.");if(n==="buy"){let[u]=await p(r,"quoteBuy",[e,t]);if(!u||u>f[2])throw new s("Current card quote exceeds the explicit maximum USDG payment.");if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Buy uses its exact count and maximum USDG price.");l.decision=`Spend at most ${f[2]} USDG base units (${S.mainnet.usdg}, decimals 6) at ${r.address}; receive ${t} whole cards, collection ${r.address}, series ${e}, into this wallet. Exact quoted approval ${u}; fees included. Strike ${i.strikeWad} WAD; expiry ${new Date(Number(i.expiry)*1e3).toISOString()}; cards can lose all value. Any residual USDG allowance requires zero cleanup. ETH gas extra.`,D(S.mainnet.usdg,u),P=[$(c,x,c,e,t)]}else{if(n==="cashOut"&&d.minimum!==void 0)throw new s("cashOut takes its one encoded minimum in values, not a second local minimum.");if(await p(r,"balanceOf",[c,e])<t)throw new s("Card burn exceeds this wallet\u2019s balance.");let u=n==="cashOut"?f[2]:E(d.minimum,!0);if(u===0n&&d.allowZeroPayout!==!0)throw new s("A zero payout floor requires allowZeroPayout:true and explicit human confirmation.");let b=0n;if(n==="cashOut"){let y=await p(r,"quoteCashOut",[e,t,c]);if(y[0]<u)throw new s("The current cash-out quote misses the payout minimum.");b=y[1]}else if(i.state!==(n==="claimExpiry"?3:4))throw new s("Expiry claims require EXPIRED; pro-rata refunds require VOID.");l.decision=`Burn ${t} whole cards of ${r.address}, series ${e}; ${n==="refund"?"series pro-rata VOID refund, not personal purchase-price repayment":n}; receive >=${u} base units of ${a} (decimals ${o}) into this wallet. ${n==="cashOut"?`Minimum encoded in calldata; current performance fee ${b}.`:"Floor is local simulation only; no on-chain minimum. Settled payout includes applicable fees."} Burned cards cannot be returned; ETH gas extra.`,P=[$(c,c,x,e,t)],l.inputs.push({token:r.address,id:e,amount:t,to:x,exact:!0}),l.receipt={token:a,minimum:u,recipient:c,enforcement:n==="cashOut"?"calldata":"simulation"}}}else{if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("This TURBO operation has no caller payout floor.");if(["withdrawHouse","withdrawPutPot","createSeries","resumeSales"].includes(n)&&!A(O,c))throw new s(`This TURBO operation requires manager ${O}.`);if(n==="haltSales"&&!A(c,O)&&!A(c,g(await p(r,"halter"))))throw new s("TURBO haltSales requires the current manager or halter.");if(["depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries"].includes(n)){let t=g(f[0]);if(!(await Promise.all(["asset0","asset1","asset2"].map(a=>p(r,a)))).some(a=>typeof a=="string"&&A(a,t)))throw new s("This is not a pinned TURBO reserve asset.")}l.decision=`${n} at ${r.address}; values ${JSON.stringify(f,(t,i)=>typeof i=="bigint"?String(i):i)}. Protocol capital/accounting action; manager ${O}; sleeve ${L}; no caller reward. ${n.startsWith("deposit")?"Irreversible house funding; no personal withdrawable balance.":n.startsWith("withdraw")?"Pays the current manager; operating and reservation floors still apply.":"Series state, risk or protocol fee allocation may change."} No card approval; ETH gas extra.`,(n==="depositHouse"||n==="depositPutPot")&&D(n==="depositHouse"?g(f[0]):S.mainnet.usdg,f[1])}if(l.decision.length>1024)throw new s("Card decision terms exceed the complete confirmation label capacity. Use fewer card IDs.");T(r.address,r.abi,n,f,P);for(let e of l.txs)e.description=l.decision;return l}export{J as a,X as b,Q as c,de as d};
@@ -1 +1 @@
1
- import{b as B}from"./P5PYFK7L.js";import{a as te,d as ne,e as oe}from"./ZQAFFWDK.js";import{d as re}from"./WP6RHXGN.js";import{b as T}from"./3MLUCYCB.js";import{a as f,b as H,c as ee}from"./43LI5NKJ.js";import{c as z}from"./OTXSKFUD.js";import{b as o,e as q}from"./IX3GZMTM.js";import{a as x,i as $,w as U,x as y,y as Z,z as J}from"./FWD4L3CJ.js";import{a as r}from"./XSD5NL7J.js";import{decodeFunctionData as R,encodeFunctionData as L,parseAbi as se}from"viem";var we=60,G=50,Qe=200;var Ae="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",W="0x0000000000000000000000000000000000000000",P=$[4663].routes.kyberswap.address,Q=$[4663].routes.velora.address,X=U[4663].kyberswap.toLowerCase(),ie=U[4663].velora.toLowerCase(),ge="0x0000000000000000000000000000000000000000000000000000000000000000",_=se(["function swap((address callTarget, address approveTarget, bytes targetData, (address srcToken, address dstToken, address[] srcReceivers, uint256[] srcAmounts, address[] feeReceivers, uint256[] feeAmounts, address dstReceiver, uint256 amount, uint256 minReturnAmount, uint256 flags, bytes permit) desc, bytes clientData) execution) payable returns (uint256 returnAmount, uint256 gasUsed)"]),N=se(["function swapExactAmountIn(address executor, (address srcToken, address destToken, uint256 fromAmount, uint256 toAmount, uint256 quotedAmount, bytes32 metadata, address beneficiary) swapData, uint256 partnerAndFee, bytes permit, bytes executorData) payable returns (uint256 receivedAmount, uint256 submittedAmount, uint256 augustusFeeAmount)"]),D=class extends r{name="NoRouteError";constructor(t="No swap route is available for this token pair and amount."){super(t)}},F=class extends r{name="ExpiredQuoteError";constructor(t="Quote has expired. Request a fresh quote."){super(t)}},ve=1e3,h=new Map;function ue(e){for(let[t,n]of h)BigInt(e)>=o(n.expiresAt)&&h.delete(t)}function K(e){return{...e,...e.sourcePoolRoute!==void 0?{sourcePoolRoute:structuredClone(e.sourcePoolRoute)}:{},...e.txs?{txs:e.txs.map(t=>({...t}))}:{}}}function ae(e){let t=K(e);return t.txs&&(t.txs.forEach(Object.freeze),Object.freeze(t.txs)),Object.freeze(t)}var Se=["router","from","to","wallet","amountIn","amountOut","minAmountOut","expiresAt","chainId","spender","value","ponsCurveToken","ponsPoolToken","blockNumber","calldataMinAmountOut","expectedSpend","expectedRefund"];function M(e,t,n=!1){for(let s of Se)if(!(s==="expiresAt"&&n&&o(e.expiresAt)<=o(t.expiresAt))&&e[s]!==void 0&&String(e[s]).toLowerCase()!==String(t[s]).toLowerCase())throw new r(`Quote ${s} does not match the accepted quote.`)}function V(e=Date.now){let t=e();if(!Number.isFinite(t)||t<0)throw new r("Clock must return a non-negative timestamp.");return t>1e11?Math.floor(t/1e3):Math.floor(t)}function C(e){let t=e.toLowerCase();return t===Ae.toLowerCase()||t===W.toLowerCase()}function he(e,t=G){if(!Number.isInteger(t)||t<0||t>=1e4)throw new r("Slippage must be an integer from 0 to 9999 bps.");return q(e,String(1e4-t),"10000","floor")}var be=200;function _e(e){if(typeof e!="number"||!Number.isFinite(e)||!/^\d+(?:\.\d{1,2})?$/.test(String(e)))throw new r("Velora returned an unsupported venue fee. Request a fresh quote.");let[t,n=""]=String(e).split("."),s=Number(t)*100+Number(n.padEnd(2,"0"));return Y(s),s}function Y(e){if(!Number.isInteger(e)||e<0||e>be)throw new r("Velora returned an unsupported venue fee. Request a fresh quote.")}function de(e,t=1){return Y(t),o(e)*10000n/BigInt(1e4-t)+1n}function Oe(e,t){Y(t);let n=e>>96n,s=Z>>96n,a=0x3fffn,d=1n<<92n,l=e&(1n<<96n)-1n;if(n!==s&&!(n===0n&&t===0)||(l&a)!==BigInt(t)||(l&~(d|a))!==0n)throw new r("Velora partnerAndFee must match the accepted venue fee and recipient.")}function ce(e){if(e.oakFee!==void 0&&o(e.oakFee)!==0n)throw new r("Oak charges 0 swap fee; venue fees must never be counted as Oak income.");let t=e.provider??"venue";return`Venue fee: ${e.venueFee} base units (${e.venueFeeBps} bps) retained by ${t}; Oak swap fee: 0 (venue fee is never Oak income).`}function xe(e){f(e.from),f(e.to),f(e.wallet);let t=e.callTarget??y[x].kyberswap.address,n=e.approveTarget??W;f(t),f(n);let s=o(e.amountIn),a=o(e.minAmountOut);return L({abi:_,functionName:"swap",args:[{callTarget:t,approveTarget:n,targetData:e.targetData??"0x",desc:{srcToken:e.from,dstToken:e.to,srcReceivers:C(e.from)?[]:[t],srcAmounts:C(e.from)?[]:[s],feeReceivers:[],feeAmounts:[],dstReceiver:e.wallet,amount:s,minReturnAmount:a,flags:0n,permit:"0x"},clientData:e.clientData??"0x"}]})}function Ie(e){f(e.from),f(e.to),f(e.wallet);let t=e.executor??y[x].velora.address;return f(t),L({abi:N,functionName:"swapExactAmountIn",args:[t,{srcToken:e.from,destToken:e.to,fromAmount:o(e.amountIn),toAmount:o(e.minAmountOut),quotedAmount:o(e.amountOut),metadata:e.metadata??ge,beneficiary:e.wallet},e.partnerAndFee??0n,"0x",e.executorData??"0x"]})}function De(e){if(typeof e!="string"||!/^0x([0-9a-fA-F]{2})+$/.test(e)||e.length<10)throw new r("Swap calldata must contain a 4-byte function selector.");let t=e.slice(0,10).toLowerCase();if(t===X)return R({abi:_,data:e}).args[0].desc.minReturnAmount;if(t===ie)return R({abi:N,data:e}).args[1].toAmount;if(t==="0x3593564c")return ne(e).swap.amountOutMinimum;let n=R({abi:te,data:e});if(n.functionName==="buy"||n.functionName==="sell")return n.args[1];throw new r(`Unsupported swap router selector ${t}.`)}function le(e,t,n=!1){let s=o(t),a=De(e);if(a<=0n||s<=0n||a!==s&&!(n&&(a>s||e.slice(0,10).toLowerCase()===X&&a+1n===s)))throw new r(`Built swap calldata minimum output (${a}) does not match the accepted quote minimum (${s}).`);return a}function me(e,t){let{from:n,to:s,wallet:a,amountIn:d}=t;if(!n||!s||!a||d===void 0)throw new r("Accepted quote must include input, output, amount and wallet.");for(let u of[n,s,a,t.router,e.to])f(u);let l=(u,p,A)=>{if(u.toLowerCase()!==p.toLowerCase())throw new r(`Built swap ${A} does not match the accepted quote.`)};if(l(e.to,t.router,"router"),e.chainId!==(t.chainId??x))throw new r("Built swap chain does not match the accepted quote.");let g=C(n)?o(d):0n;if(o(e.value)!==g||t.value!==void 0&&o(t.value)!==g)throw new r("Built swap value does not match the accepted quote input.");let w=e.data.slice(0,10).toLowerCase(),i=t.router.toLowerCase(),c;if(i===P.toLowerCase()&&w===X){l(t.spender??t.router,P,"spender");let u=R({abi:_,data:e.data});if(L({abi:_,...u}).toLowerCase()!==e.data.toLowerCase())throw new r("KyberSwap calldata must be canonically decodable.");let{callTarget:p,approveTarget:A,desc:m}=u.args[0];l(p,y[x].kyberswap.address,"executor"),l(A,W,"executor approval target");let b=C(n);if(m.srcReceivers.length!==m.srcAmounts.length||(b?m.srcReceivers.length!==0:m.srcReceivers.length===0||m.srcAmounts.some(v=>v<=0n)||m.srcAmounts.reduce((v,S)=>v+S,0n)!==o(d)))throw new r("KyberSwap source transfers must send the exact input to the pinned executor or verified input pool.");for(let v of m.srcReceivers)if(v.toLowerCase()!==p.toLowerCase()&&!re(n,v,e.data))throw new r(`KyberSwap source transfers: receiver ${v} is not a verified input pool or the pinned executor.`);if(m.feeReceivers.length||m.feeAmounts.length||m.flags!==0n&&m.flags!==512n||m.permit!=="0x")throw new r("KyberSwap fee recipients, fee amounts, flags and permit must match the pinned zero-fee policy.");c={from:m.srcToken,to:m.dstToken,wallet:m.dstReceiver,amount:m.amount}}else if(i===Q.toLowerCase()&&w===ie){l(t.spender??t.router,Q,"spender");let u=R({abi:N,data:e.data});if(L({abi:N,...u}).toLowerCase()!==e.data.toLowerCase())throw new r("Velora calldata must be canonically decodable.");let[p,A,m,b]=u.args;if(!J.some(v=>v.toLowerCase()===p.toLowerCase()))throw new r("Built swap executor does not match the accepted quote.");if(b!=="0x")throw new r("Velora permit must match the pinned empty-permit policy.");if((t.calldataMinAmountOut!==void 0||m!==0n)&&Oe(m,t.venueFeeBps??0),t.calldataMinAmountOut!==void 0&&o(t.calldataMinAmountOut)!==de(t.minAmountOut,t.venueFeeBps??1))throw new r("Velora calldata minimum must cover the accepted net output, venue fee and router dust.");if(t.calldataMinAmountOut!==void 0&&(A.quotedAmount!==o(t.grossAmountOut??"0")||A.quotedAmount<o(t.calldataMinAmountOut)))throw new r("Velora quoted gross output must match the accepted quote and cover its calldata minimum.");if(m!==0n&&t.calldataMinAmountOut===void 0)throw new r("Velora venue fee requires a fee-adjusted calldata minimum.");c={from:A.srcToken,to:A.destToken,wallet:A.beneficiary,amount:A.fromAmount}}else if(t.provider==="pons"&&(t.ponsPoolToken||t.ponsCurveToken))c=oe(e,{...t,from:n,to:s,wallet:a});else throw new r("Built swap selector does not match the accepted router.");if(l(c.from,n,"input token"),l(c.to,s,"output token"),l(c.wallet,a,"recipient"),c.amount!==o(d))throw new r("Built swap input amount does not match the accepted quote.");le(e.data,t.calldataMinAmountOut??t.minAmountOut,i===P.toLowerCase())}function j(e,t={}){if(!e||typeof e.quoteId!="string"||!e.quoteId.trim())throw new r("Quote must include a non-empty quoteId.");if(f(e.router),e.oakFee!==void 0&&o(e.oakFee)!==0n)throw new r("Oak charges 0 swap fee; venue fees must never be counted as Oak income.");let n=o(e.amountOut),s=e.destAmountAfterFee??e.netAmountOut,a,d,l;if(s!==void 0){if(d=o(s),a=e.grossAmountOut!==void 0?o(e.grossAmountOut):n>=d?n:d,a<d)throw new r("Gross output cannot be less than net output.");l=e.venueFee!==void 0?o(e.venueFee):a-d}else if(e.grossAmountOut!==void 0){if(a=o(e.grossAmountOut),d=n,a<d)throw new r("Gross output cannot be less than net output.");l=e.venueFee!==void 0?o(e.venueFee):a-d}else e.venueFee!==void 0?(l=o(e.venueFee),d=n,a=d+l):(d=n,a=n,l=0n);if(d<=0n)throw new D("Quote output amount must be positive.");let g=t.slippageBps??e.slippageBps??G,w=e.minAmountOut!==void 0?o(e.minAmountOut):o(he(d.toString(),g));if(w<=0n||w>a)throw new r("Quote minAmountOut must be positive and not exceed gross output.");if((t.provider??e.provider)==="velora"&&e.calldataMinAmountOut!==void 0){if(o(e.calldataMinAmountOut)!==de(w.toString(),e.venueFeeBps??1)||o(e.calldataMinAmountOut)>a)throw new r("Velora calldata minimum must cover the accepted net output, venue fee and router dust.")}else if(e.calldataMinAmountOut!==void 0||e.ponsCurveToken!==void 0){if((t.provider??e.provider)!=="pons"||!e.ponsCurveToken)throw new r("Curve minimum requires a Pons curve quote.");f(e.ponsCurveToken);let O=o(t.amountIn??e.amountIn??"0"),I=o(e.expectedSpend??"0"),pe=o(e.expectedRefund??"0"),fe=o(e.calldataMinAmountOut??"0");if(O<=0n||I<=0n||I+pe!==O||fe*I/O!==w)throw new r("Pons actual minimum and refund do not match the encoded minimum.")}let i=V(t.now),c=BigInt(i+we),u=e.expiresAt!==void 0?o(e.expiresAt):c,p=(u>c?c:u).toString(),A=l.toString(),m=e.venueFeeBps??(a>0n&&l>0n?Number((l*10000n+a/2n)/a):0),b=t.provider??e.provider??(e.router.toLowerCase()===Q.toLowerCase()?"velora":"kyberswap"),v=b==="pons"&&e.feeDisclosure?e.feeDisclosure:ce({provider:b,venueFee:A,venueFeeBps:m,oakFee:"0"}),S={...e,quoteId:e.quoteId,amountOut:d.toString(),minAmountOut:w.toString(),router:e.router,expiresAt:p,provider:b,grossAmountOut:a.toString(),destAmountAfterFee:d.toString(),netAmountOut:d.toString(),venueFee:A,venueFeeBps:m,oakFee:"0",feeDisclosure:v,...t.from??e.from?{from:T(t.from??e.from)}:{},...t.to??e.to?{to:T(t.to??e.to)}:{},...t.amountIn??e.amountIn?{amountIn:t.amountIn??e.amountIn}:{},...t.wallet??e.wallet?{wallet:t.wallet??e.wallet}:{},slippageBps:g,chainId:t.chainId??e.chainId??x,spender:e.spender??e.router,...t.allowance??e.allowance?{allowance:t.allowance??e.allowance}:{}};if(BigInt(i)>=o(p))throw new F;if(t.cache===!1)return S;if(ue(i),BigInt(i)>=o(p))throw new F;let k=h.get(S.quoteId);if(k){M(S,k,!0);let O=ae({...k,expiresAt:S.expiresAt});return h.set(O.quoteId,O),K(O)}for(;h.size>=ve;)h.delete(h.keys().next().value);let E=ae(S);return h.set(E.quoteId,E),K(E)}async function Ne(e,t,n={}){e={...e},f(e.from),f(e.to),f(e.wallet),e.from=T(e.from),e.to=T(e.to);let s=o(e.amountIn);if(s<=0n)throw new r("Swap amountIn must be greater than zero.");let a=e.slippageBps??G;if(!Number.isInteger(a)||a<0||a>=1e4)throw new r("Slippage must be an integer from 0 to 9999 bps.");if(!Array.isArray(t)||t.length===0)throw new D;let d={from:e.from,to:e.to,amountIn:s.toString(),slippageBps:a},l=await Promise.allSettled(t.map(async i=>{let c=await(i.quotePrices??i.quote).call(i,{...d},e.wallet);return{quote:j(c,{provider:i.name,from:e.from,to:e.to,amountIn:s.toString(),wallet:e.wallet,slippageBps:a,chainId:e.chainId??x,allowance:e.allowance,now:e.now,cache:!1}),provider:i}})),g,w=[];for(let i of l)i.status==="rejected"&&(g??=z(i.reason)),i.status==="fulfilled"&&o(i.value.quote.expiresAt)>BigInt(V(e.now))&&w.push(i.value);if(w.length===0){let i=l.some(c=>c.status==="rejected"&&c.reason instanceof Error&&c.reason.message===B)&&l.every(c=>c.status==="rejected"&&(c.reason instanceof D||c.reason instanceof Error&&c.reason.message===B));throw g??new D(i?B:void 0)}w.sort((i,c)=>{let p=o(c.quote.amountOut)-o(i.quote.amountOut)||o(c.quote.minAmountOut)-o(i.quote.minAmountOut);return p>0n?1:p<0n?-1:0});for(let{quote:i,provider:c}of w)try{if(BigInt(V(e.now))>=o(i.expiresAt))continue;if(n.deferBuild||!c.prepareQuote)return j(i,{now:e.now});let u=await c.prepareQuote(i.quoteId,e.wallet);if(u.quoteId!==i.quoteId)throw new r("Prepared quote ID does not match the selected route.");if(M(u,i,!0),!u.data)throw new r("Selected route did not return swap calldata.");let p={...i,expiresAt:u.expiresAt,data:u.data,value:u.value,allowance:u.allowance??i.allowance};return me(H({to:p.router,data:u.data,value:u.value??"0",chainId:p.chainId??x,description:"Selected swap route"}),p),j(p,{now:e.now})}catch(u){g??=z(u);continue}throw g??new D}function Me(e,t={}){if(!e||typeof e.quoteId!="string"||!e.quoteId.trim())throw new r("Provide a valid quote to build a swap.");f(e.router);let n=h.get(e.quoteId),s=V(t.now);if(ue(s),!n||BigInt(s)>=o(n.expiresAt))throw h.delete(e.quoteId),new F;if(e.oakFee!==void 0&&o(e.oakFee)!==0n)throw new r("Oak charges 0 swap fee; venue fees must never be counted as Oak income.");M(e,n),M({...n,...t},n);let a=n.from,d=n.to,l=n.amountIn,g=n.wallet;if(!a||!d||!g||l===void 0)throw new r("Accepted quote must include input, output, amount and wallet.");let w=n.chainId??x,i=n.spender??n.router,c=t.allowance??e.allowance??n?.allowance??"0";f(a),f(d),f(g),f(i);let u=o(l);if(u<=0n)throw new r("Swap amountIn must be greater than zero.");let p=o(n.minAmountOut);if(p<=0n)throw new r("Swap minAmountOut must be greater than zero.");let A=e.router.toLowerCase()===Q.toLowerCase(),m=t.data??e.data??n?.data??(A?Ie({from:a,to:d,amountIn:u.toString(),amountOut:n.amountOut,minAmountOut:p.toString(),wallet:g}):xe({from:a,to:d,amountIn:u.toString(),minAmountOut:p.toString(),wallet:g}));le(m,n.calldataMinAmountOut??p.toString(),n.router.toLowerCase()===P.toLowerCase());let b=n.venueFee??"0",v=n.venueFeeBps??0,S=n.provider??(A?"velora":"kyberswap"),k=n.feeDisclosure??ce({provider:S,venueFee:b,venueFeeBps:v,oakFee:"0"}),E=C(a),O=t.value??e.value??n?.value??(E?u.toString():"0"),I=H({to:e.router,data:m,value:O,chainId:w,description:`Swap ${u} base units of ${a} for at least ${p} base units of ${d} via ${S} (${e.router}). ${k}`});return me(I,n),E||o(c)>=u?[I]:[ee(a,i,u.toString(),w),I]}export{we as a,G as b,Qe as c,Ae as d,W as e,_ as f,D as g,F as h,ve as i,K as j,ae as k,M as l,V as m,C as n,he as o,be as p,_e as q,de as r,Oe as s,ce as t,xe as u,Ie as v,De as w,le as x,me as y,j as z,Ne as A,Me as B};
1
+ import{b as B}from"./P5PYFK7L.js";import{a as te,d as ne,e as oe}from"./ZQAFFWDK.js";import{d as re}from"./WP6RHXGN.js";import{b as T}from"./QHBS3PVU.js";import{a as f,b as H,c as ee}from"./43LI5NKJ.js";import{c as z}from"./OTXSKFUD.js";import{b as o,e as q}from"./IX3GZMTM.js";import{a as x,i as $,w as U,x as y,y as Z,z as J}from"./FWD4L3CJ.js";import{a as r}from"./XSD5NL7J.js";import{decodeFunctionData as R,encodeFunctionData as L,parseAbi as se}from"viem";var we=60,G=50,Qe=200;var Ae="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",W="0x0000000000000000000000000000000000000000",P=$[4663].routes.kyberswap.address,Q=$[4663].routes.velora.address,X=U[4663].kyberswap.toLowerCase(),ie=U[4663].velora.toLowerCase(),ge="0x0000000000000000000000000000000000000000000000000000000000000000",_=se(["function swap((address callTarget, address approveTarget, bytes targetData, (address srcToken, address dstToken, address[] srcReceivers, uint256[] srcAmounts, address[] feeReceivers, uint256[] feeAmounts, address dstReceiver, uint256 amount, uint256 minReturnAmount, uint256 flags, bytes permit) desc, bytes clientData) execution) payable returns (uint256 returnAmount, uint256 gasUsed)"]),N=se(["function swapExactAmountIn(address executor, (address srcToken, address destToken, uint256 fromAmount, uint256 toAmount, uint256 quotedAmount, bytes32 metadata, address beneficiary) swapData, uint256 partnerAndFee, bytes permit, bytes executorData) payable returns (uint256 receivedAmount, uint256 submittedAmount, uint256 augustusFeeAmount)"]),D=class extends r{name="NoRouteError";constructor(t="No swap route is available for this token pair and amount."){super(t)}},F=class extends r{name="ExpiredQuoteError";constructor(t="Quote has expired. Request a fresh quote."){super(t)}},ve=1e3,h=new Map;function ue(e){for(let[t,n]of h)BigInt(e)>=o(n.expiresAt)&&h.delete(t)}function K(e){return{...e,...e.sourcePoolRoute!==void 0?{sourcePoolRoute:structuredClone(e.sourcePoolRoute)}:{},...e.txs?{txs:e.txs.map(t=>({...t}))}:{}}}function ae(e){let t=K(e);return t.txs&&(t.txs.forEach(Object.freeze),Object.freeze(t.txs)),Object.freeze(t)}var Se=["router","from","to","wallet","amountIn","amountOut","minAmountOut","expiresAt","chainId","spender","value","ponsCurveToken","ponsPoolToken","blockNumber","calldataMinAmountOut","expectedSpend","expectedRefund"];function M(e,t,n=!1){for(let s of Se)if(!(s==="expiresAt"&&n&&o(e.expiresAt)<=o(t.expiresAt))&&e[s]!==void 0&&String(e[s]).toLowerCase()!==String(t[s]).toLowerCase())throw new r(`Quote ${s} does not match the accepted quote.`)}function V(e=Date.now){let t=e();if(!Number.isFinite(t)||t<0)throw new r("Clock must return a non-negative timestamp.");return t>1e11?Math.floor(t/1e3):Math.floor(t)}function C(e){let t=e.toLowerCase();return t===Ae.toLowerCase()||t===W.toLowerCase()}function he(e,t=G){if(!Number.isInteger(t)||t<0||t>=1e4)throw new r("Slippage must be an integer from 0 to 9999 bps.");return q(e,String(1e4-t),"10000","floor")}var be=200;function _e(e){if(typeof e!="number"||!Number.isFinite(e)||!/^\d+(?:\.\d{1,2})?$/.test(String(e)))throw new r("Velora returned an unsupported venue fee. Request a fresh quote.");let[t,n=""]=String(e).split("."),s=Number(t)*100+Number(n.padEnd(2,"0"));return Y(s),s}function Y(e){if(!Number.isInteger(e)||e<0||e>be)throw new r("Velora returned an unsupported venue fee. Request a fresh quote.")}function de(e,t=1){return Y(t),o(e)*10000n/BigInt(1e4-t)+1n}function Oe(e,t){Y(t);let n=e>>96n,s=Z>>96n,a=0x3fffn,d=1n<<92n,l=e&(1n<<96n)-1n;if(n!==s&&!(n===0n&&t===0)||(l&a)!==BigInt(t)||(l&~(d|a))!==0n)throw new r("Velora partnerAndFee must match the accepted venue fee and recipient.")}function ce(e){if(e.oakFee!==void 0&&o(e.oakFee)!==0n)throw new r("Oak charges 0 swap fee; venue fees must never be counted as Oak income.");let t=e.provider??"venue";return`Venue fee: ${e.venueFee} base units (${e.venueFeeBps} bps) retained by ${t}; Oak swap fee: 0 (venue fee is never Oak income).`}function xe(e){f(e.from),f(e.to),f(e.wallet);let t=e.callTarget??y[x].kyberswap.address,n=e.approveTarget??W;f(t),f(n);let s=o(e.amountIn),a=o(e.minAmountOut);return L({abi:_,functionName:"swap",args:[{callTarget:t,approveTarget:n,targetData:e.targetData??"0x",desc:{srcToken:e.from,dstToken:e.to,srcReceivers:C(e.from)?[]:[t],srcAmounts:C(e.from)?[]:[s],feeReceivers:[],feeAmounts:[],dstReceiver:e.wallet,amount:s,minReturnAmount:a,flags:0n,permit:"0x"},clientData:e.clientData??"0x"}]})}function Ie(e){f(e.from),f(e.to),f(e.wallet);let t=e.executor??y[x].velora.address;return f(t),L({abi:N,functionName:"swapExactAmountIn",args:[t,{srcToken:e.from,destToken:e.to,fromAmount:o(e.amountIn),toAmount:o(e.minAmountOut),quotedAmount:o(e.amountOut),metadata:e.metadata??ge,beneficiary:e.wallet},e.partnerAndFee??0n,"0x",e.executorData??"0x"]})}function De(e){if(typeof e!="string"||!/^0x([0-9a-fA-F]{2})+$/.test(e)||e.length<10)throw new r("Swap calldata must contain a 4-byte function selector.");let t=e.slice(0,10).toLowerCase();if(t===X)return R({abi:_,data:e}).args[0].desc.minReturnAmount;if(t===ie)return R({abi:N,data:e}).args[1].toAmount;if(t==="0x3593564c")return ne(e).swap.amountOutMinimum;let n=R({abi:te,data:e});if(n.functionName==="buy"||n.functionName==="sell")return n.args[1];throw new r(`Unsupported swap router selector ${t}.`)}function le(e,t,n=!1){let s=o(t),a=De(e);if(a<=0n||s<=0n||a!==s&&!(n&&(a>s||e.slice(0,10).toLowerCase()===X&&a+1n===s)))throw new r(`Built swap calldata minimum output (${a}) does not match the accepted quote minimum (${s}).`);return a}function me(e,t){let{from:n,to:s,wallet:a,amountIn:d}=t;if(!n||!s||!a||d===void 0)throw new r("Accepted quote must include input, output, amount and wallet.");for(let u of[n,s,a,t.router,e.to])f(u);let l=(u,p,A)=>{if(u.toLowerCase()!==p.toLowerCase())throw new r(`Built swap ${A} does not match the accepted quote.`)};if(l(e.to,t.router,"router"),e.chainId!==(t.chainId??x))throw new r("Built swap chain does not match the accepted quote.");let g=C(n)?o(d):0n;if(o(e.value)!==g||t.value!==void 0&&o(t.value)!==g)throw new r("Built swap value does not match the accepted quote input.");let w=e.data.slice(0,10).toLowerCase(),i=t.router.toLowerCase(),c;if(i===P.toLowerCase()&&w===X){l(t.spender??t.router,P,"spender");let u=R({abi:_,data:e.data});if(L({abi:_,...u}).toLowerCase()!==e.data.toLowerCase())throw new r("KyberSwap calldata must be canonically decodable.");let{callTarget:p,approveTarget:A,desc:m}=u.args[0];l(p,y[x].kyberswap.address,"executor"),l(A,W,"executor approval target");let b=C(n);if(m.srcReceivers.length!==m.srcAmounts.length||(b?m.srcReceivers.length!==0:m.srcReceivers.length===0||m.srcAmounts.some(v=>v<=0n)||m.srcAmounts.reduce((v,S)=>v+S,0n)!==o(d)))throw new r("KyberSwap source transfers must send the exact input to the pinned executor or verified input pool.");for(let v of m.srcReceivers)if(v.toLowerCase()!==p.toLowerCase()&&!re(n,v,e.data))throw new r(`KyberSwap source transfers: receiver ${v} is not a verified input pool or the pinned executor.`);if(m.feeReceivers.length||m.feeAmounts.length||m.flags!==0n&&m.flags!==512n||m.permit!=="0x")throw new r("KyberSwap fee recipients, fee amounts, flags and permit must match the pinned zero-fee policy.");c={from:m.srcToken,to:m.dstToken,wallet:m.dstReceiver,amount:m.amount}}else if(i===Q.toLowerCase()&&w===ie){l(t.spender??t.router,Q,"spender");let u=R({abi:N,data:e.data});if(L({abi:N,...u}).toLowerCase()!==e.data.toLowerCase())throw new r("Velora calldata must be canonically decodable.");let[p,A,m,b]=u.args;if(!J.some(v=>v.toLowerCase()===p.toLowerCase()))throw new r("Built swap executor does not match the accepted quote.");if(b!=="0x")throw new r("Velora permit must match the pinned empty-permit policy.");if((t.calldataMinAmountOut!==void 0||m!==0n)&&Oe(m,t.venueFeeBps??0),t.calldataMinAmountOut!==void 0&&o(t.calldataMinAmountOut)!==de(t.minAmountOut,t.venueFeeBps??1))throw new r("Velora calldata minimum must cover the accepted net output, venue fee and router dust.");if(t.calldataMinAmountOut!==void 0&&(A.quotedAmount!==o(t.grossAmountOut??"0")||A.quotedAmount<o(t.calldataMinAmountOut)))throw new r("Velora quoted gross output must match the accepted quote and cover its calldata minimum.");if(m!==0n&&t.calldataMinAmountOut===void 0)throw new r("Velora venue fee requires a fee-adjusted calldata minimum.");c={from:A.srcToken,to:A.destToken,wallet:A.beneficiary,amount:A.fromAmount}}else if(t.provider==="pons"&&(t.ponsPoolToken||t.ponsCurveToken))c=oe(e,{...t,from:n,to:s,wallet:a});else throw new r("Built swap selector does not match the accepted router.");if(l(c.from,n,"input token"),l(c.to,s,"output token"),l(c.wallet,a,"recipient"),c.amount!==o(d))throw new r("Built swap input amount does not match the accepted quote.");le(e.data,t.calldataMinAmountOut??t.minAmountOut,i===P.toLowerCase())}function j(e,t={}){if(!e||typeof e.quoteId!="string"||!e.quoteId.trim())throw new r("Quote must include a non-empty quoteId.");if(f(e.router),e.oakFee!==void 0&&o(e.oakFee)!==0n)throw new r("Oak charges 0 swap fee; venue fees must never be counted as Oak income.");let n=o(e.amountOut),s=e.destAmountAfterFee??e.netAmountOut,a,d,l;if(s!==void 0){if(d=o(s),a=e.grossAmountOut!==void 0?o(e.grossAmountOut):n>=d?n:d,a<d)throw new r("Gross output cannot be less than net output.");l=e.venueFee!==void 0?o(e.venueFee):a-d}else if(e.grossAmountOut!==void 0){if(a=o(e.grossAmountOut),d=n,a<d)throw new r("Gross output cannot be less than net output.");l=e.venueFee!==void 0?o(e.venueFee):a-d}else e.venueFee!==void 0?(l=o(e.venueFee),d=n,a=d+l):(d=n,a=n,l=0n);if(d<=0n)throw new D("Quote output amount must be positive.");let g=t.slippageBps??e.slippageBps??G,w=e.minAmountOut!==void 0?o(e.minAmountOut):o(he(d.toString(),g));if(w<=0n||w>a)throw new r("Quote minAmountOut must be positive and not exceed gross output.");if((t.provider??e.provider)==="velora"&&e.calldataMinAmountOut!==void 0){if(o(e.calldataMinAmountOut)!==de(w.toString(),e.venueFeeBps??1)||o(e.calldataMinAmountOut)>a)throw new r("Velora calldata minimum must cover the accepted net output, venue fee and router dust.")}else if(e.calldataMinAmountOut!==void 0||e.ponsCurveToken!==void 0){if((t.provider??e.provider)!=="pons"||!e.ponsCurveToken)throw new r("Curve minimum requires a Pons curve quote.");f(e.ponsCurveToken);let O=o(t.amountIn??e.amountIn??"0"),I=o(e.expectedSpend??"0"),pe=o(e.expectedRefund??"0"),fe=o(e.calldataMinAmountOut??"0");if(O<=0n||I<=0n||I+pe!==O||fe*I/O!==w)throw new r("Pons actual minimum and refund do not match the encoded minimum.")}let i=V(t.now),c=BigInt(i+we),u=e.expiresAt!==void 0?o(e.expiresAt):c,p=(u>c?c:u).toString(),A=l.toString(),m=e.venueFeeBps??(a>0n&&l>0n?Number((l*10000n+a/2n)/a):0),b=t.provider??e.provider??(e.router.toLowerCase()===Q.toLowerCase()?"velora":"kyberswap"),v=b==="pons"&&e.feeDisclosure?e.feeDisclosure:ce({provider:b,venueFee:A,venueFeeBps:m,oakFee:"0"}),S={...e,quoteId:e.quoteId,amountOut:d.toString(),minAmountOut:w.toString(),router:e.router,expiresAt:p,provider:b,grossAmountOut:a.toString(),destAmountAfterFee:d.toString(),netAmountOut:d.toString(),venueFee:A,venueFeeBps:m,oakFee:"0",feeDisclosure:v,...t.from??e.from?{from:T(t.from??e.from)}:{},...t.to??e.to?{to:T(t.to??e.to)}:{},...t.amountIn??e.amountIn?{amountIn:t.amountIn??e.amountIn}:{},...t.wallet??e.wallet?{wallet:t.wallet??e.wallet}:{},slippageBps:g,chainId:t.chainId??e.chainId??x,spender:e.spender??e.router,...t.allowance??e.allowance?{allowance:t.allowance??e.allowance}:{}};if(BigInt(i)>=o(p))throw new F;if(t.cache===!1)return S;if(ue(i),BigInt(i)>=o(p))throw new F;let k=h.get(S.quoteId);if(k){M(S,k,!0);let O=ae({...k,expiresAt:S.expiresAt});return h.set(O.quoteId,O),K(O)}for(;h.size>=ve;)h.delete(h.keys().next().value);let E=ae(S);return h.set(E.quoteId,E),K(E)}async function Ne(e,t,n={}){e={...e},f(e.from),f(e.to),f(e.wallet),e.from=T(e.from),e.to=T(e.to);let s=o(e.amountIn);if(s<=0n)throw new r("Swap amountIn must be greater than zero.");let a=e.slippageBps??G;if(!Number.isInteger(a)||a<0||a>=1e4)throw new r("Slippage must be an integer from 0 to 9999 bps.");if(!Array.isArray(t)||t.length===0)throw new D;let d={from:e.from,to:e.to,amountIn:s.toString(),slippageBps:a},l=await Promise.allSettled(t.map(async i=>{let c=await(i.quotePrices??i.quote).call(i,{...d},e.wallet);return{quote:j(c,{provider:i.name,from:e.from,to:e.to,amountIn:s.toString(),wallet:e.wallet,slippageBps:a,chainId:e.chainId??x,allowance:e.allowance,now:e.now,cache:!1}),provider:i}})),g,w=[];for(let i of l)i.status==="rejected"&&(g??=z(i.reason)),i.status==="fulfilled"&&o(i.value.quote.expiresAt)>BigInt(V(e.now))&&w.push(i.value);if(w.length===0){let i=l.some(c=>c.status==="rejected"&&c.reason instanceof Error&&c.reason.message===B)&&l.every(c=>c.status==="rejected"&&(c.reason instanceof D||c.reason instanceof Error&&c.reason.message===B));throw g??new D(i?B:void 0)}w.sort((i,c)=>{let p=o(c.quote.amountOut)-o(i.quote.amountOut)||o(c.quote.minAmountOut)-o(i.quote.minAmountOut);return p>0n?1:p<0n?-1:0});for(let{quote:i,provider:c}of w)try{if(BigInt(V(e.now))>=o(i.expiresAt))continue;if(n.deferBuild||!c.prepareQuote)return j(i,{now:e.now});let u=await c.prepareQuote(i.quoteId,e.wallet);if(u.quoteId!==i.quoteId)throw new r("Prepared quote ID does not match the selected route.");if(M(u,i,!0),!u.data)throw new r("Selected route did not return swap calldata.");let p={...i,expiresAt:u.expiresAt,data:u.data,value:u.value,allowance:u.allowance??i.allowance};return me(H({to:p.router,data:u.data,value:u.value??"0",chainId:p.chainId??x,description:"Selected swap route"}),p),j(p,{now:e.now})}catch(u){g??=z(u);continue}throw g??new D}function Me(e,t={}){if(!e||typeof e.quoteId!="string"||!e.quoteId.trim())throw new r("Provide a valid quote to build a swap.");f(e.router);let n=h.get(e.quoteId),s=V(t.now);if(ue(s),!n||BigInt(s)>=o(n.expiresAt))throw h.delete(e.quoteId),new F;if(e.oakFee!==void 0&&o(e.oakFee)!==0n)throw new r("Oak charges 0 swap fee; venue fees must never be counted as Oak income.");M(e,n),M({...n,...t},n);let a=n.from,d=n.to,l=n.amountIn,g=n.wallet;if(!a||!d||!g||l===void 0)throw new r("Accepted quote must include input, output, amount and wallet.");let w=n.chainId??x,i=n.spender??n.router,c=t.allowance??e.allowance??n?.allowance??"0";f(a),f(d),f(g),f(i);let u=o(l);if(u<=0n)throw new r("Swap amountIn must be greater than zero.");let p=o(n.minAmountOut);if(p<=0n)throw new r("Swap minAmountOut must be greater than zero.");let A=e.router.toLowerCase()===Q.toLowerCase(),m=t.data??e.data??n?.data??(A?Ie({from:a,to:d,amountIn:u.toString(),amountOut:n.amountOut,minAmountOut:p.toString(),wallet:g}):xe({from:a,to:d,amountIn:u.toString(),minAmountOut:p.toString(),wallet:g}));le(m,n.calldataMinAmountOut??p.toString(),n.router.toLowerCase()===P.toLowerCase());let b=n.venueFee??"0",v=n.venueFeeBps??0,S=n.provider??(A?"velora":"kyberswap"),k=n.feeDisclosure??ce({provider:S,venueFee:b,venueFeeBps:v,oakFee:"0"}),E=C(a),O=t.value??e.value??n?.value??(E?u.toString():"0"),I=H({to:e.router,data:m,value:O,chainId:w,description:`Swap ${u} base units of ${a} for at least ${p} base units of ${d} via ${S} (${e.router}). ${k}`});return me(I,n),E||o(c)>=u?[I]:[ee(a,i,u.toString(),w),I]}export{we as a,G as b,Qe as c,Ae as d,W as e,_ as f,D as g,F as h,ve as i,K as j,ae as k,M as l,V as m,C as n,he as o,be as p,_e as q,de as r,Oe as s,ce as t,xe as u,Ie as v,De as w,le as x,me as y,j as z,Ne as A,Me as B};
@@ -1 +1 @@
1
- import{h as L,j as i,k as d,l as w,m as y,n as D,o as f,p as l,q as h,r as _,s as q,t as r}from"./JVLLVNF2.js";import{a as O,f as F}from"./MQK6OP7S.js";import{a as c}from"./XSD5NL7J.js";import{encodeAbiParameters as M,getAddress as B,keccak256 as j,parseAbi as $,zeroHash as N}from"viem";var Y="0x167ba3b15d65044b17c87154087d35fc5efde07538be66b804a54e63d6089136",z=$(["function getVersion() view returns (string)"]),E=B("0x8004A169FB4a3325136EB29fA0ceB6D2e539a432"),R=B("0x8004BAa17C55a88189AE136b182e5fdA19dE9b63");function ee(n,s){let e=y(n),o=y(e.caps),t=i(e.gasLimit,32),m=i(o.maxLpFeePips,24);if(s!==Y||e.schemaHash!==Y||e.codeHash!==F(r).codeHash||e.implementation!==r||i(e.kind,8)!==1n||i(e.phaseMask,8)!==1n||d(e.failOpen)||t<400000n||t>2000000n||m>50000n||i(o.maxQuoteTakePips,24)!==0n||i(o.maxSubjectTakeBps,16)!==0n)throw new c("Hookr agent gate admission, schema or execution caps differ from the supported fail-closed BEFORE_SWAP profile. Review the deployment before entry.");return d(e.feeOnly),{...e,caps:o}}async function oe(n,s,e,o=[]){let t=(a,p=[])=>l(n,r,f("agentGateV1"),a,p,s),[m,A,S,g,x,v,k,H,Q,U,W,X]=await Promise.all([t("configSchemaHash"),l(n,_,f("registry"),"admission",[h,r],s),t("retired"),t("identity"),t("reputation"),t("poolManager"),t("isAgent",[e]),t("linkOf",[e]),t("MIN_ADVISORY_GAS"),t("MAX_ADVISORY_GAS"),l(n,E,z,"getVersion",[],s),l(n,R,z,"getVersion",[],s)]),J=ee(A,m);if(g!==E||x!==R||v!==q||i(Q)!==400000n||i(U)!==2000000n)throw new c("Hookr gate dependencies or gas limits differ from the reviewed profile.");let C=a=>{if(typeof a!="string"||new TextEncoder().encode(a).length>32)throw new c("Hookr registry version read is incomplete.");return j(M([{type:"string"}],[a]))},I=C(W)!==O.gateVersions.identity,K=C(X)!==O.gateVersions.reputation,P=I||K,u=d(S),T=w(H,2),Z=await Promise.all(o.map(async a=>{let[p,b]=w(await t("reviewerSet",[a]),2);if(!Array.isArray(p)||p.length===0||p.length>32||typeof b!="string")throw new c("Reviewer set is unregistered or unavailable. Supply an existing registered bytes32 set ID.");let V=p.map(G=>B(String(G)));if(V.some(G=>BigInt(G)===0n)||j(M([{type:"address[]"},{type:"string"}],[V,b]))!==a.toLowerCase())throw new c("Hookr reviewer set does not match its registered ID.");return{id:a,clients:V,tag:b}}));return{address:r,healthy:!u&&!P,healthyIdentityOnly:!u&&!I,healthyForScores:!u&&!P,retired:u,registryVersionDrift:P,schemaHash:m,admission:D(J),identity:E,reputation:R,walletAgent:d(k),link:{linked:d(T[0]),agentId:i(T[1]).toString()},reviewerSets:Z,reviewerSetsComplete:!1,reviewerSetsNotice:"Only explicitly requested registered set IDs are read. This is not an enumeration. No reviewed Priors alias is configured; provide a registered bytes32 set ID.",termsSchema:{flags:"uint16",minScore:"uint32",tierScore:"uint32",tierPips:"uint24",reviewers:"bytes32"},defaults:{flags:"1",minScore:"0",tierScore:"0",tierPips:"0",reviewers:N},maxTierPips:"50000",minGas:"400000",maxGas:"2000000"}}async function ae(n,s,e,o,t){if(BigInt(t)===0n)return{gated:!1,admissionRequiredForCollectOrRemove:!1};if(t!==r)throw new c("This position uses an unreviewed advisory. Gate status is unknown.");let[m,A,S]=await Promise.all([l(n,r,f("agentGateV1"),"terms",[h,e],s),l(n,r,f("agentGateV1"),"explainLiquidity",[h,e,o],s),l(n,r,f("agentGateV1"),"retired",[],s)]),g=y(m),[x,v]=w(A,2);if(!d(g.bound)||g.launcher!==o)throw new c("Hookr gate is not bound to this family Launcher.");for(let[k,H]of[["flags",16],["minScore",32],["tierScore",32],["tierPips",24]])i(g[k],H);return L(g.reviewers),{gated:!0,gate:r,terms:D(g),retired:d(S),liquidityEntryAllowed:d(x),entryReason:i(v,8).toString(),admissionRequiredForCollectOrRemove:!1}}export{Y as a,ee as b,oe as c,ae as d};
1
+ import{h as L,j as i,k as d,l as w,m as y,n as D,o as f,p as l,q as h,r as _,s as q,t as r}from"./T7TFUH5K.js";import{a as O,f as F}from"./MQK6OP7S.js";import{a as c}from"./XSD5NL7J.js";import{encodeAbiParameters as M,getAddress as B,keccak256 as j,parseAbi as $,zeroHash as N}from"viem";var Y="0x167ba3b15d65044b17c87154087d35fc5efde07538be66b804a54e63d6089136",z=$(["function getVersion() view returns (string)"]),E=B("0x8004A169FB4a3325136EB29fA0ceB6D2e539a432"),R=B("0x8004BAa17C55a88189AE136b182e5fdA19dE9b63");function ee(n,s){let e=y(n),o=y(e.caps),t=i(e.gasLimit,32),m=i(o.maxLpFeePips,24);if(s!==Y||e.schemaHash!==Y||e.codeHash!==F(r).codeHash||e.implementation!==r||i(e.kind,8)!==1n||i(e.phaseMask,8)!==1n||d(e.failOpen)||t<400000n||t>2000000n||m>50000n||i(o.maxQuoteTakePips,24)!==0n||i(o.maxSubjectTakeBps,16)!==0n)throw new c("Hookr agent gate admission, schema or execution caps differ from the supported fail-closed BEFORE_SWAP profile. Review the deployment before entry.");return d(e.feeOnly),{...e,caps:o}}async function oe(n,s,e,o=[]){let t=(a,p=[])=>l(n,r,f("agentGateV1"),a,p,s),[m,A,S,g,x,v,k,H,Q,U,W,X]=await Promise.all([t("configSchemaHash"),l(n,_,f("registry"),"admission",[h,r],s),t("retired"),t("identity"),t("reputation"),t("poolManager"),t("isAgent",[e]),t("linkOf",[e]),t("MIN_ADVISORY_GAS"),t("MAX_ADVISORY_GAS"),l(n,E,z,"getVersion",[],s),l(n,R,z,"getVersion",[],s)]),J=ee(A,m);if(g!==E||x!==R||v!==q||i(Q)!==400000n||i(U)!==2000000n)throw new c("Hookr gate dependencies or gas limits differ from the reviewed profile.");let C=a=>{if(typeof a!="string"||new TextEncoder().encode(a).length>32)throw new c("Hookr registry version read is incomplete.");return j(M([{type:"string"}],[a]))},I=C(W)!==O.gateVersions.identity,K=C(X)!==O.gateVersions.reputation,P=I||K,u=d(S),T=w(H,2),Z=await Promise.all(o.map(async a=>{let[p,b]=w(await t("reviewerSet",[a]),2);if(!Array.isArray(p)||p.length===0||p.length>32||typeof b!="string")throw new c("Reviewer set is unregistered or unavailable. Supply an existing registered bytes32 set ID.");let V=p.map(G=>B(String(G)));if(V.some(G=>BigInt(G)===0n)||j(M([{type:"address[]"},{type:"string"}],[V,b]))!==a.toLowerCase())throw new c("Hookr reviewer set does not match its registered ID.");return{id:a,clients:V,tag:b}}));return{address:r,healthy:!u&&!P,healthyIdentityOnly:!u&&!I,healthyForScores:!u&&!P,retired:u,registryVersionDrift:P,schemaHash:m,admission:D(J),identity:E,reputation:R,walletAgent:d(k),link:{linked:d(T[0]),agentId:i(T[1]).toString()},reviewerSets:Z,reviewerSetsComplete:!1,reviewerSetsNotice:"Only explicitly requested registered set IDs are read. This is not an enumeration. No reviewed Priors alias is configured; provide a registered bytes32 set ID.",termsSchema:{flags:"uint16",minScore:"uint32",tierScore:"uint32",tierPips:"uint24",reviewers:"bytes32"},defaults:{flags:"1",minScore:"0",tierScore:"0",tierPips:"0",reviewers:N},maxTierPips:"50000",minGas:"400000",maxGas:"2000000"}}async function ae(n,s,e,o,t){if(BigInt(t)===0n)return{gated:!1,admissionRequiredForCollectOrRemove:!1};if(t!==r)throw new c("This position uses an unreviewed advisory. Gate status is unknown.");let[m,A,S]=await Promise.all([l(n,r,f("agentGateV1"),"terms",[h,e],s),l(n,r,f("agentGateV1"),"explainLiquidity",[h,e,o],s),l(n,r,f("agentGateV1"),"retired",[],s)]),g=y(m),[x,v]=w(A,2);if(!d(g.bound)||g.launcher!==o)throw new c("Hookr gate is not bound to this family Launcher.");for(let[k,H]of[["flags",16],["minScore",32],["tierScore",32],["tierPips",24]])i(g[k],H);return L(g.reviewers),{gated:!0,gate:r,terms:D(g),retired:d(S),liquidityEntryAllowed:d(x),entryReason:i(v,8).toString(),admissionRequiredForCollectOrRemove:!1}}export{Y as a,ee as b,oe as c,ae as d};
@@ -0,0 +1 @@
1
+ import{c as t}from"./VYAJXLND.js";import{c as o}from"./AEL62KCG.js";function s(e,n,a){return t(e,n,a,o)}export{s as a};
@@ -1 +1 @@
1
- import{a as P}from"./SMYWWIE6.js";import{a as y}from"./JKD2B6OX.js";import{b as h,c as w,d as m}from"./2MZXTOZU.js";import{j as B}from"./57MEFFCU.js";import{a as b}from"./43LI5NKJ.js";import{m as f,n as g}from"./NWNYJ26T.js";import{a as u}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{erc20Abi as L,formatUnits as R}from"viem";var A=70515n,U=250202n,C=568341n;function S(a,n){return{token:{...a},amount:n.toString()}}function v(a){if(a.network!==void 0&&a.network!=="mainnet")throw new o("LayerBank requires chain 4663.")}async function k(a,n,r,e){try{return f(await a.readContract({address:n.address,abi:L,functionName:"balanceOf",args:[r],blockNumber:e}),"LayerBank returned a malformed wallet balance read.")}catch(t){throw t instanceof o?t:new o("LayerBank wallet balance could not be read. Please try again.")}}async function T(a,n,r){try{let[e,t]=await Promise.all([n.getGasPrice(),B("ETH",{client:n,http:a.http,chainId:u,blockNumber:r})]),i=g(t.usdE18,"LayerBank gas reference is unavailable.",{positive:!0}),c=f(e,"LayerBank gas reference is unavailable.");if(c===0n)throw new o("LayerBank gas reference is unavailable.");let d=p=>Number(R(p*c*i/10n**18n,18)),s=d(A+U),l=d(C);if(![s,l].every(p=>Number.isFinite(p)&&p>0))throw new o("LayerBank gas reference is unavailable.");return{gasInUsd:s,gasOutUsd:l}}catch{throw new o("LayerBank gas costs could not be checked against a fresh ETH/USD reference. Please try again.")}}async function x(a,n){v(a),b(n);let r=a.clientFor(u),e=await y(r),[t,i,c,d]=await Promise.all([k(r,w,n,e.blockNumber),k(r,m,n,e.blockNumber),P(a.http),T(a,r,e.blockNumber)]),s=[...c.checks,"Gas costs use measured USDG calls plus 20% headroom; entry includes approval and supply."];e.active||s.push("LayerBank reserve is inactive."),e.frozen&&s.push("LayerBank reserve is frozen for deposits."),e.paused&&s.push("LayerBank reserve is paused."),e.capRoomBase===0n&&s.push("LayerBank supply cap has no room left.");let l={rateBasePct:e.rateBasePct,...c.bonus==="unavailable"?{}:{bonus:c.bonus},cashUsdgBase:e.cashUsdgBase,capRoomBase:e.capRoomBase,open:e.active&&!e.frozen&&!e.paused&&e.capRoomBase>0n,walletUsdgBase:t,walletReceiptBase:i,...d,checks:s};return{reserve:e,reading:l}}function H(a){return async n=>{try{return(await x(a,n)).reading}catch(r){return{rateBasePct:0,cashUsdgBase:0n,capRoomBase:0n,open:!1,walletUsdgBase:0n,walletReceiptBase:0n,gasInUsd:0,gasOutUsd:0,checks:[r instanceof o?a.plainError(r):"LayerBank could not be checked right now. Please try again."]}}}}async function z(a,n){v(a),b(n);let r=a.clientFor(u),e=await y(r),t=await k(r,m,n,e.blockNumber);if(t===0n)return[];let i=a.formatAmount(t.toString(),6);return[{module:"layerbank",id:`${u}:${h}`,chainId:u,assets:[S(m,t)],description:`${i} lRobUSDG = ${i} USDG; base supply rate ${e.rateBasePct}% a year, read now.`}]}export{A as a,U as b,C as c,S as d,v as e,k as f,x as g,H as h,z as i};
1
+ import{a as P}from"./SMYWWIE6.js";import{a as y}from"./JKD2B6OX.js";import{b as h,c as w,d as m}from"./2MZXTOZU.js";import{j as B}from"./7KWZ5QJU.js";import{a as b}from"./43LI5NKJ.js";import{m as f,n as g}from"./NWNYJ26T.js";import{a as u}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{erc20Abi as L,formatUnits as R}from"viem";var A=70515n,U=250202n,C=568341n;function S(a,n){return{token:{...a},amount:n.toString()}}function v(a){if(a.network!==void 0&&a.network!=="mainnet")throw new o("LayerBank requires chain 4663.")}async function k(a,n,r,e){try{return f(await a.readContract({address:n.address,abi:L,functionName:"balanceOf",args:[r],blockNumber:e}),"LayerBank returned a malformed wallet balance read.")}catch(t){throw t instanceof o?t:new o("LayerBank wallet balance could not be read. Please try again.")}}async function T(a,n,r){try{let[e,t]=await Promise.all([n.getGasPrice(),B("ETH",{client:n,http:a.http,chainId:u,blockNumber:r})]),i=g(t.usdE18,"LayerBank gas reference is unavailable.",{positive:!0}),c=f(e,"LayerBank gas reference is unavailable.");if(c===0n)throw new o("LayerBank gas reference is unavailable.");let d=p=>Number(R(p*c*i/10n**18n,18)),s=d(A+U),l=d(C);if(![s,l].every(p=>Number.isFinite(p)&&p>0))throw new o("LayerBank gas reference is unavailable.");return{gasInUsd:s,gasOutUsd:l}}catch{throw new o("LayerBank gas costs could not be checked against a fresh ETH/USD reference. Please try again.")}}async function x(a,n){v(a),b(n);let r=a.clientFor(u),e=await y(r),[t,i,c,d]=await Promise.all([k(r,w,n,e.blockNumber),k(r,m,n,e.blockNumber),P(a.http),T(a,r,e.blockNumber)]),s=[...c.checks,"Gas costs use measured USDG calls plus 20% headroom; entry includes approval and supply."];e.active||s.push("LayerBank reserve is inactive."),e.frozen&&s.push("LayerBank reserve is frozen for deposits."),e.paused&&s.push("LayerBank reserve is paused."),e.capRoomBase===0n&&s.push("LayerBank supply cap has no room left.");let l={rateBasePct:e.rateBasePct,...c.bonus==="unavailable"?{}:{bonus:c.bonus},cashUsdgBase:e.cashUsdgBase,capRoomBase:e.capRoomBase,open:e.active&&!e.frozen&&!e.paused&&e.capRoomBase>0n,walletUsdgBase:t,walletReceiptBase:i,...d,checks:s};return{reserve:e,reading:l}}function H(a){return async n=>{try{return(await x(a,n)).reading}catch(r){return{rateBasePct:0,cashUsdgBase:0n,capRoomBase:0n,open:!1,walletUsdgBase:0n,walletReceiptBase:0n,gasInUsd:0,gasOutUsd:0,checks:[r instanceof o?a.plainError(r):"LayerBank could not be checked right now. Please try again."]}}}}async function z(a,n){v(a),b(n);let r=a.clientFor(u),e=await y(r),t=await k(r,m,n,e.blockNumber);if(t===0n)return[];let i=a.formatAmount(t.toString(),6);return[{module:"layerbank",id:`${u}:${h}`,chainId:u,assets:[S(m,t)],description:`${i} lRobUSDG = ${i} USDG; base supply rate ${e.rateBasePct}% a year, read now.`}]}export{A as a,U as b,C as c,S as d,v as e,k as f,x as g,H as h,z as i};