@oakagentkit/core 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/build/dist/api/addresses.d.ts +1 -1
  2. package/build/dist/api/addresses.js +1 -1
  3. package/build/dist/api/amounts.js +1 -1
  4. package/build/dist/api/args.d.ts +19 -0
  5. package/build/dist/api/args.js +1 -0
  6. package/build/dist/api/canonical.js +1 -1
  7. package/build/dist/api/chain.js +1 -1
  8. package/build/dist/api/errors.d.ts +1 -0
  9. package/build/dist/api/errors.js +1 -1
  10. package/build/dist/api/gas.d.ts +5 -0
  11. package/build/dist/api/gas.js +1 -0
  12. package/build/dist/api/grandfather.js +1 -1
  13. package/build/dist/api/history.js +1 -1
  14. package/build/dist/api/http.js +1 -1
  15. package/build/dist/api/identity-link.js +1 -1
  16. package/build/dist/api/merkle.js +1 -1
  17. package/build/dist/api/metadata.js +1 -1
  18. package/build/dist/api/module.js +1 -1
  19. package/build/dist/api/modules/beefy/index.js +1 -1
  20. package/build/dist/api/modules/clanker/index.js +1 -1
  21. package/build/dist/api/modules/erc8004/index.d.ts +11 -0
  22. package/build/dist/api/modules/erc8004/index.js +1 -1
  23. package/build/dist/api/modules/grove/index.js +1 -1
  24. package/build/dist/api/modules/heyresearch/index.js +1 -1
  25. package/build/dist/api/modules/hoodag/index.js +1 -1
  26. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  27. package/build/dist/api/modules/hoodlock/index.js +1 -1
  28. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  29. package/build/dist/api/modules/hookr/create-cancel.d.ts +2 -2
  30. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  31. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  32. package/build/dist/api/modules/hookr/index.js +1 -1
  33. package/build/dist/api/modules/kyberswap/index.js +1 -1
  34. package/build/dist/api/modules/lighter/index.js +1 -1
  35. package/build/dist/api/modules/longbow/index.d.ts +4 -2
  36. package/build/dist/api/modules/longbow/index.js +1 -1
  37. package/build/dist/api/modules/meridian/index.js +1 -1
  38. package/build/dist/api/modules/meridian/markets.js +1 -1
  39. package/build/dist/api/modules/meridian/rfq.js +1 -1
  40. package/build/dist/api/modules/merkl/index.js +1 -1
  41. package/build/dist/api/modules/morpho/index.d.ts +1 -1
  42. package/build/dist/api/modules/morpho/index.js +2 -2
  43. package/build/dist/api/modules/netnet/index.js +1 -1
  44. package/build/dist/api/modules/orbio/index.js +1 -1
  45. package/build/dist/api/modules/pons/claim.js +1 -1
  46. package/build/dist/api/modules/pons/index.js +1 -1
  47. package/build/dist/api/modules/pons/launch-status.js +1 -1
  48. package/build/dist/api/modules/pons/prices.js +1 -1
  49. package/build/dist/api/modules/pons/trade.d.ts +3 -1
  50. package/build/dist/api/modules/pons/trade.js +1 -1
  51. package/build/dist/api/modules/poolstrade/index.js +1 -1
  52. package/build/dist/api/modules/priors/index.js +1 -1
  53. package/build/dist/api/modules/relay/inbound.d.ts +2 -0
  54. package/build/dist/api/modules/relay/inbound.js +1 -1
  55. package/build/dist/api/modules/relay/index.js +1 -1
  56. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  57. package/build/dist/api/modules/spark/index.js +1 -1
  58. package/build/dist/api/modules/steakhouse/index.js +1 -1
  59. package/build/dist/api/modules/tickerspring/index.js +1 -1
  60. package/build/dist/api/modules/uniswap/index.js +1 -1
  61. package/build/dist/api/modules/uniswap/v3.js +1 -1
  62. package/build/dist/api/modules/uniswap/v4.js +1 -1
  63. package/build/dist/api/modules/velora/index.js +1 -1
  64. package/build/dist/api/positions.js +1 -1
  65. package/build/dist/api/pricenote.js +1 -1
  66. package/build/dist/api/prices.js +1 -1
  67. package/build/dist/api/pricing.d.ts +5 -1
  68. package/build/dist/api/pricing.js +1 -1
  69. package/build/dist/api/routes.js +1 -1
  70. package/build/dist/api/secret-fields.js +1 -1
  71. package/build/dist/api/send.d.ts +45 -0
  72. package/build/dist/api/send.js +1 -0
  73. package/build/dist/api/simulate.js +1 -1
  74. package/build/dist/api/swap.d.ts +6 -1
  75. package/build/dist/api/swap.js +1 -1
  76. package/build/dist/api/tokens.js +1 -1
  77. package/build/dist/api/tool-policy.d.ts +1 -0
  78. package/build/dist/api/tool-policy.js +1 -1
  79. package/build/dist/api/tx.js +1 -1
  80. package/build/dist/api/types.d.ts +13 -0
  81. package/build/dist/api/untrusted.js +1 -1
  82. package/build/dist/api/vendor-limits.js +1 -1
  83. package/build/dist/chunks/2IRORNOH.js +1 -0
  84. package/build/dist/chunks/{YTHDLCHL.js → 3PA2XT75.js} +1 -1
  85. package/build/dist/chunks/52TGAWSI.js +1 -0
  86. package/build/dist/chunks/{OOSNTGDJ.js → 66DWJWDA.js} +1 -1
  87. package/build/dist/chunks/{ZKOMJGNH.js → 6SYTB6FB.js} +1 -1
  88. package/build/dist/chunks/73EABRFC.js +1 -0
  89. package/build/dist/chunks/{VZWOWR6G.js → A5ITAEUQ.js} +1 -1
  90. package/build/dist/chunks/A5KSG6LW.js +1 -0
  91. package/build/dist/chunks/{JMPOXXNJ.js → B4FOHEBE.js} +1 -1
  92. package/build/dist/chunks/B4MLWDPM.js +1 -0
  93. package/build/dist/chunks/{D45AODDL.js → BHR46XNW.js} +1 -1
  94. package/build/dist/chunks/{YEE3KKTA.js → BOFA26WU.js} +1 -1
  95. package/build/dist/chunks/CQNZWL7F.js +1 -0
  96. package/build/dist/chunks/GDP4JSAX.js +1 -0
  97. package/build/dist/chunks/{P7Q6MJZH.js → GIBF3YJO.js} +1 -1
  98. package/build/dist/chunks/GN4QZ4JA.js +1 -0
  99. package/build/dist/chunks/{B5RZYFQC.js → I5CQ64EU.js} +1 -1
  100. package/build/dist/chunks/ICCJ3TOO.js +1 -0
  101. package/build/dist/chunks/{XN4WDN3O.js → JXOEJPJ4.js} +1 -1
  102. package/build/dist/chunks/{47PKSOXA.js → KL5YE7JA.js} +1 -1
  103. package/build/dist/chunks/KVVTKM6E.js +1 -0
  104. package/build/dist/chunks/{UL2L7NHO.js → M6JGTQRY.js} +1 -1
  105. package/build/dist/chunks/{ZUAXW2ZD.js → MK6L6TGI.js} +1 -1
  106. package/build/dist/chunks/{KFMNCJXJ.js → MOVRI5IV.js} +1 -1
  107. package/build/dist/chunks/NA7HV7BR.js +1 -0
  108. package/build/dist/chunks/NGAI6GTU.js +1 -0
  109. package/build/dist/chunks/{UZH4FQEL.js → OBX7IZG5.js} +1 -1
  110. package/build/dist/chunks/{KP7VSXIQ.js → OSQ4AAM2.js} +1 -1
  111. package/build/dist/chunks/{75D6Q7L3.js → OWEUVFB6.js} +1 -1
  112. package/build/dist/chunks/{LZK6C5LT.js → P4G3EKF7.js} +1 -1
  113. package/build/dist/chunks/{IABIXUNX.js → QGDHMVPE.js} +1 -1
  114. package/build/dist/chunks/{VZPFBWVH.js → SJ7HDRI4.js} +1 -1
  115. package/build/dist/chunks/SPAKOCR7.js +1 -0
  116. package/build/dist/chunks/T6O2L6HF.js +1 -0
  117. package/build/dist/chunks/TEVKPJV5.js +1 -0
  118. package/build/dist/chunks/UCMNB2UP.js +1 -0
  119. package/build/dist/chunks/{64EN6Y7E.js → Y3P6SUNL.js} +1 -1
  120. package/build/dist/chunks/YX4NVVSX.js +1 -0
  121. package/build/dist/chunks/ZUC6ILK2.js +1 -0
  122. package/package.json +9 -13
  123. package/build/dist/chunks/24JYIH53.js +0 -1
  124. package/build/dist/chunks/25EOXUBI.js +0 -1
  125. package/build/dist/chunks/4P6XI564.js +0 -1
  126. package/build/dist/chunks/6YU3JLQQ.js +0 -1
  127. package/build/dist/chunks/AE6YEEZP.js +0 -1
  128. package/build/dist/chunks/BH3CI6WO.js +0 -1
  129. package/build/dist/chunks/CUBRTOMA.js +0 -1
  130. package/build/dist/chunks/FSSCJNAQ.js +0 -1
  131. package/build/dist/chunks/MGEJPRXP.js +0 -1
  132. package/build/dist/chunks/S3YSJ7XH.js +0 -1
  133. package/build/dist/chunks/SGDWO7XI.js +0 -1
  134. package/build/dist/chunks/T5E4OJEU.js +0 -1
  135. package/build/dist/chunks/VBV366XQ.js +0 -1
  136. package/build/dist/chunks/XUL6NKAK.js +0 -1
  137. package/build/dist/chunks/ZERWRK6X.js +0 -1
@@ -1 +1 @@
1
- import{a as r,b as u,h as n,i as c,j as d,k as i,l as m,m as M,n as a,o as p}from"../../../chunks/OOSNTGDJ.js";import{R as t}from"../../../chunks/47PKSOXA.js";import"../../../chunks/VZPFBWVH.js";import"../../../chunks/MGEJPRXP.js";import"../../../chunks/ZKOMJGNH.js";import"../../../chunks/YTHDLCHL.js";import"../../../chunks/KFMNCJXJ.js";import"../../../chunks/6YU3JLQQ.js";import"../../../chunks/D45AODDL.js";import"../../../chunks/24JYIH53.js";import"../../../chunks/VBV366XQ.js";import"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/P7Q6MJZH.js";import"../../../chunks/ZUAXW2ZD.js";import"../../../chunks/64EN6Y7E.js";import{b as e}from"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import"../../../chunks/25EOXUBI.js";import"../../../chunks/B5RZYFQC.js";import"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";function l(o){return e(r,[t(o),a(o)])}var _=l;var f=l;export{n as HOOKR_LIMIT_ORDERS_ABI,u as HOOKR_LIMIT_ORDERS_ADDRESS,r as HOOKR_MODULE_NAME,a as createFillBountyPart,m as createHookrClaimBountyTool,p as createHookrFillBountyPart,i as createHookrFillTool,_ as createHookrModule,l as createModule,f as default,c as formatSignedAmount,d as parseRoundedAmount,M as readHookrBountyPositions};
1
+ import{a as r,b as u,h as n,i as c,j as d,k as i,l as m,m as M,n as a,o as p}from"../../../chunks/66DWJWDA.js";import{R as t}from"../../../chunks/KL5YE7JA.js";import"../../../chunks/SJ7HDRI4.js";import"../../../chunks/6SYTB6FB.js";import"../../../chunks/52TGAWSI.js";import"../../../chunks/3PA2XT75.js";import"../../../chunks/MOVRI5IV.js";import"../../../chunks/YX4NVVSX.js";import"../../../chunks/BHR46XNW.js";import"../../../chunks/73EABRFC.js";import"../../../chunks/2IRORNOH.js";import"../../../chunks/GDP4JSAX.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/MK6L6TGI.js";import"../../../chunks/Y3P6SUNL.js";import"../../../chunks/GIBF3YJO.js";import{b as e}from"../../../chunks/UCMNB2UP.js";import"../../../chunks/Z25UKUJF.js";import"../../../chunks/A5ITAEUQ.js";import"../../../chunks/I5CQ64EU.js";import"../../../chunks/NA7HV7BR.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/M6JGTQRY.js";import"../../../chunks/ZUC6ILK2.js";import"../../../chunks/B4MLWDPM.js";import"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";function l(o){return e(r,[t(o),a(o)])}var _=l;var f=l;export{n as HOOKR_LIMIT_ORDERS_ABI,u as HOOKR_LIMIT_ORDERS_ADDRESS,r as HOOKR_MODULE_NAME,a as createFillBountyPart,m as createHookrClaimBountyTool,p as createHookrFillBountyPart,i as createHookrFillTool,_ as createHookrModule,l as createModule,f as default,c as formatSignedAmount,d as parseRoundedAmount,M as readHookrBountyPositions};
@@ -1 +1 @@
1
- import{a as X}from"../../../chunks/JMPOXXNJ.js";import{a as z,b as J,e as R,i as V,n as g,o as C,t as G,v as E}from"../../../chunks/VBV366XQ.js";import{b as j}from"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import{a as K}from"../../../chunks/P7Q6MJZH.js";import{c as H}from"../../../chunks/ZUAXW2ZD.js";import"../../../chunks/64EN6Y7E.js";import{a as Q}from"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import{a as c,i as F}from"../../../chunks/25EOXUBI.js";import{a as M}from"../../../chunks/B5RZYFQC.js";import{a as o}from"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";import{randomUUID as ne}from"node:crypto";import{erc20Abi as re}from"viem";var b=F[c].routes.kyberswap.address,W="https://aggregator-api.kyberswap.com/robinhood/api/v1",Y="Quoted output is net of venue fees. Oak swap fee: 0.",oe=(1n<<256n)-1n;function U(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Z(e){return U(e)&&e.code===0&&U(e.data)}function P(e,t=!1){if(typeof e!="string")throw new o("Amount must be an integer string in base units.");let n=M(e);if(n>oe||t&&n===0n)throw new o("Swap amount must be positive and within the uint256 range.");return n.toString()}function y(e,t){return typeof e=="string"&&e.toLowerCase()===t.toLowerCase()}function D(e){if(!y(e.routerAddress,b)||e.spender!==void 0&&!y(e.spender,b))throw new o("KyberSwap router or spender does not match the evidenced deployment.");if(e.chainId!==void 0&&e.chainId!==c)throw new o("KyberSwap response is for a different chain.")}function ee(e){if(typeof e!="string")throw new o("Provide a token address on chain 4663.");return Q(e),j(e)}async function te(e,t){if(g(t))return{address:t,symbol:"ETH",decimals:18,chainId:c};let[n,m]=await Promise.all([K(e,c,t,"symbol"),K(e,c,t,"decimals")]);if(typeof n!="string"||!n.trim()||!Number.isInteger(m)||m<0||m>255)throw new o("Token metadata could not be read on chain 4663.");return{address:t,symbol:n,decimals:m,chainId:c}}function h(e){if(BigInt(Math.floor(Date.now()/1e3))>=BigInt(e.expiresAt))throw new o("Quote has expired. Request a fresh quote.")}function ae(e){let t=new Map,n=async()=>{let r=e.clientFor(c);if(await r.getChainId()!==c)throw new o("KyberSwap requires an RPC on chain 4663.");return r},m={name:"kyberswap",async quote(r,a,d=!1){try{Q(a);let i=ee(r.from),s=ee(r.to);if(y(i,s))throw new o("Choose two different token addresses.");let u=P(r.amountIn,!0),w=r.slippageBps===void 0?J:r.slippageBps;C("1",w);let v=String(Math.floor(Date.now()/1e3)+z),S=await n(),[A,x]=await Promise.all([te(S,i),te(S,s)]),$=new URL(`${W}/routes`);$.search=new URLSearchParams({tokenIn:g(i)?R:i,tokenOut:g(s)?R:s,amountIn:u}).toString();let _=await X(e.http,$.toString(),Z),N=_.value;D(N.data);let f=N.data.routeSummary;if(!U(f)||!y(f.tokenIn,i)||!y(f.tokenOut,s)||P(f.amountIn,!0)!==u)throw new o("KyberSwap route does not match the requested tokens and amount.");f.routerAddress!==void 0&&D(f);let O=P(f.amountOut,!0),I=C(O,w);if(I==="0")throw new o("KyberSwap minimum output must be positive.");let p={quoteId:`kyberswap:${ne()}`,provider:"kyberswap",from:i,to:s,wallet:a,amountIn:u,amountOut:O,minAmountOut:I,router:b,spender:b,value:g(i)?u:"0",chainId:c,slippageBps:w,expiresAt:String(Math.min(Number(v),_.expiresAt)),oakFee:"0",feeDisclosure:Y,input:{token:A,amount:u},output:{token:x,amount:O},minimumOutput:{token:x,amount:I}},T={quote:p,wallet:a,prepare:async()=>{if(h(p),T.tx)return structuredClone(T.quote);let l=await H(e.http,`${W}/route/build`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({routeSummary:f,sender:a,recipient:a,slippageTolerance:w})},Z);if(D(l.data),P(l.data.amountIn,!0)!==u)throw new o("KyberSwap built input amount does not match the route.");let k=P(l.data.amountOut,!0);if(BigInt(k)<BigInt(I))throw new o("KyberSwap built output is below the route minimum.");if(typeof l.data.data!="string")throw new o("KyberSwap did not return swap calldata.");let L=l.data.data,q=G(L).toString();if(q!==C(k,w)||q==="0"||d&&BigInt(q)<BigInt(I))throw new o("KyberSwap calldata minimum does not match the quoted output and slippage.");d||(p.amountOut=k,p.minAmountOut=q,p.output.amount=k,p.minimumOutput.amount=q);let B=e.unsignedTx({to:b,data:L,value:P(l.data.transactionValue),chainId:c,description:`Swap ${e.formatAmount(u,A.decimals)} ${A.symbol} for at least ${e.formatAmount(p.minAmountOut,x.decimals)} ${x.symbol} via KyberSwap. ${Y}`});return E(B,p),h(p),p.data=B.data,T.tx=B,structuredClone(p)}};h(p);for(let[l,k]of t)BigInt(k.quote.expiresAt)<=BigInt(Math.floor(Date.now()/1e3))&&t.delete(l);return t.size>=V&&t.delete(t.keys().next().value),t.set(p.quoteId,T),d?structuredClone(p):await T.prepare()}catch(i){throw new o(e.plainError(i))}},async quotePrices(r,a){return m.quote(r,a,!0)},async prepareQuote(r,a){let d=t.get(r);if(!d)throw new o("Quote is unknown or expired. Request a fresh quote.");if(!y(a,d.wallet))throw new o("Quote belongs to a different wallet.");return d.prepare()},async readAllowance(r,a){let d=t.get(r);if(!d)throw new o("Quote is unknown or expired. Request a fresh quote.");if(h(d.quote),!y(a,d.wallet))throw new o("Quote belongs to a different wallet.");let i=await n(),s=d.quote.input.token.address;if(g(s))return"0";let u=await i.readContract({address:s,abi:re,functionName:"allowance",args:[a,b]});if(typeof u!="bigint"||u<0n||u>oe)throw new o("Token allowance could not be read.");return h(d.quote),u.toString()},async build(r,a,d={}){try{Q(a);let i=t.get(r);if(!i)throw new o("Quote is unknown or expired. Request a fresh quote.");let{quote:s}=i;if(h(s),!y(a,i.wallet))throw new o("Quote belongs to a different wallet.");await m.prepareQuote(r,a);let u=[],w=s.input.token.address,v=M(d.allowance??await m.readAllowance(r,a));g(w)||v<BigInt(s.input.amount)&&u.push(e.approval(w,b,s.input.amount,c)),h(s);let S={...i.tx};E(S,s),u.push(S);let A=await e.preview(u,a);return h(s),{txs:u,preview:A,summary:`${S.description} ${A.summary}`}}catch(i){throw new o(e.plainError(i))}}};return m}function ie(e){let t={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"};return[{name:"kyberswap_quote",inputSchema:{type:"object",additionalProperties:!1,required:["from","to","amountIn"],properties:{from:t,to:t,amountIn:{type:"string",pattern:"^[0-9]+$"},slippageBps:{type:"integer",minimum:0,maximum:9999}}},execute:(n,m)=>e.quote({from:n.from,to:n.to,amountIn:n.amountIn,...n.slippageBps!==void 0?{slippageBps:n.slippageBps}:{}},m)},{name:"kyberswap_swap",inputSchema:{type:"object",additionalProperties:!1,required:["quoteId"],properties:{quoteId:{type:"string",minLength:1}}},execute:(n,m)=>e.build(n.quoteId,m)}]}function se(e){let t=ae(e);return{name:"kyberswap",tools:ie(t),swapProvider:t}}var be=e=>({tools:se(e).tools});export{se as createModule,be as createModulePart,ae as createSwapProvider};
1
+ import{a as Y}from"../../../chunks/B4FOHEBE.js";import{a as V,b as G,e as E,i as X,n as g,o as Q,w as W,x as D,y as U}from"../../../chunks/2IRORNOH.js";import{b as z}from"../../../chunks/GDP4JSAX.js";import"../../../chunks/LIUXNOLP.js";import{c as J}from"../../../chunks/MK6L6TGI.js";import"../../../chunks/Y3P6SUNL.js";import{a as R}from"../../../chunks/GIBF3YJO.js";import{a as C}from"../../../chunks/A5ITAEUQ.js";import{a as K}from"../../../chunks/I5CQ64EU.js";import{b as H}from"../../../chunks/NA7HV7BR.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/M6JGTQRY.js";import{a as c,i as j}from"../../../chunks/ZUC6ILK2.js";import"../../../chunks/B4MLWDPM.js";import{a as o}from"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";import{randomUUID as ae}from"node:crypto";import{erc20Abi as ie}from"viem";var S=j[c].routes.kyberswap.address,Z="https://aggregator-api.kyberswap.com/robinhood/api/v1",ee="Quoted output is net of venue fees. Oak swap fee: 0.",re=(1n<<256n)-1n;function $(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function te(e){return $(e)&&e.code===0&&$(e.data)}function P(e,t=!1){if(typeof e!="string")throw new o("Amount must be an integer string in base units.");let n=K(e);if(n>re||t&&n===0n)throw new o("Swap amount must be positive and within the uint256 range.");return n.toString()}function y(e,t){return typeof e=="string"&&e.toLowerCase()===t.toLowerCase()}function _(e){if(!y(e.routerAddress,S)||e.spender!==void 0&&!y(e.spender,S))throw new o("KyberSwap router or spender does not match the evidenced deployment.");if(e.chainId!==void 0&&e.chainId!==c)throw new o("KyberSwap response is for a different chain.")}function oe(e){if(typeof e!="string")throw new o("Provide a token address on chain 4663.");return C(e),z(e)}async function ne(e,t){if(g(t))return{address:t,symbol:"ETH",decimals:18,chainId:c};let[n,m]=await Promise.all([R(e,c,t,"symbol"),R(e,c,t,"decimals")]);if(typeof n!="string"||!n.trim()||!Number.isInteger(m)||m<0||m>255)throw new o("Token metadata could not be read on chain 4663.");return{address:t,symbol:n,decimals:m,chainId:c}}function h(e){if(BigInt(Math.floor(Date.now()/1e3))>=BigInt(e.expiresAt))throw new o("Quote has expired. Request a fresh quote.")}function se(e){let t=new Map,n=async()=>{let r=e.clientFor(c);if(await r.getChainId()!==c)throw new o("KyberSwap requires an RPC on chain 4663.");return r},m={name:"kyberswap",async quote(r,a,d=!1){try{C(a);let i=oe(r.from),s=oe(r.to);if(y(i,s))throw new o("Choose two different token addresses.");let u=P(r.amountIn,!0),w=r.slippageBps===void 0?G:r.slippageBps;Q("1",w);let O=String(Math.floor(Date.now()/1e3)+V),A=await n(),[k,x]=await Promise.all([ne(A,i),ne(A,s)]),N=new URL(`${Z}/routes`);N.search=new URLSearchParams({tokenIn:g(i)?E:i,tokenOut:g(s)?E:s,amountIn:u}).toString();let L=await Y(e.http,N.toString(),te),F=L.value;_(F.data);let f=F.data.routeSummary;if(!$(f)||!y(f.tokenIn,i)||!y(f.tokenOut,s)||P(f.amountIn,!0)!==u)throw new o("KyberSwap route does not match the requested tokens and amount.");f.routerAddress!==void 0&&_(f);let v=P(f.amountOut,!0),I=Q(v,w);if(I==="0")throw new o("KyberSwap minimum output must be positive.");let p={quoteId:`kyberswap:${ae()}`,provider:"kyberswap",from:i,to:s,wallet:a,amountIn:u,amountOut:v,minAmountOut:I,router:S,spender:S,value:g(i)?u:"0",chainId:c,slippageBps:w,expiresAt:String(Math.min(Number(O),L.expiresAt)),oakFee:"0",feeDisclosure:ee,input:{token:k,amount:u},output:{token:x,amount:v},minimumOutput:{token:x,amount:I}},T={quote:p,wallet:a,prepare:async()=>{if(h(p),T.tx)return structuredClone(T.quote);let l=await J(e.http,`${Z}/route/build`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({routeSummary:f,sender:a,recipient:a,slippageTolerance:w})},te);if(_(l.data),P(l.data.amountIn,!0)!==u)throw new o("KyberSwap built input amount does not match the route.");let b=P(l.data.amountOut,!0);if(BigInt(b)<BigInt(I))throw new o("KyberSwap built output is below the route minimum.");if(typeof l.data.data!="string")throw new o("KyberSwap did not return swap calldata.");let q=l.data.data,M=W(q).toString();if(D(q,I,!0),D(q,Q(b,w),!0),BigInt(M)>BigInt(b))throw new o("KyberSwap calldata minimum exceeds the built output.");d||(p.amountOut=b,p.minAmountOut=M,p.output.amount=b,p.minimumOutput.amount=M);let B=e.unsignedTx({to:S,data:q,value:P(l.data.transactionValue),chainId:c,description:`Swap ${e.formatAmount(u,k.decimals)} ${k.symbol} for at least ${e.formatAmount(p.minAmountOut,x.decimals)} ${x.symbol} via KyberSwap. ${ee}`});return U(B,p),h(p),p.data=B.data,T.tx=B,structuredClone(p)}};h(p);for(let[l,b]of t)BigInt(b.quote.expiresAt)<=BigInt(Math.floor(Date.now()/1e3))&&t.delete(l);return t.size>=X&&t.delete(t.keys().next().value),t.set(p.quoteId,T),d?structuredClone(p):await T.prepare()}catch(i){throw new o(e.plainError(i))}},async quotePrices(r,a){return m.quote(r,a,!0)},async prepareQuote(r,a){let d=t.get(r);if(!d)throw new o("Quote is unknown or expired. Request a fresh quote.");if(!y(a,d.wallet))throw new o("Quote belongs to a different wallet.");return d.prepare()},async readAllowance(r,a){let d=t.get(r);if(!d)throw new o("Quote is unknown or expired. Request a fresh quote.");if(h(d.quote),!y(a,d.wallet))throw new o("Quote belongs to a different wallet.");let i=await n(),s=d.quote.input.token.address;if(g(s))return"0";let u=await i.readContract({address:s,abi:ie,functionName:"allowance",args:[a,S]});if(typeof u!="bigint"||u<0n||u>re)throw new o("Token allowance could not be read.");return h(d.quote),u.toString()},async build(r,a,d={}){try{C(a);let i=t.get(r);if(!i)throw new o("Quote is unknown or expired. Request a fresh quote.");let{quote:s}=i;if(h(s),!y(a,i.wallet))throw new o("Quote belongs to a different wallet.");await m.prepareQuote(r,a);let u=[],w=s.input.token.address,O=K(d.allowance??await m.readAllowance(r,a));g(w)||O<BigInt(s.input.amount)&&u.push(e.approval(w,S,s.input.amount,c)),h(s);let A={...i.tx};U(A,s),u.push(A);let k=await e.preview(u,a);return h(s),{txs:u,preview:k,summary:`${A.description} ${k.summary}`}}catch(i){throw new o(e.plainError(i))}}};return m}function ue(e){let t={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"};return[{name:"kyberswap_quote",inputSchema:{type:"object",additionalProperties:!1,required:["from","to","amountIn"],properties:{from:t,to:t,amountIn:H(),slippageBps:{type:"integer",minimum:0,maximum:9999}}},execute:(n,m)=>e.quote({from:n.from,to:n.to,amountIn:n.amountIn,...n.slippageBps!==void 0?{slippageBps:n.slippageBps}:{}},m)},{name:"kyberswap_swap",inputSchema:{type:"object",additionalProperties:!1,required:["quoteId"],properties:{quoteId:{type:"string",minLength:1}}},execute:(n,m)=>e.build(n.quoteId,m)}]}function de(e){let t=se(e);return{name:"kyberswap",tools:ue(t),swapProvider:t}}var ke=e=>({tools:de(e).tools});export{de as createModule,ke as createModulePart,se as createSwapProvider};
@@ -1 +1 @@
1
- import{c as A}from"../../../chunks/ZUAXW2ZD.js";import"../../../chunks/64EN6Y7E.js";import{b as M}from"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import"../../../chunks/VZWOWR6G.js";import{a as y,d as v,j as L}from"../../../chunks/25EOXUBI.js";import{c as D}from"../../../chunks/B5RZYFQC.js";import{a as d,c as x}from"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";var b="https://api.rh.lighter.xyz",U={chainId:y,address:L,symbol:"USDG",decimals:v};function w(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function u(){throw new d("Lighter returned an unexpected funding response.")}function I(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function _(e){return typeof e=="string"&&e.length>0&&e.length<=100&&e.trim()===e}function g(e,t){let r=e[t];return(!Array.isArray(r)||r.length===0||!r.every(w))&&u(),r}function T(e){let t=/^(-?)(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/i.exec(e);(!t||e.length>150)&&u();let r=t[3]??"",m=Number(t[4]??0),a=r.length-m;(!Number.isSafeInteger(m)||Math.abs(a)>250)&&u();let n=BigInt(`${t[1]}${t[2]}${r}`);return a<0?{coefficient:n*10n**BigInt(-a),decimals:0}:{coefficient:n,decimals:a}}function f(e,t,r=0){let m=e.coefficient*t;return`${m<0n?"-":""}${D((m<0n?-m:m).toString(),e.decimals+r)}`}function N(e){(typeof e!="number"||!Number.isFinite(e))&&u();let t=T(String(e));return{rate_1h_pct:f(t,125n,1),rate_8h_pct:f(t,100n),rate_annualized_pct:f(t,109500n),direction:e<0?"short":"long"}}function V(e){(typeof e.rate!="string"||!/^\d+(\.\d+)?$/.test(e.rate)||e.direction!=="long"&&e.direction!=="short")&&u();let t=T(e.rate),r=e.direction==="short"?-1n:1n;return{rate_1h_pct:f(t,r),rate_8h_pct:f(t,r*8n),rate_annualized_pct:f(t,r*8760n),direction:e.direction}}function P(e,t){let r,m;return async()=>r&&Date.now()<r.expires?r.value:(m||(m=e().then(a=>(r={value:a,expires:Date.now()+t},a)).finally(()=>{m=void 0})),m)}function q(e){if(!w(e)||Object.keys(e).some(t=>t!=="symbol"&&t!=="historyHours"))throw new d("Provide only a perpetual market symbol and optional historyHours.");if(e.symbol!==void 0&&(!_(e.symbol)||!e.symbol.trim()))throw new d("Provide a perpetual market symbol.");if(e.historyHours!==void 0&&(e.symbol===void 0||typeof e.historyHours!="number"||!Number.isInteger(e.historyHours)||e.historyHours<1||e.historyHours>168))throw new d("History requires a perpetual market symbol and 1 to 168 whole hours.");return{symbol:e.symbol?.toUpperCase(),historyHours:e.historyHours}}var E=e=>{async function t(a){return A(e.http,`${b}${a}`,{method:"GET",headers:{"user-agent":"oak-core/0.1.0"}},n=>w(n)&&n.code===200)}let r=P(async()=>{let a=await t("/api/v1/orderBookDetails?filter=perp"),n=new Set,c=new Set,o=[];for(let s of g(a,"order_book_details")){if(s.market_type==="spot"||typeof s.status=="string"&&s.status!=="active")continue;(s.market_type!=="perp"||s.status!=="active"||!I(s.market_id)||!_(s.symbol)||s.quote_asset_id!==void 0&&s.quote_asset_id!==0&&s.quote_asset_id!==3)&&u();let l=s.symbol.toUpperCase();(n.has(s.market_id)||c.has(l))&&u(),n.add(s.market_id),c.add(l),o.push({market_id:s.market_id,symbol:l})}if(!o.length)throw new d("Lighter returned no active perpetual markets.");return o},6e5),m=P(async()=>{let a=await t("/api/v1/funding-rates"),n=new Set,c=g(a,"funding_rates").filter(o=>o.exchange==="lighter").map(o=>((!I(o.market_id)||!_(o.symbol)||n.has(o.market_id))&&u(),n.add(o.market_id),{market_id:o.market_id,symbol:o.symbol.toUpperCase(),exchange:"lighter",...N(o.rate)}));if(!c.length)throw new d("Lighter returned no funding rates.");return{rates:c,observed_at:String(Math.floor(Date.now()/1e3))}},3e4);return{tools:[{name:"lighter_funding",inputSchema:{type:"object",additionalProperties:!1,properties:{symbol:{type:"string",minLength:1,maxLength:100,description:"Perpetual market ticker from the Lighter RH directory; omit for all current rates."},historyHours:{type:"integer",minimum:1,maximum:168,description:"Fetch hourly settled funding for the selected symbol over this many hours."}},dependentRequired:{historyHours:["symbol"]}},async execute(a){try{let n=q(a),c=await r(),o=n.symbol===void 0?void 0:c.find(i=>i.symbol===n.symbol);if(n.symbol!==void 0&&!o)throw new d("That active perpetual market is not available on Lighter RH.");let s=await m(),l=s.rates.filter(i=>!o||i.market_id===o.market_id);if(!l.length)throw new d("Lighter returned no funding rate for that perpetual market.");for(let i of l)c.some(R=>R.market_id===i.market_id&&R.symbol===i.symbol)||u();let k={venue:"lighter-rh",chainId:y,collateral:{...U},source:`${b}/api/v1/funding-rates`,observed_at:s.observed_at,timestamp_unit:"seconds",current_timestamp_kind:"observed_at",rate_unit:"percent",annualization:"simple, 365 days; indicative, not a forecast",rates:l.map(i=>({...i}))};if(n.historyHours===void 0||!o)return k;let p=Math.floor(Date.now()/1e3),h=p-n.historyHours*3600,$=new URLSearchParams({market_id:String(o.market_id),resolution:"1h",start_timestamp:String(h),end_timestamp:String(p),count_back:String(n.historyHours)}),S=await t(`/api/v1/fundings?${$}`);S.resolution!=="1h"&&u();let H=new Set,C=g(S,"fundings").map(i=>((typeof i.timestamp!="number"||!Number.isSafeInteger(i.timestamp)||i.timestamp%3600!==0||i.timestamp<h||i.timestamp>p||H.has(i.timestamp))&&u(),H.add(i.timestamp),{...o,exchange:"lighter",timestamp:String(i.timestamp),...V(i)}));return{...k,history:C,history_source:`${b}/api/v1/fundings`,start_timestamp:String(h),end_timestamp:String(p)}}catch(n){throw new d(x(n))}}}]}},O=e=>M("lighter",[E(e)]);export{O as createModule,E as createModulePart};
1
+ import{c as A}from"../../../chunks/MK6L6TGI.js";import"../../../chunks/Y3P6SUNL.js";import{b as M}from"../../../chunks/UCMNB2UP.js";import"../../../chunks/Z25UKUJF.js";import"../../../chunks/A5ITAEUQ.js";import{c as D}from"../../../chunks/I5CQ64EU.js";import"../../../chunks/NA7HV7BR.js";import{a as y,d as v,j as L}from"../../../chunks/ZUC6ILK2.js";import{a as d,d as x}from"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";var b="https://api.rh.lighter.xyz",U={chainId:y,address:L,symbol:"USDG",decimals:v};function w(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function u(){throw new d("Lighter returned an unexpected funding response.")}function I(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function _(e){return typeof e=="string"&&e.length>0&&e.length<=100&&e.trim()===e}function g(e,t){let r=e[t];return(!Array.isArray(r)||r.length===0||!r.every(w))&&u(),r}function T(e){let t=/^(-?)(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/i.exec(e);(!t||e.length>150)&&u();let r=t[3]??"",m=Number(t[4]??0),a=r.length-m;(!Number.isSafeInteger(m)||Math.abs(a)>250)&&u();let n=BigInt(`${t[1]}${t[2]}${r}`);return a<0?{coefficient:n*10n**BigInt(-a),decimals:0}:{coefficient:n,decimals:a}}function f(e,t,r=0){let m=e.coefficient*t;return`${m<0n?"-":""}${D((m<0n?-m:m).toString(),e.decimals+r)}`}function N(e){(typeof e!="number"||!Number.isFinite(e))&&u();let t=T(String(e));return{rate_1h_pct:f(t,125n,1),rate_8h_pct:f(t,100n),rate_annualized_pct:f(t,109500n),direction:e<0?"short":"long"}}function V(e){(typeof e.rate!="string"||!/^\d+(\.\d+)?$/.test(e.rate)||e.direction!=="long"&&e.direction!=="short")&&u();let t=T(e.rate),r=e.direction==="short"?-1n:1n;return{rate_1h_pct:f(t,r),rate_8h_pct:f(t,r*8n),rate_annualized_pct:f(t,r*8760n),direction:e.direction}}function P(e,t){let r,m;return async()=>r&&Date.now()<r.expires?r.value:(m||(m=e().then(a=>(r={value:a,expires:Date.now()+t},a)).finally(()=>{m=void 0})),m)}function q(e){if(!w(e)||Object.keys(e).some(t=>t!=="symbol"&&t!=="historyHours"))throw new d("Provide only a perpetual market symbol and optional historyHours.");if(e.symbol!==void 0&&(!_(e.symbol)||!e.symbol.trim()))throw new d("Provide a perpetual market symbol.");if(e.historyHours!==void 0&&(e.symbol===void 0||typeof e.historyHours!="number"||!Number.isInteger(e.historyHours)||e.historyHours<1||e.historyHours>168))throw new d("History requires a perpetual market symbol and 1 to 168 whole hours.");return{symbol:e.symbol?.toUpperCase(),historyHours:e.historyHours}}var E=e=>{async function t(a){return A(e.http,`${b}${a}`,{method:"GET",headers:{"user-agent":"oak-core/0.1.0"}},n=>w(n)&&n.code===200)}let r=P(async()=>{let a=await t("/api/v1/orderBookDetails?filter=perp"),n=new Set,c=new Set,o=[];for(let s of g(a,"order_book_details")){if(s.market_type==="spot"||typeof s.status=="string"&&s.status!=="active")continue;(s.market_type!=="perp"||s.status!=="active"||!I(s.market_id)||!_(s.symbol)||s.quote_asset_id!==void 0&&s.quote_asset_id!==0&&s.quote_asset_id!==3)&&u();let l=s.symbol.toUpperCase();(n.has(s.market_id)||c.has(l))&&u(),n.add(s.market_id),c.add(l),o.push({market_id:s.market_id,symbol:l})}if(!o.length)throw new d("Lighter returned no active perpetual markets.");return o},6e5),m=P(async()=>{let a=await t("/api/v1/funding-rates"),n=new Set,c=g(a,"funding_rates").filter(o=>o.exchange==="lighter").map(o=>((!I(o.market_id)||!_(o.symbol)||n.has(o.market_id))&&u(),n.add(o.market_id),{market_id:o.market_id,symbol:o.symbol.toUpperCase(),exchange:"lighter",...N(o.rate)}));if(!c.length)throw new d("Lighter returned no funding rates.");return{rates:c,observed_at:String(Math.floor(Date.now()/1e3))}},3e4);return{tools:[{name:"lighter_funding",inputSchema:{type:"object",additionalProperties:!1,properties:{symbol:{type:"string",minLength:1,maxLength:100,description:"Perpetual market ticker from the Lighter RH directory; omit for all current rates."},historyHours:{type:"integer",minimum:1,maximum:168,description:"Fetch hourly settled funding for the selected symbol over this many hours."}},dependentRequired:{historyHours:["symbol"]}},async execute(a){try{let n=q(a),c=await r(),o=n.symbol===void 0?void 0:c.find(i=>i.symbol===n.symbol);if(n.symbol!==void 0&&!o)throw new d("That active perpetual market is not available on Lighter RH.");let s=await m(),l=s.rates.filter(i=>!o||i.market_id===o.market_id);if(!l.length)throw new d("Lighter returned no funding rate for that perpetual market.");for(let i of l)c.some(R=>R.market_id===i.market_id&&R.symbol===i.symbol)||u();let k={venue:"lighter-rh",chainId:y,collateral:{...U},source:`${b}/api/v1/funding-rates`,observed_at:s.observed_at,timestamp_unit:"seconds",current_timestamp_kind:"observed_at",rate_unit:"percent",annualization:"simple, 365 days; indicative, not a forecast",rates:l.map(i=>({...i}))};if(n.historyHours===void 0||!o)return k;let p=Math.floor(Date.now()/1e3),h=p-n.historyHours*3600,$=new URLSearchParams({market_id:String(o.market_id),resolution:"1h",start_timestamp:String(h),end_timestamp:String(p),count_back:String(n.historyHours)}),S=await t(`/api/v1/fundings?${$}`);S.resolution!=="1h"&&u();let H=new Set,C=g(S,"fundings").map(i=>((typeof i.timestamp!="number"||!Number.isSafeInteger(i.timestamp)||i.timestamp%3600!==0||i.timestamp<h||i.timestamp>p||H.has(i.timestamp))&&u(),H.add(i.timestamp),{...o,exchange:"lighter",timestamp:String(i.timestamp),...V(i)}));return{...k,history:C,history_source:`${b}/api/v1/fundings`,start_timestamp:String(h),end_timestamp:String(p)}}catch(n){throw new d(x(n))}}}]}},O=e=>M("lighter",[E(e)]);export{O as createModule,E as createModulePart};
@@ -1,5 +1,7 @@
1
- import type { ActionResult, CreateModulePart, ModuleContext, Preview, ProjectModule, TokenAmount } from '../../types.js';
2
- export type LongbowAction = ActionResult & {
1
+ import type { ActionResult, CreateModulePart, ModuleContext, Preview, ProjectModule, TokenAmount, UnsignedTx } from '../../types.js';
2
+ export type LongbowAction = Extract<ActionResult, {
3
+ txs: UnsignedTx[];
4
+ }> & {
3
5
  preview: Preview;
4
6
  expectedOutput: TokenAmount;
5
7
  minimumOutput: TokenAmount;
@@ -1 +1 @@
1
- import{b as N,o as M}from"../../../chunks/VBV366XQ.js";import"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/P7Q6MJZH.js";import"../../../chunks/64EN6Y7E.js";import{b as I}from"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import{a as b}from"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import{a as l,i as $}from"../../../chunks/25EOXUBI.js";import{a as D}from"../../../chunks/B5RZYFQC.js";import{a as i}from"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";import{encodeFunctionData as k,getAddress as y,parseAbi as R}from"viem";var d=R(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)","function balanceOf(address) view returns (uint256)","function previewDeposit(uint256 assets) view returns (uint256)","function previewRedeem(uint256 shares) view returns (uint256)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),_=R(["function deposit() payable"]),g=$[l],H=(1n<<256n)-1n,A=[{key:"core",name:"Longbow Core USDG",vault:g.vaults.longbowCore.address,asset:g.tokens.USDG.address,symbol:"USDG",decimals:6},{key:"frontier",name:"Longbow Frontier USDG",vault:g.vaults.longbowFrontier.address,asset:g.tokens.USDG.address,symbol:"USDG",decimals:6},{key:"eth",name:"Longbow ETH",vault:g.vaults.longbowEth.address,asset:g.tokens.WETH.address,symbol:"WETH",decimals:18}];function U(s,w){if(typeof s!="string")throw new i(`${w} must be a positive integer string in base units.`);let c=D(s);if(c===0n||c>H)throw new i(`${w} must be positive and within the uint256 range.`);return c}function f(s){if(typeof s!="bigint"||s<0n||s>H)throw new i("Longbow returned an invalid integer response.");return s}function F(s){if(typeof s!="string")throw new i("Provide the address of a current Longbow vault.");let w=A.find(c=>c.vault.toLowerCase()===s.toLowerCase());if(!w)throw new i("Provide the address of a current Longbow vault. Legacy vaults are not supported.");return w}function C(s,w){if(Object.keys(s).some(c=>!w.includes(c)))throw new i("Unsupported Longbow input. Use the fields in the tool schema.")}var j=s=>{async function w(t){try{return await t()}catch(e){throw new i(s.plainError(e))}}async function c(){let t=s.clientFor(l);if(await t.getChainId()!==l)throw new i("Longbow requires a client on chain 4663.");return t}async function v(t,e){let[a,r,o]=await Promise.all([t.readContract({address:e.vault,abi:d,functionName:"asset"}),t.readContract({address:e.vault,abi:d,functionName:"decimals"}),t.readContract({address:e.asset,abi:d,functionName:"decimals"})]);if(typeof a!="string"||a.toLowerCase()!==e.asset.toLowerCase())throw new i("Longbow vault asset does not match the recorded deployment.");if(r!==18||o!==e.decimals)throw new i("Longbow token decimals do not match the recorded deployment.");return{vault:e.vault,key:e.key,name:e.name,asset:{address:y(e.asset),symbol:e.symbol,decimals:o,chainId:l},share:{address:e.vault,symbol:`${e.key} shares`,decimals:r,chainId:l}}}async function E(t,e,a,r){let o=M(a.amount,N);if(BigInt(o)===0n)throw new i("The expected output is too small for a nonzero simulation minimum.");let n=await s.preview(t,e);if(n.changes.filter(m=>m.token.chainId===a.token.chainId&&m.token.address.toLowerCase()===a.token.address.toLowerCase()&&m.token.decimals===a.token.decimals).reduce((m,h)=>m+BigInt(h.amount),0n)<BigInt(o))throw new i("Longbow simulated output is below the expected minimum.");let u=n.changes.map(({token:m,amount:h})=>{let L=h.startsWith("-");return`${L?"-":"+"}${s.formatAmount(L?h.slice(1):h,m.decimals)} ${m.symbol} (${m.address}, chain ${m.chainId})`}).join("; ");return{txs:t,preview:n,expectedOutput:a,minimumOutput:{token:a.token,amount:o},minimumEnforcedOnchain:!1,summary:`${r} ${u}. Simulation only; no on-chain minimum is enforced by these ERC-4626 calls. ${n.summary}`}}async function W(t){C(t,[]);let e=await c();return Promise.all(A.map(async a=>{let[r,o,n,p]=await Promise.all([v(e,a),e.readContract({address:a.vault,abi:d,functionName:"totalAssets"}),e.readContract({address:a.vault,abi:d,functionName:"performanceFee"}),e.readContract({address:a.vault,abi:d,functionName:"managementFee"})]);return{...r,totalAssets:{token:r.asset,amount:f(o).toString()},fees:{performanceFeeE18:f(n).toString(),managementFeeE18:f(p).toString()},caveat:"Morpho V2 max views can be zero even when writes succeed. Simulate the requested action; listing does not prove availability."}}))}async function O(t,e){C(t,["vault","amount","wrapEth"]),b(e);let a=F(t.vault),r=U(t.amount,"Deposit amount");if(t.wrapEth!==void 0&&typeof t.wrapEth!="boolean")throw new i("wrapEth must be a boolean.");if(t.wrapEth&&a.asset.toLowerCase()!==g.tokens.WETH.address.toLowerCase())throw new i("Only a WETH vault accepts explicit ETH wrapping.");let o=await c(),n=await v(o,a),p=f(await o.readContract({address:n.vault,abi:d,functionName:"previewDeposit",args:[r]})),u=[];return t.wrapEth&&u.push(s.unsignedTx({to:n.asset.address,data:k({abi:_,functionName:"deposit"}),value:r.toString(),chainId:l,description:`Wrap ${s.formatAmount(r.toString(),18)} ETH into WETH for ${n.name}.`})),u.push(s.approval(n.asset.address,n.vault,r.toString(),l)),u.push(s.unsignedTx({to:n.vault,data:k({abi:d,functionName:"deposit",args:[r,y(e)]}),value:"0",chainId:l,description:`Deposit ${s.formatAmount(r.toString(),n.asset.decimals)} ${n.asset.symbol} into ${n.name}.`})),E(u,e,{token:n.share,amount:p.toString()},`Deposit into ${n.name}.`)}async function G(t,e){C(t,["vault","shares"]),b(e);let a=F(t.vault),r=t.shares==="all"?void 0:U(t.shares,"Redeem shares"),o=await c(),n=await v(o,a),p=f(await o.readContract({address:n.vault,abi:d,functionName:"balanceOf",args:[e]})),u=r??p;if(u===0n||u>p)throw new i("The wallet has insufficient Longbow shares for this redemption.");let m=f(await o.readContract({address:n.vault,abi:d,functionName:"previewRedeem",args:[u]})),h=[s.unsignedTx({to:n.vault,data:k({abi:d,functionName:"redeem",args:[u,y(e),y(e)]}),value:"0",chainId:l,description:`Redeem ${s.formatAmount(u.toString(),n.share.decimals)} shares from ${n.name} into ${n.asset.symbol}.`})];return E(h,e,{token:n.asset,amount:m.toString()},`Redeem from ${n.name}.`)}let P={type:"string",enum:A.map(t=>t.vault),description:"Current vault address on chain 4663."},S={type:"string",pattern:"^[0-9]+$",description:"Positive integer base units, never a human-unit decimal."},T=(t,e,a,r)=>({name:t,inputSchema:{type:"object",properties:e,required:a,additionalProperties:!1},execute:(o,n)=>w(()=>r(o,n))});return{tools:[T("longbow_list",{},[],W),T("longbow_deposit",{vault:P,amount:S,wrapEth:{type:"boolean",default:!1,description:"Explicitly wrap this amount of native ETH before depositing into the WETH vault."}},["vault","amount"],O),T("longbow_withdraw",{vault:P,shares:{anyOf:[S,{const:"all"}],description:"Share base units (18 decimals), or all for the fresh wallet share balance. Returns the underlying asset, including WETH."}},["vault","shares"],G)],positions:t=>w(async()=>{b(t);let e=await c();return(await Promise.all(A.map(async r=>{let o=await v(e,r),n=f(await e.readContract({address:o.vault,abi:d,functionName:"balanceOf",args:[t]}));if(n===0n)return[];let p=f(await e.readContract({address:o.vault,abi:d,functionName:"previewRedeem",args:[n]}));return[{module:"longbow",id:`${l}:${o.vault.toLowerCase()}`,chainId:l,assets:[{token:o.asset,amount:p.toString()}],description:`${o.name}: ${s.formatAmount(n.toString(),o.share.decimals)} shares (${o.share.address}, ${o.share.decimals} decimals). Underlying is a preview, not a guaranteed redemption.`}]}))).flat()})}};function Q(s){return I("longbow",[j(s)])}export{Q as createModule,j as createModulePart};
1
+ import{b as N,o as U}from"../../../chunks/2IRORNOH.js";import"../../../chunks/GDP4JSAX.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/Y3P6SUNL.js";import"../../../chunks/GIBF3YJO.js";import{b as I}from"../../../chunks/UCMNB2UP.js";import"../../../chunks/Z25UKUJF.js";import{a as b}from"../../../chunks/A5ITAEUQ.js";import{a as D}from"../../../chunks/I5CQ64EU.js";import"../../../chunks/NA7HV7BR.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/M6JGTQRY.js";import{a as l,i as $}from"../../../chunks/ZUC6ILK2.js";import"../../../chunks/B4MLWDPM.js";import{a as i}from"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";import{encodeFunctionData as k,getAddress as y,parseAbi as R}from"viem";var d=R(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)","function balanceOf(address) view returns (uint256)","function previewDeposit(uint256 assets) view returns (uint256)","function previewRedeem(uint256 shares) view returns (uint256)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),G=R(["function deposit() payable"]),g=$[l],H=(1n<<256n)-1n,A=[{key:"core",name:"Longbow Core USDG",vault:g.vaults.longbowCore.address,asset:g.tokens.USDG.address,symbol:"USDG",decimals:6},{key:"frontier",name:"Longbow Frontier USDG",vault:g.vaults.longbowFrontier.address,asset:g.tokens.USDG.address,symbol:"USDG",decimals:6},{key:"eth",name:"Longbow ETH",vault:g.vaults.longbowEth.address,asset:g.tokens.WETH.address,symbol:"WETH",decimals:18}];function M(s,w){if(typeof s!="string")throw new i(`${w} must be a positive integer string in base units.`);let c=D(s);if(c===0n||c>H)throw new i(`${w} must be positive and within the uint256 range.`);return c}function f(s){if(typeof s!="bigint"||s<0n||s>H)throw new i("Longbow returned an invalid integer response.");return s}function F(s){if(typeof s!="string")throw new i("Provide the address of a current Longbow vault.");let w=A.find(c=>c.vault.toLowerCase()===s.toLowerCase());if(!w)throw new i("Provide the address of a current Longbow vault. Legacy vaults are not supported.");return w}function C(s,w){if(Object.keys(s).some(c=>!w.includes(c)))throw new i("Unsupported Longbow input. Use the fields in the tool schema.")}var _=s=>{async function w(t){try{return await t()}catch(e){throw new i(s.plainError(e))}}async function c(){let t=s.clientFor(l);if(await t.getChainId()!==l)throw new i("Longbow requires a client on chain 4663.");return t}async function v(t,e){let[a,r,o]=await Promise.all([t.readContract({address:e.vault,abi:d,functionName:"asset"}),t.readContract({address:e.vault,abi:d,functionName:"decimals"}),t.readContract({address:e.asset,abi:d,functionName:"decimals"})]);if(typeof a!="string"||a.toLowerCase()!==e.asset.toLowerCase())throw new i("Longbow vault asset does not match the recorded deployment.");if(r!==18||o!==e.decimals)throw new i("Longbow token decimals do not match the recorded deployment.");return{vault:e.vault,key:e.key,name:e.name,asset:{address:y(e.asset),symbol:e.symbol,decimals:o,chainId:l},share:{address:e.vault,symbol:`${e.key} shares`,decimals:r,chainId:l}}}async function E(t,e,a,r){let o=U(a.amount,N);if(BigInt(o)===0n)throw new i("The expected output is too small for a nonzero simulation minimum.");let n=await s.preview(t,e);if(n.changes.filter(m=>m.token.chainId===a.token.chainId&&m.token.address.toLowerCase()===a.token.address.toLowerCase()&&m.token.decimals===a.token.decimals).reduce((m,h)=>m+BigInt(h.amount),0n)<BigInt(o))throw new i("Longbow simulated output is below the expected minimum.");let u=n.changes.map(({token:m,amount:h})=>{let L=h.startsWith("-");return`${L?"-":"+"}${s.formatAmount(L?h.slice(1):h,m.decimals)} ${m.symbol} (${m.address}, chain ${m.chainId})`}).join("; ");return{txs:t,preview:n,expectedOutput:a,minimumOutput:{token:a.token,amount:o},minimumEnforcedOnchain:!1,summary:`${r} ${u}. Simulation only; no on-chain minimum is enforced by these ERC-4626 calls. ${n.summary}`}}async function W(t){C(t,[]);let e=await c();return Promise.all(A.map(async a=>{let[r,o,n,p]=await Promise.all([v(e,a),e.readContract({address:a.vault,abi:d,functionName:"totalAssets"}),e.readContract({address:a.vault,abi:d,functionName:"performanceFee"}),e.readContract({address:a.vault,abi:d,functionName:"managementFee"})]);return{...r,totalAssets:{token:r.asset,amount:f(o).toString()},fees:{performanceFeeE18:f(n).toString(),managementFeeE18:f(p).toString()},caveat:"Morpho V2 max views can be zero even when writes succeed. Simulate the requested action; listing does not prove availability."}}))}async function O(t,e){C(t,["vault","amount","wrapEth"]),b(e);let a=F(t.vault),r=M(t.amount,"Deposit amount");if(t.wrapEth!==void 0&&typeof t.wrapEth!="boolean")throw new i("wrapEth must be a boolean.");if(t.wrapEth&&a.asset.toLowerCase()!==g.tokens.WETH.address.toLowerCase())throw new i("Only a WETH vault accepts explicit ETH wrapping.");let o=await c(),n=await v(o,a),p=f(await o.readContract({address:n.vault,abi:d,functionName:"previewDeposit",args:[r]})),u=[];return t.wrapEth&&u.push(s.unsignedTx({to:n.asset.address,data:k({abi:G,functionName:"deposit"}),value:r.toString(),chainId:l,description:`Wrap ${s.formatAmount(r.toString(),18)} ETH into WETH for ${n.name}.`})),u.push(s.approval(n.asset.address,n.vault,r.toString(),l)),u.push(s.unsignedTx({to:n.vault,data:k({abi:d,functionName:"deposit",args:[r,y(e)]}),value:"0",chainId:l,description:`Deposit ${s.formatAmount(r.toString(),n.asset.decimals)} ${n.asset.symbol} into ${n.name}.`})),E(u,e,{token:n.share,amount:p.toString()},`Deposit into ${n.name}.`)}async function x(t,e){C(t,["vault","shares"]),b(e);let a=F(t.vault),r=t.shares==="all"?void 0:M(t.shares,"Redeem shares"),o=await c(),n=await v(o,a),p=f(await o.readContract({address:n.vault,abi:d,functionName:"balanceOf",args:[e]})),u=r??p;if(u===0n||u>p)throw new i("The wallet has insufficient Longbow shares for this redemption.");let m=f(await o.readContract({address:n.vault,abi:d,functionName:"previewRedeem",args:[u]})),h=[s.unsignedTx({to:n.vault,data:k({abi:d,functionName:"redeem",args:[u,y(e),y(e)]}),value:"0",chainId:l,description:`Redeem ${s.formatAmount(u.toString(),n.share.decimals)} shares from ${n.name} into ${n.asset.symbol}.`})];return E(h,e,{token:n.asset,amount:m.toString()},`Redeem from ${n.name}.`)}let P={type:"string",enum:A.map(t=>t.vault),description:"Current vault address on chain 4663."},S={type:"string",pattern:"^[0-9]+$",description:"Positive integer base units, never a human-unit decimal."},T=(t,e,a,r)=>({name:t,inputSchema:{type:"object",properties:e,required:a,additionalProperties:!1},execute:(o,n)=>w(()=>r(o,n))});return{tools:[T("longbow_list",{},[],W),T("longbow_deposit",{vault:P,amount:S,wrapEth:{type:"boolean",default:!1,description:"Explicitly wrap this amount of native ETH before depositing into the WETH vault."}},["vault","amount"],O),T("longbow_withdraw",{vault:P,shares:{anyOf:[S,{const:"all"}],description:"Share base units (18 decimals), or all for the fresh wallet share balance. Returns the underlying asset, including WETH."}},["vault","shares"],x)],positions:t=>w(async()=>{b(t);let e=await c();return(await Promise.all(A.map(async r=>{let o=await v(e,r),n=f(await e.readContract({address:o.vault,abi:d,functionName:"balanceOf",args:[t]}));if(n===0n)return[];let p=f(await e.readContract({address:o.vault,abi:d,functionName:"previewRedeem",args:[n]}));return[{module:"longbow",id:`${l}:${o.vault.toLowerCase()}`,chainId:l,assets:[{token:o.asset,amount:p.toString()}],description:`${o.name}: ${s.formatAmount(n.toString(),o.share.decimals)} shares (${o.share.address}, ${o.share.decimals} decimals). Underlying is a preview, not a guaranteed redemption.`}]}))).flat()})}};function Q(s){return I("longbow",[_(s)])}export{Q as createModule,_ as createModulePart};
@@ -1 +1 @@
1
- import{b as t}from"../../../chunks/IABIXUNX.js";import{a as o}from"../../../chunks/AE6YEEZP.js";import"../../../chunks/VBV366XQ.js";import"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/P7Q6MJZH.js";import"../../../chunks/64EN6Y7E.js";import{b as r}from"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import"../../../chunks/25EOXUBI.js";import"../../../chunks/B5RZYFQC.js";import"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";var i=e=>r("meridian",[t(e),o(e)]);export{i as createModule};
1
+ import{b as o}from"../../../chunks/ICCJ3TOO.js";import{b as m}from"../../../chunks/QGDHMVPE.js";import{a as i}from"../../../chunks/KVVTKM6E.js";import"../../../chunks/2IRORNOH.js";import"../../../chunks/GDP4JSAX.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/Y3P6SUNL.js";import"../../../chunks/GIBF3YJO.js";import{b as a}from"../../../chunks/UCMNB2UP.js";import"../../../chunks/Z25UKUJF.js";import"../../../chunks/A5ITAEUQ.js";import"../../../chunks/I5CQ64EU.js";import"../../../chunks/NA7HV7BR.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/M6JGTQRY.js";import"../../../chunks/ZUC6ILK2.js";import"../../../chunks/B4MLWDPM.js";import"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";var p=r=>{let t=i(r);return a("meridian",[m(r),{...t,tools:t.tools.map(e=>e.name==="meridian_buy"?{...e,execute:async()=>({summary:o.get("meridian_buy")})}:e)}])};export{p as createModule};
@@ -1 +1 @@
1
- import{a,b}from"../../../chunks/IABIXUNX.js";import"../../../chunks/25EOXUBI.js";import"../../../chunks/B5RZYFQC.js";import"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";export{a as createMarketsPart,b as createModulePart};
1
+ import{a,b}from"../../../chunks/QGDHMVPE.js";import"../../../chunks/I5CQ64EU.js";import"../../../chunks/ZUC6ILK2.js";import"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";export{a as createMarketsPart,b as createModulePart};
@@ -1 +1 @@
1
- import{a}from"../../../chunks/AE6YEEZP.js";import"../../../chunks/VBV366XQ.js";import"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/P7Q6MJZH.js";import"../../../chunks/64EN6Y7E.js";import"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import"../../../chunks/25EOXUBI.js";import"../../../chunks/B5RZYFQC.js";import"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";export{a as createModulePart};
1
+ import{a}from"../../../chunks/KVVTKM6E.js";import"../../../chunks/2IRORNOH.js";import"../../../chunks/GDP4JSAX.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/Y3P6SUNL.js";import"../../../chunks/GIBF3YJO.js";import"../../../chunks/A5ITAEUQ.js";import"../../../chunks/I5CQ64EU.js";import"../../../chunks/NA7HV7BR.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/M6JGTQRY.js";import"../../../chunks/ZUC6ILK2.js";import"../../../chunks/B4MLWDPM.js";import"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";export{a as createModulePart};
@@ -1 +1 @@
1
- import{c as v}from"../../../chunks/ZUAXW2ZD.js";import"../../../chunks/64EN6Y7E.js";import{b as M}from"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import{a as g}from"../../../chunks/VZWOWR6G.js";import{a as c,i as A}from"../../../chunks/25EOXUBI.js";import{a as P}from"../../../chunks/B5RZYFQC.js";import{a as m}from"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";import{encodeAbiParameters as I,encodeFunctionData as S,keccak256 as T,parseAbi as E}from"viem";var h=A[c].merkl.distributor.address,k="Claim rewards on Merkl (Powered by Merkl \u2014 https://app.merkl.xyz)",x=`${k}. No claimable rewards on Robinhood Chain. Pending rewards must settle into a Merkle root before they can be claimed.`,b=E(["function claimed(address user,address token) view returns (uint208 amount,uint48 timestamp,bytes32 merkleRoot)","function getMerkleRoot() view returns (bytes32)","function claim(address[] users,address[] tokens,uint256[] amounts,bytes32[][] proofs)"]);function w(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function C(r){return typeof r=="string"&&/^0x[0-9a-fA-F]{64}$/.test(r)}function y(){throw new m("Merkl returned an unexpected response. Please refetch rewards.")}function $(r){typeof r!="string"&&y();let a=P(r);if(a>=1n<<256n)throw new m("The Merkl reward amount exceeds the uint256 range.");return a.toString()}function N(r){let a=[],p=new Set;for(let s of r)if((!w(s)||!w(s.chain)||!Number.isSafeInteger(s.chain.id))&&y(),s.chain.id===c){Array.isArray(s.rewards)||y();for(let e of s.rewards){if((!w(e)||typeof e.distributionLayer!="string"||!w(e.token))&&y(),e.distributionLayer!=="TREE"||(Number.isSafeInteger(e.token.chainId)||y(),e.token.chainId!==c)||(Array.isArray(e.proofs)||y(),!e.proofs.length))continue;(!e.proofs.every(C)||typeof e.token.address!="string"||typeof e.token.symbol!="string"||!e.token.symbol.trim()||typeof e.token.decimals!="number"||!Number.isInteger(e.token.decimals)||e.token.decimals<0||e.token.decimals>255)&&y(),g(e.token.address);let t=$(e.amount),n=$(e.pending);if(BigInt(t)===0n)continue;let o=e.token.address.toLowerCase();if(p.has(o))throw new m("Merkl returned duplicate token leaves. Please refetch rewards.");p.add(o),a.push({token:{address:e.token.address,chainId:c,decimals:e.token.decimals,symbol:e.token.symbol},amount:t,pending:n,proofs:e.proofs})}}return a}function j(r,a,p){let s=T(I([{type:"address"},{type:"address"},{type:"uint256"}],[r,a.token.address,BigInt(a.amount)]));for(let e of a.proofs){let t=BigInt(s)<BigInt(e)?[s,e]:[e,s];s=T(I([{type:"bytes32"},{type:"bytes32"}],t))}if(s.toLowerCase()!==p.toLowerCase())throw new m("The Merkl proof does not match the active root. Please refetch rewards.")}function R(r){if(!w(r)||Object.keys(r).length)throw new m("This Merkl tool takes no arguments and uses the connected wallet.")}var B=r=>{async function a(t){try{return await t()}catch(n){throw new m(r.plainError(n))}}function p(t){let n=t.amount.startsWith("-"),o=n?t.amount.slice(1):t.amount;return`${n?"-":""}${r.formatAmount(o,t.token.decimals)} ${t.token.symbol} (${t.token.address}, chain ${t.token.chainId}, ${t.token.decimals} decimals)`}async function s(t){g(t);let n=await v(r.http,`https://api.merkl.xyz/v4/users/${t}/rewards/summary?chainId=${c}`,{method:"GET",headers:{"User-Agent":"oak-core/merkl"}},l=>Array.isArray(l)),o=N(n);if(!o.length)return[];let i=r.clientFor(c),d=[];for(let l of o){let f=await i.readContract({address:h,abi:b,functionName:"claimed",args:[t,l.token.address]});if(!Array.isArray(f)||typeof f[0]!="bigint"||f[0]<0n||f[0]>=1n<<208n)throw new m("The Merkl claimed balance could not be read. Please try again.");BigInt(l.amount)<=f[0]||d.push({...l,claimed:f[0].toString(),claimable:(BigInt(l.amount)-f[0]).toString()})}if(!d.length)return[];let u=await i.readContract({address:h,abi:b,functionName:"getMerkleRoot"});if(!C(u))throw new m("The active Merkl root could not be read. Please try again.");for(let l of d)j(t,l,u);return d}return{tools:[{name:"merkl_rewards",description:"Read claimable rewards (Powered by Merkl \u2014 https://app.merkl.xyz).",inputSchema:{type:"object",properties:{},additionalProperties:!1,description:"Read rewards (Powered by Merkl \u2014 https://app.merkl.xyz)."},execute:(t,n)=>a(async()=>{R(t);let o=await s(n);return{rewards:o.map(({proofs:i,...d})=>d),summary:o.length?`${k}. Claimable reward leaves: ${o.map(i=>p({token:i.token,amount:i.claimable})).join("; ")}. Wrapped leaves may transfer underlying tokens; claim preview shows the received assets. Pending rewards are excluded.`:x}})},{name:"merkl_claim",description:k,inputSchema:{type:"object",properties:{},additionalProperties:!1,description:k},execute:(t,n)=>a(async()=>{R(t);let o=await s(n);if(!o.length)return{txs:[],summary:x};let i=[r.unsignedTx({to:h,chainId:c,value:"0",description:k,data:S({abi:b,functionName:"claim",args:[o.map(()=>n),o.map(u=>u.token.address),o.map(u=>BigInt(u.amount)),o.map(u=>u.proofs)]})})],d=await r.preview(i,n);return{txs:i,summary:`${k}. Prepared unsigned claim. Expected wallet changes: ${d.changes.length?d.changes.map(p).join("; "):"no token transfers in simulation"}. ${d.summary}`}})}],positions:t=>a(async()=>(await s(t)).map(n=>({module:"merkl",id:`${c}:${n.token.address.toLowerCase()}`,chainId:c,assets:[{token:n.token,amount:n.claimable}],description:`${k}. Unclaimed reward leaf; wrapped rewards may transfer underlying assets. Pending rewards are excluded.`})))}},_=r=>M("merkl",[B(r)]);export{_ as createModule,B as createModulePart};
1
+ import{c as v}from"../../../chunks/MK6L6TGI.js";import"../../../chunks/Y3P6SUNL.js";import{b as M}from"../../../chunks/UCMNB2UP.js";import"../../../chunks/Z25UKUJF.js";import{a as g}from"../../../chunks/A5ITAEUQ.js";import{a as P}from"../../../chunks/I5CQ64EU.js";import"../../../chunks/NA7HV7BR.js";import{a as c,i as A}from"../../../chunks/ZUC6ILK2.js";import{a as m}from"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";import{encodeAbiParameters as I,encodeFunctionData as S,keccak256 as T,parseAbi as E}from"viem";var h=A[c].merkl.distributor.address,k="Claim rewards on Merkl (Powered by Merkl \u2014 https://app.merkl.xyz)",x=`${k}. No claimable rewards on Robinhood Chain. Pending rewards must settle into a Merkle root before they can be claimed.`,b=E(["function claimed(address user,address token) view returns (uint208 amount,uint48 timestamp,bytes32 merkleRoot)","function getMerkleRoot() view returns (bytes32)","function claim(address[] users,address[] tokens,uint256[] amounts,bytes32[][] proofs)"]);function w(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function C(r){return typeof r=="string"&&/^0x[0-9a-fA-F]{64}$/.test(r)}function y(){throw new m("Merkl returned an unexpected response. Please refetch rewards.")}function $(r){typeof r!="string"&&y();let a=P(r);if(a>=1n<<256n)throw new m("The Merkl reward amount exceeds the uint256 range.");return a.toString()}function N(r){let a=[],p=new Set;for(let s of r)if((!w(s)||!w(s.chain)||!Number.isSafeInteger(s.chain.id))&&y(),s.chain.id===c){Array.isArray(s.rewards)||y();for(let e of s.rewards){if((!w(e)||typeof e.distributionLayer!="string"||!w(e.token))&&y(),e.distributionLayer!=="TREE"||(Number.isSafeInteger(e.token.chainId)||y(),e.token.chainId!==c)||(Array.isArray(e.proofs)||y(),!e.proofs.length))continue;(!e.proofs.every(C)||typeof e.token.address!="string"||typeof e.token.symbol!="string"||!e.token.symbol.trim()||typeof e.token.decimals!="number"||!Number.isInteger(e.token.decimals)||e.token.decimals<0||e.token.decimals>255)&&y(),g(e.token.address);let t=$(e.amount),n=$(e.pending);if(BigInt(t)===0n)continue;let o=e.token.address.toLowerCase();if(p.has(o))throw new m("Merkl returned duplicate token leaves. Please refetch rewards.");p.add(o),a.push({token:{address:e.token.address,chainId:c,decimals:e.token.decimals,symbol:e.token.symbol},amount:t,pending:n,proofs:e.proofs})}}return a}function j(r,a,p){let s=T(I([{type:"address"},{type:"address"},{type:"uint256"}],[r,a.token.address,BigInt(a.amount)]));for(let e of a.proofs){let t=BigInt(s)<BigInt(e)?[s,e]:[e,s];s=T(I([{type:"bytes32"},{type:"bytes32"}],t))}if(s.toLowerCase()!==p.toLowerCase())throw new m("The Merkl proof does not match the active root. Please refetch rewards.")}function R(r){if(!w(r)||Object.keys(r).length)throw new m("This Merkl tool takes no arguments and uses the connected wallet.")}var B=r=>{async function a(t){try{return await t()}catch(n){throw new m(r.plainError(n))}}function p(t){let n=t.amount.startsWith("-"),o=n?t.amount.slice(1):t.amount;return`${n?"-":""}${r.formatAmount(o,t.token.decimals)} ${t.token.symbol} (${t.token.address}, chain ${t.token.chainId}, ${t.token.decimals} decimals)`}async function s(t){g(t);let n=await v(r.http,`https://api.merkl.xyz/v4/users/${t}/rewards/summary?chainId=${c}`,{method:"GET",headers:{"User-Agent":"oak-core/merkl"}},l=>Array.isArray(l)),o=N(n);if(!o.length)return[];let i=r.clientFor(c),d=[];for(let l of o){let f=await i.readContract({address:h,abi:b,functionName:"claimed",args:[t,l.token.address]});if(!Array.isArray(f)||typeof f[0]!="bigint"||f[0]<0n||f[0]>=1n<<208n)throw new m("The Merkl claimed balance could not be read. Please try again.");BigInt(l.amount)<=f[0]||d.push({...l,claimed:f[0].toString(),claimable:(BigInt(l.amount)-f[0]).toString()})}if(!d.length)return[];let u=await i.readContract({address:h,abi:b,functionName:"getMerkleRoot"});if(!C(u))throw new m("The active Merkl root could not be read. Please try again.");for(let l of d)j(t,l,u);return d}return{tools:[{name:"merkl_rewards",description:"Read claimable rewards (Powered by Merkl \u2014 https://app.merkl.xyz).",inputSchema:{type:"object",properties:{},additionalProperties:!1,description:"Read rewards (Powered by Merkl \u2014 https://app.merkl.xyz)."},execute:(t,n)=>a(async()=>{R(t);let o=await s(n);return{rewards:o.map(({proofs:i,...d})=>d),summary:o.length?`${k}. Claimable reward leaves: ${o.map(i=>p({token:i.token,amount:i.claimable})).join("; ")}. Wrapped leaves may transfer underlying tokens; claim preview shows the received assets. Pending rewards are excluded.`:x}})},{name:"merkl_claim",description:k,inputSchema:{type:"object",properties:{},additionalProperties:!1,description:k},execute:(t,n)=>a(async()=>{R(t);let o=await s(n);if(!o.length)return{txs:[],summary:x};let i=[r.unsignedTx({to:h,chainId:c,value:"0",description:k,data:S({abi:b,functionName:"claim",args:[o.map(()=>n),o.map(u=>u.token.address),o.map(u=>BigInt(u.amount)),o.map(u=>u.proofs)]})})],d=await r.preview(i,n);return{txs:i,summary:`${k}. Prepared unsigned claim. Expected wallet changes: ${d.changes.length?d.changes.map(p).join("; "):"no token transfers in simulation"}. ${d.summary}`}})}],positions:t=>a(async()=>(await s(t)).map(n=>({module:"merkl",id:`${c}:${n.token.address.toLowerCase()}`,chainId:c,assets:[{token:n.token,amount:n.claimable}],description:`${k}. Unclaimed reward leaf; wrapped rewards may transfer underlying assets. Pending rewards are excluded.`})))}},_=r=>M("merkl",[B(r)]);export{_ as createModule,B as createModulePart};
@@ -52,7 +52,7 @@ export interface MorphoActionOutput {
52
52
  readonly lltv: DecimalString;
53
53
  };
54
54
  readonly txs: UnsignedTx[];
55
- readonly steps: UnsignedTx[];
55
+ readonly steps?: never;
56
56
  readonly summary: string;
57
57
  readonly preview: Preview;
58
58
  readonly formattedChanges: FormattedTokenChange[];
@@ -1,4 +1,4 @@
1
- import{b as de,c as ue,d as me}from"../../../chunks/KFMNCJXJ.js";import"../../../chunks/6YU3JLQQ.js";import"../../../chunks/D45AODDL.js";import"../../../chunks/24JYIH53.js";import{e as ce,f as I}from"../../../chunks/VBV366XQ.js";import{a as le}from"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/P7Q6MJZH.js";import"../../../chunks/ZUAXW2ZD.js";import"../../../chunks/64EN6Y7E.js";import{b as ie}from"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import{a as D}from"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import{a as u,i as N}from"../../../chunks/25EOXUBI.js";import{a as H}from"../../../chunks/B5RZYFQC.js";import{a as d,c as se}from"../../../chunks/T5E4OJEU.js";import{a as oe}from"../../../chunks/XN4WDN3O.js";import{decodeAbiParameters as _,encodeAbiParameters as Te,encodeFunctionData as T,erc20Abi as re,getAddress as b,isAddress as he,keccak256 as Pe,parseAbi as z,parseAbiParameters as $}from"viem";var we="morpho",Me="https://api.morpho.org/graphql",v=b(N[u].morpho.morpho_blue.address),ve=b(N[u].morpho.adaptive_curve_irm.address),Ce=b(N[u].morpho.USDG.address),V=b(N[u].morpho.WETH.address),ne=["0x7c820d6a09502d63be80bb8025ec479d29d7c06e70f8df65a92aaeed23a366e2","0x1fa5293f9f60059a7f6a4923022156fcdcc038bd3749be55897000c03afe92d8"],U=120n,K=1000000n,Q=1n,L=10n**18n,Be=10n**36n,fe=(1n<<128n)-1n,xe=(1n<<256n)-1n,E=z(["function idToMarketParams(bytes32 id) view returns (address loanToken, address collateralToken, address oracle, address irm, uint256 lltv)","function market(bytes32 id) view returns (uint128 totalSupplyAssets, uint128 totalSupplyShares, uint128 totalBorrowAssets, uint128 totalBorrowShares, uint128 lastUpdate, uint128 fee)","function position(bytes32 id, address user) view returns (uint256 supplyShares, uint128 borrowShares, uint128 collateral)","function supplyCollateral((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, bytes data)","function withdrawCollateral((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, address receiver)","function borrow((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, address receiver) returns (uint256 assetsBorrowed, uint256 sharesBorrowed)","function repay((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, bytes data) returns (uint256 assetsRepaid, uint256 sharesRepaid)"]),$e=z(["function price() view returns (uint256)"]),Ie=z(["function borrowRateView((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, (uint128 totalSupplyAssets, uint128 totalSupplyShares, uint128 totalBorrowAssets, uint128 totalBorrowShares, uint128 lastUpdate, uint128 fee) market) view returns (uint256)"]),_e=z(["function deposit() payable"]);function j(e,t){return e===0n?0n:(e+t-1n)/t}function rt(e,t,o){return e*(o+K)/(t+Q)}function Oe(e,t,o){return j(e*(o+K),t+Q)}function ke(e,t,o){return e*(t+Q)/(o+K)}function q(e,t,o){return j(e*(t+Q),o+K)}function X(e,t,o){return e*t/Be*o/L}function Re(e,t,o){return t.startsWith("-")?`-${e.formatAmount(t.slice(1),o)}`:e.formatAmount(t,o)}function J(e,t){let o=[],r={};for(let i of t.changes){let a=Re(e,i.amount,i.token.decimals);o.push({token:i.token,amount:i.amount,formattedAmount:a}),r[i.token.address.toLowerCase()]=a}return{formattedChanges:o,formattedNetOutflows:r}}function Ee(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new d("Morpho marketId must be a 32-byte hex string.");return e.toLowerCase()}function ye(e){if(!e||typeof e!="object")throw new d("Morpho marketParams must be an object.");for(let n of[e.loanToken,e.collateralToken,e.oracle,e.irm])if(typeof n!="string"||!he(n,{strict:!1}))throw new d("Morpho marketParams contains an invalid address.");let t=b(e.loanToken),o=b(e.collateralToken),r=b(e.oracle),i=b(e.irm),a=typeof e.lltv=="bigint"?e.lltv:H(String(e.lltv));if(t===I||o===I||r===I)throw new d("Morpho marketParams loan, collateral, and oracle addresses must be non-zero.");if(a<=0n||a>=L)throw new d("Morpho marketParams LLTV must be between 0 and 1e18.");return{loanToken:t,collateralToken:o,oracle:r,irm:i,lltv:a}}function pe(e){let t=ye(e),o=Te($("address, address, address, address, uint256"),[t.loanToken,t.collateralToken,t.oracle,t.irm,t.lltv]);return Pe(o)}function ae(e){let t=e.toLowerCase();return t===le.toLowerCase()||t===ce.toLowerCase()||t===I.toLowerCase()}function Y(e,t){let o=t??e.wallet;if(!o)throw new d("Provide a valid wallet address.");return D(o),b(o)}async function O(e,t,o){if(typeof e.call=="function"){let r=await e.call({to:t,data:o});if(r&&typeof r.data=="string")return r.data}if(typeof e.request=="function"){let r=await e.request({method:"eth_call",params:[{to:t,data:o},"latest"]});if(typeof r=="string")return r}throw new d(`Unable to execute eth_call on contract ${t}.`)}async function R(e,t,o=u){if(D(t),ae(t))return{...de,chainId:o};let r=b(t),i=r.toLowerCase();if(o===u){if(i===Ce.toLowerCase())return ue;if(i===V.toLowerCase())return me}let[a,n]=await Promise.all([O(e,r,T({abi:re,functionName:"symbol"})),O(e,r,T({abi:re,functionName:"decimals"}))]),[s]=_($("string"),a),[l]=_($("uint8"),n);return{address:r,symbol:s,decimals:Number(l),chainId:o}}async function be(e,t){let o=await O(e,v,T({abi:E,functionName:"idToMarketParams",args:[t]})),[r,i,a,n,s]=_($("address, address, address, address, uint256"),o);return{loanToken:b(r),collateralToken:b(i),oracle:b(a),irm:b(n),lltv:s}}async function Se(e,t){let o=await O(e,v,T({abi:E,functionName:"market",args:[t]})),[r,i,a,n,s,l]=_($("uint128, uint128, uint128, uint128, uint128, uint128"),o);return{totalSupplyAssets:r,totalSupplyShares:i,totalBorrowAssets:a,totalBorrowShares:n,lastUpdate:s,fee:l}}async function W(e,t,o){let r=await O(e,v,T({abi:E,functionName:"position",args:[t,b(o)]})),[i,a,n]=_($("uint256, uint128, uint128"),r);return{supplyShares:i,borrowShares:a,collateral:n}}async function Z(e,t){let o=await O(e,b(t),T({abi:$e,functionName:"price"})),[r]=_($("uint256"),o);return r}async function Le(e,t,o){if(t.irm===I)return 0n;let r=await O(e,b(t.irm),T({abi:Ie,functionName:"borrowRateView",args:[t,o]})),[i]=_($("uint256"),r);return i}function Ne(e,t,o){let r=o>e.lastUpdate?o-e.lastUpdate:0n,i=t*r,a=j(i*i,2n*L),n=j(a*i,3n*L);return e.totalBorrowAssets+j(e.totalBorrowAssets*(i+a+n),L)}async function F(e,t,o,r=0n){let[i,a]=await Promise.all([e.getBlock({blockTag:"latest"}),Le(e,t,o)]),n=BigInt(Math.ceil(Date.now()/1e3)),s=(i.timestamp>n?i.timestamp:n)+r;return{totalBorrowAssets:Ne(o,a,s),accruedThrough:s,rate:a}}async function He(e,t,o){let r=await O(e,b(t),T({abi:re,functionName:"balanceOf",args:[b(o)]})),[i]=_($("uint256"),r);return i}async function G(e,t,o=!1){let r=t.marketId,i=t.marketParams;if(!r&&!i)throw new d("Provide either marketId or marketParams for the Morpho Blue market.");let a=i?ye(i):void 0,n=a?pe(a):void 0,s=r!==void 0?Ee(r):void 0;if(s&&n&&s!==n.toLowerCase())throw new d(`MarketParams tuple hash (${n}) does not match marketId (${s}).`);let l=s??n;if(o&&!ne.includes(l))throw new d("Morpho actions require a known market with a pinned oracle.");let[c,p]=await Promise.all([be(e,l),Se(e,l)]);if(c.loanToken===I||c.collateralToken===I||c.lltv===0n||p.lastUpdate===0n)throw new d(`Morpho market ${l} is not initialized on chain ${u}.`);let m=pe(c);if(m.toLowerCase()!==l.toLowerCase())throw new d(`On-chain idToMarketParams tuple hash (${m}) does not match marketId (${l}).`);if(a&&!(a.loanToken.toLowerCase()===c.loanToken.toLowerCase()&&a.collateralToken.toLowerCase()===c.collateralToken.toLowerCase()&&a.oracle.toLowerCase()===c.oracle.toLowerCase()&&a.irm.toLowerCase()===c.irm.toLowerCase()&&a.lltv===c.lltv))throw new d(`Provided marketParams tuple does not match on-chain idToMarketParams for ${l}.`);return{marketId:l,marketParams:c,marketState:p}}function ee(e){if(e.assets!==void 0&&e.amount!==void 0)throw new d("Specify either assets or amount, not both.");let t=e.assets??e.amount;if(typeof t!="string")throw new d("Provide an amount as a base-unit integer string.");let o=H(t);if(o<=0n||o>fe)throw new d("Asset amount must be greater than zero and fit in uint128.");return o}function te(e,t){for(let o of["onBehalf","receiver"])if(e[o]!==void 0&&(typeof e[o]!="string"||e[o].toLowerCase()!==t.toLowerCase()))throw new d(`Morpho ${o} must be the wallet; overrides are not supported.`);if(e.data!==void 0&&e.data!=="0x")throw new d("Morpho callback data must be empty (0x).")}async function De(e,t,o){let r=Y(t,o);te(t,r);let i=r,a=e.clientFor(u),{marketId:n,marketParams:s}=await G(a,t,!0),l=await R(a,s.collateralToken,u),c=s.collateralToken.toLowerCase()===V.toLowerCase(),p=typeof t.collateralToken=="string"?(D(t.collateralToken),b(t.collateralToken)):void 0,m=!!t.wrapNative||p!==void 0&&ae(p);if(p&&!ae(p)&&p.toLowerCase()!==s.collateralToken.toLowerCase())throw new d(`Collateral token ${p} does not match market collateral ${s.collateralToken}.`);if(m&&!c)throw new d("Native ETH wrapping is only supported when market collateralToken is WETH.");let h=ee(t),f=h.toString(),w=e.formatAmount(f,l.decimals),k=[];m&&k.push(e.unsignedTx({chainId:u,to:V,data:T({abi:_e,functionName:"deposit"}),value:f,description:`Wrap ${w} ETH into WETH at ${V}.`})),k.push(e.approval(s.collateralToken,v,f,u)),k.push(e.unsignedTx({chainId:u,to:v,data:T({abi:E,functionName:"supplyCollateral",args:[s,h,i,"0x"]}),value:"0",description:`Supply ${w} ${l.symbol} (${f} base units) collateral to Morpho market ${n}.`}));let S=await e.preview(k,r),{formattedChanges:y,formattedNetOutflows:g}=J(e,S);return{action:"morpho_supply_collateral",chainId:u,marketId:n,marketParams:{loanToken:s.loanToken,collateralToken:s.collateralToken,oracle:s.oracle,irm:s.irm,lltv:s.lltv.toString()},collateralToken:l,assets:f,formattedAssets:w,onBehalf:i,txs:k,steps:k,summary:`${m?`Send ${w} ETH to wrap into WETH. `:""}Supply ${w} ${l.symbol} collateral to Morpho Blue market ${n}.`,preview:S,formattedChanges:y,formattedNetOutflows:g}}async function Ue(e,t,o){let r=Y(t,o);te(t,r);let i=r,a=r,n=e.clientFor(u),{marketId:s,marketParams:l,marketState:c}=await G(n,t,!0),[p,m,h,f]=await Promise.all([R(n,l.loanToken,u),W(n,s,i),Z(n,l.oracle),F(n,l,c,U)]),w=ee(t),k=w.toString(),S=e.formatAmount(k,p.decimals),y=c.totalSupplyAssets>c.totalBorrowAssets?c.totalSupplyAssets-c.totalBorrowAssets:0n;if(w>y)throw new d(`Insufficient market liquidity: requested ${k} base units, available ${y.toString()} base units.`);let g=X(m.collateral,h,l.lltv),C=q(m.borrowShares,f.totalBorrowAssets,c.totalBorrowShares);if(m.collateral===0n||C+w>g)throw new d(`Insufficient collateral or unhealthy borrow: total debt ${(C+w).toString()} exceeds max borrow ${g.toString()} base units.`);let P=Oe(w,f.totalBorrowAssets,c.totalBorrowShares),x=[e.unsignedTx({chainId:u,to:v,data:T({abi:E,functionName:"borrow",args:[l,w,0n,i,a]}),value:"0",description:`Borrow ${S} ${p.symbol} (${k} base units) from Morpho market ${s}.`})],M=await e.preview(x,r),{formattedChanges:A,formattedNetOutflows:Ae}=J(e,M);return{action:"morpho_borrow",chainId:u,marketId:s,marketParams:{loanToken:l.loanToken,collateralToken:l.collateralToken,oracle:l.oracle,irm:l.irm,lltv:l.lltv.toString()},loanToken:p,assets:k,formattedAssets:S,borrowShares:P.toString(),onBehalf:i,receiver:a,txs:x,steps:x,summary:`Borrow ${S} ${p.symbol} from Morpho Blue market ${s}.`,preview:M,formattedChanges:A,formattedNetOutflows:Ae}}async function je(e,t,o){let r=Y(t,o);te(t,r);let i=r,a=e.clientFor(u);if(t.shares!==void 0){let A=H(t.shares);if(A<=0n||A===xe||A>fe)throw new d("Morpho Blue core does not accept maxUint256 or out-of-range share sentinels; pass exact position.borrowShares.")}if(t.repayAll===!0&&(t.shares!==void 0||t.assets!==void 0||t.amount!==void 0))throw new d("Specify repayAll alone, without shares or assets/amount.");if(t.shares!==void 0&&(t.assets!==void 0||t.amount!==void 0))throw new d("Specify either assets/amount or shares for Morpho repay, not both.");let{marketId:n,marketParams:s,marketState:l}=await G(a,t,!0),[c,p,m]=await Promise.all([R(a,s.loanToken,u),W(a,n,i),He(a,s.loanToken,r)]);if(p.borrowShares===0n)throw new d(`Position has no active borrow debt on Morpho market ${n}.`);let h=0n,f=0n;if(t.repayAll===!0)f=p.borrowShares;else if(t.shares!==void 0){let A=H(t.shares);if(A>p.borrowShares)throw new d(`Repay shares (${A.toString()}) exceed current position borrowShares (${p.borrowShares.toString()}).`);f=A}else h=ee(t);let w=f>0n?await F(a,s,l,U):void 0,k=f>0n?q(f,w.totalBorrowAssets,l.totalBorrowShares):h;if(m<k)throw new d(`Insufficient loan token balance for repayment: wallet holds ${m.toString()} base units, but ${k.toString()} base units are required (including accrued interest).`);let S=k.toString(),y=e.formatAmount(S,c.decimals),g=e.approval(s.loanToken,v,S,u),C=e.unsignedTx({chainId:u,to:v,data:T({abi:E,functionName:"repay",args:[s,h,f,i,"0x"]}),value:"0",description:f>0n?`Repay ${f.toString()} borrow shares (${y} ${c.symbol}) on Morpho market ${n}.`:`Repay ${y} ${c.symbol} (${h.toString()} base units) on Morpho market ${n}.`}),P=[g,C],B=await e.preview(P,r),{formattedChanges:x,formattedNetOutflows:M}=J(e,B);return{action:"morpho_repay",chainId:u,marketId:n,marketParams:{loanToken:s.loanToken,collateralToken:s.collateralToken,oracle:s.oracle,irm:s.irm,lltv:s.lltv.toString()},loanToken:c,repayAssets:h.toString(),repayShares:f.toString(),requiredAssets:S,...w?{accruedThrough:w.accruedThrough.toString(),borrowRatePerSecond:w.rate.toString(),inclusionSeconds:U.toString()}:{},formattedRequiredAssets:y,onBehalf:i,txs:P,steps:P,summary:f>0n?`Repay ${f.toString()} borrow shares (approval up to ${y} ${c.symbol}) on Morpho Blue market ${n}. Refresh if signing/inclusion takes more than ${U} seconds.`:`Repay ${y} ${c.symbol} on Morpho Blue market ${n}.`,preview:B,formattedChanges:x,formattedNetOutflows:M}}async function qe(e,t,o){let r=Y(t,o);te(t,r);let i=r,a=r,n=e.clientFor(u),{marketId:s,marketParams:l,marketState:c}=await G(n,t,!0),[p,m,h,f]=await Promise.all([R(n,l.collateralToken,u),W(n,s,i),Z(n,l.oracle),F(n,l,c,U)]),w=t.withdrawAll===!0?m.collateral:ee(t);if(w<=0n||w>m.collateral)throw new d(`Insufficient collateral to withdraw: requested ${w.toString()} base units, position holds ${m.collateral.toString()} base units.`);if(m.borrowShares>0n){let x=m.collateral-w,M=X(x,h,l.lltv),A=q(m.borrowShares,f.totalBorrowAssets,c.totalBorrowShares);if(A>M)throw new d(`Unhealthy collateral withdrawal: remaining max borrow ${M.toString()} would fall below current debt ${A.toString()} base units.`)}let k=w.toString(),S=e.formatAmount(k,p.decimals),g=[e.unsignedTx({chainId:u,to:v,data:T({abi:E,functionName:"withdrawCollateral",args:[l,w,i,a]}),value:"0",description:`Withdraw ${S} ${p.symbol} (${k} base units) collateral from Morpho market ${s}.`})],C=await e.preview(g,r),{formattedChanges:P,formattedNetOutflows:B}=J(e,C);return{action:"morpho_withdraw_collateral",chainId:u,marketId:s,marketParams:{loanToken:l.loanToken,collateralToken:l.collateralToken,oracle:l.oracle,irm:l.irm,lltv:l.lltv.toString()},collateralToken:p,assets:k,formattedAssets:S,onBehalf:i,receiver:a,txs:g,steps:g,summary:`Withdraw ${S} ${p.symbol} collateral from Morpho Blue market ${s}.`,preview:C,formattedChanges:P,formattedNetOutflows:B}}async function We(e,t){let o=`query Markets($chainId: Int!) {
1
+ import{b as me,c as pe,d as he}from"../../../chunks/MOVRI5IV.js";import"../../../chunks/YX4NVVSX.js";import"../../../chunks/BHR46XNW.js";import"../../../chunks/73EABRFC.js";import{e as ue,f as _}from"../../../chunks/2IRORNOH.js";import{a as de}from"../../../chunks/GDP4JSAX.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/MK6L6TGI.js";import"../../../chunks/Y3P6SUNL.js";import"../../../chunks/GIBF3YJO.js";import{b as ce}from"../../../chunks/UCMNB2UP.js";import"../../../chunks/Z25UKUJF.js";import{a as j}from"../../../chunks/A5ITAEUQ.js";import{a as U}from"../../../chunks/I5CQ64EU.js";import{a as v,d as N}from"../../../chunks/NA7HV7BR.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/M6JGTQRY.js";import{a as u,i as D}from"../../../chunks/ZUC6ILK2.js";import"../../../chunks/B4MLWDPM.js";import{a as d,d as le}from"../../../chunks/NGAI6GTU.js";import{a as ae}from"../../../chunks/JXOEJPJ4.js";import{decodeAbiParameters as O,encodeAbiParameters as Me,encodeFunctionData as T,erc20Abi as ne,getAddress as b,isAddress as fe,keccak256 as ve,parseAbi as Q,parseAbiParameters as x}from"viem";var ke="morpho",Ce="https://api.morpho.org/graphql",C=b(D[u].morpho.morpho_blue.address),Be=b(D[u].morpho.adaptive_curve_irm.address),$e=b(D[u].morpho.USDG.address),K=b(D[u].morpho.WETH.address),ie=["0x7c820d6a09502d63be80bb8025ec479d29d7c06e70f8df65a92aaeed23a366e2","0x1fa5293f9f60059a7f6a4923022156fcdcc038bd3749be55897000c03afe92d8"],q=120n,X=1000000n,J=1n,H=10n**18n,xe=10n**36n,ye=(1n<<128n)-1n,Ie=(1n<<256n)-1n,L=Q(["function idToMarketParams(bytes32 id) view returns (address loanToken, address collateralToken, address oracle, address irm, uint256 lltv)","function market(bytes32 id) view returns (uint128 totalSupplyAssets, uint128 totalSupplyShares, uint128 totalBorrowAssets, uint128 totalBorrowShares, uint128 lastUpdate, uint128 fee)","function position(bytes32 id, address user) view returns (uint256 supplyShares, uint128 borrowShares, uint128 collateral)","function supplyCollateral((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, bytes data)","function withdrawCollateral((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, address receiver)","function borrow((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, address receiver) returns (uint256 assetsBorrowed, uint256 sharesBorrowed)","function repay((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, bytes data) returns (uint256 assetsRepaid, uint256 sharesRepaid)"]),_e=Q(["function price() view returns (uint256)"]),Oe=Q(["function borrowRateView((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, (uint128 totalSupplyAssets, uint128 totalSupplyShares, uint128 totalBorrowAssets, uint128 totalBorrowShares, uint128 lastUpdate, uint128 fee) market) view returns (uint256)"]),Re=Q(["function deposit() payable"]);function W(e,t){return e===0n?0n:(e+t-1n)/t}function st(e,t,o){return e*(o+X)/(t+J)}function Ee(e,t,o){return W(e*(o+X),t+J)}function be(e,t,o){return e*(t+J)/(o+X)}function F(e,t,o){return W(e*(t+J),o+X)}function Y(e,t,o){return e*t/xe*o/H}function Le(e,t,o){return t.startsWith("-")?`-${e.formatAmount(t.slice(1),o)}`:e.formatAmount(t,o)}function Z(e,t){let o=[],r={};for(let i of t.changes){let a=Le(e,i.amount,i.token.decimals);o.push({token:i.token,amount:i.amount,formattedAmount:a}),r[i.token.address.toLowerCase()]=a}return{formattedChanges:o,formattedNetOutflows:r}}function Ne(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new d("Morpho marketId must be a 32-byte hex string.");return e.toLowerCase()}function Se(e){if(!e||typeof e!="object")throw new d("Morpho marketParams must be an object.");for(let n of[e.loanToken,e.collateralToken,e.oracle,e.irm])if(typeof n!="string"||!fe(n,{strict:!1}))throw new d("Morpho marketParams contains an invalid address.");let t=b(e.loanToken),o=b(e.collateralToken),r=b(e.oracle),i=b(e.irm),a=typeof e.lltv=="bigint"?e.lltv:U(String(e.lltv));if(t===_||o===_||r===_)throw new d("Morpho marketParams loan, collateral, and oracle addresses must be non-zero.");if(a<=0n||a>=H)throw new d("Morpho marketParams LLTV must be between 0 and 1e18.");return{loanToken:t,collateralToken:o,oracle:r,irm:i,lltv:a}}function we(e){let t=Se(e),o=Me(x("address, address, address, address, uint256"),[t.loanToken,t.collateralToken,t.oracle,t.irm,t.lltv]);return ve(o)}function se(e){let t=e.toLowerCase();return t===de.toLowerCase()||t===ue.toLowerCase()||t===_.toLowerCase()}function ee(e,t){let o=t??e.wallet;if(!o)throw new d("Provide a valid wallet address.");return j(o),b(o)}async function R(e,t,o){if(typeof e.call=="function"){let r=await e.call({to:t,data:o});if(r&&typeof r.data=="string")return r.data}if(typeof e.request=="function"){let r=await e.request({method:"eth_call",params:[{to:t,data:o},"latest"]});if(typeof r=="string")return r}throw new d(`Unable to execute eth_call on contract ${t}.`)}async function E(e,t,o=u){if(j(t),se(t))return{...me,chainId:o};let r=b(t),i=r.toLowerCase();if(o===u){if(i===$e.toLowerCase())return pe;if(i===K.toLowerCase())return he}let[a,n]=await Promise.all([R(e,r,T({abi:ne,functionName:"symbol"})),R(e,r,T({abi:ne,functionName:"decimals"}))]),[s]=O(x("string"),a),[l]=O(x("uint8"),n);return{address:r,symbol:s,decimals:Number(l),chainId:o}}async function Ae(e,t){let o=await R(e,C,T({abi:L,functionName:"idToMarketParams",args:[t]})),[r,i,a,n,s]=O(x("address, address, address, address, uint256"),o);return{loanToken:b(r),collateralToken:b(i),oracle:b(a),irm:b(n),lltv:s}}async function ge(e,t){let o=await R(e,C,T({abi:L,functionName:"market",args:[t]})),[r,i,a,n,s,l]=O(x("uint128, uint128, uint128, uint128, uint128, uint128"),o);return{totalSupplyAssets:r,totalSupplyShares:i,totalBorrowAssets:a,totalBorrowShares:n,lastUpdate:s,fee:l}}async function G(e,t,o){let r=await R(e,C,T({abi:L,functionName:"position",args:[t,b(o)]})),[i,a,n]=O(x("uint256, uint128, uint128"),r);return{supplyShares:i,borrowShares:a,collateral:n}}async function te(e,t){let o=await R(e,b(t),T({abi:_e,functionName:"price"})),[r]=O(x("uint256"),o);return r}async function He(e,t,o){if(t.irm===_)return 0n;let r=await R(e,b(t.irm),T({abi:Oe,functionName:"borrowRateView",args:[t,o]})),[i]=O(x("uint256"),r);return i}function De(e,t,o){let r=o>e.lastUpdate?o-e.lastUpdate:0n,i=t*r,a=W(i*i,2n*H),n=W(a*i,3n*H);return e.totalBorrowAssets+W(e.totalBorrowAssets*(i+a+n),H)}async function V(e,t,o,r=0n){let[i,a]=await Promise.all([e.getBlock({blockTag:"latest"}),He(e,t,o)]),n=BigInt(Math.ceil(Date.now()/1e3)),s=(i.timestamp>n?i.timestamp:n)+r;return{totalBorrowAssets:De(o,a,s),accruedThrough:s,rate:a}}async function Ue(e,t,o){let r=await R(e,b(t),T({abi:ne,functionName:"balanceOf",args:[b(o)]})),[i]=O(x("uint256"),r);return i}async function z(e,t,o=!1){let r=t.marketId,i=t.marketParams;if(!r&&!i)throw new d("Provide either marketId or marketParams for the Morpho Blue market.");let a=i?Se(i):void 0,n=a?we(a):void 0,s=r!==void 0?Ne(r):void 0;if(s&&n&&s!==n.toLowerCase())throw new d(`MarketParams tuple hash (${n}) does not match marketId (${s}).`);let l=s??n;if(o&&!ie.includes(l))throw new d("Morpho actions require a known market with a pinned oracle.");let[c,p]=await Promise.all([Ae(e,l),ge(e,l)]);if(c.loanToken===_||c.collateralToken===_||c.lltv===0n||p.lastUpdate===0n)throw new d(`Morpho market ${l} is not initialized on chain ${u}.`);let m=we(c);if(m.toLowerCase()!==l.toLowerCase())throw new d(`On-chain idToMarketParams tuple hash (${m}) does not match marketId (${l}).`);if(a&&!(a.loanToken.toLowerCase()===c.loanToken.toLowerCase()&&a.collateralToken.toLowerCase()===c.collateralToken.toLowerCase()&&a.oracle.toLowerCase()===c.oracle.toLowerCase()&&a.irm.toLowerCase()===c.irm.toLowerCase()&&a.lltv===c.lltv))throw new d(`Provided marketParams tuple does not match on-chain idToMarketParams for ${l}.`);return{marketId:l,marketParams:c,marketState:p}}function oe(e){if(e.assets!==void 0&&e.amount!==void 0)throw new d("Specify either assets or amount, not both.");let t=e.assets??e.amount;if(typeof t!="string")throw new d("Provide an amount as a base-unit integer string.");let o=U(t);if(o<=0n||o>ye)throw new d("Asset amount must be greater than zero and fit in uint128.");return o}function re(e,t){for(let o of["onBehalf","receiver"])if(e[o]!==void 0&&(typeof e[o]!="string"||e[o].toLowerCase()!==t.toLowerCase()))throw new d(`Morpho ${o} must be the wallet; overrides are not supported.`);if(e.data!==void 0&&e.data!=="0x")throw new d("Morpho callback data must be empty (0x).")}async function je(e,t,o){let r=ee(t,o);re(t,r);let i=r,a=e.clientFor(u),{marketId:n,marketParams:s}=await z(a,t,!0),l=await E(a,s.collateralToken,u),c=s.collateralToken.toLowerCase()===K.toLowerCase(),p=typeof t.collateralToken=="string"?(j(t.collateralToken),b(t.collateralToken)):void 0,m=N("wrapNative",t.wrapNative)===!0||p!==void 0&&se(p);if(p&&!se(p)&&p.toLowerCase()!==s.collateralToken.toLowerCase())throw new d(`Collateral token ${p} does not match market collateral ${s.collateralToken}.`);if(m&&!c)throw new d("Native ETH wrapping is only supported when market collateralToken is WETH.");let h=oe(t),f=h.toString(),w=e.formatAmount(f,l.decimals),k=[];m&&k.push(e.unsignedTx({chainId:u,to:K,data:T({abi:Re,functionName:"deposit"}),value:f,description:`Wrap ${w} ETH into WETH at ${K}.`})),k.push(e.approval(s.collateralToken,C,f,u)),k.push(e.unsignedTx({chainId:u,to:C,data:T({abi:L,functionName:"supplyCollateral",args:[s,h,i,"0x"]}),value:"0",description:`Supply ${w} ${l.symbol} (${f} base units) collateral to Morpho market ${n}.`}));let S=await e.preview(k,r),{formattedChanges:y,formattedNetOutflows:g}=Z(e,S);return{action:"morpho_supply_collateral",chainId:u,marketId:n,marketParams:{loanToken:s.loanToken,collateralToken:s.collateralToken,oracle:s.oracle,irm:s.irm,lltv:s.lltv.toString()},collateralToken:l,assets:f,formattedAssets:w,onBehalf:i,txs:k,summary:`${m?`Send ${w} ETH to wrap into WETH. `:""}Supply ${w} ${l.symbol} collateral to Morpho Blue market ${n}.`,preview:S,formattedChanges:y,formattedNetOutflows:g}}async function qe(e,t,o){let r=ee(t,o);re(t,r);let i=r,a=r,n=e.clientFor(u),{marketId:s,marketParams:l,marketState:c}=await z(n,t,!0),[p,m,h,f]=await Promise.all([E(n,l.loanToken,u),G(n,s,i),te(n,l.oracle),V(n,l,c,q)]),w=oe(t),k=w.toString(),S=e.formatAmount(k,p.decimals),y=c.totalSupplyAssets>c.totalBorrowAssets?c.totalSupplyAssets-c.totalBorrowAssets:0n;if(w>y)throw new d(`Insufficient market liquidity: requested ${k} base units, available ${y.toString()} base units.`);let g=Y(m.collateral,h,l.lltv),B=F(m.borrowShares,f.totalBorrowAssets,c.totalBorrowShares);if(m.collateral===0n||B+w>g)throw new d(`Insufficient collateral or unhealthy borrow: total debt ${(B+w).toString()} exceeds max borrow ${g.toString()} base units.`);let P=Ee(w,f.totalBorrowAssets,c.totalBorrowShares),I=[e.unsignedTx({chainId:u,to:C,data:T({abi:L,functionName:"borrow",args:[l,w,0n,i,a]}),value:"0",description:`Borrow ${S} ${p.symbol} (${k} base units) from Morpho market ${s}.`})],M=await e.preview(I,r),{formattedChanges:A,formattedNetOutflows:Pe}=Z(e,M);return{action:"morpho_borrow",chainId:u,marketId:s,marketParams:{loanToken:l.loanToken,collateralToken:l.collateralToken,oracle:l.oracle,irm:l.irm,lltv:l.lltv.toString()},loanToken:p,assets:k,formattedAssets:S,borrowShares:P.toString(),onBehalf:i,receiver:a,txs:I,summary:`Borrow ${S} ${p.symbol} from Morpho Blue market ${s}.`,preview:M,formattedChanges:A,formattedNetOutflows:Pe}}async function We(e,t,o){let r=ee(t,o);re(t,r);let i=r,a=e.clientFor(u);if(t.shares!==void 0){let A=U(t.shares);if(A<=0n||A===Ie||A>ye)throw new d("Morpho Blue core does not accept maxUint256 or out-of-range share sentinels; pass exact position.borrowShares.")}if(N("repayAll",t.repayAll)===!0&&(t.shares!==void 0||t.assets!==void 0||t.amount!==void 0))throw new d("Specify repayAll alone, without shares or assets/amount.");if(t.shares!==void 0&&(t.assets!==void 0||t.amount!==void 0))throw new d("Specify either assets/amount or shares for Morpho repay, not both.");let{marketId:n,marketParams:s,marketState:l}=await z(a,t,!0),[c,p,m]=await Promise.all([E(a,s.loanToken,u),G(a,n,i),Ue(a,s.loanToken,r)]);if(p.borrowShares===0n)throw new d(`Position has no active borrow debt on Morpho market ${n}.`);let h=0n,f=0n;if(N("repayAll",t.repayAll)===!0)f=p.borrowShares;else if(t.shares!==void 0){let A=U(t.shares);if(A>p.borrowShares)throw new d(`Repay shares (${A.toString()}) exceed current position borrowShares (${p.borrowShares.toString()}).`);f=A}else h=oe(t);let w=f>0n?await V(a,s,l,q):void 0,k=f>0n?F(f,w.totalBorrowAssets,l.totalBorrowShares):h;if(m<k)throw new d(`Insufficient loan token balance for repayment: wallet holds ${m.toString()} base units, but ${k.toString()} base units are required (including accrued interest).`);let S=k.toString(),y=e.formatAmount(S,c.decimals),g=e.approval(s.loanToken,C,S,u),B=e.unsignedTx({chainId:u,to:C,data:T({abi:L,functionName:"repay",args:[s,h,f,i,"0x"]}),value:"0",description:f>0n?`Repay ${f.toString()} borrow shares (${y} ${c.symbol}) on Morpho market ${n}.`:`Repay ${y} ${c.symbol} (${h.toString()} base units) on Morpho market ${n}.`}),P=[g,B],$=await e.preview(P,r),{formattedChanges:I,formattedNetOutflows:M}=Z(e,$);return{action:"morpho_repay",chainId:u,marketId:n,marketParams:{loanToken:s.loanToken,collateralToken:s.collateralToken,oracle:s.oracle,irm:s.irm,lltv:s.lltv.toString()},loanToken:c,repayAssets:h.toString(),repayShares:f.toString(),requiredAssets:S,...w?{accruedThrough:w.accruedThrough.toString(),borrowRatePerSecond:w.rate.toString(),inclusionSeconds:q.toString()}:{},formattedRequiredAssets:y,onBehalf:i,txs:P,summary:f>0n?`Repay ${f.toString()} borrow shares (approval up to ${y} ${c.symbol}) on Morpho Blue market ${n}. Refresh if signing/inclusion takes more than ${q} seconds.`:`Repay ${y} ${c.symbol} on Morpho Blue market ${n}.`,preview:$,formattedChanges:I,formattedNetOutflows:M}}async function Fe(e,t,o){let r=ee(t,o);re(t,r);let i=r,a=r,n=e.clientFor(u),{marketId:s,marketParams:l,marketState:c}=await z(n,t,!0),[p,m,h,f]=await Promise.all([E(n,l.collateralToken,u),G(n,s,i),te(n,l.oracle),V(n,l,c,q)]),w=N("withdrawAll",t.withdrawAll)===!0?m.collateral:oe(t);if(w<=0n||w>m.collateral)throw new d(`Insufficient collateral to withdraw: requested ${w.toString()} base units, position holds ${m.collateral.toString()} base units.`);if(m.borrowShares>0n){let I=m.collateral-w,M=Y(I,h,l.lltv),A=F(m.borrowShares,f.totalBorrowAssets,c.totalBorrowShares);if(A>M)throw new d(`Unhealthy collateral withdrawal: remaining max borrow ${M.toString()} would fall below current debt ${A.toString()} base units.`)}let k=w.toString(),S=e.formatAmount(k,p.decimals),g=[e.unsignedTx({chainId:u,to:C,data:T({abi:L,functionName:"withdrawCollateral",args:[l,w,i,a]}),value:"0",description:`Withdraw ${S} ${p.symbol} (${k} base units) collateral from Morpho market ${s}.`})],B=await e.preview(g,r),{formattedChanges:P,formattedNetOutflows:$}=Z(e,B);return{action:"morpho_withdraw_collateral",chainId:u,marketId:s,marketParams:{loanToken:l.loanToken,collateralToken:l.collateralToken,oracle:l.oracle,irm:l.irm,lltv:l.lltv.toString()},collateralToken:p,assets:k,formattedAssets:S,onBehalf:i,receiver:a,txs:g,summary:`Withdraw ${S} ${p.symbol} collateral from Morpho Blue market ${s}.`,preview:B,formattedChanges:P,formattedNetOutflows:$}}async function Ge(e,t){let o=`query Markets($chainId: Int!) {
2
2
  markets(first: 1000, where: { chainId_in: [$chainId] }) {
3
3
  items {
4
4
  marketId chain { id } lltv listed
@@ -9,4 +9,4 @@ import{b as de,c as ue,d as me}from"../../../chunks/KFMNCJXJ.js";import"../../..
9
9
  }
10
10
  pageInfo { count countTotal }
11
11
  }
12
- }`;try{let r=await e.http(Me,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({query:o,variables:{chainId:u}})});if(!r.ok)throw new d(`Morpho GraphQL request failed (HTTP ${r.status}).`);let i=await r.json();if(i.errors?.length)throw new d("Morpho GraphQL returned query errors.");let a=i.data?.markets;if(!Array.isArray(a?.items)||typeof a.pageInfo?.countTotal!="number"||a.pageInfo.countTotal!==a.items.length||a.items.some(n=>!n||typeof n.marketId!="string"))throw new d("Morpho GraphQL returned an incomplete or invalid market inventory.");return a.items.find(n=>n.marketId.toLowerCase()===t)??null}catch(r){throw new d(`Morpho GraphQL read failed: ${se(r)}`)}}async function Fe(e,t,o){let r=e.clientFor(u),i=o??t.wallet,a=i&&he(i,{strict:!1})?b(i):void 0,n=!!t.includeGraphql,s=t.marketId||t.marketParams?[t]:ne.map(c=>({marketId:c})),l=await Promise.all(s.map(async c=>{let{marketId:p,marketParams:m,marketState:h}=await G(r,c),[f,w,k,S,y,g]=await Promise.all([R(r,m.loanToken,u),R(r,m.collateralToken,u),Z(r,m.oracle),F(r,m,h),a?W(r,p,a):Promise.resolve(void 0),n?We(e,p):Promise.resolve(void 0)]),C=h.totalSupplyAssets>h.totalBorrowAssets?h.totalSupplyAssets-h.totalBorrowAssets:0n,P;if(y){let B=y.borrowShares>0n?q(y.borrowShares,S.totalBorrowAssets,h.totalBorrowShares):0n,x=y.supplyShares>0n?ke(y.supplyShares,h.totalSupplyAssets,h.totalSupplyShares):0n,M=X(y.collateral,k,m.lltv),A=B>0n?e.formatAmount((M*L/B).toString(),18):null;P={supplyShares:y.supplyShares.toString(),supplyAssets:x.toString(),borrowShares:y.borrowShares.toString(),borrowAssets:B.toString(),collateralAssets:y.collateral.toString(),maxBorrowAssets:M.toString(),healthFactor:A}}return{marketId:p,marketParams:{loanToken:m.loanToken,collateralToken:m.collateralToken,oracle:m.oracle,irm:m.irm,lltv:m.lltv.toString()},loanToken:f,collateralToken:w,state:{totalSupplyAssets:h.totalSupplyAssets.toString(),totalSupplyShares:h.totalSupplyShares.toString(),totalBorrowAssets:h.totalBorrowAssets.toString(),totalBorrowShares:h.totalBorrowShares.toString(),availableLiquidity:C.toString(),lastUpdate:h.lastUpdate.toString(),fee:h.fee.toString()},oraclePrice:k.toString(),borrowRatePerSecond:S.rate.toString(),...P?{position:P}:{},...n?{graphql:g??null}:{}}}));return{chainId:u,morphoBlue:v,adaptiveCurveIrm:ve,markets:l}}async function Ge(e,t){D(t);let o=b(t),r=e.clientFor(u),i=[];for(let a of ne){let n=await W(r,a,o);if(n.supplyShares===0n&&n.borrowShares===0n&&n.collateral===0n)continue;let[s,l]=await Promise.all([be(r,a),Se(r,a)]),[c,p,m,h]=await Promise.all([R(r,s.loanToken,u),R(r,s.collateralToken,u),Z(r,s.oracle),F(r,s,l)]),f=[];n.collateral>0n&&f.push({token:p,amount:n.collateral.toString()});let w=n.supplyShares>0n?ke(n.supplyShares,l.totalSupplyAssets,l.totalSupplyShares):0n;w>0n&&f.push({token:c,amount:w.toString()});let k=n.borrowShares>0n?q(n.borrowShares,h.totalBorrowAssets,l.totalBorrowShares):0n,S=X(n.collateral,m,s.lltv),y=e.formatAmount(n.collateral.toString(),p.decimals),g=e.formatAmount(k.toString(),c.decimals);i.push({module:we,id:a,chainId:u,assets:f,description:`Morpho Blue market ${a}: collateral=${y} ${p.symbol} (${n.collateral.toString()}), debt=${g} ${c.symbol} (${k.toString()}, shares=${n.borrowShares.toString()}), maxBorrow=${S.toString()}.`})}return i}var ge=e=>({tools:[{name:"morpho_supply_collateral",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:{type:"string"},amount:{type:"string"},collateralToken:{type:"string"},wrapNative:{type:"boolean"},onBehalf:{type:"string"}}},execute:(o,r)=>De(e,o,r)},{name:"morpho_withdraw_collateral",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:{type:"string"},amount:{type:"string"},withdrawAll:{type:"boolean"},onBehalf:{type:"string"},receiver:{type:"string"}}},execute:(o,r)=>qe(e,o,r)},{name:"morpho_borrow",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:{type:"string"},amount:{type:"string"},onBehalf:{type:"string"},receiver:{type:"string"}}},execute:(o,r)=>Ue(e,o,r)},{name:"morpho_repay",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:{type:"string"},amount:{type:"string"},shares:{type:"string"},repayAll:{type:"boolean"},onBehalf:{type:"string"}}},execute:(o,r)=>je(e,o,r)},{name:"morpho_status",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},includeGraphql:{type:"boolean"}}},execute:(o,r)=>Fe(e,o,r)}].map(o=>{let r=new Set(Object.keys(o.inputSchema.properties));if(r.add("wallet"),o.name!=="morpho_status")for(let a of["onBehalf","receiver","data"])r.add(a);let i=new Set(["loanToken","collateralToken","oracle","irm","lltv"]);return{...o,execute:async(a,n)=>{for(let s of Object.keys(a))if(!r.has(s))throw new d(`Unknown argument ${oe(s)} for ${o.name}; remove it and retry.`);if(a.marketParams&&typeof a.marketParams=="object"){for(let s of Object.keys(a.marketParams))if(!i.has(s))throw new d(`Unknown Morpho marketParams field ${oe(s)}; remove it and retry.`)}return o.execute(a,n)}}}),positions:o=>Ge(e,o)}),Ve=e=>ie(we,[ge(e)]),at=Ve,nt=ge;export{ve as ADAPTIVE_CURVE_IRM_ADDRESS,ne as KNOWN_MORPHO_MARKET_IDS,v as MORPHO_BLUE_ADDRESS,Me as MORPHO_GRAPHQL_URL,we as MORPHO_MODULE_NAME,Ce as MORPHO_USDG_ADDRESS,V as MORPHO_WETH_ADDRESS,U as REPAY_INCLUSION_SECONDS,pe as computeMarketId,X as computeMaxBorrowAssets,Ve as createModule,ge as createModulePart,at as createMorphoModule,nt as createMorphoPart,Re as formatSignedAmount,ye as normalizeMarketParams,Ne as projectBorrowAssets,ke as toAssetsDown,q as toAssetsUp,rt as toSharesDown,Oe as toSharesUp};
12
+ }`;try{let r=await e.http(Ce,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({query:o,variables:{chainId:u}})});if(!r.ok)throw new d(`Morpho GraphQL request failed (HTTP ${r.status}).`);let i=await r.json();if(i.errors?.length)throw new d("Morpho GraphQL returned query errors.");let a=i.data?.markets;if(!Array.isArray(a?.items)||typeof a.pageInfo?.countTotal!="number"||a.pageInfo.countTotal!==a.items.length||a.items.some(n=>!n||typeof n.marketId!="string"))throw new d("Morpho GraphQL returned an incomplete or invalid market inventory.");return a.items.find(n=>n.marketId.toLowerCase()===t)??null}catch(r){throw new d(`Morpho GraphQL read failed: ${le(r)}`)}}async function Ve(e,t,o){let r=e.clientFor(u),i=o??t.wallet,a=i&&fe(i,{strict:!1})?b(i):void 0,n=N("includeGraphql",t.includeGraphql)===!0,s=t.marketId||t.marketParams?[t]:ie.map(c=>({marketId:c})),l=await Promise.all(s.map(async c=>{let{marketId:p,marketParams:m,marketState:h}=await z(r,c),[f,w,k,S,y,g]=await Promise.all([E(r,m.loanToken,u),E(r,m.collateralToken,u),te(r,m.oracle),V(r,m,h),a?G(r,p,a):Promise.resolve(void 0),n?Ge(e,p):Promise.resolve(void 0)]),B=h.totalSupplyAssets>h.totalBorrowAssets?h.totalSupplyAssets-h.totalBorrowAssets:0n,P;if(y){let $=y.borrowShares>0n?F(y.borrowShares,S.totalBorrowAssets,h.totalBorrowShares):0n,I=y.supplyShares>0n?be(y.supplyShares,h.totalSupplyAssets,h.totalSupplyShares):0n,M=Y(y.collateral,k,m.lltv),A=$>0n?e.formatAmount((M*H/$).toString(),18):null;P={supplyShares:y.supplyShares.toString(),supplyAssets:I.toString(),borrowShares:y.borrowShares.toString(),borrowAssets:$.toString(),collateralAssets:y.collateral.toString(),maxBorrowAssets:M.toString(),healthFactor:A}}return{marketId:p,marketParams:{loanToken:m.loanToken,collateralToken:m.collateralToken,oracle:m.oracle,irm:m.irm,lltv:m.lltv.toString()},loanToken:f,collateralToken:w,state:{totalSupplyAssets:h.totalSupplyAssets.toString(),totalSupplyShares:h.totalSupplyShares.toString(),totalBorrowAssets:h.totalBorrowAssets.toString(),totalBorrowShares:h.totalBorrowShares.toString(),availableLiquidity:B.toString(),lastUpdate:h.lastUpdate.toString(),fee:h.fee.toString()},oraclePrice:k.toString(),borrowRatePerSecond:S.rate.toString(),...P?{position:P}:{},...n?{graphql:g??null}:{}}}));return{chainId:u,morphoBlue:C,adaptiveCurveIrm:Be,markets:l}}async function ze(e,t){j(t);let o=b(t),r=e.clientFor(u),i=[];for(let a of ie){let n=await G(r,a,o);if(n.supplyShares===0n&&n.borrowShares===0n&&n.collateral===0n)continue;let[s,l]=await Promise.all([Ae(r,a),ge(r,a)]),[c,p,m,h]=await Promise.all([E(r,s.loanToken,u),E(r,s.collateralToken,u),te(r,s.oracle),V(r,s,l)]),f=[];n.collateral>0n&&f.push({token:p,amount:n.collateral.toString()});let w=n.supplyShares>0n?be(n.supplyShares,l.totalSupplyAssets,l.totalSupplyShares):0n;w>0n&&f.push({token:c,amount:w.toString()});let k=n.borrowShares>0n?F(n.borrowShares,h.totalBorrowAssets,l.totalBorrowShares):0n,S=Y(n.collateral,m,s.lltv),y=e.formatAmount(n.collateral.toString(),p.decimals),g=e.formatAmount(k.toString(),c.decimals);i.push({module:ke,id:a,chainId:u,assets:f,description:`Morpho Blue market ${a}: collateral=${y} ${p.symbol} (${n.collateral.toString()}), debt=${g} ${c.symbol} (${k.toString()}, shares=${n.borrowShares.toString()}), maxBorrow=${S.toString()}.`})}return i}var Te=e=>({tools:[{name:"morpho_supply_collateral",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:v(),amount:v(),collateralToken:{type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},wrapNative:{type:"boolean"},onBehalf:{type:"string"}}},execute:(o,r)=>je(e,o,r)},{name:"morpho_withdraw_collateral",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:v(),amount:v(),withdrawAll:{type:"boolean"},onBehalf:{type:"string"},receiver:{type:"string"}}},execute:(o,r)=>Fe(e,o,r)},{name:"morpho_borrow",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:v(),amount:v(),onBehalf:{type:"string"},receiver:{type:"string"}}},execute:(o,r)=>qe(e,o,r)},{name:"morpho_repay",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:v(),amount:v(),shares:v(),repayAll:{type:"boolean"},onBehalf:{type:"string"}}},execute:(o,r)=>We(e,o,r)},{name:"morpho_status",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},includeGraphql:{type:"boolean"}}},execute:(o,r)=>Ve(e,o,r)}].map(o=>{let r=new Set(Object.keys(o.inputSchema.properties));if(r.add("wallet"),o.name!=="morpho_status")for(let a of["onBehalf","receiver","data"])r.add(a);let i=new Set(["loanToken","collateralToken","oracle","irm","lltv"]);return{...o,execute:async(a,n)=>{for(let s of Object.keys(a))if(!r.has(s))throw new d(`Unknown argument ${ae(s)} for ${o.name}; remove it and retry.`);if(a.marketParams&&typeof a.marketParams=="object"){for(let s of Object.keys(a.marketParams))if(!i.has(s))throw new d(`Unknown Morpho marketParams field ${ae(s)}; remove it and retry.`)}return o.execute(a,n)}}}),positions:o=>ze(e,o)}),Ke=e=>ce(ke,[Te(e)]),it=Ke,lt=Te;export{Be as ADAPTIVE_CURVE_IRM_ADDRESS,ie as KNOWN_MORPHO_MARKET_IDS,C as MORPHO_BLUE_ADDRESS,Ce as MORPHO_GRAPHQL_URL,ke as MORPHO_MODULE_NAME,$e as MORPHO_USDG_ADDRESS,K as MORPHO_WETH_ADDRESS,q as REPAY_INCLUSION_SECONDS,we as computeMarketId,Y as computeMaxBorrowAssets,Ke as createModule,Te as createModulePart,it as createMorphoModule,lt as createMorphoPart,Le as formatSignedAmount,Se as normalizeMarketParams,De as projectBorrowAssets,be as toAssetsDown,F as toAssetsUp,st as toSharesDown,Ee as toSharesUp};
@@ -1 +1 @@
1
- import{b}from"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import{a as h}from"../../../chunks/VZWOWR6G.js";import{a,d as y,i as g}from"../../../chunks/25EOXUBI.js";import{a as C}from"../../../chunks/B5RZYFQC.js";import{a as d}from"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";import{encodeFunctionData as v,parseAbi as $}from"viem";var r=g[a].vaults.netnet.address,l={address:g[a].tokens.USDG.address,chainId:a,decimals:y,symbol:"USDG"},w={address:r,chainId:a,decimals:18,symbol:"nnUSDG"},u=$(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function balanceOf(address owner) view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),P={type:"string",pattern:"^[0-9]+$",description:"Positive USDG amount in integer base units (6 decimals)."},G="Preview amounts are estimates; these ERC-4626 calls have no on-chain minimum output argument. No transaction was sent.";function D(n){if(typeof n!="string")throw new d("Provide an integer amount string in base units.");let i=C(n);if(i<=0n||i>=1n<<256n)throw new d("Amount must be positive and fit in uint256.");return i}function N(n,i){if(Object.keys(n).some(f=>!i.includes(f)))throw new d("Unsupported NetNet argument.")}var T=n=>{async function i(e){try{return await e()}catch(t){throw new d(n.plainError(t))}}async function f(){let e=n.clientFor(a);if(await e.getChainId()!==a)throw new d("NetNet requires chain 4663.");let[t,s]=await Promise.all([e.readContract({address:r,abi:u,functionName:"asset"}),e.readContract({address:r,abi:u,functionName:"decimals"})]);if(t.toLowerCase()!==l.address.toLowerCase())throw new d("NetNet does not report the pinned USDG asset.");if(s!==w.decimals)throw new d("NetNet share decimals do not match the pinned metadata.");return e}async function S(e,t,s){let o=await n.preview(e,t),p=o.changes.map(({token:c,amount:m})=>{let A=m.startsWith("-");return`${A?"-":"+"}${n.formatAmount(A?m.slice(1):m,c.decimals)} ${c.symbol}`}).join(", ");return{txs:e,preview:o,summary:`${s} ${o.summary} ${p?`Estimated changes: ${p}. `:""}${G}`}}async function U(e){return i(async()=>{h(e);let t=await f(),s=await t.readContract({address:r,abi:u,functionName:"balanceOf",args:[e]});if(s===0n)return[];let o=await t.readContract({address:r,abi:u,functionName:"convertToAssets",args:[s]});return[{module:"netnet",id:`${a}:${r}`,chainId:a,assets:[{token:{...l},amount:o.toString()}],description:`${n.formatAmount(s.toString(),w.decimals)} nnUSDG shares in NetNet Credit (${r}); underlying USDG is an estimate, not a liquidity guarantee.`}]})}return{positions:U,tools:[{name:"netnet_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:e=>i(async()=>{N(e,[]);let s=await(await f()).readContract({address:r,abi:u,functionName:"totalAssets"});return[{address:r,name:"NetNet Credit",chainId:a,asset:{...l},shares:{...w},totalAssets:{token:{...l},amount:s.toString()}}]})},{name:"netnet_deposit",inputSchema:{type:"object",properties:{amount:P},required:["amount"],additionalProperties:!1},execute:(e,t)=>i(async()=>{N(e,["amount"]),h(t);let s=D(e.amount);await f();let o=[n.approval(l.address,r,s.toString(),a),n.unsignedTx({to:r,data:v({abi:u,functionName:"deposit",args:[s,t]}),value:"0",chainId:a,description:`Deposit ${n.formatAmount(s.toString(),l.decimals)} USDG into NetNet Credit.`})];return S(o,t,"Approve the exact USDG amount, then deposit into NetNet Credit.")})},{name:"netnet_withdraw",inputSchema:{type:"object",properties:{amount:{anyOf:[P,{const:"max",description:"Redeem the fresh full nnUSDG share balance."}]}},required:["amount"],additionalProperties:!1},execute:(e,t)=>i(async()=>{N(e,["amount"]),h(t);let s=e.amount==="max"?void 0:D(e.amount),o=await f(),p,c;if(s===void 0){let m=await o.readContract({address:r,abi:u,functionName:"balanceOf",args:[t]});if(m===0n)throw new d("This wallet has no NetNet shares to redeem.");p=v({abi:u,functionName:"redeem",args:[m,t,t]}),c=`Redeem all ${n.formatAmount(m.toString(),w.decimals)} nnUSDG shares for USDG.`}else p=v({abi:u,functionName:"withdraw",args:[s,t,t]}),c=`Withdraw ${n.formatAmount(s.toString(),l.decimals)} USDG from NetNet Credit (unmeasured on the recorded fork; full exit uses amount "max" redeem).`;return S([n.unsignedTx({to:r,data:p,value:"0",chainId:a,description:c})],t,c)})}]}};function R(n){return b("netnet",[T(n)])}export{R as createModule,T as createModulePart};
1
+ import{b}from"../../../chunks/UCMNB2UP.js";import"../../../chunks/Z25UKUJF.js";import{a as h}from"../../../chunks/A5ITAEUQ.js";import{a as C}from"../../../chunks/I5CQ64EU.js";import"../../../chunks/NA7HV7BR.js";import{a,d as y,i as g}from"../../../chunks/ZUC6ILK2.js";import{a as d}from"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";import{encodeFunctionData as v,parseAbi as $}from"viem";var r=g[a].vaults.netnet.address,l={address:g[a].tokens.USDG.address,chainId:a,decimals:y,symbol:"USDG"},w={address:r,chainId:a,decimals:18,symbol:"nnUSDG"},u=$(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function balanceOf(address owner) view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]),P={type:"string",pattern:"^[0-9]+$",description:"Positive USDG amount in integer base units (6 decimals)."},G="Preview amounts are estimates; these ERC-4626 calls have no on-chain minimum output argument. No transaction was sent.";function D(n){if(typeof n!="string")throw new d("Provide an integer amount string in base units.");let i=C(n);if(i<=0n||i>=1n<<256n)throw new d("Amount must be positive and fit in uint256.");return i}function N(n,i){if(Object.keys(n).some(f=>!i.includes(f)))throw new d("Unsupported NetNet argument.")}var T=n=>{async function i(e){try{return await e()}catch(t){throw new d(n.plainError(t))}}async function f(){let e=n.clientFor(a);if(await e.getChainId()!==a)throw new d("NetNet requires chain 4663.");let[t,s]=await Promise.all([e.readContract({address:r,abi:u,functionName:"asset"}),e.readContract({address:r,abi:u,functionName:"decimals"})]);if(t.toLowerCase()!==l.address.toLowerCase())throw new d("NetNet does not report the pinned USDG asset.");if(s!==w.decimals)throw new d("NetNet share decimals do not match the pinned metadata.");return e}async function S(e,t,s){let o=await n.preview(e,t),p=o.changes.map(({token:c,amount:m})=>{let A=m.startsWith("-");return`${A?"-":"+"}${n.formatAmount(A?m.slice(1):m,c.decimals)} ${c.symbol}`}).join(", ");return{txs:e,preview:o,summary:`${s} ${o.summary} ${p?`Estimated changes: ${p}. `:""}${G}`}}async function U(e){return i(async()=>{h(e);let t=await f(),s=await t.readContract({address:r,abi:u,functionName:"balanceOf",args:[e]});if(s===0n)return[];let o=await t.readContract({address:r,abi:u,functionName:"convertToAssets",args:[s]});return[{module:"netnet",id:`${a}:${r}`,chainId:a,assets:[{token:{...l},amount:o.toString()}],description:`${n.formatAmount(s.toString(),w.decimals)} nnUSDG shares in NetNet Credit (${r}); underlying USDG is an estimate, not a liquidity guarantee.`}]})}return{positions:U,tools:[{name:"netnet_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:e=>i(async()=>{N(e,[]);let s=await(await f()).readContract({address:r,abi:u,functionName:"totalAssets"});return[{address:r,name:"NetNet Credit",chainId:a,asset:{...l},shares:{...w},totalAssets:{token:{...l},amount:s.toString()}}]})},{name:"netnet_deposit",inputSchema:{type:"object",properties:{amount:P},required:["amount"],additionalProperties:!1},execute:(e,t)=>i(async()=>{N(e,["amount"]),h(t);let s=D(e.amount);await f();let o=[n.approval(l.address,r,s.toString(),a),n.unsignedTx({to:r,data:v({abi:u,functionName:"deposit",args:[s,t]}),value:"0",chainId:a,description:`Deposit ${n.formatAmount(s.toString(),l.decimals)} USDG into NetNet Credit.`})];return S(o,t,"Approve the exact USDG amount, then deposit into NetNet Credit.")})},{name:"netnet_withdraw",inputSchema:{type:"object",properties:{amount:{anyOf:[P,{const:"max",description:"Redeem the fresh full nnUSDG share balance."}]}},required:["amount"],additionalProperties:!1},execute:(e,t)=>i(async()=>{N(e,["amount"]),h(t);let s=e.amount==="max"?void 0:D(e.amount),o=await f(),p,c;if(s===void 0){let m=await o.readContract({address:r,abi:u,functionName:"balanceOf",args:[t]});if(m===0n)throw new d("This wallet has no NetNet shares to redeem.");p=v({abi:u,functionName:"redeem",args:[m,t,t]}),c=`Redeem all ${n.formatAmount(m.toString(),w.decimals)} nnUSDG shares for USDG.`}else p=v({abi:u,functionName:"withdraw",args:[s,t,t]}),c=`Withdraw ${n.formatAmount(s.toString(),l.decimals)} USDG from NetNet Credit (unmeasured on the recorded fork; full exit uses amount "max" redeem).`;return S([n.unsignedTx({to:r,data:p,value:"0",chainId:a,description:c})],t,c)})}]}};function R(n){return b("netnet",[T(n)])}export{R as createModule,T as createModulePart};
@@ -1 +1 @@
1
- import{b as G,o as U}from"../../../chunks/VBV366XQ.js";import"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/P7Q6MJZH.js";import"../../../chunks/64EN6Y7E.js";import{b as j}from"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import{a as H}from"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import{a as l,d as q,i as E,j as D}from"../../../chunks/25EOXUBI.js";import{a as _}from"../../../chunks/B5RZYFQC.js";import{a as i}from"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";import{decodeEventLog as M,encodeFunctionData as tt,erc20Abi as R,pad as Q,parseAbi as W,toEventSelector as P,zeroAddress as et}from"viem";var $=E[l].orbio.credit.address,g=E[l].orbio.exchange.address,a={address:$,chainId:l,symbol:"CREDIT",decimals:6},O={address:D,chainId:l,symbol:"USDG",decimals:q},J=(1n<<256n)-1n,B=W(["function buyAndActivate(uint256 usdgIn, uint256 minCreditOut, bytes32 activationRef, uint256 maxFills) returns (uint256 creditOut, uint256 usdgSpent, uint256 activationId)","function getActivationQuote(uint256 usdgIn, uint256 maxFills) view returns (uint256 grossCredit, uint256 inputAmount, uint256 exchangeFee, uint256 fills, uint256 unknown, uint256 netActivated, uint256 activationFee)"]),k=W(["event Activated(uint256 indexed activationId, address indexed by, bytes32 indexed ref, uint256 amount)","event ActivationFeeCharged(uint256 indexed activationId, uint256 fee)"]),nt=P(k[0]),it=P(k[1]),ot=P("Transfer(address,address,uint256)"),K={status:"unverified",reason:"Off-chain spendable credit requires a separate service canary. An on-chain activation does not prove service credit."};function c(t,e){return{token:{...t},amount:e.toString()}}function z(t,e){if(typeof t!="string")throw new i(`${e} must be an integer string in base units.`);let o=_(t);if(o<=0n||o>J)throw new i(`${e} must be positive and fit uint256.`);return o}function L(t){if(typeof t!="bigint"||t<0n||t>J)throw new i("Orbio returned an invalid on-chain amount.");return t}function V(t,e){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(o=>!e.includes(o)))throw new i("Unsupported Orbio argument.")}function C(t,e){return t.toLowerCase()===e.toLowerCase()}async function X(t){let e=t.clientFor(l);if(await e.getChainId()!==l)throw new i(`Orbio requires chain ${l}.`);return e}async function at(t,e,o){V(e,["usdgIn","minCreditOut","maxFills"]),H(o);let d=z(e.usdgIn,"usdgIn"),u=e.maxFills===void 0?16:e.maxFills;if(typeof u!="number"||!Number.isInteger(u)||u<1||u>64)throw new i("maxFills must be an integer from 1 to 64.");let x=e.minCreditOut===void 0?void 0:z(e.minCreditOut,"minCreditOut"),I=await(await X(t)).readContract({address:g,abi:B,functionName:"getActivationQuote",args:[d,BigInt(u)]});if(!Array.isArray(I)||I.length!==7)throw new i("Orbio returned an invalid activation quote.");let[f,s,v,b,F,h,r]=I.map(L);if(f===0n||s!==d||b<1n||b>BigInt(u)||v>s||h===0n||h+r!==f)throw new i("Orbio returned an inconsistent activation quote.");let m=x??BigInt(U(f.toString(),G));if(m<=1n||m>f)throw new i("minCreditOut must exceed one base unit and be no greater than quoted gross CREDIT.");let T=Q(o.toLowerCase(),{size:32}),n=[t.approval(D,g,d.toString(),l),t.unsignedTx({to:g,chainId:l,value:"0",data:tt({abi:B,functionName:"buyAndActivate",args:[d,m,T,BigInt(u)]}),description:"Buy CREDIT and burn it for activation using the wallet reference."})],w=await t.preview(n,o),A=w.changes.map(p=>{let S=p.amount.startsWith("-"),Z=S?p.amount.slice(1):p.amount;return`${S?"-":""}${t.formatAmount(Z,p.token.decimals)} ${p.token.symbol} (${p.token.address}, chain ${p.token.chainId})`}).join("; "),y=(p,S)=>`${t.formatAmount(p.toString(),S.decimals)} ${S.symbol}`,Y=`Approve exactly ${y(d,O)} to Exchange, then buy and burn ${y(f,a)} (quoted). Gross minimum: ${y(m,a)}; exchange fee: ${y(v,O)}; activation fee: ${y(r,a)}; net activation: ${y(h,a)}. CREDIT is burned for activation, not transferred into the wallet. Off-chain spendable credit remains unverified. ${w.summary}${A?` Preview changes: ${A}.`:""}`;return{...{txs:n,summary:Y},preview:w,activationRef:T,spendableCredit:{...K},quote:{usdgIn:c(O,s),grossCredit:c(a,f),minCreditOut:c(a,m),exchangeFee:c(O,v),activationFee:c(a,r),netActivated:c(a,h),fills:b.toString(),unknownWord:F.toString()}}}async function rt(t,e,o){if(V(e,["transactionHash"]),H(o),e.transactionHash!==void 0&&(typeof e.transactionHash!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e.transactionHash)))throw new i("Provide a valid activation transaction hash.");let d=await X(t),[u,x]=await Promise.all([d.readContract({address:$,abi:R,functionName:"balanceOf",args:[o]}),d.readContract({address:$,abi:R,functionName:"totalSupply"})]),N=c(a,L(u)),I=c(a,L(x)),f={walletCredit:N,totalSupply:I,spendableCredit:{...K}};if(e.transactionHash===void 0)return{...f,activation:null};let s=await d.getTransactionReceipt({hash:e.transactionHash});if(s.status!=="success"||!C(s.from,o)||!s.to||!C(s.to,g)||s.transactionHash.toLowerCase()!==e.transactionHash.toLowerCase())throw new i("The transaction is not a successful Orbio activation from this wallet.");let v=Q(o.toLowerCase(),{size:32}),b=s.logs.filter(n=>C(n.address,$)),F=b.filter(n=>n.topics[0]?.toLowerCase()===nt);if(F.length!==1)throw new i("The receipt must contain one CREDIT activation.");let h=F[0],r=M({abi:k,eventName:"Activated",data:h.data,topics:h.topics,strict:!0}).args;if(!C(r.by,g)||r.ref.toLowerCase()!==v||r.amount===0n)throw new i("The CREDIT activation does not match Exchange and this wallet reference.");let m=b.filter(n=>n.topics[0]?.toLowerCase()===it).map(n=>M({abi:k,eventName:"ActivationFeeCharged",data:n.data,topics:n.topics,strict:!0}).args).filter(n=>n.activationId===r.activationId);if(m.length!==1||m[0].fee>r.amount)throw new i("The activation fee is missing or inconsistent.");let T=b.filter(n=>n.topics[0]?.toLowerCase()===ot).reduce((n,w)=>{let A=M({abi:R,eventName:"Transfer",data:w.data,topics:w.topics,strict:!0}).args;return n+(C(A.from,g)&&C(A.to,et)?A.value:0n)},0n);if(T!==r.amount)throw new i("The CREDIT burn does not match the activation amount.");return{...f,activation:{status:"onchain_success",id:r.activationId.toString(),transactionHash:s.transactionHash,blockNumber:s.blockNumber.toString(),by:g,ref:v,grossCredit:c(a,r.amount),burnedCredit:c(a,T),activationFee:c(a,m[0].fee),netActivated:c(a,r.amount-m[0].fee),note:"Receipt inclusion only; finality and off-chain spendable credit are not established. totalSupply is a current read, not a historical supply delta."}}}var st=t=>{let e=o=>async(d,u)=>{try{return await o(t,d,u)}catch(x){throw new i(t.plainError(x))}};return{tools:[{name:"orbio_buy_credit",inputSchema:{type:"object",additionalProperties:!1,required:["usdgIn"],properties:{usdgIn:{type:"string",pattern:"^[0-9]+$",description:"USDG base units (6 decimals) on chain 4663."},minCreditOut:{type:"string",pattern:"^[0-9]+$",description:"Gross CREDIT minimum before activation fee; defaults to the quoted gross amount minus shared slippage."},maxFills:{type:"integer",minimum:1,maximum:64,default:16}}},execute:e(at)},{name:"orbio_credit_status",inputSchema:{type:"object",additionalProperties:!1,properties:{transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"Optional buyAndActivate receipt to inspect for this wallet."}}},execute:e(rt)}]}};function ht(t){return j("orbio",[st(t)])}export{ht as createModule,st as createModulePart};
1
+ import{b as F,o as O}from"../../../chunks/2IRORNOH.js";import"../../../chunks/GDP4JSAX.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/Y3P6SUNL.js";import"../../../chunks/GIBF3YJO.js";import{b as Q}from"../../../chunks/UCMNB2UP.js";import"../../../chunks/Z25UKUJF.js";import{a as L}from"../../../chunks/A5ITAEUQ.js";import{a as j}from"../../../chunks/I5CQ64EU.js";import"../../../chunks/NA7HV7BR.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/M6JGTQRY.js";import{a as g,d as R,i as H,j as P}from"../../../chunks/ZUC6ILK2.js";import"../../../chunks/B4MLWDPM.js";import{a as i}from"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";import{decodeEventLog as N,encodeFunctionData as et,erc20Abi as q,pad as W,parseAbi as J,toEventSelector as U,zeroAddress as nt}from"viem";var E=H[g].orbio.credit.address,w=H[g].orbio.exchange.address,m={address:E,chainId:g,symbol:"CREDIT",decimals:6},D={address:P,chainId:g,symbol:"USDG",decimals:R},_=(1n<<256n)-1n,B=J(["function buyAndActivate(uint256 usdgIn, uint256 minCreditOut, bytes32 activationRef, uint256 maxFills) returns (uint256 creditOut, uint256 usdgSpent, uint256 activationId)","function getActivationQuote(uint256 usdgIn, uint256 maxFills) view returns (uint256 grossCredit, uint256 inputAmount, uint256 exchangeFee, uint256 fills, uint256 unknown, uint256 netActivated, uint256 activationFee)"]),M=J(["event Activated(uint256 indexed activationId, address indexed by, bytes32 indexed ref, uint256 amount)","event ActivationFeeCharged(uint256 indexed activationId, uint256 fee)"]),it=U(M[0]),ot=U(M[1]),at=U("Transfer(address,address,uint256)"),K={status:"unverified",reason:"Off-chain spendable credit requires a separate service canary. An on-chain activation does not prove service credit."};function p(t,e){return{token:{...t},amount:e.toString()}}function z(t,e){if(typeof t!="string")throw new i(`${e} must be an integer string in base units.`);let n=j(t);if(n<=0n||n>_)throw new i(`${e} must be positive and fit uint256.`);return n}function G(t){if(typeof t!="bigint"||t<0n||t>_)throw new i("Orbio returned an invalid on-chain amount.");return t}function V(t,e){if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).some(n=>!e.includes(n)))throw new i("Unsupported Orbio argument.")}function S(t,e){return t.toLowerCase()===e.toLowerCase()}async function X(t){let e=t.clientFor(g);if(await e.getChainId()!==g)throw new i(`Orbio requires chain ${g}.`);return e}function Y(t,e,n){if(!Array.isArray(t)||t.length!==7)throw new i("Orbio returned an invalid activation quote.");let a=t.map(G),[r,d,b,u,,c,o]=a;if(r===0n||d!==e||u<1n||u>BigInt(n)||b>d||c+o!==r)throw new i("Orbio returned an inconsistent activation quote.");return a}async function rt(t,e,n,a){let r=await t.getBlockNumber(),d=async c=>{let o=await t.readContract({address:w,abi:B,functionName:"getActivationQuote",args:[c,BigInt(n)],blockNumber:r}),[v,,,,,A]=Y(o,c,n),y=a??BigInt(O(v.toString(),F));return A>0n&&y>1n&&y<=v};if(await d(e))return e;let b=e,u=e;for(let c=0;c<16&&!(u>_/2n);c++){if(u*=2n,await d(u)){for(;u-b>1n;){let o=(b+u)/2n;await d(o)?u=o:b=o}return u}b=u}throw new i("Orbio amount is too small. A workable minimum could not be quoted; retry when liquidity is available.")}async function st(t,e,n){V(e,["usdgIn","minCreditOut","maxFills"]),L(n);let a=z(e.usdgIn,"usdgIn"),r=e.maxFills===void 0?16:e.maxFills;if(typeof r!="number"||!Number.isInteger(r)||r<1||r>64)throw new i("maxFills must be an integer from 1 to 64.");let d=e.minCreditOut===void 0?void 0:z(e.minCreditOut,"minCreditOut"),b=await X(t),u=await b.readContract({address:w,abi:B,functionName:"getActivationQuote",args:[a,BigInt(r)]}),[c,o,v,A,y,C,l]=Y(u,a,r);if(C===0n||d===void 0&&BigInt(O(c.toString(),F))<=1n){let f=await rt(b,a,r,d);throw new i(`Orbio amount is too small. Minimum at the quoted block: ${f} USDG base units (${t.formatAmount(f.toString(),R)} USDG, 6 decimals, chain ${g}).`)}let h=d??BigInt(O(c.toString(),F));if(h<=1n||h>c)throw new i("minCreditOut must exceed one base unit and be no greater than quoted gross CREDIT.");let k=W(n.toLowerCase(),{size:32}),s=[t.approval(P,w,a.toString(),g),t.unsignedTx({to:w,chainId:g,value:"0",data:et({abi:B,functionName:"buyAndActivate",args:[a,h,k,BigInt(r)]}),description:"Buy CREDIT and burn it for activation using the wallet reference."})],I=await t.preview(s,n),x=I.changes.map(f=>{let $=f.amount.startsWith("-"),tt=$?f.amount.slice(1):f.amount;return`${$?"-":""}${t.formatAmount(tt,f.token.decimals)} ${f.token.symbol} (${f.token.address}, chain ${f.token.chainId})`}).join("; "),T=(f,$)=>`${t.formatAmount(f.toString(),$.decimals)} ${$.symbol}`,Z=`Approve exactly ${T(a,D)} to Exchange, then buy and burn ${T(c,m)} (quoted). Gross minimum: ${T(h,m)}; exchange fee: ${T(v,D)}; activation fee: ${T(l,m)}; net activation: ${T(C,m)}. CREDIT is burned for activation, not transferred into the wallet. Off-chain spendable credit remains unverified. ${I.summary}${x?` Preview changes: ${x}.`:""}`;return{...{txs:s,summary:Z},preview:I,activationRef:k,spendableCredit:{...K},quote:{usdgIn:p(D,o),grossCredit:p(m,c),minCreditOut:p(m,h),exchangeFee:p(D,v),activationFee:p(m,l),netActivated:p(m,C),fills:A.toString(),unknownWord:y.toString()}}}async function ct(t,e,n){if(V(e,["transactionHash"]),L(n),e.transactionHash!==void 0&&(typeof e.transactionHash!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e.transactionHash)))throw new i("Provide a valid activation transaction hash.");let a=await X(t),[r,d]=await Promise.all([a.readContract({address:E,abi:q,functionName:"balanceOf",args:[n]}),a.readContract({address:E,abi:q,functionName:"totalSupply"})]),b=p(m,G(r)),u=p(m,G(d)),c={walletCredit:b,totalSupply:u,spendableCredit:{...K}};if(e.transactionHash===void 0)return{...c,activation:null};let o=await a.getTransactionReceipt({hash:e.transactionHash});if(o.status!=="success"||!S(o.from,n)||!o.to||!S(o.to,w)||o.transactionHash.toLowerCase()!==e.transactionHash.toLowerCase())throw new i("The transaction is not a successful Orbio activation from this wallet.");let v=W(n.toLowerCase(),{size:32}),A=o.logs.filter(s=>S(s.address,E)),y=A.filter(s=>s.topics[0]?.toLowerCase()===it);if(y.length!==1)throw new i("The receipt must contain one CREDIT activation.");let C=y[0],l=N({abi:M,eventName:"Activated",data:C.data,topics:C.topics,strict:!0}).args;if(!S(l.by,w)||l.ref.toLowerCase()!==v||l.amount===0n)throw new i("The CREDIT activation does not match Exchange and this wallet reference.");let h=A.filter(s=>s.topics[0]?.toLowerCase()===ot).map(s=>N({abi:M,eventName:"ActivationFeeCharged",data:s.data,topics:s.topics,strict:!0}).args).filter(s=>s.activationId===l.activationId);if(h.length!==1||h[0].fee>l.amount)throw new i("The activation fee is missing or inconsistent.");let k=A.filter(s=>s.topics[0]?.toLowerCase()===at).reduce((s,I)=>{let x=N({abi:q,eventName:"Transfer",data:I.data,topics:I.topics,strict:!0}).args;return s+(S(x.from,w)&&S(x.to,nt)?x.value:0n)},0n);if(k!==l.amount)throw new i("The CREDIT burn does not match the activation amount.");return{...c,activation:{status:"onchain_success",id:l.activationId.toString(),transactionHash:o.transactionHash,blockNumber:o.blockNumber.toString(),by:w,ref:v,grossCredit:p(m,l.amount),burnedCredit:p(m,k),activationFee:p(m,h[0].fee),netActivated:p(m,l.amount-h[0].fee),note:"Receipt inclusion only; finality and off-chain spendable credit are not established. totalSupply is a current read, not a historical supply delta."}}}var ut=t=>{let e=n=>async(a,r)=>{try{return await n(t,a,r)}catch(d){throw new i(t.plainError(d))}};return{tools:[{name:"orbio_buy_credit",inputSchema:{type:"object",additionalProperties:!1,required:["usdgIn"],properties:{usdgIn:{type:"string",pattern:"^[0-9]+$",description:"USDG base units (6 decimals) on chain 4663."},minCreditOut:{type:"string",pattern:"^[0-9]+$",description:"Gross CREDIT minimum before activation fee; defaults to the quoted gross amount minus shared slippage."},maxFills:{type:"integer",minimum:1,maximum:64,default:16}}},execute:e(st)},{name:"orbio_credit_status",inputSchema:{type:"object",additionalProperties:!1,properties:{transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"Optional buyAndActivate receipt to inspect for this wallet."}}},execute:e(ct)}]}};function vt(t){return Q("orbio",[ut(t)])}export{vt as createModule,ut as createModulePart};
@@ -1 +1 @@
1
- import{a}from"../../../chunks/BH3CI6WO.js";import"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/P7Q6MJZH.js";import"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import"../../../chunks/25EOXUBI.js";import"../../../chunks/B5RZYFQC.js";import"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";export{a as createModulePart};
1
+ import{a}from"../../../chunks/TEVKPJV5.js";import"../../../chunks/GDP4JSAX.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/GIBF3YJO.js";import"../../../chunks/A5ITAEUQ.js";import"../../../chunks/I5CQ64EU.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/M6JGTQRY.js";import"../../../chunks/ZUC6ILK2.js";import"../../../chunks/B4MLWDPM.js";import"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";export{a as createModulePart};
@@ -1 +1 @@
1
- import{a as o,c as m}from"../../../chunks/4P6XI564.js";import{a as t}from"../../../chunks/BH3CI6WO.js";import{c as a}from"../../../chunks/D45AODDL.js";import"../../../chunks/VBV366XQ.js";import"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/P7Q6MJZH.js";import"../../../chunks/ZUAXW2ZD.js";import"../../../chunks/64EN6Y7E.js";import{b as r}from"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import"../../../chunks/25EOXUBI.js";import"../../../chunks/B5RZYFQC.js";import"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";var i=e=>r("pons",[a(e),m(e),t(e)],o(e));export{i as createModule};
1
+ import{a as o,d as m}from"../../../chunks/A5KSG6LW.js";import{a as t}from"../../../chunks/TEVKPJV5.js";import{c as a}from"../../../chunks/BHR46XNW.js";import"../../../chunks/2IRORNOH.js";import"../../../chunks/GDP4JSAX.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/MK6L6TGI.js";import"../../../chunks/Y3P6SUNL.js";import"../../../chunks/GIBF3YJO.js";import{b as r}from"../../../chunks/UCMNB2UP.js";import"../../../chunks/Z25UKUJF.js";import"../../../chunks/A5ITAEUQ.js";import"../../../chunks/I5CQ64EU.js";import"../../../chunks/NA7HV7BR.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/M6JGTQRY.js";import"../../../chunks/ZUC6ILK2.js";import"../../../chunks/B4MLWDPM.js";import"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";var i=e=>r("pons",[a(e),m(e),t(e)],o(e));export{i as createModule};
@@ -1 +1 @@
1
- import{a,b,c,d}from"../../../chunks/D45AODDL.js";import"../../../chunks/VBV366XQ.js";import"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/P7Q6MJZH.js";import"../../../chunks/ZUAXW2ZD.js";import"../../../chunks/64EN6Y7E.js";import"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import"../../../chunks/25EOXUBI.js";import"../../../chunks/B5RZYFQC.js";import"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";export{d as createLaunchStatusPart,c as createModulePart,a as readLaunchStatus,b as readLaunches};
1
+ import{a,b,c,d}from"../../../chunks/BHR46XNW.js";import"../../../chunks/2IRORNOH.js";import"../../../chunks/GDP4JSAX.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/MK6L6TGI.js";import"../../../chunks/Y3P6SUNL.js";import"../../../chunks/GIBF3YJO.js";import"../../../chunks/A5ITAEUQ.js";import"../../../chunks/I5CQ64EU.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/M6JGTQRY.js";import"../../../chunks/ZUC6ILK2.js";import"../../../chunks/B4MLWDPM.js";import"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";export{d as createLaunchStatusPart,c as createModulePart,a as readLaunchStatus,b as readLaunches};
@@ -1 +1 @@
1
- import{a}from"../../../chunks/YTHDLCHL.js";import"../../../chunks/25EOXUBI.js";import"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";export{a as readPonsEthRatio};
1
+ import{a}from"../../../chunks/3PA2XT75.js";import"../../../chunks/ZUC6ILK2.js";import"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";export{a as readPonsEthRatio};
@@ -1,6 +1,6 @@
1
1
  import { type Address } from 'viem';
2
2
  import type { CreateModulePart, ModuleContext, SwapProvider, TokenAmount, ToolArgs, UnsignedTx } from '../../types.js';
3
- declare function trade(context: ModuleContext, args: ToolArgs, wallet: Address, buy: boolean, curveQuote?: boolean): Promise<{
3
+ declare function trade(context: ModuleContext, args: ToolArgs, wallet: Address, buy: boolean, quoteOnly?: boolean, curveOnly?: boolean, blockNumber?: bigint): Promise<{
4
4
  txs: UnsignedTx[];
5
5
  changes: never[] | TokenAmount[];
6
6
  summary: string;
@@ -19,10 +19,12 @@ declare function trade(context: ModuleContext, args: ToolArgs, wallet: Address,
19
19
  snipe: TokenAmount;
20
20
  } | null;
21
21
  blockNumber: string;
22
+ blockTimestamp: string;
22
23
  };
23
24
  }>;
24
25
  export type PonsTradeResult = Awaited<ReturnType<typeof trade>>;
25
26
  export declare function createCurveSwapProvider(context: ModuleContext): SwapProvider;
27
+ export declare function createPonsSwapProvider(context: ModuleContext, curveOnly?: boolean, blockNumber?: bigint): SwapProvider;
26
28
  export declare const createTradePart: CreateModulePart;
27
29
  export declare const createModulePart: CreateModulePart;
28
30
  export {};
@@ -1 +1 @@
1
- import{a,b,c}from"../../../chunks/4P6XI564.js";import"../../../chunks/VBV366XQ.js";import"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/P7Q6MJZH.js";import"../../../chunks/64EN6Y7E.js";import"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import"../../../chunks/25EOXUBI.js";import"../../../chunks/B5RZYFQC.js";import"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";export{a as createCurveSwapProvider,c as createModulePart,b as createTradePart};
1
+ import{a,b,c,d}from"../../../chunks/A5KSG6LW.js";import"../../../chunks/2IRORNOH.js";import"../../../chunks/GDP4JSAX.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/Y3P6SUNL.js";import"../../../chunks/GIBF3YJO.js";import"../../../chunks/A5ITAEUQ.js";import"../../../chunks/I5CQ64EU.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/M6JGTQRY.js";import"../../../chunks/ZUC6ILK2.js";import"../../../chunks/B4MLWDPM.js";import"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";export{a as createCurveSwapProvider,d as createModulePart,b as createPonsSwapProvider,c as createTradePart};
@@ -1 +1 @@
1
- import{a,b,c}from"../../../chunks/6YU3JLQQ.js";import"../../../chunks/VBV366XQ.js";import"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/P7Q6MJZH.js";import"../../../chunks/64EN6Y7E.js";import"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import"../../../chunks/25EOXUBI.js";import"../../../chunks/B5RZYFQC.js";import"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";export{c as createModule,b as createModulePart,a as recoverLaunches};
1
+ import{a,b,c}from"../../../chunks/YX4NVVSX.js";import"../../../chunks/2IRORNOH.js";import"../../../chunks/GDP4JSAX.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/Y3P6SUNL.js";import"../../../chunks/GIBF3YJO.js";import"../../../chunks/UCMNB2UP.js";import"../../../chunks/Z25UKUJF.js";import"../../../chunks/A5ITAEUQ.js";import"../../../chunks/I5CQ64EU.js";import"../../../chunks/NA7HV7BR.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/M6JGTQRY.js";import"../../../chunks/ZUC6ILK2.js";import"../../../chunks/B4MLWDPM.js";import"../../../chunks/NGAI6GTU.js";import"../../../chunks/JXOEJPJ4.js";export{c as createModule,b as createModulePart,a as recoverLaunches};