@oakagentkit/core 0.1.9 → 0.2.0

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 (171) hide show
  1. package/build/dist/api/deployments.d.ts +26 -0
  2. package/build/dist/api/deployments.js +1 -0
  3. package/build/dist/api/history.js +1 -1
  4. package/build/dist/api/modules/beefy/clm.js +1 -1
  5. package/build/dist/api/modules/beefy/guard.js +1 -1
  6. package/build/dist/api/modules/beefy/index.js +1 -1
  7. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  8. package/build/dist/api/modules/clanker/index.js +1 -1
  9. package/build/dist/api/modules/grove/index.js +1 -1
  10. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  11. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  12. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  13. package/build/dist/api/modules/hoodlock/index.js +1 -1
  14. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  15. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  16. package/build/dist/api/modules/hoodlock/public.js +1 -1
  17. package/build/dist/api/modules/hookr/actions.js +1 -1
  18. package/build/dist/api/modules/hookr/addons.js +1 -1
  19. package/build/dist/api/modules/hookr/contracts.js +1 -1
  20. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  21. package/build/dist/api/modules/hookr/discovery.js +1 -1
  22. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  23. package/build/dist/api/modules/hookr/index.js +1 -1
  24. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  25. package/build/dist/api/modules/hookr/relay.js +1 -1
  26. package/build/dist/api/modules/kyberswap/index.js +1 -1
  27. package/build/dist/api/modules/kyberswap/source-pools.d.ts +22 -3
  28. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  29. package/build/dist/api/modules/longbow/administration.js +1 -1
  30. package/build/dist/api/modules/longbow/fixed.js +1 -1
  31. package/build/dist/api/modules/longbow/index.js +1 -1
  32. package/build/dist/api/modules/meridian/index.js +1 -1
  33. package/build/dist/api/modules/meridian/rfq.js +1 -1
  34. package/build/dist/api/modules/morpho/bundles.js +1 -1
  35. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  36. package/build/dist/api/modules/morpho/index.js +1 -1
  37. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  38. package/build/dist/api/modules/morpho/midnight.js +1 -1
  39. package/build/dist/api/modules/morpho/protocol.js +1 -1
  40. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  41. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  42. package/build/dist/api/modules/netnet/card-read.js +1 -1
  43. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  44. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  45. package/build/dist/api/modules/netnet/financial.js +1 -1
  46. package/build/dist/api/modules/netnet/index.js +1 -1
  47. package/build/dist/api/modules/orbio/index.js +1 -1
  48. package/build/dist/api/modules/pons/claim.js +1 -1
  49. package/build/dist/api/modules/pons/index.js +1 -1
  50. package/build/dist/api/modules/pons/launch-status.js +1 -1
  51. package/build/dist/api/modules/pons/reads.js +1 -1
  52. package/build/dist/api/modules/pons/trade.js +1 -1
  53. package/build/dist/api/modules/poolstrade/index.js +1 -1
  54. package/build/dist/api/modules/priors/index.js +1 -1
  55. package/build/dist/api/modules/relay/discovery.js +1 -1
  56. package/build/dist/api/modules/relay/inbound.js +1 -1
  57. package/build/dist/api/modules/relay/index.js +1 -1
  58. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  59. package/build/dist/api/modules/steakhouse/index.js +1 -1
  60. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  61. package/build/dist/api/modules/steakhouse/management.js +1 -1
  62. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  63. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  64. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  65. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  66. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  67. package/build/dist/api/modules/tickerspring/index.js +1 -1
  68. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  69. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  70. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  71. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  72. package/build/dist/api/modules/tickerspring/research.js +1 -1
  73. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  74. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  75. package/build/dist/api/modules/uniswap/auction.js +1 -1
  76. package/build/dist/api/modules/uniswap/batch.js +1 -1
  77. package/build/dist/api/modules/uniswap/common.js +1 -1
  78. package/build/dist/api/modules/uniswap/fees.js +1 -1
  79. package/build/dist/api/modules/uniswap/index.js +1 -1
  80. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  81. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  82. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  83. package/build/dist/api/modules/uniswap/pools.js +1 -1
  84. package/build/dist/api/modules/uniswap/position.js +1 -1
  85. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  86. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  87. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  88. package/build/dist/api/modules/uniswap/trade.js +1 -1
  89. package/build/dist/api/modules/uniswap/v2.js +1 -1
  90. package/build/dist/api/modules/uniswap/v3.js +1 -1
  91. package/build/dist/api/modules/uniswap/v4.js +1 -1
  92. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  93. package/build/dist/api/modules/velora/claims.js +1 -1
  94. package/build/dist/api/modules/velora/index.js +1 -1
  95. package/build/dist/api/prices.js +1 -1
  96. package/build/dist/api/routes.d.ts +2 -0
  97. package/build/dist/api/routes.js +1 -1
  98. package/build/dist/api/send.js +1 -1
  99. package/build/dist/api/signing-registry.js +1 -1
  100. package/build/dist/api/simulate.js +1 -1
  101. package/build/dist/api/swap.js +1 -1
  102. package/build/dist/api/tokens.js +1 -1
  103. package/build/dist/chunks/{QOY4AANB.js → 2SNQWKHA.js} +1 -1
  104. package/build/dist/chunks/{FYTF2QMS.js → 3ACEWCKZ.js} +1 -1
  105. package/build/dist/chunks/{HZUWK5B2.js → 46ZA2R5L.js} +1 -1
  106. package/build/dist/chunks/{W6G2QGYF.js → 4IPW5WZ4.js} +1 -1
  107. package/build/dist/chunks/{JRZLKIYB.js → 55NX776C.js} +1 -1
  108. package/build/dist/chunks/{2EGFALNH.js → 5FTSKYQH.js} +1 -1
  109. package/build/dist/chunks/{OJP7Y4AM.js → 5HW6JKME.js} +1 -1
  110. package/build/dist/chunks/{ZL3KVABO.js → 5VXNQFYJ.js} +1 -1
  111. package/build/dist/chunks/{ITIIHCZK.js → 64AF7ECA.js} +1 -1
  112. package/build/dist/chunks/{FLXID6I3.js → 6LLOTPH2.js} +1 -1
  113. package/build/dist/chunks/{CXMC3T6B.js → 6PU2CMQZ.js} +1 -1
  114. package/build/dist/chunks/{E2IVNGLC.js → 7BTELNNI.js} +1 -1
  115. package/build/dist/chunks/{C5LR6F4B.js → 7T4BYFD4.js} +1 -1
  116. package/build/dist/chunks/{6SB3FB3P.js → 7Z5IM2QZ.js} +1 -1
  117. package/build/dist/chunks/{JOMK32QW.js → A25P24G2.js} +1 -1
  118. package/build/dist/chunks/{FL3EF72E.js → ANQ43XJA.js} +1 -1
  119. package/build/dist/chunks/{B72Q2EQ2.js → BFVLBENV.js} +1 -1
  120. package/build/dist/chunks/{QH3AL3UN.js → BV3AHLH5.js} +1 -1
  121. package/build/dist/chunks/{EKGHKEKV.js → BXN3MDS4.js} +1 -1
  122. package/build/dist/chunks/CAU44UWP.js +1 -0
  123. package/build/dist/chunks/{HACP2Q6D.js → D6VP3N27.js} +2 -2
  124. package/build/dist/chunks/{37QNUNED.js → DLIOZCEG.js} +1 -1
  125. package/build/dist/chunks/EA6IYKIB.js +1 -0
  126. package/build/dist/chunks/{SYZ55RCX.js → EYYUWFUR.js} +1 -1
  127. package/build/dist/chunks/{HF2AGJZC.js → FSPNOVKB.js} +1 -1
  128. package/build/dist/chunks/G4PDM3MX.js +1 -0
  129. package/build/dist/chunks/{ZPNGV34U.js → GHDDVBPK.js} +1 -1
  130. package/build/dist/chunks/{OK3TQFXZ.js → GSI5COTD.js} +1 -1
  131. package/build/dist/chunks/{CAYBSVA6.js → HRG2VVPY.js} +1 -1
  132. package/build/dist/chunks/{MWWYIFXJ.js → ITV52TIE.js} +1 -1
  133. package/build/dist/chunks/{4CDR7F4I.js → IUXOUKQN.js} +1 -1
  134. package/build/dist/chunks/{5H3MQWH7.js → JC4SYMBV.js} +1 -1
  135. package/build/dist/chunks/{KEPQXFHU.js → JREVERSC.js} +1 -1
  136. package/build/dist/chunks/{NUWL6TJM.js → K463HFGC.js} +1 -1
  137. package/build/dist/chunks/{VCWDJQDE.js → KQFDLDHL.js} +1 -1
  138. package/build/dist/chunks/{LFKSXD3S.js → LI7FYINH.js} +1 -1
  139. package/build/dist/chunks/{4X6JEMSF.js → N6RL3SUZ.js} +1 -1
  140. package/build/dist/chunks/{E7ASOYQI.js → NBRMUFJP.js} +1 -1
  141. package/build/dist/chunks/{UEYFMXV3.js → NIOBE2LK.js} +1 -1
  142. package/build/dist/chunks/NMFVXBTL.js +1 -0
  143. package/build/dist/chunks/{REGJY5RC.js → NO57NGRV.js} +1 -1
  144. package/build/dist/chunks/{SEW7UP5U.js → O5SU2I3G.js} +1 -1
  145. package/build/dist/chunks/{P6ELT4ZV.js → PJ65ZOQ7.js} +1 -1
  146. package/build/dist/chunks/{B7V7AA5A.js → QCD33HMD.js} +1 -1
  147. package/build/dist/chunks/{SS7U3CMZ.js → QQWF6A4P.js} +1 -1
  148. package/build/dist/chunks/{NNZ4SZZ4.js → QZM7CWZW.js} +1 -1
  149. package/build/dist/chunks/{HYIEQG4X.js → QZTUMSQY.js} +1 -1
  150. package/build/dist/chunks/{JVTVOK6P.js → R7D256HG.js} +1 -1
  151. package/build/dist/chunks/{Z4LJ2GTX.js → RTBOMWCB.js} +1 -1
  152. package/build/dist/chunks/{EHVPRQHS.js → SDICP7BT.js} +1 -1
  153. package/build/dist/chunks/{L2MTPRU7.js → T3NPRRTY.js} +1 -1
  154. package/build/dist/chunks/{BQLLTY4L.js → TNRDCBGO.js} +1 -1
  155. package/build/dist/chunks/{IKP3Z3RX.js → U3FMCX3L.js} +1 -1
  156. package/build/dist/chunks/{WHT45EFX.js → UIIJWIR6.js} +1 -1
  157. package/build/dist/chunks/{K2LWX3PZ.js → UMK564HS.js} +1 -1
  158. package/build/dist/chunks/{AIWZGIZ6.js → UPPYXY74.js} +1 -1
  159. package/build/dist/chunks/{XCFA73P2.js → VJ3W2V3B.js} +1 -1
  160. package/build/dist/chunks/{RNEMTLQG.js → VY3P34PY.js} +1 -1
  161. package/build/dist/chunks/{2LM5C7FQ.js → WDGPCPQJ.js} +1 -1
  162. package/build/dist/chunks/{PHXWBC4O.js → XKRWJCYE.js} +1 -1
  163. package/build/dist/chunks/{E2Q5IA67.js → Y2IWPNEW.js} +1 -1
  164. package/build/dist/chunks/{YONRUWN7.js → ZCGVBK5K.js} +1 -1
  165. package/build/dist/chunks/{BBQVTEYB.js → ZGXNTWYG.js} +1 -1
  166. package/build/dist/chunks/{CS55ERS3.js → ZYR5LSVB.js} +1 -1
  167. package/package.json +1 -1
  168. package/build/dist/chunks/2O6A6WEX.js +0 -1
  169. package/build/dist/chunks/3Z3U4YPA.js +0 -1
  170. package/build/dist/chunks/EAEQOS7Y.js +0 -1
  171. package/build/dist/chunks/ZQI7B2Z7.js +0 -1
@@ -1 +1 @@
1
- import{a as k,b as P,d as R,e as x,f as U,g as $}from"./ITIIHCZK.js";import{a as w}from"./UWOFA6GV.js";import{c as y,g as D}from"./73N3TOJL.js";import{a as f}from"./XPFVT2EA.js";import{a as p}from"./5YS5V2LK.js";import{encodeFunctionData as O,erc20Abi as L,getAddress as E,parseAbi as I,zeroAddress as h}from"viem";var _=E("0x8bceaa40b9acdfaedf85adf4ff01f5ad6517937f"),g=E("0x89e5db8b5aa49aa85ac63f691524311aeb649eba"),F=I(["function getPair(address,address) view returns (address)"]),S=I(["function token0() view returns (address)","function token1() view returns (address)","function getReserves() view returns (uint112,uint112,uint32)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)"]),C=I(["function factory() view returns (address)","function addLiquidity(address tokenA,address tokenB,uint256 amountADesired,uint256 amountBDesired,uint256 amountAMin,uint256 amountBMin,address to,uint256 deadline) returns (uint256,uint256,uint256)","function removeLiquidity(address tokenA,address tokenB,uint256 liquidity,uint256 amountAMin,uint256 amountBMin,address to,uint256 deadline) returns (uint256,uint256)","function getAmountsOut(uint256 amountIn,address[] path) view returns (uint256[] amounts)","function getAmountsIn(uint256 amountOut,address[] path) view returns (uint256[] amounts)"]);async function z(s,c,t,n){if(c===h||t===h||c===t)throw new p("Provide two different ERC-20 tokens; use WETH for native ETH.");let o=s.clientFor(f),i=await o.getBlockNumber(),a=await o.readContract({address:_,abi:F,functionName:"getPair",args:[c,t],blockNumber:i}),[e,v]=await Promise.all([x(s,c,i),x(s,t,i)]);if(a===h)return{pair:a,tokenA:e,tokenB:v,reserveA:0n,reserveB:0n,supply:0n,balance:0n,blockNumber:i};let[M,l,A,B]=await Promise.all([o.readContract({address:a,abi:S,functionName:"token0",blockNumber:i}),o.readContract({address:a,abi:S,functionName:"getReserves",blockNumber:i}),o.readContract({address:a,abi:S,functionName:"totalSupply",blockNumber:i}),o.readContract({address:a,abi:L,functionName:"balanceOf",args:[n],blockNumber:i})]),[b,r]=D(M,c)?l:[l[1],l[0]];return{pair:a,tokenA:e,tokenB:v,reserveA:b,reserveB:r,supply:A,balance:B,blockNumber:i}}var H={tokenA:y,tokenB:y,amountADesired:w(),amountBDesired:w(),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$"},slippageBps:{type:"integer",minimum:0,maximum:9999},amountAMin:w(),amountBMin:w()};function J(s){let c=async(t,n,o)=>{$(n,t==="pool"?["tokenA","tokenB"]:["tokenA","tokenB","slippageBps","amountAMin","amountBMin",...t==="add"?["amountADesired","amountBDesired"]:["liquidity"]]);let i=P(n.tokenA),a=P(n.tokenB),e=await z(s,i,a,o);if(t==="pool")return{pair:e.pair,tokenA:e.tokenA,tokenB:e.tokenB,reserveA:e.reserveA.toString(),reserveB:e.reserveB.toString(),totalSupply:e.supply.toString(),balance:e.balance.toString(),blockNumber:e.blockNumber.toString(),initialized:e.pair!==h};let v=s.clientFor(f),M=R(n.slippageBps);if(!D(await v.readContract({address:g,abi:C,functionName:"factory"}),_))throw new p("Uniswap v2 router factory differs from its pinned deployment.");let l=(await v.getBlock()).timestamp+300n,A=[],B=(r,u,m)=>{let d=r===void 0?u*BigInt(1e4-M)/10000n:k(r,m,256,!0);if(d>u||u>0n&&d===0n)throw new p(`${m} must be positive and no more than the reserve-ratio estimate.`);return d},b;if(t==="add"){let r=k(n.amountADesired,"amountADesired"),u=k(n.amountBDesired,"amountBDesired");if(e.reserveA===0n!=(e.reserveB===0n))throw new p("Uniswap v2 pair reserves are inconsistent.");let m=r,d=u;if(e.reserveA>0n&&e.reserveB>0n){let T=r*e.reserveB/e.reserveA;T<=u?d=T:m=u*e.reserveA/e.reserveB}if(m===0n||d===0n)throw new p("Liquidity amounts round to zero at the pool reserve ratio.");let q=B(n.amountAMin,m,"amountAMin"),N=B(n.amountBMin,d,"amountBMin");A.push(s.approval(i,g,r.toString(),f),s.approval(a,g,u.toString(),f)),b=O({abi:C,functionName:"addLiquidity",args:[i,a,r,u,q,N,o,l]})}else{if(e.pair===h||e.supply===0n)throw new p("No Uniswap v2 liquidity exists for this pair.");let r=n.liquidity==="all"?e.balance:k(n.liquidity,"liquidity");if(r===0n||r>e.balance)throw new p("Removal exceeds the wallet LP token balance or is zero.");let[u,m]=await Promise.all([i,a].map(N=>v.readContract({address:N,abi:L,functionName:"balanceOf",args:[e.pair]}))),d=B(n.amountAMin,r*u/e.supply,"amountAMin"),q=B(n.amountBMin,r*m/e.supply,"amountBMin");A.push(s.approval(e.pair,g,r.toString(),f)),b=O({abi:C,functionName:"removeLiquidity",args:[i,a,r,d,q,o,l]})}return A.push(s.unsignedTx({to:g,data:b,value:"0",chainId:f,description:`${t} Uniswap v2 liquidity for ${i}/${a}; recipient ${o}; deadline ${l}.`})),U(s,A,o,`${t==="add"?"Add":"Remove"} v2 liquidity. Review exact approvals, token minimums and wallet recipient. The first deposit sets the price; v2 locks MINIMUM_LIQUIDITY permanently.`)};return{tools:["pool","add","remove"].map(t=>({name:`uniswap_v2_${t}`,inputSchema:{type:"object",additionalProperties:!1,required:["tokenA","tokenB",...t==="add"?["amountADesired","amountBDesired"]:t==="remove"?["liquidity"]:[]],properties:t==="pool"?{tokenA:y,tokenB:y}:H},execute:(n,o)=>c(t,n,o)}))}}export{_ as a,g as b,F as c,S as d,C as e,z as f,J as g};
1
+ import{a as k,b as P,d as R,e as x,f as U,g as $}from"./64AF7ECA.js";import{a as w}from"./UWOFA6GV.js";import{c as y,g as D}from"./73N3TOJL.js";import{a as f}from"./XPFVT2EA.js";import{a as p}from"./5YS5V2LK.js";import{encodeFunctionData as O,erc20Abi as L,getAddress as E,parseAbi as I,zeroAddress as h}from"viem";var _=E("0x8bceaa40b9acdfaedf85adf4ff01f5ad6517937f"),g=E("0x89e5db8b5aa49aa85ac63f691524311aeb649eba"),F=I(["function getPair(address,address) view returns (address)"]),S=I(["function token0() view returns (address)","function token1() view returns (address)","function getReserves() view returns (uint112,uint112,uint32)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)"]),C=I(["function factory() view returns (address)","function addLiquidity(address tokenA,address tokenB,uint256 amountADesired,uint256 amountBDesired,uint256 amountAMin,uint256 amountBMin,address to,uint256 deadline) returns (uint256,uint256,uint256)","function removeLiquidity(address tokenA,address tokenB,uint256 liquidity,uint256 amountAMin,uint256 amountBMin,address to,uint256 deadline) returns (uint256,uint256)","function getAmountsOut(uint256 amountIn,address[] path) view returns (uint256[] amounts)","function getAmountsIn(uint256 amountOut,address[] path) view returns (uint256[] amounts)"]);async function z(s,c,t,n){if(c===h||t===h||c===t)throw new p("Provide two different ERC-20 tokens; use WETH for native ETH.");let o=s.clientFor(f),i=await o.getBlockNumber(),a=await o.readContract({address:_,abi:F,functionName:"getPair",args:[c,t],blockNumber:i}),[e,v]=await Promise.all([x(s,c,i),x(s,t,i)]);if(a===h)return{pair:a,tokenA:e,tokenB:v,reserveA:0n,reserveB:0n,supply:0n,balance:0n,blockNumber:i};let[M,l,A,B]=await Promise.all([o.readContract({address:a,abi:S,functionName:"token0",blockNumber:i}),o.readContract({address:a,abi:S,functionName:"getReserves",blockNumber:i}),o.readContract({address:a,abi:S,functionName:"totalSupply",blockNumber:i}),o.readContract({address:a,abi:L,functionName:"balanceOf",args:[n],blockNumber:i})]),[b,r]=D(M,c)?l:[l[1],l[0]];return{pair:a,tokenA:e,tokenB:v,reserveA:b,reserveB:r,supply:A,balance:B,blockNumber:i}}var H={tokenA:y,tokenB:y,amountADesired:w(),amountBDesired:w(),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$"},slippageBps:{type:"integer",minimum:0,maximum:9999},amountAMin:w(),amountBMin:w()};function J(s){let c=async(t,n,o)=>{$(n,t==="pool"?["tokenA","tokenB"]:["tokenA","tokenB","slippageBps","amountAMin","amountBMin",...t==="add"?["amountADesired","amountBDesired"]:["liquidity"]]);let i=P(n.tokenA),a=P(n.tokenB),e=await z(s,i,a,o);if(t==="pool")return{pair:e.pair,tokenA:e.tokenA,tokenB:e.tokenB,reserveA:e.reserveA.toString(),reserveB:e.reserveB.toString(),totalSupply:e.supply.toString(),balance:e.balance.toString(),blockNumber:e.blockNumber.toString(),initialized:e.pair!==h};let v=s.clientFor(f),M=R(n.slippageBps);if(!D(await v.readContract({address:g,abi:C,functionName:"factory"}),_))throw new p("Uniswap v2 router factory differs from its pinned deployment.");let l=(await v.getBlock()).timestamp+300n,A=[],B=(r,u,m)=>{let d=r===void 0?u*BigInt(1e4-M)/10000n:k(r,m,256,!0);if(d>u||u>0n&&d===0n)throw new p(`${m} must be positive and no more than the reserve-ratio estimate.`);return d},b;if(t==="add"){let r=k(n.amountADesired,"amountADesired"),u=k(n.amountBDesired,"amountBDesired");if(e.reserveA===0n!=(e.reserveB===0n))throw new p("Uniswap v2 pair reserves are inconsistent.");let m=r,d=u;if(e.reserveA>0n&&e.reserveB>0n){let T=r*e.reserveB/e.reserveA;T<=u?d=T:m=u*e.reserveA/e.reserveB}if(m===0n||d===0n)throw new p("Liquidity amounts round to zero at the pool reserve ratio.");let q=B(n.amountAMin,m,"amountAMin"),N=B(n.amountBMin,d,"amountBMin");A.push(s.approval(i,g,r.toString(),f),s.approval(a,g,u.toString(),f)),b=O({abi:C,functionName:"addLiquidity",args:[i,a,r,u,q,N,o,l]})}else{if(e.pair===h||e.supply===0n)throw new p("No Uniswap v2 liquidity exists for this pair.");let r=n.liquidity==="all"?e.balance:k(n.liquidity,"liquidity");if(r===0n||r>e.balance)throw new p("Removal exceeds the wallet LP token balance or is zero.");let[u,m]=await Promise.all([i,a].map(N=>v.readContract({address:N,abi:L,functionName:"balanceOf",args:[e.pair]}))),d=B(n.amountAMin,r*u/e.supply,"amountAMin"),q=B(n.amountBMin,r*m/e.supply,"amountBMin");A.push(s.approval(e.pair,g,r.toString(),f)),b=O({abi:C,functionName:"removeLiquidity",args:[i,a,r,d,q,o,l]})}return A.push(s.unsignedTx({to:g,data:b,value:"0",chainId:f,description:`${t} Uniswap v2 liquidity for ${i}/${a}; recipient ${o}; deadline ${l}.`})),U(s,A,o,`${t==="add"?"Add":"Remove"} v2 liquidity. Review exact approvals, token minimums and wallet recipient. The first deposit sets the price; v2 locks MINIMUM_LIQUIDITY permanently.`)};return{tools:["pool","add","remove"].map(t=>({name:`uniswap_v2_${t}`,inputSchema:{type:"object",additionalProperties:!1,required:["tokenA","tokenB",...t==="add"?["amountADesired","amountBDesired"]:t==="remove"?["liquidity"]:[]],properties:t==="pool"?{tokenA:y,tokenB:y}:H},execute:(n,o)=>c(t,n,o)}))}}export{_ as a,g as b,F as c,S as d,C as e,z as f,J as g};
@@ -0,0 +1 @@
1
+ import{c as t}from"./UXG67LH3.js";import{c as o}from"./46ZA2R5L.js";function s(e,n,a){return t(e,n,a,o)}export{s as a};
@@ -1 +1 @@
1
- import{b as k,c as D,d as x}from"./HZUWK5B2.js";import{a as Q}from"./XCFA73P2.js";import{a as T}from"./6IM6A5VA.js";import{g as V,i as G}from"./73N3TOJL.js";import{a as X,b as W}from"./RETS2ZEK.js";import{a as c,d as j,i as O}from"./XPFVT2EA.js";import{a as u}from"./5YS5V2LK.js";import{encodeFunctionData as tt,erc20Abi as Z,getAddress as a,parseAbi as kt}from"viem";var gt="hookr",y=a(O[4663].hookr.HookrLimitOrders.address),At=a(O[4663].hookr.HookrRoot.address),wt=a(O[4663].hookr.HookrRouter.address),Ot=a(O[4663].hookr.HookrForwarder.address),Bt=a(O[4663].hookr.PoolManager.address),ht=a(O[4663].hookr.HOOKR_Token.address),L="0x0000000000000000000000000000000000000000",It="0x000000000000000000000000000000000000dEaD",J=(1n<<128n)-1n,St=new Set([L.toLowerCase(),It.toLowerCase(),y.toLowerCase(),wt.toLowerCase(),Ot.toLowerCase(),Bt.toLowerCase(),At.toLowerCase()]),B=kt(["function getOrder(uint256 orderId) view returns (((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, address owner, uint40 createdAt, uint40 expiry, bool zeroForOne, uint8 status, address recipient, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable, uint256 amountOut)","function bountyBounds((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut) view returns (uint128 minBounty, uint128 defaultBounty, uint128 maxBounty)","function fill(uint256 orderId) returns (uint256 amountOut)","function claimBounty(address to) returns (uint256 amount)","function bountyOf(address keeper) view returns (uint256)","function lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)"]);function Tt(t){let n=t.toLowerCase();return n===L.toLowerCase()||n===Q.toLowerCase()}function Ht(t,n,i){let o=n.trim();if(o.startsWith("-")){let s=o.slice(1),r=t(s,i);return r==="0"?"0":`-${r}`}return t(o,i)}function jt(t,n,i){return W(t,n,i)}function nt(t,n){return!t.changes||t.changes.length===0?"no net ERC-20/native transfer delta on caller":t.changes.map(i=>`${Ht(n,i.amount,i.token.decimals)} ${i.token.symbol} (${i.token.address})`).join(", ")}function $t(t){if(typeof t=="bigint"){if(t<=0n)throw new u("Hookr orderId must be a positive integer.");return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<=0)throw new u("Hookr orderId must be a positive integer.");return BigInt(t)}if(typeof t=="string"&&/^\d+$/.test(t.trim())){let n=BigInt(t.trim());if(n<=0n)throw new u("Hookr orderId must be a positive integer.");return n}throw new u("Provide a positive integer Hookr orderId.")}function et(t){if(t==null)return c;if(typeof t!="number"||!Number.isSafeInteger(t)||t!==c)throw new u(`Hookr limit orders are only supported on chain ${c}.`);return c}function xt(t){switch(t){case 0:return"None";case 1:return"Open";case 2:return"Filled";case 3:return"Cancelled";default:return"Unknown"}}function Rt(t){if(Array.isArray(t)){let[n,i,o,s,r,d,g,m,b,e,l]=t;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:i,createdAt:o,expiry:s,zeroForOne:!!r,status:d,recipient:g,amountIn:BigInt(m),minAmountOut:BigInt(b),bounty:BigInt(e),sqrtPriceLimitX96:BigInt(l)}}if(t&&typeof t=="object"){let n=t;if(n.key&&typeof n.key=="object")return{key:{currency0:n.key.currency0,currency1:n.key.currency1,fee:Number(n.key.fee),tickSpacing:Number(n.key.tickSpacing),hooks:n.key.hooks},owner:n.owner,createdAt:n.createdAt,expiry:n.expiry,zeroForOne:!!n.zeroForOne,status:n.status,recipient:n.recipient,amountIn:BigInt(n.amountIn),minAmountOut:BigInt(n.minAmountOut),bounty:BigInt(n.bounty),sqrtPriceLimitX96:BigInt(n.sqrtPriceLimitX96)}}throw new u("HookrLimitOrders returned a malformed order tuple.")}function Ct(t){if(Array.isArray(t)&&t.length>=2)return{fillable:!!t[0],amountOut:BigInt(t[1])};if(t&&typeof t=="object"&&"fillable"in t&&"amountOut"in t){let n=t;return{fillable:!!n.fillable,amountOut:BigInt(n.amountOut)}}throw new u("HookrLimitOrders returned a malformed quoteFill response.")}function Dt(t){if(Array.isArray(t)&&t.length>=3)return{minBounty:BigInt(t[0]),defaultBounty:BigInt(t[1]),maxBounty:BigInt(t[2])};if(t&&typeof t=="object"&&"minBounty"in t&&"defaultBounty"in t&&"maxBounty"in t){let n=t;return{minBounty:BigInt(n.minBounty),defaultBounty:BigInt(n.defaultBounty),maxBounty:BigInt(n.maxBounty)}}throw new u("HookrLimitOrders returned a malformed bountyBounds response.")}async function Y(t,n,i=c){if(i!==c)throw new u(`Unsupported token chain ${i}; Hookr requires chain ${c}.`);if(Tt(n))return{...k,chainId:i};T(n);let o=a(n),s=o.toLowerCase();if(s===D.address.toLowerCase())return{address:o,symbol:D.symbol,decimals:j,chainId:i};if(s===x.address.toLowerCase())return{address:o,symbol:x.symbol,decimals:x.decimals,chainId:i};if(s===ht.toLowerCase())return{address:o,symbol:"HOOKR",decimals:18,chainId:i};let[r,d]=await Promise.all([t.readContract({address:o,abi:Z,functionName:"symbol"}),t.readContract({address:o,abi:Z,functionName:"decimals"})]),g=typeof r=="string"&&r.trim()?r.trim():o,m=Number(d);if(!Number.isInteger(m)||m<0||m>255)throw new u(`Invalid token decimals for ${o} on chain ${i}.`);return{address:o,symbol:g,decimals:m,chainId:i}}async function Pt(t){if(typeof t.getBlock!="function")throw new u("Cannot read the latest block timestamp for Hookr order expiry.");let n=await t.getBlock().catch(()=>{throw new u("Cannot read the latest block timestamp for Hookr order expiry.")});if(!n||typeof n.timestamp!="bigint"||n.timestamp<=0n)throw new u("Hookr requires a usable latest block timestamp to check order expiry.");return n.timestamp}function P(t,n=[]){let i=G(t,"Provide a valid recipient wallet address."),o=i.toLowerCase();if(St.has(o)||n.some(s=>s.toLowerCase()===o))throw new u(`Recipient ${i} is a reserved protocol or zero address (invalid recipient).`);return i}function ot(t){if(t.minBountyEth!==void 0||t.minAmountOutDecimal!==void 0||t.rounding!==void 0)throw new u("Use minBounty and minAmountOut as base-unit integer strings.")}function E(t,n){if(t!==void 0){if(typeof t!="string"||!/^\d+$/.test(t))throw new u(`Provide ${n} as a base-unit integer string.`);return X(t)}}function Et(t){return{name:"hookr_fill",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"HookrLimitOrders orderId as a positive integer string."},minBounty:{type:"string",description:"Optional minimum keeper bounty in wei (decimal base-unit string)."},minAmountOut:{type:"string",description:"Optional quote pre-check only, in token base-unit integer strings. Not enforced on chain: fill(uint256) enforces only the order minAmountOut."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},required:["orderId"],additionalProperties:!1},async execute(n,i){try{ot(n),T(i);let o=a(i),s=et(n.chainId),r=$t(n.orderId),d=t.clientFor(s),[g,m,b]=await Promise.all([d.readContract({address:y,abi:B,functionName:"getOrder",args:[r]}),d.readContract({address:y,abi:B,functionName:"quoteFill",args:[r]}),Pt(d)]),e=Rt(g),l=Number(e.status),h=xt(l);if(l===0||V(e.owner,L))throw new u(`Hookr order #${r} does not exist.`);if(l!==1)throw new u(`Hookr order #${r} is not open (current status: ${h}).`);let A=BigInt(e.expiry);if(A<b)throw new u(`Hookr order #${r} is expired (expiry ${A} < current timestamp ${b}).`);let f=Number(e.key.tickSpacing),H=Number(e.key.fee);if(!Number.isInteger(f)||f<=0)throw new u(`Hookr order #${r} has an invalid pool tickSpacing (${f}).`);if(e.amountIn<=0n||e.amountIn>J)throw new u(`Hookr order #${r} has an invalid amountIn (${e.amountIn}).`);if(e.minAmountOut<=0n||e.minAmountOut>J)throw new u(`Hookr order #${r} has an invalid minAmountOut (${e.minAmountOut}).`);let R=a(e.key.hooks);P(e.recipient,[R]);let rt=await d.readContract({address:y,abi:B,functionName:"bountyBounds",args:[{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:H,tickSpacing:f,hooks:R},e.zeroForOne,e.amountIn,e.minAmountOut]}),w=Dt(rt),C=E(n.minBounty,"minBounty"),_=C!==void 0&&C>w.minBounty?C:w.minBounty;if(e.bounty<_)throw new u(`Hookr order #${r} is underbounty: order bounty (${e.bounty} wei) is below the required keeper bounty (${_} wei).`);if(e.bounty>w.maxBounty)throw new u(`Hookr order #${r} bounty (${e.bounty} wei) exceeds maximum bounty bound (${w.maxBounty} wei).`);let I=Ct(m),it=e.zeroForOne?e.key.currency0:e.key.currency1,ut=e.zeroForOne?e.key.currency1:e.key.currency0,[$,p]=await Promise.all([Y(d,it,s),Y(d,ut,s)]),S=E(n.minAmountOut,"minAmountOut"),F=S!==void 0&&S>e.minAmountOut?S:e.minAmountOut;if(!I.fillable||I.amountOut<=0n||I.amountOut<F)throw new u(`Hookr order #${r} is not executable: quoted output (${I.amountOut} base units of ${p.address}) does not meet minimum output (${F} base units).`);let st=tt({abi:B,functionName:"fill",args:[r]}),at=t.formatAmount(e.amountIn.toString(),$.decimals),mt=t.formatAmount(I.amountOut.toString(),p.decimals),dt=t.formatAmount(e.minAmountOut.toString(),p.decimals),ct=t.formatAmount(e.bounty.toString(),18),lt=S===void 0?"":` Caller minAmountOut ${S} base units is a quote pre-check only, not enforced on chain; fill(uint256) enforces the order minimum of ${e.minAmountOut} base units.`,v=`Fill Hookr order #${r}: maker's escrow pays ${at} ${$.symbol} (${e.amountIn} base units of ${$.address}); net output goes to ${a(e.recipient)} (quoted ${mt} ${p.symbol}, order minimum ${dt} ${p.symbol}, ${e.minAmountOut} base units of ${p.address}). The filler sends no tokens or ETH (value 0), pays gas, and accrues ${ct} ETH (${e.bounty} wei) bounty to ${o}, payable only via claimBounty. Pool tickSpacing ${f}; expiry ${A} inclusive.${lt}`,q=t.unsignedTx({to:y,data:st,value:"0",chainId:s,description:v}),M=await t.preview([q],o),yt=nt(M,t.formatAmount),z={token:$,amount:e.amountIn.toString()},K={token:p,amount:e.minAmountOut.toString()},bt={token:p,amount:I.amountOut.toString()},U={token:{...k,chainId:s},amount:e.bounty.toString()},ft={orderId:r.toString(),key:{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:H,tickSpacing:f,hooks:R},owner:a(e.owner),recipient:a(e.recipient),createdAt:BigInt(e.createdAt).toString(),expiry:A.toString(),zeroForOne:e.zeroForOne,status:l,statusLabel:h,amountIn:z,minAmountOut:K,bounty:U,sqrtPriceLimitX96:e.sqrtPriceLimitX96.toString()},pt={minBounty:{token:{...k,chainId:s},amount:w.minBounty.toString()},defaultBounty:{token:{...k,chainId:s},amount:w.defaultBounty.toString()},maxBounty:{token:{...k,chainId:s},amount:w.maxBounty.toString()}};return{txs:[q],summary:`${v} Preview deltas: ${yt}.`,preview:M,orderId:r.toString(),fillable:!0,amountIn:z,minAmountOut:K,quotedAmountOut:bt,bounty:U,bountyBounds:pt,order:ft}}catch(o){throw new u(t.plainError(o))}}}}function Lt(t){return{name:"hookr_claim_bounty",inputSchema:{type:"object",properties:{to:{type:"string",description:"Optional recipient address for the claimed native ETH bounty (must be the signing wallet)."},minBounty:{type:"string",description:"Optional minimum claimable bounty in wei (decimal base-unit string)."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},additionalProperties:!1},async execute(n,i){try{ot(n),T(i);let o=a(i),s=et(n.chainId),r=n.to!==void 0&&n.to!==null?P(String(n.to)):P(o);if(r!==o)throw new u("Hookr bounty recipient must be the signing wallet.");let g=await t.clientFor(s).readContract({address:y,abi:B,functionName:"bountyOf",args:[o]}),m=BigInt(g);if(m<=0n)throw new u(`No claimable Hookr keeper bounty for ${o}.`);let b=E(n.minBounty,"minBounty");if(b!==void 0&&m<b)throw new u(`Claimable Hookr bounty (${m} wei) is below the requested minimum (${b} wei).`);let e=tt({abi:B,functionName:"claimBounty",args:[r]}),l=t.formatAmount(m.toString(),18),h=t.unsignedTx({to:y,data:e,value:"0",chainId:s,description:`Claim ${l} ETH (${m} wei) of accrued Hookr keeper bounty from ${y} to ${r}.`}),A=await t.preview([h],o),f=nt(A,t.formatAmount),H={token:{...k,chainId:s},amount:m.toString()};return{txs:[h],summary:`Claim ${l} ETH (${m} wei) Hookr keeper bounty to ${r}. Preview deltas: ${f}.`,preview:A,recipient:r,claimableBounty:H}}catch(o){throw new u(t.plainError(o))}}}}async function Nt(t,n){T(n);let i=a(n),o=t.clientFor(c);try{let s=await o.readContract({address:y,abi:B,functionName:"bountyOf",args:[i]}),r=BigInt(s);if(r<=0n)return[];let d=t.formatAmount(r.toString(),18);return[{module:gt,id:`hookr:bounty:${i.toLowerCase()}`,chainId:c,assets:[{token:{...k,chainId:c},amount:r.toString()}],description:`Hookr claimable keeper bounty (${d} ETH)`}]}catch(s){throw new u(t.plainError(s))}}var N=t=>({tools:[Et(t),Lt(t)],positions:n=>Nt(t,n)}),Xt=N,Wt=N,Vt=N;export{gt as a,y as b,At as c,wt as d,Ot as e,Bt as f,ht as g,B as h,Ht as i,jt as j,Et as k,Lt as l,Nt as m,N as n,Xt as o,Wt as p,Vt as q};
1
+ import{b as k,c as D,d as x}from"./46ZA2R5L.js";import{a as Q}from"./VJ3W2V3B.js";import{a as T}from"./6IM6A5VA.js";import{g as V,i as G}from"./73N3TOJL.js";import{a as X,b as W}from"./RETS2ZEK.js";import{a as c,d as j,i as O}from"./XPFVT2EA.js";import{a as u}from"./5YS5V2LK.js";import{encodeFunctionData as tt,erc20Abi as Z,getAddress as a,parseAbi as kt}from"viem";var gt="hookr",y=a(O[4663].hookr.HookrLimitOrders.address),At=a(O[4663].hookr.HookrRoot.address),wt=a(O[4663].hookr.HookrRouter.address),Ot=a(O[4663].hookr.HookrForwarder.address),Bt=a(O[4663].hookr.PoolManager.address),ht=a(O[4663].hookr.HOOKR_Token.address),L="0x0000000000000000000000000000000000000000",It="0x000000000000000000000000000000000000dEaD",J=(1n<<128n)-1n,St=new Set([L.toLowerCase(),It.toLowerCase(),y.toLowerCase(),wt.toLowerCase(),Ot.toLowerCase(),Bt.toLowerCase(),At.toLowerCase()]),B=kt(["function getOrder(uint256 orderId) view returns (((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, address owner, uint40 createdAt, uint40 expiry, bool zeroForOne, uint8 status, address recipient, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable, uint256 amountOut)","function bountyBounds((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut) view returns (uint128 minBounty, uint128 defaultBounty, uint128 maxBounty)","function fill(uint256 orderId) returns (uint256 amountOut)","function claimBounty(address to) returns (uint256 amount)","function bountyOf(address keeper) view returns (uint256)","function lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)"]);function Tt(t){let n=t.toLowerCase();return n===L.toLowerCase()||n===Q.toLowerCase()}function Ht(t,n,i){let o=n.trim();if(o.startsWith("-")){let s=o.slice(1),r=t(s,i);return r==="0"?"0":`-${r}`}return t(o,i)}function jt(t,n,i){return W(t,n,i)}function nt(t,n){return!t.changes||t.changes.length===0?"no net ERC-20/native transfer delta on caller":t.changes.map(i=>`${Ht(n,i.amount,i.token.decimals)} ${i.token.symbol} (${i.token.address})`).join(", ")}function $t(t){if(typeof t=="bigint"){if(t<=0n)throw new u("Hookr orderId must be a positive integer.");return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<=0)throw new u("Hookr orderId must be a positive integer.");return BigInt(t)}if(typeof t=="string"&&/^\d+$/.test(t.trim())){let n=BigInt(t.trim());if(n<=0n)throw new u("Hookr orderId must be a positive integer.");return n}throw new u("Provide a positive integer Hookr orderId.")}function et(t){if(t==null)return c;if(typeof t!="number"||!Number.isSafeInteger(t)||t!==c)throw new u(`Hookr limit orders are only supported on chain ${c}.`);return c}function xt(t){switch(t){case 0:return"None";case 1:return"Open";case 2:return"Filled";case 3:return"Cancelled";default:return"Unknown"}}function Rt(t){if(Array.isArray(t)){let[n,i,o,s,r,d,g,m,b,e,l]=t;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:i,createdAt:o,expiry:s,zeroForOne:!!r,status:d,recipient:g,amountIn:BigInt(m),minAmountOut:BigInt(b),bounty:BigInt(e),sqrtPriceLimitX96:BigInt(l)}}if(t&&typeof t=="object"){let n=t;if(n.key&&typeof n.key=="object")return{key:{currency0:n.key.currency0,currency1:n.key.currency1,fee:Number(n.key.fee),tickSpacing:Number(n.key.tickSpacing),hooks:n.key.hooks},owner:n.owner,createdAt:n.createdAt,expiry:n.expiry,zeroForOne:!!n.zeroForOne,status:n.status,recipient:n.recipient,amountIn:BigInt(n.amountIn),minAmountOut:BigInt(n.minAmountOut),bounty:BigInt(n.bounty),sqrtPriceLimitX96:BigInt(n.sqrtPriceLimitX96)}}throw new u("HookrLimitOrders returned a malformed order tuple.")}function Ct(t){if(Array.isArray(t)&&t.length>=2)return{fillable:!!t[0],amountOut:BigInt(t[1])};if(t&&typeof t=="object"&&"fillable"in t&&"amountOut"in t){let n=t;return{fillable:!!n.fillable,amountOut:BigInt(n.amountOut)}}throw new u("HookrLimitOrders returned a malformed quoteFill response.")}function Dt(t){if(Array.isArray(t)&&t.length>=3)return{minBounty:BigInt(t[0]),defaultBounty:BigInt(t[1]),maxBounty:BigInt(t[2])};if(t&&typeof t=="object"&&"minBounty"in t&&"defaultBounty"in t&&"maxBounty"in t){let n=t;return{minBounty:BigInt(n.minBounty),defaultBounty:BigInt(n.defaultBounty),maxBounty:BigInt(n.maxBounty)}}throw new u("HookrLimitOrders returned a malformed bountyBounds response.")}async function Y(t,n,i=c){if(i!==c)throw new u(`Unsupported token chain ${i}; Hookr requires chain ${c}.`);if(Tt(n))return{...k,chainId:i};T(n);let o=a(n),s=o.toLowerCase();if(s===D.address.toLowerCase())return{address:o,symbol:D.symbol,decimals:j,chainId:i};if(s===x.address.toLowerCase())return{address:o,symbol:x.symbol,decimals:x.decimals,chainId:i};if(s===ht.toLowerCase())return{address:o,symbol:"HOOKR",decimals:18,chainId:i};let[r,d]=await Promise.all([t.readContract({address:o,abi:Z,functionName:"symbol"}),t.readContract({address:o,abi:Z,functionName:"decimals"})]),g=typeof r=="string"&&r.trim()?r.trim():o,m=Number(d);if(!Number.isInteger(m)||m<0||m>255)throw new u(`Invalid token decimals for ${o} on chain ${i}.`);return{address:o,symbol:g,decimals:m,chainId:i}}async function Pt(t){if(typeof t.getBlock!="function")throw new u("Cannot read the latest block timestamp for Hookr order expiry.");let n=await t.getBlock().catch(()=>{throw new u("Cannot read the latest block timestamp for Hookr order expiry.")});if(!n||typeof n.timestamp!="bigint"||n.timestamp<=0n)throw new u("Hookr requires a usable latest block timestamp to check order expiry.");return n.timestamp}function P(t,n=[]){let i=G(t,"Provide a valid recipient wallet address."),o=i.toLowerCase();if(St.has(o)||n.some(s=>s.toLowerCase()===o))throw new u(`Recipient ${i} is a reserved protocol or zero address (invalid recipient).`);return i}function ot(t){if(t.minBountyEth!==void 0||t.minAmountOutDecimal!==void 0||t.rounding!==void 0)throw new u("Use minBounty and minAmountOut as base-unit integer strings.")}function E(t,n){if(t!==void 0){if(typeof t!="string"||!/^\d+$/.test(t))throw new u(`Provide ${n} as a base-unit integer string.`);return X(t)}}function Et(t){return{name:"hookr_fill",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"HookrLimitOrders orderId as a positive integer string."},minBounty:{type:"string",description:"Optional minimum keeper bounty in wei (decimal base-unit string)."},minAmountOut:{type:"string",description:"Optional quote pre-check only, in token base-unit integer strings. Not enforced on chain: fill(uint256) enforces only the order minAmountOut."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},required:["orderId"],additionalProperties:!1},async execute(n,i){try{ot(n),T(i);let o=a(i),s=et(n.chainId),r=$t(n.orderId),d=t.clientFor(s),[g,m,b]=await Promise.all([d.readContract({address:y,abi:B,functionName:"getOrder",args:[r]}),d.readContract({address:y,abi:B,functionName:"quoteFill",args:[r]}),Pt(d)]),e=Rt(g),l=Number(e.status),h=xt(l);if(l===0||V(e.owner,L))throw new u(`Hookr order #${r} does not exist.`);if(l!==1)throw new u(`Hookr order #${r} is not open (current status: ${h}).`);let A=BigInt(e.expiry);if(A<b)throw new u(`Hookr order #${r} is expired (expiry ${A} < current timestamp ${b}).`);let f=Number(e.key.tickSpacing),H=Number(e.key.fee);if(!Number.isInteger(f)||f<=0)throw new u(`Hookr order #${r} has an invalid pool tickSpacing (${f}).`);if(e.amountIn<=0n||e.amountIn>J)throw new u(`Hookr order #${r} has an invalid amountIn (${e.amountIn}).`);if(e.minAmountOut<=0n||e.minAmountOut>J)throw new u(`Hookr order #${r} has an invalid minAmountOut (${e.minAmountOut}).`);let R=a(e.key.hooks);P(e.recipient,[R]);let rt=await d.readContract({address:y,abi:B,functionName:"bountyBounds",args:[{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:H,tickSpacing:f,hooks:R},e.zeroForOne,e.amountIn,e.minAmountOut]}),w=Dt(rt),C=E(n.minBounty,"minBounty"),_=C!==void 0&&C>w.minBounty?C:w.minBounty;if(e.bounty<_)throw new u(`Hookr order #${r} is underbounty: order bounty (${e.bounty} wei) is below the required keeper bounty (${_} wei).`);if(e.bounty>w.maxBounty)throw new u(`Hookr order #${r} bounty (${e.bounty} wei) exceeds maximum bounty bound (${w.maxBounty} wei).`);let I=Ct(m),it=e.zeroForOne?e.key.currency0:e.key.currency1,ut=e.zeroForOne?e.key.currency1:e.key.currency0,[$,p]=await Promise.all([Y(d,it,s),Y(d,ut,s)]),S=E(n.minAmountOut,"minAmountOut"),F=S!==void 0&&S>e.minAmountOut?S:e.minAmountOut;if(!I.fillable||I.amountOut<=0n||I.amountOut<F)throw new u(`Hookr order #${r} is not executable: quoted output (${I.amountOut} base units of ${p.address}) does not meet minimum output (${F} base units).`);let st=tt({abi:B,functionName:"fill",args:[r]}),at=t.formatAmount(e.amountIn.toString(),$.decimals),mt=t.formatAmount(I.amountOut.toString(),p.decimals),dt=t.formatAmount(e.minAmountOut.toString(),p.decimals),ct=t.formatAmount(e.bounty.toString(),18),lt=S===void 0?"":` Caller minAmountOut ${S} base units is a quote pre-check only, not enforced on chain; fill(uint256) enforces the order minimum of ${e.minAmountOut} base units.`,v=`Fill Hookr order #${r}: maker's escrow pays ${at} ${$.symbol} (${e.amountIn} base units of ${$.address}); net output goes to ${a(e.recipient)} (quoted ${mt} ${p.symbol}, order minimum ${dt} ${p.symbol}, ${e.minAmountOut} base units of ${p.address}). The filler sends no tokens or ETH (value 0), pays gas, and accrues ${ct} ETH (${e.bounty} wei) bounty to ${o}, payable only via claimBounty. Pool tickSpacing ${f}; expiry ${A} inclusive.${lt}`,q=t.unsignedTx({to:y,data:st,value:"0",chainId:s,description:v}),M=await t.preview([q],o),yt=nt(M,t.formatAmount),z={token:$,amount:e.amountIn.toString()},K={token:p,amount:e.minAmountOut.toString()},bt={token:p,amount:I.amountOut.toString()},U={token:{...k,chainId:s},amount:e.bounty.toString()},ft={orderId:r.toString(),key:{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:H,tickSpacing:f,hooks:R},owner:a(e.owner),recipient:a(e.recipient),createdAt:BigInt(e.createdAt).toString(),expiry:A.toString(),zeroForOne:e.zeroForOne,status:l,statusLabel:h,amountIn:z,minAmountOut:K,bounty:U,sqrtPriceLimitX96:e.sqrtPriceLimitX96.toString()},pt={minBounty:{token:{...k,chainId:s},amount:w.minBounty.toString()},defaultBounty:{token:{...k,chainId:s},amount:w.defaultBounty.toString()},maxBounty:{token:{...k,chainId:s},amount:w.maxBounty.toString()}};return{txs:[q],summary:`${v} Preview deltas: ${yt}.`,preview:M,orderId:r.toString(),fillable:!0,amountIn:z,minAmountOut:K,quotedAmountOut:bt,bounty:U,bountyBounds:pt,order:ft}}catch(o){throw new u(t.plainError(o))}}}}function Lt(t){return{name:"hookr_claim_bounty",inputSchema:{type:"object",properties:{to:{type:"string",description:"Optional recipient address for the claimed native ETH bounty (must be the signing wallet)."},minBounty:{type:"string",description:"Optional minimum claimable bounty in wei (decimal base-unit string)."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},additionalProperties:!1},async execute(n,i){try{ot(n),T(i);let o=a(i),s=et(n.chainId),r=n.to!==void 0&&n.to!==null?P(String(n.to)):P(o);if(r!==o)throw new u("Hookr bounty recipient must be the signing wallet.");let g=await t.clientFor(s).readContract({address:y,abi:B,functionName:"bountyOf",args:[o]}),m=BigInt(g);if(m<=0n)throw new u(`No claimable Hookr keeper bounty for ${o}.`);let b=E(n.minBounty,"minBounty");if(b!==void 0&&m<b)throw new u(`Claimable Hookr bounty (${m} wei) is below the requested minimum (${b} wei).`);let e=tt({abi:B,functionName:"claimBounty",args:[r]}),l=t.formatAmount(m.toString(),18),h=t.unsignedTx({to:y,data:e,value:"0",chainId:s,description:`Claim ${l} ETH (${m} wei) of accrued Hookr keeper bounty from ${y} to ${r}.`}),A=await t.preview([h],o),f=nt(A,t.formatAmount),H={token:{...k,chainId:s},amount:m.toString()};return{txs:[h],summary:`Claim ${l} ETH (${m} wei) Hookr keeper bounty to ${r}. Preview deltas: ${f}.`,preview:A,recipient:r,claimableBounty:H}}catch(o){throw new u(t.plainError(o))}}}}async function Nt(t,n){T(n);let i=a(n),o=t.clientFor(c);try{let s=await o.readContract({address:y,abi:B,functionName:"bountyOf",args:[i]}),r=BigInt(s);if(r<=0n)return[];let d=t.formatAmount(r.toString(),18);return[{module:gt,id:`hookr:bounty:${i.toLowerCase()}`,chainId:c,assets:[{token:{...k,chainId:c},amount:r.toString()}],description:`Hookr claimable keeper bounty (${d} ETH)`}]}catch(s){throw new u(t.plainError(s))}}var N=t=>({tools:[Et(t),Lt(t)],positions:n=>Nt(t,n)}),Xt=N,Wt=N,Vt=N;export{gt as a,y as b,At as c,wt as d,Ot as e,Bt as f,ht as g,B as h,Ht as i,jt as j,Et as k,Lt as l,Nt as m,N as n,Xt as o,Wt as p,Vt as q};
@@ -1 +1 @@
1
- import{c as u,f as h}from"./QRUC7EFE.js";import{i as g,j as k}from"./2LM5C7FQ.js";import{d as p,f}from"./QOY4AANB.js";import{q as m}from"./PHXWBC4O.js";import{a as d}from"./AXYOJBX6.js";import{g as l}from"./73N3TOJL.js";import{a as i}from"./5YS5V2LK.js";var w=["hoodlock_lock","hoodlock_burn","hoodlock_airdrop_create","hoodlock_airdrop_claim",...p,...u];async function H(e,r,t,s){if(!w.includes(e))throw new i("Unknown HoodLock action; nothing was signed.");let o=async()=>{throw new i("HoodLock does not require a swap for this action.")},n=d({clientFor:()=>s,http:fetch,preview:async a=>({txs:a,changes:[],summary:"Locally reconstructed HoodLock intent."}),quoteSwap:o,buildSwap:o}),c=await[g(n),k(n),...m(n).tools,...f(n).tools,...h(n).tools].find(a=>a.name===e).execute(r,t);if(!Array.isArray(c.txs)||c.txs.length===0)throw new i("HoodLock action has no transactions; use the read route.");return c.txs.map(a=>({...a}))}function I(e,r){if(!r.length||e.length!==r.length||e.some((t,s)=>{let o=r[s];return t.chainId!==o.chainId||!l(t.to,o.to)||!l(t.data,o.data)||t.value!==o.value}))throw new i("HoodLock transaction differs from the locally reconstructed request; nothing was signed.")}export{w as a,H as b,I as c};
1
+ import{q as m}from"./XKRWJCYE.js";import{c as u,f as h}from"./QRUC7EFE.js";import{d as p,f}from"./2SNQWKHA.js";import{i as g,j as k}from"./WDGPCPQJ.js";import{a as d}from"./AXYOJBX6.js";import{g as l}from"./73N3TOJL.js";import{a as i}from"./5YS5V2LK.js";var w=["hoodlock_lock","hoodlock_burn","hoodlock_airdrop_create","hoodlock_airdrop_claim",...p,...u];async function H(e,r,t,s){if(!w.includes(e))throw new i("Unknown HoodLock action; nothing was signed.");let o=async()=>{throw new i("HoodLock does not require a swap for this action.")},n=d({clientFor:()=>s,http:fetch,preview:async a=>({txs:a,changes:[],summary:"Locally reconstructed HoodLock intent."}),quoteSwap:o,buildSwap:o}),c=await[g(n),k(n),...m(n).tools,...f(n).tools,...h(n).tools].find(a=>a.name===e).execute(r,t);if(!Array.isArray(c.txs)||c.txs.length===0)throw new i("HoodLock action has no transactions; use the read route.");return c.txs.map(a=>({...a}))}function I(e,r){if(!r.length||e.length!==r.length||e.some((t,s)=>{let o=r[s];return t.chainId!==o.chainId||!l(t.to,o.to)||!l(t.data,o.data)||t.value!==o.value}))throw new i("HoodLock transaction differs from the locally reconstructed request; nothing was signed.")}export{w as a,H as b,I as c};
@@ -1 +1 @@
1
- import{i as G}from"./E7ASOYQI.js";import{b as j,c as V,d as W}from"./HZUWK5B2.js";import{d as ae,e as L}from"./EAEQOS7Y.js";import{a as N}from"./XCFA73P2.js";import{a as v}from"./6IM6A5VA.js";import{a as R,b as ie,c as se,d as U}from"./RETS2ZEK.js";import{a as S,i as x}from"./XPFVT2EA.js";import{a as o}from"./5YS5V2LK.js";import{decodeEventLog as He,encodeAbiParameters as fe,encodeFunctionData as ye,erc20Abi as Q,getAddress as l,isAddress as $,keccak256 as $e,parseAbi as Ee,parseAbiParameters as pe,toEventSelector as we}from"viem";var A=l(x[4663].hookr.HookrLimitOrders.address),_e=l(x[4663].hookr.HookrRoot.address),ve=l(x[4663].hookr.HookrRouter.address),kt=l(x[4663].hookr.HookrRegistry.address),Ne=l(x[4663].hookr.HookrForwarder.address),Be=l(x[4663].hookr.PoolManager.address),Ot=l(x[4663].hookr.HOOKR_Token.address),Fe=l("0x000000000000000000000000000000000000dEaD"),Me=8388608,ze=200,de=60n,qe=604800n,ce=31536000n,It=10,At=100,ht="500000000000000",St="10000000000000000",ue=4096n,Y=32n,Xe=1e4,Ke=(1n<<127n)-1n,me=(1n<<128n)-1n,Ue=(1n<<160n)-1n,je=(1n<<40n)-1n,Ve=16777215,We=8388607,le=1n<<192n,J=0,F=1,Ge=2,Ye=3,Qe=we("OrderCreated(uint256,address,bytes32,bool,uint128,uint128,uint128,uint40,address)"),Ct=we("OrderCancelled(uint256,address,address,uint256,uint256)"),D=Ee(["function bountyBounds((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut) view returns (uint128 minBounty, uint128 defaultBounty, uint128 maxBounty)","function createOrder(((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut, uint160 sqrtPriceLimitX96, address recipient, uint40 expiry, uint128 bounty) params) payable returns (uint256 orderId)","function cancel(uint256 orderId, address to)","function getOrder(uint256 orderId) view returns (((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, address owner, uint40 createdAt, uint40 expiry, bool zeroForOne, uint8 status, address recipient, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable, uint256 amountOut)","function lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)","function router() view returns (address)","function registry() view returns (address)","function poolManager() view returns (address)","function forwarder() view returns (address)","event OrderCreated(uint256 indexed orderId, address indexed owner, bytes32 indexed poolId, bool zeroForOne, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint40 expiry, address recipient)","event OrderCancelled(uint256 indexed orderId, address indexed owner, address indexed to, uint256 amountIn, uint256 bounty)"]);function B(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ge(e){let t=e.toLowerCase();return t===L.toLowerCase()||t===N.toLowerCase()||t===ae.toLowerCase()}function H(e,t){if(typeof e!="string"||!e.trim())throw new o(`Provide a valid contract address for ${t}. Identify tokens by chain and address, never by symbol.`);let n=e.trim();if(!$(n,{strict:!1}))throw new o(`Invalid token address "${n}" for ${t}. Identify tokens by chain and address, never by symbol.`);return ge(n)?L:l(n)}function be(e){let t=e===void 0?S:Number(e);if(!Number.isSafeInteger(t)||t!==S)throw new o(`Hookr limit orders are only supported on Robinhood Chain (${S}).`);return S}function Ze(e){switch(e){case J:return"None";case F:return"Open";case Ge:return"Filled";case Ye:return"Cancelled";default:return"Unknown"}}function Je(e,t,n=se){if(typeof e!="string"||!/^-?\d+$/.test(e.trim()))throw new o("Signed amount must be an integer string in base units.");let r=e.trim();if(r.startsWith("-")){let i=r.slice(1),u=n(i,t);return u==="0"?"0":`-${u}`}return n(r,t)}function xt(e,t,n="floor"){return ie(e,t,n)}function ke(e){return $e(fe(pe("address, address, uint24, int24, address"),[l(e.currency0),l(e.currency1),e.fee,e.tickSpacing,l(e.hooks)]))}function Oe(e,t){let n=e.toLowerCase();if(new Set([L.toLowerCase(),Fe.toLowerCase(),A.toLowerCase(),ve.toLowerCase(),Ne.toLowerCase(),Be.toLowerCase(),t.toLowerCase()]).has(n))throw new o(`Recipient ${e} is a reserved address and cannot receive Hookr limit order funds.`)}async function Z(e,t,n,r){if(ge(e))return{address:N,symbol:j.symbol,decimals:j.decimals,chainId:t};let i=l(e),u=i.toLowerCase();if(B(r)){let s=typeof r.decimals=="number"&&Number.isInteger(r.decimals)&&r.decimals>=0&&r.decimals<=255?r.decimals:void 0,a=typeof r.symbol=="string"&&r.symbol.trim()?r.symbol.trim():void 0;if(s!==void 0&&a!==void 0)return{address:i,symbol:a,decimals:s,chainId:t}}if(u===V.address.toLowerCase())return{...V,chainId:t};if(u===W.address.toLowerCase())return{...W,chainId:t};try{let[s,a]=await Promise.all([n.readContract({address:i,abi:Q,functionName:"symbol"}),n.readContract({address:i,abi:Q,functionName:"decimals"})]);if(typeof s!="string"||!s.trim()||typeof a!="number"||!Number.isInteger(a)||a<0||a>255)throw new o(`Invalid token metadata for ${i}.`);return{address:i,symbol:s.trim(),decimals:a,chainId:t}}catch{throw new o(`Could not read valid token metadata for ${i}. Refusing to guess token decimals.`)}}function et(e){let t=B(e.key)?e.key:B(e.poolKey)?e.poolKey:void 0,n=t?.fee??e.fee??Me,r=(typeof n=="string"&&/^\d+$/.test(n),Number(n));if(!Number.isInteger(r)||r<0||r>Ve)throw new o("Pool fee must be a valid uint24 integer (default 8388608 for Hookr dynamic fee pools).");let i=t?.tickSpacing??e.tickSpacing??ze,u=(typeof i=="string"&&/^-?\d+$/.test(i),Number(i));if(!Number.isInteger(u)||u<=0||u>We)throw new o("Pool tickSpacing must be a positive int24 integer.");let s=t?.hooks??e.hooks??_e;if(typeof s!="string"||!$(s,{strict:!1}))throw new o("Provide a valid Hookr root contract address for hooks.");let a=l(s);if(t?.currency0!==void 0&&t?.currency1!==void 0||e.currency0!==void 0&&e.currency1!==void 0){let m=H(t?.currency0??e.currency0,"currency0"),I=H(t?.currency1??e.currency1,"currency1");if(m.toLowerCase()===I.toLowerCase())throw new o("Pool currency0 and currency1 must be distinct token addresses.");if(BigInt(m)>=BigInt(I))throw new o("Pool currency0 must sort strictly before currency1 by address.");let k;if(typeof e.zeroForOne=="boolean")k=e.zeroForOne;else if(e.tokenIn!==void 0||e.from!==void 0){let C=H(e.tokenIn??e.from,"tokenIn");if(C.toLowerCase()===m.toLowerCase())k=!0;else if(C.toLowerCase()===I.toLowerCase())k=!1;else throw new o("tokenIn does not match currency0 or currency1 of the pool key.")}else throw new o("Provide zeroForOne (boolean) or tokenIn when specifying a pool key.");return{key:{currency0:m,currency1:I,fee:r,tickSpacing:u,hooks:a},zeroForOne:k}}let w=e.tokenIn??e.from,f=e.tokenOut??e.to;if(w===void 0||f===void 0)throw new o("Provide either key ({ currency0, currency1, fee, tickSpacing, hooks }) with zeroForOne or tokenIn and tokenOut addresses.");let g=H(w,"tokenIn"),b=H(f,"tokenOut");if(g.toLowerCase()===b.toLowerCase())throw new o("Input and output tokens must have distinct addresses.");let y=BigInt(g)<BigInt(b),p=y?g:b,d=y?b:g;if(typeof e.zeroForOne=="boolean"&&e.zeroForOne!==y)throw new o("zeroForOne conflicts with the canonical sorting of tokenIn and tokenOut.");return{key:{currency0:p,currency1:d,fee:r,tickSpacing:u,hooks:a},zeroForOne:y}}function tt(e,t,n){let r=G(t),i=r*r;if(n){let s=U(e.toString(),i.toString(),le.toString(),"ceil");return BigInt(s)}let u=U(e.toString(),le.toString(),i.toString(),"ceil");return BigInt(u)}function T(e,t){if(typeof e=="bigint"){if(e<0n)throw new o(`${t} must be a non-negative integer.`);return e}if(typeof e=="number"){if(!Number.isSafeInteger(e)||e<0)throw new o(`${t} must be a non-negative safe integer.`);return BigInt(e)}if(typeof e=="string")return R(e.trim());throw new o(`Provide ${t} as a decimal base-unit string.`)}async function nt(e,t){if(t!==void 0)return T(t,"now");if(typeof e.getBlock=="function"){let n=await e.getBlock().catch(()=>{throw new o("Could not read the chain timestamp for Hookr order expiry.")});return BigInt(n.timestamp)}throw new o("Could not read the chain timestamp for Hookr order expiry.")}function Ie(e,t){return!e.changes||e.changes.length===0?"no net ERC-20 transfer deltas":e.changes.map(n=>`${Je(n.amount,n.token.decimals,t.formatAmount)} ${n.token.symbol}`).join(", ")}function ot(e,t,n,r){if(!e||!Array.isArray(e.logs))throw new o("Provide a transaction receipt with a logs array.");for(let i of e.logs){if(!i||typeof i.address!="string"||!$(i.address,{strict:!1})||!Array.isArray(i.topics)||typeof i.data!="string"||i.topics.some(u=>typeof u!="string"||!/^0x[0-9a-fA-F]{64}$/.test(u)))throw new o(`Malformed Hookr ${t} receipt log.`);if(i.address.toLowerCase()===A.toLowerCase()&&i.topics[0]?.toLowerCase()===n.toLowerCase()){if(i.topics.length!==4||!/^0x0{24}/i.test(i.topics[2])||t==="OrderCancelled"&&!/^0x0{24}/i.test(i.topics[3])||!/^0x[0-9a-fA-F]*$/.test(i.data)||i.data.length!==2+r*64)throw new o(`Malformed Hookr ${t} receipt log.`);return{topics:i.topics,data:i.data}}}throw new o(`Could not find Hookr ${t} event in transaction receipt logs.`)}function Ae(e){if(e.receipt!==void 0){if(!B(e.receipt)||!Array.isArray(e.receipt.logs))throw new o("Provide a transaction receipt with a logs array.");return it({logs:e.receipt.logs})}if(e.logs!==void 0){if(!Array.isArray(e.logs))throw new o("Provide receipt logs as an array.");return rt(e.logs)}}function he(e){let t=ot(e,"OrderCreated",Qe,6);try{let n=He({abi:D,eventName:"OrderCreated",...t,strict:!0});if(fe(pe("bool, uint128, uint128, uint128, uint40, address"),[n.args.zeroForOne,n.args.amountIn,n.args.minAmountOut,n.args.bounty,n.args.expiry,n.args.recipient]).toLowerCase()!==t.data.toLowerCase())throw new o("Noncanonical Hookr OrderCreated event data.");return{orderId:n.args.orderId.toString(),owner:l(n.args.owner),poolId:n.args.poolId,zeroForOne:n.args.zeroForOne,amountIn:n.args.amountIn.toString(),minAmountOut:n.args.minAmountOut.toString(),bounty:n.args.bounty.toString(),expiry:n.args.expiry.toString(),recipient:l(n.args.recipient)}}catch{throw new o("Malformed Hookr OrderCreated receipt log.")}}function rt(e){return he({logs:e}).orderId}function it(e){return he(e).orderId}function Se(e){if(Array.isArray(e)){let[n,r,i,u,s,a,c,w,f,g,b]=e;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:r,createdAt:i,expiry:u,zeroForOne:s,status:a,recipient:c,amountIn:BigInt(w),minAmountOut:BigInt(f),bounty:BigInt(g),sqrtPriceLimitX96:BigInt(b)}}let t=e;return{key:{currency0:t.key.currency0,currency1:t.key.currency1,fee:Number(t.key.fee),tickSpacing:Number(t.key.tickSpacing),hooks:t.key.hooks},owner:t.owner,createdAt:t.createdAt,expiry:t.expiry,zeroForOne:!!t.zeroForOne,status:Number(t.status),recipient:t.recipient,amountIn:BigInt(t.amountIn),minAmountOut:BigInt(t.minAmountOut),bounty:BigInt(t.bounty),sqrtPriceLimitX96:BigInt(t.sqrtPriceLimitX96)}}async function Ce(e,t,n){let r=T(t,"orderId");if(r<=0n)throw new o("Order ID must be a positive integer.");let i=e.clientFor(S),u=n?.order??await i.readContract({address:A,abi:D,functionName:"getOrder",args:[r]}).catch(()=>{throw new o(`Could not read Hookr order #${r}. Order coverage is incomplete.`)}),s=Se(u),a=Number(s.status);if(s.owner.toLowerCase()===L.toLowerCase()||a===J)throw new o(`Hookr order #${r} does not exist.`);let c={currency0:l(s.key.currency0),currency1:l(s.key.currency1),fee:Number(s.key.fee),tickSpacing:Number(s.key.tickSpacing),hooks:l(s.key.hooks)},w=s.zeroForOne?c.currency0:c.currency1,f=s.zeroForOne?c.currency1:c.currency0,g=m=>{let I=m.toLowerCase(),k=n?.tokens.get(I);if(k)return k;let C=Z(m,S,i);return n?.tokens.set(I,C),C},[b,y]=await Promise.all([g(w),g(f)]),p=!1,d=0n;if(a===F)try{let m=await i.readContract({address:A,abi:D,functionName:"quoteFill",args:[r]});if(typeof m[0]!="boolean"||typeof m[1]!="bigint"||m[1]<0n)throw new o(`Invalid quote for Hookr order #${r}.`);p=m[0],d=m[1]}catch{throw new o(`Could not quote Hookr order #${r}. Fillability and output amount are unknown.`)}return{orderId:r.toString(),poolId:ke(c),key:c,owner:l(s.owner),recipient:l(s.recipient),createdAt:BigInt(s.createdAt).toString(),expiry:BigInt(s.expiry).toString(),zeroForOne:s.zeroForOne,status:a,statusLabel:Ze(a),amountIn:s.amountIn.toString(),minAmountOut:s.minAmountOut.toString(),bounty:s.bounty.toString(),sqrtPriceLimitX96:s.sqrtPriceLimitX96.toString(),tokenIn:b,tokenOut:y,fillable:p,quotedAmountOut:d.toString()}}function st(e){return{name:"hookr_create",inputSchema:{type:"object",properties:{key:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},tokenIn:{type:"string",description:"Input token address on chain 4663."},tokenOut:{type:"string",description:"Output token address on chain 4663."},zeroForOne:{type:"boolean",description:"True when selling currency0 for currency1."},amountIn:{type:"string",description:"Input amount in base units (uint128)."},minAmountOut:{type:"string",description:"Minimum net output amount in base units (uint128)."},tick:{type:"number",description:"Optional limit tick in [-887272, 887272]."},expiry:{type:"string",description:"Order expiry unix timestamp in seconds (uint40)."},deadline:{type:"string",description:"Alias for expiry unix timestamp in seconds."},bounty:{type:"string",description:"Keeper bounty in native ETH wei (uint128)."},recipient:{type:"string",description:"Order output recipient address (must be the signing wallet)."},sqrtPriceLimitX96:{type:"string",description:"Optional sqrtPriceLimitX96 (defaults to 0)."},chainId:{type:"number",description:"Must be 4663 (Robinhood Chain)."}},required:["amountIn"]},async execute(t,n){v(n);let r=l(n),i=be(t.chainId),u=e.clientFor(i),s=Ae(t),{key:a,zeroForOne:c}=et(t),w=c?a.currency0:a.currency1,f=c?a.currency1:a.currency0,[g,b]=await Promise.all([Z(w,i,u,t.tokenInMeta),Z(f,i,u,t.tokenOutMeta)]),y=t.recipient??r;if(typeof y!="string"||!$(y,{strict:!1}))throw new o("Provide a valid recipient address for the Hookr limit order.");let p=l(y);if(Oe(p,a.hooks),p!==r)throw new o("Hookr recipient must be the signing wallet.");if(typeof t.amountIn!="string")throw new o("Provide amountIn as an integer string in base units.");let d=R(t.amountIn);if(d<=0n||d>Ke)throw new o("amountIn must be between 1 and int128.max base units.");if(t.tick!==void 0){let P=Number(t.tick);G(P)}let m;if(t.minAmountOut!==void 0){if(typeof t.minAmountOut!="string")throw new o("Provide minAmountOut as an integer string in base units.");m=R(t.minAmountOut)}else if(t.tick!==void 0)m=tt(d,Number(t.tick),c);else throw new o("Provide minAmountOut in base units (or tick to derive minAmountOut).");if(m<=0n||m>me)throw new o("minAmountOut must be between 1 and uint128.max base units.");let I=t.sqrtPriceLimitX96!==void 0?T(t.sqrtPriceLimitX96,"sqrtPriceLimitX96"):0n;if(I>Ue)throw new o("sqrtPriceLimitX96 exceeds uint160 bounds.");let k=await nt(u,t.now),C=t.expiry??t.deadline,O;if(C!==void 0)O=T(C,"expiry");else if(t.lifetime!==void 0||t.ttlSeconds!==void 0){let P=T(t.lifetime??t.ttlSeconds,"lifetime");O=k+P}else O=k+qe;if(O<k+de)throw new o(`Order expiry (${O}) is expired or below the minimum lifetime of ${de} seconds from block timestamp ${k}.`);if(O>k+ce||O>je)throw new o(`Order expiry (${O}) exceeds the maximum lifetime of ${ce} seconds (365 days).`);let M=await u.readContract({address:A,abi:D,functionName:"bountyBounds",args:[a,c,d,m]}).catch(()=>{throw new o("Could not read Hookr bounty bounds.")}),E=BigInt(M[0]),z=BigInt(M[1]),q=BigInt(M[2]);if(t.bounty!==void 0&&typeof t.bounty!="string")throw new o("Provide bounty as an integer string in base units.");let h=t.bounty!==void 0?R(t.bounty):z,X=E>0n?E:z;if(h<E||X>0n&&h<X)throw new o(`Order keeper bounty (${h} wei) is underbounty: must be at least ${X} wei (default keeper bounty floor).`);if(h>q||h>me)throw new o(`Order keeper bounty (${h} wei) exceeds the maximum allowed bounty of ${q} wei.`);let ee=w.toLowerCase()===L.toLowerCase(),_=[];if(!ee){let P;try{let K=await u.readContract({address:w,abi:Q,functionName:"allowance",args:[r,A]});if(typeof K!="bigint"||K<0n)throw new o("Invalid token allowance.");P=K}catch{throw new o(`Could not read token allowance for ${w}. No approval was prepared.`)}P<d&&_.push(e.approval(w,A,d.toString(),i))}let De=ee?d+h:h,Le=ye({abi:D,functionName:"createOrder",args:[{key:a,zeroForOne:c,amountIn:d,minAmountOut:m,sqrtPriceLimitX96:I,recipient:p,expiry:Number(O),bounty:h}]}),te=e.formatAmount(d.toString(),g.decimals),ne=e.formatAmount(m.toString(),b.decimals),oe=e.formatAmount(h.toString(),18),Pe=e.unsignedTx({to:A,data:Le,value:De.toString(),chainId:i,description:`Create Hookr limit order on ${A}: sell ${te} ${g.symbol} (${g.address}) for at least ${ne} ${b.symbol} (${b.address}) with ${oe} ETH keeper bounty (fee=${a.fee}, tickSpacing=${a.tickSpacing}, expiry=${O}).`});_.push(Pe);let re=await e.preview(_,r),Te=Ie(re,e),Re=ke(a);return{txs:_,summary:`Hookr limit order prepared: sell ${te} ${g.symbol} for at least ${ne} ${b.symbol} (bounty ${oe} ETH, expiry ${O}; preview deltas: ${Te}).`,preview:re,poolId:Re,key:a,zeroForOne:c,amountIn:d.toString(),minAmountOut:m.toString(),bounty:h.toString(),bountyBounds:{minBounty:E.toString(),defaultBounty:z.toString(),maxBounty:q.toString()},expiry:O.toString(),recipient:p,sqrtPriceLimitX96:I.toString(),tokenIn:g,tokenOut:b,...s!==void 0?{orderId:s}:{}}}}}function at(e){return{name:"hookr_cancel",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"Hookr order ID to cancel (uint256 decimal string)."},to:{type:"string",description:"Recipient address for the refunded principal and bounty (must be the signing wallet)."},chainId:{type:"number",description:"Must be 4663 (Robinhood Chain)."}},required:["orderId"]},async execute(t,n){v(n);let r=l(n),i=be(t.chainId),u=Ae(t),s=t.orderId??t.id??u;if(s===void 0)throw new o("Provide orderId to cancel a Hookr limit order.");let a=T(s,"orderId");if(a<=0n)throw new o("orderId must be a positive integer.");let c=await Ce(e,a);if(c.owner.toLowerCase()!==r.toLowerCase())throw new o(`Unauthorized cancellation: only the order owner (${c.owner}) can cancel Hookr order #${a} (caller is ${r}).`);if(c.status!==F)throw new o(`Hookr order #${a} is not open (current status: ${c.statusLabel}).`);let w=t.to??r;if(typeof w!="string"||!$(w,{strict:!1}))throw new o("Provide a valid refund recipient address for cancel.");let f=l(w);if(Oe(f,c.key.hooks),f!==r)throw new o("Hookr refund recipient must be the signing wallet.");let g=ye({abi:D,functionName:"cancel",args:[a,f]}),b=e.formatAmount(c.amountIn,c.tokenIn.decimals),y=e.formatAmount(c.bounty,18),p=e.unsignedTx({to:A,data:g,value:"0",chainId:i,description:`Cancel Hookr limit order #${a} on ${A} and refund ${b} ${c.tokenIn.symbol} plus ${y} ETH bounty to ${f}.`}),d=await e.preview([p],r),m=Ie(d,e);return{txs:[p],summary:`Cancel Hookr limit order #${a}: refund ${b} ${c.tokenIn.symbol} and ${y} ETH bounty to ${f} (preview deltas: ${m}).`,preview:d,orderId:a.toString(),to:f,refundedAmountIn:c.amountIn,refundedBounty:c.bounty,tokenIn:c.tokenIn,tokenOut:c.tokenOut}}}}function dt(e){let t=performance.now()+Xe;return new Proxy(e,{get(n,r,i){return r!=="readContract"?Reflect.get(n,r,i):async(...u)=>{let s=t-performance.now(),a=()=>new o("Hookr scan deadline exceeded. Order coverage is incomplete; retry later.");if(s<=0)throw a();let c;try{return await Promise.race([n.readContract(...u),new Promise((w,f)=>{c=setTimeout(()=>f(a()),s)})])}finally{c!==void 0&&clearTimeout(c)}}}})}function ct(e){return async t=>{v(t);let n=l(t),r=dt(e.clientFor(S)),i={...e,clientFor:()=>r},u=await r.readContract({address:A,abi:D,functionName:"lastOrderId"}).catch(()=>{throw new o("Could not read the last Hookr order ID. Order coverage is incomplete.")});if(typeof u!="bigint"||u<0n)throw new o("Could not read a valid last Hookr order ID. Order coverage is incomplete.");let s=u,a=s>ue?s-ue+1n:1n;if(s<=0n)return[];let c=[],w=new Map;for(let f=a;f<=s;f+=Y){let g=Array.from({length:Number(s-f+1n<Y?s-f+1n:Y)},(y,p)=>f+BigInt(p)),b=await Promise.all(g.map(async y=>{let p=await r.readContract({address:A,abi:D,functionName:"getOrder",args:[y]}).catch(()=>{throw new o(`Could not read Hookr order #${y}. Order coverage is incomplete.`)}),d=Se(p);if(d.owner.toLowerCase()===L||Number(d.status)===J)throw new o(`Hookr order #${y} does not exist. Order coverage is incomplete.`);return{id:y,order:d}}));for(let{id:y,order:p}of b){if(p.owner.toLowerCase()!==n.toLowerCase()||Number(p.status)!==F)continue;let d=await Ce(i,y,{order:p,tokens:w}),m=[{token:d.tokenIn,amount:d.amountIn}];BigInt(d.bounty)>0n&&m.push({token:{address:N,symbol:"ETH",decimals:18,chainId:S},amount:d.bounty});let I=e.formatAmount(d.amountIn,d.tokenIn.decimals),k=e.formatAmount(d.minAmountOut,d.tokenOut.decimals),C=e.formatAmount(d.bounty,18),O=e.formatAmount(d.quotedAmountOut,d.tokenOut.decimals);c.push({module:"hookr",id:d.orderId,chainId:S,assets:m,description:`Hookr open limit order #${d.orderId}: sell ${I} ${d.tokenIn.symbol} (${d.tokenIn.address}) for at least ${k} ${d.tokenOut.symbol} (${d.tokenOut.address}), bounty ${C} ETH, expiry ${d.expiry}, fillable=${d.fillable} (quoted output ${O} ${d.tokenOut.symbol}).`})}}return a>1n&&c.push({module:"hookr",id:"coverage",chainId:S,assets:[],description:`Hookr order coverage is incomplete: scanned IDs ${a}-${s}. Older orders require an explicit order ID.`}),c}}var xe=e=>{let t=[st(e),at(e)],n=ct(e);return{tools:t,positions:n}},Dt=xe,Lt=xe;export{A as a,_e as b,ve as c,kt as d,Ne as e,Be as f,Ot as g,Fe as h,Me as i,ze as j,de as k,qe as l,ce as m,It as n,At as o,ht as p,St as q,ue as r,Xe as s,J as t,F as u,Ge as v,Ye as w,Qe as x,Ct as y,D as z,Je as A,xt as B,ke as C,ot as D,he as E,rt as F,it as G,Se as H,Ce as I,st as J,at as K,dt as L,ct as M,xe as N,Dt as O,Lt as P};
1
+ import{i as G}from"./NBRMUFJP.js";import{b as j,c as V,d as W}from"./46ZA2R5L.js";import{d as ae,e as L}from"./CAU44UWP.js";import{a as N}from"./VJ3W2V3B.js";import{a as v}from"./6IM6A5VA.js";import{a as R,b as ie,c as se,d as U}from"./RETS2ZEK.js";import{a as S,i as x}from"./XPFVT2EA.js";import{a as o}from"./5YS5V2LK.js";import{decodeEventLog as He,encodeAbiParameters as fe,encodeFunctionData as ye,erc20Abi as Q,getAddress as l,isAddress as $,keccak256 as $e,parseAbi as Ee,parseAbiParameters as pe,toEventSelector as we}from"viem";var A=l(x[4663].hookr.HookrLimitOrders.address),_e=l(x[4663].hookr.HookrRoot.address),ve=l(x[4663].hookr.HookrRouter.address),kt=l(x[4663].hookr.HookrRegistry.address),Ne=l(x[4663].hookr.HookrForwarder.address),Be=l(x[4663].hookr.PoolManager.address),Ot=l(x[4663].hookr.HOOKR_Token.address),Fe=l("0x000000000000000000000000000000000000dEaD"),Me=8388608,ze=200,de=60n,qe=604800n,ce=31536000n,It=10,At=100,ht="500000000000000",St="10000000000000000",ue=4096n,Y=32n,Xe=1e4,Ke=(1n<<127n)-1n,me=(1n<<128n)-1n,Ue=(1n<<160n)-1n,je=(1n<<40n)-1n,Ve=16777215,We=8388607,le=1n<<192n,J=0,F=1,Ge=2,Ye=3,Qe=we("OrderCreated(uint256,address,bytes32,bool,uint128,uint128,uint128,uint40,address)"),Ct=we("OrderCancelled(uint256,address,address,uint256,uint256)"),D=Ee(["function bountyBounds((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut) view returns (uint128 minBounty, uint128 defaultBounty, uint128 maxBounty)","function createOrder(((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut, uint160 sqrtPriceLimitX96, address recipient, uint40 expiry, uint128 bounty) params) payable returns (uint256 orderId)","function cancel(uint256 orderId, address to)","function getOrder(uint256 orderId) view returns (((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, address owner, uint40 createdAt, uint40 expiry, bool zeroForOne, uint8 status, address recipient, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable, uint256 amountOut)","function lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)","function router() view returns (address)","function registry() view returns (address)","function poolManager() view returns (address)","function forwarder() view returns (address)","event OrderCreated(uint256 indexed orderId, address indexed owner, bytes32 indexed poolId, bool zeroForOne, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint40 expiry, address recipient)","event OrderCancelled(uint256 indexed orderId, address indexed owner, address indexed to, uint256 amountIn, uint256 bounty)"]);function B(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ge(e){let t=e.toLowerCase();return t===L.toLowerCase()||t===N.toLowerCase()||t===ae.toLowerCase()}function H(e,t){if(typeof e!="string"||!e.trim())throw new o(`Provide a valid contract address for ${t}. Identify tokens by chain and address, never by symbol.`);let n=e.trim();if(!$(n,{strict:!1}))throw new o(`Invalid token address "${n}" for ${t}. Identify tokens by chain and address, never by symbol.`);return ge(n)?L:l(n)}function be(e){let t=e===void 0?S:Number(e);if(!Number.isSafeInteger(t)||t!==S)throw new o(`Hookr limit orders are only supported on Robinhood Chain (${S}).`);return S}function Ze(e){switch(e){case J:return"None";case F:return"Open";case Ge:return"Filled";case Ye:return"Cancelled";default:return"Unknown"}}function Je(e,t,n=se){if(typeof e!="string"||!/^-?\d+$/.test(e.trim()))throw new o("Signed amount must be an integer string in base units.");let r=e.trim();if(r.startsWith("-")){let i=r.slice(1),u=n(i,t);return u==="0"?"0":`-${u}`}return n(r,t)}function xt(e,t,n="floor"){return ie(e,t,n)}function ke(e){return $e(fe(pe("address, address, uint24, int24, address"),[l(e.currency0),l(e.currency1),e.fee,e.tickSpacing,l(e.hooks)]))}function Oe(e,t){let n=e.toLowerCase();if(new Set([L.toLowerCase(),Fe.toLowerCase(),A.toLowerCase(),ve.toLowerCase(),Ne.toLowerCase(),Be.toLowerCase(),t.toLowerCase()]).has(n))throw new o(`Recipient ${e} is a reserved address and cannot receive Hookr limit order funds.`)}async function Z(e,t,n,r){if(ge(e))return{address:N,symbol:j.symbol,decimals:j.decimals,chainId:t};let i=l(e),u=i.toLowerCase();if(B(r)){let s=typeof r.decimals=="number"&&Number.isInteger(r.decimals)&&r.decimals>=0&&r.decimals<=255?r.decimals:void 0,a=typeof r.symbol=="string"&&r.symbol.trim()?r.symbol.trim():void 0;if(s!==void 0&&a!==void 0)return{address:i,symbol:a,decimals:s,chainId:t}}if(u===V.address.toLowerCase())return{...V,chainId:t};if(u===W.address.toLowerCase())return{...W,chainId:t};try{let[s,a]=await Promise.all([n.readContract({address:i,abi:Q,functionName:"symbol"}),n.readContract({address:i,abi:Q,functionName:"decimals"})]);if(typeof s!="string"||!s.trim()||typeof a!="number"||!Number.isInteger(a)||a<0||a>255)throw new o(`Invalid token metadata for ${i}.`);return{address:i,symbol:s.trim(),decimals:a,chainId:t}}catch{throw new o(`Could not read valid token metadata for ${i}. Refusing to guess token decimals.`)}}function et(e){let t=B(e.key)?e.key:B(e.poolKey)?e.poolKey:void 0,n=t?.fee??e.fee??Me,r=(typeof n=="string"&&/^\d+$/.test(n),Number(n));if(!Number.isInteger(r)||r<0||r>Ve)throw new o("Pool fee must be a valid uint24 integer (default 8388608 for Hookr dynamic fee pools).");let i=t?.tickSpacing??e.tickSpacing??ze,u=(typeof i=="string"&&/^-?\d+$/.test(i),Number(i));if(!Number.isInteger(u)||u<=0||u>We)throw new o("Pool tickSpacing must be a positive int24 integer.");let s=t?.hooks??e.hooks??_e;if(typeof s!="string"||!$(s,{strict:!1}))throw new o("Provide a valid Hookr root contract address for hooks.");let a=l(s);if(t?.currency0!==void 0&&t?.currency1!==void 0||e.currency0!==void 0&&e.currency1!==void 0){let m=H(t?.currency0??e.currency0,"currency0"),I=H(t?.currency1??e.currency1,"currency1");if(m.toLowerCase()===I.toLowerCase())throw new o("Pool currency0 and currency1 must be distinct token addresses.");if(BigInt(m)>=BigInt(I))throw new o("Pool currency0 must sort strictly before currency1 by address.");let k;if(typeof e.zeroForOne=="boolean")k=e.zeroForOne;else if(e.tokenIn!==void 0||e.from!==void 0){let C=H(e.tokenIn??e.from,"tokenIn");if(C.toLowerCase()===m.toLowerCase())k=!0;else if(C.toLowerCase()===I.toLowerCase())k=!1;else throw new o("tokenIn does not match currency0 or currency1 of the pool key.")}else throw new o("Provide zeroForOne (boolean) or tokenIn when specifying a pool key.");return{key:{currency0:m,currency1:I,fee:r,tickSpacing:u,hooks:a},zeroForOne:k}}let w=e.tokenIn??e.from,f=e.tokenOut??e.to;if(w===void 0||f===void 0)throw new o("Provide either key ({ currency0, currency1, fee, tickSpacing, hooks }) with zeroForOne or tokenIn and tokenOut addresses.");let g=H(w,"tokenIn"),b=H(f,"tokenOut");if(g.toLowerCase()===b.toLowerCase())throw new o("Input and output tokens must have distinct addresses.");let y=BigInt(g)<BigInt(b),p=y?g:b,d=y?b:g;if(typeof e.zeroForOne=="boolean"&&e.zeroForOne!==y)throw new o("zeroForOne conflicts with the canonical sorting of tokenIn and tokenOut.");return{key:{currency0:p,currency1:d,fee:r,tickSpacing:u,hooks:a},zeroForOne:y}}function tt(e,t,n){let r=G(t),i=r*r;if(n){let s=U(e.toString(),i.toString(),le.toString(),"ceil");return BigInt(s)}let u=U(e.toString(),le.toString(),i.toString(),"ceil");return BigInt(u)}function T(e,t){if(typeof e=="bigint"){if(e<0n)throw new o(`${t} must be a non-negative integer.`);return e}if(typeof e=="number"){if(!Number.isSafeInteger(e)||e<0)throw new o(`${t} must be a non-negative safe integer.`);return BigInt(e)}if(typeof e=="string")return R(e.trim());throw new o(`Provide ${t} as a decimal base-unit string.`)}async function nt(e,t){if(t!==void 0)return T(t,"now");if(typeof e.getBlock=="function"){let n=await e.getBlock().catch(()=>{throw new o("Could not read the chain timestamp for Hookr order expiry.")});return BigInt(n.timestamp)}throw new o("Could not read the chain timestamp for Hookr order expiry.")}function Ie(e,t){return!e.changes||e.changes.length===0?"no net ERC-20 transfer deltas":e.changes.map(n=>`${Je(n.amount,n.token.decimals,t.formatAmount)} ${n.token.symbol}`).join(", ")}function ot(e,t,n,r){if(!e||!Array.isArray(e.logs))throw new o("Provide a transaction receipt with a logs array.");for(let i of e.logs){if(!i||typeof i.address!="string"||!$(i.address,{strict:!1})||!Array.isArray(i.topics)||typeof i.data!="string"||i.topics.some(u=>typeof u!="string"||!/^0x[0-9a-fA-F]{64}$/.test(u)))throw new o(`Malformed Hookr ${t} receipt log.`);if(i.address.toLowerCase()===A.toLowerCase()&&i.topics[0]?.toLowerCase()===n.toLowerCase()){if(i.topics.length!==4||!/^0x0{24}/i.test(i.topics[2])||t==="OrderCancelled"&&!/^0x0{24}/i.test(i.topics[3])||!/^0x[0-9a-fA-F]*$/.test(i.data)||i.data.length!==2+r*64)throw new o(`Malformed Hookr ${t} receipt log.`);return{topics:i.topics,data:i.data}}}throw new o(`Could not find Hookr ${t} event in transaction receipt logs.`)}function Ae(e){if(e.receipt!==void 0){if(!B(e.receipt)||!Array.isArray(e.receipt.logs))throw new o("Provide a transaction receipt with a logs array.");return it({logs:e.receipt.logs})}if(e.logs!==void 0){if(!Array.isArray(e.logs))throw new o("Provide receipt logs as an array.");return rt(e.logs)}}function he(e){let t=ot(e,"OrderCreated",Qe,6);try{let n=He({abi:D,eventName:"OrderCreated",...t,strict:!0});if(fe(pe("bool, uint128, uint128, uint128, uint40, address"),[n.args.zeroForOne,n.args.amountIn,n.args.minAmountOut,n.args.bounty,n.args.expiry,n.args.recipient]).toLowerCase()!==t.data.toLowerCase())throw new o("Noncanonical Hookr OrderCreated event data.");return{orderId:n.args.orderId.toString(),owner:l(n.args.owner),poolId:n.args.poolId,zeroForOne:n.args.zeroForOne,amountIn:n.args.amountIn.toString(),minAmountOut:n.args.minAmountOut.toString(),bounty:n.args.bounty.toString(),expiry:n.args.expiry.toString(),recipient:l(n.args.recipient)}}catch{throw new o("Malformed Hookr OrderCreated receipt log.")}}function rt(e){return he({logs:e}).orderId}function it(e){return he(e).orderId}function Se(e){if(Array.isArray(e)){let[n,r,i,u,s,a,c,w,f,g,b]=e;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:r,createdAt:i,expiry:u,zeroForOne:s,status:a,recipient:c,amountIn:BigInt(w),minAmountOut:BigInt(f),bounty:BigInt(g),sqrtPriceLimitX96:BigInt(b)}}let t=e;return{key:{currency0:t.key.currency0,currency1:t.key.currency1,fee:Number(t.key.fee),tickSpacing:Number(t.key.tickSpacing),hooks:t.key.hooks},owner:t.owner,createdAt:t.createdAt,expiry:t.expiry,zeroForOne:!!t.zeroForOne,status:Number(t.status),recipient:t.recipient,amountIn:BigInt(t.amountIn),minAmountOut:BigInt(t.minAmountOut),bounty:BigInt(t.bounty),sqrtPriceLimitX96:BigInt(t.sqrtPriceLimitX96)}}async function Ce(e,t,n){let r=T(t,"orderId");if(r<=0n)throw new o("Order ID must be a positive integer.");let i=e.clientFor(S),u=n?.order??await i.readContract({address:A,abi:D,functionName:"getOrder",args:[r]}).catch(()=>{throw new o(`Could not read Hookr order #${r}. Order coverage is incomplete.`)}),s=Se(u),a=Number(s.status);if(s.owner.toLowerCase()===L.toLowerCase()||a===J)throw new o(`Hookr order #${r} does not exist.`);let c={currency0:l(s.key.currency0),currency1:l(s.key.currency1),fee:Number(s.key.fee),tickSpacing:Number(s.key.tickSpacing),hooks:l(s.key.hooks)},w=s.zeroForOne?c.currency0:c.currency1,f=s.zeroForOne?c.currency1:c.currency0,g=m=>{let I=m.toLowerCase(),k=n?.tokens.get(I);if(k)return k;let C=Z(m,S,i);return n?.tokens.set(I,C),C},[b,y]=await Promise.all([g(w),g(f)]),p=!1,d=0n;if(a===F)try{let m=await i.readContract({address:A,abi:D,functionName:"quoteFill",args:[r]});if(typeof m[0]!="boolean"||typeof m[1]!="bigint"||m[1]<0n)throw new o(`Invalid quote for Hookr order #${r}.`);p=m[0],d=m[1]}catch{throw new o(`Could not quote Hookr order #${r}. Fillability and output amount are unknown.`)}return{orderId:r.toString(),poolId:ke(c),key:c,owner:l(s.owner),recipient:l(s.recipient),createdAt:BigInt(s.createdAt).toString(),expiry:BigInt(s.expiry).toString(),zeroForOne:s.zeroForOne,status:a,statusLabel:Ze(a),amountIn:s.amountIn.toString(),minAmountOut:s.minAmountOut.toString(),bounty:s.bounty.toString(),sqrtPriceLimitX96:s.sqrtPriceLimitX96.toString(),tokenIn:b,tokenOut:y,fillable:p,quotedAmountOut:d.toString()}}function st(e){return{name:"hookr_create",inputSchema:{type:"object",properties:{key:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},tokenIn:{type:"string",description:"Input token address on chain 4663."},tokenOut:{type:"string",description:"Output token address on chain 4663."},zeroForOne:{type:"boolean",description:"True when selling currency0 for currency1."},amountIn:{type:"string",description:"Input amount in base units (uint128)."},minAmountOut:{type:"string",description:"Minimum net output amount in base units (uint128)."},tick:{type:"number",description:"Optional limit tick in [-887272, 887272]."},expiry:{type:"string",description:"Order expiry unix timestamp in seconds (uint40)."},deadline:{type:"string",description:"Alias for expiry unix timestamp in seconds."},bounty:{type:"string",description:"Keeper bounty in native ETH wei (uint128)."},recipient:{type:"string",description:"Order output recipient address (must be the signing wallet)."},sqrtPriceLimitX96:{type:"string",description:"Optional sqrtPriceLimitX96 (defaults to 0)."},chainId:{type:"number",description:"Must be 4663 (Robinhood Chain)."}},required:["amountIn"]},async execute(t,n){v(n);let r=l(n),i=be(t.chainId),u=e.clientFor(i),s=Ae(t),{key:a,zeroForOne:c}=et(t),w=c?a.currency0:a.currency1,f=c?a.currency1:a.currency0,[g,b]=await Promise.all([Z(w,i,u,t.tokenInMeta),Z(f,i,u,t.tokenOutMeta)]),y=t.recipient??r;if(typeof y!="string"||!$(y,{strict:!1}))throw new o("Provide a valid recipient address for the Hookr limit order.");let p=l(y);if(Oe(p,a.hooks),p!==r)throw new o("Hookr recipient must be the signing wallet.");if(typeof t.amountIn!="string")throw new o("Provide amountIn as an integer string in base units.");let d=R(t.amountIn);if(d<=0n||d>Ke)throw new o("amountIn must be between 1 and int128.max base units.");if(t.tick!==void 0){let P=Number(t.tick);G(P)}let m;if(t.minAmountOut!==void 0){if(typeof t.minAmountOut!="string")throw new o("Provide minAmountOut as an integer string in base units.");m=R(t.minAmountOut)}else if(t.tick!==void 0)m=tt(d,Number(t.tick),c);else throw new o("Provide minAmountOut in base units (or tick to derive minAmountOut).");if(m<=0n||m>me)throw new o("minAmountOut must be between 1 and uint128.max base units.");let I=t.sqrtPriceLimitX96!==void 0?T(t.sqrtPriceLimitX96,"sqrtPriceLimitX96"):0n;if(I>Ue)throw new o("sqrtPriceLimitX96 exceeds uint160 bounds.");let k=await nt(u,t.now),C=t.expiry??t.deadline,O;if(C!==void 0)O=T(C,"expiry");else if(t.lifetime!==void 0||t.ttlSeconds!==void 0){let P=T(t.lifetime??t.ttlSeconds,"lifetime");O=k+P}else O=k+qe;if(O<k+de)throw new o(`Order expiry (${O}) is expired or below the minimum lifetime of ${de} seconds from block timestamp ${k}.`);if(O>k+ce||O>je)throw new o(`Order expiry (${O}) exceeds the maximum lifetime of ${ce} seconds (365 days).`);let M=await u.readContract({address:A,abi:D,functionName:"bountyBounds",args:[a,c,d,m]}).catch(()=>{throw new o("Could not read Hookr bounty bounds.")}),E=BigInt(M[0]),z=BigInt(M[1]),q=BigInt(M[2]);if(t.bounty!==void 0&&typeof t.bounty!="string")throw new o("Provide bounty as an integer string in base units.");let h=t.bounty!==void 0?R(t.bounty):z,X=E>0n?E:z;if(h<E||X>0n&&h<X)throw new o(`Order keeper bounty (${h} wei) is underbounty: must be at least ${X} wei (default keeper bounty floor).`);if(h>q||h>me)throw new o(`Order keeper bounty (${h} wei) exceeds the maximum allowed bounty of ${q} wei.`);let ee=w.toLowerCase()===L.toLowerCase(),_=[];if(!ee){let P;try{let K=await u.readContract({address:w,abi:Q,functionName:"allowance",args:[r,A]});if(typeof K!="bigint"||K<0n)throw new o("Invalid token allowance.");P=K}catch{throw new o(`Could not read token allowance for ${w}. No approval was prepared.`)}P<d&&_.push(e.approval(w,A,d.toString(),i))}let De=ee?d+h:h,Le=ye({abi:D,functionName:"createOrder",args:[{key:a,zeroForOne:c,amountIn:d,minAmountOut:m,sqrtPriceLimitX96:I,recipient:p,expiry:Number(O),bounty:h}]}),te=e.formatAmount(d.toString(),g.decimals),ne=e.formatAmount(m.toString(),b.decimals),oe=e.formatAmount(h.toString(),18),Pe=e.unsignedTx({to:A,data:Le,value:De.toString(),chainId:i,description:`Create Hookr limit order on ${A}: sell ${te} ${g.symbol} (${g.address}) for at least ${ne} ${b.symbol} (${b.address}) with ${oe} ETH keeper bounty (fee=${a.fee}, tickSpacing=${a.tickSpacing}, expiry=${O}).`});_.push(Pe);let re=await e.preview(_,r),Te=Ie(re,e),Re=ke(a);return{txs:_,summary:`Hookr limit order prepared: sell ${te} ${g.symbol} for at least ${ne} ${b.symbol} (bounty ${oe} ETH, expiry ${O}; preview deltas: ${Te}).`,preview:re,poolId:Re,key:a,zeroForOne:c,amountIn:d.toString(),minAmountOut:m.toString(),bounty:h.toString(),bountyBounds:{minBounty:E.toString(),defaultBounty:z.toString(),maxBounty:q.toString()},expiry:O.toString(),recipient:p,sqrtPriceLimitX96:I.toString(),tokenIn:g,tokenOut:b,...s!==void 0?{orderId:s}:{}}}}}function at(e){return{name:"hookr_cancel",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"Hookr order ID to cancel (uint256 decimal string)."},to:{type:"string",description:"Recipient address for the refunded principal and bounty (must be the signing wallet)."},chainId:{type:"number",description:"Must be 4663 (Robinhood Chain)."}},required:["orderId"]},async execute(t,n){v(n);let r=l(n),i=be(t.chainId),u=Ae(t),s=t.orderId??t.id??u;if(s===void 0)throw new o("Provide orderId to cancel a Hookr limit order.");let a=T(s,"orderId");if(a<=0n)throw new o("orderId must be a positive integer.");let c=await Ce(e,a);if(c.owner.toLowerCase()!==r.toLowerCase())throw new o(`Unauthorized cancellation: only the order owner (${c.owner}) can cancel Hookr order #${a} (caller is ${r}).`);if(c.status!==F)throw new o(`Hookr order #${a} is not open (current status: ${c.statusLabel}).`);let w=t.to??r;if(typeof w!="string"||!$(w,{strict:!1}))throw new o("Provide a valid refund recipient address for cancel.");let f=l(w);if(Oe(f,c.key.hooks),f!==r)throw new o("Hookr refund recipient must be the signing wallet.");let g=ye({abi:D,functionName:"cancel",args:[a,f]}),b=e.formatAmount(c.amountIn,c.tokenIn.decimals),y=e.formatAmount(c.bounty,18),p=e.unsignedTx({to:A,data:g,value:"0",chainId:i,description:`Cancel Hookr limit order #${a} on ${A} and refund ${b} ${c.tokenIn.symbol} plus ${y} ETH bounty to ${f}.`}),d=await e.preview([p],r),m=Ie(d,e);return{txs:[p],summary:`Cancel Hookr limit order #${a}: refund ${b} ${c.tokenIn.symbol} and ${y} ETH bounty to ${f} (preview deltas: ${m}).`,preview:d,orderId:a.toString(),to:f,refundedAmountIn:c.amountIn,refundedBounty:c.bounty,tokenIn:c.tokenIn,tokenOut:c.tokenOut}}}}function dt(e){let t=performance.now()+Xe;return new Proxy(e,{get(n,r,i){return r!=="readContract"?Reflect.get(n,r,i):async(...u)=>{let s=t-performance.now(),a=()=>new o("Hookr scan deadline exceeded. Order coverage is incomplete; retry later.");if(s<=0)throw a();let c;try{return await Promise.race([n.readContract(...u),new Promise((w,f)=>{c=setTimeout(()=>f(a()),s)})])}finally{c!==void 0&&clearTimeout(c)}}}})}function ct(e){return async t=>{v(t);let n=l(t),r=dt(e.clientFor(S)),i={...e,clientFor:()=>r},u=await r.readContract({address:A,abi:D,functionName:"lastOrderId"}).catch(()=>{throw new o("Could not read the last Hookr order ID. Order coverage is incomplete.")});if(typeof u!="bigint"||u<0n)throw new o("Could not read a valid last Hookr order ID. Order coverage is incomplete.");let s=u,a=s>ue?s-ue+1n:1n;if(s<=0n)return[];let c=[],w=new Map;for(let f=a;f<=s;f+=Y){let g=Array.from({length:Number(s-f+1n<Y?s-f+1n:Y)},(y,p)=>f+BigInt(p)),b=await Promise.all(g.map(async y=>{let p=await r.readContract({address:A,abi:D,functionName:"getOrder",args:[y]}).catch(()=>{throw new o(`Could not read Hookr order #${y}. Order coverage is incomplete.`)}),d=Se(p);if(d.owner.toLowerCase()===L||Number(d.status)===J)throw new o(`Hookr order #${y} does not exist. Order coverage is incomplete.`);return{id:y,order:d}}));for(let{id:y,order:p}of b){if(p.owner.toLowerCase()!==n.toLowerCase()||Number(p.status)!==F)continue;let d=await Ce(i,y,{order:p,tokens:w}),m=[{token:d.tokenIn,amount:d.amountIn}];BigInt(d.bounty)>0n&&m.push({token:{address:N,symbol:"ETH",decimals:18,chainId:S},amount:d.bounty});let I=e.formatAmount(d.amountIn,d.tokenIn.decimals),k=e.formatAmount(d.minAmountOut,d.tokenOut.decimals),C=e.formatAmount(d.bounty,18),O=e.formatAmount(d.quotedAmountOut,d.tokenOut.decimals);c.push({module:"hookr",id:d.orderId,chainId:S,assets:m,description:`Hookr open limit order #${d.orderId}: sell ${I} ${d.tokenIn.symbol} (${d.tokenIn.address}) for at least ${k} ${d.tokenOut.symbol} (${d.tokenOut.address}), bounty ${C} ETH, expiry ${d.expiry}, fillable=${d.fillable} (quoted output ${O} ${d.tokenOut.symbol}).`})}}return a>1n&&c.push({module:"hookr",id:"coverage",chainId:S,assets:[],description:`Hookr order coverage is incomplete: scanned IDs ${a}-${s}. Older orders require an explicit order ID.`}),c}}var xe=e=>{let t=[st(e),at(e)],n=ct(e);return{tools:t,positions:n}},Dt=xe,Lt=xe;export{A as a,_e as b,ve as c,kt as d,Ne as e,Be as f,Ot as g,Fe as h,Me as i,ze as j,de as k,qe as l,ce as m,It as n,At as o,ht as p,St as q,ue as r,Xe as s,J as t,F as u,Ge as v,Ye as w,Qe as x,Ct as y,D as z,Je as A,xt as B,ke as C,ot as D,he as E,rt as F,it as G,Se as H,Ce as I,st as J,at as K,dt as L,ct as M,xe as N,Dt as O,Lt as P};
@@ -1 +1 @@
1
- import{d as y,h as A}from"./JVTVOK6P.js";import{b as p,e as f,g as v}from"./ITIIHCZK.js";import{c as l}from"./73N3TOJL.js";import{a as g}from"./XPFVT2EA.js";import{a as r}from"./5YS5V2LK.js";import{parseAbi as I,zeroAddress as N}from"viem";var S=I(["function observe(uint32[] secondsAgos) view returns (int56[] tickCumulatives,uint160[] secondsPerLiquidityCumulativeX128s)"]);function j(s){return{tools:[{name:"uniswap_oracle",inputSchema:{type:"object",additionalProperties:!1,required:["token0","token1","fee","secondsAgo"],properties:{token0:l,token1:l,fee:{type:"integer",minimum:0,maximum:999999},secondsAgo:{type:"integer",minimum:1,maximum:4294967295}}},async execute(t){v(t,["token0","token1","fee","secondsAgo"]);let a=p(t.token0),c=p(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 m=s.clientFor(g),i=await m.getBlockNumber(),u=await m.readContract({address:y.factory,abi:A,functionName:"getPool",args:[a,c,o],blockNumber:i});if(u===N)throw new r("No factory-verified v3 pool exists for this oracle.");let[[n,k],w,h]=await Promise.all([m.readContract({address:u,abi:S,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 d=n[1]-n[0],b=BigInt(e),P=d/b-(d<0n&&d%b!==0n?1n:0n);return{pool:u,token0:w,token1:h,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{j as a};
1
+ import{d as y,h as A}from"./R7D256HG.js";import{b as p,e as f,g as v}from"./64AF7ECA.js";import{c as l}from"./73N3TOJL.js";import{a as g}from"./XPFVT2EA.js";import{a as r}from"./5YS5V2LK.js";import{parseAbi as I,zeroAddress as N}from"viem";var S=I(["function observe(uint32[] secondsAgos) view returns (int56[] tickCumulatives,uint160[] secondsPerLiquidityCumulativeX128s)"]);function j(s){return{tools:[{name:"uniswap_oracle",inputSchema:{type:"object",additionalProperties:!1,required:["token0","token1","fee","secondsAgo"],properties:{token0:l,token1:l,fee:{type:"integer",minimum:0,maximum:999999},secondsAgo:{type:"integer",minimum:1,maximum:4294967295}}},async execute(t){v(t,["token0","token1","fee","secondsAgo"]);let a=p(t.token0),c=p(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 m=s.clientFor(g),i=await m.getBlockNumber(),u=await m.readContract({address:y.factory,abi:A,functionName:"getPool",args:[a,c,o],blockNumber:i});if(u===N)throw new r("No factory-verified v3 pool exists for this oracle.");let[[n,k],w,h]=await Promise.all([m.readContract({address:u,abi:S,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 d=n[1]-n[0],b=BigInt(e),P=d/b-(d<0n&&d%b!==0n?1n:0n);return{pool:u,token0:w,token1:h,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{j as a};
@@ -1 +1 @@
1
- import{a as B}from"./CXMC3T6B.js";import{c as V}from"./7B5UH2VS.js";import{c as P}from"./T6MTTMLQ.js";import{b as M}from"./LFKSXD3S.js";import{k as R}from"./O47JXRXN.js";import{c as _}from"./OJP7Y4AM.js";import{b as H,o as F}from"./EAEQOS7Y.js";import{b as W}from"./AXYOJBX6.js";import{a as k}from"./6IM6A5VA.js";import{a as G}from"./UWOFA6GV.js";import{g as A,m as I,n as O}from"./73N3TOJL.js";import{a as m,i as U}from"./XPFVT2EA.js";import{a as u}from"./5YS5V2LK.js";import{encodeFunctionData as C,getAddress as b,parseAbi as q}from"viem";var c=q(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)","function balanceOf(address) view returns (uint256)","function previewDeposit(uint256 assets) view returns (uint256)","function previewRedeem(uint256 shares) view returns (uint256)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),J=q(["function deposit() payable"]),f=U[m],T=[{key:"core",name:"Longbow Core USDG",vault:f.vaults.longbowCore.address,asset:f.tokens.USDG.address,symbol:"USDG",decimals:6},{key:"frontier",name:"Longbow Frontier USDG",vault:f.vaults.longbowFrontier.address,asset:f.tokens.USDG.address,symbol:"USDG",decimals:6},{key:"eth",name:"Longbow ETH",vault:f.vaults.longbowEth.address,asset:f.tokens.WETH.address,symbol:"WETH",decimals:18}],D=[{key:"v1-usdg",name:"Longbow USDG Core V1 (legacy)",vault:b("0x8cb8AA35228c96C1C4E956E69AbAEBCc2aA7Dcfe"),asset:f.tokens.USDG.address,symbol:"USDG",decimals:6},{key:"v1-weth",name:"Longbow WETH Core V1 (legacy)",vault:b("0x93777a9b917be3c8259c84456222f43a01dd6492"),asset:f.tokens.WETH.address,symbol:"WETH",decimals:18}];function x(a,i){return O(a,`${i} must be positive and within the uint256 range.`,{notString:`${i} must be a positive integer string in base units.`,positive:!0})}function h(a){return I(a,"Longbow returned an invalid integer response.")}function j(a,i=!1){if(typeof a!="string")throw new u("Provide the address of a current Longbow vault.");let p=D.find(y=>A(y.vault,a));if(p&&!i)throw new u("Longbow V1 vaults are withdraw-only; deposit into a current V2 vault from longbow_list instead.");let g=p??T.find(y=>A(y.vault,a));if(!g)throw new u("Provide the address of a current Longbow vault, or a Longbow V1 vault to withdraw from. Other vaults are not supported.");return g}function L(a,i){if(Object.keys(a).some(p=>!i.includes(p)))throw new u("Unsupported Longbow input. Use the fields in the tool schema.")}var Q=a=>{async function i(t){try{return await t()}catch(e){throw new u(a.plainError(e))}}async function p(){let t=a.clientFor(m);if(await t.getChainId()!==m)throw new u("Longbow requires a client on chain 4663.");return t}async function g(t,e){let[o,r,s]=await Promise.all([t.readContract({address:e.vault,abi:c,functionName:"asset"}),t.readContract({address:e.vault,abi:c,functionName:"decimals"}),t.readContract({address:e.asset,abi:c,functionName:"decimals"})]);if(typeof o!="string"||!A(o,e.asset))throw new u("Longbow vault asset does not match the recorded deployment.");if(r!==18||s!==e.decimals)throw new u("Longbow token decimals do not match the recorded deployment.");return{vault:e.vault,key:e.key,name:e.name,asset:{address:b(e.asset),symbol:e.symbol,decimals:s,chainId:m},share:{address:e.vault,symbol:`${e.key} shares`,decimals:r,chainId:m}}}async function y(t,e,o,r){let s=F(o.amount,H);if(BigInt(s)===0n)throw new u("The expected output is too small for a nonzero simulation minimum.");let n=await a.preview(t,e);if(n.changes.filter(l=>l.token.chainId===o.token.chainId&&A(l.token.address,o.token.address)&&l.token.decimals===o.token.decimals).reduce((l,v)=>l+BigInt(v.amount),0n)<BigInt(s))throw new u("Longbow simulated output is below the expected minimum.");let d=n.changes.map(({token:l,amount:v})=>{let N=v.startsWith("-");return`${N?"-":"+"}${a.formatAmount(N?v.slice(1):v,l.decimals)} ${l.symbol} (${l.address}, chain ${l.chainId})`}).join("; ");return{txs:t,preview:n,expectedOutput:o,minimumOutput:{token:o.token,amount:s},minimumEnforcedOnchain:!1,summary:`${r} ${d}. Simulation only; no on-chain minimum is enforced by these ERC-4626 calls. ${n.summary}`}}async function z(t){L(t,[]);let e=await p();return Promise.all(T.map(async o=>{let[r,s,n,w]=await Promise.all([g(e,o),e.readContract({address:o.vault,abi:c,functionName:"totalAssets"}),e.readContract({address:o.vault,abi:c,functionName:"performanceFee"}),e.readContract({address:o.vault,abi:c,functionName:"managementFee"})]);return{...r,totalAssets:{token:r.asset,amount:h(s).toString()},fees:{performanceFeeE18:h(n).toString(),managementFeeE18:h(w).toString()},caveat:"Morpho V2 max views can be zero even when writes succeed. Simulate the requested action; listing does not prove availability."}}))}async function Y(t,e){L(t,["vault","amount","wrapEth"]),k(e);let o=j(t.vault),r=x(t.amount,"Deposit amount");if(t.wrapEth!==void 0&&typeof t.wrapEth!="boolean")throw new u("wrapEth must be a boolean.");if(t.wrapEth&&!A(o.asset,f.tokens.WETH.address))throw new u("Only a WETH vault accepts explicit ETH wrapping.");let s=await p(),n=await g(s,o),w=h(await s.readContract({address:n.vault,abi:c,functionName:"previewDeposit",args:[r]})),d=[];return t.wrapEth&&d.push(a.unsignedTx({to:n.asset.address,data:C({abi:J,functionName:"deposit"}),value:r.toString(),chainId:m,description:`Wrap ${a.formatAmount(r.toString(),18)} ETH into WETH for ${n.name}.`})),d.push(a.approval(n.asset.address,n.vault,r.toString(),m)),d.push(a.unsignedTx({to:n.vault,data:C({abi:c,functionName:"deposit",args:[r,b(e)]}),value:"0",chainId:m,description:`Deposit ${a.formatAmount(r.toString(),n.asset.decimals)} ${n.asset.symbol} into ${n.name}.`})),y(d,e,{token:n.share,amount:w.toString()},`Deposit into ${n.name}.`)}async function K(t,e){L(t,["vault","shares"]),k(e);let o=j(t.vault,!0),r=t.shares==="all"?void 0:x(t.shares,"Redeem shares"),s=await p(),n=await g(s,o),w=h(await s.readContract({address:n.vault,abi:c,functionName:"balanceOf",args:[e]})),d=r??w;if(d===0n||d>w)throw new u("The wallet has insufficient Longbow shares for this redemption.");let l=h(await s.readContract({address:n.vault,abi:c,functionName:"previewRedeem",args:[d]})),v=[a.unsignedTx({to:n.vault,data:C({abi:c,functionName:"redeem",args:[d,b(e),b(e)]}),value:"0",chainId:m,description:`Redeem ${a.formatAmount(d.toString(),n.share.decimals)} shares from ${n.name} into ${n.asset.symbol}.`})];return y(v,e,{token:n.asset,amount:l.toString()},`Redeem from ${n.name}.`)}let E={type:"string",enum:T.map(t=>t.vault),description:"Current vault address on chain 4663."},$=G("Positive integer base units, never a human-unit decimal."),S=(t,e,o,r)=>({name:t,inputSchema:{type:"object",properties:e,required:o,additionalProperties:!1},execute:(s,n)=>i(()=>r(s,n))});return{tools:[S("longbow_list",{},[],z),S("longbow_deposit",{vault:E,amount:$,wrapEth:{type:"boolean",default:!1,description:"Explicitly wrap this amount of native ETH before depositing into the WETH vault."}},["vault","amount"],Y),S("longbow_withdraw",{vault:{...E,enum:[...E.enum,...D.map(t=>t.vault)],description:"Current vault address, or a Longbow V1 vault (withdraw-only) on chain 4663."},shares:{anyOf:[$,{const:"all"}],description:"Share base units (18 decimals), or all for the fresh wallet share balance. Returns the underlying asset, including WETH."}},["vault","shares"],K)],positions:t=>i(async()=>{k(t);let e=await p();return(await Promise.all([...T,...D].map(async r=>{let s=await g(e,r),n=h(await e.readContract({address:s.vault,abi:c,functionName:"balanceOf",args:[t]}));if(n===0n)return[];let w=h(await e.readContract({address:s.vault,abi:c,functionName:"previewRedeem",args:[n]}));return[{module:"longbow",id:`${m}:${s.vault.toLowerCase()}`,chainId:m,assets:[{token:s.asset,amount:w.toString()}],description:`${s.name}: ${a.formatAmount(n.toString(),s.share.decimals)} shares (${s.share.address}, ${s.share.decimals} decimals). Underlying is a preview, not a guaranteed redemption.`}]}))).flat()})}};function we(a){return W("longbow",[Q(a),P(a),R(a),V(a),M(a),_(a),{tools:B(a,"longbow",T.map(i=>({vault:i.vault,asset:{address:b(i.asset),symbol:i.symbol,decimals:i.decimals,chainId:m}})))}])}export{D as a,Q as b,we as c};
1
+ import{a as B}from"./6PU2CMQZ.js";import{c as _}from"./5HW6JKME.js";import{c as V}from"./7B5UH2VS.js";import{c as P}from"./T6MTTMLQ.js";import{b as M}from"./LI7FYINH.js";import{k as R}from"./O47JXRXN.js";import{b as H,o as F}from"./CAU44UWP.js";import{b as W}from"./AXYOJBX6.js";import{a as k}from"./6IM6A5VA.js";import{a as G}from"./UWOFA6GV.js";import{g as A,m as I,n as O}from"./73N3TOJL.js";import{a as m,i as U}from"./XPFVT2EA.js";import{a as u}from"./5YS5V2LK.js";import{encodeFunctionData as C,getAddress as b,parseAbi as q}from"viem";var c=q(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)","function balanceOf(address) view returns (uint256)","function previewDeposit(uint256 assets) view returns (uint256)","function previewRedeem(uint256 shares) view returns (uint256)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),J=q(["function deposit() payable"]),f=U[m],T=[{key:"core",name:"Longbow Core USDG",vault:f.vaults.longbowCore.address,asset:f.tokens.USDG.address,symbol:"USDG",decimals:6},{key:"frontier",name:"Longbow Frontier USDG",vault:f.vaults.longbowFrontier.address,asset:f.tokens.USDG.address,symbol:"USDG",decimals:6},{key:"eth",name:"Longbow ETH",vault:f.vaults.longbowEth.address,asset:f.tokens.WETH.address,symbol:"WETH",decimals:18}],D=[{key:"v1-usdg",name:"Longbow USDG Core V1 (legacy)",vault:b("0x8cb8AA35228c96C1C4E956E69AbAEBCc2aA7Dcfe"),asset:f.tokens.USDG.address,symbol:"USDG",decimals:6},{key:"v1-weth",name:"Longbow WETH Core V1 (legacy)",vault:b("0x93777a9b917be3c8259c84456222f43a01dd6492"),asset:f.tokens.WETH.address,symbol:"WETH",decimals:18}];function x(a,i){return O(a,`${i} must be positive and within the uint256 range.`,{notString:`${i} must be a positive integer string in base units.`,positive:!0})}function h(a){return I(a,"Longbow returned an invalid integer response.")}function j(a,i=!1){if(typeof a!="string")throw new u("Provide the address of a current Longbow vault.");let p=D.find(y=>A(y.vault,a));if(p&&!i)throw new u("Longbow V1 vaults are withdraw-only; deposit into a current V2 vault from longbow_list instead.");let g=p??T.find(y=>A(y.vault,a));if(!g)throw new u("Provide the address of a current Longbow vault, or a Longbow V1 vault to withdraw from. Other vaults are not supported.");return g}function L(a,i){if(Object.keys(a).some(p=>!i.includes(p)))throw new u("Unsupported Longbow input. Use the fields in the tool schema.")}var Q=a=>{async function i(t){try{return await t()}catch(e){throw new u(a.plainError(e))}}async function p(){let t=a.clientFor(m);if(await t.getChainId()!==m)throw new u("Longbow requires a client on chain 4663.");return t}async function g(t,e){let[o,r,s]=await Promise.all([t.readContract({address:e.vault,abi:c,functionName:"asset"}),t.readContract({address:e.vault,abi:c,functionName:"decimals"}),t.readContract({address:e.asset,abi:c,functionName:"decimals"})]);if(typeof o!="string"||!A(o,e.asset))throw new u("Longbow vault asset does not match the recorded deployment.");if(r!==18||s!==e.decimals)throw new u("Longbow token decimals do not match the recorded deployment.");return{vault:e.vault,key:e.key,name:e.name,asset:{address:b(e.asset),symbol:e.symbol,decimals:s,chainId:m},share:{address:e.vault,symbol:`${e.key} shares`,decimals:r,chainId:m}}}async function y(t,e,o,r){let s=F(o.amount,H);if(BigInt(s)===0n)throw new u("The expected output is too small for a nonzero simulation minimum.");let n=await a.preview(t,e);if(n.changes.filter(l=>l.token.chainId===o.token.chainId&&A(l.token.address,o.token.address)&&l.token.decimals===o.token.decimals).reduce((l,v)=>l+BigInt(v.amount),0n)<BigInt(s))throw new u("Longbow simulated output is below the expected minimum.");let d=n.changes.map(({token:l,amount:v})=>{let N=v.startsWith("-");return`${N?"-":"+"}${a.formatAmount(N?v.slice(1):v,l.decimals)} ${l.symbol} (${l.address}, chain ${l.chainId})`}).join("; ");return{txs:t,preview:n,expectedOutput:o,minimumOutput:{token:o.token,amount:s},minimumEnforcedOnchain:!1,summary:`${r} ${d}. Simulation only; no on-chain minimum is enforced by these ERC-4626 calls. ${n.summary}`}}async function z(t){L(t,[]);let e=await p();return Promise.all(T.map(async o=>{let[r,s,n,w]=await Promise.all([g(e,o),e.readContract({address:o.vault,abi:c,functionName:"totalAssets"}),e.readContract({address:o.vault,abi:c,functionName:"performanceFee"}),e.readContract({address:o.vault,abi:c,functionName:"managementFee"})]);return{...r,totalAssets:{token:r.asset,amount:h(s).toString()},fees:{performanceFeeE18:h(n).toString(),managementFeeE18:h(w).toString()},caveat:"Morpho V2 max views can be zero even when writes succeed. Simulate the requested action; listing does not prove availability."}}))}async function Y(t,e){L(t,["vault","amount","wrapEth"]),k(e);let o=j(t.vault),r=x(t.amount,"Deposit amount");if(t.wrapEth!==void 0&&typeof t.wrapEth!="boolean")throw new u("wrapEth must be a boolean.");if(t.wrapEth&&!A(o.asset,f.tokens.WETH.address))throw new u("Only a WETH vault accepts explicit ETH wrapping.");let s=await p(),n=await g(s,o),w=h(await s.readContract({address:n.vault,abi:c,functionName:"previewDeposit",args:[r]})),d=[];return t.wrapEth&&d.push(a.unsignedTx({to:n.asset.address,data:C({abi:J,functionName:"deposit"}),value:r.toString(),chainId:m,description:`Wrap ${a.formatAmount(r.toString(),18)} ETH into WETH for ${n.name}.`})),d.push(a.approval(n.asset.address,n.vault,r.toString(),m)),d.push(a.unsignedTx({to:n.vault,data:C({abi:c,functionName:"deposit",args:[r,b(e)]}),value:"0",chainId:m,description:`Deposit ${a.formatAmount(r.toString(),n.asset.decimals)} ${n.asset.symbol} into ${n.name}.`})),y(d,e,{token:n.share,amount:w.toString()},`Deposit into ${n.name}.`)}async function K(t,e){L(t,["vault","shares"]),k(e);let o=j(t.vault,!0),r=t.shares==="all"?void 0:x(t.shares,"Redeem shares"),s=await p(),n=await g(s,o),w=h(await s.readContract({address:n.vault,abi:c,functionName:"balanceOf",args:[e]})),d=r??w;if(d===0n||d>w)throw new u("The wallet has insufficient Longbow shares for this redemption.");let l=h(await s.readContract({address:n.vault,abi:c,functionName:"previewRedeem",args:[d]})),v=[a.unsignedTx({to:n.vault,data:C({abi:c,functionName:"redeem",args:[d,b(e),b(e)]}),value:"0",chainId:m,description:`Redeem ${a.formatAmount(d.toString(),n.share.decimals)} shares from ${n.name} into ${n.asset.symbol}.`})];return y(v,e,{token:n.asset,amount:l.toString()},`Redeem from ${n.name}.`)}let E={type:"string",enum:T.map(t=>t.vault),description:"Current vault address on chain 4663."},$=G("Positive integer base units, never a human-unit decimal."),S=(t,e,o,r)=>({name:t,inputSchema:{type:"object",properties:e,required:o,additionalProperties:!1},execute:(s,n)=>i(()=>r(s,n))});return{tools:[S("longbow_list",{},[],z),S("longbow_deposit",{vault:E,amount:$,wrapEth:{type:"boolean",default:!1,description:"Explicitly wrap this amount of native ETH before depositing into the WETH vault."}},["vault","amount"],Y),S("longbow_withdraw",{vault:{...E,enum:[...E.enum,...D.map(t=>t.vault)],description:"Current vault address, or a Longbow V1 vault (withdraw-only) on chain 4663."},shares:{anyOf:[$,{const:"all"}],description:"Share base units (18 decimals), or all for the fresh wallet share balance. Returns the underlying asset, including WETH."}},["vault","shares"],K)],positions:t=>i(async()=>{k(t);let e=await p();return(await Promise.all([...T,...D].map(async r=>{let s=await g(e,r),n=h(await e.readContract({address:s.vault,abi:c,functionName:"balanceOf",args:[t]}));if(n===0n)return[];let w=h(await e.readContract({address:s.vault,abi:c,functionName:"previewRedeem",args:[n]}));return[{module:"longbow",id:`${m}:${s.vault.toLowerCase()}`,chainId:m,assets:[{token:s.asset,amount:w.toString()}],description:`${s.name}: ${a.formatAmount(n.toString(),s.share.decimals)} shares (${s.share.address}, ${s.share.decimals} decimals). Underlying is a preview, not a guaranteed redemption.`}]}))).flat()})}};function we(a){return W("longbow",[Q(a),P(a),R(a),V(a),M(a),_(a),{tools:B(a,"longbow",T.map(i=>({vault:i.vault,asset:{address:b(i.asset),symbol:i.symbol,decimals:i.decimals,chainId:m}})))}])}export{D as a,Q as b,we as c};