@oakagentkit/core 0.1.9 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/api/deployments.d.ts +26 -0
- package/build/dist/api/deployments.js +1 -0
- package/build/dist/api/history.js +1 -1
- package/build/dist/api/modules/beefy/clm.js +1 -1
- package/build/dist/api/modules/beefy/guard.js +1 -1
- package/build/dist/api/modules/beefy/index.js +1 -1
- package/build/dist/api/modules/beefy/liquidity.js +1 -1
- package/build/dist/api/modules/clanker/index.js +1 -1
- package/build/dist/api/modules/grove/index.js +1 -1
- package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
- package/build/dist/api/modules/hoodlock/fee.js +1 -1
- package/build/dist/api/modules/hoodlock/guard.js +1 -1
- package/build/dist/api/modules/hoodlock/index.js +1 -1
- package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
- package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
- package/build/dist/api/modules/hoodlock/public.js +1 -1
- package/build/dist/api/modules/hookr/actions.js +1 -1
- package/build/dist/api/modules/hookr/addons.js +1 -1
- package/build/dist/api/modules/hookr/contracts.js +1 -1
- package/build/dist/api/modules/hookr/create-cancel.js +1 -1
- package/build/dist/api/modules/hookr/discovery.js +1 -1
- package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
- package/build/dist/api/modules/hookr/index.js +1 -1
- package/build/dist/api/modules/hookr/public-reads.js +1 -1
- package/build/dist/api/modules/hookr/relay.js +1 -1
- package/build/dist/api/modules/kyberswap/index.js +1 -1
- package/build/dist/api/modules/kyberswap/source-pools.d.ts +22 -3
- package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
- package/build/dist/api/modules/longbow/administration.js +1 -1
- package/build/dist/api/modules/longbow/fixed.js +1 -1
- package/build/dist/api/modules/longbow/index.js +1 -1
- package/build/dist/api/modules/meridian/index.js +1 -1
- package/build/dist/api/modules/meridian/rfq.js +1 -1
- package/build/dist/api/modules/morpho/bundles.js +1 -1
- package/build/dist/api/modules/morpho/in-kind.js +1 -1
- package/build/dist/api/modules/morpho/index.js +1 -1
- package/build/dist/api/modules/morpho/local-guard.js +1 -1
- package/build/dist/api/modules/morpho/midnight.js +1 -1
- package/build/dist/api/modules/morpho/protocol.js +1 -1
- package/build/dist/api/modules/morpho/vault-tools.js +1 -1
- package/build/dist/api/modules/netnet/card-plan.js +1 -1
- package/build/dist/api/modules/netnet/card-read.js +1 -1
- package/build/dist/api/modules/netnet/card-recovery.js +1 -1
- package/build/dist/api/modules/netnet/desk-action.js +1 -1
- package/build/dist/api/modules/netnet/financial.js +1 -1
- package/build/dist/api/modules/netnet/index.js +1 -1
- package/build/dist/api/modules/orbio/index.js +1 -1
- package/build/dist/api/modules/pons/claim.js +1 -1
- package/build/dist/api/modules/pons/index.js +1 -1
- package/build/dist/api/modules/pons/launch-status.js +1 -1
- package/build/dist/api/modules/pons/reads.js +1 -1
- package/build/dist/api/modules/pons/trade.js +1 -1
- package/build/dist/api/modules/poolstrade/index.js +1 -1
- package/build/dist/api/modules/priors/coverage.js +1 -1
- package/build/dist/api/modules/priors/discovery.js +1 -1
- package/build/dist/api/modules/priors/index.js +1 -1
- package/build/dist/api/modules/priors/integration.js +1 -1
- package/build/dist/api/modules/priors/stock-swap.js +1 -1
- package/build/dist/api/modules/relay/discovery.js +1 -1
- package/build/dist/api/modules/relay/inbound.js +1 -1
- package/build/dist/api/modules/relay/index.js +1 -1
- package/build/dist/api/modules/relay/outbound-status.js +1 -1
- package/build/dist/api/modules/steakhouse/index.js +1 -1
- package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
- package/build/dist/api/modules/steakhouse/management.js +1 -1
- package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
- package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
- package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
- package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
- package/build/dist/api/modules/tickerspring/guards.js +1 -1
- package/build/dist/api/modules/tickerspring/index.js +1 -1
- package/build/dist/api/modules/tickerspring/journeys.js +1 -1
- package/build/dist/api/modules/tickerspring/ladder.js +1 -1
- package/build/dist/api/modules/tickerspring/maker.js +1 -1
- package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
- package/build/dist/api/modules/tickerspring/research.js +1 -1
- package/build/dist/api/modules/tickerspring/strategies.js +1 -1
- package/build/dist/api/modules/uniswap/auction-create.js +1 -1
- package/build/dist/api/modules/uniswap/auction.js +1 -1
- package/build/dist/api/modules/uniswap/batch.js +1 -1
- package/build/dist/api/modules/uniswap/common.js +1 -1
- package/build/dist/api/modules/uniswap/fees.js +1 -1
- package/build/dist/api/modules/uniswap/index.js +1 -1
- package/build/dist/api/modules/uniswap/local-guard.js +1 -1
- package/build/dist/api/modules/uniswap/oracle.js +1 -1
- package/build/dist/api/modules/uniswap/pool-math.js +1 -1
- package/build/dist/api/modules/uniswap/pools.js +1 -1
- package/build/dist/api/modules/uniswap/position.js +1 -1
- package/build/dist/api/modules/uniswap/protocol.js +1 -1
- package/build/dist/api/modules/uniswap/token-jar.js +1 -1
- package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
- package/build/dist/api/modules/uniswap/trade.js +1 -1
- package/build/dist/api/modules/uniswap/v2.js +1 -1
- package/build/dist/api/modules/uniswap/v3.js +1 -1
- package/build/dist/api/modules/uniswap/v4.js +1 -1
- package/build/dist/api/modules/uniswap/wrap.js +1 -1
- package/build/dist/api/modules/velora/claims.js +1 -1
- package/build/dist/api/modules/velora/index.js +1 -1
- package/build/dist/api/prices.js +1 -1
- package/build/dist/api/routes.d.ts +2 -0
- package/build/dist/api/routes.js +1 -1
- package/build/dist/api/send.js +1 -1
- package/build/dist/api/signing-registry.js +1 -1
- package/build/dist/api/simulate.js +1 -1
- package/build/dist/api/swap.js +1 -1
- package/build/dist/api/tokens.d.ts +4 -0
- package/build/dist/api/tokens.js +1 -1
- package/build/dist/chunks/{ZL3KVABO.js → 22S4SFD5.js} +1 -1
- package/build/dist/chunks/{MWWYIFXJ.js → 2CS3M32D.js} +1 -1
- package/build/dist/chunks/{JVTVOK6P.js → 3R3C3CU5.js} +1 -1
- package/build/dist/chunks/{QOY4AANB.js → 3ZVGHC6S.js} +1 -1
- package/build/dist/chunks/{2EGFALNH.js → 5LQBHXFA.js} +1 -1
- package/build/dist/chunks/{OJP7Y4AM.js → 5RKWSFD2.js} +1 -1
- package/build/dist/chunks/6L6DSMCU.js +1 -0
- package/build/dist/chunks/{FLXID6I3.js → 6LLOTPH2.js} +1 -1
- package/build/dist/chunks/{JOMK32QW.js → 72AWP4BM.js} +1 -1
- package/build/dist/chunks/{C5LR6F4B.js → 7T4BYFD4.js} +1 -1
- package/build/dist/chunks/{W6G2QGYF.js → AZGMF26W.js} +1 -1
- package/build/dist/chunks/{PHXWBC4O.js → BBVKWG65.js} +1 -1
- package/build/dist/chunks/{HYIEQG4X.js → BEPSWFJX.js} +1 -1
- package/build/dist/chunks/{YONRUWN7.js → BG4S6MSN.js} +1 -1
- package/build/dist/chunks/{QH3AL3UN.js → BV3AHLH5.js} +1 -1
- package/build/dist/chunks/CAU44UWP.js +1 -0
- package/build/dist/chunks/{BQLLTY4L.js → D4WURN33.js} +1 -1
- package/build/dist/chunks/{HACP2Q6D.js → D6VP3N27.js} +2 -2
- package/build/dist/chunks/{6SB3FB3P.js → DD7755AW.js} +1 -1
- package/build/dist/chunks/{4CDR7F4I.js → DGGOO4RN.js} +1 -1
- package/build/dist/chunks/{VCWDJQDE.js → DVKDWXEJ.js} +1 -1
- package/build/dist/chunks/{4X6JEMSF.js → E24S22BZ.js} +1 -1
- package/build/dist/chunks/EA6IYKIB.js +1 -0
- package/build/dist/chunks/{SYZ55RCX.js → EYYUWFUR.js} +1 -1
- package/build/dist/chunks/FBQWTWPT.js +1 -0
- package/build/dist/chunks/{P6ELT4ZV.js → FKAA7VUR.js} +1 -1
- package/build/dist/chunks/{NUWL6TJM.js → GECX5U3F.js} +1 -1
- package/build/dist/chunks/{B72Q2EQ2.js → GUBB5P6V.js} +1 -1
- package/build/dist/chunks/{EHVPRQHS.js → I7NUTSSX.js} +1 -1
- package/build/dist/chunks/{ITIIHCZK.js → IAXKPME3.js} +1 -1
- package/build/dist/chunks/{WQZLYX64.js → IRWEY7TQ.js} +1 -1
- package/build/dist/chunks/{2LM5C7FQ.js → IUETZH6I.js} +1 -1
- package/build/dist/chunks/{FL3EF72E.js → JG24LNUI.js} +1 -1
- package/build/dist/chunks/{IKP3Z3RX.js → K7HIKXNT.js} +1 -1
- package/build/dist/chunks/LFN3OODW.js +1 -0
- package/build/dist/chunks/{FYTF2QMS.js → MEMVFR7Z.js} +1 -1
- package/build/dist/chunks/{37QNUNED.js → MNFU7PO3.js} +1 -1
- package/build/dist/chunks/{REGJY5RC.js → N37ZLNCT.js} +1 -1
- package/build/dist/chunks/{UEYFMXV3.js → N3GWFLG6.js} +1 -1
- package/build/dist/chunks/{SEW7UP5U.js → NCEJZWGX.js} +1 -1
- package/build/dist/chunks/{OK3TQFXZ.js → NKY3DT34.js} +1 -1
- package/build/dist/chunks/NMFVXBTL.js +1 -0
- package/build/dist/chunks/{SS7U3CMZ.js → NUTHT4FE.js} +1 -1
- package/build/dist/chunks/{5H3MQWH7.js → O7PQDUVT.js} +1 -1
- package/build/dist/chunks/{CS55ERS3.js → OMTCWXQR.js} +1 -1
- package/build/dist/chunks/{JRZLKIYB.js → PR2QED25.js} +1 -1
- package/build/dist/chunks/{B7V7AA5A.js → Q4RZQCDS.js} +1 -1
- package/build/dist/chunks/{E2IVNGLC.js → QR7ALOR4.js} +1 -1
- package/build/dist/chunks/{SQH7A4O3.js → QXFJZGVB.js} +1 -1
- package/build/dist/chunks/{ZPNGV34U.js → QYHJWU5T.js} +1 -1
- package/build/dist/chunks/{NNZ4SZZ4.js → QZM7CWZW.js} +1 -1
- package/build/dist/chunks/{E2Q5IA67.js → RM5W63LO.js} +1 -1
- package/build/dist/chunks/{Z4LJ2GTX.js → RTBOMWCB.js} +1 -1
- package/build/dist/chunks/T3MGNKA6.js +1 -0
- package/build/dist/chunks/{L2MTPRU7.js → T3NPRRTY.js} +1 -1
- package/build/dist/chunks/{HF2AGJZC.js → TDN3C4IG.js} +1 -1
- package/build/dist/chunks/{WHT45EFX.js → UIIJWIR6.js} +1 -1
- package/build/dist/chunks/{CAYBSVA6.js → ULJ6E4HP.js} +1 -1
- package/build/dist/chunks/{K2LWX3PZ.js → UMK564HS.js} +1 -1
- package/build/dist/chunks/{AIWZGIZ6.js → UPPYXY74.js} +1 -1
- package/build/dist/chunks/{XCFA73P2.js → VJ3W2V3B.js} +1 -1
- package/build/dist/chunks/{RNEMTLQG.js → VY3P34PY.js} +1 -1
- package/build/dist/chunks/{EKGHKEKV.js → WLACEU2Y.js} +1 -1
- package/build/dist/chunks/{KEPQXFHU.js → X6G4BD35.js} +1 -1
- package/build/dist/chunks/{CXMC3T6B.js → XGUKLFBU.js} +1 -1
- package/build/dist/chunks/XUJSQV52.js +1 -0
- package/build/dist/chunks/{LFKSXD3S.js → YMB553OJ.js} +1 -1
- package/build/dist/chunks/{BBQVTEYB.js → ZGXNTWYG.js} +1 -1
- package/package.json +2 -2
- package/build/dist/chunks/2O6A6WEX.js +0 -1
- package/build/dist/chunks/3Z3U4YPA.js +0 -1
- package/build/dist/chunks/74BPMUAG.js +0 -1
- package/build/dist/chunks/E7ASOYQI.js +0 -1
- package/build/dist/chunks/EAEQOS7Y.js +0 -1
- package/build/dist/chunks/HZUWK5B2.js +0 -1
- package/build/dist/chunks/OJMYESQU.js +0 -1
- package/build/dist/chunks/ZQI7B2Z7.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b as o,d as r}from"./
|
|
1
|
+
import{a,b as o,d as r}from"./IRWEY7TQ.js";import{c as s}from"./HNMOB76J.js";import{a as t}from"./XPFVT2EA.js";var i=[{feature:"Ethos claim",source:"https://go.priors.trade/start-ethos.js",missing:"Public claim endpoint signs/sends the sponsor transaction remotely. No unsigned final transaction with a local preview/confirmation handoff is published. Use the owner Go Start workflow; Oak offers status and route discovery."},{feature:"x402 pay_url, paid reports, hire payments and pay_gateway",source:"https://github.com/priors-agents/priors/tree/02230282d8888e00794207ed271ee01b4ce30309/packages/x402",missing:"These hand EIP-3009 payment authorization to an external merchant/facilitator. The recipient settles remotely; no Oak-local unsigned transaction handoff is exposed. Oak discovery is supported; external payment-signature validation, recipient/invoice binding and preview semantics require a shared add-on protocol, beyond this module write scope. Gateway source also says its live 402 surface was not measured."},{feature:"Go Google/Privy account, gas sponsorship, recovery and agent001 approvals",source:"https://go.priors.trade/account",missing:"Authenticated smart-account/session and sponsored-operation APIs are not publicly specified as an unsigned plain-wallet contract. Owner uses Priors UI. Underlying pool, stock, savings and backing contracts are supported here."},{feature:"Publish merchant listings, job offers/results, board requests and signed public offers",source:"https://priors.trade/agent",missing:"Hosted MCP supplies discovery and signed board reads. A versioned authenticated mutation/withdrawal contract is not pinned from the inspected public SDK. Existing owner consent plus direct sponsor offer is supported on chain; creating external listings/messages remains an owner workflow."},{feature:"Create the X proof post",source:"https://go.priors.trade/xlink-core.js",missing:"Requires the human account owner to publish on X. Oak can set or clear the canonical proof URL as public ERC-8004 metadata, but does not publish posts or claim metadata alone verifies X ownership."}];function p(){return{tools:[{name:"priors_capabilities",inputSchema:{type:"object",properties:{},additionalProperties:!1},async execute(){return{chainId:t,sourceCommit:"02230282d8888e00794207ed271ee01b4ce30309",reads:[...a],actions:[...r],localOwnerSignatures:[...o],ownerOnly:s.filter(e=>e.owner).map(e=>e.name),blocked:i.map(e=>({...e,status:"BLOCKED"})),integration:"The shared bridge/server diffs must be integrated for open reads, local signing continuations, exact calldata reconstruction, action destinations and human confirmation. New core builders fail closed in older add-ons; a core-only install does not establish end-to-end feature availability.",safety:"Every local action previews its exact unsigned transaction bundle. Approvals equal inputs or explicit finite future budgets; never unlimited. Persistent autopay and bids authorize later third-party execution within the stated budget. Token backing is collateral and provides no promised returns."}}}]}}export{i as a,p as b};
|
|
@@ -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"./T3MGNKA6.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{b as H,o as q}from"./EAEQOS7Y.js";import{a as de,b as ce,c as le}from"./HFQS5344.js";import{a as ae}from"./G7UKNO2I.js";import{a as ue,b as me}from"./BYXBS45D.js";import{a as pe}from"./GZ5TW3WB.js";import{e as U,h as B,m as re}from"./5EHQM6DM.js";import{b as ie}from"./AXYOJBX6.js";import{c as se}from"./MYBDO5SA.js";import{c as M,e as x,g as w,k as ee,l as ne,m as te,n as oe}from"./73N3TOJL.js";import{a as h,i as Y}from"./XPFVT2EA.js";import{a as E}from"./EG6M6SSO.js";import{a as s}from"./5YS5V2LK.js";import{decodeFunctionResult as Ce,encodeAbiParameters as F,encodeFunctionData as N,erc20Abi as V,isAddress as Ie,parseAbi as we,parseAbiParameters as j,toHex as J,zeroAddress as W}from"viem";var k=Y[h].clanker,fe=we(["function deployToken(((address tokenAdmin,string name,string symbol,bytes32 salt,string image,string metadata,string context,uint256 originatingChainId) tokenConfig,(address hook,address pairedToken,int24 tickIfToken0IsClanker,int24 tickSpacing,bytes poolData) poolConfig,(address locker,address[] rewardAdmins,address[] rewardRecipients,uint16[] rewardBps,int24[] tickLower,int24[] tickUpper,uint16[] positionBps,bytes lockerData) lockerConfig,(address mevModule,bytes mevModuleData) mevModuleConfig,(address extension,uint256 msgValue,uint16 extensionBps,bytes extensionData)[] extensionConfigs) config) payable returns (address)","function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),C=we(["function availableFees(address,address) view returns (uint256)","function claim(address,address)","function collectRewards(address)","function mevModuleEnabled(bytes32) view returns (bool)","function mevModuleOperational(bytes32) returns (bool)"]),I={address:k.paired_weth.address,symbol:"WETH",decimals:18,chainId:h},Pe="https://www.clanker.world/api/tokens",ye={type:"string",pattern:"^\\d+$"},he={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"};function P(n){return ne(ee(n,U),U)}function ge(n,t){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new s(`Provide an explicit bytes32 ${t}.`);return n}function T(n,t,a=!1){if(n===void 0&&!a)return"";if(typeof n!="string"||a&&!n.trim())throw new s(`Provide ${t} as text.`);return n}function z(n,t=256){return oe(n,`Amount exceeds the uint${t} range.`,{bits:t})}function G(n){return te(n,"The contract returned an invalid amount.").toString()}function O(n,t){let a=Object.keys(n).find(p=>!t.includes(p));if(a)throw new s(`Unsupported Clanker input: ${a}.`)}function be(n,t){return t.changes.map(({token:a,amount:p})=>{let b=p.startsWith("-");return`${b?"-":"+"}${n.formatAmount(b?p.slice(1):p,a.decimals)} ${a.symbol} (${a.address}, chain ${a.chainId})`}).join("; ")}function Te(n){return x(n)&&Array.isArray(n.data)&&Number.isSafeInteger(n.total)&&Number(n.total)>=0&&Number.isSafeInteger(n.tokensDeployed)&&Number(n.tokensDeployed)>=0&&(n.cursor===null||typeof n.cursor=="string"||n.cursor===void 0&&n.data.length===0&&n.total===0&&n.tokensDeployed===0)&&n.data.every(t=>x(t)&&typeof t.name=="string"&&typeof t.symbol=="string"&&Number.isSafeInteger(t.chain_id)&&["contract_address","admin","msg_sender","factory_address"].every(a=>typeof t[a]=="string"&&Ie(t[a],{strict:!1})))}async function ve(n,t={}){O(t,["q","limit","cursor","deployer"]);let a=t.limit??10;if(typeof a!="number"||!Number.isInteger(a)||a<1||a>20)throw new s("Choose an indexer limit from 1 to 20.");let p=new URL(Pe);p.searchParams.set("chainId",String(h)),p.searchParams.set("limit",String(a)),t.q!==void 0&&p.searchParams.set("q",T(t.q,"search")),t.cursor!==void 0&&p.searchParams.set("cursor",T(t.cursor,"cursor",!0)),t.deployer!==void 0&&p.searchParams.set("msgSender",P(t.deployer));let b=await se(n.http,p.toString(),{headers:{"User-Agent":"Oak-Clanker/1.0"}},Te);return{tokens:b.data.filter(v=>v.chain_id===h&&w(v.factory_address,k.factory.address)),total:b.total,cursor:b.cursor||null,tokensDeployed:b.tokensDeployed}}var Se=n=>{let t=()=>n.clientFor(h),a=async e=>{try{return await e()}catch(i){throw new s(n.plainError(i))}},p=(e,i,l,d="0")=>n.unsignedTx({to:e,data:i,value:d,chainId:h,description:l}),b=async(e,i)=>G(await t().readContract({address:k.fee_locker.address,abi:C,functionName:"availableFees",args:[e,i]})),v=async e=>{if(w(e,I.address))return I;let[i,l]=await Promise.all([t().readContract({address:e,abi:V,functionName:"symbol"}),t().readContract({address:e,abi:V,functionName:"decimals"})]);if(typeof i!="string"||!i.trim()||!Number.isInteger(l)||l<0||l>255)throw new s("The contract returned invalid token metadata.");return{address:e,chainId:h,symbol:i,decimals:l}},Z=e=>ve(n,e),ke=async(e,i)=>{if(O(e,["name","symbol","salt","image","metadata","context","vanity","initialBuy","minAmountOut","slippageBps","rewards","vault","airdrop","feeBps","pool"]),e.vanity!==void 0&&e.vanity!==!1)throw new s("Clanker launches use vanity false and an explicit salt.");let l=T(e.name,"token name",!0),d=T(e.symbol,"token symbol",!0),g=ge(e.salt,"salt"),f=z(e.initialBuy??"0"),u=e.slippageBps??H;if(typeof u!="number")throw new s("Slippage must be an integer from 0 to 9999 bps.");q("0",u);let o=e.minAmountOut===void 0?void 0:z(e.minAmountOut,128);if(o!==void 0&&o<=1n)throw new s("Initial-buy minimum must exceed one base unit.");if(!f&&o!==void 0)throw new s("A minimum requires a positive initial buy.");let c=ce(e,i);B(e.feeBps??100,0,1e3);let y=me(e);if(f&&!w(y.poolConfig.pairedToken,I.address))throw new s("An initial ETH buy currently requires a WETH-paired pool. Launch without an initial buy and obtain a protected swap quote separately.");let r=e.rewards??[{admin:i,recipient:i,bps:1e4,feePreference:0}];if(!Array.isArray(r)||!r.length||r.length>7)throw new s("Provide one to seven reward allocations.");let A=r.map(m=>{if(!x(m))throw new s("Provide reward allocations as objects.");return O(m,["admin","recipient","bps","feePreference"]),{admin:P(m.admin),recipient:P(m.recipient),bps:B(m.bps,1,1e4),feePreference:B(m.feePreference??0,0,2)}});if(A.reduce((m,S)=>m+S.bps,0)!==1e4)throw new s("Reward allocations must total 10000 bps.");let $={tokenConfig:{tokenAdmin:i,name:l,symbol:d,salt:g,image:T(e.image,"image"),metadata:T(e.metadata,"metadata"),context:e.context===void 0?JSON.stringify({interface:"Oak",platform:"robinhood"}):T(e.context,"context"),originatingChainId:BigInt(h)},poolConfig:y.poolConfig,lockerConfig:{locker:k.locker.address,rewardAdmins:A.map(m=>m.admin),rewardRecipients:A.map(m=>m.recipient),rewardBps:A.map(m=>m.bps),tickLower:y.tickLower,tickUpper:y.tickUpper,positionBps:y.positionBps,lockerData:F(j("(uint8[])"),[[A.map(m=>m.feePreference)]])},mevModuleConfig:{mevModule:k.mev_module.address,mevModuleData:F(j("(uint24,uint24,uint256)"),[[666777,41673,15n]])},extensionConfigs:c},xe=await t().simulateContract({address:k.factory.address,abi:fe,functionName:"deployToken",args:[$],account:i,value:0n,gas:E}),_=P(xe.result),K=m=>{let S=[...c,...f?[{extension:k.devbuy.address,msgValue:f,extensionBps:0,extensionData:F(j("(address,address,uint24,int24,address),uint128,address"),[[W,W,0,0,W],m,i])}]:[]];return p(k.factory.address,N({abi:fe,functionName:"deployToken",args:[{...$,extensionConfigs:S}]}),`Launch ${l} (${d}); initial buy ${f} native ETH base units.`,f.toString())};if(f&&o===void 0){let S=(await n.preview([K(0n)],i)).changes.filter(D=>D.token.chainId===h&&w(D.token.address,_)&&D.token.decimals===18).reduce((D,X)=>D+(/^-?\d+$/.test(X.amount)?BigInt(X.amount):(()=>{throw new s("Invalid initial-buy simulation amount.")})()),0n);if(S<=0n)throw new s("Initial-buy simulation returned no token output.");if(o=z(q(S.toString(),u),128),o<=1n)throw new s("Initial-buy output is too small for a protected minimum.")}let Q=[K(o??0n)],R=await n.preview(Q,i);return{txs:Q,preview:R,predictedToken:_,token:{address:_,chainId:h,symbol:d,decimals:18},...o!==void 0?{minAmountOut:o.toString()}:{},summary:`Launch ${d} at ${_} (CREATE2 address predicted from simulation); vanity false; salt ${g}. Supply 100000000000000000000000000000 base units (18 decimals). ${y.feeSummary}; protocol adds 20% of LP fees. Pool and LP allocations: ${JSON.stringify(y)}. Reward allocations: ${JSON.stringify(A)}. Extensions: ${JSON.stringify({vault:e.vault,airdrop:e.airdrop})}. Sniper fees 666777 to 41673 over 15 seconds. ${R.summary} ${be(n,R)}`}},Ae=async(e,i)=>{if(O(e,["token","poolId","collect"]),e.collect!==void 0&&typeof e.collect!="boolean")throw new s("collect must be boolean.");if(e.collect===!1&&e.poolId!==void 0)throw new s("poolId requires collection.");if(e.collect===!0&&e.token===void 0)throw new s("Collection requires a Clanker token.");if(e.poolId!==void 0&&e.token===void 0)throw new s("A pool ID requires its Clanker token.");let l=[I],d=[];if(e.token!==void 0){let o=P(e.token);if(w(o,I.address))throw new s("Provide the launched Clanker token, not WETH.");if(e.collect!==!1){let c=await re(n,o),{poolId:y,hook:r,locker:A}=c;if(e.poolId!==void 0&&!w(ge(e.poolId,"pool ID for fee collection"),y))throw new s("The supplied pool ID does not match the onchain Clanker pool.");w(c.pairedToken,I.address)||l.splice(0,1,await v(c.pairedToken));let $=await t().readContract({address:r,abi:C,functionName:"mevModuleEnabled",args:[y]});if(typeof $!="boolean")throw new s("The hook returned an invalid MEV guard state.");$&&d.push(p(r,N({abi:C,functionName:"mevModuleOperational",args:[y]}),"Update the Clanker pool MEV guard before collection.")),d.push(p(A,N({abi:C,functionName:"collectRewards",args:[o]}),"Collect pending LP fees into the fee locker."))}l.push(await v(o))}let g;if(d.length){if(await t().getChainId()!==h)throw new s("Fee simulation endpoint is on the wrong chain.");let o=[...d.map(r=>({from:i,gas:J(E),to:r.to,data:r.data,value:J(BigInt(r.value))})),...l.map(r=>({from:i,gas:J(E),to:k.fee_locker.address,data:N({abi:C,functionName:"availableFees",args:[i,r.address]}),value:"0x0"}))],c=await t().request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:o}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(c)||c.length!==1||!x(c[0])||!Array.isArray(c[0].calls)||c[0].calls.length!==o.length)throw new s("The endpoint returned an unexpected fee simulation response.");let y=c[0].calls;if(!y.every(r=>x(r)&&r.status==="0x1"&&!r.error))throw new s("Clanker fee collection simulation failed.");g=y.slice(d.length).map(r=>{if(!x(r)||typeof r.returnData!="string"||!/^0x[0-9a-fA-F]{64}$/.test(r.returnData))throw new s("The endpoint returned an invalid fee balance.");return G(Ce({abi:C,functionName:"availableFees",data:r.returnData}))})}else g=await Promise.all(l.map(o=>b(i,o.address)));let f=l.flatMap((o,c)=>BigInt(g[c])>0n?[{token:o,amount:g[c]}]:[]);if(!f.length)throw new s("No claimable fees for this wallet; pending LP fees may require the MEV window to end.");for(let{token:o}of f)d.push(p(k.fee_locker.address,N({abi:C,functionName:"claim",args:[i,o.address]}),`Claim ${o.symbol} fees to ${i}.`));let u=await n.preview(d,i);return{txs:d,preview:u,fees:f,summary:`Claim fees to ${i}. WETH fees aggregate across all Clanker launches for this recipient. ${u.summary} ${be(n,u)}`}},L=(e,i,l,d)=>({name:`clanker_${e}`,inputSchema:{type:"object",properties:i,required:l,additionalProperties:!1},execute:(g,f)=>a(async()=>d(g,P(f)))});return{tools:[L("launch",{name:{type:"string"},symbol:{type:"string"},salt:he,image:{type:"string"},metadata:{type:"string"},context:{type:"string"},vanity:{const:!1},initialBuy:{...ye,description:"Native ETH base units, 18 decimals."},minAmountOut:{...ye,description:"Minimum new token base units, 18 decimals; derived from simulation when omitted."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:H},feeBps:{type:"integer",minimum:0,maximum:1e3,default:100},pool:ue,rewards:{type:"array",minItems:1,maxItems:7,items:{type:"object",properties:{admin:M,recipient:M,bps:{type:"integer",minimum:1,maximum:1e4},feePreference:{type:"integer",minimum:0,maximum:2}},required:["admin","recipient","bps"],additionalProperties:!1}},...de},["name","symbol","salt"],ke),L("claim",{token:{...M,description:"Launched token; derives its onchain pool and collects pending LP fees before claiming."},poolId:{...he,description:"Optional assertion against the derived pool ID."},collect:{type:"boolean",default:!0,description:"Set false to claim only already-collected fees."}},[],Ae),L("browse",{q:{type:"string"},limit:{type:"integer",minimum:1,maximum:20},cursor:{type:"string"},deployer:M},[],Z)],positions:e=>a(async()=>{P(e);let i=new Map,l=new Set,d;do{let u=await Z({deployer:e,limit:20,...d?{cursor:d}:{}});for(let o of u.tokens)w(o.msg_sender,e)&&i.set(o.contract_address.toLowerCase(),o);if(u.cursor&&l.has(u.cursor))throw new s("The Clanker indexer repeated a pagination cursor.");u.cursor&&l.add(u.cursor),d=u.cursor??void 0}while(d);let g=[],f=[I];for(let[u,o]of i){let c=await v(o.contract_address),y=G(await t().readContract({address:c.address,abi:V,functionName:"balanceOf",args:[e]}));g.push({module:"clanker",id:`launch:${u}`,chainId:h,assets:[{token:c,amount:y}],description:`Indexed launch ${o.name}; wallet token balance, not locked LP principal.`}),f.some(r=>w(r.address,c.address))||f.push(c)}for(let u of f){let o=await b(e,u.address);BigInt(o)>0n&&g.push({module:"clanker",id:`fees:${u.address.toLowerCase()}`,chainId:h,assets:[{token:u,amount:o}],description:"Collected fees across launches for this recipient. Pending LP fees excluded; token-side discovery covers indexed launches by this wallet."})}return g})}},Fe=n=>ie("clanker",[Se(n),ae(n),le(n),pe(n)]);export{ve as a,Se as b,Fe as c};
|
|
1
|
+
import{b as H,o as q}from"./CAU44UWP.js";import{a as de,b as ce,c as le}from"./HFQS5344.js";import{a as ae}from"./G7UKNO2I.js";import{a as ue,b as me}from"./BYXBS45D.js";import{a as pe}from"./GZ5TW3WB.js";import{e as U,h as B,m as re}from"./5EHQM6DM.js";import{b as ie}from"./AXYOJBX6.js";import{a as E}from"./EG6M6SSO.js";import{c as se}from"./MYBDO5SA.js";import{c as M,e as x,g as w,k as ee,l as ne,m as te,n as oe}from"./73N3TOJL.js";import{a as h,i as Y}from"./XPFVT2EA.js";import{a as s}from"./5YS5V2LK.js";import{decodeFunctionResult as Ce,encodeAbiParameters as F,encodeFunctionData as N,erc20Abi as V,isAddress as Ie,parseAbi as we,parseAbiParameters as j,toHex as J,zeroAddress as W}from"viem";var k=Y[h].clanker,fe=we(["function deployToken(((address tokenAdmin,string name,string symbol,bytes32 salt,string image,string metadata,string context,uint256 originatingChainId) tokenConfig,(address hook,address pairedToken,int24 tickIfToken0IsClanker,int24 tickSpacing,bytes poolData) poolConfig,(address locker,address[] rewardAdmins,address[] rewardRecipients,uint16[] rewardBps,int24[] tickLower,int24[] tickUpper,uint16[] positionBps,bytes lockerData) lockerConfig,(address mevModule,bytes mevModuleData) mevModuleConfig,(address extension,uint256 msgValue,uint16 extensionBps,bytes extensionData)[] extensionConfigs) config) payable returns (address)","function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),C=we(["function availableFees(address,address) view returns (uint256)","function claim(address,address)","function collectRewards(address)","function mevModuleEnabled(bytes32) view returns (bool)","function mevModuleOperational(bytes32) returns (bool)"]),I={address:k.paired_weth.address,symbol:"WETH",decimals:18,chainId:h},Pe="https://www.clanker.world/api/tokens",ye={type:"string",pattern:"^\\d+$"},he={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"};function P(n){return ne(ee(n,U),U)}function ge(n,t){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new s(`Provide an explicit bytes32 ${t}.`);return n}function T(n,t,a=!1){if(n===void 0&&!a)return"";if(typeof n!="string"||a&&!n.trim())throw new s(`Provide ${t} as text.`);return n}function z(n,t=256){return oe(n,`Amount exceeds the uint${t} range.`,{bits:t})}function G(n){return te(n,"The contract returned an invalid amount.").toString()}function O(n,t){let a=Object.keys(n).find(p=>!t.includes(p));if(a)throw new s(`Unsupported Clanker input: ${a}.`)}function be(n,t){return t.changes.map(({token:a,amount:p})=>{let b=p.startsWith("-");return`${b?"-":"+"}${n.formatAmount(b?p.slice(1):p,a.decimals)} ${a.symbol} (${a.address}, chain ${a.chainId})`}).join("; ")}function Te(n){return x(n)&&Array.isArray(n.data)&&Number.isSafeInteger(n.total)&&Number(n.total)>=0&&Number.isSafeInteger(n.tokensDeployed)&&Number(n.tokensDeployed)>=0&&(n.cursor===null||typeof n.cursor=="string"||n.cursor===void 0&&n.data.length===0&&n.total===0&&n.tokensDeployed===0)&&n.data.every(t=>x(t)&&typeof t.name=="string"&&typeof t.symbol=="string"&&Number.isSafeInteger(t.chain_id)&&["contract_address","admin","msg_sender","factory_address"].every(a=>typeof t[a]=="string"&&Ie(t[a],{strict:!1})))}async function ve(n,t={}){O(t,["q","limit","cursor","deployer"]);let a=t.limit??10;if(typeof a!="number"||!Number.isInteger(a)||a<1||a>20)throw new s("Choose an indexer limit from 1 to 20.");let p=new URL(Pe);p.searchParams.set("chainId",String(h)),p.searchParams.set("limit",String(a)),t.q!==void 0&&p.searchParams.set("q",T(t.q,"search")),t.cursor!==void 0&&p.searchParams.set("cursor",T(t.cursor,"cursor",!0)),t.deployer!==void 0&&p.searchParams.set("msgSender",P(t.deployer));let b=await se(n.http,p.toString(),{headers:{"User-Agent":"Oak-Clanker/1.0"}},Te);return{tokens:b.data.filter(v=>v.chain_id===h&&w(v.factory_address,k.factory.address)),total:b.total,cursor:b.cursor||null,tokensDeployed:b.tokensDeployed}}var Se=n=>{let t=()=>n.clientFor(h),a=async e=>{try{return await e()}catch(i){throw new s(n.plainError(i))}},p=(e,i,l,d="0")=>n.unsignedTx({to:e,data:i,value:d,chainId:h,description:l}),b=async(e,i)=>G(await t().readContract({address:k.fee_locker.address,abi:C,functionName:"availableFees",args:[e,i]})),v=async e=>{if(w(e,I.address))return I;let[i,l]=await Promise.all([t().readContract({address:e,abi:V,functionName:"symbol"}),t().readContract({address:e,abi:V,functionName:"decimals"})]);if(typeof i!="string"||!i.trim()||!Number.isInteger(l)||l<0||l>255)throw new s("The contract returned invalid token metadata.");return{address:e,chainId:h,symbol:i,decimals:l}},Z=e=>ve(n,e),ke=async(e,i)=>{if(O(e,["name","symbol","salt","image","metadata","context","vanity","initialBuy","minAmountOut","slippageBps","rewards","vault","airdrop","feeBps","pool"]),e.vanity!==void 0&&e.vanity!==!1)throw new s("Clanker launches use vanity false and an explicit salt.");let l=T(e.name,"token name",!0),d=T(e.symbol,"token symbol",!0),g=ge(e.salt,"salt"),f=z(e.initialBuy??"0"),u=e.slippageBps??H;if(typeof u!="number")throw new s("Slippage must be an integer from 0 to 9999 bps.");q("0",u);let o=e.minAmountOut===void 0?void 0:z(e.minAmountOut,128);if(o!==void 0&&o<=1n)throw new s("Initial-buy minimum must exceed one base unit.");if(!f&&o!==void 0)throw new s("A minimum requires a positive initial buy.");let c=ce(e,i);B(e.feeBps??100,0,1e3);let y=me(e);if(f&&!w(y.poolConfig.pairedToken,I.address))throw new s("An initial ETH buy currently requires a WETH-paired pool. Launch without an initial buy and obtain a protected swap quote separately.");let r=e.rewards??[{admin:i,recipient:i,bps:1e4,feePreference:0}];if(!Array.isArray(r)||!r.length||r.length>7)throw new s("Provide one to seven reward allocations.");let A=r.map(m=>{if(!x(m))throw new s("Provide reward allocations as objects.");return O(m,["admin","recipient","bps","feePreference"]),{admin:P(m.admin),recipient:P(m.recipient),bps:B(m.bps,1,1e4),feePreference:B(m.feePreference??0,0,2)}});if(A.reduce((m,S)=>m+S.bps,0)!==1e4)throw new s("Reward allocations must total 10000 bps.");let $={tokenConfig:{tokenAdmin:i,name:l,symbol:d,salt:g,image:T(e.image,"image"),metadata:T(e.metadata,"metadata"),context:e.context===void 0?JSON.stringify({interface:"Oak",platform:"robinhood"}):T(e.context,"context"),originatingChainId:BigInt(h)},poolConfig:y.poolConfig,lockerConfig:{locker:k.locker.address,rewardAdmins:A.map(m=>m.admin),rewardRecipients:A.map(m=>m.recipient),rewardBps:A.map(m=>m.bps),tickLower:y.tickLower,tickUpper:y.tickUpper,positionBps:y.positionBps,lockerData:F(j("(uint8[])"),[[A.map(m=>m.feePreference)]])},mevModuleConfig:{mevModule:k.mev_module.address,mevModuleData:F(j("(uint24,uint24,uint256)"),[[666777,41673,15n]])},extensionConfigs:c},xe=await t().simulateContract({address:k.factory.address,abi:fe,functionName:"deployToken",args:[$],account:i,value:0n,gas:E}),_=P(xe.result),K=m=>{let S=[...c,...f?[{extension:k.devbuy.address,msgValue:f,extensionBps:0,extensionData:F(j("(address,address,uint24,int24,address),uint128,address"),[[W,W,0,0,W],m,i])}]:[]];return p(k.factory.address,N({abi:fe,functionName:"deployToken",args:[{...$,extensionConfigs:S}]}),`Launch ${l} (${d}); initial buy ${f} native ETH base units.`,f.toString())};if(f&&o===void 0){let S=(await n.preview([K(0n)],i)).changes.filter(D=>D.token.chainId===h&&w(D.token.address,_)&&D.token.decimals===18).reduce((D,X)=>D+(/^-?\d+$/.test(X.amount)?BigInt(X.amount):(()=>{throw new s("Invalid initial-buy simulation amount.")})()),0n);if(S<=0n)throw new s("Initial-buy simulation returned no token output.");if(o=z(q(S.toString(),u),128),o<=1n)throw new s("Initial-buy output is too small for a protected minimum.")}let Q=[K(o??0n)],R=await n.preview(Q,i);return{txs:Q,preview:R,predictedToken:_,token:{address:_,chainId:h,symbol:d,decimals:18},...o!==void 0?{minAmountOut:o.toString()}:{},summary:`Launch ${d} at ${_} (CREATE2 address predicted from simulation); vanity false; salt ${g}. Supply 100000000000000000000000000000 base units (18 decimals). ${y.feeSummary}; protocol adds 20% of LP fees. Pool and LP allocations: ${JSON.stringify(y)}. Reward allocations: ${JSON.stringify(A)}. Extensions: ${JSON.stringify({vault:e.vault,airdrop:e.airdrop})}. Sniper fees 666777 to 41673 over 15 seconds. ${R.summary} ${be(n,R)}`}},Ae=async(e,i)=>{if(O(e,["token","poolId","collect"]),e.collect!==void 0&&typeof e.collect!="boolean")throw new s("collect must be boolean.");if(e.collect===!1&&e.poolId!==void 0)throw new s("poolId requires collection.");if(e.collect===!0&&e.token===void 0)throw new s("Collection requires a Clanker token.");if(e.poolId!==void 0&&e.token===void 0)throw new s("A pool ID requires its Clanker token.");let l=[I],d=[];if(e.token!==void 0){let o=P(e.token);if(w(o,I.address))throw new s("Provide the launched Clanker token, not WETH.");if(e.collect!==!1){let c=await re(n,o),{poolId:y,hook:r,locker:A}=c;if(e.poolId!==void 0&&!w(ge(e.poolId,"pool ID for fee collection"),y))throw new s("The supplied pool ID does not match the onchain Clanker pool.");w(c.pairedToken,I.address)||l.splice(0,1,await v(c.pairedToken));let $=await t().readContract({address:r,abi:C,functionName:"mevModuleEnabled",args:[y]});if(typeof $!="boolean")throw new s("The hook returned an invalid MEV guard state.");$&&d.push(p(r,N({abi:C,functionName:"mevModuleOperational",args:[y]}),"Update the Clanker pool MEV guard before collection.")),d.push(p(A,N({abi:C,functionName:"collectRewards",args:[o]}),"Collect pending LP fees into the fee locker."))}l.push(await v(o))}let g;if(d.length){if(await t().getChainId()!==h)throw new s("Fee simulation endpoint is on the wrong chain.");let o=[...d.map(r=>({from:i,gas:J(E),to:r.to,data:r.data,value:J(BigInt(r.value))})),...l.map(r=>({from:i,gas:J(E),to:k.fee_locker.address,data:N({abi:C,functionName:"availableFees",args:[i,r.address]}),value:"0x0"}))],c=await t().request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:o}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(c)||c.length!==1||!x(c[0])||!Array.isArray(c[0].calls)||c[0].calls.length!==o.length)throw new s("The endpoint returned an unexpected fee simulation response.");let y=c[0].calls;if(!y.every(r=>x(r)&&r.status==="0x1"&&!r.error))throw new s("Clanker fee collection simulation failed.");g=y.slice(d.length).map(r=>{if(!x(r)||typeof r.returnData!="string"||!/^0x[0-9a-fA-F]{64}$/.test(r.returnData))throw new s("The endpoint returned an invalid fee balance.");return G(Ce({abi:C,functionName:"availableFees",data:r.returnData}))})}else g=await Promise.all(l.map(o=>b(i,o.address)));let f=l.flatMap((o,c)=>BigInt(g[c])>0n?[{token:o,amount:g[c]}]:[]);if(!f.length)throw new s("No claimable fees for this wallet; pending LP fees may require the MEV window to end.");for(let{token:o}of f)d.push(p(k.fee_locker.address,N({abi:C,functionName:"claim",args:[i,o.address]}),`Claim ${o.symbol} fees to ${i}.`));let u=await n.preview(d,i);return{txs:d,preview:u,fees:f,summary:`Claim fees to ${i}. WETH fees aggregate across all Clanker launches for this recipient. ${u.summary} ${be(n,u)}`}},L=(e,i,l,d)=>({name:`clanker_${e}`,inputSchema:{type:"object",properties:i,required:l,additionalProperties:!1},execute:(g,f)=>a(async()=>d(g,P(f)))});return{tools:[L("launch",{name:{type:"string"},symbol:{type:"string"},salt:he,image:{type:"string"},metadata:{type:"string"},context:{type:"string"},vanity:{const:!1},initialBuy:{...ye,description:"Native ETH base units, 18 decimals."},minAmountOut:{...ye,description:"Minimum new token base units, 18 decimals; derived from simulation when omitted."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:H},feeBps:{type:"integer",minimum:0,maximum:1e3,default:100},pool:ue,rewards:{type:"array",minItems:1,maxItems:7,items:{type:"object",properties:{admin:M,recipient:M,bps:{type:"integer",minimum:1,maximum:1e4},feePreference:{type:"integer",minimum:0,maximum:2}},required:["admin","recipient","bps"],additionalProperties:!1}},...de},["name","symbol","salt"],ke),L("claim",{token:{...M,description:"Launched token; derives its onchain pool and collects pending LP fees before claiming."},poolId:{...he,description:"Optional assertion against the derived pool ID."},collect:{type:"boolean",default:!0,description:"Set false to claim only already-collected fees."}},[],Ae),L("browse",{q:{type:"string"},limit:{type:"integer",minimum:1,maximum:20},cursor:{type:"string"},deployer:M},[],Z)],positions:e=>a(async()=>{P(e);let i=new Map,l=new Set,d;do{let u=await Z({deployer:e,limit:20,...d?{cursor:d}:{}});for(let o of u.tokens)w(o.msg_sender,e)&&i.set(o.contract_address.toLowerCase(),o);if(u.cursor&&l.has(u.cursor))throw new s("The Clanker indexer repeated a pagination cursor.");u.cursor&&l.add(u.cursor),d=u.cursor??void 0}while(d);let g=[],f=[I];for(let[u,o]of i){let c=await v(o.contract_address),y=G(await t().readContract({address:c.address,abi:V,functionName:"balanceOf",args:[e]}));g.push({module:"clanker",id:`launch:${u}`,chainId:h,assets:[{token:c,amount:y}],description:`Indexed launch ${o.name}; wallet token balance, not locked LP principal.`}),f.some(r=>w(r.address,c.address))||f.push(c)}for(let u of f){let o=await b(e,u.address);BigInt(o)>0n&&g.push({module:"clanker",id:`fees:${u.address.toLowerCase()}`,chainId:h,assets:[{token:u,amount:o}],description:"Collected fees across launches for this recipient. Pending LP fees excluded; token-side discovery covers indexed launches by this wallet."})}return g})}},Fe=n=>ie("clanker",[Se(n),ae(n),le(n),pe(n)]);export{ve as a,Se as b,Fe as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as A}from"./
|
|
1
|
+
import{a as A}from"./E24S22BZ.js";import{a,b as g,c as b,e as w,f as x,g as h}from"./IAXKPME3.js";import{a as r}from"./UWOFA6GV.js";import{c as y}from"./73N3TOJL.js";import{a as m}from"./XPFVT2EA.js";import{a as i}from"./5YS5V2LK.js";import{encodeAbiParameters as S,encodeFunctionData as B,encodePacked as T,erc20Abi as I,getAddress as q,parseAbi as C,parseAbiParameters as N,zeroAddress as R}from"viem";var O=q("0x0000ffffbe8efe702c8703ae3477ff5de3d319c0"),$=N("(address currency,address tokensRecipient,address fundsRecipient,uint64 startBlock,uint64 endBlock,uint64 claimBlock,uint256 tickSpacing,address validationHook,uint256 floorPrice,uint128 requiredCurrencyRaised,bytes auctionStepsData)"),P=C(["function create(address token,uint256 amount,bytes configData,bytes32 salt) returns (address)","function getAddress(address token,uint256 amount,bytes configData,bytes32 salt,address sender) view returns (address)"]),Q=C(["function distributeToken(address token,(address strategy,uint128 amount,bytes configData) distribution,bytes32 salt) payable"]),v={token:y,amount:r(),currency:y,startBlock:r(),endBlock:r(),claimBlock:r(),tickSpacing:r(),floorPrice:r(),requiredCurrencyRaised:r(),salt:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},steps:{type:"array",minItems:1,maxItems:100,items:{type:"object",additionalProperties:!1,required:["mps","duration"],properties:{mps:r(),duration:r()}}}};function D(e,t){let s=a(e.startBlock,"startBlock",64),o=a(e.endBlock,"endBlock",64),c=a(e.claimBlock,"claimBlock",64);if(o<=s||c<o)throw new i("Auction needs startBlock < endBlock <= claimBlock.");if(!Array.isArray(e.steps)||e.steps.length<1||e.steps.length>100)throw new i("Provide 1 to 100 issuance steps.");let u="0x",p=0n,l=0n;for(let d of e.steps){if(!d||typeof d!="object"||Array.isArray(d))throw new i("Each step requires mps and duration decimal strings.");h(d,["mps","duration"]);let n=d,k=a(n.mps,"mps",24,!0),f=a(n.duration,"duration",40);u=`${u}${T(["uint24","uint40"],[Number(k),Number(f)]).slice(2)}`,l+=k*f,p+=f}if(l!==10000000n||p!==o-s)throw new i("Issuance must total exactly 10000000 MPS and its durations must equal endBlock - startBlock.");return S($,[{currency:b(e.currency),tokensRecipient:t,fundsRecipient:t,startBlock:s,endBlock:o,claimBlock:c,tickSpacing:a(e.tickSpacing,"tickSpacing"),validationHook:R,floorPrice:a(e.floorPrice,"floorPrice"),requiredCurrencyRaised:a(e.requiredCurrencyRaised??"0","requiredCurrencyRaised",128,!0),auctionStepsData:u}])}function U(e){return{tools:[{name:"uniswap_create_auction",inputSchema:{type:"object",additionalProperties:!1,required:["token","amount","currency","startBlock","endBlock","claimBlock","tickSpacing","floorPrice","steps","salt"],properties:v},async execute(t,s){h(t,Object.keys(v));let o=g(t.token),c=a(t.amount,"amount",128);if(o===R||o===b(t.currency))throw new i("Auction sale token must be an ERC-20 distinct from its payment currency.");let u=D(t,s);if(typeof t.salt!="string"||!/^0x[0-9a-fA-F]{64}$/.test(t.salt))throw new i("Provide a 32-byte deployment salt.");let p=t.salt,l=e.clientFor(m),d=await l.getBlockNumber();if(BigInt(String(t.startBlock))<=d)throw new i("Choose a future auction startBlock with time for confirmation and approvals.");let n=await l.readContract({address:A,abi:P,functionName:"getAddress",args:[o,c,u,p,s]});if((await l.getCode({address:n})??"0x")!=="0x")throw new i("This auction already exists; choose a fresh salt or configuration.");let k=await w(e,o),f=[e.unsignedTx({to:A,data:B({abi:P,functionName:"create",args:[o,c,u,p]}),value:"0",chainId:m,description:`Create CCA ${n}; proceeds and unsold tokens go to ${s}.`}),e.unsignedTx({to:o,data:B({abi:I,functionName:"transfer",args:[n,c]}),value:"0",chainId:m,description:`Fund the factory-predicted auction ${n} with exactly ${c} base units of ${o}.`}),e.unsignedTx({to:n,data:B({abi:C(["function onTokensReceived()"]),functionName:"onTokensReceived"}),value:"0",chainId:m,description:`Activate CCA ${n} after its sale tokens arrive.`})];return{...await x(e,f,s,"Create/fund/activate a standalone CCA in three separately confirmed transactions, not an LBP-managed liquidity launch. If interrupted, inspect the predicted address and journal before recovery; do not transfer tokens twice. Raw prices are payment-base-units per sale-token-base-unit in Q96. No validation hook or off-chain signature; all proceeds and unsold tokens go to the signing wallet."),auction:n,sale:{token:k,amount:c.toString()}}}}]}}export{O as a,$ as b,P as c,Q as d,D as e,U as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ee}from"./H4S2ZCWK.js";import{a as xe}from"./L2MTPRU7.js";import{a as $e,b as me,c as Te}from"./SQ5BNSXR.js";import{c as Re,d as t,e as R,f as d,g as Ae,h as W,i as v,j as de,k as L,m as O,n as c,o as ue,p as ce,q as le,r as Ce,s as qe}from"./53N7PNJH.js";import{a as ke,o as re}from"./EAEQOS7Y.js";import{a as ve}from"./UWOFA6GV.js";import{c as be,e as Q,g as M}from"./73N3TOJL.js";import{a as l,i as we}from"./XPFVT2EA.js";import{a as h}from"./5YS5V2LK.js";import{decodeFunctionData as Fe,erc20Abi as Me}from"viem";var z="0x0000000000000000000000000000000000000000",N=we[l].relay.depository.address.toLowerCase(),Se=30,ze=w=>{let U=qe(w);async function pe(n){let e;try{e=await U(`/intents/status/v3?requestId=${encodeURIComponent(n)}`)}catch(C){if(w.plainError(C)!=="The request timed out. Please try again.")throw C;return{requestId:n,status:"unknown",timedOut:!0,fulfilled:!1,settled:!1,pollAgain:!0,needsAttention:!1,inTxHashes:[],txHashes:[],originChainId:void 0,destinationChainId:void 0,summary:"The status request timed out. Bridge settlement is unknown; poll again."}}if(typeof e.status!="string")throw new h("Relay returned an invalid bridge status.");let i=ue(e.inTxHashes),p=ue(e.txHashes),u=e.originChainId===void 0?void 0:W(e.originChainId),a=e.destinationChainId===void 0?void 0:W(e.destinationChainId),s=ce(e.failReason),m=ce(e.refundFailReason),r=e.status==="success"&&p.length>0&&a!==void 0,q=e.status==="refund"&&p.length>0&&u!==void 0,g=e.status==="failure"&&m!==void 0,A=["waiting","depositing","pending","submitted","failure","refund","success"].includes(e.status)?e.status==="failure"&&/TIMEOUT|EXPIRED/.test(typeof e.failReason=="string"?e.failReason:"")?"timeout":e.status:"unknown",k=r?"Relay reports destination fulfillment.":q?"Relay reports a refund on the origin chain; the destination was not fulfilled.":g?"The bridge failed and automatic refund is unavailable. Review the request with Relay.":"Bridge settlement is not confirmed. Poll Relay again; an origin receipt alone does not prove destination fulfillment.";return{requestId:n,status:A,relayStatus:e.status,fulfilled:r,settled:r||q,pollAgain:!r&&!q&&!g,needsAttention:g,timedOut:!1,inTxHashes:i,txHashes:p,originChainId:u,destinationChainId:a,failReason:s,refundFailReason:m,...e.updatedAt===void 0?{}:{updatedAt:v(String(e.updatedAt))},summary:k}}async function De(n,e){let i=s=>({destinationVerified:!1,destinationCheck:s}),p;try{if(p=w.clientFor(n),await p.getChainId()!==n)return i(`The configured RPC does not serve chain ${n}; destination receipts were not checked.`)}catch{return i(`No RPC is available for chain ${n}; destination receipts were not checked.`)}let u=[];for(let s of e)try{let m=await p.getTransactionReceipt({hash:s});u.push({hash:s,status:m.status,blockNumber:m.blockNumber.toString()})}catch{return{...i(`Receipt ${s} is not available on chain ${n} yet; poll again.`),destinationReceipts:u}}let a=u.length>0&&u.every(s=>s.status==="success");return{destinationVerified:a,destinationReceipts:u,destinationCheck:a?`Every Relay destination transaction has a successful receipt on chain ${n}. Amounts are not decoded here; compare the recipient balance for the exact delivered amount.`:`A Relay destination transaction did not succeed on chain ${n}; do not treat this bridge as delivered.`}}async function Pe(n){let e=await w.clientFor(l).readContract({address:n,abi:Me,functionName:"decimals"}),i=typeof e=="bigint"?Number(e):e;if(typeof i!="number"||!Number.isInteger(i)||i<0||i>255)throw new h("Could not read valid ERC-20 decimals() on-chain.");return i}async function _e(n,e){let i=d(e),p=d(n.recipient??i),u=W(n.destinationChainId);if(u===l)throw new h("Choose a destination chain other than 4663.");let a=Ae(n.originCurrency??z),s=a!==z,m=d(n.destinationCurrency??z),r=v(n.amount);if(r==="0")throw new h("Provide a positive bridge amount.");let q=n.minAmountOut===void 0?void 0:v(n.minAmountOut),g=n.slippageBps??me;if(typeof g!="number")throw new h("Slippage must be an integer from 0 to 9999 bps.");re("0",g);let I=R((await U("/chains")).chains).map(t),A=I.find(o=>o.id===l),k=I.find(o=>o.id===u);if(!A||!k||A.disabled!==!1||k.disabled!==!1||A.depositEnabled!==!0||A.vmType!=="evm"||k.vmType!=="evm")throw new h("Relay does not currently support this outbound chain route.");if(!xe(u))throw new h(`Relay has no supported Oak return path from chain ${u}. Choose a destination supported by relay_bridge_in before bridge-out.`);let C=await $e(w.clientFor,u,i,"server"),b=s?await Pe(a):18,P=Math.floor(Date.now()/1e3)+ke,$=await U("/quote/v2",{user:i,recipient:p,originChainId:l,destinationChainId:u,originCurrency:a,destinationCurrency:m,amount:r,tradeType:"EXACT_INPUT",...s?{explicitDeposit:!0}:{}}),E=L($.requestId),S=t($.details),B=O(S.currencyIn),f=O(S.currencyOut),T={token:f.token,amount:v(t(S.currencyOut).minimumAmount)};if(c(d(S.sender)===i&&d(S.recipient)===p&&B.token.chainId===l&&B.token.address===a&&B.token.decimals===b&&B.amount===r&&f.token.chainId===u&&f.token.address===m&&BigInt(T.amount)>0n&&BigInt(T.amount)<=BigInt(f.amount)),m===z&&c(f.token.decimals===t(k.currency).decimals),q!==void 0){if(T.amount!==q)throw new h("Relay order minimum must exactly match minAmountOut. Request a new quote.")}else if(BigInt(T.amount)<BigInt(re(f.amount,g)))throw Te(f.amount,T.amount);let J=t(t($.protocol).v2),j=L(J.orderId),Z=t(J.orderData),Y=t(Z.output),ee=de(Y.deadline),K=R(Z.inputs).map(t);c(K.length>0);let te=K.flatMap(o=>{let y=R(o.refunds).map(t);return c(y.length>0),y.map(Ie=>{if(d(Ie.recipient)!==i)throw new h("Relay refund recipient does not match the agent wallet. Request a new quote.");return de(Ie.deadline)})}),Oe=te.reduce((o,y)=>Math.min(o,y),ee),ne=Math.min(P,Oe-Se),he=()=>{if(Date.now()/1e3>=ne)throw new h("The Relay quote expired or its order/refund deadline leaves too little time to sign and send. Request a fresh bridge quote.")};he();let H=R(Y.payments).map(t),ie=t(t(A.protocol).v2),Ne=t(t(k.protocol).v2),V=t(J.paymentDetails);c(Y.chainId===Ne.chainId&&H.length===1&&R(Y.calls).length===0&&d(H[0].recipient)===p&&d(H[0].currency)===m&&v(H[0].minimumAmount)===T.amount&&v(H[0].expectedAmount)===f.amount&&V.chainId===ie.chainId&&d(V.currency)===a&&v(V.amount)===r),c(d(V.depository)===N&&d(ie.depository)===N);let oe=t(K[0].payment);c(K.length===1&&oe.chainId===ie.chainId&&d(oe.currency)===a&&v(oe.amount)===r);let F=R($.steps).map(t),_=s&&F.length===2?F[0]:void 0;c(F.length===(_?2:1));let G=F[F.length-1];c(G.kind==="transaction"&&G.id==="deposit"&&G.requestId===E);let X=R(G.items).map(t);c(X.length===1&&X[0].status==="incomplete");let x=t(X[0].data),fe=t(X[0].check);if(c(fe.method==="GET"&&fe.endpoint===`/intents/status/v3?requestId=${E}`&&x.chainId===l&&d(x.from)===i&&d(x.to)===N&&v(x.value)===(s?"0":r)),typeof x.data!="string"||!(s?/^0x[0-9a-fA-F]{264}$/:/^0x[0-9a-fA-F]{136}$/).test(x.data))throw new h(`Relay returned unexpected ${s?"ERC-20":"native"} deposit calldata.`);let D=Fe({abi:Re,data:x.data});D.functionName==="depositErc20"?c(s&&d(D.args[0])===i&&d(D.args[1])===a&&D.args[2]===BigInt(r)&&M(D.args[3],j)):c(!s&&d(D.args[0])===i&&M(D.args[1],j));let Be=I.filter(o=>o.vmType==="evm"&&Q(o.protocol)&&Q(o.protocol.v2)).map(o=>t(t(o.protocol).v2).chainId).filter(o=>typeof o=="string");if(!M(Ee(Z,Be),j))throw new h("Relay order ID does not match the checked quote terms. Request a new quote.");let ae=s?w.approval(a,N,r,l):void 0;if(_&&ae){c(_.kind==="transaction"&&_.id==="approve"&&_.requestId===E);let o=R(_.items).map(t);c(o.length===1&&o[0].status==="incomplete");let y=t(o[0].data);c(y.chainId===l&&d(y.from)===i&&d(y.to)===a&&v(y.value)==="0"&&typeof y.data=="string"&&M(y.data,ae.data))}let ye=[...ae?await Ce(w,a,N,r,l,i):[],w.unsignedTx({to:N,data:x.data,value:s?"0":r,chainId:l,description:s?`Deposit ${r} base units of ${a} for Relay request ${E}.`:`Deposit native ETH for Relay request ${E}.`})],ge=t($.fees);for(let o of Object.values(ge))O(o);let se=await w.preview(ye,i);he();let He=se.changes.map(o=>{let y=o.amount.startsWith("-");return`${y?"-":""}${w.formatAmount(y?o.amount.slice(1):o.amount,o.token.decimals)} ${o.token.symbol}`}).join(", ");return{txs:ye,requestId:E,orderId:j,recipient:p,originChainId:l,destinationChainId:u,expiresAt:String(ne),orderDeadline:String(ee),refundDeadlines:te.map(String),returnPath:C,amountIn:B,amountOut:f,minAmountOut:T,fees:ge,expandedPriceImpact:S.expandedPriceImpact,timeEstimate:S.timeEstimate,preview:se,summary:`${C} Bridge to ${p} on chain ${u}; asset ${f.token.address} on chain ${f.token.chainId} (${le(f.token.symbol)}); expected ${f.amount}, minimum ${T.amount} base units (${f.token.decimals} decimals). Order deadline ${ee} Unix seconds; refund deadlines ${te.join(", ")} Unix seconds; accept before ${ne} Unix seconds to reserve ${Se}s to sign and send. Origin preview: ${He||se.summary}. Relay route fees are included in the quote; origin gas is separate. Poll relay_status with requestId ${E} after local submission; destination fulfillment is not yet confirmed.`}}return{tools:[{name:"relay_bridge_out",inputSchema:{type:"object",required:["destinationChainId","amount"],additionalProperties:!1,properties:{destinationChainId:{type:"integer",minimum:1},amount:{type:"string",pattern:"^[1-9][0-9]*$"},recipient:{type:"string"},originCurrency:be,slippageBps:{type:"integer",minimum:0,maximum:9999,default:me},destinationCurrency:{type:"string"},minAmountOut:ve()}},execute:async(n,e)=>{try{return await _e(n,e)}catch(i){throw new h(w.plainError(i))}}},{name:"relay_status",inputSchema:{type:"object",required:["requestId"],additionalProperties:!1,properties:{requestId:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},verifyDestination:{type:"boolean"}}},execute:async n=>{let e=await pe(L(n.requestId));return n.verifyDestination!==!0||!e.fulfilled||e.destinationChainId===void 0?e:{...e,...await De(e.destinationChainId,e.txHashes)}}}],positions:async n=>{let e=d(n);if(!process.env.OAK_RELAY_API_KEY?.trim())return[{module:"relay",id:"relay-discovery-unavailable",chainId:l,assets:[],incomplete:!0,description:'Relay pending bridge discovery requires OAK_RELAY_API_KEY on the server. The request-history API requires this key; no pending bridges were checked. Ask the operator to configure it, or check a known request with relay_status {"requestId":"<id>"}. Legacy vault shares on other chains can be checked with relay_vault_status {"chainId":1} or {"chainId":42161}.'}];let i=new Map;for(let p of["outbound","inbound"]){let u=new Set,a;do{let s=new URLSearchParams({user:e,[p==="outbound"?"originChainId":"destinationChainId"]:String(l),limit:"100",includePendingRequests:"true"});a&&s.set("continuation",a);let m=await U(`/requests/v3?${s}`);for(let r of R(m.requests).map(t)){let q=Q(r.depositAddress)?r.depositAddress.depositor:void 0;if(![r.user,r.sender,q].some($=>typeof $=="string"&&$.toLowerCase()===e))throw new h("Relay returned a request for another wallet.");let g=L(r.id);if(i.has(g))continue;let I=await pe(g);if(I.settled)continue;let A=t(r.data),k=t(t(A.route).quoted),C=O(t(k.origin).inputCurrency),b={...C,token:{...C.token,symbol:le(C.token.symbol)??"unknown"}},P=O(t(k.destination).outputCurrency);c(p==="outbound"?b.token.chainId===l&&P.token.chainId!==l:b.token.chainId!==l&&P.token.chainId===l),I.originChainId!==void 0&&c(I.originChainId===b.token.chainId),I.destinationChainId!==void 0&&c(I.destinationChainId===P.token.chainId),i.set(g,{module:"relay",id:g,chainId:b.token.chainId,assets:[b],description:`Relay ${p} ${I.status}: ${b.amount} ${b.token.symbol} base units (${b.token.decimals} decimals) from chain ${b.token.chainId} toward ${d(r.recipient)} on chain ${P.token.chainId}. ${I.summary} Track with relay_status requestId ${g}.`})}if(m.continuation!==void 0&&m.continuation!==null&&typeof m.continuation!="string")throw new h("Relay returned invalid pagination.");if(a=typeof m.continuation=="string"&&m.continuation?m.continuation:void 0,a){if(u.has(a))throw new h("Relay repeated its pagination cursor. Pending positions are incomplete.");u.add(a)}}while(a)}return[...i.values()]}}};export{ze as a};
|
|
1
|
+
import{a as Ee}from"./H4S2ZCWK.js";import{a as xe}from"./T3NPRRTY.js";import{a as $e,b as me,c as Te}from"./SQ5BNSXR.js";import{c as Re,d as t,e as R,f as d,g as Ae,h as W,i as v,j as de,k as L,m as O,n as c,o as ue,p as ce,q as le,r as Ce,s as qe}from"./53N7PNJH.js";import{a as ke,o as re}from"./CAU44UWP.js";import{a as ve}from"./UWOFA6GV.js";import{c as be,e as Q,g as M}from"./73N3TOJL.js";import{a as l,i as we}from"./XPFVT2EA.js";import{a as h}from"./5YS5V2LK.js";import{decodeFunctionData as Fe,erc20Abi as Me}from"viem";var z="0x0000000000000000000000000000000000000000",N=we[l].relay.depository.address.toLowerCase(),Se=30,ze=w=>{let U=qe(w);async function pe(n){let e;try{e=await U(`/intents/status/v3?requestId=${encodeURIComponent(n)}`)}catch(C){if(w.plainError(C)!=="The request timed out. Please try again.")throw C;return{requestId:n,status:"unknown",timedOut:!0,fulfilled:!1,settled:!1,pollAgain:!0,needsAttention:!1,inTxHashes:[],txHashes:[],originChainId:void 0,destinationChainId:void 0,summary:"The status request timed out. Bridge settlement is unknown; poll again."}}if(typeof e.status!="string")throw new h("Relay returned an invalid bridge status.");let i=ue(e.inTxHashes),p=ue(e.txHashes),u=e.originChainId===void 0?void 0:W(e.originChainId),a=e.destinationChainId===void 0?void 0:W(e.destinationChainId),s=ce(e.failReason),m=ce(e.refundFailReason),r=e.status==="success"&&p.length>0&&a!==void 0,q=e.status==="refund"&&p.length>0&&u!==void 0,g=e.status==="failure"&&m!==void 0,A=["waiting","depositing","pending","submitted","failure","refund","success"].includes(e.status)?e.status==="failure"&&/TIMEOUT|EXPIRED/.test(typeof e.failReason=="string"?e.failReason:"")?"timeout":e.status:"unknown",k=r?"Relay reports destination fulfillment.":q?"Relay reports a refund on the origin chain; the destination was not fulfilled.":g?"The bridge failed and automatic refund is unavailable. Review the request with Relay.":"Bridge settlement is not confirmed. Poll Relay again; an origin receipt alone does not prove destination fulfillment.";return{requestId:n,status:A,relayStatus:e.status,fulfilled:r,settled:r||q,pollAgain:!r&&!q&&!g,needsAttention:g,timedOut:!1,inTxHashes:i,txHashes:p,originChainId:u,destinationChainId:a,failReason:s,refundFailReason:m,...e.updatedAt===void 0?{}:{updatedAt:v(String(e.updatedAt))},summary:k}}async function De(n,e){let i=s=>({destinationVerified:!1,destinationCheck:s}),p;try{if(p=w.clientFor(n),await p.getChainId()!==n)return i(`The configured RPC does not serve chain ${n}; destination receipts were not checked.`)}catch{return i(`No RPC is available for chain ${n}; destination receipts were not checked.`)}let u=[];for(let s of e)try{let m=await p.getTransactionReceipt({hash:s});u.push({hash:s,status:m.status,blockNumber:m.blockNumber.toString()})}catch{return{...i(`Receipt ${s} is not available on chain ${n} yet; poll again.`),destinationReceipts:u}}let a=u.length>0&&u.every(s=>s.status==="success");return{destinationVerified:a,destinationReceipts:u,destinationCheck:a?`Every Relay destination transaction has a successful receipt on chain ${n}. Amounts are not decoded here; compare the recipient balance for the exact delivered amount.`:`A Relay destination transaction did not succeed on chain ${n}; do not treat this bridge as delivered.`}}async function Pe(n){let e=await w.clientFor(l).readContract({address:n,abi:Me,functionName:"decimals"}),i=typeof e=="bigint"?Number(e):e;if(typeof i!="number"||!Number.isInteger(i)||i<0||i>255)throw new h("Could not read valid ERC-20 decimals() on-chain.");return i}async function _e(n,e){let i=d(e),p=d(n.recipient??i),u=W(n.destinationChainId);if(u===l)throw new h("Choose a destination chain other than 4663.");let a=Ae(n.originCurrency??z),s=a!==z,m=d(n.destinationCurrency??z),r=v(n.amount);if(r==="0")throw new h("Provide a positive bridge amount.");let q=n.minAmountOut===void 0?void 0:v(n.minAmountOut),g=n.slippageBps??me;if(typeof g!="number")throw new h("Slippage must be an integer from 0 to 9999 bps.");re("0",g);let I=R((await U("/chains")).chains).map(t),A=I.find(o=>o.id===l),k=I.find(o=>o.id===u);if(!A||!k||A.disabled!==!1||k.disabled!==!1||A.depositEnabled!==!0||A.vmType!=="evm"||k.vmType!=="evm")throw new h("Relay does not currently support this outbound chain route.");if(!xe(u))throw new h(`Relay has no supported Oak return path from chain ${u}. Choose a destination supported by relay_bridge_in before bridge-out.`);let C=await $e(w.clientFor,u,i,"server"),b=s?await Pe(a):18,P=Math.floor(Date.now()/1e3)+ke,$=await U("/quote/v2",{user:i,recipient:p,originChainId:l,destinationChainId:u,originCurrency:a,destinationCurrency:m,amount:r,tradeType:"EXACT_INPUT",...s?{explicitDeposit:!0}:{}}),E=L($.requestId),S=t($.details),B=O(S.currencyIn),f=O(S.currencyOut),T={token:f.token,amount:v(t(S.currencyOut).minimumAmount)};if(c(d(S.sender)===i&&d(S.recipient)===p&&B.token.chainId===l&&B.token.address===a&&B.token.decimals===b&&B.amount===r&&f.token.chainId===u&&f.token.address===m&&BigInt(T.amount)>0n&&BigInt(T.amount)<=BigInt(f.amount)),m===z&&c(f.token.decimals===t(k.currency).decimals),q!==void 0){if(T.amount!==q)throw new h("Relay order minimum must exactly match minAmountOut. Request a new quote.")}else if(BigInt(T.amount)<BigInt(re(f.amount,g)))throw Te(f.amount,T.amount);let J=t(t($.protocol).v2),j=L(J.orderId),Z=t(J.orderData),Y=t(Z.output),ee=de(Y.deadline),K=R(Z.inputs).map(t);c(K.length>0);let te=K.flatMap(o=>{let y=R(o.refunds).map(t);return c(y.length>0),y.map(Ie=>{if(d(Ie.recipient)!==i)throw new h("Relay refund recipient does not match the agent wallet. Request a new quote.");return de(Ie.deadline)})}),Oe=te.reduce((o,y)=>Math.min(o,y),ee),ne=Math.min(P,Oe-Se),he=()=>{if(Date.now()/1e3>=ne)throw new h("The Relay quote expired or its order/refund deadline leaves too little time to sign and send. Request a fresh bridge quote.")};he();let H=R(Y.payments).map(t),ie=t(t(A.protocol).v2),Ne=t(t(k.protocol).v2),V=t(J.paymentDetails);c(Y.chainId===Ne.chainId&&H.length===1&&R(Y.calls).length===0&&d(H[0].recipient)===p&&d(H[0].currency)===m&&v(H[0].minimumAmount)===T.amount&&v(H[0].expectedAmount)===f.amount&&V.chainId===ie.chainId&&d(V.currency)===a&&v(V.amount)===r),c(d(V.depository)===N&&d(ie.depository)===N);let oe=t(K[0].payment);c(K.length===1&&oe.chainId===ie.chainId&&d(oe.currency)===a&&v(oe.amount)===r);let F=R($.steps).map(t),_=s&&F.length===2?F[0]:void 0;c(F.length===(_?2:1));let G=F[F.length-1];c(G.kind==="transaction"&&G.id==="deposit"&&G.requestId===E);let X=R(G.items).map(t);c(X.length===1&&X[0].status==="incomplete");let x=t(X[0].data),fe=t(X[0].check);if(c(fe.method==="GET"&&fe.endpoint===`/intents/status/v3?requestId=${E}`&&x.chainId===l&&d(x.from)===i&&d(x.to)===N&&v(x.value)===(s?"0":r)),typeof x.data!="string"||!(s?/^0x[0-9a-fA-F]{264}$/:/^0x[0-9a-fA-F]{136}$/).test(x.data))throw new h(`Relay returned unexpected ${s?"ERC-20":"native"} deposit calldata.`);let D=Fe({abi:Re,data:x.data});D.functionName==="depositErc20"?c(s&&d(D.args[0])===i&&d(D.args[1])===a&&D.args[2]===BigInt(r)&&M(D.args[3],j)):c(!s&&d(D.args[0])===i&&M(D.args[1],j));let Be=I.filter(o=>o.vmType==="evm"&&Q(o.protocol)&&Q(o.protocol.v2)).map(o=>t(t(o.protocol).v2).chainId).filter(o=>typeof o=="string");if(!M(Ee(Z,Be),j))throw new h("Relay order ID does not match the checked quote terms. Request a new quote.");let ae=s?w.approval(a,N,r,l):void 0;if(_&&ae){c(_.kind==="transaction"&&_.id==="approve"&&_.requestId===E);let o=R(_.items).map(t);c(o.length===1&&o[0].status==="incomplete");let y=t(o[0].data);c(y.chainId===l&&d(y.from)===i&&d(y.to)===a&&v(y.value)==="0"&&typeof y.data=="string"&&M(y.data,ae.data))}let ye=[...ae?await Ce(w,a,N,r,l,i):[],w.unsignedTx({to:N,data:x.data,value:s?"0":r,chainId:l,description:s?`Deposit ${r} base units of ${a} for Relay request ${E}.`:`Deposit native ETH for Relay request ${E}.`})],ge=t($.fees);for(let o of Object.values(ge))O(o);let se=await w.preview(ye,i);he();let He=se.changes.map(o=>{let y=o.amount.startsWith("-");return`${y?"-":""}${w.formatAmount(y?o.amount.slice(1):o.amount,o.token.decimals)} ${o.token.symbol}`}).join(", ");return{txs:ye,requestId:E,orderId:j,recipient:p,originChainId:l,destinationChainId:u,expiresAt:String(ne),orderDeadline:String(ee),refundDeadlines:te.map(String),returnPath:C,amountIn:B,amountOut:f,minAmountOut:T,fees:ge,expandedPriceImpact:S.expandedPriceImpact,timeEstimate:S.timeEstimate,preview:se,summary:`${C} Bridge to ${p} on chain ${u}; asset ${f.token.address} on chain ${f.token.chainId} (${le(f.token.symbol)}); expected ${f.amount}, minimum ${T.amount} base units (${f.token.decimals} decimals). Order deadline ${ee} Unix seconds; refund deadlines ${te.join(", ")} Unix seconds; accept before ${ne} Unix seconds to reserve ${Se}s to sign and send. Origin preview: ${He||se.summary}. Relay route fees are included in the quote; origin gas is separate. Poll relay_status with requestId ${E} after local submission; destination fulfillment is not yet confirmed.`}}return{tools:[{name:"relay_bridge_out",inputSchema:{type:"object",required:["destinationChainId","amount"],additionalProperties:!1,properties:{destinationChainId:{type:"integer",minimum:1},amount:{type:"string",pattern:"^[1-9][0-9]*$"},recipient:{type:"string"},originCurrency:be,slippageBps:{type:"integer",minimum:0,maximum:9999,default:me},destinationCurrency:{type:"string"},minAmountOut:ve()}},execute:async(n,e)=>{try{return await _e(n,e)}catch(i){throw new h(w.plainError(i))}}},{name:"relay_status",inputSchema:{type:"object",required:["requestId"],additionalProperties:!1,properties:{requestId:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},verifyDestination:{type:"boolean"}}},execute:async n=>{let e=await pe(L(n.requestId));return n.verifyDestination!==!0||!e.fulfilled||e.destinationChainId===void 0?e:{...e,...await De(e.destinationChainId,e.txHashes)}}}],positions:async n=>{let e=d(n);if(!process.env.OAK_RELAY_API_KEY?.trim())return[{module:"relay",id:"relay-discovery-unavailable",chainId:l,assets:[],incomplete:!0,description:'Relay pending bridge discovery requires OAK_RELAY_API_KEY on the server. The request-history API requires this key; no pending bridges were checked. Ask the operator to configure it, or check a known request with relay_status {"requestId":"<id>"}. Legacy vault shares on other chains can be checked with relay_vault_status {"chainId":1} or {"chainId":42161}.'}];let i=new Map;for(let p of["outbound","inbound"]){let u=new Set,a;do{let s=new URLSearchParams({user:e,[p==="outbound"?"originChainId":"destinationChainId"]:String(l),limit:"100",includePendingRequests:"true"});a&&s.set("continuation",a);let m=await U(`/requests/v3?${s}`);for(let r of R(m.requests).map(t)){let q=Q(r.depositAddress)?r.depositAddress.depositor:void 0;if(![r.user,r.sender,q].some($=>typeof $=="string"&&$.toLowerCase()===e))throw new h("Relay returned a request for another wallet.");let g=L(r.id);if(i.has(g))continue;let I=await pe(g);if(I.settled)continue;let A=t(r.data),k=t(t(A.route).quoted),C=O(t(k.origin).inputCurrency),b={...C,token:{...C.token,symbol:le(C.token.symbol)??"unknown"}},P=O(t(k.destination).outputCurrency);c(p==="outbound"?b.token.chainId===l&&P.token.chainId!==l:b.token.chainId!==l&&P.token.chainId===l),I.originChainId!==void 0&&c(I.originChainId===b.token.chainId),I.destinationChainId!==void 0&&c(I.destinationChainId===P.token.chainId),i.set(g,{module:"relay",id:g,chainId:b.token.chainId,assets:[b],description:`Relay ${p} ${I.status}: ${b.amount} ${b.token.symbol} base units (${b.token.decimals} decimals) from chain ${b.token.chainId} toward ${d(r.recipient)} on chain ${P.token.chainId}. ${I.summary} Track with relay_status requestId ${g}.`})}if(m.continuation!==void 0&&m.continuation!==null&&typeof m.continuation!="string")throw new h("Relay returned invalid pagination.");if(a=typeof m.continuation=="string"&&m.continuation?m.continuation:void 0,a){if(u.has(a))throw new h("Relay repeated its pagination cursor. Pending positions are incomplete.");u.add(a)}}while(a)}return[...i.values()]}}};export{ze as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ue}from"./UIIJWIR6.js";import{c as le}from"./D6VP3N27.js";import{a as X}from"./QZM7CWZW.js";import{a as x,b as v}from"./VJ3W2V3B.js";import{a as L}from"./OG5HRQU4.js";import{a as de}from"./P4UQGWCP.js";import{a as E}from"./6IM6A5VA.js";import{b as ie,c as ce}from"./MYBDO5SA.js";import{a as oe,b as G,c as V}from"./5HCXZWUH.js";import{l as ae,n as F,o as re}from"./IWALIX7Q.js";import{a as w,b as U,c as B,d as te,i as P,j as se,s as N}from"./XPFVT2EA.js";import{a as m}from"./5YS5V2LK.js";import{a as p,b as W,c as ne}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ie,encodeFunctionData as Le,erc20Abi as Z,getAddress as b,isAddress as H,parseAbi as ee}from"viem";var Te="https://api.robinhood.com/rhj/assets",Ne={address:x,symbol:"ETH",decimals:18,chainId:w},j={address:b(se),symbol:"USDG",decimals:te,chainId:w},Y={address:b(P[4663].tokens.WETH.address),symbol:"WETH",decimals:18,chainId:w},be={address:b(P[4663].meridian.CollateralToken_USDe.address),symbol:"USDe",decimals:18,chainId:w};function _(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Q(e,t=w,s={}){let n=Array.isArray(e)?e:_(e)&&Array.isArray(e.assets)?e.assets:void 0;if(!n)throw new m("Official stock asset list response is malformed.");let o=new Map,d=new Map;if(n.length>1e4)throw new m("Official stock asset list exceeds the lookup limit.");for(let a of n){if(!_(a))continue;let r=a;if(typeof r.tokenSymbol!="string"||!r.tokenSymbol.trim()||!Array.isArray(r.deployments))continue;if(r.deployments.length>100)throw new m("Official stock deployment list exceeds the lookup limit.");let l=r.tokenSymbol;if(!/^[A-Za-z0-9.$_-]{1,32}$/.test(l))throw new m(`Invalid official stock ticker ${p(l)}.`);if(r.tokenDecimals!==void 0&&(typeof r.tokenDecimals!="number"||!Number.isInteger(r.tokenDecimals)||r.tokenDecimals<0||r.tokenDecimals>255))throw new m("Official stock asset has invalid token decimals.");let f=typeof r.tokenDecimals=="number"&&Number.isInteger(r.tokenDecimals)&&r.tokenDecimals>=0&&r.tokenDecimals<=255?r.tokenDecimals:18;for(let k of r.deployments){if(!_(k))continue;let h=k;if(h.chainId!==t)continue;if(typeof h.contractAddress!="string"||!H(h.contractAddress,{strict:!1}))throw new m("Official stock deployment has an invalid contract address.");let y=b(h.contractAddress),u=y.toLowerCase(),g=l.toUpperCase(),i=d.get(g);if(!s.allowAmbiguousSymbols&&i&&i!==u)throw new m(`Ambiguous official stock ticker ${p(l)} across multiple addresses.`);let c=o.get(u);if(c&&(c.symbol!==l||c.decimals!==f))throw new m(`Conflicting official stock identity at ${y}.`);d.set(g,u),o.set(u,{address:y,symbol:l,decimals:f,chainId:t,...s.includeNames&&typeof r.tokenName=="string"&&r.tokenName.trim()?{name:r.tokenName.trim()}:{}})}}return[...o.values()]}function De(e,t){if(typeof e.address!="string"||!H(e.address,{strict:!1}))return!1;let s=e.chainId??w,n=e.address.toLowerCase();return t.some(o=>o.chainId===s&&o.address.toLowerCase()===n&&o.symbol===e.symbol)}function $(e,t){E(e.address);let s=e.chainId??w,n=b(e.address),o=n.toLowerCase(),d=C(e.symbol),a=t.find(l=>l.chainId===s&&l.address.toLowerCase()===o),r=t.find(l=>l.chainId===s&&C(l.symbol)===d);if(a){if(e.symbol!==a.symbol)throw new m(`Token at ${n} does not match official stock ticker ${p(a.symbol)} (received ${p(e.symbol)}).`);if(e.decimals!==void 0&&e.decimals!==a.decimals)throw new m(`Token ${p(a.symbol)} at ${n} does not match official decimals ${a.decimals}.`);return a}if(r)throw new m(`Token symbol ${p(e.symbol)} at ${n} does not match the official stock contract address ${r.address}.`);return{address:n,symbol:e.symbol.trim(),decimals:e.decimals??18,chainId:s}}var ve=["AAOI","AAPL","ABCL","ADBE","AEHR","AEIS","ALAB","AMAT","AMBA","AMC","AMD","AMKR","AMZN","ANET","APLD","APP","ASML","ASTS","AUR","AVAV","AVGO","AXON","AXTI","BA","BABA","BB","BE","BMNR","BND","BULL","CBRS","CCL","CEG","CELH","CIEN","CLOV","CLS","CLSK","COHR","COIN","COST","CRCL","CRDO","CRM","CRWD","CRWV","CSCO","CTSH","CVNA","DDOG","DELL","DIS","DJT","DOCN","ELF","EWT","EWY","F","FICO","FIG","FISV","FIX","FLNC","FLY","FTNT","FUTU","GDX","GE","GEV","GLD","GLW","GLXY","GME","GOOGL","HII","HIMS","HPE","HWM","IBM","IBRX","INDA","INFQ","INOD","INTC","INTU","IONQ","IREN","JBL","JNJ","JOBY","JPM","KLAC","KSS","KTOS","LHX","LITE","LLY","LMT","LRCX","LULU","LUNR","MCD","MDB","META","MOD","MPWR","MRNA","MRVL","MSFT","MSTR","MTSI","MU","MXL","NAVN","NBIS","NET","NFLX","NNE","NOW","NU","NVDA","NVTS","OKLO","ON","ONTO","ORCL","OUST","P","PANW","PATH","PENG","PFE","PL","PLTR","POET","POWL","PR","PWR","PYPL","QBTS","QCOM","QQQ","QUBT","RBLX","RCAT","RDDT","RDW","RGTI","RIVN","RKLB","RUN","SATS","SCHD","SGOV","SHOP","SHY","SIMO","SKHY","SLS","SLV","SMCI","SMH","SMR","SNAP","SNDK","SNOW","SOFI","SOUN","SOXX","SPCX","SPMO","SPY","TE","TEAM","TEM","TER","TSEM","TSLA","TSM","TTD","TTWO","UBER","UMC","UNH","UPS","USAR","USO","V","VICR","VRT","VSAT","VST","VTI","WDAY","WDC","WULF","WYFI","XLK","XNDU","XOM","ZETA","ZM","ZS"],J=new WeakMap,me=new WeakMap,z=new WeakMap;function K(e,t){return(z.get(e)??F)(t)}async function pe(e){let t=e?.http??ie(),s=e?.url??Te,n=e?.chainId??w,o=V(t),d=me.get(o);d||(d=new oe(3e4),me.set(o,d));let{value:a}=await K(t,()=>d.read(`${n}:${s}`,async()=>{let l=await F(k=>ce(o,s,{method:"GET",signal:k},h=>_(h)||Array.isArray(h))),f=Q(l,n,{allowAmbiguousSymbols:!0});if(n===w&&f.length===0)throw new m("Official stock asset list has no mainnet deployments; retry when the list is available.");return l})),r=Q(a,n,e);if(n===w){let l=J.get(o);l||(l=new Set,J.set(o,l));for(let f of r)l.add(C(f.symbol))}return r}var Pe=ee(["function aggregate3((address target, bool allowFailure, bytes callData)[] calls) payable returns ((bool success, bytes returnData)[] returnData)"]);function fe(e){let t=e,s=new Set;for(;t&&typeof t=="object"&&!s.has(t)&&s.size<10;){s.add(t);let n=t;if(n.name==="ContractFunctionZeroDataError"||n.name==="AbiDecodingZeroDataError")return!0;let o=`${typeof n.shortMessage=="string"?n.shortMessage:""} ${typeof n.message=="string"?n.message:""}`;if(/returned no data \("0x"\)|Cannot decode zero data/i.test(o))return!0;t=n.cause}return!1}function Ee(e){return e instanceof m?/RPC endpoint|too many requests|malformed JSON/i.test(e.message):e instanceof Error?/fetch failed|network|ECONNREFUSED|ETIMEDOUT|HTTP \d{3}|rate limit|too many requests/i.test(e.message):!1}async function xe(e,t,s){if(typeof e.getCode=="function")try{let n=await e.getCode({address:t});return!n||n==="0x"}catch{return fe(s)}return fe(s)}async function ke(e,t,s){if(t.length===0)return[];let n=await Promise.allSettled(t.map(o=>e.readContract({address:o.address,abi:Z,functionName:"balanceOf",args:[s]})));if(n.every(o=>o.status==="rejected")&&n[0]?.status==="rejected"&&Ee(n[0].reason))throw n[0].reason;return n.map(o=>{if(o.status!=="fulfilled"||o.value===void 0||o.value===null)return{ok:!1};try{let d=typeof o.value=="bigint"?o.value:BigInt(o.value);return d>=0n?{ok:!0,amount:d}:{ok:!1}}catch{return{ok:!1}}})}async function we(e,t,s,n){if(s.length===0)return[];let o=ae(t,e);if(!o)return ke(e,s,n);let d=s.map(r=>({target:r.address,allowFailure:!0,callData:Le({abi:Z,functionName:"balanceOf",args:[n]})})),a;try{a=await e.readContract({address:o,abi:Pe,functionName:"aggregate3",args:[d]})}catch(r){if(await xe(e,o,r))return ke(e,s,n);throw r}if(!Array.isArray(a)||a.length!==s.length)throw new m("Multicall3 aggregate3 returned an invalid result list.");return a.map(r=>{let l=r,f=Array.isArray(l)?l[0]:l?.success,k=Array.isArray(l)?l[1]:l?.returnData;if(!f||typeof k!="string"||k==="0x")return{ok:!1};try{let h=Ie({abi:Z,functionName:"balanceOf",data:k}),y=typeof h=="bigint"?h:BigInt(h);return y>=0n?{ok:!0,amount:y}:{ok:!1}}catch{return{ok:!1}}})}async function ze(e,t={}){E(e);let s=b(e),n=t.chainId??w,o=t.client??re(t.rpcUrl,n),d=[];if(t.stockTokens?d=[...t.stockTokens]:t.stockAssetsPayload!==void 0?d=Q(t.stockAssetsPayload,n):t.includeStockTokens!==!1&&n!==U&&(d=await pe({http:t.http,url:t.stockAssetsUrl,chainId:n})),t.tokens)for(let i of t.tokens)$(i,d);let a=n===w?[j,Y,be,...t.oakTokenAddress||process.env.OAK_TOKEN_ADDRESS?[{address:b(t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS),symbol:"OAK",decimals:B,chainId:n}]:[]]:n===U?[{...j,address:b(N.testnet.usdg),chainId:n},{...Y,address:b(N.testnet.weth),chainId:n},...t.oakTokenAddress?[{address:b(t.oakTokenAddress),symbol:"OAK",decimals:B,chainId:n}]:[]]:[],r=n===w&&t.includePoolTokens!==!1?de.vaults.flatMap(i=>[{address:b(i.tokenAddress),symbol:b(i.tokenAddress),decimals:i.tokenDecimals,chainId:n},{address:b(i.earnContractAddress),symbol:b(i.earnContractAddress),decimals:18,chainId:n}]):[],l=new Set(r.map(i=>i.address.toLowerCase())),f=[],k=new Set;for(let i of[...a,...d,...t.tokens??[],...r]){if(i.chainId!==n||v(i.address)===x)continue;let c=$(i,d),T=c.address.toLowerCase();k.has(T)||(k.add(T),f.push(c))}let[h,y]=await Promise.all([o.getBalance({address:s}),we(o,n,f,s)]),u=[],g={address:x,symbol:"ETH",decimals:18,chainId:n};(h>0n||t.includeZero)&&u.push({token:g,amount:h.toString()});for(let i=0;i<f.length;i++){let c=f[i],T=a.some(S=>O(S.address,c.address))||d.some(S=>O(S.address,c.address))?c.symbol:p(c.symbol),I=y[i]??{ok:!1};if(!I.ok){u.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:"unavailable"});continue}let A=I.amount;if(A>0n&&l.has(c.address.toLowerCase()))try{let[S,M]=await Promise.all([L(o,n,c.address,"symbol"),L(o,n,c.address,"decimals")]);T=p(S),c.decimals=M}catch{}(A>0n||t.includeZero)&&u.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:A.toString()})}return u}async function qe(e,t,s){if(E(e),t.length>1e4)throw new m("Journal token discovery exceeds the balance lookup limit.");let n=[...new Set(t.map(a=>(E(a),b(a))))].filter(a=>v(a)!==x).map(a=>({address:a,symbol:a,decimals:0,chainId:s.chainId})),o=await we(s.client,s.chainId,n,b(e)),d=n.flatMap((a,r)=>{let l=o[r];return l.ok&&l.amount===0n?[]:[{token:a,amount:l.ok?l.amount.toString():"unavailable"}]});return Promise.all(d.map(async({token:a,amount:r})=>{let[l,f]=await Promise.all([L(s.client,s.chainId,a.address,"symbol").catch(()=>a.address),L(s.client,s.chainId,a.address,"decimals").catch(()=>{throw new m(`Token decimals are unavailable for journal-received token ${a.address}; retry balances when RPC metadata is available.`)})]);return{token:{...a,symbol:p(l),decimals:f},amount:r}}))}var O=(e,t)=>e.toLowerCase()===t.toLowerCase(),C=e=>ne(e.normalize("NFKC")).toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");function ge(e){let t=e.context.network??"mainnet",{chainId:s,usdg:n,weth:o}=N[t],d=(a,r,l)=>({...a,address:v(b(a.address)),name:r,kind:l,verified:!0,source:"Oak fixed addresses",warnings:[]});return[d({...Ne,chainId:s},"Ether","native"),d({...j,address:n,chainId:s},"Global Dollar","stablecoin"),d({...Y,address:o,chainId:s},"Wrapped Ether","wrapped"),...t==="mainnet"?[d(be,"USDe","stablecoin")]:[],...e.oakTokenAddress?[d({address:e.oakTokenAddress,symbol:"OAK",decimals:B,chainId:s},"Oak","oak")]:[]]}async function Ae(e){if(e.context.network==="testnet")return[];let t=e.officialStockTokens??await pe({http:e.context.http,includeNames:!0,allowAmbiguousSymbols:!0});return t.filter(s=>De(s,t)).map(s=>({...s,name:s.name??s.symbol,kind:"official_stock",verified:!0,source:Te,warnings:[]}))}async function q(e,t,s=!0){let{chainId:n}=N[t.context.network??"mainnet"],o=t.context.clientFor(n);if(await o.getChainId()!==n)throw new m(`Token lookup requires Robinhood Chain ${n}.`);let[d,a,r]=await Promise.all([K(o,()=>L(o,n,e,"name",t.blockNumber)).catch(l=>{if(s)throw l;return""}),K(o,()=>L(o,n,e,"symbol",t.blockNumber)),K(o,()=>L(o,n,e,"decimals",t.blockNumber))]);if(typeof d!="string"||s&&!d.trim()||typeof a!="string"||!a.trim()||!Number.isInteger(r)||r<0||r>255)throw new m("The contract returned invalid token metadata.");return{address:b(e),name:d||a,symbol:a,decimals:r,chainId:n}}async function he(e,t){let s=await t.context.clientFor(w).readContract({address:P[w].clanker.factory.address,abi:ee(["function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),functionName:"tokenDeploymentInfo",args:[e]});return Array.isArray(s)&&s.length===4&&typeof s[0]=="string"&&O(s[0],e)}async function Me(e,t){let s=t.context.clientFor(w),n=P[w].poolsTrade,o=[n.instantLaunchStrategyFeesOn.address,n.instantLaunchStrategyFeesOff.address],d=ee(["event TokenLaunched(bytes32 indexed poolId,address indexed token,address indexed feeSplitter,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey)"])[0],a=await s.getBlockNumber(),r=new Set,l=0,f=0;for(let k=63127652n;k<=a;k+=10000000n){if(++l>Se)throw new m("Token origin scan limit reached.");let h=k+9999999n>a?a:k+9999999n,y=await s.getLogs({address:o,event:d,args:{token:e},fromBlock:k,toBlock:h,strict:!0});for(let u of y){if(u.removed||!o.some(i=>O(i,u.address))||!u.args.token||!O(u.args.token,e)||!u.transactionHash||r.has(u.transactionHash))continue;if(r.add(u.transactionHash),++f>20)throw new m("Token origin receipt limit reached.");let g=await s.getTransactionReceipt({hash:u.transactionHash});if(ue(g).some(i=>O(i.token,e)))return b(g.from)}}}var Se=5,Re=100,Ue=500,Be=3e4;function Ce(e){let t=Date.now()+Be,s=0,n=new Map,o=a=>{let r=t-Date.now();if(r<=0)throw new m("Token lookup time budget reached; results are partial.");return F(a,Math.min(1e4,r))},d=G((a,r)=>o(async l=>{let f=await e.context.http(a,{...r,signal:l});return new Proxy(f,{get(k,h){if(h==="json")return()=>o(()=>k.json());let y=Reflect.get(k,h,k);return typeof y=="function"?y.bind(k):y}})}),e.context.http);return z.set(d,o),{...e,context:{...e.context,http:d,clientFor:a=>{if(!n.has(a)){let r=e.context.clientFor(a),l=f=>{if(++s>Ue)throw new m("Token lookup RPC budget reached; results are partial.");return o(f)};n.set(a,G(new Proxy(r,{get(f,k){let h=Reflect.get(f,k);return typeof h!="function"?h:(...y)=>l(()=>h.apply(f,y))}}),r)),z.set(n.get(a),l)}return n.get(a)}}}}function ye(e){return e.source==="Oak fixed addresses"?e:{...e,symbol:p(e.symbol),name:p(e.name)}}async function en(e,t){if(t=Ce(t),typeof e!="string"||e.length>256||!C(e))throw new m("Provide a token name, symbol or address to find_token.");let s=C(e),n=H(e.trim(),{strict:!1})?v(b(e.trim())):void 0,{chainId:o}=N[t.context.network??"mainnet"],d=[],a=ge(t),r=!1;try{a.push(...await Ae(t))}catch{r=!0,d.push("The official stock list is unavailable; results are partial and stock identities and lookalikes could not be checked.")}let l=i=>n?O(i.address,n):C(i.symbol).includes(s)||C(i.name).includes(s),f=a.filter(l),k=[],h=(i,c)=>[i.symbol,i.name??""].some(T=>[c.symbol,c.name].some(I=>{let A=C(T),S=C(I);return!!A&&!!S&&(A.includes(S)||S.includes(A))})),y=(i,c={})=>{if(k.some(A=>O(A.address,i.address)))return;let T=[`Token ${p(i.symbol)} at ${i.address} is an unverified ${c.launchpad?"launchpad token":"token"}. Use its address, not its name or symbol.`];(W(i.symbol)||W(i.name)||a.some(A=>!O(A.address,i.address)&&h(i,A)))&&T.push(`Lookalike warning: ${p(i.symbol)} at ${i.address} resembles a verified token's name or symbol.`);let I={...i,...c,kind:c.launchpad?"launchpad":"erc20",verified:!1,source:c.launchpad?`${c.launchpad} origin and on-chain metadata; not a verified token`:"On-chain metadata only",warnings:T};k.push(I),d.push(...T)};if(n&&!f.length){let i=await q(n,t),c={};if(o===w){try{await he(n,t)&&(c.launchpad="clanker")}catch{d.push("Clanker origin lookup was unavailable for this address.")}if(c.launchpad==="clanker")try{let I=(await X(t.context,{q:n,limit:20})).tokens.find(A=>O(A.contract_address,n));I&&(c.creator=b(I.msg_sender),c.creatorSource="Clanker indexer msg_sender")}catch{d.push("Clanker creator lookup is unavailable.")}else try{let T=await le(t.context,n);c.launchpad="pons",c.creator=b(T.creator),c.creatorSource="Pons factory deployer"}catch{d.push("Pons launch origin could not be confirmed for this address.")}if(!c.launchpad)try{let T=await Me(n,t);T&&(c.launchpad="pools.trade",c.creator=T,c.creatorSource="Launch transaction sender; may be a relayer")}catch{r=!0,d.push("pools.trade launch receipt lookup is unavailable; origin results are partial.")}}y(i,c)}else if(!n&&o===w){let i=new Set,c=new Set,T,I=0,A=0;try{do{if(++I>Se)throw new m("Token search page limit reached.");let S=await X(t.context,{q:e.trim(),limit:20,...T?{cursor:T}:{}});for(let M of S.tokens){if(++A>Re)throw new m("Token candidate limit reached.");let D=b(M.contract_address);if(!(c.has(D)||a.some(R=>O(R.address,D)))){c.add(D);try{let R=await q(D,t);if(!l(R))continue;let Oe=await he(D,t)?{launchpad:"clanker",creator:b(M.msg_sender),creatorSource:"Clanker indexer msg_sender"}:{};y(R,Oe)}catch{r=!0,d.push(`Could not read Clanker candidate ${D}; it was omitted from these partial results.`)}}}if(S.cursor&&i.has(S.cursor))throw new m("The Clanker indexer repeated a pagination cursor.");S.cursor&&i.add(S.cursor),T=S.cursor??void 0}while(T)}catch{r=!0,d.push("Clanker name search is unavailable, incomplete or reached its scan limit; results are partial.")}d.push("Pons and pools.trade require a token address; name search does not cover those launchpads.")}o===U&&d.push("Testnet lookup covers pinned tokens and explicit token addresses; stock and launchpad discovery are unavailable.");let u=i=>[...new Map(i.map(c=>[c.address.toLowerCase(),c])).values()],g=u([...f,...k]);for(let i of g)if(g.some(c=>!O(c.address,i.address)&&(C(i.symbol)===C(c.symbol)||C(i.name)===C(c.name)))){let c=`Duplicate warning: several tokens share the symbol or name of ${i.address}. Choose the intended address; do not guess from the name.`;i.warnings.push(c),d.push(c)}return f.length>1&&d.push("Several verified tokens match this search, including possible substring matches. Choose an exact address; the search does not select a quote token."),{query:p(e.trim()),chainId:o,partial:r,matches:u(f).map(ye),unverified:u(k).map(ye),warnings:d}}async function nn(e,t){if(typeof e!="string"||!e.trim())throw new m("Provide a token address or verified symbol; use find_token to look it up.");if(!/^[A-Za-z0-9.$_-]{1,42}$/.test(e))throw new m("Use an exact ASCII verified symbol or token address; use find_token to look it up.");let s=e,n=H(s,{strict:!1})?v(b(s)):void 0,o=ge(t),d=n&&o.find(y=>O(y.address,n));if(d)return d;let a=s.toUpperCase()==="$OAK"?"OAK":s.toUpperCase(),r=!n&&o.find(y=>y.symbol.toUpperCase()===a),l=[],f=!1;try{l=await Ae(t)}catch{if(r)return r;if(!n)throw new m("The official stock list is unavailable; stock symbols cannot be checked. Use find_token and try again when the list is reachable.");f=!0}if(n){let y=l.find(i=>O(i.address,n));if(y)return t.tokenMetadata&&$(t.tokenMetadata,l),{...y,name:p(y.name)};let u=t.tokenMetadata??await t.readMetadata?.(n);if(u&&(!O(u.address,n)||u.chainId!==N[t.context.network??"mainnet"].chainId))throw new m("Token metadata does not match the requested address and chain.");if(u&&(typeof u.symbol!="string"||!u.symbol.trim()||!Number.isInteger(u.decimals)||u.decimals<0||u.decimals>255))throw new m("The contract returned invalid token metadata.");let g=u?{...u,name:u.symbol}:await q(n,Ce(t),!1);if(f){let i=C(g.symbol),c=J.get(V(t.context.http));if(ve.some(T=>C(T)===i)||c?.has(i))throw new m("The official stock list is unavailable; this address claims a stock ticker that cannot be checked. Try again when the list is reachable.")}return $(g,l),{...g,symbol:p(g.symbol),name:p(g.name),kind:"erc20",verified:!1,source:"On-chain metadata only",warnings:["This token address is unverified. On-chain names and symbols do not prove identity.",...f?["The official stock list is unavailable; stock identity could not be verified."]:[]]}}let k=[...o,...l].filter(y=>y.symbol.toUpperCase()===a);if(k.length!==1)throw new m(`Token symbol ${p(s)} is ${k.length?"ambiguous":"unverified"}; use find_token and choose an explicit address.`);let h=k[0];if(h.kind==="official_stock"&&s!==h.symbol)throw new m(`Use the exact official stock ticker ${p(h.symbol)}; case variants are refused.`);return h.source==="Oak fixed addresses"?h:{...h,name:p(h.name)}}export{Te as a,Ne as b,j as c,Y as d,be as e,Q as f,De as g,$ as h,pe as i,Pe as j,ze as k,qe as l,en as m,nn as n};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as pe,c as De}from"./SQ5BNSXR.js";import{c as Te,d as a,r as xe}from"./53N7PNJH.js";import{o as ce}from"./EAEQOS7Y.js";import{a as M}from"./XCFA73P2.js";import{a as ve}from"./6IM6A5VA.js";import{a as te}from"./UWOFA6GV.js";import{c as H,j as Ce}from"./73N3TOJL.js";import{a as ke}from"./RETS2ZEK.js";import{a as R,i as qe}from"./XPFVT2EA.js";import{a as e}from"./5YS5V2LK.js";import{decodeFunctionData as Ee,erc20Abi as Ne}from"viem";var je="https://api.relay.link",q="0x0000000000000000000000000000000000000000",Le=60,Se=30,n=qe[R].relay.depository.address.toLowerCase(),ne="0x59916da825d2d2ec1bf878d71c88826f6633ecca",Oe=new Map([[1,{chainId:"ethereum",depository:n}],[10,{chainId:"optimism",depository:n}],[25,{chainId:"cronos",depository:ne}],[56,{chainId:"bnb",depository:n}],[100,{chainId:"gnosis",depository:n}],[130,{chainId:"unichain",depository:n}],[137,{chainId:"polygon",depository:n}],[143,{chainId:"monad",depository:n}],[146,{chainId:"sonic",depository:n}],[169,{chainId:"manta",depository:n}],[196,{chainId:"xlayer",depository:n}],[288,{chainId:"boba",depository:n}],[324,{chainId:"zksync",depository:n}],[360,{chainId:"shape",depository:n}],[480,{chainId:"worldchain",depository:n}],[747,{chainId:"flow",depository:n}],[988,{chainId:"stable",depository:n}],[999,{chainId:"hyperevm",depository:n}],[1088,{chainId:"metis",depository:ne}],[1135,{chainId:"lisk",depository:n}],[1868,{chainId:"soneium",depository:n}],[2020,{chainId:"ronin",depository:n}],[2741,{chainId:"abstract",depository:n}],[2818,{chainId:"morph",depository:n}],[4217,{chainId:"tempo",depository:n}],[4326,{chainId:"megaeth",depository:n}],[5e3,{chainId:"mantle",depository:ne}],[5031,{chainId:"somnia",depository:n}],[5042,{chainId:"arc",depository:n}],[8453,{chainId:"base",depository:n}],[9745,{chainId:"plasma",depository:n}],[33139,{chainId:"apechain",depository:n}],[34443,{chainId:"mode",depository:n}],[42018,{chainId:"mythos",depository:n}],[42161,{chainId:"arbitrum",depository:n}],[42220,{chainId:"celo",depository:n}],[43114,{chainId:"avalanche",depository:n}],[48900,{chainId:"zircuit",depository:n}],[57073,{chainId:"ink",depository:n}],[59144,{chainId:"linea",depository:ne}],[60808,{chainId:"bob",depository:n}],[80094,{chainId:"berachain",depository:n}],[97477,{chainId:"doma",depository:n}],[98866,{chainId:"plume",depository:n}],[534352,{chainId:"scroll",depository:n}],[685689,{chainId:"gensyn",depository:n}],[747474,{chainId:"katana",depository:n}],[5064014,{chainId:"ethereal",depository:n}],[7777777,{chainId:"zora",depository:n}]]);function nt(t){return Oe.get(t)?.depository}function F(t){return Ce(t,"Provide a token or wallet address.")}function I(t){let o=F(t);return o===M?q:o}function f(t,o){return F(t)===F(o)}function l(t){if(typeof t!="string")throw new e("Provide a decimal base-unit amount string.");return ke(t),t}function oe(t){let o=l(t);if(BigInt(o)<=0n)throw new e("Provide a positive base-unit amount.");return o}function ze(t){if(typeof t!="number"||!Number.isSafeInteger(t)||t<=0)throw new e("Provide a positive integer origin chain ID.");return t}function Pe(t,o){if(typeof t!="number"||!Number.isSafeInteger(t)||t<=0)throw new e(`${o} is missing or invalid.`);return t}async function G(t,o,c,i,p){let r=a(c);if(r.chainId!==i||I(r.address)!==p||typeof r.symbol!="string"||!/^[A-Za-z0-9._-]{1,32}$/.test(r.symbol))throw new e("Relay quote token metadata does not match the requested chain and address.");if(p===q){if(r.decimals!==18)throw new e("Native token decimals must be 18.");return{address:M,chainId:i,symbol:r.symbol,decimals:18}}let g=`${i}:${p}`,m=o.get(g);if(m===void 0){let d=await t.clientFor(i).readContract({address:p,abi:Ne,functionName:"decimals"}),w=typeof d=="bigint"?Number(d):d;if(typeof w!="number"||!Number.isInteger(w)||w<0||w>255)throw new e("Could not read valid ERC-20 decimals() on-chain.");m=w,o.set(g,m)}return{address:p,chainId:i,symbol:r.symbol,decimals:m}}async function Ke(t,o,c,i,p,r,g){if(c.swap===void 0)return[];let m=a(c.swap),d=a(m.from);if(d.chainId!==p)throw new e("The swap prerequisite token must be on the origin chain.");let w=await G(t,o,d,p,I(d.address)),j=r===q?M:r;if(f(w.address,j))throw new e("The swap prerequisite must use a different input token.");let me=oe(m.amountIn),y=m.slippageBps;if(y!==void 0&&(typeof y!="number"||!Number.isInteger(y)||y<0||y>1e4))throw new e("Provide swap slippage in basis points from 0 to 10000.");let E=await t.quoteSwap({from:w.address,to:j,amountIn:me,...y===void 0?{}:{slippageBps:y}},i);if(BigInt(l(E.expiresAt))<=BigInt(Math.floor(Date.now()/1e3)))throw new e("The swap prerequisite quote expired. Request a fresh quote.");if(BigInt(l(E.minAmountOut))<BigInt(g))throw new e("The swap prerequisite minimum cannot cover the bridge amount.");let k=await t.buildSwap(E.quoteId,i);if(!("txs"in k)||!k.txs.length)throw new e("The swap prerequisite must return unsigned transactions.");if(k.txs.some(S=>S.chainId!==p))throw new e("The injected swap coordinator does not support this origin chain.");return k.txs.map(S=>t.unsignedTx(S))}async function Ue(t,o,c){ve(c);let i=ze(o.originChainId);if(i===R)throw new e("Inbound bridging requires an origin chain other than 4663.");let p=Oe.get(i);if(!p)throw new e("Relay inbound does not support this origin chain.");if(o.destinationChainId!==void 0&&o.destinationChainId!==R)throw new e("Inbound bridge destination must be chain 4663.");let r=I(o.originCurrency??M),g=I(o.destinationCurrency??M),m=F(o.recipient??c),d=oe(o.amount),w=o.minAmountOut===void 0?void 0:l(o.minAmountOut),j=o.slippageBps===void 0?pe:o.slippageBps;if(ce("0",j),await t.clientFor(i).getChainId()!==i)throw new e("The RPC chain does not match the inbound origin chain.");let y=new Map,E=await Ke(t,y,o,c,i,r,d),k,S=process.env.OAK_RELAY_API_KEY?.trim();if(!S)throw new e("Configure OAK_RELAY_API_KEY on the server: Relay quote/v2 requires a valid API key since October 2, 2026. Status and chain reads remain available without it.");try{let s=await t.http(`${je}/quote/v2`,{method:"POST",headers:{"content-type":"application/json","user-agent":"oak-core/0.1.0","x-api-key":S},body:JSON.stringify({user:c,recipient:m,originChainId:i,destinationChainId:R,originCurrency:r,destinationCurrency:g,amount:d,tradeType:"EXACT_INPUT",...r===q?{}:{explicitDeposit:!0}})});if(!s.ok)throw new Error("Relay HTTP failure.");k=await s.json()}catch{throw new e("Relay quote request failed. Please try again.")}let b=a(k);if(typeof b.requestId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(b.requestId))throw new e("Relay returned an invalid request ID.");let P=b.requestId,he=`/intents/status/v3?requestId=${P}`,L=a(b.details);if(!f(L.sender,c)||!f(L.recipient,m))throw new e("Relay quote sender or recipient does not match the request.");let ye=a(L.currencyIn),ie=a(L.currencyOut),N=await G(t,y,ye.currency,i,r),O=await G(t,y,ie.currency,R,g);if(l(ye.amount)!==d)throw new e("Relay quote input amount does not match the request.");let _=oe(ie.amount),C=oe(ie.minimumAmount);if(BigInt(C)>BigInt(_))throw new e("Relay quote minimum output exceeds the expected output.");if(w!==void 0){if(C!==w)throw new e("Relay order minimum must exactly match minAmountOut. Request a new quote.")}else{let s=ce(_,j);if(BigInt(C)<BigInt(s))throw De(_,C)}let le=a(a(b.fees).relayer),fe=a(le.currency),Q=await G(t,y,fe,i,I(fe.address)),we={token:Q,amount:l(le.amount)},Ie=a(L.refundCurrency),_e=a(Ie.currency),z=await G(t,y,_e,i,r),re=l(Ie.amount),K=a(a(b.protocol).v2);if(typeof K.orderId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(K.orderId))throw new e("Relay returned an invalid order ID.");let V=K.orderId.toLowerCase(),W=a(K.paymentDetails),$=F(W.depository);if(W.chainId!==p.chainId||$!==p.depository||I(W.currency)!==r||l(W.amount)!==d)throw new e("Relay payment details do not match the origin chain depository and input.");let J=a(K.orderData),v=a(J.output);if(v.chainId!=="robinhood"||!Array.isArray(v.calls)||v.calls.length!==0||!Array.isArray(v.payments)||v.payments.length!==1)throw new e("Relay order output does not match destination chain 4663.");let X=a(v.payments[0]);if(!f(X.recipient,m)||I(X.currency)!==g||l(X.minimumAmount)!==C||l(X.expectedAmount)!==_)throw new e("Relay order output payment does not match the quoted recipient and amounts.");let se=Pe(v.deadline,"Relay order output deadline");if(!Array.isArray(J.inputs)||!J.inputs.length)throw new e("Relay order has no inputs.");let Z=[],ae=[];for(let s of J.inputs){let u=a(s),x=a(u.payment);if(x.chainId!==p.chainId||I(x.currency)!==r||l(x.amount)!==d||!Array.isArray(u.refunds)||!u.refunds.length)throw new e("Relay order input does not match the quoted input.");for(let D of u.refunds){let h=a(D);if(!f(h.recipient,c))throw new e("Relay refund recipient does not match the agent wallet. Request a new quote.");if(Z.push(Pe(h.deadline,"Relay order refund deadline")),ae.push(l(h.minimumAmount)),!(h.chainId===p.chainId?f(h.recipient,c)&&I(h.currency)===r:h.chainId==="robinhood"&&I(h.currency)===g))throw new e("Relay order refund terms do not match the sender or recipient.")}}let ge=Math.min(se,...Z),U=0,be=()=>{let s=Math.floor(Date.now()/1e3),u=U||s+Le;if(ge-s<=Se)throw new e("Relay order deadline is expired or too soon to sign safely. Request a new quote.");if(U=Math.min(u,ge-Se),U<=s)throw new e("Relay quote expired before signing. Request a new quote.")};if(be(),!Array.isArray(b.steps)||!b.steps.length)throw new e("Relay returned no origin transactions.");let T=[];for(let s of b.steps){let u=a(s);if(u.kind!=="transaction"||u.requestId!==P||!Array.isArray(u.items)||!u.items.length)throw new e("Relay returned an unsupported origin step.");for(let x of u.items){let D=a(x),h=a(D.data),ue=a(D.check);if(D.status!=="incomplete"||h.chainId!==i||!f(h.from,c))throw new e("Relay transaction does not match the origin chain and sender.");if(ue.method!=="GET"||ue.endpoint!==he)throw new e("Relay status endpoint does not match the request ID.");T.push(t.unsignedTx({to:F(h.to),data:h.data,value:l(h.value),chainId:i,description:`Relay inbound deposit for request ${P}; destination chain 4663.`}))}}if(!T.length)throw new e("Relay returned no origin transactions.");if(r===q&&T.length!==1)throw new e("Relay native deposit must be a single depositNative transaction.");if(r!==q&&T.length>2)throw new e("Relay ERC-20 deposit allows at most one exact-amount approval before depositErc20.");for(let s of T.slice(0,-1)){if(!s.data.toLowerCase().startsWith("0x095ea7b3"))throw new e("Relay returned an unsupported prerequisite transaction.");let u=Ee({abi:Ne,data:s.data});if(u.functionName!=="approve")throw new e("Relay returned an invalid approval.");let[x,D]=u.args;if(r===q||!f(s.to,r)||!f(x,$)||D!==BigInt(d)||s.value!=="0")throw new e("Relay approval must authorize the exact input amount for the origin depository.");s.description=`Approve exactly ${t.formatAmount(d,N.decimals)} ${N.symbol} (${d} base units of ${r}) for ${$} on chain ${i}.`}let B=T[T.length-1],Y=r===q,ee=Y?"depositNative":"depositErc20",Ae=Y?"depositNative(address,bytes32)":"depositErc20(address,address,uint256,bytes32)";if(!f(B.to,$)||B.value!==(Y?d:"0")||!(Y?/^0x[0-9a-fA-F]{136}$/:/^0x[0-9a-fA-F]{264}$/).test(B.data))throw new e(`Relay deposit transaction does not target the origin depository with ${ee} calldata.`);let A;try{A=Ee({abi:Te,data:B.data})}catch{throw new e(`Relay deposit transaction must call ${Ae}.`)}if(A.functionName!==ee)throw new e(`Relay deposit transaction must call ${Ae}.`);let Be=A.args[0],Me=A.functionName==="depositErc20"?A.args[3]:A.args[1];if(A.functionName==="depositErc20"&&(!f(A.args[1],r)||A.args[2]!==BigInt(d)))throw new e("Relay depositErc20 token or amount does not match the quoted input.");if(!f(Be,c)||Me.toLowerCase()!==V)throw new e(`Relay ${ee} depositor or orderId does not match the wallet and quoted protocol.v2.orderId.`);B.description=`Relay inbound ${ee} for order ${V} (request ${P}); destination chain 4663.`;let de=Y?[]:await xe(t,r,$,d,i,c);for(let[s,u]of de.entries())u.description=de.length===2&&s===0?`Reset the existing ${N.symbol} allowance for ${$} on chain ${i} to zero.`:`Approve exactly ${t.formatAmount(d,N.decimals)} ${N.symbol} (${d} base units of ${r}) for ${$} on chain ${i}.`;let $e=[...E,...de,B],Re=await t.preview($e,c);be();let Fe=Re.changes.map(s=>{let u=s.amount.startsWith("-");return`${u?"-":""}${t.formatAmount(u?s.amount.slice(1):s.amount,s.token.decimals)} ${s.token.symbol} (${s.token.address}, chain ${s.token.chainId})`});return{txs:$e,preview:Re,requestId:P,orderId:V,depository:$,originChainId:i,destinationChainId:R,recipient:m,amountIn:{token:N,amount:d},amountOut:{token:O,amount:_},minAmountOut:C,relayerFee:we,refundCurrency:{token:z,amount:re,minimumAmounts:ae},orderDeadline:String(se),refundDeadlines:Z.map(String),expiresAt:String(U),status:"pending",statusEndpoint:he,summary:`${E.length?"Swap prerequisite first, then ":""}Relay inbound from chain ${i} to chain 4663 for ${m}; expected ${t.formatAmount(_,O.decimals)} ${O.symbol}, minimum ${t.formatAmount(C,O.decimals)} ${O.symbol} (${O.address}). Quoted relay fee ${t.formatAmount(we.amount,Q.decimals)} ${Q.symbol} (${Q.address}, chain ${i}); output is net of quoted fees. Order ${V} (request ${P}); output deadline ${se}, refund deadlines ${Z.join(", ")}, quote expires ${U}. Refund terms: details.refundCurrency quotes ${t.formatAmount(re,z.decimals)} ${z.symbol} (${re} base units) on chain ${z.chainId} (${z.address}), but protocol.v2 order refund floor is ${ae.join(", ")} base units. ${Fe.join("; ")}. Unsigned origin transactions only; destination fulfillment remains pending. Track with relay_status; timeout or refund is not fulfillment.`}}var ot=t=>({tools:[{name:"relay_bridge_in",inputSchema:{type:"object",additionalProperties:!1,required:["originChainId","amount"],properties:{originChainId:{type:"integer",minimum:1},destinationChainId:{const:R},originCurrency:H,destinationCurrency:H,amount:te(),minAmountOut:te(),slippageBps:{type:"integer",minimum:0,maximum:9999,default:pe},recipient:H,swap:{type:"object",additionalProperties:!1,required:["from","amountIn"],properties:{from:{type:"object",additionalProperties:!1,required:["address","chainId","symbol","decimals"],properties:{address:H,chainId:{type:"integer",minimum:1},symbol:{type:"string"},decimals:{type:"integer",minimum:0,maximum:255}}},amountIn:te(),slippageBps:{type:"integer",minimum:0,maximum:1e4}}}}},async execute(o,c){try{return await Ue(t,o,c)}catch(i){throw new e(t.plainError(i))}}}]});export{nt as a,ot as b};
|
|
1
|
+
import{b as pe,c as De}from"./SQ5BNSXR.js";import{c as Te,d as a,r as xe}from"./53N7PNJH.js";import{o as ce}from"./CAU44UWP.js";import{a as M}from"./VJ3W2V3B.js";import{a as ve}from"./6IM6A5VA.js";import{a as te}from"./UWOFA6GV.js";import{c as H,j as Ce}from"./73N3TOJL.js";import{a as ke}from"./RETS2ZEK.js";import{a as R,i as qe}from"./XPFVT2EA.js";import{a as e}from"./5YS5V2LK.js";import{decodeFunctionData as Ee,erc20Abi as Ne}from"viem";var je="https://api.relay.link",q="0x0000000000000000000000000000000000000000",Le=60,Se=30,n=qe[R].relay.depository.address.toLowerCase(),ne="0x59916da825d2d2ec1bf878d71c88826f6633ecca",Oe=new Map([[1,{chainId:"ethereum",depository:n}],[10,{chainId:"optimism",depository:n}],[25,{chainId:"cronos",depository:ne}],[56,{chainId:"bnb",depository:n}],[100,{chainId:"gnosis",depository:n}],[130,{chainId:"unichain",depository:n}],[137,{chainId:"polygon",depository:n}],[143,{chainId:"monad",depository:n}],[146,{chainId:"sonic",depository:n}],[169,{chainId:"manta",depository:n}],[196,{chainId:"xlayer",depository:n}],[288,{chainId:"boba",depository:n}],[324,{chainId:"zksync",depository:n}],[360,{chainId:"shape",depository:n}],[480,{chainId:"worldchain",depository:n}],[747,{chainId:"flow",depository:n}],[988,{chainId:"stable",depository:n}],[999,{chainId:"hyperevm",depository:n}],[1088,{chainId:"metis",depository:ne}],[1135,{chainId:"lisk",depository:n}],[1868,{chainId:"soneium",depository:n}],[2020,{chainId:"ronin",depository:n}],[2741,{chainId:"abstract",depository:n}],[2818,{chainId:"morph",depository:n}],[4217,{chainId:"tempo",depository:n}],[4326,{chainId:"megaeth",depository:n}],[5e3,{chainId:"mantle",depository:ne}],[5031,{chainId:"somnia",depository:n}],[5042,{chainId:"arc",depository:n}],[8453,{chainId:"base",depository:n}],[9745,{chainId:"plasma",depository:n}],[33139,{chainId:"apechain",depository:n}],[34443,{chainId:"mode",depository:n}],[42018,{chainId:"mythos",depository:n}],[42161,{chainId:"arbitrum",depository:n}],[42220,{chainId:"celo",depository:n}],[43114,{chainId:"avalanche",depository:n}],[48900,{chainId:"zircuit",depository:n}],[57073,{chainId:"ink",depository:n}],[59144,{chainId:"linea",depository:ne}],[60808,{chainId:"bob",depository:n}],[80094,{chainId:"berachain",depository:n}],[97477,{chainId:"doma",depository:n}],[98866,{chainId:"plume",depository:n}],[534352,{chainId:"scroll",depository:n}],[685689,{chainId:"gensyn",depository:n}],[747474,{chainId:"katana",depository:n}],[5064014,{chainId:"ethereal",depository:n}],[7777777,{chainId:"zora",depository:n}]]);function nt(t){return Oe.get(t)?.depository}function F(t){return Ce(t,"Provide a token or wallet address.")}function I(t){let o=F(t);return o===M?q:o}function f(t,o){return F(t)===F(o)}function l(t){if(typeof t!="string")throw new e("Provide a decimal base-unit amount string.");return ke(t),t}function oe(t){let o=l(t);if(BigInt(o)<=0n)throw new e("Provide a positive base-unit amount.");return o}function ze(t){if(typeof t!="number"||!Number.isSafeInteger(t)||t<=0)throw new e("Provide a positive integer origin chain ID.");return t}function Pe(t,o){if(typeof t!="number"||!Number.isSafeInteger(t)||t<=0)throw new e(`${o} is missing or invalid.`);return t}async function G(t,o,c,i,p){let r=a(c);if(r.chainId!==i||I(r.address)!==p||typeof r.symbol!="string"||!/^[A-Za-z0-9._-]{1,32}$/.test(r.symbol))throw new e("Relay quote token metadata does not match the requested chain and address.");if(p===q){if(r.decimals!==18)throw new e("Native token decimals must be 18.");return{address:M,chainId:i,symbol:r.symbol,decimals:18}}let g=`${i}:${p}`,m=o.get(g);if(m===void 0){let d=await t.clientFor(i).readContract({address:p,abi:Ne,functionName:"decimals"}),w=typeof d=="bigint"?Number(d):d;if(typeof w!="number"||!Number.isInteger(w)||w<0||w>255)throw new e("Could not read valid ERC-20 decimals() on-chain.");m=w,o.set(g,m)}return{address:p,chainId:i,symbol:r.symbol,decimals:m}}async function Ke(t,o,c,i,p,r,g){if(c.swap===void 0)return[];let m=a(c.swap),d=a(m.from);if(d.chainId!==p)throw new e("The swap prerequisite token must be on the origin chain.");let w=await G(t,o,d,p,I(d.address)),j=r===q?M:r;if(f(w.address,j))throw new e("The swap prerequisite must use a different input token.");let me=oe(m.amountIn),y=m.slippageBps;if(y!==void 0&&(typeof y!="number"||!Number.isInteger(y)||y<0||y>1e4))throw new e("Provide swap slippage in basis points from 0 to 10000.");let E=await t.quoteSwap({from:w.address,to:j,amountIn:me,...y===void 0?{}:{slippageBps:y}},i);if(BigInt(l(E.expiresAt))<=BigInt(Math.floor(Date.now()/1e3)))throw new e("The swap prerequisite quote expired. Request a fresh quote.");if(BigInt(l(E.minAmountOut))<BigInt(g))throw new e("The swap prerequisite minimum cannot cover the bridge amount.");let k=await t.buildSwap(E.quoteId,i);if(!("txs"in k)||!k.txs.length)throw new e("The swap prerequisite must return unsigned transactions.");if(k.txs.some(S=>S.chainId!==p))throw new e("The injected swap coordinator does not support this origin chain.");return k.txs.map(S=>t.unsignedTx(S))}async function Ue(t,o,c){ve(c);let i=ze(o.originChainId);if(i===R)throw new e("Inbound bridging requires an origin chain other than 4663.");let p=Oe.get(i);if(!p)throw new e("Relay inbound does not support this origin chain.");if(o.destinationChainId!==void 0&&o.destinationChainId!==R)throw new e("Inbound bridge destination must be chain 4663.");let r=I(o.originCurrency??M),g=I(o.destinationCurrency??M),m=F(o.recipient??c),d=oe(o.amount),w=o.minAmountOut===void 0?void 0:l(o.minAmountOut),j=o.slippageBps===void 0?pe:o.slippageBps;if(ce("0",j),await t.clientFor(i).getChainId()!==i)throw new e("The RPC chain does not match the inbound origin chain.");let y=new Map,E=await Ke(t,y,o,c,i,r,d),k,S=process.env.OAK_RELAY_API_KEY?.trim();if(!S)throw new e("Configure OAK_RELAY_API_KEY on the server: Relay quote/v2 requires a valid API key since October 2, 2026. Status and chain reads remain available without it.");try{let s=await t.http(`${je}/quote/v2`,{method:"POST",headers:{"content-type":"application/json","user-agent":"oak-core/0.1.0","x-api-key":S},body:JSON.stringify({user:c,recipient:m,originChainId:i,destinationChainId:R,originCurrency:r,destinationCurrency:g,amount:d,tradeType:"EXACT_INPUT",...r===q?{}:{explicitDeposit:!0}})});if(!s.ok)throw new Error("Relay HTTP failure.");k=await s.json()}catch{throw new e("Relay quote request failed. Please try again.")}let b=a(k);if(typeof b.requestId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(b.requestId))throw new e("Relay returned an invalid request ID.");let P=b.requestId,he=`/intents/status/v3?requestId=${P}`,L=a(b.details);if(!f(L.sender,c)||!f(L.recipient,m))throw new e("Relay quote sender or recipient does not match the request.");let ye=a(L.currencyIn),ie=a(L.currencyOut),N=await G(t,y,ye.currency,i,r),O=await G(t,y,ie.currency,R,g);if(l(ye.amount)!==d)throw new e("Relay quote input amount does not match the request.");let _=oe(ie.amount),C=oe(ie.minimumAmount);if(BigInt(C)>BigInt(_))throw new e("Relay quote minimum output exceeds the expected output.");if(w!==void 0){if(C!==w)throw new e("Relay order minimum must exactly match minAmountOut. Request a new quote.")}else{let s=ce(_,j);if(BigInt(C)<BigInt(s))throw De(_,C)}let le=a(a(b.fees).relayer),fe=a(le.currency),Q=await G(t,y,fe,i,I(fe.address)),we={token:Q,amount:l(le.amount)},Ie=a(L.refundCurrency),_e=a(Ie.currency),z=await G(t,y,_e,i,r),re=l(Ie.amount),K=a(a(b.protocol).v2);if(typeof K.orderId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(K.orderId))throw new e("Relay returned an invalid order ID.");let V=K.orderId.toLowerCase(),W=a(K.paymentDetails),$=F(W.depository);if(W.chainId!==p.chainId||$!==p.depository||I(W.currency)!==r||l(W.amount)!==d)throw new e("Relay payment details do not match the origin chain depository and input.");let J=a(K.orderData),v=a(J.output);if(v.chainId!=="robinhood"||!Array.isArray(v.calls)||v.calls.length!==0||!Array.isArray(v.payments)||v.payments.length!==1)throw new e("Relay order output does not match destination chain 4663.");let X=a(v.payments[0]);if(!f(X.recipient,m)||I(X.currency)!==g||l(X.minimumAmount)!==C||l(X.expectedAmount)!==_)throw new e("Relay order output payment does not match the quoted recipient and amounts.");let se=Pe(v.deadline,"Relay order output deadline");if(!Array.isArray(J.inputs)||!J.inputs.length)throw new e("Relay order has no inputs.");let Z=[],ae=[];for(let s of J.inputs){let u=a(s),x=a(u.payment);if(x.chainId!==p.chainId||I(x.currency)!==r||l(x.amount)!==d||!Array.isArray(u.refunds)||!u.refunds.length)throw new e("Relay order input does not match the quoted input.");for(let D of u.refunds){let h=a(D);if(!f(h.recipient,c))throw new e("Relay refund recipient does not match the agent wallet. Request a new quote.");if(Z.push(Pe(h.deadline,"Relay order refund deadline")),ae.push(l(h.minimumAmount)),!(h.chainId===p.chainId?f(h.recipient,c)&&I(h.currency)===r:h.chainId==="robinhood"&&I(h.currency)===g))throw new e("Relay order refund terms do not match the sender or recipient.")}}let ge=Math.min(se,...Z),U=0,be=()=>{let s=Math.floor(Date.now()/1e3),u=U||s+Le;if(ge-s<=Se)throw new e("Relay order deadline is expired or too soon to sign safely. Request a new quote.");if(U=Math.min(u,ge-Se),U<=s)throw new e("Relay quote expired before signing. Request a new quote.")};if(be(),!Array.isArray(b.steps)||!b.steps.length)throw new e("Relay returned no origin transactions.");let T=[];for(let s of b.steps){let u=a(s);if(u.kind!=="transaction"||u.requestId!==P||!Array.isArray(u.items)||!u.items.length)throw new e("Relay returned an unsupported origin step.");for(let x of u.items){let D=a(x),h=a(D.data),ue=a(D.check);if(D.status!=="incomplete"||h.chainId!==i||!f(h.from,c))throw new e("Relay transaction does not match the origin chain and sender.");if(ue.method!=="GET"||ue.endpoint!==he)throw new e("Relay status endpoint does not match the request ID.");T.push(t.unsignedTx({to:F(h.to),data:h.data,value:l(h.value),chainId:i,description:`Relay inbound deposit for request ${P}; destination chain 4663.`}))}}if(!T.length)throw new e("Relay returned no origin transactions.");if(r===q&&T.length!==1)throw new e("Relay native deposit must be a single depositNative transaction.");if(r!==q&&T.length>2)throw new e("Relay ERC-20 deposit allows at most one exact-amount approval before depositErc20.");for(let s of T.slice(0,-1)){if(!s.data.toLowerCase().startsWith("0x095ea7b3"))throw new e("Relay returned an unsupported prerequisite transaction.");let u=Ee({abi:Ne,data:s.data});if(u.functionName!=="approve")throw new e("Relay returned an invalid approval.");let[x,D]=u.args;if(r===q||!f(s.to,r)||!f(x,$)||D!==BigInt(d)||s.value!=="0")throw new e("Relay approval must authorize the exact input amount for the origin depository.");s.description=`Approve exactly ${t.formatAmount(d,N.decimals)} ${N.symbol} (${d} base units of ${r}) for ${$} on chain ${i}.`}let B=T[T.length-1],Y=r===q,ee=Y?"depositNative":"depositErc20",Ae=Y?"depositNative(address,bytes32)":"depositErc20(address,address,uint256,bytes32)";if(!f(B.to,$)||B.value!==(Y?d:"0")||!(Y?/^0x[0-9a-fA-F]{136}$/:/^0x[0-9a-fA-F]{264}$/).test(B.data))throw new e(`Relay deposit transaction does not target the origin depository with ${ee} calldata.`);let A;try{A=Ee({abi:Te,data:B.data})}catch{throw new e(`Relay deposit transaction must call ${Ae}.`)}if(A.functionName!==ee)throw new e(`Relay deposit transaction must call ${Ae}.`);let Be=A.args[0],Me=A.functionName==="depositErc20"?A.args[3]:A.args[1];if(A.functionName==="depositErc20"&&(!f(A.args[1],r)||A.args[2]!==BigInt(d)))throw new e("Relay depositErc20 token or amount does not match the quoted input.");if(!f(Be,c)||Me.toLowerCase()!==V)throw new e(`Relay ${ee} depositor or orderId does not match the wallet and quoted protocol.v2.orderId.`);B.description=`Relay inbound ${ee} for order ${V} (request ${P}); destination chain 4663.`;let de=Y?[]:await xe(t,r,$,d,i,c);for(let[s,u]of de.entries())u.description=de.length===2&&s===0?`Reset the existing ${N.symbol} allowance for ${$} on chain ${i} to zero.`:`Approve exactly ${t.formatAmount(d,N.decimals)} ${N.symbol} (${d} base units of ${r}) for ${$} on chain ${i}.`;let $e=[...E,...de,B],Re=await t.preview($e,c);be();let Fe=Re.changes.map(s=>{let u=s.amount.startsWith("-");return`${u?"-":""}${t.formatAmount(u?s.amount.slice(1):s.amount,s.token.decimals)} ${s.token.symbol} (${s.token.address}, chain ${s.token.chainId})`});return{txs:$e,preview:Re,requestId:P,orderId:V,depository:$,originChainId:i,destinationChainId:R,recipient:m,amountIn:{token:N,amount:d},amountOut:{token:O,amount:_},minAmountOut:C,relayerFee:we,refundCurrency:{token:z,amount:re,minimumAmounts:ae},orderDeadline:String(se),refundDeadlines:Z.map(String),expiresAt:String(U),status:"pending",statusEndpoint:he,summary:`${E.length?"Swap prerequisite first, then ":""}Relay inbound from chain ${i} to chain 4663 for ${m}; expected ${t.formatAmount(_,O.decimals)} ${O.symbol}, minimum ${t.formatAmount(C,O.decimals)} ${O.symbol} (${O.address}). Quoted relay fee ${t.formatAmount(we.amount,Q.decimals)} ${Q.symbol} (${Q.address}, chain ${i}); output is net of quoted fees. Order ${V} (request ${P}); output deadline ${se}, refund deadlines ${Z.join(", ")}, quote expires ${U}. Refund terms: details.refundCurrency quotes ${t.formatAmount(re,z.decimals)} ${z.symbol} (${re} base units) on chain ${z.chainId} (${z.address}), but protocol.v2 order refund floor is ${ae.join(", ")} base units. ${Fe.join("; ")}. Unsigned origin transactions only; destination fulfillment remains pending. Track with relay_status; timeout or refund is not fulfillment.`}}var ot=t=>({tools:[{name:"relay_bridge_in",inputSchema:{type:"object",additionalProperties:!1,required:["originChainId","amount"],properties:{originChainId:{type:"integer",minimum:1},destinationChainId:{const:R},originCurrency:H,destinationCurrency:H,amount:te(),minAmountOut:te(),slippageBps:{type:"integer",minimum:0,maximum:9999,default:pe},recipient:H,swap:{type:"object",additionalProperties:!1,required:["from","amountIn"],properties:{from:{type:"object",additionalProperties:!1,required:["address","chainId","symbol","decimals"],properties:{address:H,chainId:{type:"integer",minimum:1},symbol:{type:"string"},decimals:{type:"integer",minimum:0,maximum:255}}},amountIn:te(),slippageBps:{type:"integer",minimum:0,maximum:1e4}}}}},async execute(o,c){try{return await Ue(t,o,c)}catch(i){throw new e(t.plainError(i))}}}]});export{nt as a,ot as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as k,b as P,d as R,e as x,f as U,g as $}from"./
|
|
1
|
+
import{a as k,b as P,d as R,e as x,f as U,g as $}from"./IAXKPME3.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 +1 @@
|
|
|
1
|
-
import{b as xe,o as ae}from"./EAEQOS7Y.js";import{a as re}from"./XCFA73P2.js";import{b as Ie}from"./AXYOJBX6.js";import{a as ke}from"./UWOFA6GV.js";import{e as W,g as p,i as ye,n as be}from"./73N3TOJL.js";import{a as x,i as we}from"./XPFVT2EA.js";import{a as Te}from"./EG6M6SSO.js";import{a}from"./5YS5V2LK.js";import{decodeErrorResult as Oe,decodeEventLog as ie,encodeAbiParameters as D,encodeFunctionData as N,erc20Abi as Q,parseAbi as Ne,parseAbiParameters as M,toHex as Ae,zeroAddress as C}from"viem";var h=we[x].poolsTrade,J=h.liquidityLauncher.address,S=h.uerc20BeneficiaryVault.address,ce=h.universalRouter.address,ne=10n**27n,q=(1n<<128n)-1n,ve=`0x${"00".repeat(32)}`,H=63127652n,de=100000n,oe=10000000n,Le=2000n,ue={address:re,symbol:"ETH",decimals:18,chainId:x},m=Ne(["function multicall(bytes[] data) payable returns (bytes[])","function createToken(address factory,string name,string symbol,uint8 decimals,uint128 initialSupply,address recipient,bytes tokenData) payable returns (address)","function distributeToken(address token,(address strategy,uint128 amount,bytes configData) distribution,bytes32 salt) payable","function distributeWithNative(address strategy,bytes configData,bytes32 salt,uint256 nativeAmount) payable","function getGraffiti(address sender) view returns (bytes32)","function getUERC20Address(string name,string symbol,uint8 decimals,address recipient,bytes32 graffiti) view returns (address)","function execute(bytes commands,bytes[] inputs,uint256 deadline) payable","function collectFees(uint256[] ids)","function claim(uint256 id,uint256 minCurrency0Amount,uint256 minCurrency1Amount)","function amounts(uint256 id) view returns (uint128 eth,uint128 token)","function ownerOf(uint256 id) view returns (address)","function getApproved(uint256 id) view returns (address)","function approve(address spender,uint256 id)","function safeTransferFrom(address from,address to,uint256 id)","function approve(address token,address spender,uint160 amount,uint48 expiration)","error V4TooLittleReceived(uint256 minAmountOut,uint256 amountOut)"]),U=Ne(["event TokenLaunched(bytes32 indexed poolId,address indexed token,address indexed feeSplitter,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey)","event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"]),_=[h.instantLaunchStrategyFeesOn.address,h.instantLaunchStrategyFeesOff.address];function se(l){if(l.status!=="success")throw new a("The launch receipt did not succeed.");let c=[];for(let y of l.logs){let F=_.findIndex(O=>p(O,y.address));if(F===-1||y.topics[0]!=="0x3b3d2bafdcae274a232217e1f80ee4305d3af6aa25c8b14b1681bd68d18042a4")continue;let j=ie({abi:U,eventName:"TokenLaunched",data:y.data,topics:[...y.topics]}),{token:T,poolId:Y,poolKey:R,feeSplitter:Z}=j.args,ee=F===0?h.feeSplitterFeesOn.address:h.feeSplitterFeesOff.address;if(!p(Z,ee)||!p(R.currency0,C)||!p(R.currency1,T)||R.fee!==2500||R.tickSpacing!==25||!p(R.hooks,C))throw new a("The launch does not match the current native ETH strategy.");let P=l.logs.filter(O=>p(O.address,h.v4PositionManager.address)).flatMap(O=>{if(O.topics[0]!=="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")return[];let G=ie({abi:U,eventName:"Transfer",data:O.data,topics:[...O.topics]}).args;return p(G.from,C)&&p(G.to,_[F])?[G.tokenId]:[]});if(P.length!==1)throw new a("The launch receipt must identify one matching position mint.");c.push({token:T,poolId:Y,positionId:P[0].toString(),creatorFees:F===0})}return c}function B(l){return ye(l,"Provide a valid wallet or token address.")}function $(l,c,y=!1){return be(l,`${c} is outside its supported range.`,{notString:`${c} must be an integer string in base units.`,positive:!y})}function X(l,c,y=!1){if(y&&l===void 0)return"";if(typeof l!="string"||!y&&!l.trim()||l.length>4096)throw new a(`Provide a valid ${c}.`);return l}function le(l){if(typeof l!="string"||!/^0x[0-9a-fA-F]{64}$/.test(l))throw new a("Provide a valid launch transaction hash.");return l}function fe(l,c,y="minAmountOut"){let F=c.slippageBps??xe;if(typeof F!="number")throw new a("Slippage must be an integer in basis points.");let j=ae(l.toString(),F),T=c[y]===void 0?BigInt(j):$(c[y],y,l===0n);if(T>l||l>0n&&T===0n||T>q)throw new a("The minimum output must be positive and no larger than the simulated output.");return T}var Ee=l=>{let c=l.clientFor(x),y=(e,s,o,n)=>l.unsignedTx({to:e,data:s,value:o.toString(),chainId:x,description:n}),F=e=>{throw new a(l.plainError(e))};async function j(){if(await c.getChainId()!==x)throw new a("pools.trade requires Robinhood Chain 4663.")}async function T(e,s,o){let n=await l.preview(e,s),t=n.changes.map(({token:r,amount:d})=>{let i=d.startsWith("-");return`${i?"-":""}${l.formatAmount(i?d.slice(1):d,r.decimals)} ${r.symbol} (${r.address}, chain ${r.chainId})`});return{txs:e,summary:[o,n.summary,...t].join(" ")}}async function Y(){return(await c.getBlock()).timestamp+600n}function R(e,s,o,n,t,r){let d=[C,e,2500,25,C],i=[D(M("((address,address,uint24,int24,address),bool,uint128,uint128,uint256,bytes)"),[[d,s,o,n,0n,"0x"]]),D(M("address,uint256"),[s?C:e,o]),D(M("address,address,uint256"),[s?e:C,t,0n])],f=[D(M("bytes,bytes[]"),["0x060c0e",i])];return{inputs:f,encoded:D(M("bytes,bytes[],uint256"),["0x10",f,r])}}async function Z(e,s){let o=await c.request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:e.map(i=>({from:s,gas:Ae(Te),to:i.to,data:i.data,value:Ae(BigInt(i.value))}))}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(o)||o.length!==1||!W(o[0])||!Array.isArray(o[0].calls)||o[0].calls.length!==e.length)throw new a("The output simulation returned a malformed response.");let n=o[0].calls;if(!n.slice(0,-1).every(i=>W(i)&&i.status==="0x1"&&!i.error))throw new a("A prerequisite failed during the output simulation.");let t=n.at(-1);if(!W(t)||t.status!=="0x0")throw new a("The output simulation did not return the expected minimum-output control.");let r=typeof t.returnData=="string"&&t.returnData!=="0x"?t.returnData:W(t.error)?t.error.data:void 0;if(typeof r!="string"||!/^0x[0-9a-fA-F]+$/.test(r))throw new a("The output simulation did not report an expected amount.");let d=Oe({abi:m,data:r});if(d.errorName!=="V4TooLittleReceived"||d.args[0]!==q||d.args[1]<=0n||d.args[1]>=q)throw new a("The output simulation did not report a valid amount.");return d.args[1]}async function ee(e,s,o,n=()=>!0){let t=await c.getBlockNumber(),r=t<H?0n:(t-H)/oe+1n,d=1n,i=(u=1n)=>{if(d+=u,d>Le)throw new a("Pools.trade scan exceeds the 2000-request limit. Use launchTx for a specific launch; positions coverage is incomplete.")};i(r*BigInt(_.length+(e&&!o?1:0)));let f=new Map,w=new Set;for(let u=H;u<=t&&n();u+=oe){let b=u+oe-1n>t?t:u+oe-1n,v=(await Promise.all(_.map(k=>c.getLogs({address:k,event:U[0],...s?{args:{token:s}}:{},fromBlock:u,toBlock:b,strict:!0})))).flat(),L=[...new Set(v.map(k=>k.transactionHash))].filter(k=>!k||!f.has(k));for(let k=0;k<L.length&&n();k+=8)await Promise.all(L.slice(k,k+8).map(async E=>{if(!E)throw new a("A launch log is missing its transaction hash.");i();let V=await c.getTransactionReceipt({hash:E});f.set(E,V),n()&&await o?.(V)}));if(!n())break;if(e&&!o){let k=await c.getLogs({address:S,event:U[1],args:{to:e},fromBlock:u,toBlock:b,strict:!0});for(let E of k){let V=ie({abi:U,eventName:"Transfer",data:E.data,topics:E.topics}).args;w.add(V.tokenId.toString())}}}return{receipts:[...f.values()],feeIds:w}}async function P(e){let o=(e.launchTx!==void 0?[await c.getTransactionReceipt({hash:le(e.launchTx)})]:(await ee(void 0,e.token===void 0?void 0:B(e.token))).receipts).flatMap(se).filter(n=>e.positionId!==void 0?n.positionId===$(e.positionId,"positionId").toString():p(n.token,B(e.token)));if(o.length!==1)throw new a("No unique current-strategy launch was found. Older strategy generations are unsupported.");return o[0]}async function O(e,s){if(typeof e.creatorFees!="boolean")throw new a("creatorFees must be an explicit boolean; the choice is permanent.");if(e.pair!==void 0&&!p(B(e.pair),C)&&!p(B(e.pair),re))throw new a("Only the native ETH pair is supported.");if(e.decimals!==void 0&&e.decimals!==18)throw new a("Instant Launch requires 18 decimals.");if(e.supply!==void 0&&$(e.supply,"supply")!==ne)throw new a("Instant Launch requires a supply of one billion tokens.");let o=B(e.feeBeneficiary);if(p(o,C)||p(o,J))throw new a("The fee beneficiary must be a wallet other than the launcher or zero address.");let n=X(e.name,"name"),t=X(e.symbol,"symbol"),r=e.initialBuy===void 0?0n:$(e.initialBuy,"initialBuy",!0);if(r>q)throw new a("The initial buy exceeds uint128.");if(r===0n&&e.minAmountOut!==void 0)throw new a("A minimum output requires an initial buy.");let d=await c.readContract({address:J,abi:m,functionName:"getGraffiti",args:[s]}),i=B(await c.readContract({address:h.uerc20Factory.address,abi:m,functionName:"getUERC20Address",args:[n,t,18,J,d]})),f=await c.getCode({address:i});if(f&&f!=="0x")throw new a("This wallet already launched that name and symbol.");let w=D(M("(string,string,string,bytes)"),[[X(e.description,"description",!0),X(e.website,"website",!0),X(e.imageUri,"image URI",!0),"0x"]]),u=e.creatorFees?_[0]:_[1],b=[N({abi:m,functionName:"createToken",args:[h.uerc20Factory.address,n,t,18,ne,J,w]}),N({abi:m,functionName:"distributeToken",args:[i,{strategy:u,amount:ne,configData:D(M("address"),[o])},ve]})],v=await Y(),z=k=>{let E=[...b];if(r>0n){let V=D(M("(address,address,bytes)"),[[ce,s,R(i,!0,r,k,s,v).encoded]]);E.push(N({abi:m,functionName:"distributeWithNative",args:[h.universalRouterStrategyApp.address,V,ve,r]}))}return y(J,N({abi:m,functionName:"multicall",args:[E]}),r,`Atomic Instant Launch: creator fees ${e.creatorFees?"on":"off"} (permanent); beneficiary ${o}.`)},L=r>0n?fe(await Z([z(q)],s),e):0n;return T([z(L)],s,`Launch ${n} (${i}, chain 4663), supply 1000000000, decimals 18. Creator fees ${e.creatorFees?"on":"off"} are permanent; fee beneficiary ${o}. Creator ETH fees come from buys only (recorded 0.09996%); sells compound into locked liquidity. Initial-buy minimum ${L} token base units. Off-chain image/display unproven; no private metadata registration. No transaction sent.`)}async function G(e,s,o){let n=$(e.amountIn,"amountIn");if(n>q)throw new a("The trade amount exceeds uint128.");let t=B(e.token);await P(e);let r=await Y(),d=[];o||(await c.readContract({address:t,abi:Q,functionName:"allowance",args:[s,h.permit2.address]})<n&&d.push(l.approval(t,h.permit2.address,n.toString(),x)),d.push(y(h.permit2.address,N({abi:m,functionName:"approve",args:[t,ce,n,Number(r)]}),0n,`Permit the exact ${n} token base units until ${r}.`)));let i=u=>[...d,y(ce,N({abi:m,functionName:"execute",args:["0x10",R(t,o,n,u,s,r).inputs,r]}),o?n:0n,`${o?"Buy":"Sell"} ${t} with minimum output ${u}.`)],f=await Z(i(q),s),w=fe(f,e);return T(i(w),s,`${o?"Buy":"Sell"} token ${t} (chain 4663, 18 decimals), amountIn ${n}, minimum output ${w} ${o?"token":"ETH"} base units (18 decimals). Recorded swap fee 0.2899%; creator ETH fees from buys only, none from sells. No transaction sent.`)}async function pe(e,s,o){let n=await P(e),t=BigInt(n.positionId),r=n.creatorFees?h.feeSplitterFeesOn.address:h.feeSplitterFeesOff.address,d=await c.readContract({address:h.v4PositionManager.address,abi:m,functionName:"ownerOf",args:[t]});if(!p(d,r))throw new a("The position is not locked in its current-strategy splitter.");if(!o)return T([y(r,N({abi:m,functionName:"collectFees",args:[[t]]}),0n,`Collect fees for position ${t}; permissionless.`)],s,"Collect fees for the entitled recipients; collection does not transfer creator fees to the collector. No transaction sent.");if(!n.creatorFees)throw new a("Creator fees are permanently disabled for this position.");let i=await c.readContract({address:S,abi:m,functionName:"ownerOf",args:[t]});if(!p(i,s))throw new a("Only the current fee NFT holder is entitled to claim.");let f=await c.readContract({address:S,abi:m,functionName:"amounts",args:[t]}),w=fe(f[0],e,"minEth");if(f[1]!==0n)throw new a("The current buy-only creator fee configuration returned unexpected token fees.");return T([y(S,N({abi:m,functionName:"claim",args:[t,w,0n]}),0n,`Claim collected ETH fees for position ${t} to ${s}.`)],s,`Claim collected fees: ${f[0]} ETH base units (18 decimals), minimum ${w}. Uncollected fees require poolstrade_collect first. No transaction sent.`)}async function Se(e,s){let o=await P(e),n=B(e.to);if(p(n,C))throw new a("The token recipient cannot be the zero address.");let t=$(e.amount,"amount"),r=await te(o.token,await c.getBlockNumber());return T([y(r.address,N({abi:Q,functionName:"transfer",args:[n,t]}),0n,`Transfer exactly ${t} ${r.symbol} base units to ${n}.`)],s,`Transfer ${t} token base units (token ${r.address}, decimals ${r.decimals}, chain ${r.chainId}) to ${n}. No approval; no transaction sent.`)}async function Be(e,s){if(!Array.isArray(e.positionIds)||e.positionIds.length<1||e.positionIds.length>20||!Array.isArray(e.launchTxs)||e.launchTxs.length!==e.positionIds.length)throw new a("Provide 1 to 20 positionIds and one matching launchTxs entry for each.");let o=e.positionIds.map(d=>$(d,"positionId").toString());if(new Set(o).size!==o.length)throw new a("Each position ID must appear once.");let n=e.launchTxs.map(le),t=new Map;for(let[d,i]of o.entries()){let w=(await P({positionId:i,launchTx:n[d]})).creatorFees?h.feeSplitterFeesOn.address:h.feeSplitterFeesOff.address,u=BigInt(i),b=await c.readContract({address:h.v4PositionManager.address,abi:m,functionName:"ownerOf",args:[u]});if(!p(b,w))throw new a("The position is not locked in its current-strategy splitter.");t.set(w,[...t.get(w)??[],u])}let r=[...t].map(([d,i])=>y(d,N({abi:m,functionName:"collectFees",args:[i]}),0n,`Collect fees for positions ${i.join(", ")}; permissionless.`));return T(r,s,"Collect fees in batches for the fixed entitled recipients. Collection does not pay the collector. No transaction sent.")}let K="Current native ETH Instant Launch strategies only. Crowd Launch and older deployments are not covered.";async function te(e,s){let[o,n]=await Promise.all([c.readContract({address:e,abi:Q,functionName:"symbol",blockNumber:s}),c.readContract({address:e,abi:Q,functionName:"decimals",blockNumber:s})]);if(typeof o!="string"||!o||o.length>256||n!==18)throw new a("The current launch token returned invalid metadata.");return{address:e,symbol:o,decimals:n,chainId:x}}async function me(e,s,o,n){let t=n??await te(e.token,o),r=await c.readContract({address:t.address,abi:Q,functionName:"balanceOf",args:[s],blockNumber:o});return{token:t,amount:r.toString(),humanAmount:l.formatAmount(r.toString(),t.decimals)}}async function Ce(e,s){let o=await P(e),n=await c.getBlockNumber();return{wallet:s,...await me(o,s,n),blockNumber:n.toString(),coverage:K}}async function $e(e,s){let o=le(e.launchTx),n=await c.getTransactionReceipt({hash:o}),t=se(n);if(e.token!==void 0&&(t=t.filter(i=>p(i.token,B(e.token)))),e.positionId!==void 0&&(t=t.filter(i=>i.positionId===$(e.positionId,"positionId").toString())),!t.length)throw new a("The receipt contains no matching current Instant Launch. Crowd Launch and older strategies are not covered.");let r=await c.getBlockNumber(),d=await Promise.all(t.map(async i=>{let f=i.creatorFees?h.feeSplitterFeesOn.address:h.feeSplitterFeesOff.address,w=await c.readContract({address:h.v4PositionManager.address,abi:m,functionName:"ownerOf",args:[BigInt(i.positionId)],blockNumber:r});if(!p(w,f))throw new a("The position is not locked in its current-strategy splitter.");let u=i.creatorFees?{owner:await c.readContract({address:S,abi:m,functionName:"ownerOf",args:[BigInt(i.positionId)],blockNumber:r}),approved:await c.readContract({address:S,abi:m,functionName:"getApproved",args:[BigInt(i.positionId)],blockNumber:r}),collected:await c.readContract({address:S,abi:m,functionName:"amounts",args:[BigInt(i.positionId)],blockNumber:r})}:void 0,b=await te(i.token,r);return{...i,token:b,custodian:w,holding:await me(i,s,r,b),...u?{feeEntitlement:{owner:u.owner,approved:u.approved,collected:[{token:ue,amount:u.collected[0].toString()},{token:b,amount:u.collected[1].toString()}],uncollectedFeesIncluded:!1}}:{}}}));return{launchTx:o,wallet:s,creator:n.from,blockNumber:r.toString(),launches:d,coverage:K}}async function Fe(e){let s=await c.getBlockNumber(),o=e.limit??20;if(typeof o!="number"||!Number.isInteger(o)||o<1||o>50)throw new a("limit must be an integer from 1 to 50.");let n=e.fromBlock===void 0?s>=H+de?s-de+1n:H:$(e.fromBlock,"fromBlock",!0),t=e.toBlock===void 0?s:$(e.toBlock,"toBlock",!0),r=0;if(e.cursor!==void 0){if(typeof e.cursor!="string"||!/^[0-9]{1,78}:[0-9]{1,78}:[0-9]{1,10}$/.test(e.cursor))throw new a("Provide the browse cursor exactly as returned.");let u=e.cursor.split(":"),b=BigInt(u[0]),v=BigInt(u[1]);if(e.fromBlock!==void 0&&n!==b||e.toBlock!==void 0&&t!==v)throw new a("The cursor does not match this block range.");n=b,t=v,r=Number(u[2])}if(s<H&&e.fromBlock===void 0&&e.toBlock===void 0&&e.cursor===void 0)return{launches:[],cursor:null,fromBlock:H.toString(),toBlock:s.toString(),coverage:K,predeployment:!0};if(n<H||t<n||t>s||t-n>=de)throw new a("Choose a deployed block range of at most 100000 blocks, ending no later than the current head.");let d=await c.getLogs({address:_,event:U[0],fromBlock:n,toBlock:t,strict:!0});if(d.some(u=>u.blockNumber===null||u.logIndex===null||!u.transactionHash))throw new a("The launch feed returned an incomplete log.");if(d.sort((u,b)=>u.blockNumber===b.blockNumber?b.logIndex-u.logIndex:u.blockNumber>b.blockNumber?-1:1),r>d.length)throw new a("The browse cursor is outside the launch feed.");let i=new Map,f=[];for(let u of d.slice(r,r+o)){let b=u.transactionHash,v=i.get(b);v||(v=await c.getTransactionReceipt({hash:b}),i.set(b,v));let z=ie({abi:U,eventName:"TokenLaunched",data:u.data,topics:u.topics}).args,L=se(v).filter(k=>p(k.token,z.token)&&p(k.poolId,z.poolId));if(L.length!==1)throw new a("The launch feed log does not match one verified receipt launch.");f.push({...L[0],launchTx:b,blockNumber:u.blockNumber.toString(),token:await te(L[0].token,t),creator:v.from})}let w=r+o;return{launches:f,cursor:w<d.length?`${n}:${t}:${w}`:null,fromBlock:n.toString(),toBlock:t.toString(),coverage:K,previousToBlock:n>H?(n-1n).toString():null,summary:"Newest launches first within this fixed block range. Empty does not establish absence outside the range or covered strategies."}}async function he(e,s,o){let n=await P(e);if(!n.creatorFees)throw new a("Creator fees are permanently disabled for this position.");let t=BigInt(n.positionId),r=await c.readContract({address:h.v4PositionManager.address,abi:m,functionName:"ownerOf",args:[t]});if(!p(r,h.feeSplitterFeesOn.address))throw new a("The position is not locked in its current-strategy splitter.");let d=await c.readContract({address:S,abi:m,functionName:"ownerOf",args:[t]});if(!p(d,s))throw new a("Only the current fee NFT holder can change this entitlement.");let i=B(o?e.to:e.spender);if(p(i,S)||o&&p(i,C))throw new a("The fee NFT recipient cannot be the vault or zero address.");let f=o?N({abi:m,functionName:"safeTransferFrom",args:[s,i,t]}):N({abi:m,functionName:"approve",args:[i,t]});return T([y(S,f,0n,o?`Transfer fee NFT ${t} to ${i}, including accrued and future fees.`:`Approve ${i} for fee NFT ${t} only; zero address revokes approval.`)],s,o?`Transfer the entire fee entitlement for position ${t} to ${i}. This includes collected and future fees; locked LP remains in its splitter. No transaction sent.`:`Set the exact single-NFT approval for position ${t} to ${i}. This permits transfer of that fee entitlement; zero address revokes. No transaction sent.`)}async function Pe(){return{chainId:x,instant:{supported:!0,supply:ne.toString(),decimals:18,currency:ue,permanentCreatorFeeChoice:!0},crowd:{status:"BLOCKED",strategy:"0xbf1aB81f7d534b2CC0Da76fcf4d541322bB0e000",factory:"0x000000001F26a0044BaA66024e7b6599c61963F8",missing:"A verified Pools-specific auction configuration (BlockNumberish timing, reserve allocation, Q96 floor/tick, USD FDV conversion, issuance steps, locked LP plan) and a bytecode-matched factory-created auction ABI with success/refund fixtures. Generic CCA parameters are not a verified Pools Crowd Launch.",source:"https://github.com/Uniswap/sdks/blob/main/sdks/liquidity-launcher-sdk/src/addresses.ts"},coverage:K}}let g={type:"string"},I=ke(),ge={chainId:{type:"integer",const:x},slippageBps:{type:"integer",minimum:0,maximum:9999}};function A(e,s,o,n){return{name:`poolstrade_${e}`,inputSchema:{type:"object",additionalProperties:!1,properties:{...ge,...s},required:o},execute:async(t,r)=>{try{let d=new Set([...Object.keys(ge),...Object.keys(s)]);if(Object.keys(t).some(i=>!d.has(i)))throw new a("Unsupported input for this pools.trade tool.");if(t.chainId!==void 0&&t.chainId!==x)throw new a("pools.trade requires chain 4663.");if(B(r),t.slippageBps!==void 0){if(typeof t.slippageBps!="number")throw new a("Slippage must be an integer in basis points.");ae("10000",t.slippageBps)}return await j(),await n(t,r)}catch(d){F(d)}}}}return{tools:[A("launch",{name:g,symbol:g,creatorFees:{type:"boolean",description:"Permanent choice; must be explicit."},feeBeneficiary:g,pair:g,decimals:{type:"integer",const:18},supply:I,initialBuy:I,minAmountOut:I,description:g,website:g,imageUri:g},["name","symbol","creatorFees","feeBeneficiary"],O),...["buy","sell"].map(e=>A(e,{token:g,amountIn:I,minAmountOut:I,launchTx:g},["token","amountIn"],(s,o)=>G(s,o,e==="buy"))),A("collect",{positionId:I,launchTx:g},["positionId"],(e,s)=>pe(e,s,!1)),A("claim",{positionId:I,launchTx:g,minEth:I},["positionId"],(e,s)=>pe(e,s,!0)),A("browse",{fromBlock:I,toBlock:I,limit:{type:"integer",minimum:1,maximum:50},cursor:g},[],Fe),A("balance",{token:g,launchTx:g},["token"],Ce),A("status",{launchTx:g,token:g,positionId:I},["launchTx"],$e),A("launch_options",{},[],Pe),A("fee_transfer",{positionId:I,launchTx:g,to:g},["positionId","to"],(e,s)=>he(e,s,!0)),A("fee_approve",{positionId:I,launchTx:g,spender:g},["positionId","spender"],(e,s)=>he(e,s,!1)),A("transfer",{token:g,amount:I,to:g,launchTx:g},["token","amount","to"],Se),A("collect_many",{positionIds:{type:"array",items:I,minItems:1,maxItems:20},launchTxs:{type:"array",items:g,minItems:1,maxItems:20}},["positionIds","launchTxs"],Be)],positions:async e=>{B(e);let s=[],o=0,n=!0,t,r=i=>({module:"poolstrade",id:"poolstrade-discovery-incomplete",chainId:x,assets:[],incomplete:!0,description:`${i} Checked ${o} launch receipts. Readable holdings are retained. Check a known launch with poolstrade_status {"launchTx":"<hash>"} or its token holding with poolstrade_balance {"token":"<address>","launchTx":"<hash>"}. Crowd Launch and older deployments are outside this reader's coverage.`}),d=async()=>{await j(),n&&await ee(e,void 0,async i=>{o++;for(let f of se(i)){if(!n)return;let w=f.creatorFees&&p(await c.readContract({address:S,abi:m,functionName:"ownerOf",args:[BigInt(f.positionId)]}),e);if(!n)return;if(!w&&!p(i.from,e))continue;let u=w?[{token:ue,amount:(await c.readContract({address:S,abi:m,functionName:"amounts",args:[BigInt(f.positionId)]}))[0].toString()}]:[];n&&s.push({module:"poolstrade",id:f.positionId,chainId:x,assets:u,description:`Current Instant Launch ${f.token} (18 decimals, supply 1000000000), pool ${f.poolId}; creator fees ${f.creatorFees?"on":"off"} (permanent). ${w?"Collected ETH fees only; uncollected fees excluded.":"Launch record; no fee entitlement held."} Liquidity is permanently locked.`})}},()=>n)};try{return await Promise.race([d().then(()=>!0),new Promise(f=>{t=setTimeout(()=>{n=!1,f(!1)},6e3)})])?s:[...s,r("Pools.trade global launch discovery reached its 6000 ms read budget; the historical scan is incomplete.")]}catch(i){return[...s,r(`Pools.trade discovery could not finish: ${l.plainError(i)}`)]}finally{n=!1,t!==void 0&&clearTimeout(t)}}}};function Ve(l){return Ie("poolstrade",[Ee(l)])}export{se as a,Ee as b,Ve as c};
|
|
1
|
+
import{b as xe,o as ae}from"./CAU44UWP.js";import{a as re}from"./VJ3W2V3B.js";import{b as Ie}from"./AXYOJBX6.js";import{a as Te}from"./EG6M6SSO.js";import{a as ke}from"./UWOFA6GV.js";import{e as W,g as p,i as ye,n as be}from"./73N3TOJL.js";import{a as x,i as we}from"./XPFVT2EA.js";import{a}from"./5YS5V2LK.js";import{decodeErrorResult as Oe,decodeEventLog as ie,encodeAbiParameters as D,encodeFunctionData as N,erc20Abi as Q,parseAbi as Ne,parseAbiParameters as M,toHex as Ae,zeroAddress as C}from"viem";var h=we[x].poolsTrade,J=h.liquidityLauncher.address,S=h.uerc20BeneficiaryVault.address,ce=h.universalRouter.address,ne=10n**27n,q=(1n<<128n)-1n,ve=`0x${"00".repeat(32)}`,H=63127652n,de=100000n,oe=10000000n,Le=2000n,ue={address:re,symbol:"ETH",decimals:18,chainId:x},m=Ne(["function multicall(bytes[] data) payable returns (bytes[])","function createToken(address factory,string name,string symbol,uint8 decimals,uint128 initialSupply,address recipient,bytes tokenData) payable returns (address)","function distributeToken(address token,(address strategy,uint128 amount,bytes configData) distribution,bytes32 salt) payable","function distributeWithNative(address strategy,bytes configData,bytes32 salt,uint256 nativeAmount) payable","function getGraffiti(address sender) view returns (bytes32)","function getUERC20Address(string name,string symbol,uint8 decimals,address recipient,bytes32 graffiti) view returns (address)","function execute(bytes commands,bytes[] inputs,uint256 deadline) payable","function collectFees(uint256[] ids)","function claim(uint256 id,uint256 minCurrency0Amount,uint256 minCurrency1Amount)","function amounts(uint256 id) view returns (uint128 eth,uint128 token)","function ownerOf(uint256 id) view returns (address)","function getApproved(uint256 id) view returns (address)","function approve(address spender,uint256 id)","function safeTransferFrom(address from,address to,uint256 id)","function approve(address token,address spender,uint160 amount,uint48 expiration)","error V4TooLittleReceived(uint256 minAmountOut,uint256 amountOut)"]),U=Ne(["event TokenLaunched(bytes32 indexed poolId,address indexed token,address indexed feeSplitter,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey)","event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"]),_=[h.instantLaunchStrategyFeesOn.address,h.instantLaunchStrategyFeesOff.address];function se(l){if(l.status!=="success")throw new a("The launch receipt did not succeed.");let c=[];for(let y of l.logs){let F=_.findIndex(O=>p(O,y.address));if(F===-1||y.topics[0]!=="0x3b3d2bafdcae274a232217e1f80ee4305d3af6aa25c8b14b1681bd68d18042a4")continue;let j=ie({abi:U,eventName:"TokenLaunched",data:y.data,topics:[...y.topics]}),{token:T,poolId:Y,poolKey:R,feeSplitter:Z}=j.args,ee=F===0?h.feeSplitterFeesOn.address:h.feeSplitterFeesOff.address;if(!p(Z,ee)||!p(R.currency0,C)||!p(R.currency1,T)||R.fee!==2500||R.tickSpacing!==25||!p(R.hooks,C))throw new a("The launch does not match the current native ETH strategy.");let P=l.logs.filter(O=>p(O.address,h.v4PositionManager.address)).flatMap(O=>{if(O.topics[0]!=="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")return[];let G=ie({abi:U,eventName:"Transfer",data:O.data,topics:[...O.topics]}).args;return p(G.from,C)&&p(G.to,_[F])?[G.tokenId]:[]});if(P.length!==1)throw new a("The launch receipt must identify one matching position mint.");c.push({token:T,poolId:Y,positionId:P[0].toString(),creatorFees:F===0})}return c}function B(l){return ye(l,"Provide a valid wallet or token address.")}function $(l,c,y=!1){return be(l,`${c} is outside its supported range.`,{notString:`${c} must be an integer string in base units.`,positive:!y})}function X(l,c,y=!1){if(y&&l===void 0)return"";if(typeof l!="string"||!y&&!l.trim()||l.length>4096)throw new a(`Provide a valid ${c}.`);return l}function le(l){if(typeof l!="string"||!/^0x[0-9a-fA-F]{64}$/.test(l))throw new a("Provide a valid launch transaction hash.");return l}function fe(l,c,y="minAmountOut"){let F=c.slippageBps??xe;if(typeof F!="number")throw new a("Slippage must be an integer in basis points.");let j=ae(l.toString(),F),T=c[y]===void 0?BigInt(j):$(c[y],y,l===0n);if(T>l||l>0n&&T===0n||T>q)throw new a("The minimum output must be positive and no larger than the simulated output.");return T}var Ee=l=>{let c=l.clientFor(x),y=(e,s,o,n)=>l.unsignedTx({to:e,data:s,value:o.toString(),chainId:x,description:n}),F=e=>{throw new a(l.plainError(e))};async function j(){if(await c.getChainId()!==x)throw new a("pools.trade requires Robinhood Chain 4663.")}async function T(e,s,o){let n=await l.preview(e,s),t=n.changes.map(({token:r,amount:d})=>{let i=d.startsWith("-");return`${i?"-":""}${l.formatAmount(i?d.slice(1):d,r.decimals)} ${r.symbol} (${r.address}, chain ${r.chainId})`});return{txs:e,summary:[o,n.summary,...t].join(" ")}}async function Y(){return(await c.getBlock()).timestamp+600n}function R(e,s,o,n,t,r){let d=[C,e,2500,25,C],i=[D(M("((address,address,uint24,int24,address),bool,uint128,uint128,uint256,bytes)"),[[d,s,o,n,0n,"0x"]]),D(M("address,uint256"),[s?C:e,o]),D(M("address,address,uint256"),[s?e:C,t,0n])],f=[D(M("bytes,bytes[]"),["0x060c0e",i])];return{inputs:f,encoded:D(M("bytes,bytes[],uint256"),["0x10",f,r])}}async function Z(e,s){let o=await c.request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:e.map(i=>({from:s,gas:Ae(Te),to:i.to,data:i.data,value:Ae(BigInt(i.value))}))}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(o)||o.length!==1||!W(o[0])||!Array.isArray(o[0].calls)||o[0].calls.length!==e.length)throw new a("The output simulation returned a malformed response.");let n=o[0].calls;if(!n.slice(0,-1).every(i=>W(i)&&i.status==="0x1"&&!i.error))throw new a("A prerequisite failed during the output simulation.");let t=n.at(-1);if(!W(t)||t.status!=="0x0")throw new a("The output simulation did not return the expected minimum-output control.");let r=typeof t.returnData=="string"&&t.returnData!=="0x"?t.returnData:W(t.error)?t.error.data:void 0;if(typeof r!="string"||!/^0x[0-9a-fA-F]+$/.test(r))throw new a("The output simulation did not report an expected amount.");let d=Oe({abi:m,data:r});if(d.errorName!=="V4TooLittleReceived"||d.args[0]!==q||d.args[1]<=0n||d.args[1]>=q)throw new a("The output simulation did not report a valid amount.");return d.args[1]}async function ee(e,s,o,n=()=>!0){let t=await c.getBlockNumber(),r=t<H?0n:(t-H)/oe+1n,d=1n,i=(u=1n)=>{if(d+=u,d>Le)throw new a("Pools.trade scan exceeds the 2000-request limit. Use launchTx for a specific launch; positions coverage is incomplete.")};i(r*BigInt(_.length+(e&&!o?1:0)));let f=new Map,w=new Set;for(let u=H;u<=t&&n();u+=oe){let b=u+oe-1n>t?t:u+oe-1n,v=(await Promise.all(_.map(k=>c.getLogs({address:k,event:U[0],...s?{args:{token:s}}:{},fromBlock:u,toBlock:b,strict:!0})))).flat(),L=[...new Set(v.map(k=>k.transactionHash))].filter(k=>!k||!f.has(k));for(let k=0;k<L.length&&n();k+=8)await Promise.all(L.slice(k,k+8).map(async E=>{if(!E)throw new a("A launch log is missing its transaction hash.");i();let V=await c.getTransactionReceipt({hash:E});f.set(E,V),n()&&await o?.(V)}));if(!n())break;if(e&&!o){let k=await c.getLogs({address:S,event:U[1],args:{to:e},fromBlock:u,toBlock:b,strict:!0});for(let E of k){let V=ie({abi:U,eventName:"Transfer",data:E.data,topics:E.topics}).args;w.add(V.tokenId.toString())}}}return{receipts:[...f.values()],feeIds:w}}async function P(e){let o=(e.launchTx!==void 0?[await c.getTransactionReceipt({hash:le(e.launchTx)})]:(await ee(void 0,e.token===void 0?void 0:B(e.token))).receipts).flatMap(se).filter(n=>e.positionId!==void 0?n.positionId===$(e.positionId,"positionId").toString():p(n.token,B(e.token)));if(o.length!==1)throw new a("No unique current-strategy launch was found. Older strategy generations are unsupported.");return o[0]}async function O(e,s){if(typeof e.creatorFees!="boolean")throw new a("creatorFees must be an explicit boolean; the choice is permanent.");if(e.pair!==void 0&&!p(B(e.pair),C)&&!p(B(e.pair),re))throw new a("Only the native ETH pair is supported.");if(e.decimals!==void 0&&e.decimals!==18)throw new a("Instant Launch requires 18 decimals.");if(e.supply!==void 0&&$(e.supply,"supply")!==ne)throw new a("Instant Launch requires a supply of one billion tokens.");let o=B(e.feeBeneficiary);if(p(o,C)||p(o,J))throw new a("The fee beneficiary must be a wallet other than the launcher or zero address.");let n=X(e.name,"name"),t=X(e.symbol,"symbol"),r=e.initialBuy===void 0?0n:$(e.initialBuy,"initialBuy",!0);if(r>q)throw new a("The initial buy exceeds uint128.");if(r===0n&&e.minAmountOut!==void 0)throw new a("A minimum output requires an initial buy.");let d=await c.readContract({address:J,abi:m,functionName:"getGraffiti",args:[s]}),i=B(await c.readContract({address:h.uerc20Factory.address,abi:m,functionName:"getUERC20Address",args:[n,t,18,J,d]})),f=await c.getCode({address:i});if(f&&f!=="0x")throw new a("This wallet already launched that name and symbol.");let w=D(M("(string,string,string,bytes)"),[[X(e.description,"description",!0),X(e.website,"website",!0),X(e.imageUri,"image URI",!0),"0x"]]),u=e.creatorFees?_[0]:_[1],b=[N({abi:m,functionName:"createToken",args:[h.uerc20Factory.address,n,t,18,ne,J,w]}),N({abi:m,functionName:"distributeToken",args:[i,{strategy:u,amount:ne,configData:D(M("address"),[o])},ve]})],v=await Y(),z=k=>{let E=[...b];if(r>0n){let V=D(M("(address,address,bytes)"),[[ce,s,R(i,!0,r,k,s,v).encoded]]);E.push(N({abi:m,functionName:"distributeWithNative",args:[h.universalRouterStrategyApp.address,V,ve,r]}))}return y(J,N({abi:m,functionName:"multicall",args:[E]}),r,`Atomic Instant Launch: creator fees ${e.creatorFees?"on":"off"} (permanent); beneficiary ${o}.`)},L=r>0n?fe(await Z([z(q)],s),e):0n;return T([z(L)],s,`Launch ${n} (${i}, chain 4663), supply 1000000000, decimals 18. Creator fees ${e.creatorFees?"on":"off"} are permanent; fee beneficiary ${o}. Creator ETH fees come from buys only (recorded 0.09996%); sells compound into locked liquidity. Initial-buy minimum ${L} token base units. Off-chain image/display unproven; no private metadata registration. No transaction sent.`)}async function G(e,s,o){let n=$(e.amountIn,"amountIn");if(n>q)throw new a("The trade amount exceeds uint128.");let t=B(e.token);await P(e);let r=await Y(),d=[];o||(await c.readContract({address:t,abi:Q,functionName:"allowance",args:[s,h.permit2.address]})<n&&d.push(l.approval(t,h.permit2.address,n.toString(),x)),d.push(y(h.permit2.address,N({abi:m,functionName:"approve",args:[t,ce,n,Number(r)]}),0n,`Permit the exact ${n} token base units until ${r}.`)));let i=u=>[...d,y(ce,N({abi:m,functionName:"execute",args:["0x10",R(t,o,n,u,s,r).inputs,r]}),o?n:0n,`${o?"Buy":"Sell"} ${t} with minimum output ${u}.`)],f=await Z(i(q),s),w=fe(f,e);return T(i(w),s,`${o?"Buy":"Sell"} token ${t} (chain 4663, 18 decimals), amountIn ${n}, minimum output ${w} ${o?"token":"ETH"} base units (18 decimals). Recorded swap fee 0.2899%; creator ETH fees from buys only, none from sells. No transaction sent.`)}async function pe(e,s,o){let n=await P(e),t=BigInt(n.positionId),r=n.creatorFees?h.feeSplitterFeesOn.address:h.feeSplitterFeesOff.address,d=await c.readContract({address:h.v4PositionManager.address,abi:m,functionName:"ownerOf",args:[t]});if(!p(d,r))throw new a("The position is not locked in its current-strategy splitter.");if(!o)return T([y(r,N({abi:m,functionName:"collectFees",args:[[t]]}),0n,`Collect fees for position ${t}; permissionless.`)],s,"Collect fees for the entitled recipients; collection does not transfer creator fees to the collector. No transaction sent.");if(!n.creatorFees)throw new a("Creator fees are permanently disabled for this position.");let i=await c.readContract({address:S,abi:m,functionName:"ownerOf",args:[t]});if(!p(i,s))throw new a("Only the current fee NFT holder is entitled to claim.");let f=await c.readContract({address:S,abi:m,functionName:"amounts",args:[t]}),w=fe(f[0],e,"minEth");if(f[1]!==0n)throw new a("The current buy-only creator fee configuration returned unexpected token fees.");return T([y(S,N({abi:m,functionName:"claim",args:[t,w,0n]}),0n,`Claim collected ETH fees for position ${t} to ${s}.`)],s,`Claim collected fees: ${f[0]} ETH base units (18 decimals), minimum ${w}. Uncollected fees require poolstrade_collect first. No transaction sent.`)}async function Se(e,s){let o=await P(e),n=B(e.to);if(p(n,C))throw new a("The token recipient cannot be the zero address.");let t=$(e.amount,"amount"),r=await te(o.token,await c.getBlockNumber());return T([y(r.address,N({abi:Q,functionName:"transfer",args:[n,t]}),0n,`Transfer exactly ${t} ${r.symbol} base units to ${n}.`)],s,`Transfer ${t} token base units (token ${r.address}, decimals ${r.decimals}, chain ${r.chainId}) to ${n}. No approval; no transaction sent.`)}async function Be(e,s){if(!Array.isArray(e.positionIds)||e.positionIds.length<1||e.positionIds.length>20||!Array.isArray(e.launchTxs)||e.launchTxs.length!==e.positionIds.length)throw new a("Provide 1 to 20 positionIds and one matching launchTxs entry for each.");let o=e.positionIds.map(d=>$(d,"positionId").toString());if(new Set(o).size!==o.length)throw new a("Each position ID must appear once.");let n=e.launchTxs.map(le),t=new Map;for(let[d,i]of o.entries()){let w=(await P({positionId:i,launchTx:n[d]})).creatorFees?h.feeSplitterFeesOn.address:h.feeSplitterFeesOff.address,u=BigInt(i),b=await c.readContract({address:h.v4PositionManager.address,abi:m,functionName:"ownerOf",args:[u]});if(!p(b,w))throw new a("The position is not locked in its current-strategy splitter.");t.set(w,[...t.get(w)??[],u])}let r=[...t].map(([d,i])=>y(d,N({abi:m,functionName:"collectFees",args:[i]}),0n,`Collect fees for positions ${i.join(", ")}; permissionless.`));return T(r,s,"Collect fees in batches for the fixed entitled recipients. Collection does not pay the collector. No transaction sent.")}let K="Current native ETH Instant Launch strategies only. Crowd Launch and older deployments are not covered.";async function te(e,s){let[o,n]=await Promise.all([c.readContract({address:e,abi:Q,functionName:"symbol",blockNumber:s}),c.readContract({address:e,abi:Q,functionName:"decimals",blockNumber:s})]);if(typeof o!="string"||!o||o.length>256||n!==18)throw new a("The current launch token returned invalid metadata.");return{address:e,symbol:o,decimals:n,chainId:x}}async function me(e,s,o,n){let t=n??await te(e.token,o),r=await c.readContract({address:t.address,abi:Q,functionName:"balanceOf",args:[s],blockNumber:o});return{token:t,amount:r.toString(),humanAmount:l.formatAmount(r.toString(),t.decimals)}}async function Ce(e,s){let o=await P(e),n=await c.getBlockNumber();return{wallet:s,...await me(o,s,n),blockNumber:n.toString(),coverage:K}}async function $e(e,s){let o=le(e.launchTx),n=await c.getTransactionReceipt({hash:o}),t=se(n);if(e.token!==void 0&&(t=t.filter(i=>p(i.token,B(e.token)))),e.positionId!==void 0&&(t=t.filter(i=>i.positionId===$(e.positionId,"positionId").toString())),!t.length)throw new a("The receipt contains no matching current Instant Launch. Crowd Launch and older strategies are not covered.");let r=await c.getBlockNumber(),d=await Promise.all(t.map(async i=>{let f=i.creatorFees?h.feeSplitterFeesOn.address:h.feeSplitterFeesOff.address,w=await c.readContract({address:h.v4PositionManager.address,abi:m,functionName:"ownerOf",args:[BigInt(i.positionId)],blockNumber:r});if(!p(w,f))throw new a("The position is not locked in its current-strategy splitter.");let u=i.creatorFees?{owner:await c.readContract({address:S,abi:m,functionName:"ownerOf",args:[BigInt(i.positionId)],blockNumber:r}),approved:await c.readContract({address:S,abi:m,functionName:"getApproved",args:[BigInt(i.positionId)],blockNumber:r}),collected:await c.readContract({address:S,abi:m,functionName:"amounts",args:[BigInt(i.positionId)],blockNumber:r})}:void 0,b=await te(i.token,r);return{...i,token:b,custodian:w,holding:await me(i,s,r,b),...u?{feeEntitlement:{owner:u.owner,approved:u.approved,collected:[{token:ue,amount:u.collected[0].toString()},{token:b,amount:u.collected[1].toString()}],uncollectedFeesIncluded:!1}}:{}}}));return{launchTx:o,wallet:s,creator:n.from,blockNumber:r.toString(),launches:d,coverage:K}}async function Fe(e){let s=await c.getBlockNumber(),o=e.limit??20;if(typeof o!="number"||!Number.isInteger(o)||o<1||o>50)throw new a("limit must be an integer from 1 to 50.");let n=e.fromBlock===void 0?s>=H+de?s-de+1n:H:$(e.fromBlock,"fromBlock",!0),t=e.toBlock===void 0?s:$(e.toBlock,"toBlock",!0),r=0;if(e.cursor!==void 0){if(typeof e.cursor!="string"||!/^[0-9]{1,78}:[0-9]{1,78}:[0-9]{1,10}$/.test(e.cursor))throw new a("Provide the browse cursor exactly as returned.");let u=e.cursor.split(":"),b=BigInt(u[0]),v=BigInt(u[1]);if(e.fromBlock!==void 0&&n!==b||e.toBlock!==void 0&&t!==v)throw new a("The cursor does not match this block range.");n=b,t=v,r=Number(u[2])}if(s<H&&e.fromBlock===void 0&&e.toBlock===void 0&&e.cursor===void 0)return{launches:[],cursor:null,fromBlock:H.toString(),toBlock:s.toString(),coverage:K,predeployment:!0};if(n<H||t<n||t>s||t-n>=de)throw new a("Choose a deployed block range of at most 100000 blocks, ending no later than the current head.");let d=await c.getLogs({address:_,event:U[0],fromBlock:n,toBlock:t,strict:!0});if(d.some(u=>u.blockNumber===null||u.logIndex===null||!u.transactionHash))throw new a("The launch feed returned an incomplete log.");if(d.sort((u,b)=>u.blockNumber===b.blockNumber?b.logIndex-u.logIndex:u.blockNumber>b.blockNumber?-1:1),r>d.length)throw new a("The browse cursor is outside the launch feed.");let i=new Map,f=[];for(let u of d.slice(r,r+o)){let b=u.transactionHash,v=i.get(b);v||(v=await c.getTransactionReceipt({hash:b}),i.set(b,v));let z=ie({abi:U,eventName:"TokenLaunched",data:u.data,topics:u.topics}).args,L=se(v).filter(k=>p(k.token,z.token)&&p(k.poolId,z.poolId));if(L.length!==1)throw new a("The launch feed log does not match one verified receipt launch.");f.push({...L[0],launchTx:b,blockNumber:u.blockNumber.toString(),token:await te(L[0].token,t),creator:v.from})}let w=r+o;return{launches:f,cursor:w<d.length?`${n}:${t}:${w}`:null,fromBlock:n.toString(),toBlock:t.toString(),coverage:K,previousToBlock:n>H?(n-1n).toString():null,summary:"Newest launches first within this fixed block range. Empty does not establish absence outside the range or covered strategies."}}async function he(e,s,o){let n=await P(e);if(!n.creatorFees)throw new a("Creator fees are permanently disabled for this position.");let t=BigInt(n.positionId),r=await c.readContract({address:h.v4PositionManager.address,abi:m,functionName:"ownerOf",args:[t]});if(!p(r,h.feeSplitterFeesOn.address))throw new a("The position is not locked in its current-strategy splitter.");let d=await c.readContract({address:S,abi:m,functionName:"ownerOf",args:[t]});if(!p(d,s))throw new a("Only the current fee NFT holder can change this entitlement.");let i=B(o?e.to:e.spender);if(p(i,S)||o&&p(i,C))throw new a("The fee NFT recipient cannot be the vault or zero address.");let f=o?N({abi:m,functionName:"safeTransferFrom",args:[s,i,t]}):N({abi:m,functionName:"approve",args:[i,t]});return T([y(S,f,0n,o?`Transfer fee NFT ${t} to ${i}, including accrued and future fees.`:`Approve ${i} for fee NFT ${t} only; zero address revokes approval.`)],s,o?`Transfer the entire fee entitlement for position ${t} to ${i}. This includes collected and future fees; locked LP remains in its splitter. No transaction sent.`:`Set the exact single-NFT approval for position ${t} to ${i}. This permits transfer of that fee entitlement; zero address revokes. No transaction sent.`)}async function Pe(){return{chainId:x,instant:{supported:!0,supply:ne.toString(),decimals:18,currency:ue,permanentCreatorFeeChoice:!0},crowd:{status:"BLOCKED",strategy:"0xbf1aB81f7d534b2CC0Da76fcf4d541322bB0e000",factory:"0x000000001F26a0044BaA66024e7b6599c61963F8",missing:"A verified Pools-specific auction configuration (BlockNumberish timing, reserve allocation, Q96 floor/tick, USD FDV conversion, issuance steps, locked LP plan) and a bytecode-matched factory-created auction ABI with success/refund fixtures. Generic CCA parameters are not a verified Pools Crowd Launch.",source:"https://github.com/Uniswap/sdks/blob/main/sdks/liquidity-launcher-sdk/src/addresses.ts"},coverage:K}}let g={type:"string"},I=ke(),ge={chainId:{type:"integer",const:x},slippageBps:{type:"integer",minimum:0,maximum:9999}};function A(e,s,o,n){return{name:`poolstrade_${e}`,inputSchema:{type:"object",additionalProperties:!1,properties:{...ge,...s},required:o},execute:async(t,r)=>{try{let d=new Set([...Object.keys(ge),...Object.keys(s)]);if(Object.keys(t).some(i=>!d.has(i)))throw new a("Unsupported input for this pools.trade tool.");if(t.chainId!==void 0&&t.chainId!==x)throw new a("pools.trade requires chain 4663.");if(B(r),t.slippageBps!==void 0){if(typeof t.slippageBps!="number")throw new a("Slippage must be an integer in basis points.");ae("10000",t.slippageBps)}return await j(),await n(t,r)}catch(d){F(d)}}}}return{tools:[A("launch",{name:g,symbol:g,creatorFees:{type:"boolean",description:"Permanent choice; must be explicit."},feeBeneficiary:g,pair:g,decimals:{type:"integer",const:18},supply:I,initialBuy:I,minAmountOut:I,description:g,website:g,imageUri:g},["name","symbol","creatorFees","feeBeneficiary"],O),...["buy","sell"].map(e=>A(e,{token:g,amountIn:I,minAmountOut:I,launchTx:g},["token","amountIn"],(s,o)=>G(s,o,e==="buy"))),A("collect",{positionId:I,launchTx:g},["positionId"],(e,s)=>pe(e,s,!1)),A("claim",{positionId:I,launchTx:g,minEth:I},["positionId"],(e,s)=>pe(e,s,!0)),A("browse",{fromBlock:I,toBlock:I,limit:{type:"integer",minimum:1,maximum:50},cursor:g},[],Fe),A("balance",{token:g,launchTx:g},["token"],Ce),A("status",{launchTx:g,token:g,positionId:I},["launchTx"],$e),A("launch_options",{},[],Pe),A("fee_transfer",{positionId:I,launchTx:g,to:g},["positionId","to"],(e,s)=>he(e,s,!0)),A("fee_approve",{positionId:I,launchTx:g,spender:g},["positionId","spender"],(e,s)=>he(e,s,!1)),A("transfer",{token:g,amount:I,to:g,launchTx:g},["token","amount","to"],Se),A("collect_many",{positionIds:{type:"array",items:I,minItems:1,maxItems:20},launchTxs:{type:"array",items:g,minItems:1,maxItems:20}},["positionIds","launchTxs"],Be)],positions:async e=>{B(e);let s=[],o=0,n=!0,t,r=i=>({module:"poolstrade",id:"poolstrade-discovery-incomplete",chainId:x,assets:[],incomplete:!0,description:`${i} Checked ${o} launch receipts. Readable holdings are retained. Check a known launch with poolstrade_status {"launchTx":"<hash>"} or its token holding with poolstrade_balance {"token":"<address>","launchTx":"<hash>"}. Crowd Launch and older deployments are outside this reader's coverage.`}),d=async()=>{await j(),n&&await ee(e,void 0,async i=>{o++;for(let f of se(i)){if(!n)return;let w=f.creatorFees&&p(await c.readContract({address:S,abi:m,functionName:"ownerOf",args:[BigInt(f.positionId)]}),e);if(!n)return;if(!w&&!p(i.from,e))continue;let u=w?[{token:ue,amount:(await c.readContract({address:S,abi:m,functionName:"amounts",args:[BigInt(f.positionId)]}))[0].toString()}]:[];n&&s.push({module:"poolstrade",id:f.positionId,chainId:x,assets:u,description:`Current Instant Launch ${f.token} (18 decimals, supply 1000000000), pool ${f.poolId}; creator fees ${f.creatorFees?"on":"off"} (permanent). ${w?"Collected ETH fees only; uncollected fees excluded.":"Launch record; no fee entitlement held."} Liquidity is permanently locked.`})}},()=>n)};try{return await Promise.race([d().then(()=>!0),new Promise(f=>{t=setTimeout(()=>{n=!1,f(!1)},6e3)})])?s:[...s,r("Pools.trade global launch discovery reached its 6000 ms read budget; the historical scan is incomplete.")]}catch(i){return[...s,r(`Pools.trade discovery could not finish: ${l.plainError(i)}`)]}finally{n=!1,t!==void 0&&clearTimeout(t)}}}};function Ve(l){return Ie("poolstrade",[Ee(l)])}export{se as a,Ee as b,Ve as c};
|