@oakagentkit/core 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{a}from"../../../chunks/NCAV7Q4C.js";import"../../../chunks/NWNYJ26T.js";import"../../../chunks/IX3GZMTM.js";import"../../../chunks/XSD5NL7J.js";import"../../../chunks/JXOEJPJ4.js";import"../../../chunks/63YRSLDK.js";export{a as createFoboClient};
1
+ import{a}from"../../../chunks/CU4PWGMJ.js";import"../../../chunks/NWNYJ26T.js";import"../../../chunks/IX3GZMTM.js";import"../../../chunks/XSD5NL7J.js";import"../../../chunks/JXOEJPJ4.js";import"../../../chunks/63YRSLDK.js";export{a as createFoboClient};
@@ -1 +1 @@
1
- import{b as E}from"../../../chunks/PHGHJ7SN.js";import{a as U,c as n,d as p,f as d,g as w,h as b,i as B,j as x,q as m}from"../../../chunks/X5I5EJ5T.js";import"../../../chunks/DFM4T6ZE.js";import{b as v,c as P,d as M,e as L}from"../../../chunks/SVKG4JOY.js";import{a as q}from"../../../chunks/4ZD5D2UP.js";import{a as f}from"../../../chunks/NCAV7Q4C.js";import"../../../chunks/BSX4LFYI.js";import{b as u}from"../../../chunks/SPJCSEKP.js";import"../../../chunks/Z25UKUJF.js";import"../../../chunks/43LI5NKJ.js";import{j as g}from"../../../chunks/66F5ZH34.js";import"../../../chunks/NWNYJ26T.js";import"../../../chunks/IX3GZMTM.js";import"../../../chunks/MQ5F2VOK.js";import"../../../chunks/5RXALTDT.js";import"../../../chunks/TI727O2H.js";import{a as c}from"../../../chunks/XSD5NL7J.js";import"../../../chunks/JXOEJPJ4.js";import"../../../chunks/63YRSLDK.js";import{formatUnits as D}from"viem";var K="FOBO tools run in the local Oak add-on. Update Oak and use prepare, then execute after a yes in chat.",j={fobo_token:"get_token",fobo_portfolio:"get_portfolio",fobo_leaderboard:"get_leaderboard",fobo_claims:"get_claims",fobo_limit_orders:"list_limit_orders",fobo_quote:"quote_trade",fobo_fee_schedule:"get_fee_schedule",fobo_limit_pay_tokens:"get_limit_pay_tokens",fobo_transaction:"get_transaction"},S={fobo_browse:"Browse FOBO launches; query searches tokens and traders.",fobo_token:"Read a FOBO token, current tax, floor, pair, vesting and risks by token address.",fobo_portfolio:"Read the local wallet\u2019s FOBO positions and profit/loss.",fobo_leaderboard:"Read FOBO trader rankings and the local wallet\u2019s rank.",fobo_claims:"Read the local wallet\u2019s creator fees, referral earnings and unlocked dev buys.",fobo_limit_orders:"Read the local wallet\u2019s limit orders, or a token\u2019s order book.",fobo_quote:"Quote a FOBO buy or sell. amount is a decimal integer of input base units; no signature.",fobo_fee_schedule:"Read FOBO pool taxes, fee splits, live launch fee and launch availability.",fobo_limit_pay_tokens:"Read the currencies accepted for FOBO limit-order escrow.",fobo_transaction:"Read a FOBO transaction status by its public transaction hash.",fobo_buy:"Prepare a FOBO token buy with exact input base units. Show the summary and wait for yes before oak_execute.",fobo_sell:"Prepare a FOBO token sell with exact input base units. Show the summary and wait for yes before oak_execute.",fobo_launch:"Prepare a FOBO coin launch. Optional initial buy needs a pair-token spending cap and can be locked. Public https image URL or none. Sign-in happens only after chat yes.",fobo_limit_order:"Prepare a FOBO buy/sell limit order. amount and maxFeePerFill are base units; limitMarketCapUsd is whole USD. Show summary and ask for yes.",fobo_cancel_limit_order:"Prepare cancellation of a local-wallet FOBO order; its remaining escrow returns to the wallet. Ask for yes.",fobo_claim:"Prepare a creator, referral or vesting claim. Referral currency is pair; only referral may specify to. Show summary and ask for yes."};function J(l,_){return l.network!==void 0&&l.network!=="mainnet"?u("fobo",[]):u("fobo",[{tools:Object.keys(n).map(e=>({name:e,description:S[e],inputSchema:{...n[e],description:S[e]},execute:async(I,O)=>{if(!_)throw new c(K);let o=w(e,g(n[e],I)),r=_.client?.()??f({fetch:l.http});try{let y=p[e];if(y)return await m(r,y,o,O);let s=j[e],t={...o};if(e==="fobo_browse"&&(o.query!==void 0?(s="search",t={query:o.query}):(s="list_launches",t=o.limit===void 0?{}:{limit:o.limit})),(["fobo_portfolio","fobo_leaderboard","fobo_claims"].includes(e)||e==="fobo_limit_orders"&&!o.token)&&(t.account=O),e==="fobo_quote"){let a=String(o.payWith??"pair");a==="pair"&&(a=String(d(await r.call("get_token",{token:o.token})).pair).replace(/^\$/,"").toLowerCase());let F=o.side==="sell"?18:b(a).decimals;t.slippageBps??=50,t.payWith??="pair",t.amount=D(BigInt(String(o.amount)),F);let i=d(await r.call(s,t)),C=o.side==="sell"?b(a).decimals:18,h=B(i.amountIn,F,"quote input");if(h!==o.amount||i.side!==o.side||String(i.token).toLowerCase()!==String(o.token).toLowerCase())throw new c("FOBO quote does not match the requested trade.");let{amountIn:R,expectedOut:A,minOut:N,...T}=i,k=x(i,C,Number(o.slippageBps??50),a);return{...T,chainId:4663,amountIn:h,amountOut:k.amountOut,minAmountOut:k.minimum}}return await r.call(s,t)}finally{await r.close()}}}))}])}export{p as FOBO_ACTION_KINDS,U as FOBO_ACTION_LIFETIME,K as FOBO_LOCAL_REFUSAL,q as FOBO_PINS,n as FOBO_SCHEMAS,f as createFoboClient,J as createModule,v as exactApprove,P as exactPermit,m as prepareFoboIntent,E as runFoboIntent,M as verifyFoboTransaction,L as verifySignInMessage};
1
+ import{b as E}from"../../../chunks/CM4DP2EZ.js";import{a as U,c as n,d as p,f as d,g as w,h as b,i as B,j as x,q as m}from"../../../chunks/IZFED3R2.js";import"../../../chunks/DFM4T6ZE.js";import{b as v,c as P,d as M,e as L}from"../../../chunks/MDLJFCT4.js";import{a as q}from"../../../chunks/4ZD5D2UP.js";import{a as f}from"../../../chunks/CU4PWGMJ.js";import"../../../chunks/BSX4LFYI.js";import{b as u}from"../../../chunks/SPJCSEKP.js";import"../../../chunks/Z25UKUJF.js";import"../../../chunks/43LI5NKJ.js";import{j as g}from"../../../chunks/66F5ZH34.js";import"../../../chunks/NWNYJ26T.js";import"../../../chunks/IX3GZMTM.js";import"../../../chunks/MQ5F2VOK.js";import"../../../chunks/5RXALTDT.js";import"../../../chunks/TI727O2H.js";import{a as c}from"../../../chunks/XSD5NL7J.js";import"../../../chunks/JXOEJPJ4.js";import"../../../chunks/63YRSLDK.js";import{formatUnits as D}from"viem";var K="FOBO tools run in the local Oak add-on. Update Oak and use prepare, then execute after a yes in chat.",j={fobo_token:"get_token",fobo_portfolio:"get_portfolio",fobo_leaderboard:"get_leaderboard",fobo_claims:"get_claims",fobo_limit_orders:"list_limit_orders",fobo_quote:"quote_trade",fobo_fee_schedule:"get_fee_schedule",fobo_limit_pay_tokens:"get_limit_pay_tokens",fobo_transaction:"get_transaction"},S={fobo_browse:"Browse FOBO launches; query searches tokens and traders.",fobo_token:"Read a FOBO token, current tax, floor, pair, vesting and risks by token address.",fobo_portfolio:"Read the local wallet\u2019s FOBO positions and profit/loss.",fobo_leaderboard:"Read FOBO trader rankings and the local wallet\u2019s rank.",fobo_claims:"Read the local wallet\u2019s creator fees, referral earnings and unlocked dev buys.",fobo_limit_orders:"Read the local wallet\u2019s limit orders, or a token\u2019s order book.",fobo_quote:"Quote a FOBO buy or sell. amount is a decimal integer of input base units; no signature.",fobo_fee_schedule:"Read FOBO pool taxes, fee splits, live launch fee and launch availability.",fobo_limit_pay_tokens:"Read the currencies accepted for FOBO limit-order escrow.",fobo_transaction:"Read a FOBO transaction status by its public transaction hash.",fobo_buy:"Prepare a FOBO token buy with exact input base units. Show the summary and wait for yes before oak_execute.",fobo_sell:"Prepare a FOBO token sell with exact input base units. Show the summary and wait for yes before oak_execute.",fobo_launch:"Prepare a FOBO coin launch. Optional initial buy needs a pair-token spending cap and can be locked. Public https image URL or none. Sign-in happens only after chat yes.",fobo_limit_order:"Prepare a FOBO buy/sell limit order. amount and maxFeePerFill are base units; limitMarketCapUsd is whole USD. Show summary and ask for yes.",fobo_cancel_limit_order:"Prepare cancellation of a local-wallet FOBO order; its remaining escrow returns to the wallet. Ask for yes.",fobo_claim:"Prepare a creator, referral or vesting claim. Referral currency is pair; only referral may specify to. Show summary and ask for yes."};function J(l,_){return l.network!==void 0&&l.network!=="mainnet"?u("fobo",[]):u("fobo",[{tools:Object.keys(n).map(e=>({name:e,description:S[e],inputSchema:{...n[e],description:S[e]},execute:async(I,O)=>{if(!_)throw new c(K);let o=w(e,g(n[e],I)),r=_.client?.()??f({fetch:l.http});try{let y=p[e];if(y)return await m(r,y,o,O);let s=j[e],t={...o};if(e==="fobo_browse"&&(o.query!==void 0?(s="search",t={query:o.query}):(s="list_launches",t=o.limit===void 0?{}:{limit:o.limit})),(["fobo_portfolio","fobo_leaderboard","fobo_claims"].includes(e)||e==="fobo_limit_orders"&&!o.token)&&(t.account=O),e==="fobo_quote"){let a=String(o.payWith??"pair");a==="pair"&&(a=String(d(await r.call("get_token",{token:o.token})).pair).replace(/^\$/,"").toLowerCase());let F=o.side==="sell"?18:b(a).decimals;t.slippageBps??=50,t.payWith??="pair",t.amount=D(BigInt(String(o.amount)),F);let i=d(await r.call(s,t)),C=o.side==="sell"?b(a).decimals:18,h=B(i.amountIn,F,"quote input");if(h!==o.amount||i.side!==o.side||String(i.token).toLowerCase()!==String(o.token).toLowerCase())throw new c("FOBO quote does not match the requested trade.");let{amountIn:R,expectedOut:A,minOut:N,...T}=i,k=x(i,C,Number(o.slippageBps??50),a);return{...T,chainId:4663,amountIn:h,amountOut:k.amountOut,minAmountOut:k.minimum}}return await r.call(s,t)}finally{await r.close()}}}))}])}export{p as FOBO_ACTION_KINDS,U as FOBO_ACTION_LIFETIME,K as FOBO_LOCAL_REFUSAL,q as FOBO_PINS,n as FOBO_SCHEMAS,f as createFoboClient,J as createModule,v as exactApprove,P as exactPermit,m as prepareFoboIntent,E as runFoboIntent,M as verifyFoboTransaction,L as verifySignInMessage};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"../../../chunks/X5I5EJ5T.js";import"../../../chunks/DFM4T6ZE.js";import"../../../chunks/SVKG4JOY.js";import"../../../chunks/4ZD5D2UP.js";import"../../../chunks/BSX4LFYI.js";import"../../../chunks/43LI5NKJ.js";import"../../../chunks/NWNYJ26T.js";import"../../../chunks/IX3GZMTM.js";import"../../../chunks/MQ5F2VOK.js";import"../../../chunks/5RXALTDT.js";import"../../../chunks/TI727O2H.js";import"../../../chunks/XSD5NL7J.js";import"../../../chunks/JXOEJPJ4.js";import"../../../chunks/63YRSLDK.js";export{d as FOBO_ACTION_KINDS,a as FOBO_ACTION_LIFETIME,b as FOBO_ADDRESSES,e as FOBO_PREPARE_TOOLS,c as FOBO_SCHEMAS,o as checkFoboPrepared,n as foboApproval,h as foboAsset,l as foboExpectation,p as foboFeeDisclosure,j as foboQuoteBounds,f as foboRecord,k as foboRequest,i as foboUnits,q as prepareFoboIntent,m as preparedAnswer,g as validateFoboArgs};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"../../../chunks/IZFED3R2.js";import"../../../chunks/DFM4T6ZE.js";import"../../../chunks/MDLJFCT4.js";import"../../../chunks/4ZD5D2UP.js";import"../../../chunks/BSX4LFYI.js";import"../../../chunks/43LI5NKJ.js";import"../../../chunks/NWNYJ26T.js";import"../../../chunks/IX3GZMTM.js";import"../../../chunks/MQ5F2VOK.js";import"../../../chunks/5RXALTDT.js";import"../../../chunks/TI727O2H.js";import"../../../chunks/XSD5NL7J.js";import"../../../chunks/JXOEJPJ4.js";import"../../../chunks/63YRSLDK.js";export{d as FOBO_ACTION_KINDS,a as FOBO_ACTION_LIFETIME,b as FOBO_ADDRESSES,e as FOBO_PREPARE_TOOLS,c as FOBO_SCHEMAS,o as checkFoboPrepared,n as foboApproval,h as foboAsset,l as foboExpectation,p as foboFeeDisclosure,j as foboQuoteBounds,f as foboRecord,k as foboRequest,i as foboUnits,q as prepareFoboIntent,m as preparedAnswer,g as validateFoboArgs};
@@ -1 +1 @@
1
- import{a,b}from"../../../chunks/PHGHJ7SN.js";import"../../../chunks/X5I5EJ5T.js";import"../../../chunks/DFM4T6ZE.js";import"../../../chunks/SVKG4JOY.js";import"../../../chunks/4ZD5D2UP.js";import"../../../chunks/BSX4LFYI.js";import"../../../chunks/43LI5NKJ.js";import"../../../chunks/NWNYJ26T.js";import"../../../chunks/IX3GZMTM.js";import"../../../chunks/MQ5F2VOK.js";import"../../../chunks/5RXALTDT.js";import"../../../chunks/TI727O2H.js";import"../../../chunks/XSD5NL7J.js";import"../../../chunks/JXOEJPJ4.js";import"../../../chunks/63YRSLDK.js";export{a as foboExactPermit,b as runFoboIntent};
1
+ import{a,b}from"../../../chunks/CM4DP2EZ.js";import"../../../chunks/IZFED3R2.js";import"../../../chunks/DFM4T6ZE.js";import"../../../chunks/MDLJFCT4.js";import"../../../chunks/4ZD5D2UP.js";import"../../../chunks/BSX4LFYI.js";import"../../../chunks/43LI5NKJ.js";import"../../../chunks/NWNYJ26T.js";import"../../../chunks/IX3GZMTM.js";import"../../../chunks/MQ5F2VOK.js";import"../../../chunks/5RXALTDT.js";import"../../../chunks/TI727O2H.js";import"../../../chunks/XSD5NL7J.js";import"../../../chunks/JXOEJPJ4.js";import"../../../chunks/63YRSLDK.js";export{a as foboExactPermit,b as runFoboIntent};
@@ -1 +1 @@
1
- import{a,b,c,d,e}from"../../../chunks/SVKG4JOY.js";import"../../../chunks/4ZD5D2UP.js";import"../../../chunks/BSX4LFYI.js";import"../../../chunks/43LI5NKJ.js";import"../../../chunks/NWNYJ26T.js";import"../../../chunks/IX3GZMTM.js";import"../../../chunks/TI727O2H.js";import"../../../chunks/XSD5NL7J.js";import"../../../chunks/JXOEJPJ4.js";import"../../../chunks/63YRSLDK.js";export{a as FOBO_MAX_GAS,b as exactApprove,c as exactPermit,d as verifyFoboTransaction,e as verifySignInMessage};
1
+ import{a,b,c,d,e}from"../../../chunks/MDLJFCT4.js";import"../../../chunks/4ZD5D2UP.js";import"../../../chunks/BSX4LFYI.js";import"../../../chunks/43LI5NKJ.js";import"../../../chunks/NWNYJ26T.js";import"../../../chunks/IX3GZMTM.js";import"../../../chunks/TI727O2H.js";import"../../../chunks/XSD5NL7J.js";import"../../../chunks/JXOEJPJ4.js";import"../../../chunks/63YRSLDK.js";export{a as FOBO_MAX_GAS,b as exactApprove,c as exactPermit,d as verifyFoboTransaction,e as verifySignInMessage};
@@ -1 +1 @@
1
- import{a as N,b as F,e as b,f as i,k as T,m as O,o as B}from"./X5I5EJ5T.js";import{c as I,e as A}from"./SVKG4JOY.js";import{h as x}from"./BSX4LFYI.js";import{a as o,e as k}from"./XSD5NL7J.js";function u(e,s){if(e.version!==1||e.chainId!==4663||!Object.hasOwn(b,e.kind))throw new o("Invalid FOBO pending action. Nothing further was signed.");if(!Number.isSafeInteger(s)||!Number.isSafeInteger(e.quotedAt)||s<e.quotedAt||s-e.quotedAt>=N)throw new o("This FOBO action expired. Nothing further was signed. Ask for a fresh summary, then say yes or no.")}function w(e,s){return typeof e=="string"&&e.toLowerCase()===s.toLowerCase()}function P(e){if(typeof e!="number"&&typeof e!="string"||!/^\d+$/.test(String(e)))throw new o("FOBO returned an invalid Permit2 nonce.");let s=Number(e);if(!Number.isSafeInteger(s)||s<0||s>=2**48)throw new o("FOBO returned an invalid Permit2 nonce.");return s}function _(e,s,n){let t=i(s),m=i(t.domain),c=i(t.message),p=i(c.details);if(!["buy","sell"].includes(e.kind)||![4663,"0x1237"].includes(m.chainId)||!w(m.verifyingContract,F.permit2)||t.primaryType!=="PermitSingle"||!w(c.spender,F.router)||!w(p.token,e.request._currencyIn)||!e.terms.amountIn)throw new o("FOBO permit does not match the approved token, spender or chain. Nothing further was signed.");return I({token:e.request._currencyIn,amount:BigInt(e.terms.amountIn),nonce:P(p.nonce),now:n})}async function*q(e,s,n){let t=structuredClone(s);u(t,n.now());let m=!1,c,p;try{if(t.kind==="launch"){let a=i(await e.call("sign_in_start",{account:t.wallet}));if(u(t,n.now()),typeof a.message!="string"||typeof a.ticket!="string"||!a.ticket||a.ticket.length>2e3)throw new o("FOBO returned an invalid sign-in ticket. Nothing was signed.");A(a.message,t.wallet,n.now());let f=await n.signMessage(a.message);u(t,n.now());let l=i(await e.call("sign_in_finish",{account:t.wallet,ticket:a.ticket,signature:f}));if(l.success===!1||l.ok===!1||l.isError===!0)throw new o("FOBO sign-in was refused. Nothing further was signed.");yield{kind:"signin",status:"signed"}}for(let a=0;a<4;a++){u(t,n.now());let f={...T(t),...c?{permit:c}:{}},h=a===0&&["limitOrder","cancel","claim"].includes(t.kind)&&typeof t.request._prepared=="string"?O({status:"ready",transactions:JSON.parse(String(t.request._prepared)).map(r=>({...r,from:t.wallet,gas:r.gasLimit}))}):O(await e.call(b[t.kind],f));u(t,n.now());let y=await B(t,h,n.now(),c?.message,n.readContract);if(h.status==="needs_approval"){if(m||c)throw new o("FOBO requested a repeated approval. Nothing further was signed. Ask for a fresh summary.");for(let r of y){u(t,n.now());let d=await n.sendTransaction(r);m=!0,await n.waitForReceipt(d),yield{kind:"approval",hash:d,tx:r,status:"mined"}}continue}if(h.status==="needs_signature"){if(c)throw new o("FOBO requested a repeated permit. Nothing further was signed.");p=_(t,h.typedData,n.now()),u(t,n.now());let r=await n.signTypedData(p);c={message:i(p).message,signature:r},yield{kind:"permit",status:"signed"};continue}if(p){let r=i(i(p).message),d=i(r.details);for(let S of y){let g=x(S.data,["0x0Af57F62982D03066ef917AcAd87F771c06528Ec","0x0000000000000000000000000000000000000000"]).permit;if(!g||!w(g.token,d.token)||g.amount!==BigInt(String(d.amount))||g.nonce!==Number(d.nonce)||g.expiration!==Number(d.expiration)||!w(g.spender,r.spender)||g.sigDeadline!==BigInt(String(r.sigDeadline)))throw new o("FOBO changed the exact signed permit in the swap. Nothing further was signed.")}}for(let r of y){u(t,n.now());let d=await n.sendTransaction(r);await n.waitForReceipt(d),yield{kind:"transaction",hash:d,tx:r,status:"mined"}}return}throw new o("FOBO preparation did not finish. Nothing further was signed. Ask for a fresh summary.")}catch(a){let f=m?" An exact approval was already sent; use oak_cleanup_allowances to review any allowance left.":"";throw new o(`${k(a).replaceAll("Nothing was signed.","Nothing further was signed.")} FOBO execution stopped; nothing further was signed.${f}`)}}export{_ as a,q as b};
1
+ import{a as N,b as F,e as b,f as i,k as T,m as O,o as B}from"./IZFED3R2.js";import{c as I,e as A}from"./MDLJFCT4.js";import{h as x}from"./BSX4LFYI.js";import{a as o,e as k}from"./XSD5NL7J.js";function u(e,s){if(e.version!==1||e.chainId!==4663||!Object.hasOwn(b,e.kind))throw new o("Invalid FOBO pending action. Nothing further was signed.");if(!Number.isSafeInteger(s)||!Number.isSafeInteger(e.quotedAt)||s<e.quotedAt||s-e.quotedAt>=N)throw new o("This FOBO action expired. Nothing further was signed. Ask for a fresh summary, then say yes or no.")}function w(e,s){return typeof e=="string"&&e.toLowerCase()===s.toLowerCase()}function P(e){if(typeof e!="number"&&typeof e!="string"||!/^\d+$/.test(String(e)))throw new o("FOBO returned an invalid Permit2 nonce.");let s=Number(e);if(!Number.isSafeInteger(s)||s<0||s>=2**48)throw new o("FOBO returned an invalid Permit2 nonce.");return s}function _(e,s,n){let t=i(s),m=i(t.domain),c=i(t.message),p=i(c.details);if(!["buy","sell"].includes(e.kind)||![4663,"0x1237"].includes(m.chainId)||!w(m.verifyingContract,F.permit2)||t.primaryType!=="PermitSingle"||!w(c.spender,F.router)||!w(p.token,e.request._currencyIn)||!e.terms.amountIn)throw new o("FOBO permit does not match the approved token, spender or chain. Nothing further was signed.");return I({token:e.request._currencyIn,amount:BigInt(e.terms.amountIn),nonce:P(p.nonce),now:n})}async function*q(e,s,n){let t=structuredClone(s);u(t,n.now());let m=!1,c,p;try{if(t.kind==="launch"){let a=i(await e.call("sign_in_start",{account:t.wallet}));if(u(t,n.now()),typeof a.message!="string"||typeof a.ticket!="string"||!a.ticket||a.ticket.length>2e3)throw new o("FOBO returned an invalid sign-in ticket. Nothing was signed.");A(a.message,t.wallet,n.now());let f=await n.signMessage(a.message);u(t,n.now());let l=i(await e.call("sign_in_finish",{account:t.wallet,ticket:a.ticket,signature:f}));if(l.success===!1||l.ok===!1||l.isError===!0)throw new o("FOBO sign-in was refused. Nothing further was signed.");yield{kind:"signin",status:"signed"}}for(let a=0;a<4;a++){u(t,n.now());let f={...T(t),...c?{permit:c}:{}},h=a===0&&["limitOrder","cancel","claim"].includes(t.kind)&&typeof t.request._prepared=="string"?O({status:"ready",transactions:JSON.parse(String(t.request._prepared)).map(r=>({...r,from:t.wallet,gas:r.gasLimit}))}):O(await e.call(b[t.kind],f));u(t,n.now());let y=await B(t,h,n.now(),c?.message,n.readContract);if(h.status==="needs_approval"){if(m||c)throw new o("FOBO requested a repeated approval. Nothing further was signed. Ask for a fresh summary.");for(let r of y){u(t,n.now());let d=await n.sendTransaction(r);m=!0,await n.waitForReceipt(d),yield{kind:"approval",hash:d,tx:r,status:"mined"}}continue}if(h.status==="needs_signature"){if(c)throw new o("FOBO requested a repeated permit. Nothing further was signed.");p=_(t,h.typedData,n.now()),u(t,n.now());let r=await n.signTypedData(p);c={message:i(p).message,signature:r},yield{kind:"permit",status:"signed"};continue}if(p){let r=i(i(p).message),d=i(r.details);for(let S of y){let g=x(S.data,["0x0Af57F62982D03066ef917AcAd87F771c06528Ec","0x0000000000000000000000000000000000000000"]).permit;if(!g||!w(g.token,d.token)||g.amount!==BigInt(String(d.amount))||g.nonce!==Number(d.nonce)||g.expiration!==Number(d.expiration)||!w(g.spender,r.spender)||g.sigDeadline!==BigInt(String(r.sigDeadline)))throw new o("FOBO changed the exact signed permit in the swap. Nothing further was signed.")}}for(let r of y){u(t,n.now());let d=await n.sendTransaction(r);await n.waitForReceipt(d),yield{kind:"transaction",hash:d,tx:r,status:"mined"}}return}throw new o("FOBO preparation did not finish. Nothing further was signed. Ask for a fresh summary.")}catch(a){let f=m?" An exact approval was already sent; use oak_cleanup_allowances to review any allowance left.":"";throw new o(`${k(a).replaceAll("Nothing was signed.","Nothing further was signed.")} FOBO execution stopped; nothing further was signed.${f}`)}}export{_ as a,q as b};
@@ -1,4 +1,4 @@
1
- import{e as c}from"./NWNYJ26T.js";import{a as x}from"./XSD5NL7J.js";import{a as C}from"./JXOEJPJ4.js";var E="https://mcp.fobo.fun/mcp",k="2025-03-26",A=4*1024*1024,n=d=>new x(`FOBO ${d}. Nothing was signed. Please try again.`);function z(d={}){let O=d.fetch??globalThis.fetch,y=d.endpoint??E,b=d.timeoutMs??3e4;if(!Number.isSafeInteger(b)||b<=0)throw n("timeout must be a positive number of milliseconds");let s,i=k,P=0,u=!1,o,e=new Set;async function w(r,l,m,h="POST",f=!1){let t=new AbortController;e.add(t);let v,p=++P,S=new Promise((g,a)=>{v=setTimeout(()=>{a(n("request timed out")),t.abort()},b)});try{return await Promise.race([S,(async()=>{let g={"Content-Type":"application/json",Accept:"application/json, text/event-stream","MCP-Protocol-Version":i};m&&(g["Mcp-Session-Id"]=m);let a=await O(y,{method:h,headers:g,signal:t.signal,...h==="POST"?{body:JSON.stringify({jsonrpc:"2.0",...f?{}:{id:p},method:r,params:l})}:{}});if(h==="DELETE"&&(a.ok||a.status===405||a.status===404))return{};if(f){if(!a.ok)throw n("session initialization was refused");return await a.body?.cancel(),{}}let R=await M(a,p);if(!a.ok&&R.error?.code!==-32e3)throw n("service is unavailable");return{rpc:R,session:a.headers.get("Mcp-Session-Id")??void 0}})()])}catch(g){throw g instanceof x?g:n("could not be reached")}finally{clearTimeout(v),e.delete(t),t.abort()}}async function T(){if(u)throw n("client is closed");s||(o||(o=(async()=>{let r=await w("initialize",{protocolVersion:k,capabilities:{},clientInfo:{name:"oak",version:"0.3.2"}});if(r.rpc?.error||!r.session||!c(r.rpc?.result))throw n("did not provide an MCP session");let l=r.rpc.result.protocolVersion;if(typeof l=="string"){if(!["2025-03-26","2025-06-18","2025-11-25"].includes(l))throw n("MCP protocol version is unsupported");i=l}if(u)throw n("client is closed");await w("notifications/initialized",{},r.session,"POST",!0),s=r.session})().finally(()=>{o=void 0})),await o)}return{async call(r,l){await T();for(let m=0;m<2;m++){if(u)throw n("client is closed");let h=s,{rpc:f}=await w("tools/call",{name:r,arguments:l},h);if(f?.error?.code===-32e3){if(m===1)throw n("session expired");s===h&&(s=void 0),await T();continue}if(!f||f.error)throw n("request was refused");let t=f.result;if(c(t)&&t.isError===!0){let v=Array.isArray(t.content)?t.content.filter(c).filter(p=>p.type==="text"&&typeof p.text=="string").map(p=>p.text).join(" "):"";throw new x(`FOBO refused the request: ${C(v||"The tool returned an error.")}. Nothing was signed. Ask for a fresh summary.`)}if(c(t)&&c(t.structuredContent))return t.structuredContent;if(c(t)&&"content"in t){if(!Array.isArray(t.content)||t.content.length!==1||!c(t.content[0])||t.content[0].type!=="text"||typeof t.content[0].text!="string")throw n("returned an unsupported tool answer");try{return JSON.parse(t.content[0].text)}catch{throw n("returned an unreadable tool answer")}}return t}throw n("session expired")},async close(){if(u)return;u=!0;for(let l of e)l.abort();let r=s;s=void 0,r&&await w("",{},r,"DELETE")}}}async function M(d,O){let y=d.body?.getReader();if(!y)throw n("returned an empty response");let b=new TextDecoder,s=d.headers.get("Content-Type")?.includes("text/event-stream"),i="",P=0,u=o=>{let e;try{e=JSON.parse(o)}catch{throw n("returned an unreadable response")}if(!c(e)||e.jsonrpc!=="2.0")throw n("returned an invalid response");if(!(s&&!("id"in e)&&typeof e.method=="string")){if(e.id!==O||"result"in e=="error"in e||"error"in e&&(!c(e.error)||typeof e.error.code!="number"))throw n("returned an invalid response");return e}};try{for(;;){let o=await y.read();if(P+=o.value?.length??0,P>A)throw n("response is too large");if(i+=b.decode(o.value,{stream:!o.done}),s){i=i.replace(/\r\n/g,`
1
+ import{e as c}from"./NWNYJ26T.js";import{a as x}from"./XSD5NL7J.js";import{a as C}from"./JXOEJPJ4.js";var E="https://mcp.fobo.fun/mcp",k="2025-03-26",A=4*1024*1024,n=d=>new x(`FOBO ${d}. Nothing was signed. Please try again.`);function z(d={}){let O=d.fetch??globalThis.fetch,y=d.endpoint??E,b=d.timeoutMs??3e4;if(!Number.isSafeInteger(b)||b<=0)throw n("timeout must be a positive number of milliseconds");let s,i=k,P=0,u=!1,o,e=new Set;async function w(r,l,m,h="POST",f=!1){let t=new AbortController;e.add(t);let v,p=++P,S=new Promise((g,a)=>{v=setTimeout(()=>{a(n("request timed out")),t.abort()},b)});try{return await Promise.race([S,(async()=>{let g={"Content-Type":"application/json",Accept:"application/json, text/event-stream","MCP-Protocol-Version":i};m&&(g["Mcp-Session-Id"]=m);let a=await O(y,{method:h,headers:g,signal:t.signal,...h==="POST"?{body:JSON.stringify({jsonrpc:"2.0",...f?{}:{id:p},method:r,params:l})}:{}});if(h==="DELETE"&&(a.ok||a.status===405||a.status===404))return{};if(f){if(!a.ok)throw n("session initialization was refused");return await a.body?.cancel(),{}}let R=await M(a,p);if(!a.ok&&R.error?.code!==-32e3)throw n("service is unavailable");return{rpc:R,session:a.headers.get("Mcp-Session-Id")??void 0}})()])}catch(g){throw g instanceof x?g:n("could not be reached")}finally{clearTimeout(v),e.delete(t),t.abort()}}async function T(){if(u)throw n("client is closed");s||(o||(o=(async()=>{let r=await w("initialize",{protocolVersion:k,capabilities:{},clientInfo:{name:"oak",version:"0.3.3"}});if(r.rpc?.error||!r.session||!c(r.rpc?.result))throw n("did not provide an MCP session");let l=r.rpc.result.protocolVersion;if(typeof l=="string"){if(!["2025-03-26","2025-06-18","2025-11-25"].includes(l))throw n("MCP protocol version is unsupported");i=l}if(u)throw n("client is closed");await w("notifications/initialized",{},r.session,"POST",!0),s=r.session})().finally(()=>{o=void 0})),await o)}return{async call(r,l){await T();for(let m=0;m<2;m++){if(u)throw n("client is closed");let h=s,{rpc:f}=await w("tools/call",{name:r,arguments:l},h);if(f?.error?.code===-32e3){if(m===1)throw n("session expired");s===h&&(s=void 0),await T();continue}if(!f||f.error)throw n("request was refused");let t=f.result;if(c(t)&&t.isError===!0){let v=Array.isArray(t.content)?t.content.filter(c).filter(p=>p.type==="text"&&typeof p.text=="string").map(p=>p.text).join(" "):"";throw new x(`FOBO refused the request: ${C(v||"The tool returned an error.")}. Nothing was signed. Ask for a fresh summary.`)}if(c(t)&&c(t.structuredContent))return t.structuredContent;if(c(t)&&"content"in t){if(!Array.isArray(t.content)||t.content.length!==1||!c(t.content[0])||t.content[0].type!=="text"||typeof t.content[0].text!="string")throw n("returned an unsupported tool answer");try{return JSON.parse(t.content[0].text)}catch{throw n("returned an unreadable tool answer")}}return t}throw n("session expired")},async close(){if(u)return;u=!0;for(let l of e)l.abort();let r=s;s=void 0,r&&await w("",{},r,"DELETE")}}}async function M(d,O){let y=d.body?.getReader();if(!y)throw n("returned an empty response");let b=new TextDecoder,s=d.headers.get("Content-Type")?.includes("text/event-stream"),i="",P=0,u=o=>{let e;try{e=JSON.parse(o)}catch{throw n("returned an unreadable response")}if(!c(e)||e.jsonrpc!=="2.0")throw n("returned an invalid response");if(!(s&&!("id"in e)&&typeof e.method=="string")){if(e.id!==O||"result"in e=="error"in e||"error"in e&&(!c(e.error)||typeof e.error.code!="number"))throw n("returned an invalid response");return e}};try{for(;;){let o=await y.read();if(P+=o.value?.length??0,P>A)throw n("response is too large");if(i+=b.decode(o.value,{stream:!o.done}),s){i=i.replace(/\r\n/g,`
2
2
  `);let e;for(;(e=i.indexOf(`
3
3
 
4
4
  `))!==-1;){let w=i.slice(0,e);i=i.slice(e+2);let T=w.split(`
@@ -1,4 +1,4 @@
1
- import{a as R}from"./DFM4T6ZE.js";import{d as N}from"./SVKG4JOY.js";import{b as D,d as M,f as C}from"./4ZD5D2UP.js";import{t as E}from"./MQ5F2VOK.js";import{a}from"./XSD5NL7J.js";import{a as P}from"./JXOEJPJ4.js";import{decodeFunctionData as _,erc20Abi as X,formatUnits as $,getAddress as x,isAddress as Q,parseUnits as K,parseAbi as V,zeroAddress as f}from"viem";var be=300,m={permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",router:"0x204FAca1764B154221e35c0d20aBb3c525710498",factory:"0xd7e538e98A208fD19e46bc549FF4710C33664e18",limitOrders:"0x3126f62d604a0AA2de8788e3eC21dDd8F2a2f82a",fobo:"0x000DE658153f47f23e92973C8EB1e89762703676",usdg:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"},T=["eth","fobo","usdg","msft","tsla","spcx","googl","amzn","aapl","nvda","meta"],b=(t,e=0)=>({type:"string",minLength:e,maxLength:t}),w=(t,e="string")=>({type:e,enum:t}),B={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},v={type:"string",pattern:"^[0-9]+$",description:"Exact input in token base units, as a decimal integer string."},U={type:"integer",minimum:1,maximum:100},L={token:B,amount:v,payWith:w(["pair","eth","usdg","fobo"]),slippageBps:{type:"integer",minimum:1,maximum:5e3}},Z={token:"FOBO coin contract address on chain 4663; obtain it from fobo_browse or fobo_token.",query:"Search FOBO coins and traders by name, ticker or address; omit to browse recent launches.",limit:"Maximum number of results, from 1 to 100.",side:"Trade direction: buy the coin or sell it back to the payment currency.",payWith:"Payment currency: pair uses the coin\u2019s own pair; trades also accept eth, usdg or fobo.",slippageBps:"Maximum loss against quoted output in basis points (50 = 0.5%); default 50.",hash:"Public transaction hash (0x followed by 64 hex digits) to look up on FOBO.",name:"New coin name, 1 to 32 characters.",ticker:"New coin ticker, 2 to 10 letters or digits; normalized to uppercase.",description:"Public description of the new coin, at most 280 characters.",imageUrl:"Optional public HTTPS image URL; omit for no image. Local uploads are unsupported.",links:"Optional public project links stored with the launched coin.",telegram:"Public Telegram URL.",discord:"Public Discord URL.",github:"Public GitHub URL.",website:"Public project website URL.",pair:"Pair currency: eth, fobo, usdg or a supported stock ticker; referral claims use this currency.",devBuyTokens:"Whole tokens in the initial buy, 0 to 50,000,000 (5% of supply); default 0.",vestMonths:"Initial-buy lock in months: 0, 1, 3, 6 or 12; default 0. A lock requires an initial buy.",limitMarketCapUsd:"Target market capitalization in whole USD, as a decimal string; not a per-token price.",expiresIn:"Order lifetime: 1h, 1d, 7d or 30d; default 7d.",maxFeePerFill:"Maximum keeper fee per fill in payment-token base units, as an exact decimal integer string.",orderId:"Positive numeric ID of the local wallet\u2019s limit order to cancel.",kind:"Claim creator fees, referral earnings or vesting tokens.",to:"Optional recipient address for a referral claim; omit for this wallet. Other claims always pay this wallet."},l=(t,e=[])=>({type:"object",additionalProperties:!1,required:e,properties:Object.fromEntries(Object.entries(t).map(([r,s])=>{let o=s;return[r,{...o,description:o.description??Z[r]}]}))}),Y={fobo_browse:l({query:b(64,1),limit:U}),fobo_token:l({token:B},["token"]),fobo_portfolio:l({}),fobo_leaderboard:l({limit:U}),fobo_claims:l({}),fobo_limit_orders:l({token:B}),fobo_quote:l({...L,side:w(["buy","sell"])},["token","side","amount"]),fobo_fee_schedule:l({}),fobo_limit_pay_tokens:l({}),fobo_transaction:l({hash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"}},["hash"]),fobo_buy:l(L,["token","amount"]),fobo_sell:l(L,["token","amount"]),fobo_launch:l({name:b(32,1),ticker:{type:"string",pattern:"^\\$?[a-zA-Z0-9]{2,10}$"},description:b(280),imageUrl:{...b(2e3),pattern:"^https://"},links:l({telegram:b(200),discord:b(200),github:b(200),website:b(200)}),pair:w(T),devBuyTokens:{type:"integer",minimum:0,maximum:5e7},vestMonths:w([0,1,3,6,12],"integer"),maxInitialBuyAmount:{...v,description:"Maximum pair-token base units to spend on the initial buy, excluding the live launch fee. Required when devBuyTokens is positive."}},["name","ticker"]),fobo_limit_order:l({token:B,side:w(["buy","sell"]),payWith:b(42,2),amount:v,limitMarketCapUsd:{type:"string",pattern:"^\\d{1,30}(\\.\\d{1,18})?$"},expiresIn:w(["1h","1d","7d","30d"]),maxFeePerFill:v},["token","side","amount","limitMarketCapUsd","maxFeePerFill"]),fobo_cancel_limit_order:l({orderId:{type:"integer",minimum:1,maximum:Number.MAX_SAFE_INTEGER}},["orderId"]),fobo_claim:l({kind:w(["creator","referral","vesting"]),token:B,pair:w(T),to:B},["kind"])},ee={fobo_buy:"buy",fobo_sell:"sell",fobo_launch:"launch",fobo_limit_order:"limitOrder",fobo_cancel_limit_order:"cancel",fobo_claim:"claim"},te={buy:"prepare_trade",sell:"prepare_trade",launch:"prepare_launch",limitOrder:"prepare_limit_order",cancel:"prepare_cancel_limit_order",claim:"prepare_claim"};function g(t){if(!t||typeof t!="object"||Array.isArray(t))throw new a("FOBO returned an invalid answer. Ask for a fresh summary.");return t}function ne(t,e){function r(s,o){let d=s.properties;if(Object.keys(o).some(n=>!Object.hasOwn(d,n)))throw new a("Unexpected FOBO argument. Use the fields declared by the tool.");for(let n of s.required)if(o[n]===void 0)throw new a(`Missing FOBO argument: ${n}.`);for(let[n,i]of Object.entries(o)){let c=d[n];if(c.type==="object"){r(c,g(i));continue}if(c.type==="integer"){if(typeof i!="number"||!Number.isSafeInteger(i)||i<Number(c.minimum??0)||i>Number(c.maximum??Number.MAX_SAFE_INTEGER))throw new a(`Invalid FOBO argument: ${n}.`)}else if(typeof i!="string"||i.length<Number(c.minLength??0)||i.length>Number(c.maxLength??256)||typeof c.pattern=="string"&&!new RegExp(c.pattern).test(i))throw new a(`Invalid FOBO argument: ${n}.`);if(Array.isArray(c.enum)&&!c.enum.includes(i))throw new a(`Invalid FOBO argument: ${n}.`)}}if(r(Y[t],g(e)),t==="fobo_claim"&&(e.kind==="referral"?e.pair===void 0:e.token===void 0))throw new a("Referral claims need pair; creator and vesting claims need token.");if(t==="fobo_claim"&&e.kind!=="referral"&&e.to!==void 0)throw new a("Only referral claims may name another recipient.");if(t==="fobo_launch"){if(Number(e.vestMonths??0)>0&&Number(e.devBuyTokens??0)===0)throw new a("A vesting lock needs an initial buy.");if(Number(e.devBuyTokens??0)>0&&(typeof e.maxInitialBuyAmount!="string"||BigInt(e.maxInitialBuyAmount)===0n))throw new a("An initial buy needs maxInitialBuyAmount in pair-token base units. Ask the person for that spending cap.");if(e.imageUrl!==void 0){let s=new URL(String(e.imageUrl));if(s.protocol!=="https:"||s.username||s.password)throw new a("Use a public https image URL.")}}return structuredClone(e)}function y(t){let e=t.toLowerCase();if(e===f||e==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")return{address:f,decimals:18};if(e===m.usdg.toLowerCase())return{address:m.usdg,decimals:6};if(e===m.fobo.toLowerCase())return{address:m.fobo,decimals:18};if(t==="eth")return{address:f,decimals:18};if(t==="usdg")return{address:m.usdg,decimals:6};if(t==="fobo")return{address:m.fobo,decimals:18};let r=R.tokens.find(s=>T.includes(t)&&s.symbol.toLowerCase()===t||s.token.toLowerCase()===e);if(r)return{address:x(r.token),decimals:18};throw new a("FOBO did not identify a supported pair currency. Ask for token details first.")}function A(t,e,r){if(typeof t!="string"||!/^\d{1,78}(\.\d{1,18})?$/.test(t)||(t.split(".")[1]?.length??0)>e)throw new a(`FOBO returned an invalid ${r}. Ask for a fresh quote.`);return K(t,e).toString()}function re(t,e,r,s){if(String(t.payWith).replace(/^\$/,"").toLowerCase()!==s.toLowerCase())throw new a("FOBO quote payment currency differs from the request.");if(t.slippageBps!==r)throw new a("FOBO quote slippage differs from the request.");let o=A(t.expectedOut,e,"quote output"),d=A(t.minOut,e,"quote minimum"),n=BigInt(o)*BigInt(1e4-r)/10000n;if(BigInt(d)<=0n||BigInt(d)>BigInt(o)||BigInt(d)<n)throw new a("FOBO quote minimum exceeds the approved slippage loss.");return{amountOut:o,minimum:d}}function W(t){let e=Object.fromEntries(Object.entries(t.request).filter(([r])=>!r.startsWith("_")&&r!=="maxInitialBuyAmount"));return typeof e.links=="string"&&(e.links=JSON.parse(e.links)),e.amount!==void 0&&(e.amount=$(BigInt(String(e.amount)),Number(t.request._inputDecimals))),e.maxFeePerFill!==void 0&&(e.maxFeePerFill=$(BigInt(String(e.maxFeePerFill)),Number(t.request._payDecimals))),(t.kind==="buy"||t.kind==="sell")&&(e.side=t.kind),t.kind==="claim"&&e.pair!==void 0&&(e.currency=e.pair,delete e.pair),{...e,account:t.wallet}}function S(t,e,r="0x0Af57F62982D03066ef917AcAd87F771c06528Ec"){let[s,o]=BigInt(t)<BigInt(e)?[t,e]:[e,t];return{currency0:s,currency1:o,fee:r===f?500:0,tickSpacing:r===f?10:60,hooks:r}}function j(t,e){let r=t===f?e:t;if(t!==f&&e!==f)throw new a("FOBO base-currency routes must pass through ETH.");if(r.toLowerCase()===m.usdg.toLowerCase())return S(t,e,f);if(r.toLowerCase()===m.fobo.toLowerCase())return S(t,e);throw new a("FOBO has not pinned a route between this pair and ETH. Use the token\u2019s own pair.")}function oe(t,e,r,s){let o=[];return r.toLowerCase()!==e.toLowerCase()&&(r!==f&&o.push(j(r,f)),e!==f&&o.push(j(f,e))),o.push(S(e,t)),s?o.reverse():o}function ie(t,e,r,s){let o=t.request,d=t.terms;if(t.kind==="buy"||t.kind==="sell")return{kind:"trade",currencyIn:o._currencyIn,currencyOut:o._currencyOut,amountIn:BigInt(d.amountIn),minOut:BigInt(d.minOut),now:e,pools:JSON.parse(String(o._pools)),...s?{permit:s}:{}};if(t.kind==="launch"){let i=(r?_({abi:D,data:r.data}).args[0]:void 0)?.devBuyMaxCost??BigInt(d.amountIn??"0");if(i>BigInt(d.amountIn??"0"))throw new a("FOBO launch exceeds the approved initial-buy spending cap. Nothing further was signed.");return{kind:"launch",name:String(o.name),ticker:String(o.ticker).replace(/^\$/,"").toUpperCase(),pair:y(String(o.pair)).address,devBuyTokens:BigInt(d.devBuyTokens??0)*10n**18n,devBuyMaxCost:i,vestMonths:d.vestMonths??0,launchFeeWei:BigInt(d.launchFeeWei),now:e}}if(t.kind==="limitOrder"){if(!r)throw new a("FOBO order is missing its unsigned transaction.");let n=_({abi:M,data:r.data});if(n.functionName!=="place")throw new a("FOBO order must call place.");let i=n.args[5],k={"1h":3600,"1d":86400,"7d":604800,"30d":2592e3}[String(o.expiresIn??"7d")],O=BigInt(t.quotedAt+k);if(i<O-60n||i>BigInt(e+k)+60n)throw new a("FOBO changed the approved order expiry. Nothing further was signed.");return{kind:"limitOrder",side:o.side==="buy"?0:1,token:d.token,payToken:y(String(o.payWith)).address,amount:BigInt(d.amountIn),limitPriceUsdE18:K(String(o.limitMarketCapUsd),18)/1000000000n,expiry:i,maxFeePerFill:BigInt(String(o.maxFeePerFill))}}if(t.kind==="cancel")return{kind:"cancel",orderId:BigInt(String(o.orderId))};if(o.kind==="creator")return{kind:"claim",claimKind:"creator",poolKey:JSON.parse(String(o._poolKey))};if(o.kind==="referral")return{kind:"claim",claimKind:"referral",currency:y(String(o.pair)).address,recipient:o.to??t.wallet};if(o.kind==="vesting"&&r)return{kind:"claim",claimKind:"vesting",lockId:_({abi:C,data:r.data}).args[0],beneficiary:t.wallet};throw new a("FOBO claim does not match a supported claim kind.")}function ae(t){let e={...g(t)};if(e.status==="needs_signature"&&e.transactions===void 0&&(e.transactions=[]),!["ready","needs_approval","needs_signature"].includes(String(e.status))||!Array.isArray(e.transactions)||e.transactions.length>32)throw new a("FOBO returned an unsupported preparation. Nothing further was signed. Ask for a fresh summary.");return e}function se(t,e,r){let s=g(e);if(![4663,"0x1237"].includes(s.chainId)||String(s.from).toLowerCase()!==t.wallet.toLowerCase()||BigInt(String(s.value??"0"))!==0n)throw new a("FOBO approval has the wrong wallet, chain or ETH value. Nothing further was signed.");let o=_({abi:X,data:String(s.data)});if(o.functionName!=="approve")throw new a("FOBO requested something other than an approval.");let d=o.args[0],n=t.kind==="launch"?m.factory:t.kind==="limitOrder"?m.limitOrders:m.permit2;if(d.toLowerCase()!==n.toLowerCase()||String(s.to).toLowerCase()!==String(t.request._currencyIn).toLowerCase()||t.terms.amountIn===void 0)throw new a("FOBO approval does not match the approved token and spender. Nothing further was signed.");return N(e,{kind:"approval",token:x(String(s.to)),spender:d,amount:BigInt(t.terms.amountIn)},t.wallet)}async function de(t,e,r,s,o){if(e.status==="needs_signature"){if(e.transactions.length)throw new a("FOBO attached unexpected transactions to a signature request.");return[]}if(!e.transactions.length||t.kind!=="claim"&&e.transactions.length!==1)throw new a("FOBO returned an unexpected transaction count. Nothing further was signed.");if(e.status==="needs_approval"){if(!["buy","sell","launch","limitOrder"].includes(t.kind))throw new a("This FOBO action must not need an approval.");return e.transactions.map(n=>se(t,n,r))}if(e.transactions.some(n=>String(g(n).data).toLowerCase().startsWith("0x095ea7b3")))throw new a("FOBO attached an approval to a ready action. Ask for a fresh summary.");if(t.kind==="claim"&&t.request.kind==="vesting"){let n=o??E({chainId:4663}).readContract,i=V(["function getLock(uint256 id) view returns ((address token,uint64 start,uint32 duration,address beneficiary,uint256 amount,uint256 claimed))"]);for(let c of e.transactions){let k=_({abi:C,data:c.data}).args[0],O=await n({address:"0x51d217Ecf7c0e4EbF54258444B9617D012Fd7D0a",abi:i,functionName:"getLock",args:[k]});if(O.beneficiary.toLowerCase()!==t.wallet.toLowerCase()||O.token.toLowerCase()!==String(t.request.token).toLowerCase())throw new a("FOBO vesting lock does not belong to this wallet and token. Nothing further was signed.")}}let d=e.transactions.map(n=>N(n,ie(t,r,n,s),t.wallet));if(t.kind==="launch"){let n=BigInt(t.terms.launchFeeWei??"0"),i=t.request.pair==="eth"?n+BigInt(t.terms.amountIn??"0"):n;if(d.some(c=>BigInt(c.value)>i||BigInt(c.value)<n))throw new a("FOBO launch exceeds the approved spending cap or changed its fee. Nothing further was signed.")}if(typeof t.request._prepared=="string"){let n=JSON.parse(t.request._prepared);if(d.length!==n.length||d.some((i,c)=>i.to.toLowerCase()!==n[c].to.toLowerCase()||i.data.toLowerCase()!==n[c].data.toLowerCase()||BigInt(i.value)!==BigInt(n[c].value)))throw new a("FOBO changed the approved terms. Nothing further was signed. Ask for a fresh summary.")}return d}function ce(t){let e="Oak fee: 0 bps on FOBO\u2019s own route.";if(t.kind==="buy"||t.kind==="sell"){let r=t.terms.tokenPoolTaxPercentNow;if(typeof r!="number"||!Number.isFinite(r)||r<0||r>100)throw new a("FOBO quote did not identify its current tax.");return`${e} FOBO's tax right now: ${r}%; included in the quoted output and minimum.`}return t.kind==="launch"?`${e} FOBO launch fee: ${$(BigInt(t.terms.launchFeeWei),18)} ETH (${t.terms.launchFeeWei} wei).`:t.kind==="limitOrder"?`${e} FOBO keeper fee: at most ${t.request.maxFeePerFill} pay-token base units per fill. Pool tax applies when the order fills; the future tax is not known at preparation.`:`${e} No additional FOBO fee for this ${t.kind==="cancel"?"cancellation":"claim"}; network fees are additional.`}async function we(t,e,r,s){let o=Object.entries(ee).find(([,u])=>u===e)?.[0];if(!o||!Q(s,{strict:!1}))throw new a("Provide a valid FOBO action and local wallet.");let d=ne(o,r),n={};for(let[u,p]of Object.entries(d))n[u]=typeof p=="object"?JSON.stringify(p):p;let i={version:1,kind:e,wallet:x(s),chainId:4663,request:n,terms:{},quotedAt:Math.floor(Date.now()/1e3)};if(e==="launch"){n.pair??="eth",n.devBuyTokens??=0,n.vestMonths??=0;let u=g(g(await t.call("get_fee_schedule",{})).launch);if(u.launchesPaused===!0)throw new a("FOBO launches are paused. Nothing was signed.");let p=y(String(n.pair));n._currencyIn=p.address,n._inputDecimals=p.decimals,i.preparation={status:"ready",transactions:[]},i.terms={launchFeeWei:A(u.feeEth,18,"launch fee"),devBuyTokens:Number(n.devBuyTokens),vestMonths:Number(n.vestMonths),amountIn:String(n.maxInitialBuyAmount??"0")}}else if(e==="buy"||e==="sell"||e==="limitOrder"){n.payWith??=e==="limitOrder"?"eth":"pair";let u=String(n.payWith),p=g(await t.call("get_token",{token:n.token}));if(String(p.address).toLowerCase()!==String(n.token).toLowerCase())throw new a("FOBO token metadata does not match the requested token.");let H=y(String(p.pair).replace(/^\$/,"").toLowerCase());u==="pair"&&(u=String(p.pair).replace(/^\$/,"").toLowerCase());let F=y(u);n._payDecimals=F.decimals;let I=e==="limitOrder"?n.side:e;if(n._currencyIn=I==="sell"?String(n.token):F.address,n._currencyOut=I==="sell"?F.address:String(n.token),n._inputDecimals=I==="sell"?18:F.decimals,n._outputDecimals=I==="sell"?F.decimals:18,e!=="limitOrder"&&(n._pools=JSON.stringify(oe(x(String(n.token)),H.address,F.address,I==="sell"))),i.terms={token:x(String(n.token)),payWith:String(n.payWith),amountIn:String(n.amount)},BigInt(String(n.amount))===0n)throw new a("FOBO input amount must be positive.");if(e!=="limitOrder"){n.slippageBps??=50;let{account:J,...z}=W(i),h=g(await t.call("quote_trade",z)),G=A(h.amountIn,Number(n._inputDecimals),"quote input"),{minimum:q}=re(h,Number(n._outputDecimals),Number(n.slippageBps),u);if(G!==n.amount||BigInt(q)===0n||String(h.token).toLowerCase()!==String(n.token).toLowerCase()||h.side!==e)throw new a("FOBO quote does not match the requested trade. Nothing was signed.");if(i.terms.minOut=q,i.terms.slippageBps=Number(n.slippageBps),typeof h.tokenPoolTaxPercentNow!="number"||!Number.isFinite(h.tokenPoolTaxPercentNow)||h.tokenPoolTaxPercentNow<0||h.tokenPoolTaxPercentNow>100)throw new a("FOBO quote did not identify its current tax.");i.terms.tokenPoolTaxPercentNow=h.tokenPoolTaxPercentNow}}if(e==="claim"&&n.kind==="creator"){let u=g(await t.call("get_token",{token:n.token}));if(String(u.address).toLowerCase()!==String(n.token).toLowerCase())throw new a("FOBO claim token metadata does not match.");n._poolKey=JSON.stringify(S(y(String(u.pair).replace(/^\$/,"").toLowerCase()).address,x(String(n.token))))}if(e!=="launch"){let u=ae(await t.call(te[e],W(i))),p=await de(i,u,i.quotedAt);if(i.preparation={status:u.status,transactions:p},e==="cancel"||e==="claim"||e==="limitOrder"){if(u.status==="needs_signature")throw new a("This FOBO action must not need a permit signature.");u.status==="ready"&&(n._prepared=JSON.stringify(p))}}let c=e==="launch"?`Launch ${P(String(n.name))} (${P(String(n.ticker))}), pair ${n.pair}, initial buy ${n.devBuyTokens} tokens, lock ${n.vestMonths} months.`:e==="limitOrder"?`Place a FOBO ${n.side} order for ${n.token}, limit market cap ${n.limitMarketCapUsd} USD, expiry ${n.expiresIn??"7d"}, maximum keeper fee ${n.maxFeePerFill} pay-token base units per fill.`:e==="claim"?`Claim FOBO ${n.kind} earnings${n.token?` for ${n.token}`:` in ${n.pair}`} to ${n.to??s}.`:e==="cancel"?`Cancel FOBO order ${n.orderId} and refund ${s}.`:`${e} on FOBO for ${n.token}.`,k=e==="launch"?`Launch fee ${i.terms.launchFeeWei} wei; initial-buy spending cap ${i.terms.amountIn} pair-token base units.`:`Exact input ${i.terms.amountIn??"0"} base units.`,O=`${c}
1
+ import{a as R}from"./DFM4T6ZE.js";import{d as N}from"./MDLJFCT4.js";import{b as D,d as M,f as C}from"./4ZD5D2UP.js";import{t as E}from"./MQ5F2VOK.js";import{a}from"./XSD5NL7J.js";import{a as P}from"./JXOEJPJ4.js";import{decodeFunctionData as _,erc20Abi as X,formatUnits as $,getAddress as x,isAddress as Q,parseUnits as K,parseAbi as V,zeroAddress as f}from"viem";var be=300,m={permit2:"0x000000000022D473030F116dDEE9F6B43aC78BA3",router:"0x204FAca1764B154221e35c0d20aBb3c525710498",factory:"0xd7e538e98A208fD19e46bc549FF4710C33664e18",limitOrders:"0x3126f62d604a0AA2de8788e3eC21dDd8F2a2f82a",fobo:"0x000DE658153f47f23e92973C8EB1e89762703676",usdg:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"},T=["eth","fobo","usdg","msft","tsla","spcx","googl","amzn","aapl","nvda","meta"],b=(t,e=0)=>({type:"string",minLength:e,maxLength:t}),w=(t,e="string")=>({type:e,enum:t}),B={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},v={type:"string",pattern:"^[0-9]+$",description:"Exact input in token base units, as a decimal integer string."},U={type:"integer",minimum:1,maximum:100},L={token:B,amount:v,payWith:w(["pair","eth","usdg","fobo"]),slippageBps:{type:"integer",minimum:1,maximum:5e3}},Z={token:"FOBO coin contract address on chain 4663; obtain it from fobo_browse or fobo_token.",query:"Search FOBO coins and traders by name, ticker or address; omit to browse recent launches.",limit:"Maximum number of results, from 1 to 100.",side:"Trade direction: buy the coin or sell it back to the payment currency.",payWith:"Payment currency: pair uses the coin\u2019s own pair; trades also accept eth, usdg or fobo.",slippageBps:"Maximum loss against quoted output in basis points (50 = 0.5%); default 50.",hash:"Public transaction hash (0x followed by 64 hex digits) to look up on FOBO.",name:"New coin name, 1 to 32 characters.",ticker:"New coin ticker, 2 to 10 letters or digits; normalized to uppercase.",description:"Public description of the new coin, at most 280 characters.",imageUrl:"Optional public HTTPS image URL; omit for no image. Local uploads are unsupported.",links:"Optional public project links stored with the launched coin.",telegram:"Public Telegram URL.",discord:"Public Discord URL.",github:"Public GitHub URL.",website:"Public project website URL.",pair:"Pair currency: eth, fobo, usdg or a supported stock ticker; referral claims use this currency.",devBuyTokens:"Whole tokens in the initial buy, 0 to 50,000,000 (5% of supply); default 0.",vestMonths:"Initial-buy lock in months: 0, 1, 3, 6 or 12; default 0. A lock requires an initial buy.",limitMarketCapUsd:"Target market capitalization in whole USD, as a decimal string; not a per-token price.",expiresIn:"Order lifetime: 1h, 1d, 7d or 30d; default 7d.",maxFeePerFill:"Maximum keeper fee per fill in payment-token base units, as an exact decimal integer string.",orderId:"Positive numeric ID of the local wallet\u2019s limit order to cancel.",kind:"Claim creator fees, referral earnings or vesting tokens.",to:"Optional recipient address for a referral claim; omit for this wallet. Other claims always pay this wallet."},l=(t,e=[])=>({type:"object",additionalProperties:!1,required:e,properties:Object.fromEntries(Object.entries(t).map(([r,s])=>{let o=s;return[r,{...o,description:o.description??Z[r]}]}))}),Y={fobo_browse:l({query:b(64,1),limit:U}),fobo_token:l({token:B},["token"]),fobo_portfolio:l({}),fobo_leaderboard:l({limit:U}),fobo_claims:l({}),fobo_limit_orders:l({token:B}),fobo_quote:l({...L,side:w(["buy","sell"])},["token","side","amount"]),fobo_fee_schedule:l({}),fobo_limit_pay_tokens:l({}),fobo_transaction:l({hash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"}},["hash"]),fobo_buy:l(L,["token","amount"]),fobo_sell:l(L,["token","amount"]),fobo_launch:l({name:b(32,1),ticker:{type:"string",pattern:"^\\$?[a-zA-Z0-9]{2,10}$"},description:b(280),imageUrl:{...b(2e3),pattern:"^https://"},links:l({telegram:b(200),discord:b(200),github:b(200),website:b(200)}),pair:w(T),devBuyTokens:{type:"integer",minimum:0,maximum:5e7},vestMonths:w([0,1,3,6,12],"integer"),maxInitialBuyAmount:{...v,description:"Maximum pair-token base units to spend on the initial buy, excluding the live launch fee. Required when devBuyTokens is positive."}},["name","ticker"]),fobo_limit_order:l({token:B,side:w(["buy","sell"]),payWith:b(42,2),amount:v,limitMarketCapUsd:{type:"string",pattern:"^\\d{1,30}(\\.\\d{1,18})?$"},expiresIn:w(["1h","1d","7d","30d"]),maxFeePerFill:v},["token","side","amount","limitMarketCapUsd","maxFeePerFill"]),fobo_cancel_limit_order:l({orderId:{type:"integer",minimum:1,maximum:Number.MAX_SAFE_INTEGER}},["orderId"]),fobo_claim:l({kind:w(["creator","referral","vesting"]),token:B,pair:w(T),to:B},["kind"])},ee={fobo_buy:"buy",fobo_sell:"sell",fobo_launch:"launch",fobo_limit_order:"limitOrder",fobo_cancel_limit_order:"cancel",fobo_claim:"claim"},te={buy:"prepare_trade",sell:"prepare_trade",launch:"prepare_launch",limitOrder:"prepare_limit_order",cancel:"prepare_cancel_limit_order",claim:"prepare_claim"};function g(t){if(!t||typeof t!="object"||Array.isArray(t))throw new a("FOBO returned an invalid answer. Ask for a fresh summary.");return t}function ne(t,e){function r(s,o){let d=s.properties;if(Object.keys(o).some(n=>!Object.hasOwn(d,n)))throw new a("Unexpected FOBO argument. Use the fields declared by the tool.");for(let n of s.required)if(o[n]===void 0)throw new a(`Missing FOBO argument: ${n}.`);for(let[n,i]of Object.entries(o)){let c=d[n];if(c.type==="object"){r(c,g(i));continue}if(c.type==="integer"){if(typeof i!="number"||!Number.isSafeInteger(i)||i<Number(c.minimum??0)||i>Number(c.maximum??Number.MAX_SAFE_INTEGER))throw new a(`Invalid FOBO argument: ${n}.`)}else if(typeof i!="string"||i.length<Number(c.minLength??0)||i.length>Number(c.maxLength??256)||typeof c.pattern=="string"&&!new RegExp(c.pattern).test(i))throw new a(`Invalid FOBO argument: ${n}.`);if(Array.isArray(c.enum)&&!c.enum.includes(i))throw new a(`Invalid FOBO argument: ${n}.`)}}if(r(Y[t],g(e)),t==="fobo_claim"&&(e.kind==="referral"?e.pair===void 0:e.token===void 0))throw new a("Referral claims need pair; creator and vesting claims need token.");if(t==="fobo_claim"&&e.kind!=="referral"&&e.to!==void 0)throw new a("Only referral claims may name another recipient.");if(t==="fobo_launch"){if(Number(e.vestMonths??0)>0&&Number(e.devBuyTokens??0)===0)throw new a("A vesting lock needs an initial buy.");if(Number(e.devBuyTokens??0)>0&&(typeof e.maxInitialBuyAmount!="string"||BigInt(e.maxInitialBuyAmount)===0n))throw new a("An initial buy needs maxInitialBuyAmount in pair-token base units. Ask the person for that spending cap.");if(e.imageUrl!==void 0){let s=new URL(String(e.imageUrl));if(s.protocol!=="https:"||s.username||s.password)throw new a("Use a public https image URL.")}}return structuredClone(e)}function y(t){let e=t.toLowerCase();if(e===f||e==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")return{address:f,decimals:18};if(e===m.usdg.toLowerCase())return{address:m.usdg,decimals:6};if(e===m.fobo.toLowerCase())return{address:m.fobo,decimals:18};if(t==="eth")return{address:f,decimals:18};if(t==="usdg")return{address:m.usdg,decimals:6};if(t==="fobo")return{address:m.fobo,decimals:18};let r=R.tokens.find(s=>T.includes(t)&&s.symbol.toLowerCase()===t||s.token.toLowerCase()===e);if(r)return{address:x(r.token),decimals:18};throw new a("FOBO did not identify a supported pair currency. Ask for token details first.")}function A(t,e,r){if(typeof t!="string"||!/^\d{1,78}(\.\d{1,18})?$/.test(t)||(t.split(".")[1]?.length??0)>e)throw new a(`FOBO returned an invalid ${r}. Ask for a fresh quote.`);return K(t,e).toString()}function re(t,e,r,s){if(String(t.payWith).replace(/^\$/,"").toLowerCase()!==s.toLowerCase())throw new a("FOBO quote payment currency differs from the request.");if(t.slippageBps!==r)throw new a("FOBO quote slippage differs from the request.");let o=A(t.expectedOut,e,"quote output"),d=A(t.minOut,e,"quote minimum"),n=BigInt(o)*BigInt(1e4-r)/10000n;if(BigInt(d)<=0n||BigInt(d)>BigInt(o)||BigInt(d)<n)throw new a("FOBO quote minimum exceeds the approved slippage loss.");return{amountOut:o,minimum:d}}function W(t){let e=Object.fromEntries(Object.entries(t.request).filter(([r])=>!r.startsWith("_")&&r!=="maxInitialBuyAmount"));return typeof e.links=="string"&&(e.links=JSON.parse(e.links)),e.amount!==void 0&&(e.amount=$(BigInt(String(e.amount)),Number(t.request._inputDecimals))),e.maxFeePerFill!==void 0&&(e.maxFeePerFill=$(BigInt(String(e.maxFeePerFill)),Number(t.request._payDecimals))),(t.kind==="buy"||t.kind==="sell")&&(e.side=t.kind),t.kind==="claim"&&e.pair!==void 0&&(e.currency=e.pair,delete e.pair),{...e,account:t.wallet}}function S(t,e,r="0x0Af57F62982D03066ef917AcAd87F771c06528Ec"){let[s,o]=BigInt(t)<BigInt(e)?[t,e]:[e,t];return{currency0:s,currency1:o,fee:r===f?500:0,tickSpacing:r===f?10:60,hooks:r}}function j(t,e){let r=t===f?e:t;if(t!==f&&e!==f)throw new a("FOBO base-currency routes must pass through ETH.");if(r.toLowerCase()===m.usdg.toLowerCase())return S(t,e,f);if(r.toLowerCase()===m.fobo.toLowerCase())return S(t,e);throw new a("FOBO has not pinned a route between this pair and ETH. Use the token\u2019s own pair.")}function oe(t,e,r,s){let o=[];return r.toLowerCase()!==e.toLowerCase()&&(r!==f&&o.push(j(r,f)),e!==f&&o.push(j(f,e))),o.push(S(e,t)),s?o.reverse():o}function ie(t,e,r,s){let o=t.request,d=t.terms;if(t.kind==="buy"||t.kind==="sell")return{kind:"trade",currencyIn:o._currencyIn,currencyOut:o._currencyOut,amountIn:BigInt(d.amountIn),minOut:BigInt(d.minOut),now:e,pools:JSON.parse(String(o._pools)),...s?{permit:s}:{}};if(t.kind==="launch"){let i=(r?_({abi:D,data:r.data}).args[0]:void 0)?.devBuyMaxCost??BigInt(d.amountIn??"0");if(i>BigInt(d.amountIn??"0"))throw new a("FOBO launch exceeds the approved initial-buy spending cap. Nothing further was signed.");return{kind:"launch",name:String(o.name),ticker:String(o.ticker).replace(/^\$/,"").toUpperCase(),pair:y(String(o.pair)).address,devBuyTokens:BigInt(d.devBuyTokens??0)*10n**18n,devBuyMaxCost:i,vestMonths:d.vestMonths??0,launchFeeWei:BigInt(d.launchFeeWei),now:e}}if(t.kind==="limitOrder"){if(!r)throw new a("FOBO order is missing its unsigned transaction.");let n=_({abi:M,data:r.data});if(n.functionName!=="place")throw new a("FOBO order must call place.");let i=n.args[5],k={"1h":3600,"1d":86400,"7d":604800,"30d":2592e3}[String(o.expiresIn??"7d")],O=BigInt(t.quotedAt+k);if(i<O-60n||i>BigInt(e+k)+60n)throw new a("FOBO changed the approved order expiry. Nothing further was signed.");return{kind:"limitOrder",side:o.side==="buy"?0:1,token:d.token,payToken:y(String(o.payWith)).address,amount:BigInt(d.amountIn),limitPriceUsdE18:K(String(o.limitMarketCapUsd),18)/1000000000n,expiry:i,maxFeePerFill:BigInt(String(o.maxFeePerFill))}}if(t.kind==="cancel")return{kind:"cancel",orderId:BigInt(String(o.orderId))};if(o.kind==="creator")return{kind:"claim",claimKind:"creator",poolKey:JSON.parse(String(o._poolKey))};if(o.kind==="referral")return{kind:"claim",claimKind:"referral",currency:y(String(o.pair)).address,recipient:o.to??t.wallet};if(o.kind==="vesting"&&r)return{kind:"claim",claimKind:"vesting",lockId:_({abi:C,data:r.data}).args[0],beneficiary:t.wallet};throw new a("FOBO claim does not match a supported claim kind.")}function ae(t){let e={...g(t)};if(e.status==="needs_signature"&&e.transactions===void 0&&(e.transactions=[]),!["ready","needs_approval","needs_signature"].includes(String(e.status))||!Array.isArray(e.transactions)||e.transactions.length>32)throw new a("FOBO returned an unsupported preparation. Nothing further was signed. Ask for a fresh summary.");return e}function se(t,e,r){let s=g(e);if(![4663,"0x1237"].includes(s.chainId)||String(s.from).toLowerCase()!==t.wallet.toLowerCase()||BigInt(String(s.value??"0"))!==0n)throw new a("FOBO approval has the wrong wallet, chain or ETH value. Nothing further was signed.");let o=_({abi:X,data:String(s.data)});if(o.functionName!=="approve")throw new a("FOBO requested something other than an approval.");let d=o.args[0],n=t.kind==="launch"?m.factory:t.kind==="limitOrder"?m.limitOrders:m.permit2;if(d.toLowerCase()!==n.toLowerCase()||String(s.to).toLowerCase()!==String(t.request._currencyIn).toLowerCase()||t.terms.amountIn===void 0)throw new a("FOBO approval does not match the approved token and spender. Nothing further was signed.");return N(e,{kind:"approval",token:x(String(s.to)),spender:d,amount:BigInt(t.terms.amountIn)},t.wallet)}async function de(t,e,r,s,o){if(e.status==="needs_signature"){if(e.transactions.length)throw new a("FOBO attached unexpected transactions to a signature request.");return[]}if(!e.transactions.length||t.kind!=="claim"&&e.transactions.length!==1)throw new a("FOBO returned an unexpected transaction count. Nothing further was signed.");if(e.status==="needs_approval"){if(!["buy","sell","launch","limitOrder"].includes(t.kind))throw new a("This FOBO action must not need an approval.");return e.transactions.map(n=>se(t,n,r))}if(e.transactions.some(n=>String(g(n).data).toLowerCase().startsWith("0x095ea7b3")))throw new a("FOBO attached an approval to a ready action. Ask for a fresh summary.");if(t.kind==="claim"&&t.request.kind==="vesting"){let n=o??E({chainId:4663}).readContract,i=V(["function getLock(uint256 id) view returns ((address token,uint64 start,uint32 duration,address beneficiary,uint256 amount,uint256 claimed))"]);for(let c of e.transactions){let k=_({abi:C,data:c.data}).args[0],O=await n({address:"0x51d217Ecf7c0e4EbF54258444B9617D012Fd7D0a",abi:i,functionName:"getLock",args:[k]});if(O.beneficiary.toLowerCase()!==t.wallet.toLowerCase()||O.token.toLowerCase()!==String(t.request.token).toLowerCase())throw new a("FOBO vesting lock does not belong to this wallet and token. Nothing further was signed.")}}let d=e.transactions.map(n=>N(n,ie(t,r,n,s),t.wallet));if(t.kind==="launch"){let n=BigInt(t.terms.launchFeeWei??"0"),i=t.request.pair==="eth"?n+BigInt(t.terms.amountIn??"0"):n;if(d.some(c=>BigInt(c.value)>i||BigInt(c.value)<n))throw new a("FOBO launch exceeds the approved spending cap or changed its fee. Nothing further was signed.")}if(typeof t.request._prepared=="string"){let n=JSON.parse(t.request._prepared);if(d.length!==n.length||d.some((i,c)=>i.to.toLowerCase()!==n[c].to.toLowerCase()||i.data.toLowerCase()!==n[c].data.toLowerCase()||BigInt(i.value)!==BigInt(n[c].value)))throw new a("FOBO changed the approved terms. Nothing further was signed. Ask for a fresh summary.")}return d}function ce(t){let e="Oak fee: 0 bps on FOBO\u2019s own route.";if(t.kind==="buy"||t.kind==="sell"){let r=t.terms.tokenPoolTaxPercentNow;if(typeof r!="number"||!Number.isFinite(r)||r<0||r>100)throw new a("FOBO quote did not identify its current tax.");return`${e} FOBO's tax right now: ${r}%; included in the quoted output and minimum.`}return t.kind==="launch"?`${e} FOBO launch fee: ${$(BigInt(t.terms.launchFeeWei),18)} ETH (${t.terms.launchFeeWei} wei).`:t.kind==="limitOrder"?`${e} FOBO keeper fee: at most ${t.request.maxFeePerFill} pay-token base units per fill. Pool tax applies when the order fills; the future tax is not known at preparation.`:`${e} No additional FOBO fee for this ${t.kind==="cancel"?"cancellation":"claim"}; network fees are additional.`}async function we(t,e,r,s){let o=Object.entries(ee).find(([,u])=>u===e)?.[0];if(!o||!Q(s,{strict:!1}))throw new a("Provide a valid FOBO action and local wallet.");let d=ne(o,r),n={};for(let[u,p]of Object.entries(d))n[u]=typeof p=="object"?JSON.stringify(p):p;let i={version:1,kind:e,wallet:x(s),chainId:4663,request:n,terms:{},quotedAt:Math.floor(Date.now()/1e3)};if(e==="launch"){n.pair??="eth",n.devBuyTokens??=0,n.vestMonths??=0;let u=g(g(await t.call("get_fee_schedule",{})).launch);if(u.launchesPaused===!0)throw new a("FOBO launches are paused. Nothing was signed.");let p=y(String(n.pair));n._currencyIn=p.address,n._inputDecimals=p.decimals,i.preparation={status:"ready",transactions:[]},i.terms={launchFeeWei:A(u.feeEth,18,"launch fee"),devBuyTokens:Number(n.devBuyTokens),vestMonths:Number(n.vestMonths),amountIn:String(n.maxInitialBuyAmount??"0")}}else if(e==="buy"||e==="sell"||e==="limitOrder"){n.payWith??=e==="limitOrder"?"eth":"pair";let u=String(n.payWith),p=g(await t.call("get_token",{token:n.token}));if(String(p.address).toLowerCase()!==String(n.token).toLowerCase())throw new a("FOBO token metadata does not match the requested token.");let H=y(String(p.pair).replace(/^\$/,"").toLowerCase());u==="pair"&&(u=String(p.pair).replace(/^\$/,"").toLowerCase());let F=y(u);n._payDecimals=F.decimals;let I=e==="limitOrder"?n.side:e;if(n._currencyIn=I==="sell"?String(n.token):F.address,n._currencyOut=I==="sell"?F.address:String(n.token),n._inputDecimals=I==="sell"?18:F.decimals,n._outputDecimals=I==="sell"?F.decimals:18,e!=="limitOrder"&&(n._pools=JSON.stringify(oe(x(String(n.token)),H.address,F.address,I==="sell"))),i.terms={token:x(String(n.token)),payWith:String(n.payWith),amountIn:String(n.amount)},BigInt(String(n.amount))===0n)throw new a("FOBO input amount must be positive.");if(e!=="limitOrder"){n.slippageBps??=50;let{account:J,...z}=W(i),h=g(await t.call("quote_trade",z)),G=A(h.amountIn,Number(n._inputDecimals),"quote input"),{minimum:q}=re(h,Number(n._outputDecimals),Number(n.slippageBps),u);if(G!==n.amount||BigInt(q)===0n||String(h.token).toLowerCase()!==String(n.token).toLowerCase()||h.side!==e)throw new a("FOBO quote does not match the requested trade. Nothing was signed.");if(i.terms.minOut=q,i.terms.slippageBps=Number(n.slippageBps),typeof h.tokenPoolTaxPercentNow!="number"||!Number.isFinite(h.tokenPoolTaxPercentNow)||h.tokenPoolTaxPercentNow<0||h.tokenPoolTaxPercentNow>100)throw new a("FOBO quote did not identify its current tax.");i.terms.tokenPoolTaxPercentNow=h.tokenPoolTaxPercentNow}}if(e==="claim"&&n.kind==="creator"){let u=g(await t.call("get_token",{token:n.token}));if(String(u.address).toLowerCase()!==String(n.token).toLowerCase())throw new a("FOBO claim token metadata does not match.");n._poolKey=JSON.stringify(S(y(String(u.pair).replace(/^\$/,"").toLowerCase()).address,x(String(n.token))))}if(e!=="launch"){let u=ae(await t.call(te[e],W(i))),p=await de(i,u,i.quotedAt);if(i.preparation={status:u.status,transactions:p},e==="cancel"||e==="claim"||e==="limitOrder"){if(u.status==="needs_signature")throw new a("This FOBO action must not need a permit signature.");u.status==="ready"&&(n._prepared=JSON.stringify(p))}}let c=e==="launch"?`Launch ${P(String(n.name))} (${P(String(n.ticker))}), pair ${n.pair}, initial buy ${n.devBuyTokens} tokens, lock ${n.vestMonths} months.`:e==="limitOrder"?`Place a FOBO ${n.side} order for ${n.token}, limit market cap ${n.limitMarketCapUsd} USD, expiry ${n.expiresIn??"7d"}, maximum keeper fee ${n.maxFeePerFill} pay-token base units per fill.`:e==="claim"?`Claim FOBO ${n.kind} earnings${n.token?` for ${n.token}`:` in ${n.pair}`} to ${n.to??s}.`:e==="cancel"?`Cancel FOBO order ${n.orderId} and refund ${s}.`:`${e} on FOBO for ${n.token}.`,k=e==="launch"?`Launch fee ${i.terms.launchFeeWei} wei; initial-buy spending cap ${i.terms.amountIn} pair-token base units.`:`Exact input ${i.terms.amountIn??"0"} base units.`,O=`${c}
2
2
  Leaves wallet: ${k}
3
3
  Comes back: ${i.terms.minOut?`at least ${i.terms.minOut} output base units`:e==="launch"?"the launched token and any initial buy, subject to the stated lock":"the approved order or claim proceeds to the named recipient"}.
4
4
  Fees: no Oak swap fee on FOBO's route. ${ce(i)}
@@ -1,3 +1,3 @@
1
- import{a as o,b as C,c as K,d as F,e as E,f as D}from"./4ZD5D2UP.js";import{h as H}from"./BSX4LFYI.js";import{c as U}from"./43LI5NKJ.js";import{e as N,g as R,h as l}from"./NWNYJ26T.js";import{a as P}from"./XSD5NL7J.js";import{decodeFunctionData as y,encodeFunctionData as k,erc20Abi as _,getAddress as q,isAddress as G,zeroAddress as h}from"viem";var X=15000000n,j=1200,L="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",w=n=>(1n<<BigInt(n))-1n;function S(n){throw new P(`FOBO ${n}. Nothing was signed. Ask for a fresh summary.`)}function i(n,e){n||S(e)}function I(n,e){return i(typeof n=="string"&&G(n,{strict:!1}),e),q(n)}function m(n,e,s){i(l(I(n,s),I(e,s)),s)}function T(n,e,s=256){i(typeof n=="string"&&n.length<=80&&/^(?:[0-9]+|0x[0-9a-fA-F]+)$/.test(n),`${e} must be an unsigned integer`);let r=BigInt(n);return i(r<=w(s),`${e} is too large`),r}function p(n,e,s=256){return i(typeof n=="bigint"&&n>=0n&&n<=w(s),`${e} is invalid`),n}function B(n){i(Number.isSafeInteger(n)&&n>=0&&n<=Number(w(48))-1800,"clock is invalid")}var $=120;function v(n,e){i(R(n,e),"calldata must be canonical")}function M(n,e){return l(n.currency0,e.currency0)&&l(n.currency1,e.currency1)&&l(n.hooks,e.hooks)&&n.fee===e.fee&&n.tickSpacing===e.tickSpacing}function z(n){i([o.permit2,o.factory,o.limitOrders].some(e=>l(n,e)),"approval spender is not pinned")}function J(n,e,s){let r=I(n,"approval token is invalid");return i(r!==h&&!l(r,L),"approval token cannot be native ETH"),z(I(e,"approval spender is invalid")),i(p(s,"approval amount")<w(256),"approval amount cannot be unlimited"),U(r,q(e),s.toString(),o.chainId)}function oe(n){let e=I(n.token,"permit token is invalid");i(e!==h&&!l(e,L),"permit token cannot be native ETH"),i(p(n.amount,"permit amount",160)>0n&&n.amount<w(160),"permit amount must be exact and positive"),i(Number.isSafeInteger(n.nonce)&&n.nonce>=0&&n.nonce<=Number(w(48)),"permit nonce is invalid"),B(n.now);let s=n.now+j;return{domain:{name:"Permit2",chainId:o.chainId,verifyingContract:o.permit2},types:{PermitDetails:[{name:"token",type:"address"},{name:"amount",type:"uint160"},{name:"expiration",type:"uint48"},{name:"nonce",type:"uint48"}],PermitSingle:[{name:"details",type:"PermitDetails"},{name:"spender",type:"address"},{name:"sigDeadline",type:"uint256"}]},primaryType:"PermitSingle",message:{details:{token:e,amount:n.amount.toString(),expiration:s,nonce:n.nonce},spender:o.router,sigDeadline:s.toString()}}}function re(n,e,s){try{return Q(n,e,s)}catch(r){if(r instanceof P&&r.message.startsWith("FOBO ")&&r.message.includes("Nothing was signed."))throw r;S("transaction could not be decoded and verified")}}function Q(n,e,s){i(N(n),"transaction is invalid"),i(n.chainId===o.chainId||n.chainId==="0x1237","chain must be 4663"),m(n.from,s,"wallet does not match the transaction sender");let r=I(n.to,"contract address is invalid");i(typeof n.data=="string"&&/^0x(?:[0-9a-fA-F]{2}){4,}$/.test(n.data),"selector or calldata is invalid");let d=T(n.value,"value"),u=T(n.gas,"gas");i(u>=21000n&&u<=X,"gas is outside the signing ceiling");let O=n.data.slice(0,10).toLowerCase(),f=(t,a)=>{m(r,t,"contract does not match the approved action"),i(O===a,"selector is not pinned for this contract")},A;switch(e.kind){case"approval":{i(l(r,e.token),"approval token differs from the approved input"),i(O===o.selectors.approve,"selector is not an ERC-20 approval"),i(d===0n,"approval value must be zero");let t=y({abi:_,data:n.data});i(t.functionName==="approve","selector is not an ERC-20 approval"),v(n.data,k({abi:_,functionName:"approve",args:t.args}));let[a]=t.args;return z(a),m(a,e.spender,"approval spender differs from the approved action"),{...J(r,a,e.amount),gasLimit:u.toString()}}case"trade":{f(o.router,o.selectors.execute),B(e.now);let t=H(n.data,[o.hook,h]);i(e.pools.length>0&&t.legs.length===e.pools.length&&t.legs.some(c=>l(c.poolKey.hooks,o.hook))&&t.legs.every((c,b)=>M(c.poolKey,e.pools[b])),"swap pools differ from the approved route");let a={currency0:h,currency1:o.usdg,fee:500,tickSpacing:10,hooks:h};if(i(t.legs.every(c=>l(c.poolKey.hooks,o.hook)||M(c.poolKey,a)),"swap contains an unsupported hookless pool"),m(t.currencyIn,e.currencyIn,"swap input currency differs"),m(t.currencyOut,e.currencyOut,"swap output currency differs"),i(t.amountIn===p(e.amountIn,"swap amount")&&t.amountIn>0n,"swap input amount differs"),i(t.amountOutMinimum>=p(e.minOut,"minimum output")&&e.minOut>0n,"swap minimum output is below the approved minimum"),i(t.deadline>BigInt(e.now)&&t.deadline<=BigInt(e.now+1200+$),"swap deadline must be within 20 minutes"),i(d===(l(e.currencyIn,h)?e.amountIn:0n),"swap ETH value differs from the approved input"),t.permit){let c=e.permit;i(c,"swap encodes an unexpected permit"),m(c.details.token,e.currencyIn,"permit token differs from the trade input"),i(T(c.details.amount,"permit amount",160)===e.amountIn&&e.amountIn<w(160),"permit amount differs from the exact trade input"),m(c.spender,o.router,"permit spender must be the Universal Router");let b=T(c.sigDeadline,"permit deadline");i(Number.isSafeInteger(c.details.expiration)&&c.details.expiration>e.now&&BigInt(c.details.expiration)<=b&&b>=BigInt(e.now+300)&&b<=BigInt(e.now+1800),"permit expiration or signature deadline is outside the signing window");let g=t.permit;i(l(g.token,c.details.token)&&g.amount===e.amountIn&&g.expiration===c.details.expiration&&g.nonce===c.details.nonce&&l(g.spender,c.spender)&&g.sigDeadline===b,"swap permit differs from the locally signed exact permit")}else i(!e.permit,"swap omitted the locally signed permit");A=`FOBO swap: exact input ${t.amountIn}; minimum output ${t.amountOutMinimum}.`;break}case"launch":{f(o.factory,o.selectors.launch),B(e.now);let t=y({abi:C,data:n.data});v(n.data,k({abi:C,...t}));let[a]=t.args;i(a.name===e.name&&a.ticker===e.ticker,"launch name or ticker differs from the approved launch"),m(a.quote,e.pair,"launch pair differs from the approved launch"),i(a.devBuyTokens===p(e.devBuyTokens,"initial buy")&&a.devBuyTokens<=50000000n*10n**18n&&a.devBuyMaxCost===p(e.devBuyMaxCost,"initial buy cost"),"launch initial buy or cost differs"),i(a.vestMonths===e.vestMonths&&[0,1,3,6,12].includes(a.vestMonths)&&(a.vestMonths===0||a.devBuyTokens>0n),"launch lock months differ"),i(a.deadline>BigInt(e.now)&&a.deadline<=BigInt(e.now+900+$),"launch deadline must be within 15 minutes"),i(d===p(e.launchFeeWei,"launch fee")+(l(a.quote,h)?a.devBuyMaxCost:0n),"launch ETH value differs from its fee plus initial buy"),A="Launch the approved FOBO token with its approved initial buy and lock.";break}case"limitOrder":{f(o.limitOrders,o.selectors.place);let t=y({abi:F,data:n.data});i(t.functionName==="place","selector is not place"),v(n.data,k({abi:F,...t}));let[a,c,b,g,W,V,Z]=t.args;i((a===0||a===1)&&a===e.side,"limit order side differs"),m(c,e.token,"limit order token differs"),m(b,e.payToken,"limit order pay token differs"),i(g===p(e.amount,"order amount")&&g>0n&&W===p(e.limitPriceUsdE18,"limit price")&&V===p(e.expiry,"order expiry")&&Z===p(e.maxFeePerFill,"keeper fee"),"limit order amount, price, expiry or keeper fee differs"),i(d===(a===0&&l(b,h)?g:0n),"limit order ETH value differs from its native escrow"),A="Place the approved FOBO limit order; escrow refunds and fills belong to this wallet.";break}case"cancel":{f(o.limitOrders,o.selectors.cancel),i(d===0n,"cancel value must be zero");let t=y({abi:F,data:n.data});i(t.functionName==="cancel","selector is not cancel"),v(n.data,k({abi:F,...t})),i(t.args[0]===p(e.orderId,"order id"),"cancel order differs"),m(t.args[1],s,"cancel recipient must be this wallet"),A="Cancel the approved FOBO order and refund this wallet.";break}case"claim":{if(i(d===0n,"claim value must be zero"),e.claimKind==="creator"){f(o.hook,o.selectors.claimCreator);let t=y({abi:K,data:n.data});v(n.data,k({abi:K,...t})),i(M(t.args[0],e.poolKey)&&l(t.args[0].hooks,o.hook),"creator claim pool differs"),m(t.args[1],s,"creator claim recipient must be this wallet")}else if(e.claimKind==="referral"){f(o.revenue,o.selectors.claimReferral);let t=y({abi:E,data:n.data});v(n.data,k({abi:E,...t})),m(t.args[0],s,"referral claim account must be this wallet"),m(t.args[1],e.currency,"referral claim currency differs"),m(t.args[2],e.recipient??s,"referral claim recipient differs from the approved recipient")}else{i(e.claimKind==="vesting","claim kind is unsupported"),f(o.vesting,o.selectors.claimVesting);let t=y({abi:D,data:n.data});v(n.data,k({abi:D,...t})),i(t.args[0]===p(e.lockId,"vesting lock"),"vesting lock differs"),m(e.beneficiary,s,"vesting beneficiary must be this wallet")}A="Claim the approved FOBO earnings to their approved recipient.";break}default:S("transaction expectation is unsupported")}return{to:r,data:n.data,value:d.toString(),chainId:o.chainId,gasLimit:u.toString(),description:A}}function ae(n,e,s){let r="sign-in message is not a fresh fobo.fun sign-in for this wallet";try{B(s),i(typeof n=="string"&&n.length<=2048&&!/[\r\p{Cc}\p{Cf}]/u.test(n.replaceAll(`
1
+ import{a as o,b as C,c as K,d as F,e as E,f as D}from"./4ZD5D2UP.js";import{h as H}from"./BSX4LFYI.js";import{c as U}from"./43LI5NKJ.js";import{e as N,g as R,h as l}from"./NWNYJ26T.js";import{a as P}from"./XSD5NL7J.js";import{decodeFunctionData as y,encodeFunctionData as k,erc20Abi as _,getAddress as q,isAddress as G,zeroAddress as h}from"viem";var X=15000000n,j=1200,L="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",w=n=>(1n<<BigInt(n))-1n;function S(n){throw new P(`FOBO ${n}. Nothing was signed. Ask for a fresh summary.`)}function i(n,e){n||S(e)}function I(n,e){return i(typeof n=="string"&&G(n,{strict:!1}),e),q(n)}function m(n,e,s){i(l(I(n,s),I(e,s)),s)}function T(n,e,s=256){i(typeof n=="string"&&n.length<=80&&/^(?:[0-9]+|0x[0-9a-fA-F]+)$/.test(n),`${e} must be an unsigned integer`);let r=BigInt(n);return i(r<=w(s),`${e} is too large`),r}function p(n,e,s=256){return i(typeof n=="bigint"&&n>=0n&&n<=w(s),`${e} is invalid`),n}function B(n){i(Number.isSafeInteger(n)&&n>=0&&n<=Number(w(48))-1800,"clock is invalid")}var $=120;function v(n,e){i(R(n,e),"calldata must be canonical")}function M(n,e){return l(n.currency0,e.currency0)&&l(n.currency1,e.currency1)&&l(n.hooks,e.hooks)&&n.fee===e.fee&&n.tickSpacing===e.tickSpacing}function W(n){i([o.permit2,o.factory,o.limitOrders].some(e=>l(n,e)),"approval spender is not pinned")}function J(n,e,s){let r=I(n,"approval token is invalid");return i(r!==h&&!l(r,L),"approval token cannot be native ETH"),W(I(e,"approval spender is invalid")),i(p(s,"approval amount")<w(256),"approval amount cannot be unlimited"),U(r,q(e),s.toString(),o.chainId)}function oe(n){let e=I(n.token,"permit token is invalid");i(e!==h&&!l(e,L),"permit token cannot be native ETH"),i(p(n.amount,"permit amount",160)>0n&&n.amount<w(160),"permit amount must be exact and positive"),i(Number.isSafeInteger(n.nonce)&&n.nonce>=0&&n.nonce<=Number(w(48)),"permit nonce is invalid"),B(n.now);let s=n.now+j;return{domain:{name:"Permit2",chainId:o.chainId,verifyingContract:o.permit2},types:{PermitDetails:[{name:"token",type:"address"},{name:"amount",type:"uint160"},{name:"expiration",type:"uint48"},{name:"nonce",type:"uint48"}],PermitSingle:[{name:"details",type:"PermitDetails"},{name:"spender",type:"address"},{name:"sigDeadline",type:"uint256"}]},primaryType:"PermitSingle",message:{details:{token:e,amount:n.amount.toString(),expiration:s,nonce:n.nonce},spender:o.router,sigDeadline:s.toString()}}}function re(n,e,s){try{return Q(n,e,s)}catch(r){if(r instanceof P&&r.message.startsWith("FOBO ")&&r.message.includes("Nothing was signed."))throw r;S("transaction could not be decoded and verified")}}function Q(n,e,s){i(N(n),"transaction is invalid"),i(n.chainId===o.chainId||n.chainId==="0x1237","chain must be 4663"),m(n.from,s,"wallet does not match the transaction sender");let r=I(n.to,"contract address is invalid");i(typeof n.data=="string"&&/^0x(?:[0-9a-fA-F]{2}){4,}$/.test(n.data),"selector or calldata is invalid");let d=T(n.value,"value"),c=T(n.gas,"gas");i(c>=21000n&&c<=X,"gas is outside the signing ceiling");let O=n.data.slice(0,10).toLowerCase(),f=(t,a)=>{m(r,t,"contract does not match the approved action"),i(O===a,"selector is not pinned for this contract")},A;switch(e.kind){case"approval":{i(l(r,e.token),"approval token differs from the approved input"),i(O===o.selectors.approve,"selector is not an ERC-20 approval"),i(d===0n,"approval value must be zero");let t=y({abi:_,data:n.data});i(t.functionName==="approve","selector is not an ERC-20 approval"),v(n.data,k({abi:_,functionName:"approve",args:t.args}));let[a]=t.args;return W(a),m(a,e.spender,"approval spender differs from the approved action"),{...J(r,a,e.amount),gasLimit:c.toString()}}case"trade":{f(o.router,o.selectors.execute),B(e.now);let t=H(n.data,[o.hook,h]);i(e.pools.length>0&&t.legs.length===e.pools.length&&t.legs.some(u=>l(u.poolKey.hooks,o.hook))&&t.legs.every((u,b)=>M(u.poolKey,e.pools[b])),"swap pools differ from the approved route");let a={currency0:h,currency1:o.usdg,fee:500,tickSpacing:10,hooks:h};if(i(t.legs.every(u=>l(u.poolKey.hooks,o.hook)||M(u.poolKey,a)),"swap contains an unsupported hookless pool"),m(t.currencyIn,e.currencyIn,"swap input currency differs"),m(t.currencyOut,e.currencyOut,"swap output currency differs"),i(t.amountIn===p(e.amountIn,"swap amount")&&t.amountIn>0n,"swap input amount differs"),i(t.amountOutMinimum>=p(e.minOut,"minimum output")&&e.minOut>0n,"swap minimum output is below the approved minimum"),i(t.deadline>BigInt(e.now)&&t.deadline<=BigInt(e.now+1200+$),"swap deadline must be within 20 minutes"),i(d===(l(e.currencyIn,h)?e.amountIn:0n),"swap ETH value differs from the approved input"),t.permit){let u=e.permit;i(u,"swap encodes an unexpected permit"),m(u.details.token,e.currencyIn,"permit token differs from the trade input"),i(T(u.details.amount,"permit amount",160)===e.amountIn&&e.amountIn<w(160),"permit amount differs from the exact trade input"),m(u.spender,o.router,"permit spender must be the Universal Router");let b=T(u.sigDeadline,"permit deadline");i(Number.isSafeInteger(u.details.expiration)&&u.details.expiration>e.now&&BigInt(u.details.expiration)<=b&&b>=BigInt(e.now+300)&&b<=BigInt(e.now+1800),"permit expiration or signature deadline is outside the signing window");let g=t.permit;i(l(g.token,u.details.token)&&g.amount===e.amountIn&&g.expiration===u.details.expiration&&g.nonce===u.details.nonce&&l(g.spender,u.spender)&&g.sigDeadline===b,"swap permit differs from the locally signed exact permit")}else i(!e.permit,"swap omitted the locally signed permit");A=`FOBO swap: exact input ${t.amountIn}; minimum output ${t.amountOutMinimum}.`;break}case"launch":{f(o.factory,o.selectors.launch),B(e.now);let t=y({abi:C,data:n.data});v(n.data,k({abi:C,...t}));let[a]=t.args;i(a.name===e.name&&a.ticker===e.ticker,"launch name or ticker differs from the approved launch"),m(a.quote,e.pair,"launch pair differs from the approved launch"),i(a.devBuyTokens===p(e.devBuyTokens,"initial buy")&&a.devBuyTokens<=50000000n*10n**18n&&a.devBuyMaxCost===p(e.devBuyMaxCost,"initial buy cost"),"launch initial buy or cost differs"),i(a.vestMonths===e.vestMonths&&[0,1,3,6,12].includes(a.vestMonths)&&(a.vestMonths===0||a.devBuyTokens>0n),"launch lock months differ"),i(a.deadline>BigInt(e.now)&&a.deadline<=BigInt(e.now+900+$),"launch deadline must be within 15 minutes"),i(d===p(e.launchFeeWei,"launch fee")+(l(a.quote,h)?a.devBuyMaxCost:0n),"launch ETH value differs from its fee plus initial buy"),A="Launch the approved FOBO token with its approved initial buy and lock.";break}case"limitOrder":{f(o.limitOrders,o.selectors.place);let t=y({abi:F,data:n.data});i(t.functionName==="place","selector is not place"),v(n.data,k({abi:F,...t}));let[a,u,b,g,z,V,Z]=t.args;i((a===0||a===1)&&a===e.side,"limit order side differs"),m(u,e.token,"limit order token differs"),m(b,e.payToken,"limit order pay token differs"),i(g===p(e.amount,"order amount")&&g>0n&&z===p(e.limitPriceUsdE18,"limit price")&&V===p(e.expiry,"order expiry")&&Z===p(e.maxFeePerFill,"keeper fee"),"limit order amount, price, expiry or keeper fee differs"),i(d===(a===0&&l(b,h)?g:0n),"limit order ETH value differs from its native escrow"),A="Place the approved FOBO limit order; escrow refunds and fills belong to this wallet.";break}case"cancel":{f(o.limitOrders,o.selectors.cancel),i(d===0n,"cancel value must be zero");let t=y({abi:F,data:n.data});i(t.functionName==="cancel","selector is not cancel"),v(n.data,k({abi:F,...t})),i(t.args[0]===p(e.orderId,"order id"),"cancel order differs"),m(t.args[1],s,"cancel recipient must be this wallet"),A="Cancel the approved FOBO order and refund this wallet.";break}case"claim":{if(i(d===0n,"claim value must be zero"),e.claimKind==="creator"){f(o.hook,o.selectors.claimCreator);let t=y({abi:K,data:n.data});v(n.data,k({abi:K,...t})),i(M(t.args[0],e.poolKey)&&l(t.args[0].hooks,o.hook),"creator claim pool differs"),m(t.args[1],s,"creator claim recipient must be this wallet")}else if(e.claimKind==="referral"){f(o.revenue,o.selectors.claimReferral);let t=y({abi:E,data:n.data});v(n.data,k({abi:E,...t})),m(t.args[0],s,"referral claim account must be this wallet"),m(t.args[1],e.currency,"referral claim currency differs"),m(t.args[2],e.recipient??s,"referral claim recipient differs from the approved recipient")}else{i(e.claimKind==="vesting","claim kind is unsupported"),f(o.vesting,o.selectors.claimVesting);let t=y({abi:D,data:n.data});v(n.data,k({abi:D,...t})),i(t.args[0]===p(e.lockId,"vesting lock"),"vesting lock differs"),m(e.beneficiary,s,"vesting beneficiary must be this wallet")}A="Claim the approved FOBO earnings to their approved recipient.";break}default:S("transaction expectation is unsupported")}return{to:r,data:n.data,value:d.toString(),chainId:o.chainId,gasLimit:c.toString(),description:A}}function ae(n,e,s){let r="sign-in message is not a fresh fobo.fun sign-in for this wallet";try{B(s),i(typeof n=="string"&&n.length<=2048&&!/[\r\p{Cc}\p{Cf}]/u.test(n.replaceAll(`
2
2
  `,"")),r);let d=n.split(`
3
- `);i(["fobo.fun wants you to sign in with your Ethereum account:","fobo.fun wants you to sign in with your wallet:"].includes(d[0]??"")&&d[2]==="",r),m(d[1],e,r);let u=3;d[u]!=="URI: https://fobo.fun"&&d[u]!=="URI: https://fobo.fun/"&&(i(["Sign in to fobo.fun","Sign in to fobo.fun.","Sign in to FOBO.","Sign in to fobo.","Sign in to FOBO. This is free: no transaction, no gas."].includes(d[u]??"")&&d[u+1]==="",r),u+=2),i(["URI: https://fobo.fun","URI: https://fobo.fun/"].includes(d[u]??"")&&d[u+1]==="Version: 1",r),u+=2,d[u]?.startsWith("Chain ID:")&&(i(d[u]==="Chain ID: 4663",r),u++),i(/^Nonce: [a-zA-Z0-9]{8,128}$/.test(d[u]??""),r);let O=d[u+1]?.match(/^Issued At: (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z)$/)?.[1];i(O&&d.length===u+2,r);let f=Date.parse(O)/1e3;i(Number.isFinite(f)&&f<=s&&f>=s-300,r)}catch{S(r)}}export{X as a,J as b,oe as c,re as d,ae as e};
3
+ `);i(["fobo.fun wants you to sign in with your Ethereum account:","fobo.fun wants you to sign in with your wallet:"].includes(d[0]??"")&&d[2]==="",r),m(d[1],e,r);let c=3;d[c]!=="URI: https://fobo.fun"&&d[c]!=="URI: https://fobo.fun/"&&(i(["Sign in to fobo.fun","Sign in to fobo.fun.","Sign in to FOBO.","Sign in to fobo.","Sign in to FOBO. This is free: no transaction, no gas."].includes(d[c]??"")&&d[c+1]==="",r),c+=2),i(["URI: https://fobo.fun","URI: https://fobo.fun/"].includes(d[c]??""),r),c+=1,d[c]?.startsWith("Version:")&&(i(d[c]==="Version: 1",r),c++),d[c]?.startsWith("Chain ID:")&&(i(d[c]==="Chain ID: 4663",r),c++),i(/^Nonce: [a-zA-Z0-9]{8,128}$/.test(d[c]??""),r);let O=d[c+1]?.match(/^Issued At: (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z)$/)?.[1];i(O&&d.length===c+2,r);let f=Math.floor(Date.parse(O)/1e3);i(Number.isFinite(f)&&f<=s+2&&f>=s-300,r)}catch{S(r)}}export{X as a,J as b,oe as c,re as d,ae as e};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oakagentkit/core",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "engines": {