@oakagentkit/core 0.2.2 → 0.2.3

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 (41) hide show
  1. package/build/dist/api/modules/hookr/actions.js +1 -1
  2. package/build/dist/api/modules/hookr/index.js +1 -1
  3. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  4. package/build/dist/api/modules/hookr/launch.js +1 -1
  5. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  6. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  7. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  8. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  9. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  10. package/build/dist/api/modules/merkl/discovery.js +1 -1
  11. package/build/dist/api/modules/merkl/index.js +1 -1
  12. package/build/dist/api/modules/merkl/manage.js +1 -1
  13. package/build/dist/api/modules/uniswap/batch.js +1 -1
  14. package/build/dist/api/modules/uniswap/fees.js +1 -1
  15. package/build/dist/api/modules/uniswap/index.js +1 -1
  16. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  17. package/build/dist/api/modules/uniswap/pools.js +1 -1
  18. package/build/dist/api/modules/uniswap/position.js +1 -1
  19. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  20. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  21. package/build/dist/api/modules/uniswap/trade.js +1 -1
  22. package/build/dist/api/modules/uniswap/v4.js +1 -1
  23. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  24. package/build/dist/chunks/{Y2KH6DCE.js → ASDKY5NX.js} +1 -1
  25. package/build/dist/chunks/{ZUG6MG46.js → CE7D6MUS.js} +1 -1
  26. package/build/dist/chunks/{MLPWQTBS.js → G3MHDTGT.js} +1 -1
  27. package/build/dist/chunks/{JNZZLA2A.js → GCWA4Z3W.js} +1 -1
  28. package/build/dist/chunks/{EPZ7SWKM.js → LKJBMHCE.js} +1 -1
  29. package/build/dist/chunks/{XMA25DXR.js → LLM5WDM3.js} +1 -1
  30. package/build/dist/chunks/{MFNP4KOK.js → O5IVZHHP.js} +1 -1
  31. package/build/dist/chunks/{66VBACC2.js → PEA32CWB.js} +1 -1
  32. package/build/dist/chunks/TNLHMDWL.js +1 -0
  33. package/build/dist/chunks/{J2XAEVKC.js → TPDOUL4N.js} +1 -1
  34. package/build/dist/chunks/{SI6GCOAS.js → VCLPOU7T.js} +1 -1
  35. package/build/dist/chunks/{JVI26KQO.js → VFKNXQXI.js} +1 -1
  36. package/build/dist/chunks/{TFVWAYHY.js → XUYHMOHS.js} +1 -1
  37. package/build/dist/chunks/YOENHHKI.js +1 -0
  38. package/build/dist/chunks/{DHOBTJRD.js → ZXQMF56D.js} +1 -1
  39. package/package.json +1 -1
  40. package/build/dist/chunks/4GAWMCQC.js +0 -1
  41. package/build/dist/chunks/Q356HHCL.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oakagentkit/core",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "engines": {
@@ -1 +0,0 @@
1
- import{c as k}from"./MYBDO5SA.js";import{e as h}from"./73N3TOJL.js";import{a as c}from"./G6HCV67X.js";import{a}from"./5YS5V2LK.js";import{getAddress as A,isAddress as b}from"viem";function f(o){if(typeof o!="string"||!o.trim()||o.length>200)throw new a("Provide nonempty filter text of at most 200 characters.");return o}function x(o,m){if(typeof o!="number"||!Number.isSafeInteger(o)||o<0||o>m)throw new a(`Choose a pagination integer from 0 to ${m}.`);return o}var _={morpho:{assess:"morpho_status",enter:"morpho_supply",exit:"morpho_withdraw"},steakhouse:{assess:"steakhouse_list",enter:"steakhouse_deposit",exit:"steakhouse_withdraw"},spark:{assess:"spark_list",enter:"spark_deposit",exit:"spark_withdraw"},netnet:{assess:"netnet_list",enter:"netnet_deposit",exit:"netnet_withdraw"},longbow:{assess:"longbow_list",enter:"longbow_deposit",exit:"longbow_withdraw"},grove:{assess:"grove_list",enter:"grove_deposit",exit:"grove_withdraw"},beefy:{assess:"beefy_list",enter:"beefy_deposit",exit:"beefy_withdraw"},uniswap:{assess:"uniswap_list_positions",enter:"uniswap_add",exit:"uniswap_remove"}},R=o=>{let m=(e,t,i)=>({name:`merkl_${e}`,inputSchema:{type:"object",properties:t,additionalProperties:!1},execute:async(n,r)=>{try{let s=Object.keys(n).find(p=>!Object.hasOwn(t,p));if(s)throw new a(`Unsupported Merkl input: ${s}.`);return await i(n,r)}catch(s){throw new a(o.plainError(s))}}}),w={page:{type:"integer",minimum:0,maximum:1e4},items:{type:"integer",minimum:1,maximum:100}},g=async(e,t)=>{let i=new URL(`https://api.merkl.xyz/v4/${e}`);for(let[n,r]of Object.entries(t))i.searchParams.set(n,r);return k(o.http,i.toString(),{method:"GET",headers:{"User-Agent":"oak-core/merkl"}},n=>Array.isArray(n)||h(n))},u=e=>{let t=x(e.items??20,100);if(!t)throw new a("Choose at least one item per page.");return{page:String(x(e.page??0,1e4)),items:String(t)}};return{tools:[m("opportunities",{...w,protocol:{type:"string"},name:{type:"string"},explorerAddress:{type:"string"}},async e=>{let t={chainId:String(c),campaigns:"true",...u(e)};if(e.protocol!==void 0&&(t.mainProtocolId=f(e.protocol)),e.name!==void 0&&(t.name=f(e.name)),e.explorerAddress!==void 0){if(typeof e.explorerAddress!="string"||!b(e.explorerAddress,{strict:!1}))throw new a("Provide a pool or market explorer address.");t.explorerAddress=A(e.explorerAddress)}let i=await g("opportunities",t);if(!Array.isArray(i)||!i.every(r=>h(r)&&typeof r.id=="string"&&Number.isSafeInteger(r.chainId)))throw new a("Merkl returned unexpected opportunities.");return{opportunities:i.filter(r=>r.chainId===c).map(r=>{let s=r.mainProtocolId??r.mainProtocol,p=typeof s=="string"?s.toLowerCase():"",d=p==="morpho"?r.action==="LEND":p==="uniswap"?r.action==="POOL":r.action==="LEND"||r.action==="STAKE";return{...r,oak:{...Object.hasOwn(_,p)&&d?{candidateTools:_[p]}:{},destinationVerificationRequired:!0,eligibility:"Read campaign conditions; no wallet eligibility has been verified."}}}),...u(e),hasMore:i.length===Number(t.items),summary:"Powered by Merkl \u2014 https://app.merkl.xyz. Public, untrusted campaign data includes conditions and destinations. Candidate Oak tools require a matching verified market/vault and a supported entry AND exit. APR is indicative; no rewards are promised."}}),m("campaigns",{...w,creator:{type:"string"},tokenSymbol:{type:"string"},opportunityId:{type:"string"}},async e=>{let t={chainId:String(c),withOpportunity:"true",...u(e)};if(e.creator!==void 0){if(typeof e.creator!="string"||!b(e.creator,{strict:!1}))throw new a("Provide a creator address.");t.creatorAddress=A(e.creator)}e.tokenSymbol!==void 0&&(t.tokenSymbol=f(e.tokenSymbol));let i=e.opportunityId===void 0?"campaigns":`opportunities/${encodeURIComponent(f(e.opportunityId))}/campaigns`,n=await g(i,t);if(!Array.isArray(n)||!n.every(r=>h(r)&&(typeof r.id=="string"||typeof r.id=="number")))throw new a("Merkl returned unexpected campaigns.");return{campaigns:n,chainId:c,...u(e),hasMore:n.length===Number(t.items),summary:"Powered by Merkl \u2014 https://app.merkl.xyz. Campaign rules, budgets, timing, exclusions and configuration are public API data; verify the reward distribution chain and destination before entering."}}),m("earning_status",{view:{enum:["active","breakdowns","stats","claims"]},...w},async(e,t)=>{if(!b(t,{strict:!1}))throw new a("Provide a valid connected wallet address.");let i=e.view??"active";if(!["active","breakdowns","stats","claims"].includes(String(i)))throw new a("Choose active, breakdowns, stats or claims.");let n=i==="claims"?"claims":i==="breakdowns"?`users/${t}/rewards/chains/${c}/breakdowns`:`users/${t}/rewards/${i==="active"?"active-opportunities":"stats"}`,{page:r,items:s}=u(e),p=i==="breakdowns"?{}:{chainId:String(c)};i==="claims"&&(p.recipient=t);let d=await g(n,p),l=Number(r)*Number(s),y=Array.isArray(d)?d:i==="breakdowns"&&h(d)&&Array.isArray(d.opportunities)?d.opportunities:void 0,v=y?Array.isArray(d)?y.slice(l,l+Number(s)):{...d,opportunities:y.slice(l,l+Number(s))}:d;return{view:i,chainId:c,wallet:t,data:v,...y?{page:r,items:s,hasMore:l+Number(s)<y.length}:{},summary:"Powered by Merkl \u2014 https://app.merkl.xyz. API earning attribution and history can lag onchain state; pending earnings are not claimable. Private or restricted attribution may be omitted by Merkl. Recheck merkl_rewards before a claim."}})]}};export{R as a};
@@ -1 +0,0 @@
1
- import{c as Re,d as je,e as qe,f as be,i as Le,j as ze}from"./6ZYLNB2B.js";import{i as ue}from"./FUXT7GRK.js";import{b as Ie,o as Ce}from"./5O5ZE3ZV.js";import{a as de}from"./CY75R4FK.js";import{a as $,b as Oe}from"./6IM6A5VA.js";import{a as L}from"./UWOFA6GV.js";import{a as D}from"./RETS2ZEK.js";import{a as f,d as Xe,i as ee,j as Be}from"./G6HCV67X.js";import{a as o,b as He,d as oe}from"./5YS5V2LK.js";import{encodeAbiParameters as A,encodeFunctionData as re,erc20Abi as We,getAddress as y,isAddress as An,keccak256 as xn,pad as Sn,parseAbi as Ae,parseAbiParameters as j,toEventSelector as In,toHex as Ge}from"viem";var Cn=y(ee[4663].uniswap.v4_pool_manager.address),T=y(ee[4663].uniswap.v4_position_manager.address),fe=y(ee[4663].uniswap.v4_state_view.address),_e=y(ee[4663].uniswap.permit2.address),at=y(ee[4663].ponsTrade.universal_router.address),se=y(ee[4663].uniswap.WETH.address),_=y(Be),g="0x0000000000000000000000000000000000000000",De=8388608,Ee=-887272,Pe=887272,pn=(1n<<48n)-1n,ne=(1n<<128n)-1n,qn=(1n<<160n)-1n,pe=1n<<96n,Ze=1800n,Ln="0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",Ke=[{poolId:"0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",key:{currency0:g,currency1:_,fee:8388608,tickSpacing:10,hooks:y("0x06a889870c8f83640d6816319f72e2aa579b6080")},liquidity:"5532026605872066941",sqrtPriceX96:"3839897026469220985301794",tick:-198703,protocolFee:0,lpFee:0},{poolId:"0x387bf619da4d3fb62bb276482693dba1b9b3520f573cabdfe033384a24125982",key:{currency0:g,currency1:_,fee:500,tickSpacing:10,hooks:g},liquidity:"225820987949255613",sqrtPriceX96:"3840577772610961024680304",tick:-198700,protocolFee:512125,lpFee:500},{poolId:"0x54f7883914619af9105355bf83ed678bcf9f63560218ac61c9963b9503d0ba32",key:{currency0:g,currency1:_,fee:460,tickSpacing:9,hooks:g},liquidity:"85654324417347171",sqrtPriceX96:"3840419018843648722761192",tick:-198701,protocolFee:479349,lpFee:460},{poolId:"0xc7b615a3721594f73664eb3f62d8290d0fcc8d9d1156aed1ddecbd7f32efd9f5",key:{currency0:g,currency1:_,fee:8388608,tickSpacing:10,hooks:y("0xcb787a5cdea8b3715d984d82f1203fd7bfebe0c4")},liquidity:"50517446454827887",sqrtPriceX96:"3840495145865430860317598",tick:-198700,protocolFee:0,lpFee:0},{poolId:"0x24107d152f14a76d292123265ae3f3c71f863fc2f4ef7ba49d64e78d28ea379e",key:{currency0:g,currency1:_,fee:100,tickSpacing:1,hooks:g},liquidity:"36478878201789434",sqrtPriceX96:"3840363370720475418748563",tick:-198701,protocolFee:102425,lpFee:100},{poolId:"0x84bd4e2d8be11aeb0afc1195b38f587b61e90068548f1063fdbe448fb8cad0b6",key:{currency0:se,currency1:_,fee:200,tickSpacing:4,hooks:g},liquidity:"5980655057479791",sqrtPriceX96:"3839891926195366283625355",tick:-198703,protocolFee:213044,lpFee:200},{poolId:"0x3b0cbf0603ecc67b5fc9bb4fbb6ac9e08d3b2f406b63d1662a36063a7fe5e866",key:{currency0:g,currency1:_,fee:87,tickSpacing:1,hooks:g},liquidity:"5486760264498148",sqrtPriceX96:"3840563617639470134132117",tick:-198700,protocolFee:90134,lpFee:87}],Ne=y("0x987e330f00b79864a07fe81dfac344d0078abcc0"),fn="0xa791e5169faf703c0b63fd9552c33ec1128a773a00f5dc33a640da62a022cd35",Tn={currency0:g,currency1:_,fee:De,tickSpacing:1,hooks:Ne},$n=new Set([...Ke.map(e=>e.key.hooks.toLowerCase()),Ne.toLowerCase()]),Mn=j("address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks"),_n=j("(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, int24 tickLower, int24 tickUpper, uint256 liquidity, uint128 amount0Max, uint128 amount1Max, address owner, bytes hookData"),En=j("address currency0, address currency1"),Un=j("address currency, address recipient"),ge=j("uint256 tokenId, uint256 liquidity, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Dn=j("uint256 tokenId, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Te=j("address currency0, address currency1, address recipient"),le=j("bytes actions, bytes[] params"),H=Ae(["function modifyLiquidities(bytes unlockData, uint256 deadline) payable","function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)","function getPositionLiquidity(uint256 tokenId) view returns (uint128 liquidity)","function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, uint256 info)","function positionInfo(uint256 tokenId) view returns (uint256 info)","function ownerOf(uint256 tokenId) view returns (address owner)","function nextTokenId() view returns (uint256 tokenId)"]),Kn=Ae(["function initialize((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint160 sqrtPriceX96) returns (int24 tick)"]),Ye=j("address currency"),Qe=1e6,me=Ae(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Nn=Ae(["function approve(address token, address spender, uint160 amount, uint48 expiration)"]),Fn=In("Transfer(address,address,uint256)");function ve(e){if(typeof e!="string"||!An(e,{strict:!1}))throw new o("Provide a valid v4 currency address.");let n=e.toLowerCase();return n===g||n===de.toLowerCase()?g:y(e)}function R(e){let n=e.toLowerCase();return n===g||n===de.toLowerCase()}function ye(e){let n=ve(e.currency0),i=ve(e.currency1);$(e.hooks);let r=y(e.hooks);return xn(A(Mn,[n,i,e.fee,e.tickSpacing,r]))}function mn(e){return((typeof e=="number"?e:e.fee)&De)!==0}function Je(e,n){return mn(e)?{dynamicFee:!0,storedLpFee:n,swapsAreFree:!1,feeNote:"Pool uses dynamic fee flag 0x800000; stored lpFee=0 does not mean swaps are free. The hook determines the swap fee; a past observation is not a current quote."}:{dynamicFee:!1,storedLpFee:n,swapsAreFree:n===0,feeNote:`Static LP fee ${n} pips.`}}function ke(e,n){if(!e||typeof e!="object")throw new o("Provide a valid v4 PoolKey.");let i=ve(e.currency0),r=ve(e.currency1);if(BigInt(i)>=BigInt(r))throw new o("PoolKey currencies must be strictly sorted (currency0 < currency1).");if(!Number.isInteger(e.tickSpacing)||e.tickSpacing<=0||e.tickSpacing>32767)throw new o("PoolKey tickSpacing must be a positive integer.");if(!Number.isInteger(e.fee)||e.fee<0||e.fee>16777215)throw new o("PoolKey fee must be a valid uint24.");$(e.hooks);let c=y(e.hooks),s=mn(e.fee);if(!s&&e.fee>Qe)throw new o(`PoolKey static fee ${e.fee} exceeds the v4 maximum of ${Qe} pips (100%).`);if(s&&e.fee!==De)throw new o("Dynamic-fee PoolKey must use exact fee flag 0x800000 (8388608).");if(s&&c.toLowerCase()===g)throw new o("Dynamic-fee PoolKey requires a non-zero hook address.");if(!$n.has(c.toLowerCase()))throw new o(`Unsupported v4 hook ${c}: Oak does not assure arbitrary v4 hooks outside measured PoolKeys.`);let t={currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c},d=ye(t);if(c===Ne&&d.toLowerCase()!==fn)throw new o("Only the documented VolatilePair ETH/USDG PoolKey is supported. Pool creation requires the Uniswap Labs role.");if(n!==void 0){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new o("Provide a 32-byte hex poolId.");if(d.toLowerCase()!==n.toLowerCase())throw new o(`PoolKey hash (${d}) does not match expected poolId (${n}).`)}return t}function Vn(e){if(!Number.isInteger(e)||e<=0||e>Pe)throw new o("tickSpacing must be a positive integer.");let n=Math.trunc(Ee/e)*e,i=Math.trunc(Pe/e)*e;return{tickLower:n===0?0:n,tickUpper:i===0?0:i}}function Hn(e,n,i){if(!Number.isInteger(i)||i<=0)throw new o("tickSpacing must be a positive integer.");if(!Number.isInteger(e)||!Number.isInteger(n))throw new o("tickLower and tickUpper must be integers.");if(e<Ee||n>Pe)throw new o(`Ticks [${e}, ${n}] are outside Uniswap bounds [${Ee}, ${Pe}].`);if(e>=n)throw new o("tickLower must be strictly less than tickUpper.");if(e%i!==0||n%i!==0)throw new o(`Ticks [${e}, ${n}] must be divisible by tickSpacing ${i}.`)}function en(e,n,i,r,c=f){if($(e),$(n),R(e))throw new o("Native ETH does not use Permit2 approval.");let s=D(i);if(s<=0n||s>qn)throw new o("Permit2 approval amount must be a positive integer within uint160.");let t=D(String(r));if(t<=0n||t>pn)throw new o("Permit2 expiration must be a positive timestamp within uint48.");let d=re({abi:Nn,functionName:"approve",args:[e,n,s,Number(t)]});return Oe({to:_e,data:d,value:"0",chainId:c,description:`Approve Permit2 allowance of ${s} base units of ${e} for ${n} until ${t}.`})}function nn(e){let n=Number(e&0xffffffn);return(n&8388608)!==0?n-16777216:n}function Xn(e){let n=(e&0xffn)!==0n,i=nn(e>>8n&0xffffffn),r=nn(e>>32n&0xffffffn);return{poolIdBytes25:`0x${(e>>56n&(1n<<200n)-1n).toString(16).padStart(50,"0")}`,tickLower:i,tickUpper:r,hasSubscriber:n}}function tn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e];if(c<=0n||s<=0n)return 0n;let t=(i<<96n)*(s-c),d=s*c;return r?(t+d-1n)/d:t/d}function on(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e],t=i*(s-c);return r?(t+pe-1n)/pe:t/pe}function yn(e){if(e.liquidity<=0n)return{amount0:0n,amount1:0n};let n=ue(e.tickLower),i=ue(e.tickUpper);return e.sqrtPriceX96<=n?{amount0:tn(n,i,e.liquidity,e.roundUp),amount1:0n}:e.sqrtPriceX96<i?{amount0:tn(e.sqrtPriceX96,i,e.liquidity,e.roundUp),amount1:on(n,e.sqrtPriceX96,e.liquidity,e.roundUp)}:{amount0:0n,amount1:on(n,i,e.liquidity,e.roundUp)}}function Bn(e){let n=ue(e.tickLower),i=ue(e.tickUpper),r=(s,t,d)=>t<=s||d<=0n?0n:d*s*t/pe/(t-s),c=(s,t,d)=>t<=s||d<=0n?0n:d*pe/(t-s);if(e.sqrtPriceX96<=n)return r(n,i,e.amount0);if(e.sqrtPriceX96<i){let s=r(e.sqrtPriceX96,i,e.amount0),t=c(n,e.sqrtPriceX96,e.amount1);return s<t?s:t}return c(n,i,e.amount1)}function $e(e,n){return e.map(i=>{let r=i.amount.trim(),c=r.startsWith("-"),s=c||r.startsWith("+")?r.slice(1):r,t=n(s,i.token.decimals);return`${c?"-":""}${t} ${i.token.symbol}`})}function rn(e,n=f){if(R(e))return{address:de,symbol:"ETH",decimals:18,chainId:n};let i=y(e);return i.toLowerCase()===_.toLowerCase()?{address:_,symbol:"USDG",decimals:Xe,chainId:n}:i.toLowerCase()===se.toLowerCase()?{address:se,symbol:"WETH",decimals:18,chainId:n}:{address:i,symbol:i.slice(0,10),decimals:18,chainId:n}}async function V(e,n,i=f){if(R(n))return rn(n,i);let r=y(n);if(r.toLowerCase()===_.toLowerCase()||r.toLowerCase()===se.toLowerCase())return rn(r,i);let[c,s]=await Promise.all([e.readContract({address:r,abi:We,functionName:"symbol"}),e.readContract({address:r,abi:We,functionName:"decimals"})]);if(!Number.isInteger(Number(s))||Number(s)<0||Number(s)>77)throw new o(`Token ${r} reports invalid decimals.`);return{address:r,symbol:ze(c,r),decimals:Number(s),chainId:i}}function W(e,n){if(typeof e!="string"||!/^\d+$/.test(e))throw new o(`${n} must be a non-negative integer string in base units.`);return D(e)}function sn(e,n,i,r){let c=e===void 0?D(Ce(n.toString(),i)):W(e,r);if(c<=1n||c>ne)throw new o(`${r} must exceed 1 base unit and fit in uint128; the simulated amount may be too small.`);return c}async function wn(e,n){if(typeof n=="number"&&Number.isFinite(n)&&n>0)return BigInt(Math.floor(n>1e11?n/1e3:n));if(typeof n=="string"&&/^\d+$/.test(n.trim()))return BigInt(n.trim());try{let i=await e.request({method:"eth_getBlockByNumber",params:["latest",!1]});if(i&&typeof i.timestamp=="string")return BigInt(i.timestamp)}catch{}return BigInt(Math.floor(Date.now()/1e3))}async function Me(e,n,i){let r=await wn(e,i);if(n==null)return r+1800n;let c=D(String(n));if(c<=r)throw new o(`Transaction deadline ${c} has expired (current timestamp ${r}).`);return c}async function Ue(e,n){let i=typeof n.poolId=="string"?n.poolId.trim():void 0,r=n.poolKey&&typeof n.poolKey=="object"&&!Array.isArray(n.poolKey)?n.poolKey:void 0,c=r?{currency0:String(r.currency0??g),currency1:String(r.currency1??_),fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:String(r.hooks??g)}:n.currency0!==void 0&&n.currency1!==void 0&&n.fee!==void 0&&n.tickSpacing!==void 0?{currency0:String(n.currency0),currency1:String(n.currency1),fee:Number(n.fee),tickSpacing:Number(n.tickSpacing),hooks:String(n.hooks??g)}:void 0;if(c){if(R(c.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");let b=ke(c,i);return{poolId:ye(b),poolKey:b}}let s=(i??Ln).toLowerCase();if(s===fn)return{poolId:s,poolKey:ke(Tn,s)};let t=Ke.find(b=>b.poolId.toLowerCase()===s);if(t){if(R(t.key.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");return{poolId:t.poolId,poolKey:t.key}}let d=s.slice(0,52),a=await e.readContract({address:T,abi:H,functionName:"poolKeys",args:[d]}),[p,l,m,u,k]=a;if(p.toLowerCase()===g&&l.toLowerCase()===g&&Number(u)===0)throw new o(`Unknown or uninitialized v4 poolId ${s}.`);let w=ke({currency0:p,currency1:l,fee:Number(m),tickSpacing:Number(u),hooks:k},s);return{poolId:s,poolKey:w}}async function he(e,n,i){try{let[r,c]=await e.readContract({address:T,abi:H,functionName:"getPoolAndPositionInfo",args:[n]}),s=ke({currency0:r.currency0,currency1:r.currency1,fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:r.hooks});if((i.poolKey||i.poolId)&&(await Ue(e,i)).poolId.toLowerCase()!==ye(s).toLowerCase())throw new o("The supplied PoolKey does not match this v4 position.");let t=Xn(BigInt(c));return{poolKey:s,poolId:ye(s),tickLower:t.tickLower,tickUpper:t.tickUpper}}catch(r){throw new o(`Could not read v4 position #${n}. ${oe(r)}`)}}async function an(e,n,i={}){$(n);let r=y(n),c=e.clientFor(f),s=new Set;if(i.tokenIds)for(let d of i.tokenIds)s.add(D(String(d)).toString());try{let d=await c.getBlockNumber(),a=10000000n;for(let p=0n;p<=d;p+=a){let l=p+a-1n<d?p+a-1n:d,m=await c.request({method:"eth_getLogs",params:[{address:T.toLowerCase(),topics:[Fn,null,Sn(r)],fromBlock:Ge(p),toBlock:Ge(l)}]});if(!Array.isArray(m))throw new o("Invalid v4 position log response.");for(let u of m){if(!Array.isArray(u.topics)||u.topics.length!==4||!/^0x[0-9a-fA-F]{64}$/.test(u.topics[3]??""))throw new o("Invalid v4 position transfer log.");s.add(BigInt(u.topics[3]).toString())}}}catch(d){if(!i.tokenIds)throw new o(`Could not discover v4 positions. ${oe(d)}`)}let t=[];for(let d of s){let a=BigInt(d);try{let p;try{p=await c.readContract({address:T,abi:H,functionName:"ownerOf",args:[a]})}catch(P){if(He(P,3))continue;throw P}if(p.toLowerCase()!==r.toLowerCase())continue;let l=await c.readContract({address:T,abi:H,functionName:"getPositionLiquidity",args:[a]}),m=BigInt(l);if(m===0n&&!i.includeZero)continue;let{poolKey:u,poolId:k,tickLower:w,tickUpper:b}=await he(c,a,{}),S=await c.readContract({address:fe,abi:me,functionName:"getSlot0",args:[k]}),I=BigInt(S[0]),{amount0:h,amount1:x}=yn({liquidity:m,tickLower:w,tickUpper:b,sqrtPriceX96:I}),[v,E]=await Promise.all([V(c,u.currency0,f),V(c,u.currency1,f)]);t.push({module:"uniswap",id:`uniswap:v4:${a.toString()}`,chainId:f,assets:[{token:v,amount:h.toString()},{token:E,amount:x.toString()}],description:`Uniswap v4 LP position #${a.toString()} (${v.symbol}/${E.symbol}, liquidity=${m.toString()}, ticks=[${w},${b}], poolId=${k})`})}catch(p){throw new o(`Could not read v4 position #${a}. ${oe(p)}`)}}return t}var On={type:"object",properties:{version:{type:"string",enum:["v4"]},poolId:{type:"string",description:"32-byte Uniswap v4 poolId hex string."},poolKey:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"},tickLower:{type:"number"},tickUpper:{type:"number"},fullRange:{type:"boolean"},liquidity:L("Position liquidity in base units."),amount0Max:L("Maximum currency0 base units to spend."),amount1Max:L("Maximum currency1 base units to spend."),recipient:{type:"string"},deadline:L(),permit2Expiration:{type:"string"},hookData:{type:"string"},tokenId:L("Existing v4 position NFT to increase (keeps its tick range). Omit to mint a new position."),initialPrice:{type:"string",description:"Only when the pool does not exist: starting price as token1 per 1 token0 in human units (native ETH is 18 decimals). Needs the full poolKey. Creates the pool then mints the first position in separately confirmed transactions."},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}}},Rn={type:"object",description:"Create and initialize an empty Uniswap v4 pool (permissionless PoolManager.initialize). Add liquidity afterwards with uniswap_add.",properties:{version:{type:"string",enum:["v4"]},poolKey:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},currency0:{type:"string",description:"Lower sorted currency; the zero address is native ETH."},currency1:{type:"string"},fee:{type:"number",description:"Static LP fee in pips (3000 = 0.30%), at most 1000000."},tickSpacing:{type:"number"},hooks:{type:"string",description:"Hook address; only hooks Oak has measured are accepted. Defaults to none."},initialPrice:{type:"string",description:'Starting price as token1 per 1 token0 in human units, e.g. "3000" for 1 ETH = 3000 USDG.'},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}}},jn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenId:L(),poolId:{type:"string"},poolKey:{type:"object"},amount0Min:L(),amount1Min:L(),recipient:{type:"string"},deadline:L(),hookData:{type:"string"}},required:["tokenId"]},zn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenId:L(),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$",description:"Positive base-unit liquidity amount, or all for a full burn."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:Ie},fullExit:{type:"boolean"},burn:{type:"boolean"},amount0Min:L(),amount1Min:L(),poolId:{type:"string"},poolKey:{type:"object"},recipient:{type:"string"},deadline:L(),hookData:{type:"string"}},required:["tokenId"]},Wn={type:"object",properties:{version:{type:"string",enum:["v4"]},tokenIds:{type:"array",items:L()},includeZero:{type:"boolean"}}};function cn(e){let n=e.poolKey&&typeof e.poolKey=="object"&&!Array.isArray(e.poolKey)?e.poolKey:e;for(let i of["currency0","currency1","fee","tickSpacing"])if(n[i]===void 0)throw new o(`Creating a pool needs the full poolKey (currency0, currency1, fee, tickSpacing, hooks); ${i} is missing. A poolId alone cannot describe a pool that does not exist yet.`)}function dn(e,n,i){if(e.initialPrice!==void 0&&e.sqrtPriceX96!==void 0)throw new o("Provide initialPrice or sqrtPriceX96, not both.");if(e.sqrtPriceX96!==void 0){if(typeof e.sqrtPriceX96!="string"||!/^\d+$/.test(e.sqrtPriceX96))throw new o("sqrtPriceX96 must be a non-negative integer string.");return je(BigInt(e.sqrtPriceX96))}return Re(e.initialPrice,n,i)}async function Gn(e,n,i){let r;try{r=await e.readContract({address:T,abi:H,functionName:"ownerOf",args:[n]})}catch(c){throw new o(`Could not verify owner of Uniswap v4 position #${n}. ${oe(c)}`)}if(y(r)!==y(i))throw new o(`Wallet ${y(i)} is not the owner of Uniswap v4 position #${n} (owned by ${y(r)}).`)}async function un(e,n){let i=ye(n).toLowerCase(),r=new Map;for(let s of Ke)s.key.currency0.toLowerCase()===n.currency0.toLowerCase()&&s.key.currency1.toLowerCase()===n.currency1.toLowerCase()&&r.set(s.poolId.toLowerCase(),s.key);let c=[];for(let[s,t]of r){if(s===i||BigInt(await e.readContract({address:fe,abi:me,functionName:"getLiquidity",args:[s]}))===0n)continue;let a=await e.readContract({address:fe,abi:me,functionName:"getSlot0",args:[s]});BigInt(a[0])>0n&&c.push({label:`v4 fee ${t.fee} spacing ${t.tickSpacing} pool ${s}`,sqrtPriceX96:BigInt(a[0])})}return c}function ln(e,n,i,r,c,s){return e.unsignedTx({to:Cn.toLowerCase(),data:re({abi:Kn,functionName:"initialize",args:[{currency0:n.currency0.toLowerCase(),currency1:n.currency1.toLowerCase(),fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks.toLowerCase()},r]}),value:"0",chainId:f,description:`Create and initialize Uniswap v4 pool ${i} (${c.symbol}/${s.symbol}, fee ${n.fee}, tickSpacing ${n.tickSpacing}) at ${be(r,c.decimals,s.decimals)} ${s.symbol} per ${c.symbol}.`})}var Zn=e=>({tools:[{name:"uniswap_add",inputSchema:On,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=t.tokenId===void 0?void 0:D(String(t.tokenId));if(a!==void 0&&a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=t.initialPrice!==void 0||t.sqrtPriceX96!==void 0;if(a!==void 0&&p)throw new o("initialPrice cannot be combined with tokenId.");if(t.amount0Min!==void 0||t.amount1Min!==void 0||t.slippageBps!==void 0)throw new o("V4 mint encodes fixed liquidity and amount0Max/amount1Max; amount minima and slippageBps are not supported for minting.");let l=e.clientFor(f);p&&cn(t);let m,u,k,w;if(a!==void 0){if(t.tickLower!==void 0||t.tickUpper!==void 0||t.fullRange!==void 0)throw new o("An existing v4 position keeps its tick range; omit tickLower, tickUpper and fullRange when increasing.");await Gn(l,a,d),{poolId:m,poolKey:u,tickLower:k,tickUpper:w}=await he(l,a,t)}else{({poolId:m,poolKey:u}=await Ue(l,t));let q=Vn(u.tickSpacing);k=t.fullRange===!0&&t.tickLower===void 0?q.tickLower:Number(t.tickLower),w=t.fullRange===!0&&t.tickUpper===void 0?q.tickUpper:Number(t.tickUpper),Hn(k,w,u.tickSpacing)}let[b,S]=await Promise.all([V(l,u.currency0,f),V(l,u.currency1,f)]),I=W(t.amount0Max??t.amount0Desired,"amount0Max"),h=W(t.amount1Max??t.amount1Desired,"amount1Max");if(I<=0n&&h<=0n||I>ne||h>ne)throw new o("Provide positive amount0Max/amount1Max within uint128.");let x=await l.readContract({address:fe,abi:me,functionName:"getSlot0",args:[m]}),v=BigInt(x[0]),E=Number(x[3]),P;if(p){if(v>0n)throw new o(`Pool ${m} already exists; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);let q=dn(t,b.decimals,S.decimals),F=Le(q,await un(l,u),t.acceptPriceDeviation===!0,b.decimals,S.decimals);P={sqrtPriceX96:q,note:F},v=q}else if(v<=0n)throw new o(`Pool ${m} is not initialized on StateView. To create it and add the first liquidity in one tool call with separately confirmed transactions, pass the full poolKey plus initialPrice (token1 per 1 token0, human units); to create it without liquidity use uniswap_create_pool.`);let C=t.liquidity!==void 0?W(t.liquidity,"liquidity"):Bn({amount0:I,amount1:h,tickLower:k,tickUpper:w,sqrtPriceX96:v});if(C<=0n||C>ne)throw new o("Position liquidity must be a positive integer within uint128.");let{amount0:U,amount1:X}=yn({liquidity:C,tickLower:k,tickUpper:w,sqrtPriceX96:v,roundUp:!0});if(U>I||X>h)throw new o("Liquidity requires more tokens than amount0Max or amount1Max.");let G=t.recipient!==void 0?String(t.recipient):d;if($(G),y(G)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let Z=await wn(l),te=await Me(l,t.deadline,Z.toString()),ae=te<Z+Ze?te:Z+Ze,Y=t.permit2Expiration===void 0?ae:D(String(t.permit2Expiration));if(Y<=Z||Y>ae||Y>pn)throw new o("Permit2 expiration must be in the next 30 minutes and no later than the transaction deadline.");let M=typeof t.hookData=="string"?t.hookData:"0x",K=(q,F)=>{let z=P?[ln(e,u,m,P.sqrtPriceX96,b,S)]:[];if(!R(u.currency0)&&q>0n){let ce=u.currency0.toLowerCase();z.push(e.approval(ce,_e.toLowerCase(),q.toString(),f)),z.push(en(ce,T.toLowerCase(),q.toString(),Y.toString(),f))}if(!R(u.currency1)&&F>0n){let ce=u.currency1.toLowerCase();z.push(e.approval(ce,_e.toLowerCase(),F.toString(),f)),z.push(en(ce,T.toLowerCase(),F.toString(),Y.toString(),f))}let O={currency0:u.currency0.toLowerCase(),currency1:u.currency1.toLowerCase(),fee:u.fee,tickSpacing:u.tickSpacing,hooks:u.hooks.toLowerCase()},Se=A(_n,[O,k,w,C,q,F,G.toLowerCase(),M]),gn=A(En,[O.currency0,O.currency1]),Ve=A(Un,[g,G.toLowerCase()]),kn=A(ge,[a??0n,C,q,F,M]),hn=a===void 0?A(le,["0x020d14",[Se,gn,Ve]]):A(le,["0x00121214",[kn,A(Ye,[O.currency0]),A(Ye,[O.currency1]),Ve]]),Pn=re({abi:H,functionName:"modifyLiquidities",args:[hn,te]}),vn=R(u.currency0)?q.toString():"0";return z.push(e.unsignedTx({to:T.toLowerCase(),data:Pn,value:vn,chainId:f,description:a!==void 0?`Increase Uniswap v4 position #${a} on pool ${m} (liquidity +${C}).`:`Mint Uniswap v4 position on pool ${m} (ticks [${k}, ${w}], liquidity ${C}).`})),z},Q=K(U,X),J=await e.preview(Q,d),B=(q,F)=>{let z=R(F)?de:F.toLowerCase();return-q.changes.filter(O=>O.token.address.toLowerCase()===z).reduce((O,Se)=>O+BigInt(Se.amount),0n)},N=B(J,u.currency0),ie=B(J,u.currency1);if(N<0n||ie<0n||N>U||ie>X||N===0n&&ie===0n&&a===void 0)throw new o("Invalid simulated v4 mint spend. Refresh the liquidity preview.");let Fe=a===void 0?K(N,ie):Q,we=a!==void 0||N===U&&ie===X?J:await e.preview(Fe,d);if(B(we,u.currency0)!==N||B(we,u.currency1)!==ie)throw new o("V4 mint spend changed. Refresh the liquidity preview.");let bn=$e(we.changes,e.formatAmount),xe=Je(u,E);return{txs:Fe,preview:we,poolId:m,poolKey:u,tickLower:k,tickUpper:w,liquidity:C.toString(),amount0Max:{token:b,amount:I.toString()},amount1Max:{token:S,amount:h.toString()},dynamicFee:xe.dynamicFee,swapsAreFree:xe.swapsAreFree,action:a!==void 0?"increase":P?"createAndMint":"mint",...a!==void 0?{tokenId:a.toString()}:{},...P?{poolCreated:!0,sqrtPriceX96:P.sqrtPriceX96.toString(),initialPrice:be(P.sqrtPriceX96,b.decimals,S.decimals),initialTick:qe(P.sqrtPriceX96),priceCheck:P.note}:{},summary:`${a!==void 0?`Increase Uniswap v4 position #${a}`:P?"Create Uniswap v4 pool and add first liquidity":"Add Uniswap v4 liquidity"} (${C} L, ticks [${k}, ${w}]) on pool ${m}. Preview deltas: ${bn.join(", ")||"none"}. ${xe.feeNote}${P?` ${P.note}`:""}`}}},{name:"uniswap_collect",inputSchema:jn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=D(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(f),l=t.recipient!==void 0?String(t.recipient):d;if($(l),y(l)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Me(p,t.deadline,t.now),u=t.amount0Min!==void 0?W(t.amount0Min,"amount0Min"):0n,k=t.amount1Min!==void 0?W(t.amount1Min,"amount1Min"):0n;if(u>ne||k>ne)throw new o("amount0Min and amount1Min must fit in uint128.");let w=typeof t.hookData=="string"?t.hookData:"0x",{poolKey:b,poolId:S}=await he(p,a,t),[I,h]=await Promise.all([V(p,b.currency0,f),V(p,b.currency1,f)]),x=A(ge,[a,0n,u,k,w]),v=A(Te,[b.currency0.toLowerCase(),b.currency1.toLowerCase(),l.toLowerCase()]),E=A(le,["0x0111",[x,v]]),P=re({abi:H,functionName:"modifyLiquidities",args:[E,m]}),C=[e.unsignedTx({to:T.toLowerCase(),data:P,value:"0",chainId:f,description:`Collect Uniswap v4 fees from position #${a} to ${l}.`})],U=await e.preview(C,d),X=$e(U.changes,e.formatAmount);return{txs:C,preview:U,tokenId:a.toString(),poolId:S,recipient:l,currencies:[I,h],summary:`Collect Uniswap v4 fees for position #${a} (actions 0x0111). Preview deltas: ${X.join(", ")||"0"}.`}}},{name:"uniswap_remove",inputSchema:zn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=D(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(f),l=t.recipient!==void 0?String(t.recipient):d;if($(l),y(l)!==y(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Me(p,t.deadline,t.now),{poolKey:u,poolId:k}=await he(p,a,t),[w,b]=await Promise.all([V(p,u.currency0,f),V(p,u.currency1,f)]),S=t.slippageBps??Ie;if(typeof S!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");Ce("0",S);let I=typeof t.hookData=="string"?t.hookData:"0x",h=t.fullExit===!0||t.burn===!0||t.liquidity==="all";if(!h&&t.liquidity===void 0)throw new o('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let x=t.liquidity===void 0||t.liquidity==="all"?void 0:W(t.liquidity,"liquidity");if(x!==void 0&&(x<0n||x===0n&&!h||x>ne))throw new o("Provide positive liquidity within uint128 for v4 removal.");let v;try{v=BigInt(await p.readContract({address:T,abi:H,functionName:"getPositionLiquidity",args:[a]}))}catch(M){throw new o(`Could not read v4 position liquidity. ${oe(M)}`)}if(v<0n||v===0n&&!h||x!==void 0&&x>v)throw new o("Removal requires a nonempty position and cannot exceed its liquidity.");if(h&&x!==void 0&&x!==v)throw new o("A full burn must match the position liquidity; omit the amount when explicitly choosing all.");let E=h?"0x0311":"0x0111",P=(M,K,Q)=>{let J=h?A(Dn,[a,M,K,I]):A(ge,[a,x,M,K,I]),B=A(Te,[u.currency0,u.currency1,Q]);return e.unsignedTx({to:T.toLowerCase(),data:re({abi:H,functionName:"modifyLiquidities",args:[A(le,[E,[J,B]]),m]}),value:"0",chainId:f,description:`${h?"Burn and exit":"Decrease"} Uniswap v4 position #${a} (${E}).`})},C=0n,U=0n;if(v>0n&&(t.amount0Min===void 0||t.amount1Min===void 0)){let M=e.unsignedTx({to:T.toLowerCase(),data:re({abi:H,functionName:"modifyLiquidities",args:[A(le,["0x0111",[A(ge,[a,0n,0n,0n,I]),A(Te,[u.currency0,u.currency1,T])]]),m]}),value:"0",chainId:f,description:"Simulation only: separate fees from removal principal."}),K=await e.preview([M,P(2n,2n,d)],d),Q=J=>K.changes.reduce((B,N)=>N.token.chainId===f&&N.token.address.toLowerCase()===J.address.toLowerCase()?B+BigInt(N.amount):B,0n);if(C=Q(w),U=Q(b),C<0n||U<0n)throw new o("Removal simulation did not return the expected currencies.")}let X=(M,K)=>{if(M!==void 0&&W(M,K)!==0n)throw new o(`${K} must be zero for an empty position burn.`);return 0n},G=v===0n?X(t.amount0Min,"amount0Min"):sn(t.amount0Min,C,S,"amount0Min"),Z=v===0n?X(t.amount1Min,"amount1Min"):sn(t.amount1Min,U,S,"amount1Min"),te=[P(G,Z,l)],ae=await e.preview(te,d),Y=$e(ae.changes,e.formatAmount);return{txs:te,preview:ae,action:E,tokenId:a.toString(),poolId:k,amount0Min:{token:w,amount:G.toString()},amount1Min:{token:b,amount:Z.toString()},summary:`${h?"Full exit":"Partial remove"} Uniswap v4 position #${a} (${E})${h?`; burns position #${a} at ${T}`:""}. Preview deltas: ${Y.join(", ")||"none"}.`}}},{name:"uniswap_list_positions",inputSchema:Wn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=Array.isArray(t.tokenIds)?t.tokenIds:void 0,p=t.includeZero===!0,l=await an(e,d,{tokenIds:a,includeZero:p});return{version:"v4",positions:l,summary:`Found ${l.length} active Uniswap v4 position(s) for ${d}.`}}},{name:"uniswap_create_pool",inputSchema:Rn,async execute(t,d){if($(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');cn(t);let a=e.clientFor(f),{poolId:p,poolKey:l}=await Ue(a,t),[m,u]=await Promise.all([V(a,l.currency0,f),V(a,l.currency1,f)]),k=await a.readContract({address:fe,abi:me,functionName:"getSlot0",args:[p]});if(BigInt(k[0])>0n)throw new o(`Uniswap v4 pool ${p} already exists. Use uniswap_add to provide liquidity.`);let w=dn(t,m.decimals,u.decimals),b=Le(w,await un(a,l),t.acceptPriceDeviation===!0,m.decimals,u.decimals),S=be(w,m.decimals,u.decimals),I=[ln(e,l,p,w,m,u)],h=await e.preview(I,d),x=Je(l,l.fee);return{txs:I,preview:h,poolId:p,poolKey:l,sqrtPriceX96:w.toString(),initialPrice:S,initialTick:qe(w),priceCheck:b,action:"createPool",summary:`${I[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add. ${x.feeNote} ${b}`}}}],positions:t=>an(e,t)}),ct=Zn;export{Cn as a,T as b,fe as c,_e as d,at as e,se as f,_ as g,g as h,De as i,Ee as j,Pe as k,Ln as l,Ke as m,Ne as n,fn as o,Tn as p,$n as q,R as r,ye as s,mn as t,Je as u,ke as v,Vn as w,Hn as x,en as y,Xn as z,yn as A,Bn as B,$e as C,rn as D,V as E,he as F,an as G,On as H,Rn as I,jn as J,zn as K,Wn as L,un as M,Zn as N,ct as O};