@oakagentkit/core 0.3.6 → 0.3.7

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 (195) hide show
  1. package/build/dist/api/history.js +1 -1
  2. package/build/dist/api/modules/borro/index.js +1 -1
  3. package/build/dist/api/modules/borro/positions.js +1 -1
  4. package/build/dist/api/modules/borro/reader.js +1 -1
  5. package/build/dist/api/modules/chop/display.js +1 -1
  6. package/build/dist/api/modules/chop/index.js +1 -1
  7. package/build/dist/api/modules/earn/index.js +1 -1
  8. package/build/dist/api/modules/erc8004/index.js +1 -1
  9. package/build/dist/api/modules/grove/index.js +1 -1
  10. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  11. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  12. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  13. package/build/dist/api/modules/hoodlock/index.js +1 -1
  14. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  15. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  16. package/build/dist/api/modules/hoodlock/public.js +1 -1
  17. package/build/dist/api/modules/hookr/actions.js +1 -1
  18. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  19. package/build/dist/api/modules/hookr/blocks/pay-later.js +1 -1
  20. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  21. package/build/dist/api/modules/hookr/discovery.js +1 -1
  22. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  23. package/build/dist/api/modules/hookr/hook-blocks.js +1 -1
  24. package/build/dist/api/modules/hookr/index.js +1 -1
  25. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  26. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  27. package/build/dist/api/modules/hookr/launch.js +1 -1
  28. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  29. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  30. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  31. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  32. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  33. package/build/dist/api/modules/hookr/pay-later-actions.js +1 -1
  34. package/build/dist/api/modules/hookr/pm-liquidity.js +1 -1
  35. package/build/dist/api/modules/hookr/relay.js +1 -1
  36. package/build/dist/api/modules/layerbank/actions.js +1 -1
  37. package/build/dist/api/modules/layerbank/index.js +1 -1
  38. package/build/dist/api/modules/layerbank/reader.js +1 -1
  39. package/build/dist/api/modules/longbow/administration.js +1 -1
  40. package/build/dist/api/modules/longbow/fixed.js +1 -1
  41. package/build/dist/api/modules/longbow/index.js +1 -1
  42. package/build/dist/api/modules/meridian/index.js +1 -1
  43. package/build/dist/api/modules/merkl/discovery.js +1 -1
  44. package/build/dist/api/modules/merkl/index.js +1 -1
  45. package/build/dist/api/modules/merkl/manage.js +1 -1
  46. package/build/dist/api/modules/merkl/stock-lp.d.ts +51 -0
  47. package/build/dist/api/modules/merkl/stock-lp.js +1 -0
  48. package/build/dist/api/modules/morpho/bundles.js +1 -1
  49. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  50. package/build/dist/api/modules/morpho/index.js +1 -1
  51. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  52. package/build/dist/api/modules/morpho/midnight.js +1 -1
  53. package/build/dist/api/modules/morpho/protocol.js +1 -1
  54. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  55. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  56. package/build/dist/api/modules/netnet/card-read.js +1 -1
  57. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  58. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  59. package/build/dist/api/modules/netnet/financial.js +1 -1
  60. package/build/dist/api/modules/netnet/index.js +1 -1
  61. package/build/dist/api/modules/pendle/index.js +1 -1
  62. package/build/dist/api/modules/pendle/reader.js +1 -1
  63. package/build/dist/api/modules/pendle/trade.js +1 -1
  64. package/build/dist/api/modules/priors/coverage.js +1 -1
  65. package/build/dist/api/modules/priors/discovery.js +1 -1
  66. package/build/dist/api/modules/priors/index.js +1 -1
  67. package/build/dist/api/modules/priors/integration.js +1 -1
  68. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  69. package/build/dist/api/modules/raeto/index.js +1 -1
  70. package/build/dist/api/modules/relay/index.js +1 -1
  71. package/build/dist/api/modules/steakhouse/index.js +1 -1
  72. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  73. package/build/dist/api/modules/steakhouse/management.js +1 -1
  74. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  75. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  76. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  77. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  78. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  79. package/build/dist/api/modules/tickerspring/index.js +1 -1
  80. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  81. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  82. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  83. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  84. package/build/dist/api/modules/tickerspring/research.js +1 -1
  85. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  86. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  87. package/build/dist/api/modules/uniswap/auction.js +1 -1
  88. package/build/dist/api/modules/uniswap/batch.js +1 -1
  89. package/build/dist/api/modules/uniswap/common.js +1 -1
  90. package/build/dist/api/modules/uniswap/fees.js +1 -1
  91. package/build/dist/api/modules/uniswap/index.js +1 -1
  92. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  93. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  94. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  95. package/build/dist/api/modules/uniswap/pools.js +1 -1
  96. package/build/dist/api/modules/uniswap/position.js +1 -1
  97. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  98. package/build/dist/api/modules/uniswap/quote-guard.js +1 -1
  99. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  100. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  101. package/build/dist/api/modules/uniswap/trade.js +1 -1
  102. package/build/dist/api/modules/uniswap/v2.js +1 -1
  103. package/build/dist/api/modules/uniswap/v3.js +1 -1
  104. package/build/dist/api/modules/uniswap/v4.js +1 -1
  105. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  106. package/build/dist/api/modules/velora/index.js +1 -1
  107. package/build/dist/api/modules/wormhole/index.js +1 -1
  108. package/build/dist/api/prices.js +1 -1
  109. package/build/dist/api/send.js +1 -1
  110. package/build/dist/api/signing-registry.js +1 -1
  111. package/build/dist/api/tokens.js +1 -1
  112. package/build/dist/api/tool-policy.d.ts +1 -0
  113. package/build/dist/api/tool-policy.js +1 -1
  114. package/build/dist/api/usd-estimate.js +1 -1
  115. package/build/dist/chunks/{GBIL2I2K.js → 2GYL3N2O.js} +1 -1
  116. package/build/dist/chunks/{5677LZOV.js → 2ZYFBBOE.js} +1 -1
  117. package/build/dist/chunks/{X53QVHBC.js → 35DTANJW.js} +1 -1
  118. package/build/dist/chunks/{HRGLFGFL.js → 37UBQQWL.js} +1 -1
  119. package/build/dist/chunks/{5DWQUEBA.js → 4JU23O3Z.js} +1 -1
  120. package/build/dist/chunks/{C2H3BWN5.js → 4WYTIM4T.js} +1 -1
  121. package/build/dist/chunks/{FGGDAAHW.js → 52AEVHKJ.js} +1 -1
  122. package/build/dist/chunks/{5RAZFRO4.js → 5EQTOA5F.js} +1 -1
  123. package/build/dist/chunks/{SRYX65GZ.js → 5VA66LFF.js} +1 -1
  124. package/build/dist/chunks/{IM7ZF7XZ.js → 627SGCTU.js} +1 -1
  125. package/build/dist/chunks/{OIGTTRN5.js → 7KK3OC7Q.js} +1 -1
  126. package/build/dist/chunks/{RYEQIZ2H.js → 7PBCV7VS.js} +1 -1
  127. package/build/dist/chunks/{P6JE2NRA.js → AOTTQPK7.js} +1 -1
  128. package/build/dist/chunks/{EHQRAA3R.js → B4U43D5Z.js} +1 -1
  129. package/build/dist/chunks/B5B7U3NZ.js +1 -0
  130. package/build/dist/chunks/{XWZ5SL5Q.js → CITHH7NK.js} +1 -1
  131. package/build/dist/chunks/{L3IAEXQR.js → CLHA557R.js} +1 -1
  132. package/build/dist/chunks/{CVVNAFUE.js → DUTAMN3F.js} +1 -1
  133. package/build/dist/chunks/{DJRS3TR5.js → EKHNXPWO.js} +1 -1
  134. package/build/dist/chunks/EXKV6QJD.js +1 -0
  135. package/build/dist/chunks/{LKRAUTYI.js → FYWK3UK6.js} +1 -1
  136. package/build/dist/chunks/GV6FZ6UG.js +1 -0
  137. package/build/dist/chunks/{TZG7HTVM.js → H5J2LFPZ.js} +1 -1
  138. package/build/dist/chunks/{UGFRBJDQ.js → HN5RBTNE.js} +1 -1
  139. package/build/dist/chunks/{3HF6WE4L.js → HTOP2OKU.js} +1 -1
  140. package/build/dist/chunks/ILTGXU6G.js +1 -0
  141. package/build/dist/chunks/{B5BU645H.js → J5624CVF.js} +1 -1
  142. package/build/dist/chunks/JFYC2LVI.js +1 -0
  143. package/build/dist/chunks/{URTQNYWU.js → JUVY6PCR.js} +1 -1
  144. package/build/dist/chunks/{GX2RCAHG.js → JYED2PZ3.js} +1 -1
  145. package/build/dist/chunks/{HNBYPHTA.js → K3HCSCXE.js} +1 -1
  146. package/build/dist/chunks/{K4CYAWNL.js → KAXLZJU6.js} +1 -1
  147. package/build/dist/chunks/{6QXTL65K.js → KW5LJGNY.js} +1 -1
  148. package/build/dist/chunks/{XUDQYSPU.js → LHC2YV2U.js} +1 -1
  149. package/build/dist/chunks/{2BKZLF5A.js → LHVGWNMW.js} +1 -1
  150. package/build/dist/chunks/{6Y2546JA.js → LOH6LUVT.js} +1 -1
  151. package/build/dist/chunks/{GTJ6LBGB.js → MFRKZOU4.js} +1 -1
  152. package/build/dist/chunks/{QZ6V6J6W.js → MSIT5Q3M.js} +1 -1
  153. package/build/dist/chunks/{G4IX4CYN.js → NCCKCGKL.js} +1 -1
  154. package/build/dist/chunks/{N6YNJGEF.js → NGHRUNXO.js} +1 -1
  155. package/build/dist/chunks/{BSV65PCA.js → NIGRNLNM.js} +1 -1
  156. package/build/dist/chunks/{4SXRXNHG.js → NWW6GY5E.js} +1 -1
  157. package/build/dist/chunks/{CR7DPGI6.js → ORKXBYVC.js} +1 -1
  158. package/build/dist/chunks/{IR7KDBFU.js → OUXPOFY2.js} +1 -1
  159. package/build/dist/chunks/{XXLQDQEX.js → OWHXYE2G.js} +1 -1
  160. package/build/dist/chunks/{J2J73XYU.js → PLEJPTTK.js} +1 -1
  161. package/build/dist/chunks/{QP2B7AYX.js → PX2G2H6G.js} +1 -1
  162. package/build/dist/chunks/{7X5JVF3F.js → QCPJZBEO.js} +1 -1
  163. package/build/dist/chunks/{7JTXYMNP.js → QGO4EKXZ.js} +1 -1
  164. package/build/dist/chunks/{JTWJT2O3.js → QXBQ7WPB.js} +1 -1
  165. package/build/dist/chunks/{DPSFR3ZS.js → R5UOFPDO.js} +1 -1
  166. package/build/dist/chunks/{EJIP7RBG.js → REXGROOD.js} +1 -1
  167. package/build/dist/chunks/{PXVF2SHU.js → RWEA4SWP.js} +1 -1
  168. package/build/dist/chunks/{K6GECT3F.js → RWUF6T4I.js} +1 -1
  169. package/build/dist/chunks/{F74ARK4H.js → SDDYM2H3.js} +1 -1
  170. package/build/dist/chunks/{3M7RMROZ.js → TKJ4GFUP.js} +1 -1
  171. package/build/dist/chunks/{DV2HVFTM.js → UCMOQAVD.js} +1 -1
  172. package/build/dist/chunks/{WUONMIA2.js → UL4DY6GX.js} +1 -1
  173. package/build/dist/chunks/{GCFHKJIO.js → UYYYSFMQ.js} +1 -1
  174. package/build/dist/chunks/{F36IA5RI.js → V7P4PCLL.js} +1 -1
  175. package/build/dist/chunks/{TWVDWNTG.js → VMSGNN3D.js} +1 -1
  176. package/build/dist/chunks/VQMBPY2P.js +1 -0
  177. package/build/dist/chunks/{K5OXLIPK.js → W3M4KAPX.js} +1 -1
  178. package/build/dist/chunks/{Q43WPRYU.js → W7BTXU3F.js} +1 -1
  179. package/build/dist/chunks/{KB2JWQZ4.js → WADRRW3E.js} +1 -1
  180. package/build/dist/chunks/{QAVP3CWL.js → WG7PMGTJ.js} +1 -1
  181. package/build/dist/chunks/{IKVRFAUP.js → WRNPYW47.js} +1 -1
  182. package/build/dist/chunks/{4GAU3JLN.js → XD4JA43O.js} +1 -1
  183. package/build/dist/chunks/{6EWSLHXL.js → Y7SKGRWC.js} +1 -1
  184. package/build/dist/chunks/{HEQBTHFS.js → YDJHXSS7.js} +1 -1
  185. package/build/dist/chunks/{TMENUIBC.js → YLU5JVRI.js} +1 -1
  186. package/build/dist/chunks/{IYOWMW5B.js → YR6Y6UIR.js} +1 -1
  187. package/build/dist/chunks/{FN6XY6ET.js → Z5WRTISY.js} +1 -1
  188. package/build/dist/chunks/{45QP74CE.js → ZB67QDN2.js} +1 -1
  189. package/build/dist/chunks/{MXI7LX2F.js → ZRG34Y7Q.js} +1 -1
  190. package/package.json +1 -1
  191. package/build/dist/chunks/5PNFV7HH.js +0 -1
  192. package/build/dist/chunks/H5KU4DUU.js +0 -1
  193. package/build/dist/chunks/H7ZJ7LAB.js +0 -1
  194. package/build/dist/chunks/M267JEDO.js +0 -1
  195. package/build/dist/chunks/Y5T36EEU.js +0 -1
@@ -1 +1 @@
1
- import{B as Fe,t as se,y as ce}from"./5677LZOV.js";import{d as $,e as Q,f as he,h as Be}from"./7GL547YZ.js";import{a as Z}from"./G2LAO23N.js";import{a as Se,b as ye,c as Ce,e as fe,f as ve,g as Re,h as K,i as b,j as u,k as O,l as Y,m as T,n as ne,o as j,p as R,q as M,s as X,u as ae,v as te}from"./UMY6SP7C.js";import{a as ge,b as E,f as xe,i as W,j as ie,k as He,l as Ie}from"./CJMVRV34.js";import{c as pe}from"./NWNYJ26T.js";import{a}from"./XSD5NL7J.js";import{concatHex as De,encodeAbiParameters as we,getAddress as ue,keccak256 as ee,parseAbi as Ve,toHex as re,zeroAddress as J,zeroHash as oe}from"viem";var Le=n=>j(n.launcher===ue(E.launcherV1)?"launcherV1":"launcher");function Te(n){let t=ee(we([{type:"bytes32"},{type:"bytes32"}],[n,"0x3c0d3d8cba92527b3a48aa783c8734a4e170057eb16401c9df8a7c8a6588b900"]));return re(BigInt(t)+5n,{size:32})}async function Ke(n,t){try{let e="0x0000000000000000000000000000000000000a11",l=await n.request({method:"eth_call",params:[{to:e,data:"0x"},re(t.number),{[e]:{code:"0x4360005260206000f3"}}]});return BigInt(K(l))}catch{throw new a("Hookr parent-block clock is unavailable. Retry with an RPC supporting named-block eth_call state overrides; child-chain height cannot establish lock expiry.")}}async function mn(n,t,e){let l=await ie(n);await W(n,l.number,[e.launcher,M,X]);let r=(k,p=[])=>R(n,e.launcher,Le(e),k,p,l.number),[h,o,m,d]=await Promise.all([r("familyOwner",[e.familyId]),r("memberCount",[e.familyId]),r("position",[e.familyId,Number(e.member)]),r("poolManager")]),i=b(h);if(i===J||i!==t)throw new a("Only the current Hookr family owner can add, collect or remove this position. Use its signing wallet.");if(d!==X||u(o,8)<1n||u(o,8)>8n||BigInt(e.member)>=u(o,8))throw new a("Hookr family member or PoolManager differs from the reviewed deployment.");let c=T(m),g=be(c.key),P=u(c.liquidity,128);if(typeof c.tickLower!="number"||typeof c.tickUpper!="number")throw new a("Hookr family range is unavailable.");let f=c.tickLower,H=c.tickUpper;ce(f,H,g.tickSpacing);let v=se(g);if(await r("poolFamily",[v])!==e.familyId)throw new a("Hookr pool does not belong to this Launcher family.");let S=T(await R(n,M,j("rootV1"),"poolConfig",[v],l.number)),V=b(S.rules),A=ae(V);if(b(S.liquidityOwner)!==e.launcher||![g.currency0,g.currency1].includes(b(S.subject))||![g.currency0,g.currency1].includes(b(S.quote))||S.subject===S.quote)throw new a("Hookr pool configuration differs from this family key.");await W(n,l.number,[V]);let[q,C]=await Promise.all([Promise.all([g.currency0,g.currency1].map(k=>te(n,k,l.number))),R(n,X,Ve(["function extsload(bytes32[] slots) view returns (bytes32[])"]),"extsload",[ke(v,e.launcher,e.familyId,Number(e.member),f,H)],l.number)]),s=Y(C,10).map(k=>BigInt(K(k))),x=s[0]&(1n<<160n)-1n,w=Number(BigInt.asIntN(24,s[0]>>160n));if(!x||w<-887272||w>887272||s[7]!==P)throw new a("Hookr PoolManager state differs from the family position. Retry the full read.");let y=[0,1].map(k=>de(P,le(s[1+k],s[3+k],s[5+k],w,f,H),s[8+k]));return{position:e,block:l,owner:i,key:g,poolId:v,liquidity:P,tickLower:f,tickUpper:H,sqrtPriceX96:x,fees:y,tokens:q,pc:S,core:V,role:A}}async function qe(n,t){let{position:e,block:l,poolId:r,core:h,role:o}=t,[m,d,i,c]=await Promise.all([R(n,e.launcher,Le(e),"principalLockedUntil",[e.familyId],l.number),R(n,h,j(o),"removalLockedUntil",[r],l.number),n.getStorageAt({address:M,slot:Te(r),blockNumber:l.number}),Ke(n,l)]),g=BigInt(K(i));if(ue(re(g&(1n<<160n)-1n,{size:20}))!==e.launcher)throw new a("Hookr frozen Root lock storage does not match the family owner contract.");let P=g>>160n&(1n<<40n)-1n,f=u(m),H=u(d);return{clock:"parent-block",parentBlock:c.toString(),familyUntilParentBlock:f.toString(),poolRulesUntilParentBlock:H.toString(),rootUntilParentBlock:P.toString(),currentlyLocked:c<f||c<H||c<P,feesCollectableDuringPrincipalLocks:!0}}async function je(n,t,e,l){let r=re(BigInt(Te(e))-4n,{size:32}),h=BigInt(K(await n.getStorageAt({address:M,slot:r,blockNumber:t}))),o=(g,P)=>h>>g&(1n<<P)-1n,m=T(l.caps),d=o(192n,24n),i=o(216n,24n),c=o(160n,32n);if(o(0n,24n)!==u(m.maxLpFeePips,24)||o(24n,24n)!==u(m.maxQuoteTakePips,24)||o(48n,16n)!==u(m.maxSubjectTakeBps,16)||c!==u(l.advisoryGasLimit,32)||o(240n,8n)!==0n||l.advisoryFailOpen!==!1||u(l.advisoryPhases,8)!==1n||c<400000n||c>2000000n||d>50000n||i!==0n)throw new a("Hookr frozen pool advisory caps or configuration are unsupported.");return{maxLpFeePips:d,maxQuoteTakePips:i,advisoryGasLimit:c}}async function Ue(n,t,e,l,r){let h=b(l);await W(n,t,[E.registry,E.rootV1]);let o=(p,I=[],N=j("agentGateV2"))=>n.readContract({address:h,abi:N,functionName:p,args:I,blockNumber:t}),[m,d]=await Promise.all([n.getCode({address:h,blockNumber:t}),o("configSchemaHash")]);if(!m||m==="0x"||m.startsWith("0xef0100"))throw new a("Hookr gate runtime is unavailable or delegated.");let i=ee(m),c=Be(h,d),g=xe[h];if(g&&g.codeHash!==i)throw new a("Hookr listed gate runtime drifted. Refresh the reviewed pin.");c.listed&&await W(n,t,[h]);let[P,f,H,v,S,V,A,q,C,s,x,w]=await Promise.all([o("identity"),o("reputation"),o("poolManager"),o(c.healthFunction,[],c.abi),o("MIN_ADVISORY_GAS"),o("MAX_ADVISORY_GAS"),o("linkOf",[J]),o("isAgent",[J]),o("reviewerSet",[oe]),o("terms",[E.rootV1,oe],c.abi),o("scoreOf",[J,oe]),o("explainLiquidity",[E.rootV1,oe,J])]);if(b(P)!==$||b(f)!==Q||b(H)!==ue(E.poolManager)||u(S)!==400000n||u(V)!==2000000n)throw new a("Hookr gate dependency wiring or gas bounds changed.");if(O(v),O(q),!Array.isArray(A)||A.length!==2||!Array.isArray(C)||C.length!==2||!Array.isArray(C[0])||typeof C[1]!="string"||!Array.isArray(x)||x.length!==2||typeof x[1]!="bigint"||!Array.isArray(w)||w.length!==2)throw new a("Hookr gate expected read is incomplete.");O(A[0]),u(A[1]),O(x[0]),O(w[0]),u(w[1],8);let y=T(s);O(y.bound);for(let[p,I]of[["flags",16],["minScore",32],["tierScore",32],["tierPips",24]])u(y[p],I);if(b(y.launcher),b(y.curatedRouter),typeof y.reviewers!="string"||!/^0x[0-9a-fA-F]{64}$/.test(y.reviewers))throw new a("Hookr gate reviewer ID read is incomplete.");if(c.supportsAge){let[p,I,N]=await Promise.all([o("positionManager"),o("ageOf",[J]),o("pins")]);u(y.minAge,32),u(I);let B=T(N);if(b(p)!==he||["identityCode","identityVersion","reputationCode","reputationVersion"].some(D=>typeof B[D]!="string"||!/^0x[0-9a-fA-F]{64}$/.test(B[D])))throw new a("Hookr gate position manager or registry pins are incomplete.");await W(n,t,[he,$,Q])}let k=await je(n,t,e,r);return{profile:c,codeHash:i,admission:null,frozenCaps:k,inactive:O(v),warnings:c.warning?[c.warning+"; the gate can refuse trades at any time"]:[]}}var Oe=Ve(["function getVersion() view returns (string)"]);async function pn(n,t,e,l,r,h,o=[]){let m=await Ue(n,t,l,r,h),d=m.profile,i=(L,F=[])=>R(n,d.address,d.abi,L,F,t),[c,g,P,f,H,v,S,V,A,q,C,s]=await Promise.all([i("configSchemaHash"),Promise.resolve(m.admission),i(d.healthFunction),i("identity"),i("reputation"),i("poolManager"),i("isAgent",[e]),i("linkOf",[e]),i("MIN_ADVISORY_GAS"),i("MAX_ADVISORY_GAS"),R(n,$,Oe,"getVersion",[],t),R(n,Q,Oe,"getVersion",[],t)]),x=g;if(c!==d.schemaHash)throw new a("Hookr gate schema changed during the read.");if(f!==$||H!==Q||v!==X||u(A)!==400000n||u(q)!==2000000n)throw new a("Hookr gate dependencies or gas limits differ from the reviewed profile.");let w=L=>{if(typeof L!="string"||!d.supportsAge&&new TextEncoder().encode(L).length>32)throw new a("Hookr registry version read is incomplete.");let F=we([{type:"string"}],[L]),U=(F.length-2)/2;return ee(d.supportsAge&&U>256?De([F.slice(0,514),re(U,{size:32})]):F)},y,k;if(d.supportsAge){let[L,F,U]=await Promise.all([i("pins"),n.getCode({address:$,blockNumber:t}),n.getCode({address:Q,blockNumber:t})]),z=T(L);for(let _ of["identityCode","identityVersion","reputationCode","reputationVersion"])K(z[_]);if(!F||F==="0x"||!U||U==="0x")throw new a("Hookr registry runtime is unavailable.");y=ee(F)!==z.identityCode||w(C)!==z.identityVersion,k=ee(U)!==z.reputationCode||w(s)!==z.reputationVersion}else y=w(C)!==ge.gateVersions.identity,k=w(s)!==ge.gateVersions.reputation;let p=y||k,I=O(P),N=Y(V,2),B=await Promise.all(o.map(async L=>{let[F,U]=Y(await i("reviewerSet",[L]),2);if(!Array.isArray(F)||F.length===0||F.length>32||typeof U!="string")throw new a("Reviewer set is unregistered or unavailable. Supply an existing registered bytes32 set ID.");let z=F.map(_=>ue(String(_)));if(z.some(_=>BigInt(_)===0n)||ee(we([{type:"address[]"},{type:"string"}],[z,U]))!==L.toLowerCase())throw new a("Hookr reviewer set does not match its registered ID.");return{id:L,clients:z,tag:U}})),D=d.supportsAge?u(await i("ageOf",[e])).toString():null;return{address:d.address,frozenCaps:ne(m.frozenCaps),listed:d.listed,warnings:m.warnings,age:D,suspended:d.supportsAge?I:null,healthy:!I&&!p,healthyIdentityOnly:!I&&!y,healthyForScores:!I&&!p,retired:I,registryVersionDrift:p,schemaHash:c,admission:ne(x),identity:$,reputation:Q,walletAgent:O(S),link:{linked:O(N[0]),agentId:u(N[1]).toString()},reviewerSets:B,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",...d.supportsAge?{minAge:"uint32"}:{}},defaults:{flags:"1",minScore:"0",tierScore:"0",tierPips:"0",reviewers:oe,...d.supportsAge?{minAge:"0"}:{}},maxTierPips:"50000",minGas:"400000",maxGas:"2000000"}}async function ze(n,t,e,l,r,h){if(r===J)return{gated:!1,admissionRequiredForCollectOrRemove:!1};let{profile:o,warnings:m,frozenCaps:d}=await Ue(n,t,e,r,h),[i,c,g]=await Promise.all([R(n,r,o.abi,"terms",[M,e],t),R(n,r,o.abi,"explainLiquidity",[M,e,l],t),R(n,r,o.abi,o.healthFunction,[],t)]),P=T(i),[f,H]=Y(c,2);if(!O(P.bound)||b(P.launcher)!==l)throw new a("Hookr gate is not bound to this family Launcher.");for(let[v,S]of[["flags",16],["minScore",32],["tierScore",32],["tierPips",24]])u(P[v],S);if(K(P.reviewers),o.supportsAge&&u(P.minAge,32),u(P.tierPips,24)>d.maxLpFeePips)throw new a("Hookr gate surcharge exceeds its frozen pool cap.");return{gated:!0,gate:r,warnings:m,frozenCaps:ne(d),terms:ne(P),retired:O(g),suspended:o.supportsAge?O(g):null,liquidityEntryAllowed:O(f),entryReason:u(H,8).toString(),admissionRequiredForCollectOrRemove:!1}}import{encodeAbiParameters as Ge,encodePacked as Ee,getAddress as We,keccak256 as Ae,parseAbi as Xe,toHex as Ye,zeroAddress as $e}from"viem";var Qe=1n<<256n,Je=1n<<128n,Ze=Xe(["function extsload(bytes32[] slots) view returns (bytes32[])"]),me=(n,t,e)=>({type:"object",additionalProperties:!1,properties:n,required:t,...e===void 0?{}:{description:e}}),en={description:"Hookr LP position, chosen by kind: a launcher family member, a position NFT, or an agent-account position.",oneOf:[me({kind:{const:"family",description:Z.enumValues({family:"one member position of a Hookr launcher family"})},launcher:{...pe,description:"Address of the Hookr launcher contract that created the family."},familyId:{...ye,description:"Bytes32 hex id of the launcher family (0x plus 64 hex digits)."},member:{type:"string",enum:["0","1","2","3","4","5","6","7"],description:'Member index within the family, a decimal string from "0" to "7".'}},["kind","launcher","familyId","member"],"Hookr family LP position: one member of a launcher family, identified by launcher, familyId and member."),me({kind:{const:"nft",description:Z.enumValues({nft:"a position held as an NFT"})},tokenId:{...Se,description:Z.id("position NFT")}},["kind","tokenId"]),me({kind:{const:"agent-account",description:Z.enumValues({"agent-account":"a position held by an agent account"})},account:{...pe,description:Z.address("agent account that holds the position")},positionId:{...ye,description:"Bytes32 hex id of the position within the agent account (0x plus 64 hex digits)."}},["kind","account","positionId"])]};function nn(n){let t=T(n);if(t.kind!=="family")throw new a("This step supports Launcher family positions only. NFT and agent-account position reads are reserved for a later integration.");fe(t,["kind","launcher","familyId","member"],["kind","launcher","familyId","member"]);let e=ve(t.member,8);if(e>7n)throw new a("Hookr family member must be a decimal string from 0 to 7.");return{kind:"family",launcher:Ie(t.launcher),familyId:K(t.familyId),member:e.toString()}}var G=n=>Ye(BigInt.asUintN(256,n),{size:32}),Pe=(n,t)=>Ae(Ge([{type:"bytes32"},{type:"bytes32"}],[n,t]));function ke(n,t,e,l,r,h){let o=Pe(n,G(6n)),m=g=>Pe(G(BigInt(g)),G(BigInt(o)+4n)),d=Ae(Ge([{type:"bytes32"},{type:"uint8"}],[e,l])),i=Ae(Ee(["address","int24","int24","bytes32"],[t,r,h,d])),c=Pe(i,G(BigInt(o)+6n));return[o,G(BigInt(o)+1n),G(BigInt(o)+2n),G(BigInt(m(r))+1n),G(BigInt(m(r))+2n),G(BigInt(m(h))+1n),G(BigInt(m(h))+2n),c,G(BigInt(c)+1n),G(BigInt(c)+2n)]}function le(n,t,e,l,r,h){return BigInt.asUintN(256,l<r?t-e:l>=h?e-t:n-t-e)}function de(n,t,e){if(n<0n||n>=1n<<128n||[t,e].some(l=>l<0n||l>=Qe))throw new a("Hookr fee inputs are outside the verified v4 layout.");return n*BigInt.asUintN(256,t-e)/Je}function be(n){let t=T(n),e={currency0:b(t.currency0),currency1:b(t.currency1),fee:Number(u(t.fee,24)),tickSpacing:Number(u(t.tickSpacing,24)),hooks:b(t.hooks)};if(BigInt(e.currency0)>=BigInt(e.currency1)||e.fee!==8388608||e.hooks!==M||e.tickSpacing<1||e.tickSpacing>32767)throw new a("Hookr family PoolKey is not a supported Root dynamic-fee pool.");return e}async function tn(n,t,e,l){let r=await ie(n,l),h={},o=new Set,m=(s,x=[])=>R(n,e.launcher,j(e.launcher===We(E.launcherV1)?"launcherV1":"launcher"),s,x,r.number),d=async(s,x)=>{try{return await x()}catch(w){return h[s]=w instanceof a?w.message:`Hookr ${s} read failed at block ${r.number}. Retry the named-block read; no zero or empty result is implied.`,null}},i={chainId:4663,blockNumber:r.number.toString(),blockHash:r.hash,position:e,owner:null,ownedByWallet:null,poolId:null,poolKey:null,range:null,liquidity:null,tokens:null,principal:null,uncollectedLpFees:null,collectedLpFees:null,claimableCoreCredits:null,poolPendingRecapture:null,inRange:null,gateStatus:null,locks:null},c=async()=>(await He(n,r),{...i,readStatus:{status:Object.keys(h).length?"partial":"complete",reasons:h},warnings:["collectedLpFees is null: no complete collection-history reconstruction is available in this step.","LP fees can include donations already released into v4 fee growth. Pending recapture is pool-level, unallocated and excluded from LP fees.","Principal is current withdrawable token inventory before fees, gas or price changes; it is not the original deposit value."]});if(await d("pins",async()=>(await W(n,r.number,[e.launcher,M,X],o),!0))===null)return c();let g=await d("owner",async()=>{let s=b(await m("familyOwner",[e.familyId]));if(s===$e)throw new a("Hookr family does not exist at this block. Check its Launcher and family ID.");return s});if(g===null)return c();i.owner=g,i.ownedByWallet=g===t;let P=await d("position",async()=>{let[s,x,w]=await Promise.all([m("memberCount",[e.familyId]),m("position",[e.familyId,Number(e.member)]),m("poolManager")]);if(w!==X||u(s,8)>8n||BigInt(e.member)>=u(s,8))throw new a("Hookr family member or PoolManager is invalid.");let y=T(x),k=be(y.key);if(typeof y.tickLower!="number"||typeof y.tickUpper!="number")throw new a("Hookr position range is incomplete.");ce(y.tickLower,y.tickUpper,k.tickSpacing);let p=u(y.liquidity,128),I=se(k);if(await m("poolFamily",[I])!==e.familyId)throw new a("Hookr pool does not belong to this family.");return{key:k,id:I,tickLower:y.tickLower,tickUpper:y.tickUpper,liquidity:p}});if(P===null)return c();let{key:f,id:H,tickLower:v,tickUpper:S,liquidity:V}=P;i.poolKey=f,i.poolId=H,i.range={tickLower:v,tickUpper:S},i.liquidity=V.toString();let[A,q,C]=await Promise.all([d("tokens",()=>Promise.all([te(n,f.currency0,r.number),te(n,f.currency1,r.number)])),d("feeGrowth",async()=>{let s=ke(H,e.launcher,e.familyId,Number(e.member),v,S),x=await R(n,X,Ze,"extsload",[s],r.number),w=Y(x,10).map(Ne=>BigInt(K(Ne))),[y,k,p,I,N,B,D,L,F,U]=w,z=y&(1n<<160n)-1n,_=Number(BigInt.asIntN(24,y>>160n));if(z===0n||_<-887272||_>887272||L!==V)throw new a("Hookr PoolManager position is uninitialized or differs from the Launcher liquidity. No principal or fee amount is inferred.");let _e=le(k,I,B,_,v,S),Me=le(p,N,D,_,v,S);return{sqrtPriceX96:z,tick:_,fee0:de(V,_e,F),fee1:de(V,Me,U)}}),d("poolConfig",async()=>{let s=T(await R(n,M,j("rootV1"),"poolConfig",[H],r.number));if(b(s.liquidityOwner)!==e.launcher||![f.currency0,f.currency1].includes(b(s.subject))||![f.currency0,f.currency1].includes(b(s.quote))||s.subject===s.quote)throw new a("Hookr pool configuration differs from this family position.");let x=b(s.rules),w=ae(x);return await W(n,r.number,[x],o),{pc:s,core:x,role:w}})]);if(i.tokens=A,q&&(i.inRange=q.tick>=v&&q.tick<S,A)){let s=Fe({liquidity:V,tickLower:v,tickUpper:S,sqrtPriceX96:q.sqrtPriceX96});i.principal=[{token:A[0],amount:s.amount0.toString()},{token:A[1],amount:s.amount1.toString()}],i.uncollectedLpFees=[{token:A[0],amount:q.fee0.toString()},{token:A[1],amount:q.fee1.toString()}]}if(C){let s=(p,I=[])=>R(n,C.core,j("rulesV1"),p,I,r.number),[x,w,y,k]=await Promise.all([d("gateStatus",async()=>{let p=b(C.pc.advisory);return ze(n,r.number,H,e.launcher,p,C.pc)}),d("locks",async()=>qe(n,{position:e,block:r,poolId:H,core:C.core,role:C.role})),d("claimableCoreCredits",async()=>{if(!A)throw new a("Read token metadata before displaying core credits.");let p=await s("poolAccruedCurrencies",[H]);if(!Array.isArray(p)||p.length>32||p.some(B=>B!==f.currency0&&B!==f.currency1))throw new a("Core accrual includes unmeasured currencies; read the core directly before collecting.");let[I,N]=await Promise.all([Promise.all([f.currency0,f.currency1].map(B=>s("poolAccrued",[H,B]))),Promise.all([f.currency0,f.currency1].map(B=>R(n,C.core,j(C.role),"claimable",[B,t],r.number)))]);return{core:C.core,familyOwnerAccrual:I.map((B,D)=>({token:A[D],amount:u(B).toString()})),walletCredits:N.map((B,D)=>({token:A[D],amount:u(B).toString()})),walletCreditsScope:"Core-wide wallet credits, not attributed to this position. Do not add them to LP fees."}}),d("poolPendingRecapture",async()=>{if(!A)throw new a("Read token metadata before displaying pending recapture.");let p=Y(await s("pendingDonation",[H]),5).map(I=>u(I));return{due:[{token:A[0],amount:p[0].toString()},{token:A[1],amount:p[1].toString()}],fresh:[{token:A[0],amount:p[2].toString()},{token:A[1],amount:p[3].toString()}],freshChildBlock:p[4].toString(),scope:"pool",allocatedToPosition:!1}})]);i.gateStatus=x,i.locks=w,i.claimableCoreCredits=y,i.poolPendingRecapture=k}return c()}function xn(n){return[{name:"hookr_lp_position",inputSchema:me({position:en,...Ce},["position"]),execute:async(t,e)=>{fe(t,["position","blockNumber"],["position"]);let l=nn(t.position);if(n.network==="testnet")throw new a("Hookr LP reads are configured only on mainnet, chain 4663.");try{return await tn(n.clientFor(4663),e,l,Re(t))}catch(r){throw r instanceof a?r:new a("Hookr position block is unavailable. Retry the complete named-block read; no zero position or fee is implied.")}}}]}export{en as a,nn as b,ke as c,le as d,de as e,be as f,tn as g,xn as h,Le as i,Te as j,Ke as k,mn as l,qe as m,je as n,Ue as o,pn as p,ze as q};
1
+ import{B as Fe,t as se,y as ce}from"./2ZYFBBOE.js";import{d as $,e as Q,f as he,h as Be}from"./7GL547YZ.js";import{a as Z}from"./G2LAO23N.js";import{a as Se,b as ye,c as Ce,e as fe,f as ve,g as Re,h as K,i as b,j as u,k as O,l as Y,m as T,n as ne,o as j,p as R,q as M,s as X,u as ae,v as te}from"./UMY6SP7C.js";import{a as ge,b as E,f as xe,i as W,j as ie,k as He,l as Ie}from"./CJMVRV34.js";import{c as pe}from"./NWNYJ26T.js";import{a}from"./XSD5NL7J.js";import{concatHex as De,encodeAbiParameters as we,getAddress as ue,keccak256 as ee,parseAbi as Ve,toHex as re,zeroAddress as J,zeroHash as oe}from"viem";var Le=n=>j(n.launcher===ue(E.launcherV1)?"launcherV1":"launcher");function Te(n){let t=ee(we([{type:"bytes32"},{type:"bytes32"}],[n,"0x3c0d3d8cba92527b3a48aa783c8734a4e170057eb16401c9df8a7c8a6588b900"]));return re(BigInt(t)+5n,{size:32})}async function Ke(n,t){try{let e="0x0000000000000000000000000000000000000a11",l=await n.request({method:"eth_call",params:[{to:e,data:"0x"},re(t.number),{[e]:{code:"0x4360005260206000f3"}}]});return BigInt(K(l))}catch{throw new a("Hookr parent-block clock is unavailable. Retry with an RPC supporting named-block eth_call state overrides; child-chain height cannot establish lock expiry.")}}async function mn(n,t,e){let l=await ie(n);await W(n,l.number,[e.launcher,M,X]);let r=(k,p=[])=>R(n,e.launcher,Le(e),k,p,l.number),[h,o,m,d]=await Promise.all([r("familyOwner",[e.familyId]),r("memberCount",[e.familyId]),r("position",[e.familyId,Number(e.member)]),r("poolManager")]),i=b(h);if(i===J||i!==t)throw new a("Only the current Hookr family owner can add, collect or remove this position. Use its signing wallet.");if(d!==X||u(o,8)<1n||u(o,8)>8n||BigInt(e.member)>=u(o,8))throw new a("Hookr family member or PoolManager differs from the reviewed deployment.");let c=T(m),g=be(c.key),P=u(c.liquidity,128);if(typeof c.tickLower!="number"||typeof c.tickUpper!="number")throw new a("Hookr family range is unavailable.");let f=c.tickLower,H=c.tickUpper;ce(f,H,g.tickSpacing);let v=se(g);if(await r("poolFamily",[v])!==e.familyId)throw new a("Hookr pool does not belong to this Launcher family.");let S=T(await R(n,M,j("rootV1"),"poolConfig",[v],l.number)),V=b(S.rules),A=ae(V);if(b(S.liquidityOwner)!==e.launcher||![g.currency0,g.currency1].includes(b(S.subject))||![g.currency0,g.currency1].includes(b(S.quote))||S.subject===S.quote)throw new a("Hookr pool configuration differs from this family key.");await W(n,l.number,[V]);let[q,C]=await Promise.all([Promise.all([g.currency0,g.currency1].map(k=>te(n,k,l.number))),R(n,X,Ve(["function extsload(bytes32[] slots) view returns (bytes32[])"]),"extsload",[ke(v,e.launcher,e.familyId,Number(e.member),f,H)],l.number)]),s=Y(C,10).map(k=>BigInt(K(k))),x=s[0]&(1n<<160n)-1n,w=Number(BigInt.asIntN(24,s[0]>>160n));if(!x||w<-887272||w>887272||s[7]!==P)throw new a("Hookr PoolManager state differs from the family position. Retry the full read.");let y=[0,1].map(k=>de(P,le(s[1+k],s[3+k],s[5+k],w,f,H),s[8+k]));return{position:e,block:l,owner:i,key:g,poolId:v,liquidity:P,tickLower:f,tickUpper:H,sqrtPriceX96:x,fees:y,tokens:q,pc:S,core:V,role:A}}async function qe(n,t){let{position:e,block:l,poolId:r,core:h,role:o}=t,[m,d,i,c]=await Promise.all([R(n,e.launcher,Le(e),"principalLockedUntil",[e.familyId],l.number),R(n,h,j(o),"removalLockedUntil",[r],l.number),n.getStorageAt({address:M,slot:Te(r),blockNumber:l.number}),Ke(n,l)]),g=BigInt(K(i));if(ue(re(g&(1n<<160n)-1n,{size:20}))!==e.launcher)throw new a("Hookr frozen Root lock storage does not match the family owner contract.");let P=g>>160n&(1n<<40n)-1n,f=u(m),H=u(d);return{clock:"parent-block",parentBlock:c.toString(),familyUntilParentBlock:f.toString(),poolRulesUntilParentBlock:H.toString(),rootUntilParentBlock:P.toString(),currentlyLocked:c<f||c<H||c<P,feesCollectableDuringPrincipalLocks:!0}}async function je(n,t,e,l){let r=re(BigInt(Te(e))-4n,{size:32}),h=BigInt(K(await n.getStorageAt({address:M,slot:r,blockNumber:t}))),o=(g,P)=>h>>g&(1n<<P)-1n,m=T(l.caps),d=o(192n,24n),i=o(216n,24n),c=o(160n,32n);if(o(0n,24n)!==u(m.maxLpFeePips,24)||o(24n,24n)!==u(m.maxQuoteTakePips,24)||o(48n,16n)!==u(m.maxSubjectTakeBps,16)||c!==u(l.advisoryGasLimit,32)||o(240n,8n)!==0n||l.advisoryFailOpen!==!1||u(l.advisoryPhases,8)!==1n||c<400000n||c>2000000n||d>50000n||i!==0n)throw new a("Hookr frozen pool advisory caps or configuration are unsupported.");return{maxLpFeePips:d,maxQuoteTakePips:i,advisoryGasLimit:c}}async function Ue(n,t,e,l,r){let h=b(l);await W(n,t,[E.registry,E.rootV1]);let o=(p,I=[],N=j("agentGateV2"))=>n.readContract({address:h,abi:N,functionName:p,args:I,blockNumber:t}),[m,d]=await Promise.all([n.getCode({address:h,blockNumber:t}),o("configSchemaHash")]);if(!m||m==="0x"||m.startsWith("0xef0100"))throw new a("Hookr gate runtime is unavailable or delegated.");let i=ee(m),c=Be(h,d),g=xe[h];if(g&&g.codeHash!==i)throw new a("Hookr listed gate runtime drifted. Refresh the reviewed pin.");c.listed&&await W(n,t,[h]);let[P,f,H,v,S,V,A,q,C,s,x,w]=await Promise.all([o("identity"),o("reputation"),o("poolManager"),o(c.healthFunction,[],c.abi),o("MIN_ADVISORY_GAS"),o("MAX_ADVISORY_GAS"),o("linkOf",[J]),o("isAgent",[J]),o("reviewerSet",[oe]),o("terms",[E.rootV1,oe],c.abi),o("scoreOf",[J,oe]),o("explainLiquidity",[E.rootV1,oe,J])]);if(b(P)!==$||b(f)!==Q||b(H)!==ue(E.poolManager)||u(S)!==400000n||u(V)!==2000000n)throw new a("Hookr gate dependency wiring or gas bounds changed.");if(O(v),O(q),!Array.isArray(A)||A.length!==2||!Array.isArray(C)||C.length!==2||!Array.isArray(C[0])||typeof C[1]!="string"||!Array.isArray(x)||x.length!==2||typeof x[1]!="bigint"||!Array.isArray(w)||w.length!==2)throw new a("Hookr gate expected read is incomplete.");O(A[0]),u(A[1]),O(x[0]),O(w[0]),u(w[1],8);let y=T(s);O(y.bound);for(let[p,I]of[["flags",16],["minScore",32],["tierScore",32],["tierPips",24]])u(y[p],I);if(b(y.launcher),b(y.curatedRouter),typeof y.reviewers!="string"||!/^0x[0-9a-fA-F]{64}$/.test(y.reviewers))throw new a("Hookr gate reviewer ID read is incomplete.");if(c.supportsAge){let[p,I,N]=await Promise.all([o("positionManager"),o("ageOf",[J]),o("pins")]);u(y.minAge,32),u(I);let B=T(N);if(b(p)!==he||["identityCode","identityVersion","reputationCode","reputationVersion"].some(D=>typeof B[D]!="string"||!/^0x[0-9a-fA-F]{64}$/.test(B[D])))throw new a("Hookr gate position manager or registry pins are incomplete.");await W(n,t,[he,$,Q])}let k=await je(n,t,e,r);return{profile:c,codeHash:i,admission:null,frozenCaps:k,inactive:O(v),warnings:c.warning?[c.warning+"; the gate can refuse trades at any time"]:[]}}var Oe=Ve(["function getVersion() view returns (string)"]);async function pn(n,t,e,l,r,h,o=[]){let m=await Ue(n,t,l,r,h),d=m.profile,i=(L,F=[])=>R(n,d.address,d.abi,L,F,t),[c,g,P,f,H,v,S,V,A,q,C,s]=await Promise.all([i("configSchemaHash"),Promise.resolve(m.admission),i(d.healthFunction),i("identity"),i("reputation"),i("poolManager"),i("isAgent",[e]),i("linkOf",[e]),i("MIN_ADVISORY_GAS"),i("MAX_ADVISORY_GAS"),R(n,$,Oe,"getVersion",[],t),R(n,Q,Oe,"getVersion",[],t)]),x=g;if(c!==d.schemaHash)throw new a("Hookr gate schema changed during the read.");if(f!==$||H!==Q||v!==X||u(A)!==400000n||u(q)!==2000000n)throw new a("Hookr gate dependencies or gas limits differ from the reviewed profile.");let w=L=>{if(typeof L!="string"||!d.supportsAge&&new TextEncoder().encode(L).length>32)throw new a("Hookr registry version read is incomplete.");let F=we([{type:"string"}],[L]),U=(F.length-2)/2;return ee(d.supportsAge&&U>256?De([F.slice(0,514),re(U,{size:32})]):F)},y,k;if(d.supportsAge){let[L,F,U]=await Promise.all([i("pins"),n.getCode({address:$,blockNumber:t}),n.getCode({address:Q,blockNumber:t})]),z=T(L);for(let _ of["identityCode","identityVersion","reputationCode","reputationVersion"])K(z[_]);if(!F||F==="0x"||!U||U==="0x")throw new a("Hookr registry runtime is unavailable.");y=ee(F)!==z.identityCode||w(C)!==z.identityVersion,k=ee(U)!==z.reputationCode||w(s)!==z.reputationVersion}else y=w(C)!==ge.gateVersions.identity,k=w(s)!==ge.gateVersions.reputation;let p=y||k,I=O(P),N=Y(V,2),B=await Promise.all(o.map(async L=>{let[F,U]=Y(await i("reviewerSet",[L]),2);if(!Array.isArray(F)||F.length===0||F.length>32||typeof U!="string")throw new a("Reviewer set is unregistered or unavailable. Supply an existing registered bytes32 set ID.");let z=F.map(_=>ue(String(_)));if(z.some(_=>BigInt(_)===0n)||ee(we([{type:"address[]"},{type:"string"}],[z,U]))!==L.toLowerCase())throw new a("Hookr reviewer set does not match its registered ID.");return{id:L,clients:z,tag:U}})),D=d.supportsAge?u(await i("ageOf",[e])).toString():null;return{address:d.address,frozenCaps:ne(m.frozenCaps),listed:d.listed,warnings:m.warnings,age:D,suspended:d.supportsAge?I:null,healthy:!I&&!p,healthyIdentityOnly:!I&&!y,healthyForScores:!I&&!p,retired:I,registryVersionDrift:p,schemaHash:c,admission:ne(x),identity:$,reputation:Q,walletAgent:O(S),link:{linked:O(N[0]),agentId:u(N[1]).toString()},reviewerSets:B,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",...d.supportsAge?{minAge:"uint32"}:{}},defaults:{flags:"1",minScore:"0",tierScore:"0",tierPips:"0",reviewers:oe,...d.supportsAge?{minAge:"0"}:{}},maxTierPips:"50000",minGas:"400000",maxGas:"2000000"}}async function ze(n,t,e,l,r,h){if(r===J)return{gated:!1,admissionRequiredForCollectOrRemove:!1};let{profile:o,warnings:m,frozenCaps:d}=await Ue(n,t,e,r,h),[i,c,g]=await Promise.all([R(n,r,o.abi,"terms",[M,e],t),R(n,r,o.abi,"explainLiquidity",[M,e,l],t),R(n,r,o.abi,o.healthFunction,[],t)]),P=T(i),[f,H]=Y(c,2);if(!O(P.bound)||b(P.launcher)!==l)throw new a("Hookr gate is not bound to this family Launcher.");for(let[v,S]of[["flags",16],["minScore",32],["tierScore",32],["tierPips",24]])u(P[v],S);if(K(P.reviewers),o.supportsAge&&u(P.minAge,32),u(P.tierPips,24)>d.maxLpFeePips)throw new a("Hookr gate surcharge exceeds its frozen pool cap.");return{gated:!0,gate:r,warnings:m,frozenCaps:ne(d),terms:ne(P),retired:O(g),suspended:o.supportsAge?O(g):null,liquidityEntryAllowed:O(f),entryReason:u(H,8).toString(),admissionRequiredForCollectOrRemove:!1}}import{encodeAbiParameters as Ge,encodePacked as Ee,getAddress as We,keccak256 as Ae,parseAbi as Xe,toHex as Ye,zeroAddress as $e}from"viem";var Qe=1n<<256n,Je=1n<<128n,Ze=Xe(["function extsload(bytes32[] slots) view returns (bytes32[])"]),me=(n,t,e)=>({type:"object",additionalProperties:!1,properties:n,required:t,...e===void 0?{}:{description:e}}),en={description:"Hookr LP position, chosen by kind: a launcher family member, a position NFT, or an agent-account position.",oneOf:[me({kind:{const:"family",description:Z.enumValues({family:"one member position of a Hookr launcher family"})},launcher:{...pe,description:"Address of the Hookr launcher contract that created the family."},familyId:{...ye,description:"Bytes32 hex id of the launcher family (0x plus 64 hex digits)."},member:{type:"string",enum:["0","1","2","3","4","5","6","7"],description:'Member index within the family, a decimal string from "0" to "7".'}},["kind","launcher","familyId","member"],"Hookr family LP position: one member of a launcher family, identified by launcher, familyId and member."),me({kind:{const:"nft",description:Z.enumValues({nft:"a position held as an NFT"})},tokenId:{...Se,description:Z.id("position NFT")}},["kind","tokenId"]),me({kind:{const:"agent-account",description:Z.enumValues({"agent-account":"a position held by an agent account"})},account:{...pe,description:Z.address("agent account that holds the position")},positionId:{...ye,description:"Bytes32 hex id of the position within the agent account (0x plus 64 hex digits)."}},["kind","account","positionId"])]};function nn(n){let t=T(n);if(t.kind!=="family")throw new a("This step supports Launcher family positions only. NFT and agent-account position reads are reserved for a later integration.");fe(t,["kind","launcher","familyId","member"],["kind","launcher","familyId","member"]);let e=ve(t.member,8);if(e>7n)throw new a("Hookr family member must be a decimal string from 0 to 7.");return{kind:"family",launcher:Ie(t.launcher),familyId:K(t.familyId),member:e.toString()}}var G=n=>Ye(BigInt.asUintN(256,n),{size:32}),Pe=(n,t)=>Ae(Ge([{type:"bytes32"},{type:"bytes32"}],[n,t]));function ke(n,t,e,l,r,h){let o=Pe(n,G(6n)),m=g=>Pe(G(BigInt(g)),G(BigInt(o)+4n)),d=Ae(Ge([{type:"bytes32"},{type:"uint8"}],[e,l])),i=Ae(Ee(["address","int24","int24","bytes32"],[t,r,h,d])),c=Pe(i,G(BigInt(o)+6n));return[o,G(BigInt(o)+1n),G(BigInt(o)+2n),G(BigInt(m(r))+1n),G(BigInt(m(r))+2n),G(BigInt(m(h))+1n),G(BigInt(m(h))+2n),c,G(BigInt(c)+1n),G(BigInt(c)+2n)]}function le(n,t,e,l,r,h){return BigInt.asUintN(256,l<r?t-e:l>=h?e-t:n-t-e)}function de(n,t,e){if(n<0n||n>=1n<<128n||[t,e].some(l=>l<0n||l>=Qe))throw new a("Hookr fee inputs are outside the verified v4 layout.");return n*BigInt.asUintN(256,t-e)/Je}function be(n){let t=T(n),e={currency0:b(t.currency0),currency1:b(t.currency1),fee:Number(u(t.fee,24)),tickSpacing:Number(u(t.tickSpacing,24)),hooks:b(t.hooks)};if(BigInt(e.currency0)>=BigInt(e.currency1)||e.fee!==8388608||e.hooks!==M||e.tickSpacing<1||e.tickSpacing>32767)throw new a("Hookr family PoolKey is not a supported Root dynamic-fee pool.");return e}async function tn(n,t,e,l){let r=await ie(n,l),h={},o=new Set,m=(s,x=[])=>R(n,e.launcher,j(e.launcher===We(E.launcherV1)?"launcherV1":"launcher"),s,x,r.number),d=async(s,x)=>{try{return await x()}catch(w){return h[s]=w instanceof a?w.message:`Hookr ${s} read failed at block ${r.number}. Retry the named-block read; no zero or empty result is implied.`,null}},i={chainId:4663,blockNumber:r.number.toString(),blockHash:r.hash,position:e,owner:null,ownedByWallet:null,poolId:null,poolKey:null,range:null,liquidity:null,tokens:null,principal:null,uncollectedLpFees:null,collectedLpFees:null,claimableCoreCredits:null,poolPendingRecapture:null,inRange:null,gateStatus:null,locks:null},c=async()=>(await He(n,r),{...i,readStatus:{status:Object.keys(h).length?"partial":"complete",reasons:h},warnings:["collectedLpFees is null: no complete collection-history reconstruction is available in this step.","LP fees can include donations already released into v4 fee growth. Pending recapture is pool-level, unallocated and excluded from LP fees.","Principal is current withdrawable token inventory before fees, gas or price changes; it is not the original deposit value."]});if(await d("pins",async()=>(await W(n,r.number,[e.launcher,M,X],o),!0))===null)return c();let g=await d("owner",async()=>{let s=b(await m("familyOwner",[e.familyId]));if(s===$e)throw new a("Hookr family does not exist at this block. Check its Launcher and family ID.");return s});if(g===null)return c();i.owner=g,i.ownedByWallet=g===t;let P=await d("position",async()=>{let[s,x,w]=await Promise.all([m("memberCount",[e.familyId]),m("position",[e.familyId,Number(e.member)]),m("poolManager")]);if(w!==X||u(s,8)>8n||BigInt(e.member)>=u(s,8))throw new a("Hookr family member or PoolManager is invalid.");let y=T(x),k=be(y.key);if(typeof y.tickLower!="number"||typeof y.tickUpper!="number")throw new a("Hookr position range is incomplete.");ce(y.tickLower,y.tickUpper,k.tickSpacing);let p=u(y.liquidity,128),I=se(k);if(await m("poolFamily",[I])!==e.familyId)throw new a("Hookr pool does not belong to this family.");return{key:k,id:I,tickLower:y.tickLower,tickUpper:y.tickUpper,liquidity:p}});if(P===null)return c();let{key:f,id:H,tickLower:v,tickUpper:S,liquidity:V}=P;i.poolKey=f,i.poolId=H,i.range={tickLower:v,tickUpper:S},i.liquidity=V.toString();let[A,q,C]=await Promise.all([d("tokens",()=>Promise.all([te(n,f.currency0,r.number),te(n,f.currency1,r.number)])),d("feeGrowth",async()=>{let s=ke(H,e.launcher,e.familyId,Number(e.member),v,S),x=await R(n,X,Ze,"extsload",[s],r.number),w=Y(x,10).map(Ne=>BigInt(K(Ne))),[y,k,p,I,N,B,D,L,F,U]=w,z=y&(1n<<160n)-1n,_=Number(BigInt.asIntN(24,y>>160n));if(z===0n||_<-887272||_>887272||L!==V)throw new a("Hookr PoolManager position is uninitialized or differs from the Launcher liquidity. No principal or fee amount is inferred.");let _e=le(k,I,B,_,v,S),Me=le(p,N,D,_,v,S);return{sqrtPriceX96:z,tick:_,fee0:de(V,_e,F),fee1:de(V,Me,U)}}),d("poolConfig",async()=>{let s=T(await R(n,M,j("rootV1"),"poolConfig",[H],r.number));if(b(s.liquidityOwner)!==e.launcher||![f.currency0,f.currency1].includes(b(s.subject))||![f.currency0,f.currency1].includes(b(s.quote))||s.subject===s.quote)throw new a("Hookr pool configuration differs from this family position.");let x=b(s.rules),w=ae(x);return await W(n,r.number,[x],o),{pc:s,core:x,role:w}})]);if(i.tokens=A,q&&(i.inRange=q.tick>=v&&q.tick<S,A)){let s=Fe({liquidity:V,tickLower:v,tickUpper:S,sqrtPriceX96:q.sqrtPriceX96});i.principal=[{token:A[0],amount:s.amount0.toString()},{token:A[1],amount:s.amount1.toString()}],i.uncollectedLpFees=[{token:A[0],amount:q.fee0.toString()},{token:A[1],amount:q.fee1.toString()}]}if(C){let s=(p,I=[])=>R(n,C.core,j("rulesV1"),p,I,r.number),[x,w,y,k]=await Promise.all([d("gateStatus",async()=>{let p=b(C.pc.advisory);return ze(n,r.number,H,e.launcher,p,C.pc)}),d("locks",async()=>qe(n,{position:e,block:r,poolId:H,core:C.core,role:C.role})),d("claimableCoreCredits",async()=>{if(!A)throw new a("Read token metadata before displaying core credits.");let p=await s("poolAccruedCurrencies",[H]);if(!Array.isArray(p)||p.length>32||p.some(B=>B!==f.currency0&&B!==f.currency1))throw new a("Core accrual includes unmeasured currencies; read the core directly before collecting.");let[I,N]=await Promise.all([Promise.all([f.currency0,f.currency1].map(B=>s("poolAccrued",[H,B]))),Promise.all([f.currency0,f.currency1].map(B=>R(n,C.core,j(C.role),"claimable",[B,t],r.number)))]);return{core:C.core,familyOwnerAccrual:I.map((B,D)=>({token:A[D],amount:u(B).toString()})),walletCredits:N.map((B,D)=>({token:A[D],amount:u(B).toString()})),walletCreditsScope:"Core-wide wallet credits, not attributed to this position. Do not add them to LP fees."}}),d("poolPendingRecapture",async()=>{if(!A)throw new a("Read token metadata before displaying pending recapture.");let p=Y(await s("pendingDonation",[H]),5).map(I=>u(I));return{due:[{token:A[0],amount:p[0].toString()},{token:A[1],amount:p[1].toString()}],fresh:[{token:A[0],amount:p[2].toString()},{token:A[1],amount:p[3].toString()}],freshChildBlock:p[4].toString(),scope:"pool",allocatedToPosition:!1}})]);i.gateStatus=x,i.locks=w,i.claimableCoreCredits=y,i.poolPendingRecapture=k}return c()}function xn(n){return[{name:"hookr_lp_position",inputSchema:me({position:en,...Ce},["position"]),execute:async(t,e)=>{fe(t,["position","blockNumber"],["position"]);let l=nn(t.position);if(n.network==="testnet")throw new a("Hookr LP reads are configured only on mainnet, chain 4663.");try{return await tn(n.clientFor(4663),e,l,Re(t))}catch(r){throw r instanceof a?r:new a("Hookr position block is unavailable. Retry the complete named-block read; no zero position or fee is implied.")}}}]}export{en as a,nn as b,ke as c,le as d,de as e,be as f,tn as g,xn as h,Le as i,Te as j,Ke as k,mn as l,qe as m,je as n,Ue as o,pn as p,ze as q};
@@ -1 +1 @@
1
- import{p as se}from"./G4IX4CYN.js";import{a as ee,c as te,d as ie,e as oe,h as re,j as L}from"./7GL547YZ.js";import{b as F,c as X,e as J,g as N,h as x,i as P,j as n,k as f,l as T,m as S,n as V,o as Z,p as A,q as C,s as $,t as D}from"./UMY6SP7C.js";import{a as B,h as K,j as Q,k as W}from"./CJMVRV34.js";import{a as p}from"./XSD5NL7J.js";import{concatHex as he,encodeAbiParameters as ne,getAddress as z,keccak256 as E,parseAbi as we,toHex as ye,zeroHash as Ae}from"viem";var ae=ee,de=we(["function getVersion() view returns (string)"]),M=z("0x8004A169FB4a3325136EB29fA0ceB6D2e539a432"),q=z("0x8004BAa17C55a88189AE136b182e5fdA19dE9b63");function Ce(s,e){let o=S(s),c=S(o.caps),g=n(o.gasLimit,32),i=n(c.maxLpFeePips,24);if(e!==ae||o.schemaHash!==ae||o.codeHash!==K(D).codeHash||o.implementation!==D||n(o.kind,8)!==1n||n(o.phaseMask,8)!==1n||f(o.failOpen)||g<400000n||g>2000000n||i>50000n||n(c.maxQuoteTakePips,24)!==0n||n(c.maxSubjectTakeBps,16)!==0n)throw new p("Hookr agent gate admission, schema or execution caps differ from the supported fail-closed BEFORE_SWAP profile. Review the deployment before entry.");return f(o.feeOnly),{...o,caps:c}}async function ke(s,e,o,c=[],g=D,i=!0){let d=await L(s,e,g,{requireAdmission:i}),t=d.profile,r=(m,l=[])=>A(s,t.address,t.abi,m,l,e),[k,u,w,a,v,H,le,pe,ce,ge,j,U]=await Promise.all([r("configSchemaHash"),Promise.resolve(d.admission),r(t.healthFunction),r("identity"),r("reputation"),r("poolManager"),r("isAgent",[o]),r("linkOf",[o]),r("MIN_ADVISORY_GAS"),r("MAX_ADVISORY_GAS"),A(s,M,de,"getVersion",[],e),A(s,q,de,"getVersion",[],e)]),ue=u;if(k!==t.schemaHash)throw new p("Hookr gate schema changed during the read.");if(a!==M||v!==q||H!==$||n(ce)!==400000n||n(ge)!==2000000n)throw new p("Hookr gate dependencies or gas limits differ from the reviewed profile.");let O=m=>{if(typeof m!="string"||!t.supportsAge&&new TextEncoder().encode(m).length>32)throw new p("Hookr registry version read is incomplete.");let l=ne([{type:"string"}],[m]),h=(l.length-2)/2;return E(t.supportsAge&&h>256?he([l.slice(0,514),ye(h,{size:32})]):l)},R,G;if(t.supportsAge){let[m,l,h]=await Promise.all([r("pins"),s.getCode({address:ie,blockNumber:e}),s.getCode({address:oe,blockNumber:e})]),y=S(m);for(let I of["identityCode","identityVersion","reputationCode","reputationVersion"])x(y[I]);if(!l||l==="0x"||!h||h==="0x")throw new p("Hookr registry runtime is unavailable.");R=E(l)!==y.identityCode||O(j)!==y.identityVersion,G=E(h)!==y.reputationCode||O(U)!==y.reputationVersion}else R=O(j)!==B.gateVersions.identity,G=O(U)!==B.gateVersions.reputation;let _=R||G,b=f(w),Y=T(pe,2),me=await Promise.all(c.map(async m=>{let[l,h]=T(await r("reviewerSet",[m]),2);if(!Array.isArray(l)||l.length===0||l.length>32||typeof h!="string")throw new p("Reviewer set is unregistered or unavailable. Supply an existing registered bytes32 set ID.");let y=l.map(I=>z(String(I)));if(y.some(I=>BigInt(I)===0n)||E(ne([{type:"address[]"},{type:"string"}],[y,h]))!==m.toLowerCase())throw new p("Hookr reviewer set does not match its registered ID.");return{id:m,clients:y,tag:h}})),fe=t.supportsAge?n(await r("ageOf",[o])).toString():null;return{address:t.address,listed:t.listed,warnings:d.warnings,age:fe,suspended:t.supportsAge?b:null,healthy:!b&&!_,healthyIdentityOnly:!b&&!R,healthyForScores:!b&&!_,retired:b,registryVersionDrift:_,schemaHash:k,admission:V(ue),identity:M,reputation:q,walletAgent:f(le),link:{linked:f(Y[0]),agentId:n(Y[1]).toString()},reviewerSets:me,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",...t.supportsAge?{minAge:"uint32"}:{}},defaults:{flags:"1",minScore:"0",tierScore:"0",tierPips:"0",reviewers:Ae,...t.supportsAge?{minAge:"0"}:{}},maxTierPips:"50000",minGas:"400000",maxGas:"2000000"}}async function Oe(s,e,o,c,g){if(BigInt(g)===0n)return{gated:!1,admissionRequiredForCollectOrRemove:!1};let{profile:i,warnings:d}=await L(s,e,g,{requireAdmission:!1}),[t,r,k]=await Promise.all([A(s,i.address,i.abi,"terms",[C,o],e),A(s,i.address,i.abi,"explainLiquidity",[C,o,c],e),A(s,i.address,i.abi,i.healthFunction,[],e)]),u=S(t),[w,a]=T(r,2);if(!f(u.bound)||u.launcher!==c)throw new p("Hookr gate is not bound to this family Launcher.");for(let[v,H]of[["flags",16],["minScore",32],["tierScore",32],["tierPips",24]])n(u[v],H);return x(u.reviewers),i.supportsAge&&n(u.minAge,32),{gated:!0,gate:i.address,warnings:d,suspended:i.supportsAge?f(k):null,terms:V(u),retired:f(k),liquidityEntryAllowed:f(w),entryReason:n(a,8).toString(),admissionRequiredForCollectOrRemove:!1}}function Re(s){return[{name:"hookr_agent_gate",inputSchema:{type:"object",additionalProperties:!1,properties:{...X,gate:{type:"string",description:"Optional checksummed gate address; defaults to the current gate."},poolId:{...F,description:"Optional pool ID as 0x plus 64 hex digits to read its frozen agent gate and terms."},reviewerSetIds:{type:"array",maxItems:8,uniqueItems:!0,items:F,description:"Up to eight distinct registered reviewer set IDs to read, each as 0x plus 64 hex digits."}}},execute:async(e,o)=>{if(J(e,["blockNumber","gate","poolId","reviewerSetIds"]),s.network==="testnet")throw new p("Hookr gate reads are configured only on mainnet, chain 4663.");let c=e.reviewerSetIds??[];if(!Array.isArray(c)||c.length>8)throw new p("Provide at most eight distinct reviewer set IDs.");let g=c.map(x);if(new Set(g).size!==g.length)throw new p("Provide distinct reviewer set IDs.");let i=s.clientFor(4663),d=await Q(i,N(e)),t=e.gate===void 0?te:P(e.gate),r=null;if(e.poolId!==void 0){let w=S(await A(i,C,Z("rootV1"),"poolConfig",[x(e.poolId)],d.number)),a=P(w.advisory);if(BigInt(a)===0n)throw new p("Hookr pool is unknown or has no agent gate.");if(e.gate!==void 0&&t!==a)throw new p("The supplied gate does not match the pool advisory at this block.");t=a,r=w}let k=r?await se(i,d.number,o,x(e.poolId),t,r,g):await ke(i,d.number,o,g,t,!1),u=null;if(r){let w=re(t,k.schemaHash),a=S(await A(i,t,w.abi,"terms",[C,x(e.poolId)],d.number));f(a.bound),P(a.launcher),P(a.curatedRouter),x(a.reviewers);for(let[v,H]of[["flags",16],["minScore",32],["tierScore",32],["tierPips",24]])n(a[v],H);w.supportsAge&&n(a.minAge,32),u=V(a)}return await W(i,d),{chainId:4663,blockNumber:d.number.toString(),blockHash:d.hash,timestamp:d.timestamp.toString(),...k,poolTerms:u}}}]}export{ae as a,Ce as b,ke as c,Oe as d,Re as e};
1
+ import{p as se}from"./NCCKCGKL.js";import{a as ee,c as te,d as ie,e as oe,h as re,j as L}from"./7GL547YZ.js";import{b as F,c as X,e as J,g as N,h as x,i as P,j as n,k as f,l as T,m as S,n as V,o as Z,p as A,q as C,s as $,t as D}from"./UMY6SP7C.js";import{a as B,h as K,j as Q,k as W}from"./CJMVRV34.js";import{a as p}from"./XSD5NL7J.js";import{concatHex as he,encodeAbiParameters as ne,getAddress as z,keccak256 as E,parseAbi as we,toHex as ye,zeroHash as Ae}from"viem";var ae=ee,de=we(["function getVersion() view returns (string)"]),M=z("0x8004A169FB4a3325136EB29fA0ceB6D2e539a432"),q=z("0x8004BAa17C55a88189AE136b182e5fdA19dE9b63");function Ce(s,e){let o=S(s),c=S(o.caps),g=n(o.gasLimit,32),i=n(c.maxLpFeePips,24);if(e!==ae||o.schemaHash!==ae||o.codeHash!==K(D).codeHash||o.implementation!==D||n(o.kind,8)!==1n||n(o.phaseMask,8)!==1n||f(o.failOpen)||g<400000n||g>2000000n||i>50000n||n(c.maxQuoteTakePips,24)!==0n||n(c.maxSubjectTakeBps,16)!==0n)throw new p("Hookr agent gate admission, schema or execution caps differ from the supported fail-closed BEFORE_SWAP profile. Review the deployment before entry.");return f(o.feeOnly),{...o,caps:c}}async function ke(s,e,o,c=[],g=D,i=!0){let d=await L(s,e,g,{requireAdmission:i}),t=d.profile,r=(m,l=[])=>A(s,t.address,t.abi,m,l,e),[k,u,w,a,v,H,le,pe,ce,ge,j,U]=await Promise.all([r("configSchemaHash"),Promise.resolve(d.admission),r(t.healthFunction),r("identity"),r("reputation"),r("poolManager"),r("isAgent",[o]),r("linkOf",[o]),r("MIN_ADVISORY_GAS"),r("MAX_ADVISORY_GAS"),A(s,M,de,"getVersion",[],e),A(s,q,de,"getVersion",[],e)]),ue=u;if(k!==t.schemaHash)throw new p("Hookr gate schema changed during the read.");if(a!==M||v!==q||H!==$||n(ce)!==400000n||n(ge)!==2000000n)throw new p("Hookr gate dependencies or gas limits differ from the reviewed profile.");let O=m=>{if(typeof m!="string"||!t.supportsAge&&new TextEncoder().encode(m).length>32)throw new p("Hookr registry version read is incomplete.");let l=ne([{type:"string"}],[m]),h=(l.length-2)/2;return E(t.supportsAge&&h>256?he([l.slice(0,514),ye(h,{size:32})]):l)},R,G;if(t.supportsAge){let[m,l,h]=await Promise.all([r("pins"),s.getCode({address:ie,blockNumber:e}),s.getCode({address:oe,blockNumber:e})]),y=S(m);for(let I of["identityCode","identityVersion","reputationCode","reputationVersion"])x(y[I]);if(!l||l==="0x"||!h||h==="0x")throw new p("Hookr registry runtime is unavailable.");R=E(l)!==y.identityCode||O(j)!==y.identityVersion,G=E(h)!==y.reputationCode||O(U)!==y.reputationVersion}else R=O(j)!==B.gateVersions.identity,G=O(U)!==B.gateVersions.reputation;let _=R||G,b=f(w),Y=T(pe,2),me=await Promise.all(c.map(async m=>{let[l,h]=T(await r("reviewerSet",[m]),2);if(!Array.isArray(l)||l.length===0||l.length>32||typeof h!="string")throw new p("Reviewer set is unregistered or unavailable. Supply an existing registered bytes32 set ID.");let y=l.map(I=>z(String(I)));if(y.some(I=>BigInt(I)===0n)||E(ne([{type:"address[]"},{type:"string"}],[y,h]))!==m.toLowerCase())throw new p("Hookr reviewer set does not match its registered ID.");return{id:m,clients:y,tag:h}})),fe=t.supportsAge?n(await r("ageOf",[o])).toString():null;return{address:t.address,listed:t.listed,warnings:d.warnings,age:fe,suspended:t.supportsAge?b:null,healthy:!b&&!_,healthyIdentityOnly:!b&&!R,healthyForScores:!b&&!_,retired:b,registryVersionDrift:_,schemaHash:k,admission:V(ue),identity:M,reputation:q,walletAgent:f(le),link:{linked:f(Y[0]),agentId:n(Y[1]).toString()},reviewerSets:me,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",...t.supportsAge?{minAge:"uint32"}:{}},defaults:{flags:"1",minScore:"0",tierScore:"0",tierPips:"0",reviewers:Ae,...t.supportsAge?{minAge:"0"}:{}},maxTierPips:"50000",minGas:"400000",maxGas:"2000000"}}async function Oe(s,e,o,c,g){if(BigInt(g)===0n)return{gated:!1,admissionRequiredForCollectOrRemove:!1};let{profile:i,warnings:d}=await L(s,e,g,{requireAdmission:!1}),[t,r,k]=await Promise.all([A(s,i.address,i.abi,"terms",[C,o],e),A(s,i.address,i.abi,"explainLiquidity",[C,o,c],e),A(s,i.address,i.abi,i.healthFunction,[],e)]),u=S(t),[w,a]=T(r,2);if(!f(u.bound)||u.launcher!==c)throw new p("Hookr gate is not bound to this family Launcher.");for(let[v,H]of[["flags",16],["minScore",32],["tierScore",32],["tierPips",24]])n(u[v],H);return x(u.reviewers),i.supportsAge&&n(u.minAge,32),{gated:!0,gate:i.address,warnings:d,suspended:i.supportsAge?f(k):null,terms:V(u),retired:f(k),liquidityEntryAllowed:f(w),entryReason:n(a,8).toString(),admissionRequiredForCollectOrRemove:!1}}function Re(s){return[{name:"hookr_agent_gate",inputSchema:{type:"object",additionalProperties:!1,properties:{...X,gate:{type:"string",description:"Optional checksummed gate address; defaults to the current gate."},poolId:{...F,description:"Optional pool ID as 0x plus 64 hex digits to read its frozen agent gate and terms."},reviewerSetIds:{type:"array",maxItems:8,uniqueItems:!0,items:F,description:"Up to eight distinct registered reviewer set IDs to read, each as 0x plus 64 hex digits."}}},execute:async(e,o)=>{if(J(e,["blockNumber","gate","poolId","reviewerSetIds"]),s.network==="testnet")throw new p("Hookr gate reads are configured only on mainnet, chain 4663.");let c=e.reviewerSetIds??[];if(!Array.isArray(c)||c.length>8)throw new p("Provide at most eight distinct reviewer set IDs.");let g=c.map(x);if(new Set(g).size!==g.length)throw new p("Provide distinct reviewer set IDs.");let i=s.clientFor(4663),d=await Q(i,N(e)),t=e.gate===void 0?te:P(e.gate),r=null;if(e.poolId!==void 0){let w=S(await A(i,C,Z("rootV1"),"poolConfig",[x(e.poolId)],d.number)),a=P(w.advisory);if(BigInt(a)===0n)throw new p("Hookr pool is unknown or has no agent gate.");if(e.gate!==void 0&&t!==a)throw new p("The supplied gate does not match the pool advisory at this block.");t=a,r=w}let k=r?await se(i,d.number,o,x(e.poolId),t,r,g):await ke(i,d.number,o,g,t,!1),u=null;if(r){let w=re(t,k.schemaHash),a=S(await A(i,t,w.abi,"terms",[C,x(e.poolId)],d.number));f(a.bound),P(a.launcher),P(a.curatedRouter),x(a.reviewers);for(let[v,H]of[["flags",16],["minScore",32],["tierScore",32],["tierPips",24]])n(a[v],H);w.supportsAge&&n(a.minAge,32),u=V(a)}return await W(i,d),{chainId:4663,blockNumber:d.number.toString(),blockHash:d.hash,timestamp:d.timestamp.toString(),...k,poolTerms:u}}}]}export{ae as a,Ce as b,ke as c,Oe as d,Re as e};
@@ -1 +1 @@
1
- import{c as A,d as M,m as $}from"./KB2JWQZ4.js";import{f as C,g as H}from"./QP2B7AYX.js";import{d as m,e as s,z as k}from"./5677LZOV.js";import{g as b}from"./NWNYJ26T.js";import{b as x}from"./EWZFZUVF.js";import{a as e}from"./XSD5NL7J.js";import{decodeFunctionData as v,encodeFunctionData as B,erc20Abi as q,getAddress as F}from"viem";function Q(u){return{tools:[{name:"uniswap_swap_batch",inputSchema:{type:"object",additionalProperties:!1,required:["routes"],properties:{routes:{description:"One to twenty complete uniswap_swap argument objects, each with its own minAmountOut or maxAmountIn bound.",type:"array",minItems:1,maxItems:20,items:{type:"object",description:"Complete uniswap_swap arguments, including an absolute minAmountOut or maxAmountIn."}}}},async execute(n,y){if(H(n,["routes"]),!Array.isArray(n.routes)||n.routes.length<1||n.routes.length>20)throw new e("Provide 1 to 20 explicit bounded Uniswap routes.");let p=[],I=[],l=new Map,i="0x",E=0n,a,w=[],P=new Set;for(let t of n.routes){if(!t||typeof t!="object"||Array.isArray(t))throw new e("Each route must contain uniswap_swap arguments.");let c=await $(u,t,y,!1);if(!("txs"in c))throw new e("Route did not build swap transactions.");p.push(...c.warnings??[]),I.push(...c.confirmationWarnings??[]);let R=c.txs;for(let r of R.slice(0,-1))if(b(r.to,m)){let[o,N,O,U]=v({abi:M,data:r.data}).args;if(N!==s)throw new e("Unexpected route approval spender.");let _=o.toLowerCase(),d=l.get(_),j=(d?.amount??0n)+O;if(j>=1n<<160n)throw new e("Combined input approvals exceed uint160.");l.set(_,{token:o,amount:j,expiration:d&&d.expiration<BigInt(U)?d.expiration:BigInt(U)})}else{let o=v({abi:q,data:r.data});if(o.functionName!=="approve"||!b(o.args[0],m))throw new e("Unexpected route prerequisite.")}let g=R.at(-1);if(g.to!==s)throw new e("Route does not use the pinned Universal Router.");E+=BigInt(g.value);let[D,h,S]=v({abi:A,data:g.data}).args,T=D.slice(2).match(/../g)??[];if(T.length!==h.length)throw new e("Unexpected route command/parameter count.");T.forEach((r,o)=>{r==="04"?P.add(h[o]):(i=`${i}${r}`,w.push(h[o]))}),a=a===void 0||S<a?S:a}for(let t of P)i=`${i}04`,w.push(t);let f=[];for(let t of l.values())f.push(u.approval(F(t.token),m,t.amount.toString(),x),k(t.token,s,t.amount.toString(),t.expiration.toString()));return f.push(u.unsignedTx({to:s,data:B({abi:A,functionName:"execute",args:[i,w,a]}),value:E.toString(),chainId:x,description:`Atomically execute ${n.routes.length} caller-selected v2/v3/v4 routes, preserving each route's trade bound.`})),{...await C(u,f,y,`${p.join(" ")}${p.length?" ":""}Explicit mixed-version/split routes; every route must meet its own bound. No automatic best-route search or allow-revert branch. The wallet must fund each independently previewed route.`),warnings:p,confirmationWarnings:I}}}]}}export{Q as a};
1
+ import{c as A,d as M,m as $}from"./WADRRW3E.js";import{f as C,g as H}from"./PX2G2H6G.js";import{d as m,e as s,z as k}from"./2ZYFBBOE.js";import{g as b}from"./NWNYJ26T.js";import{b as x}from"./EWZFZUVF.js";import{a as e}from"./XSD5NL7J.js";import{decodeFunctionData as v,encodeFunctionData as B,erc20Abi as q,getAddress as F}from"viem";function Q(u){return{tools:[{name:"uniswap_swap_batch",inputSchema:{type:"object",additionalProperties:!1,required:["routes"],properties:{routes:{description:"One to twenty complete uniswap_swap argument objects, each with its own minAmountOut or maxAmountIn bound.",type:"array",minItems:1,maxItems:20,items:{type:"object",description:"Complete uniswap_swap arguments, including an absolute minAmountOut or maxAmountIn."}}}},async execute(n,y){if(H(n,["routes"]),!Array.isArray(n.routes)||n.routes.length<1||n.routes.length>20)throw new e("Provide 1 to 20 explicit bounded Uniswap routes.");let p=[],I=[],l=new Map,i="0x",E=0n,a,w=[],P=new Set;for(let t of n.routes){if(!t||typeof t!="object"||Array.isArray(t))throw new e("Each route must contain uniswap_swap arguments.");let c=await $(u,t,y,!1);if(!("txs"in c))throw new e("Route did not build swap transactions.");p.push(...c.warnings??[]),I.push(...c.confirmationWarnings??[]);let R=c.txs;for(let r of R.slice(0,-1))if(b(r.to,m)){let[o,N,O,U]=v({abi:M,data:r.data}).args;if(N!==s)throw new e("Unexpected route approval spender.");let _=o.toLowerCase(),d=l.get(_),j=(d?.amount??0n)+O;if(j>=1n<<160n)throw new e("Combined input approvals exceed uint160.");l.set(_,{token:o,amount:j,expiration:d&&d.expiration<BigInt(U)?d.expiration:BigInt(U)})}else{let o=v({abi:q,data:r.data});if(o.functionName!=="approve"||!b(o.args[0],m))throw new e("Unexpected route prerequisite.")}let g=R.at(-1);if(g.to!==s)throw new e("Route does not use the pinned Universal Router.");E+=BigInt(g.value);let[D,h,S]=v({abi:A,data:g.data}).args,T=D.slice(2).match(/../g)??[];if(T.length!==h.length)throw new e("Unexpected route command/parameter count.");T.forEach((r,o)=>{r==="04"?P.add(h[o]):(i=`${i}${r}`,w.push(h[o]))}),a=a===void 0||S<a?S:a}for(let t of P)i=`${i}04`,w.push(t);let f=[];for(let t of l.values())f.push(u.approval(F(t.token),m,t.amount.toString(),x),k(t.token,s,t.amount.toString(),t.expiration.toString()));return f.push(u.unsignedTx({to:s,data:B({abi:A,functionName:"execute",args:[i,w,a]}),value:E.toString(),chainId:x,description:`Atomically execute ${n.routes.length} caller-selected v2/v3/v4 routes, preserving each route's trade bound.`})),{...await C(u,f,y,`${p.join(" ")}${p.length?" ":""}Explicit mixed-version/split routes; every route must meet its own bound. No automatic best-route search or allow-revert branch. The wallet must fund each independently previewed route.`),warnings:p,confirmationWarnings:I}}}]}}export{Q as a};
@@ -1 +1 @@
1
- import{e as h,i as y}from"./5DWQUEBA.js";import{b as l,e as f,g as v}from"./QP2B7AYX.js";import{c as p}from"./NWNYJ26T.js";import{b as g}from"./EWZFZUVF.js";import{a as r}from"./XSD5NL7J.js";import{parseAbi as C,zeroAddress as I}from"viem";var N=C(["function observe(uint32[] secondsAgos) view returns (int56[] tickCumulatives,uint160[] secondsPerLiquidityCumulativeX128s)"]);function B(s){return{tools:[{name:"uniswap_oracle",inputSchema:{type:"object",additionalProperties:!1,required:["token0","token1","fee","secondsAgo"],properties:{token0:{...p,description:"Lower sorted ERC-20 token address; use WETH for native ETH in v3."},token1:{...p,description:"Higher sorted ERC-20 token address."},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"integer",minimum:0,maximum:999999},secondsAgo:{description:"Oracle lookback duration in seconds; a positive integer.",type:"integer",minimum:1,maximum:4294967295}}},async execute(t){v(t,["token0","token1","fee","secondsAgo"]);let a=l(t.token0),c=l(t.token1),o=t.fee,e=t.secondsAgo;if(BigInt(a)>=BigInt(c))throw new r("Oracle tokens must be strictly sorted token0 < token1.");if(typeof o!="number"||!Number.isInteger(o)||o<0||o>=1e6||typeof e!="number"||!Number.isInteger(e)||e<=0||e>4294967295)throw new r("Provide integer fee pips and a positive uint32 secondsAgo.");let d=s.clientFor(g),i=await d.getBlockNumber(),m=await d.readContract({address:h.factory,abi:y,functionName:"getPool",args:[a,c,o],blockNumber:i});if(m===I)throw new r("No factory-verified v3 pool exists for this oracle.");let[[n,k],w,A]=await Promise.all([d.readContract({address:m,abi:N,functionName:"observe",args:[[e,0]],blockNumber:i}),f(s,a,i),f(s,c,i)]);if(n.length!==2||k.length!==2)throw new r("Oracle returned an unexpected observation count.");let u=n[1]-n[0],b=BigInt(e),P=u/b-(u<0n&&u%b!==0n?1n:0n);return{pool:m,token0:w,token1:A,secondsAgo:e,blockNumber:i.toString(),tickCumulatives:n.map(String),secondsPerLiquidityCumulativeX128s:k.map(String),arithmeticMeanTick:P.toString(),summary:"V3 time-weighted arithmetic mean tick, rounded toward negative infinity. Price is token1-base-units per token0-base-unit before decimal adjustment. Insufficient pool history reverts; an unavailable oracle is never reported as zero."}}}]}}export{B as a};
1
+ import{e as h,i as y}from"./4JU23O3Z.js";import{b as l,e as f,g as v}from"./PX2G2H6G.js";import{c as p}from"./NWNYJ26T.js";import{b as g}from"./EWZFZUVF.js";import{a as r}from"./XSD5NL7J.js";import{parseAbi as C,zeroAddress as I}from"viem";var N=C(["function observe(uint32[] secondsAgos) view returns (int56[] tickCumulatives,uint160[] secondsPerLiquidityCumulativeX128s)"]);function B(s){return{tools:[{name:"uniswap_oracle",inputSchema:{type:"object",additionalProperties:!1,required:["token0","token1","fee","secondsAgo"],properties:{token0:{...p,description:"Lower sorted ERC-20 token address; use WETH for native ETH in v3."},token1:{...p,description:"Higher sorted ERC-20 token address."},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"integer",minimum:0,maximum:999999},secondsAgo:{description:"Oracle lookback duration in seconds; a positive integer.",type:"integer",minimum:1,maximum:4294967295}}},async execute(t){v(t,["token0","token1","fee","secondsAgo"]);let a=l(t.token0),c=l(t.token1),o=t.fee,e=t.secondsAgo;if(BigInt(a)>=BigInt(c))throw new r("Oracle tokens must be strictly sorted token0 < token1.");if(typeof o!="number"||!Number.isInteger(o)||o<0||o>=1e6||typeof e!="number"||!Number.isInteger(e)||e<=0||e>4294967295)throw new r("Provide integer fee pips and a positive uint32 secondsAgo.");let d=s.clientFor(g),i=await d.getBlockNumber(),m=await d.readContract({address:h.factory,abi:y,functionName:"getPool",args:[a,c,o],blockNumber:i});if(m===I)throw new r("No factory-verified v3 pool exists for this oracle.");let[[n,k],w,A]=await Promise.all([d.readContract({address:m,abi:N,functionName:"observe",args:[[e,0]],blockNumber:i}),f(s,a,i),f(s,c,i)]);if(n.length!==2||k.length!==2)throw new r("Oracle returned an unexpected observation count.");let u=n[1]-n[0],b=BigInt(e),P=u/b-(u<0n&&u%b!==0n?1n:0n);return{pool:m,token0:w,token1:A,secondsAgo:e,blockNumber:i.toString(),tickCumulatives:n.map(String),secondsPerLiquidityCumulativeX128s:k.map(String),arithmeticMeanTick:P.toString(),summary:"V3 time-weighted arithmetic mean tick, rounded toward negative infinity. Price is token1-base-units per token0-base-unit before decimal adjustment. Insufficient pool history reverts; an unavailable oracle is never reported as zero."}}}]}}export{B as a};
@@ -1 +1 @@
1
- import{b as s}from"./4GAU3JLN.js";import{a as o,c as t}from"./BWE5PXRE.js";import{getAddress as i}from"viem";var f=new Set(["priors_status",...s,...t.filter(r=>r.read).map(r=>r.name),"priors_ethos_status","priors_request_borrow","priors_request_repay","priors_request_stock","priors_request_backing","priors_pt_quote","priors_pt_position","priors_stock_quote","priors_savings_liquidity","priors_market_origin","priors_market_pins","priors_capabilities"]),p=new Set(["priors_sign_consent",...t.filter(r=>r.consentRoot).map(r=>r.name)]),u=new Set([...p,"priors_starter_line"]),R=new Set([...t.filter(r=>!r.read).map(r=>r.name),"priors_root_offer","priors_autopay_on","priors_autopay_off","priors_pt_buy","priors_pt_sell","priors_pt_redeem","priors_savings_force_withdraw","priors_stock_swap","priors_market_clear_bid_budget","priors_market_revoke_nft","priors_x_link"]),S=["priors_lend","priors_withdraw","priors_borrow","priors_repay","priors_starter_line","priors_close_line","priors_release_bond"];function c(r){let _=t.find(e=>e.name===r);return _?[o[_.contract],..._.approval==="bid"?[o.bidSpender]:[]]:r==="priors_root_offer"?[o.pool]:r==="priors_autopay_on"||r==="priors_autopay_off"?[o.autopay]:r==="priors_savings_force_withdraw"?[o.savings]:r==="priors_stock_swap"?[i("0xCaf681a66D020601342297493863E78C959E5cb2"),i("0x7Cd4E04E433E69e588728c86A3832753B5F846d4")]:r==="priors_pt_buy"||r==="priors_pt_sell"||r==="priors_pt_redeem"?[i("0x888888888889758F76e7103c6CbF23ABbF58F946")]:r==="priors_market_clear_bid_budget"?[o.bidSpender]:r==="priors_market_revoke_nft"?[o.registry,"0x0000000000000000000000000000000000000000"]:r==="priors_x_link"?[o.registry]:[]}export{f as a,p as b,u as c,R as d,S as e,c as f};
1
+ import{b as s}from"./XD4JA43O.js";import{a as o,c as t}from"./BWE5PXRE.js";import{getAddress as i}from"viem";var f=new Set(["priors_status",...s,...t.filter(r=>r.read).map(r=>r.name),"priors_ethos_status","priors_request_borrow","priors_request_repay","priors_request_stock","priors_request_backing","priors_pt_quote","priors_pt_position","priors_stock_quote","priors_savings_liquidity","priors_market_origin","priors_market_pins","priors_capabilities"]),p=new Set(["priors_sign_consent",...t.filter(r=>r.consentRoot).map(r=>r.name)]),u=new Set([...p,"priors_starter_line"]),R=new Set([...t.filter(r=>!r.read).map(r=>r.name),"priors_root_offer","priors_autopay_on","priors_autopay_off","priors_pt_buy","priors_pt_sell","priors_pt_redeem","priors_savings_force_withdraw","priors_stock_swap","priors_market_clear_bid_budget","priors_market_revoke_nft","priors_x_link"]),S=["priors_lend","priors_withdraw","priors_borrow","priors_repay","priors_starter_line","priors_close_line","priors_release_bond"];function c(r){let _=t.find(e=>e.name===r);return _?[o[_.contract],..._.approval==="bid"?[o.bidSpender]:[]]:r==="priors_root_offer"?[o.pool]:r==="priors_autopay_on"||r==="priors_autopay_off"?[o.autopay]:r==="priors_savings_force_withdraw"?[o.savings]:r==="priors_stock_swap"?[i("0xCaf681a66D020601342297493863E78C959E5cb2"),i("0x7Cd4E04E433E69e588728c86A3832753B5F846d4")]:r==="priors_pt_buy"||r==="priors_pt_sell"||r==="priors_pt_redeem"?[i("0x888888888889758F76e7103c6CbF23ABbF58F946")]:r==="priors_market_clear_bid_budget"?[o.bidSpender]:r==="priors_market_revoke_nft"?[o.registry,"0x0000000000000000000000000000000000000000"]:r==="priors_x_link"?[o.registry]:[]}export{f as a,p as b,u as c,R as d,S as e,c as f};
@@ -1 +1 @@
1
- import{a as O,e as se,h as ae,i as oe,k as de}from"./KHOUBQJK.js";import{m as ie}from"./6STUQOFL.js";import{c as N,d as Y,e as J,f as Z,g as ee,h as te,j as ne}from"./GV6Z3MET.js";import{a as re}from"./4P6DRKY3.js";import{b as ce,e as U,r as ue}from"./5PNFV7HH.js";import{a as g,b as C}from"./7WXAS54T.js";import{a as P}from"./LIUXNOLP.js";import{e as j,f as Q}from"./S65KXMZ7.js";import{f as V,l as z}from"./CW37EGPL.js";import{a as X,c as A}from"./CFPJDLTZ.js";import{a as D}from"./5N6YJFFA.js";import{a as F}from"./SPJCSEKP.js";import{b as $}from"./SCG5HWMN.js";import{b as E}from"./IX3GZMTM.js";import{t as T}from"./EZUQMTLE.js";import{b as m,c as l,d as q,e as v,j as h,k as W,l as B,q as K}from"./EWZFZUVF.js";import{a as c}from"./XSD5NL7J.js";import{a as x,b as G}from"./JXOEJPJ4.js";import{getAddress as p,isAddress as le,parseAbi as ye,zeroAddress as fe}from"viem";var me=[{inputs:[],name:"available",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"ethUsdE18",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"liquidityUsdgE6",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"phase",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"priceSigner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"signer",type:"address"}],name:"setPriceSigner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"spotOakPerEthE18",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"supplyNet",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"syncPhase",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"wallet",type:"address"},{internalType:"uint256",name:"oakPerEthE18",type:"uint256"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"bytes32",name:"nonce",type:"bytes32"}],internalType:"struct PriceNote",name:"n",type:"tuple"},{internalType:"bytes",name:"sig",type:"bytes"},{internalType:"address",name:"boundWallet",type:"address"}],name:"verifyNote",outputs:[{internalType:"uint256",name:"oakPerEthE18",type:"uint256"}],stateMutability:"view",type:"function"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"signer",type:"address"}],name:"PriceSignerSet",type:"event"},{inputs:[],name:"NotReady",type:"error"},{inputs:[],name:"NoteBadSignature",type:"error"},{inputs:[],name:"NoteExpired",type:"error"},{inputs:[],name:"NoteNotYetValid",type:"error"},{inputs:[{internalType:"uint256",name:"spot",type:"uint256"},{internalType:"uint256",name:"note",type:"uint256"}],name:"NoteOutsideGuard",type:"error"},{inputs:[],name:"NoteWrongWallet",type:"error"},{inputs:[{internalType:"address",name:"source",type:"address"}],name:"OracleUnreadable",type:"error"}];function tt(n){return"source"in n&&n.source==="pool-spot-estimate"?void 0:n}var M=300,xe="1000000000000000000",we=p(h[m].tokens.USDG.address),ge=p(h[l].deployments.test_USDG.address),L=p(h[m].tokens.WETH.address),I=p(h[l].deployments.test_WETH.address),R=p(X.chop);function he(n){return n.chainId===m&&n.address.toLowerCase()===R.toLowerCase()}async function nt(n,e,t,o){let a=o?.find(b=>b.measuredAtBlock===t.toString()&&[b.log.address,b.staking.address].some(y=>y.toLowerCase()===n.address.toLowerCase())),i=n.address;try{a||(i=p(await V(e,n.address,"INDEX_FUND",[],t)))}catch{}let s=a??await z(e,i,"read",t);if(s.drift.length)throw new c("Chop code changed; share backing cannot be estimated.");let r=10n**BigInt(n.decimals),d=n.address.toLowerCase()===s.log.address.toLowerCase(),u=n.address.toLowerCase()===s.staking.address.toLowerCase();if(!d&&!u||n.chainId!==m||n.decimals!==(d?s.log.decimals:s.staking.decimals))throw new c("Chop share identity does not match the verified log.");let f=d?[(await j(e,s,fe,r,t)).net]:(await Q(e,s,fe,r,t)).assets;if(!f.length)throw new c("Chop LP reserves or net log backing could not be verified.");return{assets:f,isLog:d}}function Ee(n){let e=n.address.toLowerCase();return n.chainId===m?e===we.toLowerCase():n.chainId===l?e===ge.toLowerCase():!1}function Te(n){return n.chainId!==m&&n.chainId!==l?!1:C(n.address)===g}function Se(n){let e=n.address.toLowerCase();return n.chainId===m?e===L.toLowerCase():n.chainId===l?e===I.toLowerCase():!1}function ve(n){return Te(n)||Se(n)}var Pe=-887272,Ce=887272,De=(1n<<256n)-1n,Ae=ye(["function observe(uint32[] secondsAgos) view returns (int56[] tickCumulatives, uint160[] secondsPerLiquidityCumulativeX128s)","function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)"]),pe=ye(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Ne=1n<<192n;async function Oe(n,e){let t=p(A.stateView),o=A.poolId,[a,i]=await Promise.all([n.readContract({address:t,abi:pe,functionName:"getSlot0",args:[o],blockNumber:e}),n.readContract({address:t,abi:pe,functionName:"getLiquidity",args:[o],blockNumber:e})]),s=a[0],r=Number(a[1]);if(s<=0n||i<=0n||!Number.isInteger(r)||r<Pe||r>Ce)throw new c("The pinned Uniswap v4 WETH/CHOP pool has no active liquidity, and the only other route is a near-empty pool.");return{numerator:Ne,denominator:s*s}}function H(n,e){if(typeof n=="bigint")return n;if(typeof n=="number"){if(!Number.isSafeInteger(n))throw new c(`Invalid ${e} timestamp.`);return BigInt(n)}if(typeof n=="string"&&/^-?\d+$/.test(n.trim()))return BigInt(n.trim());throw new c(`Invalid ${e} timestamp.`)}function rt(n,e=BigInt(Math.floor(Date.now()/1e3)),t=M){try{return w(n,e,t),!0}catch{return!1}}function w(n,e=BigInt(Math.floor(Date.now()/1e3)),t=M){if(!Number.isInteger(t)||t<0)throw new c("Maximum price age must be a non-negative integer.");let o=H(n,"price"),a=H(e,"current");if(o<=0n)throw new c("Price timestamp must be positive.");if(o>a)throw new c("Price timestamp is in the future.");let i=a-o;if(i>BigInt(t))throw new c(`Price is stale: age ${i}s exceeds ${t}s.`);return o.toString()}function Ue(n){if(!Number.isInteger(n)||n<Pe||n>Ce)throw new c(`Tick ${n} is outside valid Uniswap bounds.`);let e=BigInt(n<0?-n:n),t=(e&0x1n)!==0n?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;return(e&0x2n)!==0n&&(t=t*0xfff97272373d413259a46990580e213an>>128n),(e&0x4n)!==0n&&(t=t*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(e&0x8n)!==0n&&(t=t*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(e&0x10n)!==0n&&(t=t*0xffcb9843d60f6159c9db58835c926644n>>128n),(e&0x20n)!==0n&&(t=t*0xff973b41fa98c081472e6896dfb254c0n>>128n),(e&0x40n)!==0n&&(t=t*0xff2ea16466c96a3843ec78b326b52861n>>128n),(e&0x80n)!==0n&&(t=t*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(e&0x100n)!==0n&&(t=t*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(e&0x200n)!==0n&&(t=t*0xf987a7253ac413176f2b074cf7815e54n>>128n),(e&0x400n)!==0n&&(t=t*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(e&0x800n)!==0n&&(t=t*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(e&0x1000n)!==0n&&(t=t*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(e&0x2000n)!==0n&&(t=t*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(e&0x4000n)!==0n&&(t=t*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(e&0x8000n)!==0n&&(t=t*0x31be135f97d08fd981231505542fcfa6n>>128n),(e&0x10000n)!==0n&&(t=t*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(e&0x20000n)!==0n&&(t=t*0x5d6af8dedb81196699c329225ee604n>>128n),(e&0x40000n)!==0n&&(t=t*0x2216e584f5fa1ea926041bedfe98n>>128n),(e&0x80000n)!==0n&&(t=t*0x48a170391f7dc42444e8fa2n>>128n),n>0&&(t=De/t),(t>>32n)+(t%(1n<<32n)===0n?0n:1n)}async function be(n,e,t,o){let a=async()=>{throw new c("Price identity resolution is read-only.")},i=F({network:e===l?"testnet":"mainnet",clientFor:r=>t.client??T(t.rpcUrl,r),http:t.http??$(),preview:a,quoteSwap:a,buildSwap:a}),s=await ue(n,{context:i,oakTokenAddress:t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS,officialStockTokens:t.officialStockTokens,tokenMetadata:o,blockNumber:t.blockNumber,readMetadata:async r=>{let d=t.client??T(t.rpcUrl,e),[u,f]=await Promise.all([D(d,e,r,"symbol",t.blockNumber),D(d,e,r,"decimals",t.blockNumber)]);return{address:r,symbol:u,decimals:f,chainId:e}}});return{address:s.address,symbol:s.kind==="erc20"&&o?o.symbol:s.symbol,decimals:s.decimals,chainId:s.chainId}}async function _e(n,e,t){if(typeof n=="object"&&n!==null){let r=n.chainId??e,d=C(n.address)===g?g:p(n.address),u={address:d,symbol:n.symbol,decimals:n.decimals,chainId:r};return Ee(u)?{address:d,symbol:"USDG",decimals:v,chainId:r}:Te(u)?{address:g,symbol:"ETH",decimals:18,chainId:r}:Se(u)?{address:d,symbol:"WETH",decimals:18,chainId:r}:he(u)?{address:d,symbol:"CHOP",decimals:18,chainId:r}:be(u.address,r,t,u)}let o=n.trim(),a=o.toUpperCase(),i=o.toLowerCase();if(a==="ETH"||le(o,{strict:!1})&&C(o)===g)return{...ce,chainId:e};if(a==="WETH"||e===m&&i===L.toLowerCase()||e===l&&i===I.toLowerCase()){if(e!==m&&e!==l)throw new c(`No canonical WETH address configured for chain ${e}.`);return{address:e===l?I:L,symbol:"WETH",decimals:18,chainId:e}}if(a==="USDG"||e===m&&i===W.toLowerCase()||e===l&&i===B.toLowerCase()){if(e!==m&&e!==l)throw new c(`No canonical USDG address configured for chain ${e}.`);return{address:e===l?ge:we,symbol:"USDG",decimals:v,chainId:e}}if(e===m&&(a==="USDE"||i===U.address.toLowerCase()))return{...U,chainId:e};if(e===m&&(a==="CHOP"||i===R.toLowerCase()))return{address:R,symbol:"CHOP",decimals:18,chainId:e};let s=t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS;if(a==="OAK"||s&&o.toLowerCase()===s.toLowerCase()){if(!s&&!le(o,{strict:!1}))throw new c("OAK token address is required to price OAK.");return{address:p(s??o),symbol:"OAK",decimals:q,chainId:e}}return be(n,e,t)}async function k(n,e,t){if(e)return(await n.readContract({address:e,abi:me,functionName:"ethUsdE18",blockNumber:t})).toString();let a=(await n.readContract({address:p(K),abi:Ae,functionName:"observe",args:[[O,0]],blockNumber:t}))[0];if(!a||a.length<2)throw new c("ETH/USDG pool observation returned insufficient tick cumulatives.");let i=ae(a[0],a[1],O),s=Ue(i);return oe(s)}async function S(n,e,t,o){if(n.timestamp!==void 0)return w(n.timestamp,t(),o);if(e&&typeof e.getBlock=="function"){let i=await P(e,n.blockNumber);return w(i.timestamp,t(),o)}let a=t();return w(a,a,o)}function _(n){if(n.startsWith("untrusted "))try{let e=JSON.parse(n.slice(10));if(typeof e=="string"&&x(e)===n)return n}catch{}return x(n)}async function it(n,e={}){let t=e.chainId??m,o=e.maxAgeSeconds??M,a=()=>e.now!==void 0?H(e.now,"current"):BigInt(Math.floor(Date.now()/1e3)),i=await _e(n,t,e);if((G(i.symbol)||i.symbol.length>256)&&(i.symbol=_(i.symbol)),e.trades){let r=await S(e,e.client,a,o),d=de(e.trades,{now:a(),windowStart:e.windowStart,windowEnd:e.windowEnd});if(e.spotOakPerEthE18!==void 0&&!ie(d,e.spotOakPerEthE18))throw new c("30-minute average is outside the 50% spot guard band.");let u=e.ethUsdE18!==void 0?e.ethUsdE18.toString():await k(e.client??T(e.rpcUrl,t),e.oracleAddress);return{token:i,usdE18:se(u,d),timestamp:r}}if(e.usdE18!==void 0){let r=await S(e,e.client,a,o),d=E(e.usdE18.toString());if(d<=0n)throw new c("USD price must be positive.");return{token:i,usdE18:d.toString(),timestamp:r}}if(e.resolver){let r=await e.resolver(i),d=w(r.timestamp,a(),o),u=E(r.usdE18);if(u<=0n)throw new c("USD price must be positive.");return{token:i,usdE18:u.toString(),timestamp:d,...r.source==="pool-spot-estimate"?{source:r.source,sourceLabel:N}:{}}}let s=e.client??T(e.rpcUrl,t);if(Ee(i)){let r=await S(e,s,a,o);return{token:i,usdE18:xe,timestamp:r}}if(ve(i)){let r=await S(e,s,a,o),d=await k(s,e.oracleAddress,e.blockNumber);return{token:i,usdE18:d,timestamp:r}}if(he(i)){let r=e.timestamp===void 0&&s&&typeof s.getBlock=="function"?await P(s,e.blockNumber):void 0,d=r?w(r.timestamp,a(),o):await S(e,s,a,o);if(r&&r.number===null)throw new c("CHOP reference requires a mined block.");let u=r?.number??e.blockNumber,[f,b]=await Promise.all([Oe(s,u),e.ethUsdE18!==void 0?Promise.resolve(e.ethUsdE18.toString()):k(s,e.oracleAddress,u)]),y=E(b)*f.numerator/f.denominator;if(y<=0n)throw new c("CHOP USD reference price must be positive.");return{token:i,usdE18:y.toString(),timestamp:d}}if(i.chainId===m)try{let r=await P(s,e.blockNumber),d=w(r.timestamp,a(),o);if(r.number===null)throw new c("Pons reference requires a mined block.");let u=await ne(i,s,r.number);if(u!==void 0&&u>0n)return{token:i,usdE18:u.toString(),timestamp:d,source:"pool-spot-estimate",sourceLabel:N};let[f,b]=await Promise.all([re(i,s,r.number),k(s,e.oracleAddress,r.number)]),y=E(b)*f.numerator/f.denominator;if(y<=0n)throw new c("Pons USD reference price must be positive.");return{token:i,usdE18:y.toString(),timestamp:d}}catch(r){let d=Y(i),u=r instanceof J?Z(r.symbol,r.gap):te(r)?ee:void 0;if(u)throw new c(`Price unavailable for now for ${d?.symbol??_(i.symbol)}: ${u}. Oak has no fresh on-chain trade price for it, so it shows no price.`)}throw new c(`Oak has no fresh on-chain trade price for ${_(i.symbol)}, so it shows no price. balances and positions show a labeled estimate where one exists; an estimate is not a quote.`)}export{tt as a,M as b,xe as c,he as d,nt as e,Ee as f,Te as g,Se as h,ve as i,Oe as j,rt as k,w as l,Ue as m,k as n,it as o};
1
+ import{a as O,e as se,h as ae,i as oe,k as de}from"./KHOUBQJK.js";import{m as ie}from"./6STUQOFL.js";import{c as N,d as Y,e as J,f as Z,g as ee,h as te,j as ne}from"./GV6Z3MET.js";import{a as re}from"./4P6DRKY3.js";import{b as ce,e as U,r as ue}from"./GV6FZ6UG.js";import{a as g,b as C}from"./7WXAS54T.js";import{a as P}from"./LIUXNOLP.js";import{e as j,f as Q}from"./S65KXMZ7.js";import{f as V,l as z}from"./CW37EGPL.js";import{a as X,c as A}from"./CFPJDLTZ.js";import{a as D}from"./5N6YJFFA.js";import{a as F}from"./SPJCSEKP.js";import{b as $}from"./SCG5HWMN.js";import{b as E}from"./IX3GZMTM.js";import{t as T}from"./EZUQMTLE.js";import{b as m,c as l,d as q,e as v,j as h,k as W,l as B,q as K}from"./EWZFZUVF.js";import{a as c}from"./XSD5NL7J.js";import{a as x,b as G}from"./JXOEJPJ4.js";import{getAddress as p,isAddress as le,parseAbi as ye,zeroAddress as fe}from"viem";var me=[{inputs:[],name:"available",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"ethUsdE18",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"liquidityUsdgE6",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"phase",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"priceSigner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"signer",type:"address"}],name:"setPriceSigner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"spotOakPerEthE18",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"supplyNet",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"syncPhase",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"wallet",type:"address"},{internalType:"uint256",name:"oakPerEthE18",type:"uint256"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"bytes32",name:"nonce",type:"bytes32"}],internalType:"struct PriceNote",name:"n",type:"tuple"},{internalType:"bytes",name:"sig",type:"bytes"},{internalType:"address",name:"boundWallet",type:"address"}],name:"verifyNote",outputs:[{internalType:"uint256",name:"oakPerEthE18",type:"uint256"}],stateMutability:"view",type:"function"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"signer",type:"address"}],name:"PriceSignerSet",type:"event"},{inputs:[],name:"NotReady",type:"error"},{inputs:[],name:"NoteBadSignature",type:"error"},{inputs:[],name:"NoteExpired",type:"error"},{inputs:[],name:"NoteNotYetValid",type:"error"},{inputs:[{internalType:"uint256",name:"spot",type:"uint256"},{internalType:"uint256",name:"note",type:"uint256"}],name:"NoteOutsideGuard",type:"error"},{inputs:[],name:"NoteWrongWallet",type:"error"},{inputs:[{internalType:"address",name:"source",type:"address"}],name:"OracleUnreadable",type:"error"}];function tt(n){return"source"in n&&n.source==="pool-spot-estimate"?void 0:n}var M=300,xe="1000000000000000000",we=p(h[m].tokens.USDG.address),ge=p(h[l].deployments.test_USDG.address),L=p(h[m].tokens.WETH.address),I=p(h[l].deployments.test_WETH.address),R=p(X.chop);function he(n){return n.chainId===m&&n.address.toLowerCase()===R.toLowerCase()}async function nt(n,e,t,o){let a=o?.find(b=>b.measuredAtBlock===t.toString()&&[b.log.address,b.staking.address].some(y=>y.toLowerCase()===n.address.toLowerCase())),i=n.address;try{a||(i=p(await V(e,n.address,"INDEX_FUND",[],t)))}catch{}let s=a??await z(e,i,"read",t);if(s.drift.length)throw new c("Chop code changed; share backing cannot be estimated.");let r=10n**BigInt(n.decimals),d=n.address.toLowerCase()===s.log.address.toLowerCase(),u=n.address.toLowerCase()===s.staking.address.toLowerCase();if(!d&&!u||n.chainId!==m||n.decimals!==(d?s.log.decimals:s.staking.decimals))throw new c("Chop share identity does not match the verified log.");let f=d?[(await j(e,s,fe,r,t)).net]:(await Q(e,s,fe,r,t)).assets;if(!f.length)throw new c("Chop LP reserves or net log backing could not be verified.");return{assets:f,isLog:d}}function Ee(n){let e=n.address.toLowerCase();return n.chainId===m?e===we.toLowerCase():n.chainId===l?e===ge.toLowerCase():!1}function Te(n){return n.chainId!==m&&n.chainId!==l?!1:C(n.address)===g}function Se(n){let e=n.address.toLowerCase();return n.chainId===m?e===L.toLowerCase():n.chainId===l?e===I.toLowerCase():!1}function ve(n){return Te(n)||Se(n)}var Pe=-887272,Ce=887272,De=(1n<<256n)-1n,Ae=ye(["function observe(uint32[] secondsAgos) view returns (int56[] tickCumulatives, uint160[] secondsPerLiquidityCumulativeX128s)","function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)"]),pe=ye(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Ne=1n<<192n;async function Oe(n,e){let t=p(A.stateView),o=A.poolId,[a,i]=await Promise.all([n.readContract({address:t,abi:pe,functionName:"getSlot0",args:[o],blockNumber:e}),n.readContract({address:t,abi:pe,functionName:"getLiquidity",args:[o],blockNumber:e})]),s=a[0],r=Number(a[1]);if(s<=0n||i<=0n||!Number.isInteger(r)||r<Pe||r>Ce)throw new c("The pinned Uniswap v4 WETH/CHOP pool has no active liquidity, and the only other route is a near-empty pool.");return{numerator:Ne,denominator:s*s}}function H(n,e){if(typeof n=="bigint")return n;if(typeof n=="number"){if(!Number.isSafeInteger(n))throw new c(`Invalid ${e} timestamp.`);return BigInt(n)}if(typeof n=="string"&&/^-?\d+$/.test(n.trim()))return BigInt(n.trim());throw new c(`Invalid ${e} timestamp.`)}function rt(n,e=BigInt(Math.floor(Date.now()/1e3)),t=M){try{return w(n,e,t),!0}catch{return!1}}function w(n,e=BigInt(Math.floor(Date.now()/1e3)),t=M){if(!Number.isInteger(t)||t<0)throw new c("Maximum price age must be a non-negative integer.");let o=H(n,"price"),a=H(e,"current");if(o<=0n)throw new c("Price timestamp must be positive.");if(o>a)throw new c("Price timestamp is in the future.");let i=a-o;if(i>BigInt(t))throw new c(`Price is stale: age ${i}s exceeds ${t}s.`);return o.toString()}function Ue(n){if(!Number.isInteger(n)||n<Pe||n>Ce)throw new c(`Tick ${n} is outside valid Uniswap bounds.`);let e=BigInt(n<0?-n:n),t=(e&0x1n)!==0n?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;return(e&0x2n)!==0n&&(t=t*0xfff97272373d413259a46990580e213an>>128n),(e&0x4n)!==0n&&(t=t*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(e&0x8n)!==0n&&(t=t*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(e&0x10n)!==0n&&(t=t*0xffcb9843d60f6159c9db58835c926644n>>128n),(e&0x20n)!==0n&&(t=t*0xff973b41fa98c081472e6896dfb254c0n>>128n),(e&0x40n)!==0n&&(t=t*0xff2ea16466c96a3843ec78b326b52861n>>128n),(e&0x80n)!==0n&&(t=t*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(e&0x100n)!==0n&&(t=t*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(e&0x200n)!==0n&&(t=t*0xf987a7253ac413176f2b074cf7815e54n>>128n),(e&0x400n)!==0n&&(t=t*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(e&0x800n)!==0n&&(t=t*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(e&0x1000n)!==0n&&(t=t*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(e&0x2000n)!==0n&&(t=t*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(e&0x4000n)!==0n&&(t=t*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(e&0x8000n)!==0n&&(t=t*0x31be135f97d08fd981231505542fcfa6n>>128n),(e&0x10000n)!==0n&&(t=t*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(e&0x20000n)!==0n&&(t=t*0x5d6af8dedb81196699c329225ee604n>>128n),(e&0x40000n)!==0n&&(t=t*0x2216e584f5fa1ea926041bedfe98n>>128n),(e&0x80000n)!==0n&&(t=t*0x48a170391f7dc42444e8fa2n>>128n),n>0&&(t=De/t),(t>>32n)+(t%(1n<<32n)===0n?0n:1n)}async function be(n,e,t,o){let a=async()=>{throw new c("Price identity resolution is read-only.")},i=F({network:e===l?"testnet":"mainnet",clientFor:r=>t.client??T(t.rpcUrl,r),http:t.http??$(),preview:a,quoteSwap:a,buildSwap:a}),s=await ue(n,{context:i,oakTokenAddress:t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS,officialStockTokens:t.officialStockTokens,tokenMetadata:o,blockNumber:t.blockNumber,readMetadata:async r=>{let d=t.client??T(t.rpcUrl,e),[u,f]=await Promise.all([D(d,e,r,"symbol",t.blockNumber),D(d,e,r,"decimals",t.blockNumber)]);return{address:r,symbol:u,decimals:f,chainId:e}}});return{address:s.address,symbol:s.kind==="erc20"&&o?o.symbol:s.symbol,decimals:s.decimals,chainId:s.chainId}}async function _e(n,e,t){if(typeof n=="object"&&n!==null){let r=n.chainId??e,d=C(n.address)===g?g:p(n.address),u={address:d,symbol:n.symbol,decimals:n.decimals,chainId:r};return Ee(u)?{address:d,symbol:"USDG",decimals:v,chainId:r}:Te(u)?{address:g,symbol:"ETH",decimals:18,chainId:r}:Se(u)?{address:d,symbol:"WETH",decimals:18,chainId:r}:he(u)?{address:d,symbol:"CHOP",decimals:18,chainId:r}:be(u.address,r,t,u)}let o=n.trim(),a=o.toUpperCase(),i=o.toLowerCase();if(a==="ETH"||le(o,{strict:!1})&&C(o)===g)return{...ce,chainId:e};if(a==="WETH"||e===m&&i===L.toLowerCase()||e===l&&i===I.toLowerCase()){if(e!==m&&e!==l)throw new c(`No canonical WETH address configured for chain ${e}.`);return{address:e===l?I:L,symbol:"WETH",decimals:18,chainId:e}}if(a==="USDG"||e===m&&i===W.toLowerCase()||e===l&&i===B.toLowerCase()){if(e!==m&&e!==l)throw new c(`No canonical USDG address configured for chain ${e}.`);return{address:e===l?ge:we,symbol:"USDG",decimals:v,chainId:e}}if(e===m&&(a==="USDE"||i===U.address.toLowerCase()))return{...U,chainId:e};if(e===m&&(a==="CHOP"||i===R.toLowerCase()))return{address:R,symbol:"CHOP",decimals:18,chainId:e};let s=t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS;if(a==="OAK"||s&&o.toLowerCase()===s.toLowerCase()){if(!s&&!le(o,{strict:!1}))throw new c("OAK token address is required to price OAK.");return{address:p(s??o),symbol:"OAK",decimals:q,chainId:e}}return be(n,e,t)}async function k(n,e,t){if(e)return(await n.readContract({address:e,abi:me,functionName:"ethUsdE18",blockNumber:t})).toString();let a=(await n.readContract({address:p(K),abi:Ae,functionName:"observe",args:[[O,0]],blockNumber:t}))[0];if(!a||a.length<2)throw new c("ETH/USDG pool observation returned insufficient tick cumulatives.");let i=ae(a[0],a[1],O),s=Ue(i);return oe(s)}async function S(n,e,t,o){if(n.timestamp!==void 0)return w(n.timestamp,t(),o);if(e&&typeof e.getBlock=="function"){let i=await P(e,n.blockNumber);return w(i.timestamp,t(),o)}let a=t();return w(a,a,o)}function _(n){if(n.startsWith("untrusted "))try{let e=JSON.parse(n.slice(10));if(typeof e=="string"&&x(e)===n)return n}catch{}return x(n)}async function it(n,e={}){let t=e.chainId??m,o=e.maxAgeSeconds??M,a=()=>e.now!==void 0?H(e.now,"current"):BigInt(Math.floor(Date.now()/1e3)),i=await _e(n,t,e);if((G(i.symbol)||i.symbol.length>256)&&(i.symbol=_(i.symbol)),e.trades){let r=await S(e,e.client,a,o),d=de(e.trades,{now:a(),windowStart:e.windowStart,windowEnd:e.windowEnd});if(e.spotOakPerEthE18!==void 0&&!ie(d,e.spotOakPerEthE18))throw new c("30-minute average is outside the 50% spot guard band.");let u=e.ethUsdE18!==void 0?e.ethUsdE18.toString():await k(e.client??T(e.rpcUrl,t),e.oracleAddress);return{token:i,usdE18:se(u,d),timestamp:r}}if(e.usdE18!==void 0){let r=await S(e,e.client,a,o),d=E(e.usdE18.toString());if(d<=0n)throw new c("USD price must be positive.");return{token:i,usdE18:d.toString(),timestamp:r}}if(e.resolver){let r=await e.resolver(i),d=w(r.timestamp,a(),o),u=E(r.usdE18);if(u<=0n)throw new c("USD price must be positive.");return{token:i,usdE18:u.toString(),timestamp:d,...r.source==="pool-spot-estimate"?{source:r.source,sourceLabel:N}:{}}}let s=e.client??T(e.rpcUrl,t);if(Ee(i)){let r=await S(e,s,a,o);return{token:i,usdE18:xe,timestamp:r}}if(ve(i)){let r=await S(e,s,a,o),d=await k(s,e.oracleAddress,e.blockNumber);return{token:i,usdE18:d,timestamp:r}}if(he(i)){let r=e.timestamp===void 0&&s&&typeof s.getBlock=="function"?await P(s,e.blockNumber):void 0,d=r?w(r.timestamp,a(),o):await S(e,s,a,o);if(r&&r.number===null)throw new c("CHOP reference requires a mined block.");let u=r?.number??e.blockNumber,[f,b]=await Promise.all([Oe(s,u),e.ethUsdE18!==void 0?Promise.resolve(e.ethUsdE18.toString()):k(s,e.oracleAddress,u)]),y=E(b)*f.numerator/f.denominator;if(y<=0n)throw new c("CHOP USD reference price must be positive.");return{token:i,usdE18:y.toString(),timestamp:d}}if(i.chainId===m)try{let r=await P(s,e.blockNumber),d=w(r.timestamp,a(),o);if(r.number===null)throw new c("Pons reference requires a mined block.");let u=await ne(i,s,r.number);if(u!==void 0&&u>0n)return{token:i,usdE18:u.toString(),timestamp:d,source:"pool-spot-estimate",sourceLabel:N};let[f,b]=await Promise.all([re(i,s,r.number),k(s,e.oracleAddress,r.number)]),y=E(b)*f.numerator/f.denominator;if(y<=0n)throw new c("Pons USD reference price must be positive.");return{token:i,usdE18:y.toString(),timestamp:d}}catch(r){let d=Y(i),u=r instanceof J?Z(r.symbol,r.gap):te(r)?ee:void 0;if(u)throw new c(`Price unavailable for now for ${d?.symbol??_(i.symbol)}: ${u}. Oak has no fresh on-chain trade price for it, so it shows no price.`)}throw new c(`Oak has no fresh on-chain trade price for ${_(i.symbol)}, so it shows no price. balances and positions show a labeled estimate where one exists; an estimate is not a quote.`)}export{tt as a,M as b,xe as c,he as d,nt as e,Ee as f,Te as g,Se as h,ve as i,Oe as j,rt as k,w as l,Ue as m,k as n,it as o};
@@ -1 +1 @@
1
- import{a as c,f as d,g as s}from"./QP2B7AYX.js";import{f as a}from"./5677LZOV.js";import{a as p}from"./66F5ZH34.js";import{b as i}from"./EWZFZUVF.js";import{a as e}from"./XSD5NL7J.js";import{encodeFunctionData as m,erc20Abi as h,parseAbi as E}from"viem";var w=E(["function deposit() payable","function withdraw(uint256)"]);function y(n){return{tools:[{name:"uniswap_wrap",inputSchema:{type:"object",additionalProperties:!1,required:["direction","amount"],properties:{direction:{description:'Choose "wrap" to exchange ETH for WETH, or "unwrap" to exchange WETH for ETH.',type:"string",enum:["wrap","unwrap"]},amount:p('Amount of ETH or WETH in base units (18 decimals). Example: "1000000000000000000" = 1 ETH or WETH.')}},async execute(t,u){if(s(t,["direction","amount"]),t.direction!=="wrap"&&t.direction!=="unwrap")throw new e("Choose direction wrap or unwrap.");let o=c(t.amount,"amount");if(t.direction==="unwrap"){let r=await n.clientFor(i).readContract({address:a,abi:h,functionName:"balanceOf",args:[u]});if(r===0n)throw new e("You have no WETH to unwrap. Wrap ETH or receive WETH first.");if(r<o)throw new e(`You do not have enough WETH to unwrap this amount. Request ${r} base units or less.`)}let f=t.direction==="wrap"?m({abi:w,functionName:"deposit"}):m({abi:w,functionName:"withdraw",args:[o]});return d(n,[n.unsignedTx({to:a,data:f,value:t.direction==="wrap"?o.toString():"0",chainId:i,description:`${t.direction} ${o} ETH/WETH base units to the signing wallet.`})],u,"Wrap or unwrap native ETH at the pinned WETH contract. Ratio 1:1; network gas is additional.")}}]}}export{w as a,y as b};
1
+ import{a as c,f as d,g as s}from"./PX2G2H6G.js";import{f as a}from"./2ZYFBBOE.js";import{a as p}from"./66F5ZH34.js";import{b as i}from"./EWZFZUVF.js";import{a as e}from"./XSD5NL7J.js";import{encodeFunctionData as m,erc20Abi as h,parseAbi as E}from"viem";var w=E(["function deposit() payable","function withdraw(uint256)"]);function y(n){return{tools:[{name:"uniswap_wrap",inputSchema:{type:"object",additionalProperties:!1,required:["direction","amount"],properties:{direction:{description:'Choose "wrap" to exchange ETH for WETH, or "unwrap" to exchange WETH for ETH.',type:"string",enum:["wrap","unwrap"]},amount:p('Amount of ETH or WETH in base units (18 decimals). Example: "1000000000000000000" = 1 ETH or WETH.')}},async execute(t,u){if(s(t,["direction","amount"]),t.direction!=="wrap"&&t.direction!=="unwrap")throw new e("Choose direction wrap or unwrap.");let o=c(t.amount,"amount");if(t.direction==="unwrap"){let r=await n.clientFor(i).readContract({address:a,abi:h,functionName:"balanceOf",args:[u]});if(r===0n)throw new e("You have no WETH to unwrap. Wrap ETH or receive WETH first.");if(r<o)throw new e(`You do not have enough WETH to unwrap this amount. Request ${r} base units or less.`)}let f=t.direction==="wrap"?m({abi:w,functionName:"deposit"}):m({abi:w,functionName:"withdraw",args:[o]});return d(n,[n.unsignedTx({to:a,data:f,value:t.direction==="wrap"?o.toString():"0",chainId:i,description:`${t.direction} ${o} ETH/WETH base units to the signing wallet.`})],u,"Wrap or unwrap native ETH at the pinned WETH contract. Ratio 1:1; network gas is additional.")}}]}}export{w as a,y as b};
@@ -1 +1 @@
1
- import{a as R}from"./G2LAO23N.js";import{C as X,H as Y,I as M,L as Z,a as g,z as C}from"./HRGLFGFL.js";import{a as B,g as E}from"./3RGED2KO.js";import{a as W}from"./66F5ZH34.js";import{f as J,g as D}from"./NWNYJ26T.js";import{b as Q,d as V}from"./IX3GZMTM.js";import{b as p}from"./EWZFZUVF.js";import{a as i}from"./XSD5NL7J.js";import{encodeFunctionData as ne,erc20Abi as ie,getAddress as w,parseAbi as re}from"viem";var ee=re(["function fill(uint256 orderId) returns (uint256)","function fillGasFloor(uint256 orderId) view returns (uint256)"]),N={type:"string",pattern:"^[1-9][0-9]*$"},oe={type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"Hookr v4 pool ID: 32 bytes, 0x followed by 64 hex digits."},te={type:"string",enum:["buy","sell"],description:R.enumValues({buy:"spend the pool quote token to receive the listed token",sell:"spend the listed token to receive the quote token"})},se={cursor:{...N,description:"Order ID to start from, scanning downward (newest first). Use nextCursor from the previous page; omit for the latest order."},limit:{type:"integer",minimum:1,maximum:32,description:"Maximum number of order IDs to scan in this page, 1 to 32. Default 16."}};function T(n,h){if(typeof n!="string"||!/^[1-9][0-9]*$/.test(n)||n.length>78||BigInt(n)>=1n<<256n)throw new i(`Provide ${h} as a positive decimal integer string.`);return BigInt(n)}function S(n){return J(n,"Hookr returned an invalid read response. Retry later.")}function H(n,h,e,o){return{name:n,inputSchema:{type:"object",description:`Read ${n.replace("hookr_","Hookr ")}. No signature or transaction.`,properties:h,required:e,additionalProperties:!1},execute:async(t,a)=>{if(Object.keys(t).some(d=>!Object.hasOwn(h,d))||e.some(d=>t[d]===void 0))throw new i(`Provide the documented arguments for ${n}.`);return o(t,a)}}}function $(n){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new i("Provide a 32-byte Hookr poolId.");return n}function F(n,h){let e=S(n),o=S(e.key);if(typeof o.fee!="number"||!Number.isInteger(o.fee)||o.fee<0||o.fee>16777215||typeof o.tickSpacing!="number"||!Number.isInteger(o.tickSpacing)||o.tickSpacing<=0||o.tickSpacing>8388607)throw new i("Hookr pool key is invalid.");let t={currency0:w(String(o.currency0)),currency1:w(String(o.currency1)),fee:o.fee,tickSpacing:o.tickSpacing,hooks:w(String(o.hooks))},a=h??$(e.poolId);if(BigInt(t.currency0)>=BigInt(t.currency1)||!D(X(t),a))throw new i("Hookr pool key does not match its PoolId.");let d=S(e.token),s=S(e.quote),u=r=>{let k=w(String(r.address));if(typeof r.symbol!="string"||!r.symbol.trim()||typeof r.decimals!="number"||!Number.isInteger(r.decimals)||r.decimals<0||r.decimals>255||![t.currency0,t.currency1].includes(k))throw new i("Hookr listed token metadata is invalid.");return{...r,address:k,chainId:p}},c=u(d),l=u(s);if(c.address===l.address)throw new i("Hookr listed token pair is invalid.");return{...e,poolId:a,key:t,token:c,quote:l}}var O=E;function be(n){let h=e=>H(e?"hookr_orders":"hookr_open_orders",se,[],async(o,t)=>{let a=o.limit??16;if(typeof a!="number"||!Number.isInteger(a)||a<1||a>32)throw new i("Hookr page limit must be an integer from 1 to 32.");let d=n.clientFor(p),s=await d.getBlock();if(typeof s.number!="bigint"||typeof s.timestamp!="bigint"||s.timestamp<=0n)throw new i("Hookr order reads need a valid chain block and timestamp.");let u=new Proxy(Z(d),{get(b,m,f){return m==="readContract"?y=>b.readContract({...y,blockNumber:s.number}):Reflect.get(b,m,f)}}),c={...n,clientFor:()=>u},l=await u.readContract({address:g,abi:C,functionName:"lastOrderId"});if(typeof l!="bigint"||l<0n)throw new i("Could not read the last Hookr order ID. Coverage is unknown.");let r=o.cursor===void 0?l:T(o.cursor,"cursor");if(r>l)throw new i("Hookr cursor exceeds the latest order ID. Restart pagination.");let k=[],x=new Map,A=r,I=r>BigInt(a)?r-BigInt(a):0n;for(;r>I;){let b=r--,m=Y(await u.readContract({address:g,abi:C,functionName:"getOrder",args:[b]}));if(Number(m.status)===0||BigInt(m.owner)===0n)throw new i(`Hookr order #${b} is missing. Coverage is unknown.`);if(e?!D(m.owner,t):Number(m.status)!==1)continue;let f=await M(c,b,{order:m,tokens:x});if(e){k.push(f);continue}let y=null,G=null,z=null,L=null,U=BigInt(f.expiry)<s.timestamp,j=f.fillable&&!U;if(j)try{let P=await u.readContract({address:g,abi:ee,functionName:"fillGasFloor",args:[BigInt(f.orderId)]}),_=await d.estimateGas({account:t,to:g,data:ne({abi:ee,functionName:"fill",args:[BigInt(f.orderId)]}),blockNumber:s.number}),v=await d.getGasPrice();if(typeof P!="bigint"||P<0n||typeof _!="bigint"||_<=0n||typeof v!="bigint"||v<0n)throw new Error("Invalid gas data");let K=(P*6n+4n)/5n,q=_>K?_:K;y=q.toString(),G=v.toString(),z=(q*v).toString(),L=(BigInt(f.bounty)-q*v).toString()}catch{}k.push({...f,fillable:j,expired:U,economics:{gasLimit:y,gasPrice:G,estimatedGasCost:z,bountyLessEstimatedGas:L,note:"Estimate only; excludes bounty claim gas and competition. Recheck the fill preview."}})}return{chainId:p,book:g,blockNumber:s.number.toString(),chainTime:s.timestamp.toString(),orders:k,scanned:{from:A.toString(),through:(r+1n).toString()},nextCursor:r>0n?r.toString():null,complete:r===0n}});return[h(!1),h(!0),H("hookr_order",{orderId:{...N,description:R.id("Hookr limit order")}},["orderId"],async e=>M(n,T(e.orderId,"orderId"))),H("hookr_pools",{sort:{type:"string",enum:["liquidity","volume","newest"],description:"Sort by USD liquidity, 24-hour volume, or opening block."},includeTests:{type:"boolean",description:"Include pools with test tickers."},agentsOnly:{type:"boolean",description:"Only pools with an agent gate."},token:{type:"string",description:R.address("listed token whose pools to return")},limit:{type:"integer",minimum:1,maximum:50,description:"Maximum number of pools to return, 1 to 50."},cursor:{type:"string",pattern:"^[0-9]{1,6}$",description:"Paging cursor: the nextCursor from the previous pools page; omit for the first page."}},[],async e=>{if(e.sort!==void 0&&!["liquidity","volume","newest"].includes(String(e.sort)))throw new i("Choose liquidity, volume or newest sorting.");for(let t of["includeTests","agentsOnly"])if(e[t]!==void 0&&typeof e[t]!="boolean")throw new i(`Provide ${t} as a boolean.`);if(e.token!==void 0)try{w(String(e.token))}catch{throw new i("Provide a valid token address.")}if(e.limit!==void 0&&(typeof e.limit!="number"||!Number.isInteger(e.limit)||e.limit<1||e.limit>50))throw new i("Pool page limit must be from 1 to 50.");if(e.cursor!==void 0&&(typeof e.cursor!="string"||!/^[0-9]{1,6}$/.test(e.cursor)))throw new i("Provide the pool nextCursor from the previous page.");let o=await O(n,"hookr_pools",e);if(!Array.isArray(o.pools))throw new i("Hookr pool coverage is unknown. Retry later.");return{...o,pools:o.pools.map(t=>F(t)),chainId:p,source:B}}),H("hookr_pool",{poolId:oe,side:te,amountIn:{...N,description:'Order input amount in base units of the input token (quote token for buy, listed token for sell); read its decimals. Example: "1000000". Give with side and minAmountOut.'},minAmountOut:{...N,description:'Minimum output in base units of the output token (listed token for buy, quote token for sell); read its decimals. Example: "1000000". Give with side and amountIn.'}},["poolId"],async e=>{let o=$(e.poolId),t=[e.side,e.amountIn,e.minAmountOut].some(y=>y!==void 0);if(t&&(e.side!=="buy"&&e.side!=="sell"||e.amountIn===void 0||e.minAmountOut===void 0))throw new i("Provide side, amountIn and minAmountOut together for order-specific bounty bounds.");let a=t?T(e.amountIn,"amountIn"):void 0,d=t?T(e.minAmountOut,"minAmountOut"):void 0;if(a!==void 0&&(a>=1n<<128n||d>=1n<<128n))throw new i("Hookr order amounts must fit uint128 base units.");let s=await O(n,"hookr_pool",{poolId:o}),u=s.listing?F(s.listing,o):void 0,c={...s,...u?{listing:u}:{},chainId:p,source:B};if(!t)return{...c,bountyBounds:{status:"requires-order-terms",note:"The keeper bounty floor depends on the order. Supply side, amountIn and minAmountOut in base units. The batch-1 0.0005 ETH observation is not a permanent floor."}};if(!u)throw new i("Hookr pool key is unavailable; bounty floor is unknown.");let l=u.key,r=S(e.side==="buy"?u.quote:u.token),k=w(String(r.address))===l.currency0,x=n.clientFor(p),A=await x.getBlock(),I=await x.readContract({address:g,abi:C,functionName:"bountyBounds",args:[l,k,a,d],blockNumber:A.number});if(!Array.isArray(I)||I.length!==3||I.some(y=>typeof y!="bigint"||y<0n||y>=1n<<128n))throw new i("Hookr bounty bounds are unavailable; the floor is unknown.");let[b,m,f]=I;return{...c,bountyBounds:{status:"available",blockNumber:A.number.toString(),token:{address:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",symbol:"ETH",decimals:18,chainId:p},minBounty:b.toString(),defaultBounty:m.toString(),maxBounty:f.toString(),effectiveFloor:(b>0n?b:m).toString(),note:"ETH wei for this order at this block. Oak create uses the positive minimum, or the default when minimum is zero; recheck at creation."}}}),H("hookr_quote",{poolId:oe,side:te,amountIn:{...W(),description:'Amount of the input token in base units (quote token for buy, listed token for sell); read its decimals. Example: "1000000" = 1 token with 6 decimals.'}},["poolId","side","amountIn"],async(e,o)=>{let t=$(e.poolId);if(e.side!=="buy"&&e.side!=="sell")throw new i("Hookr side must be buy or sell.");if(typeof e.amountIn!="string"||Q(e.amountIn)<=0n)throw new i("Provide a positive amountIn in base units.");let a=await O(n,"hookr_pool",{poolId:t}),d=F(a.listing,t),s=S(e.side==="buy"?d.quote:d.token),u=w(String(s.address)),c=u==="0x0000000000000000000000000000000000000000"?18:await n.clientFor(p).readContract({address:u,abi:ie,functionName:"decimals"});if(typeof c!="number"||!Number.isInteger(c)||c<0||c>255||typeof s.symbol!="string")throw new i("Hookr input token metadata is unavailable.");let l=V(e.amountIn,c),r=await O(n,"hookr_quote",{poolId:t,side:e.side,amount:l,payer:o}),k=await O(n,"hookr_check_trade",{poolId:t,side:e.side,amount:l,wallet:o});return{chainId:p,source:B,input:{token:{address:u,symbol:s.symbol,decimals:c,chainId:p},amount:e.amountIn},quote:r,check:k,note:"Informational quote. Review pool rules; unknown trade checks do not authorize a trade."}})]}export{be as a};
1
+ import{a as R}from"./G2LAO23N.js";import{C as X,H as Y,I as M,L as Z,a as g,z as C}from"./37UBQQWL.js";import{a as B,g as E}from"./3RGED2KO.js";import{a as W}from"./66F5ZH34.js";import{f as J,g as D}from"./NWNYJ26T.js";import{b as Q,d as V}from"./IX3GZMTM.js";import{b as p}from"./EWZFZUVF.js";import{a as i}from"./XSD5NL7J.js";import{encodeFunctionData as ne,erc20Abi as ie,getAddress as w,parseAbi as re}from"viem";var ee=re(["function fill(uint256 orderId) returns (uint256)","function fillGasFloor(uint256 orderId) view returns (uint256)"]),N={type:"string",pattern:"^[1-9][0-9]*$"},oe={type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"Hookr v4 pool ID: 32 bytes, 0x followed by 64 hex digits."},te={type:"string",enum:["buy","sell"],description:R.enumValues({buy:"spend the pool quote token to receive the listed token",sell:"spend the listed token to receive the quote token"})},se={cursor:{...N,description:"Order ID to start from, scanning downward (newest first). Use nextCursor from the previous page; omit for the latest order."},limit:{type:"integer",minimum:1,maximum:32,description:"Maximum number of order IDs to scan in this page, 1 to 32. Default 16."}};function T(n,h){if(typeof n!="string"||!/^[1-9][0-9]*$/.test(n)||n.length>78||BigInt(n)>=1n<<256n)throw new i(`Provide ${h} as a positive decimal integer string.`);return BigInt(n)}function S(n){return J(n,"Hookr returned an invalid read response. Retry later.")}function H(n,h,e,o){return{name:n,inputSchema:{type:"object",description:`Read ${n.replace("hookr_","Hookr ")}. No signature or transaction.`,properties:h,required:e,additionalProperties:!1},execute:async(t,a)=>{if(Object.keys(t).some(d=>!Object.hasOwn(h,d))||e.some(d=>t[d]===void 0))throw new i(`Provide the documented arguments for ${n}.`);return o(t,a)}}}function $(n){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new i("Provide a 32-byte Hookr poolId.");return n}function F(n,h){let e=S(n),o=S(e.key);if(typeof o.fee!="number"||!Number.isInteger(o.fee)||o.fee<0||o.fee>16777215||typeof o.tickSpacing!="number"||!Number.isInteger(o.tickSpacing)||o.tickSpacing<=0||o.tickSpacing>8388607)throw new i("Hookr pool key is invalid.");let t={currency0:w(String(o.currency0)),currency1:w(String(o.currency1)),fee:o.fee,tickSpacing:o.tickSpacing,hooks:w(String(o.hooks))},a=h??$(e.poolId);if(BigInt(t.currency0)>=BigInt(t.currency1)||!D(X(t),a))throw new i("Hookr pool key does not match its PoolId.");let d=S(e.token),s=S(e.quote),u=r=>{let k=w(String(r.address));if(typeof r.symbol!="string"||!r.symbol.trim()||typeof r.decimals!="number"||!Number.isInteger(r.decimals)||r.decimals<0||r.decimals>255||![t.currency0,t.currency1].includes(k))throw new i("Hookr listed token metadata is invalid.");return{...r,address:k,chainId:p}},c=u(d),l=u(s);if(c.address===l.address)throw new i("Hookr listed token pair is invalid.");return{...e,poolId:a,key:t,token:c,quote:l}}var O=E;function be(n){let h=e=>H(e?"hookr_orders":"hookr_open_orders",se,[],async(o,t)=>{let a=o.limit??16;if(typeof a!="number"||!Number.isInteger(a)||a<1||a>32)throw new i("Hookr page limit must be an integer from 1 to 32.");let d=n.clientFor(p),s=await d.getBlock();if(typeof s.number!="bigint"||typeof s.timestamp!="bigint"||s.timestamp<=0n)throw new i("Hookr order reads need a valid chain block and timestamp.");let u=new Proxy(Z(d),{get(b,m,f){return m==="readContract"?y=>b.readContract({...y,blockNumber:s.number}):Reflect.get(b,m,f)}}),c={...n,clientFor:()=>u},l=await u.readContract({address:g,abi:C,functionName:"lastOrderId"});if(typeof l!="bigint"||l<0n)throw new i("Could not read the last Hookr order ID. Coverage is unknown.");let r=o.cursor===void 0?l:T(o.cursor,"cursor");if(r>l)throw new i("Hookr cursor exceeds the latest order ID. Restart pagination.");let k=[],x=new Map,A=r,I=r>BigInt(a)?r-BigInt(a):0n;for(;r>I;){let b=r--,m=Y(await u.readContract({address:g,abi:C,functionName:"getOrder",args:[b]}));if(Number(m.status)===0||BigInt(m.owner)===0n)throw new i(`Hookr order #${b} is missing. Coverage is unknown.`);if(e?!D(m.owner,t):Number(m.status)!==1)continue;let f=await M(c,b,{order:m,tokens:x});if(e){k.push(f);continue}let y=null,G=null,z=null,L=null,U=BigInt(f.expiry)<s.timestamp,j=f.fillable&&!U;if(j)try{let P=await u.readContract({address:g,abi:ee,functionName:"fillGasFloor",args:[BigInt(f.orderId)]}),_=await d.estimateGas({account:t,to:g,data:ne({abi:ee,functionName:"fill",args:[BigInt(f.orderId)]}),blockNumber:s.number}),v=await d.getGasPrice();if(typeof P!="bigint"||P<0n||typeof _!="bigint"||_<=0n||typeof v!="bigint"||v<0n)throw new Error("Invalid gas data");let K=(P*6n+4n)/5n,q=_>K?_:K;y=q.toString(),G=v.toString(),z=(q*v).toString(),L=(BigInt(f.bounty)-q*v).toString()}catch{}k.push({...f,fillable:j,expired:U,economics:{gasLimit:y,gasPrice:G,estimatedGasCost:z,bountyLessEstimatedGas:L,note:"Estimate only; excludes bounty claim gas and competition. Recheck the fill preview."}})}return{chainId:p,book:g,blockNumber:s.number.toString(),chainTime:s.timestamp.toString(),orders:k,scanned:{from:A.toString(),through:(r+1n).toString()},nextCursor:r>0n?r.toString():null,complete:r===0n}});return[h(!1),h(!0),H("hookr_order",{orderId:{...N,description:R.id("Hookr limit order")}},["orderId"],async e=>M(n,T(e.orderId,"orderId"))),H("hookr_pools",{sort:{type:"string",enum:["liquidity","volume","newest"],description:"Sort by USD liquidity, 24-hour volume, or opening block."},includeTests:{type:"boolean",description:"Include pools with test tickers."},agentsOnly:{type:"boolean",description:"Only pools with an agent gate."},token:{type:"string",description:R.address("listed token whose pools to return")},limit:{type:"integer",minimum:1,maximum:50,description:"Maximum number of pools to return, 1 to 50."},cursor:{type:"string",pattern:"^[0-9]{1,6}$",description:"Paging cursor: the nextCursor from the previous pools page; omit for the first page."}},[],async e=>{if(e.sort!==void 0&&!["liquidity","volume","newest"].includes(String(e.sort)))throw new i("Choose liquidity, volume or newest sorting.");for(let t of["includeTests","agentsOnly"])if(e[t]!==void 0&&typeof e[t]!="boolean")throw new i(`Provide ${t} as a boolean.`);if(e.token!==void 0)try{w(String(e.token))}catch{throw new i("Provide a valid token address.")}if(e.limit!==void 0&&(typeof e.limit!="number"||!Number.isInteger(e.limit)||e.limit<1||e.limit>50))throw new i("Pool page limit must be from 1 to 50.");if(e.cursor!==void 0&&(typeof e.cursor!="string"||!/^[0-9]{1,6}$/.test(e.cursor)))throw new i("Provide the pool nextCursor from the previous page.");let o=await O(n,"hookr_pools",e);if(!Array.isArray(o.pools))throw new i("Hookr pool coverage is unknown. Retry later.");return{...o,pools:o.pools.map(t=>F(t)),chainId:p,source:B}}),H("hookr_pool",{poolId:oe,side:te,amountIn:{...N,description:'Order input amount in base units of the input token (quote token for buy, listed token for sell); read its decimals. Example: "1000000". Give with side and minAmountOut.'},minAmountOut:{...N,description:'Minimum output in base units of the output token (listed token for buy, quote token for sell); read its decimals. Example: "1000000". Give with side and amountIn.'}},["poolId"],async e=>{let o=$(e.poolId),t=[e.side,e.amountIn,e.minAmountOut].some(y=>y!==void 0);if(t&&(e.side!=="buy"&&e.side!=="sell"||e.amountIn===void 0||e.minAmountOut===void 0))throw new i("Provide side, amountIn and minAmountOut together for order-specific bounty bounds.");let a=t?T(e.amountIn,"amountIn"):void 0,d=t?T(e.minAmountOut,"minAmountOut"):void 0;if(a!==void 0&&(a>=1n<<128n||d>=1n<<128n))throw new i("Hookr order amounts must fit uint128 base units.");let s=await O(n,"hookr_pool",{poolId:o}),u=s.listing?F(s.listing,o):void 0,c={...s,...u?{listing:u}:{},chainId:p,source:B};if(!t)return{...c,bountyBounds:{status:"requires-order-terms",note:"The keeper bounty floor depends on the order. Supply side, amountIn and minAmountOut in base units. The batch-1 0.0005 ETH observation is not a permanent floor."}};if(!u)throw new i("Hookr pool key is unavailable; bounty floor is unknown.");let l=u.key,r=S(e.side==="buy"?u.quote:u.token),k=w(String(r.address))===l.currency0,x=n.clientFor(p),A=await x.getBlock(),I=await x.readContract({address:g,abi:C,functionName:"bountyBounds",args:[l,k,a,d],blockNumber:A.number});if(!Array.isArray(I)||I.length!==3||I.some(y=>typeof y!="bigint"||y<0n||y>=1n<<128n))throw new i("Hookr bounty bounds are unavailable; the floor is unknown.");let[b,m,f]=I;return{...c,bountyBounds:{status:"available",blockNumber:A.number.toString(),token:{address:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",symbol:"ETH",decimals:18,chainId:p},minBounty:b.toString(),defaultBounty:m.toString(),maxBounty:f.toString(),effectiveFloor:(b>0n?b:m).toString(),note:"ETH wei for this order at this block. Oak create uses the positive minimum, or the default when minimum is zero; recheck at creation."}}}),H("hookr_quote",{poolId:oe,side:te,amountIn:{...W(),description:'Amount of the input token in base units (quote token for buy, listed token for sell); read its decimals. Example: "1000000" = 1 token with 6 decimals.'}},["poolId","side","amountIn"],async(e,o)=>{let t=$(e.poolId);if(e.side!=="buy"&&e.side!=="sell")throw new i("Hookr side must be buy or sell.");if(typeof e.amountIn!="string"||Q(e.amountIn)<=0n)throw new i("Provide a positive amountIn in base units.");let a=await O(n,"hookr_pool",{poolId:t}),d=F(a.listing,t),s=S(e.side==="buy"?d.quote:d.token),u=w(String(s.address)),c=u==="0x0000000000000000000000000000000000000000"?18:await n.clientFor(p).readContract({address:u,abi:ie,functionName:"decimals"});if(typeof c!="number"||!Number.isInteger(c)||c<0||c>255||typeof s.symbol!="string")throw new i("Hookr input token metadata is unavailable.");let l=V(e.amountIn,c),r=await O(n,"hookr_quote",{poolId:t,side:e.side,amount:l,payer:o}),k=await O(n,"hookr_check_trade",{poolId:t,side:e.side,amount:l,wallet:o});return{chainId:p,source:B,input:{token:{address:u,symbol:s.symbol,decimals:c,chainId:p},amount:e.amountIn},quote:r,check:k,note:"Informational quote. Review pool rules; unknown trade checks do not authorize a trade."}})]}export{be as a};
@@ -1 +1 @@
1
- import{j as p}from"./6EWSLHXL.js";import{a as d}from"./7WXAS54T.js";import{a as f}from"./43LI5NKJ.js";import{d as a,i as c}from"./NWNYJ26T.js";import{b as m}from"./IX3GZMTM.js";import{b as i}from"./EWZFZUVF.js";import{a as s}from"./XSD5NL7J.js";import{erc20Abi as u,zeroAddress as b}from"viem";function T(r,n,e=256,t=!1){if(typeof r!="string"||!/^[0-9]+$/.test(r))throw new s(`${n} must be a decimal base-unit string.`);let o=m(r);if(!t&&o===0n||o>=1n<<BigInt(e))throw new s(`${n} must be ${t?"a":"a positive"} uint${e}.`);return o}function g(r){return c(r,"Provide a token or contract address.",a)}function E(r){return typeof r=="string"&&["eth",d.toLowerCase()].includes(r.toLowerCase())?b:g(r)}function D(r){let n=r??50;if(typeof n!="number"||!Number.isInteger(n)||n<0||n>=1e4)throw new s("Slippage must be an integer from 0 to 9999 bps.");return n}async function N(r,n,e){if(n===b)return{address:d,symbol:"ETH",decimals:18,chainId:i};let t=r.clientFor(i),[o,w]=await Promise.all([t.readContract({address:n,abi:u,functionName:"symbol",blockNumber:e}),t.readContract({address:n,abi:u,functionName:"decimals",blockNumber:e})]);return{address:n,symbol:p(o,n),decimals:w,chainId:i}}async function S(r,n,e,t){return f(e),{txs:n,preview:await r.preview(n,e),summary:t}}function $(r,n){if(Object.keys(r).some(e=>!n.includes(e)))throw new s(`Provide only ${n.join(", ")}.`)}export{T as a,g as b,E as c,D as d,N as e,S as f,$ as g};
1
+ import{j as p}from"./Y7SKGRWC.js";import{a as d}from"./7WXAS54T.js";import{a as f}from"./43LI5NKJ.js";import{d as a,i as c}from"./NWNYJ26T.js";import{b as m}from"./IX3GZMTM.js";import{b as i}from"./EWZFZUVF.js";import{a as s}from"./XSD5NL7J.js";import{erc20Abi as u,zeroAddress as b}from"viem";function T(r,n,e=256,t=!1){if(typeof r!="string"||!/^[0-9]+$/.test(r))throw new s(`${n} must be a decimal base-unit string.`);let o=m(r);if(!t&&o===0n||o>=1n<<BigInt(e))throw new s(`${n} must be ${t?"a":"a positive"} uint${e}.`);return o}function g(r){return c(r,"Provide a token or contract address.",a)}function E(r){return typeof r=="string"&&["eth",d.toLowerCase()].includes(r.toLowerCase())?b:g(r)}function D(r){let n=r??50;if(typeof n!="number"||!Number.isInteger(n)||n<0||n>=1e4)throw new s("Slippage must be an integer from 0 to 9999 bps.");return n}async function N(r,n,e){if(n===b)return{address:d,symbol:"ETH",decimals:18,chainId:i};let t=r.clientFor(i),[o,w]=await Promise.all([t.readContract({address:n,abi:u,functionName:"symbol",blockNumber:e}),t.readContract({address:n,abi:u,functionName:"decimals",blockNumber:e})]);return{address:n,symbol:p(o,n),decimals:w,chainId:i}}async function S(r,n,e,t){return f(e),{txs:n,preview:await r.preview(n,e),summary:t}}function $(r,n){if(Object.keys(r).some(e=>!n.includes(e)))throw new s(`Provide only ${n.join(", ")}.`)}export{T as a,g as b,E as c,D as d,N as e,S as f,$ as g};
@@ -1 +1 @@
1
- import{L as P}from"./DPSFR3ZS.js";import{a as u}from"./QBHY2QRC.js";import{a as O}from"./43LI5NKJ.js";import{a as A}from"./66F5ZH34.js";import{d as g,i as T}from"./NWNYJ26T.js";import{b as p}from"./EWZFZUVF.js";import{a as r}from"./XSD5NL7J.js";import{a as k}from"./JXOEJPJ4.js";import{encodeFunctionData as E,getAddress as f,parseAbi as v,zeroAddress as R}from"viem";var w=v(["function owner() view returns (address)","function paused() view returns (bool)","function maximumLoanDuration() view returns (uint256)","function adminFeeInBasisPoints() view returns (uint16)","function pause()","function unpause()","function updateAdminFee(uint16)","function updateMaximumLoanDuration(uint256)","function setERC20Permit(address,bool)","function setERC20Permits(address[],bool[])","function getERC20Permit(address) view returns (bool)","function requestTransferOwnership(address)","function cancelTransferOwnership()","function acceptTransferOwnership()","function rejectTransferOwnership()"]),C=["pause","unpause","updateAdminFee","updateMaximumLoanDuration","setERC20Permit","setERC20Permits","requestTransferOwnership","cancelTransferOwnership","acceptTransferOwnership","rejectTransferOwnership"];function m(d){return T(d,"Provide an explicit checksummed address.",g)}var S=d=>{let h=(n,i,c,e)=>({name:n,inputSchema:{type:"object",properties:i,required:c,additionalProperties:!1},execute:async(s,t)=>{try{if(O(t),Object.keys(s).some(a=>!Object.hasOwn(i,a)))throw new r("Unsupported Longbow administration argument.");return await e(s,t)}catch(a){throw new r(d.plainError(a))}}});async function b(){let n=d.clientFor(p);if(await n.getChainId()!==p)throw new r("Longbow requires chain 4663.");return n}return{tools:[h("longbow_nft_admin",{token:{type:"string",description:"Optional ERC-20 token address to check whether the NFT loan contract permits it as a loan currency."}},[],async n=>{let i=await b(),c=["owner","paused","maximumLoanDuration","adminFeeInBasisPoints"],e=await Promise.all(c.map(s=>i.readContract({address:u,abi:w,functionName:s})));return{chainId:p,contract:u,...Object.fromEntries(c.map((s,t)=>[s,typeof e[t]=="bigint"?String(e[t]):e[t]])),...n.token===void 0?{}:{token:m(n.token),permitted:await i.readContract({address:u,abi:w,functionName:"getERC20Permit",args:[m(n.token)]})}}}),h("longbow_manage_nft",{operation:{type:"string",enum:C,description:"Owner administration call: pause or unpause the protocol, update the admin fee or maximum loan duration, permit tokens, or manage ownership transfer."},value:A("Integer in base units of the setting, as a decimal string. updateAdminFee: basis points (50 = 0.5%, max 10000). updateMaximumLoanDuration: seconds (86400 = 1 day)."),account:{type:"string",description:"Address of the ERC-20 token for setERC20Permit, or of the proposed new owner for requestTransferOwnership."},enabled:{type:"boolean",description:"For setERC20Permit: true permits the token as a loan currency, false removes the permission."},tokens:{type:"array",maxItems:32,description:"For setERC20Permits: unique token addresses to update; pairs by position with permissions.",items:{type:"string",description:"ERC-20 token address."}},permissions:{type:"array",maxItems:32,description:"For setERC20Permits: true/false per token, same length and order as tokens.",items:{type:"boolean",description:"True permits the token at the same index as a loan currency."}}},["operation"],async(n,i)=>{if(typeof n.operation!="string"||!C.includes(n.operation))throw new r("Choose a documented NFT administration operation.");let c=await b(),e=n.operation,s=e.startsWith("update")?["operation","value"]:e==="setERC20Permit"?["operation","account","enabled"]:e==="setERC20Permits"?["operation","tokens","permissions"]:e==="requestTransferOwnership"?["operation","account"]:["operation"];if(Object.keys(n).some(o=>!s.includes(o)))throw new r("Unexpected fields for this NFT administration operation.");if(!["acceptTransferOwnership","rejectTransferOwnership"].includes(e)){let o=await c.readContract({address:u,abi:w,functionName:"owner"});if(f(o)!==f(i))throw new r("This wallet lacks the NFT loan owner role.")}let t=[];if(e.startsWith("update")){let o=P(n.value,!0);if(o>(e==="updateAdminFee"?10000n:(1n<<32n)-1n))throw new r("NFT fee/duration exceeds the contract limit.");t=[e==="updateAdminFee"?Number(o):o]}else if(e==="setERC20Permit"){if(typeof n.enabled!="boolean")throw new r("Provide enabled as a boolean.");t=[m(n.account),n.enabled]}else if(e==="setERC20Permits"){if(!Array.isArray(n.tokens)||!Array.isArray(n.permissions)||!n.tokens.length||n.tokens.length>32||n.tokens.length!==n.permissions.length||n.permissions.some(l=>typeof l!="boolean"))throw new r("Provide equal bounded token and permission arrays.");let o=n.tokens.map(m);if(new Set(o).size!==o.length)throw new r("Currency tokens must be unique.");t=[o,n.permissions]}else if(e==="requestTransferOwnership"){let o=m(n.account);if(o===R)throw new r("New owner must be nonzero.");t=[o]}let a=`Longbow NFT protocol administration ${e} on ${u}, values ${JSON.stringify(t,(o,l)=>typeof l=="bigint"?String(l):l)}. This changes protocol-wide settings or authority. Ownership acceptance/rejection requires the pending owner; the contract preview verifies that role. Permitting a currency here does not qualify it for Oak\u2019s borrower tools.`,y=[d.unsignedTx({to:u,data:E({abi:w,functionName:e,args:t}),value:"0",chainId:p,description:a})];return{txs:y,preview:await d.preview(y,i),summary:a}}),h("longbow_referral",{},[],async(n,i)=>{let c=await d.http(`https://longbow.credit/api/referral/stats/${f(i)}`,{method:"GET",redirect:"error"});if(!c.ok)throw new r(`Longbow referral service returned HTTP ${c.status}; referral state is unavailable.`);let e=await c.json();if(!e||typeof e!="object"||m(e.address)!==f(i))throw new r("Referral response does not match this wallet.");let s=a=>{if(typeof a!="number"||!Number.isSafeInteger(a)||a<0)throw new r("Invalid referral count.");return a},t=e.bonusEarnedAllTime;if(typeof t!="number"||!Number.isFinite(t)||t<0)throw new r("Invalid referral bonus estimate.");if(e.code!==null&&e.code!==void 0&&(typeof e.code!="string"||!/^[a-zA-Z0-9_-]{1,64}$/.test(e.code)))throw new r("Invalid referral code.");return{address:f(i),chainId:p,code:e.code??null,referrals:s(e.referrals),activeThisEpoch:s(e.activeThisEpoch),bonusEstimateUsd:t,source:"Longbow public referral service; off-chain estimates, not verified payments.",warning:k("Referral links are permanent according to the app. Registration/linking publishes wallet associations and requires a separate authorized publication flow. This tool only reads stats; no payout or claim is promised.")}})]}};export{w as a,S as b};
1
+ import{L as P}from"./R5UOFPDO.js";import{a as u}from"./QBHY2QRC.js";import{a as O}from"./43LI5NKJ.js";import{a as A}from"./66F5ZH34.js";import{d as g,i as T}from"./NWNYJ26T.js";import{b as p}from"./EWZFZUVF.js";import{a as r}from"./XSD5NL7J.js";import{a as k}from"./JXOEJPJ4.js";import{encodeFunctionData as E,getAddress as f,parseAbi as v,zeroAddress as R}from"viem";var w=v(["function owner() view returns (address)","function paused() view returns (bool)","function maximumLoanDuration() view returns (uint256)","function adminFeeInBasisPoints() view returns (uint16)","function pause()","function unpause()","function updateAdminFee(uint16)","function updateMaximumLoanDuration(uint256)","function setERC20Permit(address,bool)","function setERC20Permits(address[],bool[])","function getERC20Permit(address) view returns (bool)","function requestTransferOwnership(address)","function cancelTransferOwnership()","function acceptTransferOwnership()","function rejectTransferOwnership()"]),C=["pause","unpause","updateAdminFee","updateMaximumLoanDuration","setERC20Permit","setERC20Permits","requestTransferOwnership","cancelTransferOwnership","acceptTransferOwnership","rejectTransferOwnership"];function m(d){return T(d,"Provide an explicit checksummed address.",g)}var S=d=>{let h=(n,i,c,e)=>({name:n,inputSchema:{type:"object",properties:i,required:c,additionalProperties:!1},execute:async(s,t)=>{try{if(O(t),Object.keys(s).some(a=>!Object.hasOwn(i,a)))throw new r("Unsupported Longbow administration argument.");return await e(s,t)}catch(a){throw new r(d.plainError(a))}}});async function b(){let n=d.clientFor(p);if(await n.getChainId()!==p)throw new r("Longbow requires chain 4663.");return n}return{tools:[h("longbow_nft_admin",{token:{type:"string",description:"Optional ERC-20 token address to check whether the NFT loan contract permits it as a loan currency."}},[],async n=>{let i=await b(),c=["owner","paused","maximumLoanDuration","adminFeeInBasisPoints"],e=await Promise.all(c.map(s=>i.readContract({address:u,abi:w,functionName:s})));return{chainId:p,contract:u,...Object.fromEntries(c.map((s,t)=>[s,typeof e[t]=="bigint"?String(e[t]):e[t]])),...n.token===void 0?{}:{token:m(n.token),permitted:await i.readContract({address:u,abi:w,functionName:"getERC20Permit",args:[m(n.token)]})}}}),h("longbow_manage_nft",{operation:{type:"string",enum:C,description:"Owner administration call: pause or unpause the protocol, update the admin fee or maximum loan duration, permit tokens, or manage ownership transfer."},value:A("Integer in base units of the setting, as a decimal string. updateAdminFee: basis points (50 = 0.5%, max 10000). updateMaximumLoanDuration: seconds (86400 = 1 day)."),account:{type:"string",description:"Address of the ERC-20 token for setERC20Permit, or of the proposed new owner for requestTransferOwnership."},enabled:{type:"boolean",description:"For setERC20Permit: true permits the token as a loan currency, false removes the permission."},tokens:{type:"array",maxItems:32,description:"For setERC20Permits: unique token addresses to update; pairs by position with permissions.",items:{type:"string",description:"ERC-20 token address."}},permissions:{type:"array",maxItems:32,description:"For setERC20Permits: true/false per token, same length and order as tokens.",items:{type:"boolean",description:"True permits the token at the same index as a loan currency."}}},["operation"],async(n,i)=>{if(typeof n.operation!="string"||!C.includes(n.operation))throw new r("Choose a documented NFT administration operation.");let c=await b(),e=n.operation,s=e.startsWith("update")?["operation","value"]:e==="setERC20Permit"?["operation","account","enabled"]:e==="setERC20Permits"?["operation","tokens","permissions"]:e==="requestTransferOwnership"?["operation","account"]:["operation"];if(Object.keys(n).some(o=>!s.includes(o)))throw new r("Unexpected fields for this NFT administration operation.");if(!["acceptTransferOwnership","rejectTransferOwnership"].includes(e)){let o=await c.readContract({address:u,abi:w,functionName:"owner"});if(f(o)!==f(i))throw new r("This wallet lacks the NFT loan owner role.")}let t=[];if(e.startsWith("update")){let o=P(n.value,!0);if(o>(e==="updateAdminFee"?10000n:(1n<<32n)-1n))throw new r("NFT fee/duration exceeds the contract limit.");t=[e==="updateAdminFee"?Number(o):o]}else if(e==="setERC20Permit"){if(typeof n.enabled!="boolean")throw new r("Provide enabled as a boolean.");t=[m(n.account),n.enabled]}else if(e==="setERC20Permits"){if(!Array.isArray(n.tokens)||!Array.isArray(n.permissions)||!n.tokens.length||n.tokens.length>32||n.tokens.length!==n.permissions.length||n.permissions.some(l=>typeof l!="boolean"))throw new r("Provide equal bounded token and permission arrays.");let o=n.tokens.map(m);if(new Set(o).size!==o.length)throw new r("Currency tokens must be unique.");t=[o,n.permissions]}else if(e==="requestTransferOwnership"){let o=m(n.account);if(o===R)throw new r("New owner must be nonzero.");t=[o]}let a=`Longbow NFT protocol administration ${e} on ${u}, values ${JSON.stringify(t,(o,l)=>typeof l=="bigint"?String(l):l)}. This changes protocol-wide settings or authority. Ownership acceptance/rejection requires the pending owner; the contract preview verifies that role. Permitting a currency here does not qualify it for Oak\u2019s borrower tools.`,y=[d.unsignedTx({to:u,data:E({abi:w,functionName:e,args:t}),value:"0",chainId:p,description:a})];return{txs:y,preview:await d.preview(y,i),summary:a}}),h("longbow_referral",{},[],async(n,i)=>{let c=await d.http(`https://longbow.credit/api/referral/stats/${f(i)}`,{method:"GET",redirect:"error"});if(!c.ok)throw new r(`Longbow referral service returned HTTP ${c.status}; referral state is unavailable.`);let e=await c.json();if(!e||typeof e!="object"||m(e.address)!==f(i))throw new r("Referral response does not match this wallet.");let s=a=>{if(typeof a!="number"||!Number.isSafeInteger(a)||a<0)throw new r("Invalid referral count.");return a},t=e.bonusEarnedAllTime;if(typeof t!="number"||!Number.isFinite(t)||t<0)throw new r("Invalid referral bonus estimate.");if(e.code!==null&&e.code!==void 0&&(typeof e.code!="string"||!/^[a-zA-Z0-9_-]{1,64}$/.test(e.code)))throw new r("Invalid referral code.");return{address:f(i),chainId:p,code:e.code??null,referrals:s(e.referrals),activeThisEpoch:s(e.activeThisEpoch),bonusEstimateUsd:t,source:"Longbow public referral service; off-chain estimates, not verified payments.",warning:k("Referral links are permanent according to the app. Registration/linking publishes wallet associations and requires a separate authorized publication flow. This tool only reads stats; no payout or claim is promised.")}})]}};export{w as a,S as b};
@@ -1 +1 @@
1
- import{a as c,b as u,e as a}from"./45QP74CE.js";import{b as R}from"./3YNXQ3EZ.js";import{g as T}from"./IM7ZF7XZ.js";import{a as O,b as d,e as P}from"./GX2RCAHG.js";import{a as s,c as f,h as H}from"./XUDQYSPU.js";import{c as A}from"./6RVAV6BB.js";import{a as C}from"./ZTNBX4VH.js";import{d as L}from"./AZBTNUXF.js";import{a as h,b as m}from"./NUTTPUYJ.js";import{e as _}from"./3XY44BP5.js";import{m as n}from"./UMY6SP7C.js";import{a as k}from"./XSD5NL7J.js";var B=[...s,...O,"hookr_launch","hookr_action","hookr_revenue_action","hookr_addon_action","hookr_agent_link","hookr_reviewer_set","hookr_claim","hookr_swap",...c];async function F(o,r,i,p,e={}){if(f(o))return H(o,r,i,p);if(o==="hookr_swap")return _(r,i,p,e);if(u(o)){let t=await a(o,r,i,p,e);return{...t,terms:{...n(t.terms),gasLimits:t.txs.map(S=>S.gasLimit)}}}if(o==="hookr_agent_link")return h(r,i,p);if(o==="hookr_reviewer_set")return m(r,i,p);if(o==="hookr_claim")return A(r,i,p);if(d(o))return P(o,r,i,p);if(o==="hookr_launch")return T(r,i,p);if(o==="hookr_action")return L(r,i,p);if(o==="hookr_revenue_action")return R(r,i,p);if(o==="hookr_addon_action")return C(r,i,p);throw new k("This Hookr tool has no local action reconstruction.")}export{B as a,F as b};
1
+ import{a as c,b as u,e as a}from"./ZB67QDN2.js";import{b as R}from"./3YNXQ3EZ.js";import{g as T}from"./627SGCTU.js";import{a as O,b as d,e as P}from"./JYED2PZ3.js";import{a as s,c as f,h as H}from"./LHC2YV2U.js";import{c as A}from"./6RVAV6BB.js";import{a as C}from"./ZTNBX4VH.js";import{d as L}from"./AZBTNUXF.js";import{a as h,b as m}from"./NUTTPUYJ.js";import{e as _}from"./3XY44BP5.js";import{m as n}from"./UMY6SP7C.js";import{a as k}from"./XSD5NL7J.js";var B=[...s,...O,"hookr_launch","hookr_action","hookr_revenue_action","hookr_addon_action","hookr_agent_link","hookr_reviewer_set","hookr_claim","hookr_swap",...c];async function F(o,r,i,p,e={}){if(f(o))return H(o,r,i,p);if(o==="hookr_swap")return _(r,i,p,e);if(u(o)){let t=await a(o,r,i,p,e);return{...t,terms:{...n(t.terms),gasLimits:t.txs.map(S=>S.gasLimit)}}}if(o==="hookr_agent_link")return h(r,i,p);if(o==="hookr_reviewer_set")return m(r,i,p);if(o==="hookr_claim")return A(r,i,p);if(d(o))return P(o,r,i,p);if(o==="hookr_launch")return T(r,i,p);if(o==="hookr_action")return L(r,i,p);if(o==="hookr_revenue_action")return R(r,i,p);if(o==="hookr_addon_action")return C(r,i,p);throw new k("This Hookr tool has no local action reconstruction.")}export{B as a,F as b};
@@ -1 +1 @@
1
- import{o as s}from"./IR7KDBFU.js";import{formatUnits as c}from"viem";function l(e){return`HoodLock creation fee: ${e.eth} ETH (${e.amount} wei; ${e.usd===null?"USD unavailable: no fresh ETH/USD reference":`approximately $${e.usd} USD`}), not refundable after creation. Paid to ${e.contract}; separate from network gas.`}async function p(e,t,d,r){let o=r===0n?"0":null;if(r>0n)try{let a=await s("ETH",{client:e.clientFor(4663),chainId:4663});BigInt(a.usdE18)>0n&&(o=c(r*BigInt(a.usdE18)/10n**18n,18))}catch{}let n={contract:d,amount:r.toString(),eth:c(r,18),usd:o,refundable:!1},i=l(n);return{...t,summary:`${t.summary} ${i}`,preview:{...t.preview,summary:`${t.preview.summary} ${i}`},protocolFee:n}}export{l as a,p as b};
1
+ import{o as s}from"./OUXPOFY2.js";import{formatUnits as c}from"viem";function l(e){return`HoodLock creation fee: ${e.eth} ETH (${e.amount} wei; ${e.usd===null?"USD unavailable: no fresh ETH/USD reference":`approximately $${e.usd} USD`}), not refundable after creation. Paid to ${e.contract}; separate from network gas.`}async function p(e,t,d,r){let o=r===0n?"0":null;if(r>0n)try{let a=await s("ETH",{client:e.clientFor(4663),chainId:4663});BigInt(a.usdE18)>0n&&(o=c(r*BigInt(a.usdE18)/10n**18n,18))}catch{}let n={contract:d,amount:r.toString(),eth:c(r,18),usd:o,refundable:!1},i=l(n);return{...t,summary:`${t.summary} ${i}`,preview:{...t.preview,summary:`${t.preview.summary} ${i}`},protocolFee:n}}export{l as a,p as b};