@oakagentkit/core 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) 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/canonical.js +1 -1
  5. package/build/dist/api/chain.js +1 -1
  6. package/build/dist/api/errors.d.ts +1 -0
  7. package/build/dist/api/errors.js +1 -1
  8. package/build/dist/api/gas.d.ts +5 -0
  9. package/build/dist/api/gas.js +1 -0
  10. package/build/dist/api/grandfather.js +1 -1
  11. package/build/dist/api/history.js +1 -1
  12. package/build/dist/api/http.js +1 -1
  13. package/build/dist/api/identity-link.js +1 -1
  14. package/build/dist/api/merkle.js +1 -1
  15. package/build/dist/api/metadata.js +1 -1
  16. package/build/dist/api/module.js +1 -1
  17. package/build/dist/api/modules/beefy/index.js +1 -1
  18. package/build/dist/api/modules/clanker/index.js +1 -1
  19. package/build/dist/api/modules/erc8004/index.d.ts +11 -0
  20. package/build/dist/api/modules/erc8004/index.js +1 -1
  21. package/build/dist/api/modules/grove/index.js +1 -1
  22. package/build/dist/api/modules/heyresearch/index.js +1 -1
  23. package/build/dist/api/modules/hoodag/index.js +1 -1
  24. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  25. package/build/dist/api/modules/hoodlock/index.js +1 -1
  26. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  27. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  28. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  29. package/build/dist/api/modules/hookr/index.js +1 -1
  30. package/build/dist/api/modules/kyberswap/index.js +1 -1
  31. package/build/dist/api/modules/lighter/index.js +1 -1
  32. package/build/dist/api/modules/longbow/index.js +1 -1
  33. package/build/dist/api/modules/meridian/index.js +1 -1
  34. package/build/dist/api/modules/meridian/markets.js +1 -1
  35. package/build/dist/api/modules/meridian/rfq.js +1 -1
  36. package/build/dist/api/modules/merkl/index.js +1 -1
  37. package/build/dist/api/modules/morpho/index.js +1 -1
  38. package/build/dist/api/modules/netnet/index.js +1 -1
  39. package/build/dist/api/modules/orbio/index.js +1 -1
  40. package/build/dist/api/modules/pons/claim.js +1 -1
  41. package/build/dist/api/modules/pons/index.js +1 -1
  42. package/build/dist/api/modules/pons/launch-status.js +1 -1
  43. package/build/dist/api/modules/pons/prices.js +1 -1
  44. package/build/dist/api/modules/pons/trade.js +1 -1
  45. package/build/dist/api/modules/poolstrade/index.js +1 -1
  46. package/build/dist/api/modules/priors/index.js +1 -1
  47. package/build/dist/api/modules/relay/inbound.d.ts +2 -0
  48. package/build/dist/api/modules/relay/inbound.js +1 -1
  49. package/build/dist/api/modules/relay/index.js +1 -1
  50. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  51. package/build/dist/api/modules/spark/index.js +1 -1
  52. package/build/dist/api/modules/steakhouse/index.js +1 -1
  53. package/build/dist/api/modules/tickerspring/index.js +1 -1
  54. package/build/dist/api/modules/uniswap/index.js +1 -1
  55. package/build/dist/api/modules/uniswap/v3.js +1 -1
  56. package/build/dist/api/modules/uniswap/v4.js +1 -1
  57. package/build/dist/api/modules/velora/index.js +1 -1
  58. package/build/dist/api/positions.js +1 -1
  59. package/build/dist/api/pricenote.js +1 -1
  60. package/build/dist/api/prices.js +1 -1
  61. package/build/dist/api/pricing.js +1 -1
  62. package/build/dist/api/routes.js +1 -1
  63. package/build/dist/api/secret-fields.js +1 -1
  64. package/build/dist/api/simulate.js +1 -1
  65. package/build/dist/api/swap.d.ts +5 -1
  66. package/build/dist/api/swap.js +1 -1
  67. package/build/dist/api/tokens.js +1 -1
  68. package/build/dist/api/tx.js +1 -1
  69. package/build/dist/api/types.d.ts +3 -0
  70. package/build/dist/api/vendor-limits.js +1 -1
  71. package/build/dist/chunks/{OOSNTGDJ.js → 5B3UVWMV.js} +1 -1
  72. package/build/dist/chunks/5BP72XOA.js +1 -0
  73. package/build/dist/chunks/5SH3C7XP.js +1 -0
  74. package/build/dist/chunks/{YEE3KKTA.js → 6YQ2RX5I.js} +1 -1
  75. package/build/dist/chunks/{64EN6Y7E.js → 74X7PXPR.js} +1 -1
  76. package/build/dist/chunks/{B5RZYFQC.js → 7I6TXFXR.js} +1 -1
  77. package/build/dist/chunks/A5O3SRHY.js +1 -0
  78. package/build/dist/chunks/{D45AODDL.js → B2LA6VVF.js} +1 -1
  79. package/build/dist/chunks/{ZERWRK6X.js → CWQ5WXZQ.js} +1 -1
  80. package/build/dist/chunks/{YTHDLCHL.js → F3TOOLFQ.js} +1 -1
  81. package/build/dist/chunks/GOIVHR4B.js +1 -0
  82. package/build/dist/chunks/{47PKSOXA.js → M643PYHO.js} +1 -1
  83. package/build/dist/chunks/{P7Q6MJZH.js → MEZH7RPA.js} +1 -1
  84. package/build/dist/chunks/{AE6YEEZP.js → NDHEJGWR.js} +1 -1
  85. package/build/dist/chunks/NNJLMS7F.js +1 -0
  86. package/build/dist/chunks/{ZKOMJGNH.js → PQHU5A3U.js} +1 -1
  87. package/build/dist/chunks/{UL2L7NHO.js → R5CBH2CR.js} +1 -1
  88. package/build/dist/chunks/{VZPFBWVH.js → RYOVSHKO.js} +1 -1
  89. package/build/dist/chunks/{75D6Q7L3.js → SUQ6PIAV.js} +1 -1
  90. package/build/dist/chunks/{KFMNCJXJ.js → SXBGOGYQ.js} +1 -1
  91. package/build/dist/chunks/{LZK6C5LT.js → T4IYMYZD.js} +1 -1
  92. package/build/dist/chunks/{IABIXUNX.js → TFYLOWFO.js} +1 -1
  93. package/build/dist/chunks/{ZUAXW2ZD.js → TU3KHOZK.js} +1 -1
  94. package/build/dist/chunks/{SGDWO7XI.js → UB5U6SI2.js} +1 -1
  95. package/build/dist/chunks/UIJWIFGV.js +1 -0
  96. package/build/dist/chunks/{VZWOWR6G.js → VBWJOG3N.js} +1 -1
  97. package/build/dist/chunks/{KP7VSXIQ.js → WFE3NXBF.js} +1 -1
  98. package/build/dist/chunks/XAB4OIE3.js +1 -0
  99. package/build/dist/chunks/XEN45QST.js +1 -0
  100. package/build/dist/chunks/{MGEJPRXP.js → XKZOMGC3.js} +1 -1
  101. package/build/dist/chunks/{JMPOXXNJ.js → XTUXR43N.js} +1 -1
  102. package/build/dist/chunks/{UZH4FQEL.js → Y2SGXWFM.js} +1 -1
  103. package/build/dist/chunks/Z3FZWNAJ.js +1 -0
  104. package/build/dist/chunks/Z53DADZ4.js +1 -0
  105. package/build/dist/chunks/ZJUNO5N7.js +1 -0
  106. package/build/dist/chunks/ZZLHDHOT.js +1 -0
  107. package/package.json +9 -13
  108. package/build/dist/chunks/24JYIH53.js +0 -1
  109. package/build/dist/chunks/25EOXUBI.js +0 -1
  110. package/build/dist/chunks/4P6XI564.js +0 -1
  111. package/build/dist/chunks/6YU3JLQQ.js +0 -1
  112. package/build/dist/chunks/BH3CI6WO.js +0 -1
  113. package/build/dist/chunks/CUBRTOMA.js +0 -1
  114. package/build/dist/chunks/FSSCJNAQ.js +0 -1
  115. package/build/dist/chunks/S3YSJ7XH.js +0 -1
  116. package/build/dist/chunks/T5E4OJEU.js +0 -1
  117. package/build/dist/chunks/VBV366XQ.js +0 -1
  118. package/build/dist/chunks/XUL6NKAK.js +0 -1
@@ -1 +1 @@
1
- import{b as P}from"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import{a as T}from"../../../chunks/VZWOWR6G.js";import{a as h,d as D,i as $,j as b}from"../../../chunks/25EOXUBI.js";import{a as R}from"../../../chunks/B5RZYFQC.js";import{a as p}from"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";import{encodeFunctionData as A,erc20Abi as _,parseAbi as I}from"viem";var f=$[h].vaults.spark.address,n={address:b,chainId:h,symbol:"USDG",decimals:D},c={address:f,chainId:h,symbol:"spUSDG",decimals:6},M=1000000000000n,C=(1n<<256n)-1n,k=I(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function balanceOf(address owner) view returns (uint256)","function maxDeposit(address receiver) view returns (uint256)","function maxWithdraw(address owner) view returns (uint256)","function maxRedeem(address owner) view returns (uint256)","function previewDeposit(uint256 assets) view returns (uint256)","function previewWithdraw(uint256 assets) view returns (uint256)","function previewRedeem(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)"]),t=(i,l)=>({token:{...i},amount:l.toString()});function y(i,l,v=!1){if(!i||typeof i!="object"||Array.isArray(i)||Object.keys(i).some(S=>!l||S!=="amount"))throw new p(l?"Provide only the amount for this Spark action.":"Spark listing takes no arguments.");if(!l)return 0n;if(v&&i.amount==="max")return"max";if(typeof i.amount!="string")throw new p("Amount must be a positive integer string in base units.");let s=R(i.amount);if(s===0n||s>C)throw new p("Amount must be positive and within the uint256 range.");return s}var G=i=>{async function l(a){try{return await a()}catch(e){throw new p(i.plainError(e))}}async function v(a){T(a);let e=i.clientFor(h);if(await e.getChainId()!==h)throw new p("Spark requires an endpoint on chain 4663.");let[r,d,o]=await Promise.all([e.readContract({address:f,abi:k,functionName:"asset"}),e.readContract({address:f,abi:k,functionName:"decimals"}),e.readContract({address:b,abi:_,functionName:"decimals"})]);if(typeof r!="string"||r.toLowerCase()!==b.toLowerCase())throw new p("Spark does not report the expected USDG asset on chain 4663.");if(d!==c.decimals||o!==n.decimals)throw new p("Spark shares and USDG must both have 6 decimals.");return async(m,x=[])=>{let u=await e.readContract({address:f,abi:k,functionName:m,args:x});if(typeof u!="bigint"||u<0n||u>C)throw new p(`Spark returned an invalid ${m} value.`);return u}}function s(a){let e=a.amount.startsWith("-"),r=e?a.amount.slice(1):a.amount;return`${e?"-":""}${i.formatAmount(r,a.token.decimals)} ${a.token.symbol}`}async function S(a,e,r,d){let o=await i.preview(a,e),m=o.changes.map(s).join(", ");return{txs:a,amounts:r,preview:o,summary:`${d} Preview values can change before execution. ${o.summary}${m?` Changes: ${m}.`:""}`}}return{positions:a=>l(async()=>{let e=await v(a),r=await e("balanceOf",[a]);if(r===0n)return[];let[d,o,m]=await Promise.all([e("previewRedeem",[r]),e("maxRedeem",[a]),e("maxWithdraw",[a])]);return[{module:"spark",id:`${h}:${f}`,chainId:h,assets:[t(c,r)],description:`${s(t(c,r))}; redeem preview ${s(t(n,d))} (rounded down). Current maximum redeem ${s(t(c,o))}; maximum withdrawal ${s(t(n,m))}.`}]}),tools:[{name:"spark_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(a,e)=>l(async()=>{y(a,!1);let r=await v(e),d=await r("totalAssets");if(d<M)return[];let[o,m,x,u,w]=await Promise.all([r("balanceOf",[e]),r("maxDeposit",[e]),r("maxWithdraw",[e]),r("maxRedeem",[e]),r("previewDeposit",[1000000n])]),g=await r("previewRedeem",[o]);return[{chainId:h,address:f,name:"Spark Savings USDG",asset:{...n},shareToken:{...c},totalAssets:t(n,d),balance:t(c,o),maxDeposit:t(n,m),maxWithdraw:t(n,x),maxRedeem:t(c,u),previewDepositAssets:t(n,1000000n),previewDeposit:t(c,w),previewRedeemShares:t(c,o),previewRedeem:t(n,g),rounding:"Deposit shares and redeemed assets round down; exact-asset withdrawals round shares up. Previews can change before execution."}]})},{name:"spark_deposit",inputSchema:{type:"object",properties:{amount:{type:"string",pattern:"^[0-9]+$",description:"Positive USDG base-unit integer (6 decimals)."}},required:["amount"],additionalProperties:!1},execute:(a,e)=>l(async()=>{let r=y(a,!0),d=await v(e),[o,m]=await Promise.all([d("maxDeposit",[e]),d("previewDeposit",[r])]);if(r>o)throw new p("The deposit exceeds Spark\u2019s current maximum deposit.");if(m===0n)throw new p("This deposit would return zero Spark shares.");let x=[i.approval(b,f,r.toString(),h),i.unsignedTx({to:f,data:A({abi:k,functionName:"deposit",args:[r,e]}),value:"0",chainId:h,description:`Deposit ${s(t(n,r))} into Spark for this wallet.`})];return S(x,e,{assets:t(n,r),shares:t(c,m),maxDeposit:t(n,o)},`Approve exactly ${s(t(n,r))} for Spark ${f}, then deposit. Expected ${s(t(c,m))}, rounded down; current maximum deposit ${s(t(n,o))}.`)})},{name:"spark_withdraw",inputSchema:{type:"object",properties:{amount:{type:"string",anyOf:[{pattern:"^[0-9]+$"},{const:"max"}],description:"Positive USDG base-unit integer (6 decimals), or max to redeem all held shares."}},required:["amount"],additionalProperties:!1},execute:(a,e)=>l(async()=>{let r=y(a,!0,!0),d=await v(e),[o,m,x]=await Promise.all([d("balanceOf",[e]),d("maxWithdraw",[e]),d("maxRedeem",[e])]);if(o===0n)throw new p("This wallet has no Spark shares to withdraw.");let u,w,g;if(r==="max"){if(w=o,w>x)throw new p("The full share balance exceeds Spark\u2019s current maximum redeem. Request an asset amount within the current maximum withdrawal.");u=await d("previewRedeem",[w]),g=A({abi:k,functionName:"redeem",args:[w,e,e]})}else{if(u=r,u>m)throw new p("The withdrawal exceeds Spark\u2019s current maximum withdrawal.");if(w=await d("previewWithdraw",[u]),w>o)throw new p("This wallet has insufficient Spark shares for the withdrawal.");g=A({abi:k,functionName:"withdraw",args:[u,e,e]})}if(u===0n||w===0n)throw new p("Spark returned a zero asset or share preview for this withdrawal.");let W=r==="max"?`Redeem all ${s(t(c,w))} from Spark to this wallet.`:`Withdraw ${s(t(n,u))} from Spark to this wallet.`,U=[i.unsignedTx({to:f,data:g,value:"0",chainId:h,description:W})];return S(U,e,{assets:t(n,u),shares:t(c,w),maxWithdraw:t(n,m),maxRedeem:t(c,x)},r==="max"?`Redeem all ${s(t(c,w))} for an expected ${s(t(n,u))}, rounded down. Current maximum redeem ${s(t(c,x))}.`:`Withdraw ${s(t(n,u))} using an expected ${s(t(c,w))}, rounded up. Current maximum withdrawal ${s(t(n,m))}.`)})}]}};function q(i){return P("spark",[G(i)])}export{q as createModule,G as createModulePart};
1
+ import{b as P}from"../../../chunks/UB5U6SI2.js";import"../../../chunks/Z25UKUJF.js";import{a as T}from"../../../chunks/VBWJOG3N.js";import{a as h,d as D,i as $,j as b}from"../../../chunks/5BP72XOA.js";import{a as R}from"../../../chunks/7I6TXFXR.js";import{a as p}from"../../../chunks/Z3FZWNAJ.js";import"../../../chunks/XN4WDN3O.js";import{encodeFunctionData as A,erc20Abi as _,parseAbi as I}from"viem";var f=$[h].vaults.spark.address,n={address:b,chainId:h,symbol:"USDG",decimals:D},c={address:f,chainId:h,symbol:"spUSDG",decimals:6},M=1000000000000n,C=(1n<<256n)-1n,k=I(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function balanceOf(address owner) view returns (uint256)","function maxDeposit(address receiver) view returns (uint256)","function maxWithdraw(address owner) view returns (uint256)","function maxRedeem(address owner) view returns (uint256)","function previewDeposit(uint256 assets) view returns (uint256)","function previewWithdraw(uint256 assets) view returns (uint256)","function previewRedeem(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)"]),t=(i,l)=>({token:{...i},amount:l.toString()});function y(i,l,v=!1){if(!i||typeof i!="object"||Array.isArray(i)||Object.keys(i).some(S=>!l||S!=="amount"))throw new p(l?"Provide only the amount for this Spark action.":"Spark listing takes no arguments.");if(!l)return 0n;if(v&&i.amount==="max")return"max";if(typeof i.amount!="string")throw new p("Amount must be a positive integer string in base units.");let s=R(i.amount);if(s===0n||s>C)throw new p("Amount must be positive and within the uint256 range.");return s}var G=i=>{async function l(a){try{return await a()}catch(e){throw new p(i.plainError(e))}}async function v(a){T(a);let e=i.clientFor(h);if(await e.getChainId()!==h)throw new p("Spark requires an endpoint on chain 4663.");let[r,d,o]=await Promise.all([e.readContract({address:f,abi:k,functionName:"asset"}),e.readContract({address:f,abi:k,functionName:"decimals"}),e.readContract({address:b,abi:_,functionName:"decimals"})]);if(typeof r!="string"||r.toLowerCase()!==b.toLowerCase())throw new p("Spark does not report the expected USDG asset on chain 4663.");if(d!==c.decimals||o!==n.decimals)throw new p("Spark shares and USDG must both have 6 decimals.");return async(m,x=[])=>{let u=await e.readContract({address:f,abi:k,functionName:m,args:x});if(typeof u!="bigint"||u<0n||u>C)throw new p(`Spark returned an invalid ${m} value.`);return u}}function s(a){let e=a.amount.startsWith("-"),r=e?a.amount.slice(1):a.amount;return`${e?"-":""}${i.formatAmount(r,a.token.decimals)} ${a.token.symbol}`}async function S(a,e,r,d){let o=await i.preview(a,e),m=o.changes.map(s).join(", ");return{txs:a,amounts:r,preview:o,summary:`${d} Preview values can change before execution. ${o.summary}${m?` Changes: ${m}.`:""}`}}return{positions:a=>l(async()=>{let e=await v(a),r=await e("balanceOf",[a]);if(r===0n)return[];let[d,o,m]=await Promise.all([e("previewRedeem",[r]),e("maxRedeem",[a]),e("maxWithdraw",[a])]);return[{module:"spark",id:`${h}:${f}`,chainId:h,assets:[t(c,r)],description:`${s(t(c,r))}; redeem preview ${s(t(n,d))} (rounded down). Current maximum redeem ${s(t(c,o))}; maximum withdrawal ${s(t(n,m))}.`}]}),tools:[{name:"spark_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(a,e)=>l(async()=>{y(a,!1);let r=await v(e),d=await r("totalAssets");if(d<M)return[];let[o,m,x,u,w]=await Promise.all([r("balanceOf",[e]),r("maxDeposit",[e]),r("maxWithdraw",[e]),r("maxRedeem",[e]),r("previewDeposit",[1000000n])]),g=await r("previewRedeem",[o]);return[{chainId:h,address:f,name:"Spark Savings USDG",asset:{...n},shareToken:{...c},totalAssets:t(n,d),balance:t(c,o),maxDeposit:t(n,m),maxWithdraw:t(n,x),maxRedeem:t(c,u),previewDepositAssets:t(n,1000000n),previewDeposit:t(c,w),previewRedeemShares:t(c,o),previewRedeem:t(n,g),rounding:"Deposit shares and redeemed assets round down; exact-asset withdrawals round shares up. Previews can change before execution."}]})},{name:"spark_deposit",inputSchema:{type:"object",properties:{amount:{type:"string",pattern:"^[0-9]+$",description:"Positive USDG base-unit integer (6 decimals)."}},required:["amount"],additionalProperties:!1},execute:(a,e)=>l(async()=>{let r=y(a,!0),d=await v(e),[o,m]=await Promise.all([d("maxDeposit",[e]),d("previewDeposit",[r])]);if(r>o)throw new p("The deposit exceeds Spark\u2019s current maximum deposit.");if(m===0n)throw new p("This deposit would return zero Spark shares.");let x=[i.approval(b,f,r.toString(),h),i.unsignedTx({to:f,data:A({abi:k,functionName:"deposit",args:[r,e]}),value:"0",chainId:h,description:`Deposit ${s(t(n,r))} into Spark for this wallet.`})];return S(x,e,{assets:t(n,r),shares:t(c,m),maxDeposit:t(n,o)},`Approve exactly ${s(t(n,r))} for Spark ${f}, then deposit. Expected ${s(t(c,m))}, rounded down; current maximum deposit ${s(t(n,o))}.`)})},{name:"spark_withdraw",inputSchema:{type:"object",properties:{amount:{type:"string",anyOf:[{pattern:"^[0-9]+$"},{const:"max"}],description:"Positive USDG base-unit integer (6 decimals), or max to redeem all held shares."}},required:["amount"],additionalProperties:!1},execute:(a,e)=>l(async()=>{let r=y(a,!0,!0),d=await v(e),[o,m,x]=await Promise.all([d("balanceOf",[e]),d("maxWithdraw",[e]),d("maxRedeem",[e])]);if(o===0n)throw new p("This wallet has no Spark shares to withdraw.");let u,w,g;if(r==="max"){if(w=o,w>x)throw new p("The full share balance exceeds Spark\u2019s current maximum redeem. Request an asset amount within the current maximum withdrawal.");u=await d("previewRedeem",[w]),g=A({abi:k,functionName:"redeem",args:[w,e,e]})}else{if(u=r,u>m)throw new p("The withdrawal exceeds Spark\u2019s current maximum withdrawal.");if(w=await d("previewWithdraw",[u]),w>o)throw new p("This wallet has insufficient Spark shares for the withdrawal.");g=A({abi:k,functionName:"withdraw",args:[u,e,e]})}if(u===0n||w===0n)throw new p("Spark returned a zero asset or share preview for this withdrawal.");let W=r==="max"?`Redeem all ${s(t(c,w))} from Spark to this wallet.`:`Withdraw ${s(t(n,u))} from Spark to this wallet.`,U=[i.unsignedTx({to:f,data:g,value:"0",chainId:h,description:W})];return S(U,e,{assets:t(n,u),shares:t(c,w),maxWithdraw:t(n,m),maxRedeem:t(c,x)},r==="max"?`Redeem all ${s(t(c,w))} for an expected ${s(t(n,u))}, rounded down. Current maximum redeem ${s(t(c,x))}.`:`Withdraw ${s(t(n,u))} using an expected ${s(t(c,w))}, rounded up. Current maximum withdrawal ${s(t(n,m))}.`)})}]}};function q(i){return P("spark",[G(i)])}export{q as createModule,G as createModulePart};
@@ -1 +1 @@
1
- import{b as $}from"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import{a as b}from"../../../chunks/VZWOWR6G.js";import{a as r,d as T,i as D,j as p}from"../../../chunks/25EOXUBI.js";import{a as C}from"../../../chunks/B5RZYFQC.js";import{a as i}from"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";import{encodeFunctionData as S,erc20Abi as v,parseAbi as I}from"viem";var o=D[r].vaults.steakhouse.address,N=1000000000000n,G=(1n<<256n)-1n,h=I(["function asset() view returns (address)","function totalAssets() view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256 assets)","function previewWithdraw(uint256 assets) view returns (uint256 shares)","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)"]);function g(e){if(typeof e!="bigint"||e<0n||e>G)throw new i("The vault returned an invalid base-unit amount.");return e}function U(e){if(typeof e!="string")throw new i("Amount must be an integer string in base units.");let c=C(e);if(c===0n)throw new i("Amount must be positive.");if(c>G)throw new i("Amount exceeds the uint256 range.");return c}function y(e,c){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(l=>!c||l!=="amount"))throw new i("Unexpected Steakhouse argument.")}var x=e=>{async function c(s){try{return await s()}catch(t){throw new i(e.plainError(t))}}async function l(){let s=e.clientFor(r);if(await s.getChainId()!==r)throw new i("Steakhouse requires chain 4663.");let t=await s.readContract({address:o,abi:h,functionName:"asset"});if(typeof t!="string"||t.toLowerCase()!==p.toLowerCase())throw new i("The Steakhouse vault asset does not match USDG on chain 4663.");let[a,n]=await Promise.all([s.readContract({address:p,abi:v,functionName:"decimals"}),s.readContract({address:o,abi:v,functionName:"decimals"})]);if(a!==T||!Number.isInteger(n)||n<0||n>255)throw new i("The vault returned invalid asset or share decimals.");return{client:s,asset:{address:p,symbol:"USDG",decimals:a,chainId:r},shares:{address:o,symbol:"steakUSDG",decimals:n,chainId:r}}}async function A(s,t){return g(await s.readContract({address:o,abi:v,functionName:"balanceOf",args:[t]}))}async function k(s,t,a){let n=await e.preview(s,t);if(n.changes.length===0)throw new i("The Steakhouse simulation returned no token balance changes.");let u=n.changes.map(({token:d,amount:m})=>{let f=m.startsWith("-"),w=e.formatAmount(f?m.slice(1):m,d.decimals);return`${f?"-":""}${w} ${d.symbol} (${d.address}, chain ${d.chainId}, decimals ${d.decimals})`});return{txs:s,summary:`${a} ${n.summary} Changes: ${u.join("; ")}.`}}return{tools:[{name:"steakhouse_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async s=>c(async()=>{y(s,!1);let{client:t,asset:a,shares:n}=await l(),u=g(await t.readContract({address:o,abi:h,functionName:"totalAssets"}));return u<N?[]:[{name:"Steakhouse USDG",vault:n,asset:a,totalAssets:{token:a,amount:u.toString()}}]})},{name:"steakhouse_deposit",inputSchema:P(!1),execute:async(s,t)=>c(async()=>{y(s,!0);let a=U(s.amount);b(t);let{asset:n}=await l(),u=[e.approval(n.address,o,a.toString(),r),e.unsignedTx({to:o,data:S({abi:h,functionName:"deposit",args:[a,t]}),value:"0",chainId:r,description:`Deposit ${e.formatAmount(a.toString(),n.decimals)} USDG into Steakhouse.`})];return k(u,t,"Approve the exact USDG amount, then deposit into Steakhouse.")})},{name:"steakhouse_withdraw",inputSchema:P(!0),execute:async(s,t)=>c(async()=>{y(s,!0);let a=s.amount==="max"?null:U(s.amount);b(t);let{client:n,asset:u,shares:d}=await l(),m=await A(n,t);if(m===0n)throw new i("The wallet has no Steakhouse shares to withdraw.");let f;if(a===null)f=e.unsignedTx({to:o,data:S({abi:h,functionName:"redeem",args:[m,t,t]}),value:"0",chainId:r,description:`Redeem all ${e.formatAmount(m.toString(),d.decimals)} steakUSDG shares.`});else{let w=g(await n.readContract({address:o,abi:h,functionName:"previewWithdraw",args:[a]}));if(w===0n||w>m)throw new i("The withdrawal exceeds the available share balance or has an invalid share quote.");f=e.unsignedTx({to:o,data:S({abi:h,functionName:"withdraw",args:[a,t,t]}),value:"0",chainId:r,description:`Withdraw ${e.formatAmount(a.toString(),u.decimals)} USDG from Steakhouse.`})}return k([f],t,a===null?"Redeem the current full share balance from Steakhouse.":"Withdraw the requested USDG amount from Steakhouse.")})}],positions:s=>c(async()=>{b(s);let{client:t,asset:a,shares:n}=await l(),u=await A(t,s);if(u===0n)return[];let d=g(await t.readContract({address:o,abi:h,functionName:"convertToAssets",args:[u]}));return[{module:"steakhouse",id:`${r}:${o.toLowerCase()}`,chainId:r,assets:[{token:a,amount:d.toString()}],description:`${e.formatAmount(u.toString(),n.decimals)} steakUSDG shares (${o}, chain ${r}, decimals ${n.decimals}); USDG conversion is indicative, not guaranteed exit liquidity.`}]})}};function P(e){return{type:"object",additionalProperties:!1,required:["amount"],properties:{amount:{type:"string",pattern:e?"^(?:[0-9]+|max)$":"^[0-9]+$",description:`USDG base-unit integer string (6 decimals)${e?", or max to redeem every share":""}.`}}}}var L=e=>$("steakhouse",[x(e)]);export{L as createModule,x as createModulePart};
1
+ import{b as $}from"../../../chunks/UB5U6SI2.js";import"../../../chunks/Z25UKUJF.js";import{a as b}from"../../../chunks/VBWJOG3N.js";import{a as r,d as T,i as D,j as p}from"../../../chunks/5BP72XOA.js";import{a as C}from"../../../chunks/7I6TXFXR.js";import{a as i}from"../../../chunks/Z3FZWNAJ.js";import"../../../chunks/XN4WDN3O.js";import{encodeFunctionData as S,erc20Abi as v,parseAbi as I}from"viem";var o=D[r].vaults.steakhouse.address,N=1000000000000n,G=(1n<<256n)-1n,h=I(["function asset() view returns (address)","function totalAssets() view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256 assets)","function previewWithdraw(uint256 assets) view returns (uint256 shares)","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)"]);function g(e){if(typeof e!="bigint"||e<0n||e>G)throw new i("The vault returned an invalid base-unit amount.");return e}function U(e){if(typeof e!="string")throw new i("Amount must be an integer string in base units.");let c=C(e);if(c===0n)throw new i("Amount must be positive.");if(c>G)throw new i("Amount exceeds the uint256 range.");return c}function y(e,c){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(l=>!c||l!=="amount"))throw new i("Unexpected Steakhouse argument.")}var x=e=>{async function c(s){try{return await s()}catch(t){throw new i(e.plainError(t))}}async function l(){let s=e.clientFor(r);if(await s.getChainId()!==r)throw new i("Steakhouse requires chain 4663.");let t=await s.readContract({address:o,abi:h,functionName:"asset"});if(typeof t!="string"||t.toLowerCase()!==p.toLowerCase())throw new i("The Steakhouse vault asset does not match USDG on chain 4663.");let[a,n]=await Promise.all([s.readContract({address:p,abi:v,functionName:"decimals"}),s.readContract({address:o,abi:v,functionName:"decimals"})]);if(a!==T||!Number.isInteger(n)||n<0||n>255)throw new i("The vault returned invalid asset or share decimals.");return{client:s,asset:{address:p,symbol:"USDG",decimals:a,chainId:r},shares:{address:o,symbol:"steakUSDG",decimals:n,chainId:r}}}async function A(s,t){return g(await s.readContract({address:o,abi:v,functionName:"balanceOf",args:[t]}))}async function k(s,t,a){let n=await e.preview(s,t);if(n.changes.length===0)throw new i("The Steakhouse simulation returned no token balance changes.");let u=n.changes.map(({token:d,amount:m})=>{let f=m.startsWith("-"),w=e.formatAmount(f?m.slice(1):m,d.decimals);return`${f?"-":""}${w} ${d.symbol} (${d.address}, chain ${d.chainId}, decimals ${d.decimals})`});return{txs:s,summary:`${a} ${n.summary} Changes: ${u.join("; ")}.`}}return{tools:[{name:"steakhouse_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async s=>c(async()=>{y(s,!1);let{client:t,asset:a,shares:n}=await l(),u=g(await t.readContract({address:o,abi:h,functionName:"totalAssets"}));return u<N?[]:[{name:"Steakhouse USDG",vault:n,asset:a,totalAssets:{token:a,amount:u.toString()}}]})},{name:"steakhouse_deposit",inputSchema:P(!1),execute:async(s,t)=>c(async()=>{y(s,!0);let a=U(s.amount);b(t);let{asset:n}=await l(),u=[e.approval(n.address,o,a.toString(),r),e.unsignedTx({to:o,data:S({abi:h,functionName:"deposit",args:[a,t]}),value:"0",chainId:r,description:`Deposit ${e.formatAmount(a.toString(),n.decimals)} USDG into Steakhouse.`})];return k(u,t,"Approve the exact USDG amount, then deposit into Steakhouse.")})},{name:"steakhouse_withdraw",inputSchema:P(!0),execute:async(s,t)=>c(async()=>{y(s,!0);let a=s.amount==="max"?null:U(s.amount);b(t);let{client:n,asset:u,shares:d}=await l(),m=await A(n,t);if(m===0n)throw new i("The wallet has no Steakhouse shares to withdraw.");let f;if(a===null)f=e.unsignedTx({to:o,data:S({abi:h,functionName:"redeem",args:[m,t,t]}),value:"0",chainId:r,description:`Redeem all ${e.formatAmount(m.toString(),d.decimals)} steakUSDG shares.`});else{let w=g(await n.readContract({address:o,abi:h,functionName:"previewWithdraw",args:[a]}));if(w===0n||w>m)throw new i("The withdrawal exceeds the available share balance or has an invalid share quote.");f=e.unsignedTx({to:o,data:S({abi:h,functionName:"withdraw",args:[a,t,t]}),value:"0",chainId:r,description:`Withdraw ${e.formatAmount(a.toString(),u.decimals)} USDG from Steakhouse.`})}return k([f],t,a===null?"Redeem the current full share balance from Steakhouse.":"Withdraw the requested USDG amount from Steakhouse.")})}],positions:s=>c(async()=>{b(s);let{client:t,asset:a,shares:n}=await l(),u=await A(t,s);if(u===0n)return[];let d=g(await t.readContract({address:o,abi:h,functionName:"convertToAssets",args:[u]}));return[{module:"steakhouse",id:`${r}:${o.toLowerCase()}`,chainId:r,assets:[{token:a,amount:d.toString()}],description:`${e.formatAmount(u.toString(),n.decimals)} steakUSDG shares (${o}, chain ${r}, decimals ${n.decimals}); USDG conversion is indicative, not guaranteed exit liquidity.`}]})}};function P(e){return{type:"object",additionalProperties:!1,required:["amount"],properties:{amount:{type:"string",pattern:e?"^(?:[0-9]+|max)$":"^[0-9]+$",description:`USDG base-unit integer string (6 decimals)${e?", or max to redeem every share":""}.`}}}}var L=e=>$("steakhouse",[x(e)]);export{L as createModule,x as createModulePart};
@@ -1 +1 @@
1
- import{i as oe}from"../../../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{o as M}from"../../../chunks/VBV366XQ.js";import"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/P7Q6MJZH.js";import{c as re}from"../../../chunks/ZUAXW2ZD.js";import"../../../chunks/64EN6Y7E.js";import{b as ie}from"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import{a as _}from"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import{a as w,d as P,i as V}from"../../../chunks/25EOXUBI.js";import{a as te,b as E}from"../../../chunks/B5RZYFQC.js";import{a as m}from"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";import{decodeFunctionData as ye,encodeFunctionData as j,erc20Abi as be,getAddress as Ae,parseAbi as Ie}from"viem";var Be="https://api.tickerspring.com",C=V[w].tickerSpring.limitOrderHook.address,S={address:Ae(V[w].tokens.USDG.address),symbol:"USDG",decimals:P,chainId:w},se=10000000n,ae="(bytes32 pool,int24 lower,bool sell0,address inputToken,uint128 maximumInput,uint128 maximumCorrectionInput,uint256 minimumFullOutput,uint16 maximumFeeBps,uint64 deadline)",U=Ie([`function create(${ae} params)`,`function createMarketOrder(${ae} params,address token,uint160 initialPrice,uint160 minimumPrice,uint160 maximumPrice)`,"function cancel(uint256 id,uint256 min0,uint256 min1,uint64 deadline,uint8 deliveryMask)","function claimBoth(uint256 id)"]),F={type:"string",pattern:"^\\d+$"},Te={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"};function k(e){return(!e||typeof e!="object"||Array.isArray(e))&&c(),e}function c(){throw new m("TickerSpring returned an incomplete or inconsistent response.")}function b(e){return(typeof e!="string"||!e.trim())&&c(),e}function R(e){if(typeof e!="string")throw new m("Provide a valid token or wallet address.");return _(e),e}function f(e,n){return typeof e=="string"&&e.toLowerCase()===n.toLowerCase()}function A(e){if(typeof e!="string")throw new m("Amount must be a non-negative integer string in base units.");return te(e),e}function O(e){let n=A(e);if(BigInt(n)<=0n)throw new m("The amount must be positive.");return n}function de(e){let n=typeof e=="number"&&Number.isFinite(e)?String(e):e;if(typeof n!="string"||!/^\d+(\.\d+)?$/.test(n)||!/[1-9]/.test(n))throw new m("TickerSpring requires a positive decimal price in USDG per token.");return n}function me(e){let n=k(e);return(typeof n.decimals!="number"||!Number.isInteger(n.decimals)||n.decimals<0||n.decimals>255||n.chainId!==void 0&&n.chainId!==w)&&c(),{address:R(n.address),symbol:b(n.symbol),decimals:n.decimals,chainId:w}}function Q(e){let n=O(e);if(BigInt(n)<=BigInt(Math.floor(Date.now()/1e3)))throw new m("The prepared TickerSpring order has expired. Prepare it again.");return n}function J(e,n){if(Object.keys(e).some(i=>!n.includes(i)))throw new m("Provide only the documented TickerSpring inputs.")}async function N(e,n,i){let r=await re(e.http,`${Be}${n}`,{method:i?"POST":"GET",headers:{"Content-Type":"application/json","User-Agent":"Oak-TickerSpring/1.0"},...i?{body:JSON.stringify(i)}:{}},t=>!!t&&typeof t=="object"&&!Array.isArray(t));return k(r.data)}function le(e,n,i,r){let t=k(n.bundle),o=k(n.walletSendCalls);(t.kind!==r||t.chainId!==w||!f(t.owner,i)||o.chainId!=="0x1237"||!f(o.from,i)||!Array.isArray(t.steps)||!t.steps.length||!Array.isArray(o.calls)||o.calls.length!==t.steps.length)&&c();let u=b(t.expiresAt);if(!Number.isFinite(Date.parse(u))||Date.parse(u)<=Date.now())throw new m("The prepared TickerSpring bundle has expired. Prepare it again.");let s=t.steps.map((h,l)=>{let a=k(h),d=k(o.calls[l]);return(a.n!==l+1||a.kind!=="approve"&&a.kind!=="call"||a.from!==void 0&&!f(a.from,i)||a.chainId!==void 0&&a.chainId!==w||!f(d.to,b(a.to))||d.data!==a.data||a.value!=="0"||d.value!=="0x0")&&c(),e.unsignedTx({to:R(a.to),data:b(a.data),value:A(a.value),chainId:w,description:b(a.label)})});return{bundle:t,txs:s,expiresAt:u}}async function H(e,n,i,r={}){let{bundle:t,txs:o,expiresAt:u}=n,s=await e.preview(o,i);if(Date.parse(u)<=Date.now())throw new m("The prepared TickerSpring bundle expired during preview. Prepare it again.");r.deadline!==void 0&&Q(r.deadline);let h=s.changes.map(({token:d,amount:I})=>{let y=I.startsWith("-");return`${y?"-":""}${e.formatAmount(y?I.slice(1):I,d.decimals)} ${d.symbol} (${d.address}, chain ${d.chainId})`});(!Array.isArray(t.warnings)||!t.warnings.every(d=>typeof d=="string"))&&c();let l=t.simulation===void 0?void 0:k(t.simulation),a=l?.ok===!1?`API simulation: ${b(l.error)}.`:"";return{txs:o,from:i,expiresAt:u,...r,preview:s,summary:[b(t.summary),"Protocol minimum: 10 USDG. Fill fee: 2.5% of received tokens; no placement or unfilled cancellation fee.","Filled proceeds require tickerspring_claim (claimBoth). No transaction has been sent.",...t.warnings,a,s.summary,...h].filter(Boolean).join(" ")}}async function Se(e,n,i){J(n,["token","side","amount","price","slippageBps","minAmountOut"]);let r=R(n.token),t=O(n.amount),o=de(b(n.price)),u=n.slippageBps===void 0?500:n.slippageBps;M("1",u);let s=n.minAmountOut===void 0?0n:BigInt(O(n.minAmountOut));if(n.minAmountOut!==void 0&&s<=1n)throw new m("The minimum output amount must be greater than 1 base unit.");if(n.side!=="buy"&&n.side!=="sell")throw new m("Choose buy or sell for the limit order.");if(n.side==="buy"&&BigInt(t)<se)throw new m("TickerSpring orders require at least 10 USDG.");let h=await N(e,"/v1/tokens");Array.isArray(h.tokens)||c();let l=h.tokens.map(k).filter(g=>f(g.address,r)&&(g.chainId===void 0||g.chainId===w));if(l.length!==1)throw new m("TickerSpring did not return a unique token for that address on chain 4663.");let a=l[0],d=me(a);if(f(d.address,S.address))throw new m("Choose the order token paired with USDG.");let I=k(a.markets);typeof I.limitOrders!="boolean"&&c();let y=n.side==="buy"?S:d,D=n.side==="buy"?d:S;if(n.side==="sell"){let g=BigInt(E(o,18,"floor"));if(BigInt(t)*g*10n**BigInt(P)/(10n**BigInt(d.decimals)*10n**18n)<se)throw new m("TickerSpring orders require at least 10 USDG at the limit price.")}let pe=await N(e,"/v1/agent/prepare/limit-order",{owner:i,token:r,side:n.side,price:o,amount:e.formatAmount(t,y.decimals),...I.limitOrders?{}:{startingPrice:de(a.priceUsd)}}),x=le(e,pe,i,"limit-order"),T=k(x.bundle.params),p=k(T.create),W=Q(p.deadline),$=O(p.minimumFullOutput);(!f(T.hook,C)||!f(p.inputToken,y.address)||A(p.maximumInput)!==t||p.maximumFeeBps!==250||typeof p.sell0!="boolean"||typeof p.lower!="number"||!Number.isInteger(p.lower)||typeof p.pool!="string"||!/^0x[0-9a-fA-F]{64}$/.test(p.pool)||BigInt(A(p.maximumCorrectionInput))>BigInt(t))&&c();let fe=BigInt(y.address)<BigInt(D.address);p.sell0!==fe&&c();let v=BigInt(t)*9750n/10000n,q=BigInt(E(o,18,"floor")),ge=n.side==="buy"?q>0n?v*10n**BigInt(d.decimals)*10n**18n/(10n**BigInt(P)*q):0n:v*q*10n**BigInt(P)/(10n**BigInt(d.decimals)*10n**18n),z=BigInt(M(ge.toString(),u)),K=oe(p.lower),G=K*K,X=1n<<192n,ke=G>0n?p.sell0?v*G/X:v*X/G:0n,he=d.decimals===18?BigInt(M(ke.toString(),u)):z,we=[s,z,he].reduce((g,B)=>g>B?g:B,0n);if(BigInt($)<=1n||BigInt($)<we)throw new m("TickerSpring minimum output is below the quoted slippage minimum.");let Y={pool:p.pool,lower:p.lower,sell0:p.sell0,inputToken:y.address,maximumInput:BigInt(t),maximumCorrectionInput:BigInt(A(p.maximumCorrectionInput)),minimumFullOutput:BigInt($),maximumFeeBps:250,deadline:BigInt(W)},L;if(I.limitOrders)L=j({abi:U,functionName:"create",args:[Y]});else{let g=k(T.market);f(g.token,d.address)||c();let B=BigInt(O(g.initialPrice)),ee=BigInt(O(g.minimumPrice)),ne=BigInt(O(g.maximumPrice));(B<ee||B>ne)&&c(),L=j({abi:U,functionName:"createMarketOrder",args:[Y,d.address,B,ee,ne]})}if((!Array.isArray(T.approvals)||T.approvals.length>1||x.txs.length!==T.approvals.length+1)&&c(),T.approvals.length){let g=k(T.approvals[0]),B=j({abi:be,functionName:"approve",args:[C,BigInt(t)]});(!f(g.token,y.address)||!f(g.spender,C)||A(g.amount)!==t||!f(x.txs[0].to,y.address)||x.txs[0].data.toLowerCase()!==B.toLowerCase())&&c()}let Z=x.txs.at(-1);return(!f(Z.to,C)||Z.data.toLowerCase()!==L.toLowerCase())&&c(),H(e,x,i,{input:{token:y,amount:t},minimumOutput:{token:D,amount:$},deadline:W})}async function ue(e,n,i,r){J(n,["id"]);let t=A(n.id),o=await N(e,"/v1/agent/prepare/order-action",{owner:i,id:t,action:r}),u=le(e,o,i,"order-action");(u.txs.length!==1||!f(u.txs[0].to,C))&&c();let s=ye({abi:U,data:u.txs[0].data});if((s.functionName!==r||s.args[0]!==BigInt(t))&&c(),s.functionName==="cancel"){let[,h,l,a,d]=s.args;if(Q(a.toString()),h+l===0n||d!==3)throw new m("TickerSpring returned a cancellation without protected amounts or both token deliveries. Prepare it again.");return H(e,u,i,{id:t,deadline:a.toString()})}return u.txs[0].data.toLowerCase()!==j({abi:U,functionName:"claimBoth",args:[BigInt(t)]}).toLowerCase()&&c(),H(e,u,i,{id:t})}async function ce(e,n){let i=await N(e,`/v1/agent/accounts/${n}`);if(!f(i.owner,n)||i.limitOrdersComplete!==!0||!Array.isArray(i.limitOrders)||!Array.isArray(i.unavailable)||i.unavailable.length)throw new m("TickerSpring could not return the complete order list for this wallet.");let r=b(i.asOf);Number.isFinite(Date.parse(r))||c();let t=new Set,o=i.limitOrders.map(u=>{let s=k(u),h=k(s.order),l=me(s.token);(!f(s.hook,C)||!f(h.owner,n)||s.side!=="buy"&&s.side!=="sell"||f(l.address,S.address)||s.feeBps!==250)&&c();let a=A(s.id);t.has(a)&&c(),t.add(a);let d=BigInt(l.address)<BigInt(S.address)?[l,S]:[S,l],I=k(s.claimable);return{id:a,status:b(s.status),side:s.side,chainId:w,feeBps:250,input:{token:s.side==="buy"?S:l,amount:A(h.debit)},claimable:d.map((y,D)=>({token:y,amount:A(I[D===0?"net0":"net1"])}))}});return{owner:n,chainId:w,asOf:r,orders:o}}var Oe=e=>{let n=r=>async t=>{try{return _(t),await r(t)}catch(o){throw new m(e.plainError(o))}},i=(r,t,o,u)=>({name:`tickerspring_${r}`,inputSchema:{type:"object",properties:t,required:o,additionalProperties:!1},execute:(s,h)=>n(l=>u(s,l))(h)});return{tools:[i("create",{token:Te,side:{type:"string",enum:["buy","sell"]},amount:{...F,description:"Base units of USDG for buys, or the selected token for sells."},price:{type:"string",pattern:"^\\d+(\\.\\d+)?$",description:"Limit price in USDG per whole token."},slippageBps:{type:"integer",minimum:0,maximum:9999},minAmountOut:{...F,description:"Optional caller minimum output in base units."}},["token","side","amount","price"],(r,t)=>Se(e,r,t)),i("cancel",{id:F},["id"],(r,t)=>ue(e,r,t,"cancel")),i("claim",{id:F},["id"],(r,t)=>ue(e,r,t,"claimBoth")),i("orders",{},[],(r,t)=>(J(r,[]),ce(e,t)))],positions:n(async r=>(await ce(e,r)).orders.map(o=>({module:"tickerspring",id:o.id,chainId:w,assets:o.claimable,description:`${o.side} order ${o.id}: ${o.status}; assets are claimable amounts only. Original input: ${e.formatAmount(o.input.amount,o.input.token.decimals)} ${o.input.token.symbol} (${o.input.token.address}). Fill fee 2.5%; use tickerspring_claim for proceeds.`})))}},Ue=e=>ie("tickerspring",[Oe(e)]);export{Ue as createModule,Oe as createModulePart};
1
+ import{i as oe}from"../../../chunks/RYOVSHKO.js";import"../../../chunks/XKZOMGC3.js";import"../../../chunks/PQHU5A3U.js";import"../../../chunks/F3TOOLFQ.js";import"../../../chunks/SXBGOGYQ.js";import"../../../chunks/UIJWIFGV.js";import"../../../chunks/B2LA6VVF.js";import"../../../chunks/NNJLMS7F.js";import{o as M}from"../../../chunks/XEN45QST.js";import"../../../chunks/Z53DADZ4.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/MEZH7RPA.js";import{c as re}from"../../../chunks/TU3KHOZK.js";import"../../../chunks/74X7PXPR.js";import{b as ie}from"../../../chunks/UB5U6SI2.js";import"../../../chunks/Z25UKUJF.js";import{a as _}from"../../../chunks/VBWJOG3N.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/R5CBH2CR.js";import{a as w,d as P,i as V}from"../../../chunks/5BP72XOA.js";import"../../../chunks/XAB4OIE3.js";import{a as te,b as E}from"../../../chunks/7I6TXFXR.js";import{a as m}from"../../../chunks/Z3FZWNAJ.js";import"../../../chunks/XN4WDN3O.js";import{decodeFunctionData as ye,encodeFunctionData as j,erc20Abi as be,getAddress as Ae,parseAbi as Ie}from"viem";var Be="https://api.tickerspring.com",C=V[w].tickerSpring.limitOrderHook.address,S={address:Ae(V[w].tokens.USDG.address),symbol:"USDG",decimals:P,chainId:w},se=10000000n,ae="(bytes32 pool,int24 lower,bool sell0,address inputToken,uint128 maximumInput,uint128 maximumCorrectionInput,uint256 minimumFullOutput,uint16 maximumFeeBps,uint64 deadline)",U=Ie([`function create(${ae} params)`,`function createMarketOrder(${ae} params,address token,uint160 initialPrice,uint160 minimumPrice,uint160 maximumPrice)`,"function cancel(uint256 id,uint256 min0,uint256 min1,uint64 deadline,uint8 deliveryMask)","function claimBoth(uint256 id)"]),F={type:"string",pattern:"^\\d+$"},Te={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"};function k(e){return(!e||typeof e!="object"||Array.isArray(e))&&c(),e}function c(){throw new m("TickerSpring returned an incomplete or inconsistent response.")}function b(e){return(typeof e!="string"||!e.trim())&&c(),e}function R(e){if(typeof e!="string")throw new m("Provide a valid token or wallet address.");return _(e),e}function f(e,n){return typeof e=="string"&&e.toLowerCase()===n.toLowerCase()}function A(e){if(typeof e!="string")throw new m("Amount must be a non-negative integer string in base units.");return te(e),e}function O(e){let n=A(e);if(BigInt(n)<=0n)throw new m("The amount must be positive.");return n}function de(e){let n=typeof e=="number"&&Number.isFinite(e)?String(e):e;if(typeof n!="string"||!/^\d+(\.\d+)?$/.test(n)||!/[1-9]/.test(n))throw new m("TickerSpring requires a positive decimal price in USDG per token.");return n}function me(e){let n=k(e);return(typeof n.decimals!="number"||!Number.isInteger(n.decimals)||n.decimals<0||n.decimals>255||n.chainId!==void 0&&n.chainId!==w)&&c(),{address:R(n.address),symbol:b(n.symbol),decimals:n.decimals,chainId:w}}function Q(e){let n=O(e);if(BigInt(n)<=BigInt(Math.floor(Date.now()/1e3)))throw new m("The prepared TickerSpring order has expired. Prepare it again.");return n}function J(e,n){if(Object.keys(e).some(i=>!n.includes(i)))throw new m("Provide only the documented TickerSpring inputs.")}async function N(e,n,i){let r=await re(e.http,`${Be}${n}`,{method:i?"POST":"GET",headers:{"Content-Type":"application/json","User-Agent":"Oak-TickerSpring/1.0"},...i?{body:JSON.stringify(i)}:{}},t=>!!t&&typeof t=="object"&&!Array.isArray(t));return k(r.data)}function le(e,n,i,r){let t=k(n.bundle),o=k(n.walletSendCalls);(t.kind!==r||t.chainId!==w||!f(t.owner,i)||o.chainId!=="0x1237"||!f(o.from,i)||!Array.isArray(t.steps)||!t.steps.length||!Array.isArray(o.calls)||o.calls.length!==t.steps.length)&&c();let u=b(t.expiresAt);if(!Number.isFinite(Date.parse(u))||Date.parse(u)<=Date.now())throw new m("The prepared TickerSpring bundle has expired. Prepare it again.");let s=t.steps.map((h,l)=>{let a=k(h),d=k(o.calls[l]);return(a.n!==l+1||a.kind!=="approve"&&a.kind!=="call"||a.from!==void 0&&!f(a.from,i)||a.chainId!==void 0&&a.chainId!==w||!f(d.to,b(a.to))||d.data!==a.data||a.value!=="0"||d.value!=="0x0")&&c(),e.unsignedTx({to:R(a.to),data:b(a.data),value:A(a.value),chainId:w,description:b(a.label)})});return{bundle:t,txs:s,expiresAt:u}}async function H(e,n,i,r={}){let{bundle:t,txs:o,expiresAt:u}=n,s=await e.preview(o,i);if(Date.parse(u)<=Date.now())throw new m("The prepared TickerSpring bundle expired during preview. Prepare it again.");r.deadline!==void 0&&Q(r.deadline);let h=s.changes.map(({token:d,amount:I})=>{let y=I.startsWith("-");return`${y?"-":""}${e.formatAmount(y?I.slice(1):I,d.decimals)} ${d.symbol} (${d.address}, chain ${d.chainId})`});(!Array.isArray(t.warnings)||!t.warnings.every(d=>typeof d=="string"))&&c();let l=t.simulation===void 0?void 0:k(t.simulation),a=l?.ok===!1?`API simulation: ${b(l.error)}.`:"";return{txs:o,from:i,expiresAt:u,...r,preview:s,summary:[b(t.summary),"Protocol minimum: 10 USDG. Fill fee: 2.5% of received tokens; no placement or unfilled cancellation fee.","Filled proceeds require tickerspring_claim (claimBoth). No transaction has been sent.",...t.warnings,a,s.summary,...h].filter(Boolean).join(" ")}}async function Se(e,n,i){J(n,["token","side","amount","price","slippageBps","minAmountOut"]);let r=R(n.token),t=O(n.amount),o=de(b(n.price)),u=n.slippageBps===void 0?500:n.slippageBps;M("1",u);let s=n.minAmountOut===void 0?0n:BigInt(O(n.minAmountOut));if(n.minAmountOut!==void 0&&s<=1n)throw new m("The minimum output amount must be greater than 1 base unit.");if(n.side!=="buy"&&n.side!=="sell")throw new m("Choose buy or sell for the limit order.");if(n.side==="buy"&&BigInt(t)<se)throw new m("TickerSpring orders require at least 10 USDG.");let h=await N(e,"/v1/tokens");Array.isArray(h.tokens)||c();let l=h.tokens.map(k).filter(g=>f(g.address,r)&&(g.chainId===void 0||g.chainId===w));if(l.length!==1)throw new m("TickerSpring did not return a unique token for that address on chain 4663.");let a=l[0],d=me(a);if(f(d.address,S.address))throw new m("Choose the order token paired with USDG.");let I=k(a.markets);typeof I.limitOrders!="boolean"&&c();let y=n.side==="buy"?S:d,D=n.side==="buy"?d:S;if(n.side==="sell"){let g=BigInt(E(o,18,"floor"));if(BigInt(t)*g*10n**BigInt(P)/(10n**BigInt(d.decimals)*10n**18n)<se)throw new m("TickerSpring orders require at least 10 USDG at the limit price.")}let pe=await N(e,"/v1/agent/prepare/limit-order",{owner:i,token:r,side:n.side,price:o,amount:e.formatAmount(t,y.decimals),...I.limitOrders?{}:{startingPrice:de(a.priceUsd)}}),x=le(e,pe,i,"limit-order"),T=k(x.bundle.params),p=k(T.create),W=Q(p.deadline),$=O(p.minimumFullOutput);(!f(T.hook,C)||!f(p.inputToken,y.address)||A(p.maximumInput)!==t||p.maximumFeeBps!==250||typeof p.sell0!="boolean"||typeof p.lower!="number"||!Number.isInteger(p.lower)||typeof p.pool!="string"||!/^0x[0-9a-fA-F]{64}$/.test(p.pool)||BigInt(A(p.maximumCorrectionInput))>BigInt(t))&&c();let fe=BigInt(y.address)<BigInt(D.address);p.sell0!==fe&&c();let v=BigInt(t)*9750n/10000n,q=BigInt(E(o,18,"floor")),ge=n.side==="buy"?q>0n?v*10n**BigInt(d.decimals)*10n**18n/(10n**BigInt(P)*q):0n:v*q*10n**BigInt(P)/(10n**BigInt(d.decimals)*10n**18n),z=BigInt(M(ge.toString(),u)),K=oe(p.lower),G=K*K,X=1n<<192n,ke=G>0n?p.sell0?v*G/X:v*X/G:0n,he=d.decimals===18?BigInt(M(ke.toString(),u)):z,we=[s,z,he].reduce((g,B)=>g>B?g:B,0n);if(BigInt($)<=1n||BigInt($)<we)throw new m("TickerSpring minimum output is below the quoted slippage minimum.");let Y={pool:p.pool,lower:p.lower,sell0:p.sell0,inputToken:y.address,maximumInput:BigInt(t),maximumCorrectionInput:BigInt(A(p.maximumCorrectionInput)),minimumFullOutput:BigInt($),maximumFeeBps:250,deadline:BigInt(W)},L;if(I.limitOrders)L=j({abi:U,functionName:"create",args:[Y]});else{let g=k(T.market);f(g.token,d.address)||c();let B=BigInt(O(g.initialPrice)),ee=BigInt(O(g.minimumPrice)),ne=BigInt(O(g.maximumPrice));(B<ee||B>ne)&&c(),L=j({abi:U,functionName:"createMarketOrder",args:[Y,d.address,B,ee,ne]})}if((!Array.isArray(T.approvals)||T.approvals.length>1||x.txs.length!==T.approvals.length+1)&&c(),T.approvals.length){let g=k(T.approvals[0]),B=j({abi:be,functionName:"approve",args:[C,BigInt(t)]});(!f(g.token,y.address)||!f(g.spender,C)||A(g.amount)!==t||!f(x.txs[0].to,y.address)||x.txs[0].data.toLowerCase()!==B.toLowerCase())&&c()}let Z=x.txs.at(-1);return(!f(Z.to,C)||Z.data.toLowerCase()!==L.toLowerCase())&&c(),H(e,x,i,{input:{token:y,amount:t},minimumOutput:{token:D,amount:$},deadline:W})}async function ue(e,n,i,r){J(n,["id"]);let t=A(n.id),o=await N(e,"/v1/agent/prepare/order-action",{owner:i,id:t,action:r}),u=le(e,o,i,"order-action");(u.txs.length!==1||!f(u.txs[0].to,C))&&c();let s=ye({abi:U,data:u.txs[0].data});if((s.functionName!==r||s.args[0]!==BigInt(t))&&c(),s.functionName==="cancel"){let[,h,l,a,d]=s.args;if(Q(a.toString()),h+l===0n||d!==3)throw new m("TickerSpring returned a cancellation without protected amounts or both token deliveries. Prepare it again.");return H(e,u,i,{id:t,deadline:a.toString()})}return u.txs[0].data.toLowerCase()!==j({abi:U,functionName:"claimBoth",args:[BigInt(t)]}).toLowerCase()&&c(),H(e,u,i,{id:t})}async function ce(e,n){let i=await N(e,`/v1/agent/accounts/${n}`);if(!f(i.owner,n)||i.limitOrdersComplete!==!0||!Array.isArray(i.limitOrders)||!Array.isArray(i.unavailable)||i.unavailable.length)throw new m("TickerSpring could not return the complete order list for this wallet.");let r=b(i.asOf);Number.isFinite(Date.parse(r))||c();let t=new Set,o=i.limitOrders.map(u=>{let s=k(u),h=k(s.order),l=me(s.token);(!f(s.hook,C)||!f(h.owner,n)||s.side!=="buy"&&s.side!=="sell"||f(l.address,S.address)||s.feeBps!==250)&&c();let a=A(s.id);t.has(a)&&c(),t.add(a);let d=BigInt(l.address)<BigInt(S.address)?[l,S]:[S,l],I=k(s.claimable);return{id:a,status:b(s.status),side:s.side,chainId:w,feeBps:250,input:{token:s.side==="buy"?S:l,amount:A(h.debit)},claimable:d.map((y,D)=>({token:y,amount:A(I[D===0?"net0":"net1"])}))}});return{owner:n,chainId:w,asOf:r,orders:o}}var Oe=e=>{let n=r=>async t=>{try{return _(t),await r(t)}catch(o){throw new m(e.plainError(o))}},i=(r,t,o,u)=>({name:`tickerspring_${r}`,inputSchema:{type:"object",properties:t,required:o,additionalProperties:!1},execute:(s,h)=>n(l=>u(s,l))(h)});return{tools:[i("create",{token:Te,side:{type:"string",enum:["buy","sell"]},amount:{...F,description:"Base units of USDG for buys, or the selected token for sells."},price:{type:"string",pattern:"^\\d+(\\.\\d+)?$",description:"Limit price in USDG per whole token."},slippageBps:{type:"integer",minimum:0,maximum:9999},minAmountOut:{...F,description:"Optional caller minimum output in base units."}},["token","side","amount","price"],(r,t)=>Se(e,r,t)),i("cancel",{id:F},["id"],(r,t)=>ue(e,r,t,"cancel")),i("claim",{id:F},["id"],(r,t)=>ue(e,r,t,"claimBoth")),i("orders",{},[],(r,t)=>(J(r,[]),ce(e,t)))],positions:n(async r=>(await ce(e,r)).orders.map(o=>({module:"tickerspring",id:o.id,chainId:w,assets:o.claimable,description:`${o.side} order ${o.id}: ${o.status}; assets are claimable amounts only. Original input: ${e.formatAmount(o.input.amount,o.input.token.decimals)} ${o.input.token.symbol} (${o.input.token.address}). Fill fee 2.5%; use tickerspring_claim for proceeds.`})))}},Ue=e=>ie("tickerspring",[Oe(e)]);export{Ue as createModule,Oe as createModulePart};
@@ -1 +1 @@
1
- import{y as _}from"../../../chunks/CUBRTOMA.js";import{A as se,B as pe,C as ue,D as de,E as w,F as M,G as k,H as A,I as ae,J as ce,K as T,L as ve,a as V,b as I,c as U,d as O,e as L,f as H,g as $,h as F,i as q,j as B,k as K,l as z,m as G,n as J,o as Q,p as W,q as X,r as Y,s as Z,t as N,u as ee,v as ne,w as oe,x as ie,y as te,z as re}from"../../../chunks/ZERWRK6X.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 m}from"../../../chunks/SGDWO7XI.js";import"../../../chunks/Z25UKUJF.js";import{a as v}from"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import"../../../chunks/25EOXUBI.js";import"../../../chunks/B5RZYFQC.js";import{a as d}from"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";var E={uniswap_add:{token0:{type:"string",description:"Sorted token0 ERC-20 address (v3)."},token1:{type:"string",description:"Sorted token1 ERC-20 address (v3)."},fee:{type:"number",description:"Pool fee tier in hundredths of a bip."},tickLower:{type:"number"},tickUpper:{type:"number"},amount0Desired:{type:"string"},amount1Desired:{type:"string"},amount0Min:{type:"string"},amount1Min:{type:"string"},recipient:{type:"string"},deadline:{type:"string"}},uniswap_collect:{tokenId:{type:"string"},recipient:{type:"string"},amount0Max:{type:"string"},amount1Max:{type:"string"}},uniswap_remove:{tokenId:{type:"string"},liquidity:{type:"string"},amount0Min:{type:"string"},amount1Min:{type:"string"},deadline:{type:"string"},burn:{type:"boolean"}},uniswap_list_positions:{tokenIds:{type:"array",items:{type:"string"}}}};function g(n,e){if(n)return typeof n=="function"?n(e):n}function R(n,e,t){let o=e.properties&&typeof e.properties=="object"?e.properties:{},s=t?.tools.find(i=>i.name===n||i.name===n.replace("uniswap_","uniswap_v3_")),a=s?.inputSchema?.properties&&typeof s.inputSchema.properties=="object"?s.inputSchema.properties:{};return{type:"object",properties:{...E[n]??{},...a,...o,version:{type:"string",enum:["v3","v4"],description:'Uniswap protocol version ("v3" or "v4").'}}}}function j(n,e){if(e.version!==void 0){if(e.version==="v3"||e.version==="v4")return e.version;throw new d(`Unsupported Uniswap version "${String(e.version)}". Choose "v3" or "v4".`)}if(n==="uniswap_collect"||n==="uniswap_remove"||e.tokenId!==void 0)throw new d('Provide version "v3" or "v4" for a Uniswap position operation; token IDs overlap between managers.');return e.poolId!==void 0||e.poolKey!==void 0||e.hooks!==void 0||e.currency0!==void 0||e.currency1!==void 0||e.permit2Expiration!==void 0?"v4":e.amount0Desired!==void 0||e.amount1Desired!==void 0||n==="uniswap_collect"&&(e.amount0Max!==void 0||e.amount1Max!==void 0)||e.token0!==void 0&&e.token1!==void 0&&e.tickSpacing===void 0?"v3":"v4"}function f(n,e){let t=n.tools.find(o=>o.name===e||o.name===e.replace("uniswap_","uniswap_v3_")||o.name===e.replace("uniswap_","uniswap_v4_"));if(!t)throw new d(`Tool ${e} is not available on the selected Uniswap part.`);return t}function h(n,e){let t=g(e?.v4,n)??T(n),o=g(e?.v3,n)??_(n),s=(i,c)=>({name:i,inputSchema:R(i,c,o),async execute(p,u){if(v(u),i==="uniswap_list_positions"&&p.version===void 0){let C=f(t,"uniswap_list_positions"),[S,l]=await Promise.all([(async()=>{let y=o.tools.find(r=>r.name==="uniswap_list_positions"||r.name==="uniswap_v3_list_positions");if(y){let r=await y.execute({...p,version:"v3"},u);if(Array.isArray(r))return r;if(r&&typeof r=="object"&&Array.isArray(r.positions))return r.positions}return o.positions?o.positions(u):[]})(),C.execute({...p,version:"v4"},u)]),x=Array.isArray(l?.positions)?l.positions:[],P=[...S,...x];return{positions:P,summary:`Found ${P.length} active Uniswap position(s) across v3 and v4 for ${u}.`}}return j(i,p)==="v3"?f(o,i).execute(p,u):f(t,i).execute({...p,version:"v4"},u)}}),a=[s("uniswap_add",w),s("uniswap_collect",M),s("uniswap_remove",k),s("uniswap_list_positions",A)];return m("uniswap",[{tools:a,positions:async i=>{v(i);let[c,p]=await Promise.all([o.positions?o.positions(i):Promise.resolve([]),t.positions?t.positions(i):Promise.resolve([])]);return[...c,...p]}}])}var _e=h;export{z as DEEPEST_V4_POOL_ID,K as MAX_TICK,J as MEASURED_V4_POOLS,B as MIN_TICK,O as PERMIT2_ADDRESS,$ as USDG_ADDRESS,G as V4_ACTIONS,w as V4_ADD_SCHEMA,M as V4_COLLECT_SCHEMA,q as V4_DYNAMIC_FEE_FLAG,A as V4_LIST_POSITIONS_SCHEMA,V as V4_POOL_MANAGER,I as V4_POSITION_MANAGER,k as V4_REMOVE_SCHEMA,U as V4_STATE_VIEW,L as V4_UNIVERSAL_ROUTER,H as WETH_ADDRESS,F as ZERO_ADDRESS,re as amountsForLiquidity,W as computePoolId,h as createModule,T as createModulePart,ce as createPart,_e as createUniswapModule,ve as createUniswapV4Part,ae as createV4Part,te as decodePackedPositionInfo,Y as describeV4FeeBehavior,ie as encodePackedPositionInfo,ne as encodePermit2Approve,oe as encodeV4UniversalRouterFeeSwap,pe as formatSignedPreviewChanges,N as fullRangeTicks,X as isDynamicFeePool,Q as isNativeV4Currency,se as liquidityForAmounts,de as readV4Positions,ue as tokenForCurrency,ee as validateTickRange,Z as validateV4PoolKey};
1
+ import{y as _}from"../../../chunks/ZJUNO5N7.js";import{A as se,B as pe,C as ue,D as de,E as w,F as M,G as k,H as A,I as ae,J as ce,K as T,L as ve,a as V,b as I,c as U,d as O,e as L,f as H,g as $,h as F,i as q,j as B,k as K,l as z,m as G,n as J,o as Q,p as W,q as X,r as Y,s as Z,t as N,u as ee,v as ne,w as oe,x as ie,y as te,z as re}from"../../../chunks/CWQ5WXZQ.js";import"../../../chunks/RYOVSHKO.js";import"../../../chunks/XKZOMGC3.js";import"../../../chunks/PQHU5A3U.js";import"../../../chunks/F3TOOLFQ.js";import"../../../chunks/SXBGOGYQ.js";import"../../../chunks/UIJWIFGV.js";import"../../../chunks/B2LA6VVF.js";import"../../../chunks/NNJLMS7F.js";import"../../../chunks/XEN45QST.js";import"../../../chunks/Z53DADZ4.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/MEZH7RPA.js";import"../../../chunks/TU3KHOZK.js";import"../../../chunks/74X7PXPR.js";import{b as m}from"../../../chunks/UB5U6SI2.js";import"../../../chunks/Z25UKUJF.js";import{a as v}from"../../../chunks/VBWJOG3N.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/R5CBH2CR.js";import"../../../chunks/5BP72XOA.js";import"../../../chunks/XAB4OIE3.js";import"../../../chunks/7I6TXFXR.js";import{a as d}from"../../../chunks/Z3FZWNAJ.js";import"../../../chunks/XN4WDN3O.js";var E={uniswap_add:{token0:{type:"string",description:"Sorted token0 ERC-20 address (v3)."},token1:{type:"string",description:"Sorted token1 ERC-20 address (v3)."},fee:{type:"number",description:"Pool fee tier in hundredths of a bip."},tickLower:{type:"number"},tickUpper:{type:"number"},amount0Desired:{type:"string"},amount1Desired:{type:"string"},amount0Min:{type:"string"},amount1Min:{type:"string"},recipient:{type:"string"},deadline:{type:"string"}},uniswap_collect:{tokenId:{type:"string"},recipient:{type:"string"},amount0Max:{type:"string"},amount1Max:{type:"string"}},uniswap_remove:{tokenId:{type:"string"},liquidity:{type:"string"},amount0Min:{type:"string"},amount1Min:{type:"string"},deadline:{type:"string"},burn:{type:"boolean"}},uniswap_list_positions:{tokenIds:{type:"array",items:{type:"string"}}}};function g(n,e){if(n)return typeof n=="function"?n(e):n}function R(n,e,t){let o=e.properties&&typeof e.properties=="object"?e.properties:{},s=t?.tools.find(i=>i.name===n||i.name===n.replace("uniswap_","uniswap_v3_")),a=s?.inputSchema?.properties&&typeof s.inputSchema.properties=="object"?s.inputSchema.properties:{};return{type:"object",properties:{...E[n]??{},...a,...o,version:{type:"string",enum:["v3","v4"],description:'Uniswap protocol version ("v3" or "v4").'}}}}function j(n,e){if(e.version!==void 0){if(e.version==="v3"||e.version==="v4")return e.version;throw new d(`Unsupported Uniswap version "${String(e.version)}". Choose "v3" or "v4".`)}if(n==="uniswap_collect"||n==="uniswap_remove"||e.tokenId!==void 0)throw new d('Provide version "v3" or "v4" for a Uniswap position operation; token IDs overlap between managers.');return e.poolId!==void 0||e.poolKey!==void 0||e.hooks!==void 0||e.currency0!==void 0||e.currency1!==void 0||e.permit2Expiration!==void 0?"v4":e.amount0Desired!==void 0||e.amount1Desired!==void 0||n==="uniswap_collect"&&(e.amount0Max!==void 0||e.amount1Max!==void 0)||e.token0!==void 0&&e.token1!==void 0&&e.tickSpacing===void 0?"v3":"v4"}function f(n,e){let t=n.tools.find(o=>o.name===e||o.name===e.replace("uniswap_","uniswap_v3_")||o.name===e.replace("uniswap_","uniswap_v4_"));if(!t)throw new d(`Tool ${e} is not available on the selected Uniswap part.`);return t}function h(n,e){let t=g(e?.v4,n)??T(n),o=g(e?.v3,n)??_(n),s=(i,c)=>({name:i,inputSchema:R(i,c,o),async execute(p,u){if(v(u),i==="uniswap_list_positions"&&p.version===void 0){let C=f(t,"uniswap_list_positions"),[S,l]=await Promise.all([(async()=>{let y=o.tools.find(r=>r.name==="uniswap_list_positions"||r.name==="uniswap_v3_list_positions");if(y){let r=await y.execute({...p,version:"v3"},u);if(Array.isArray(r))return r;if(r&&typeof r=="object"&&Array.isArray(r.positions))return r.positions}return o.positions?o.positions(u):[]})(),C.execute({...p,version:"v4"},u)]),x=Array.isArray(l?.positions)?l.positions:[],P=[...S,...x];return{positions:P,summary:`Found ${P.length} active Uniswap position(s) across v3 and v4 for ${u}.`}}return j(i,p)==="v3"?f(o,i).execute(p,u):f(t,i).execute({...p,version:"v4"},u)}}),a=[s("uniswap_add",w),s("uniswap_collect",M),s("uniswap_remove",k),s("uniswap_list_positions",A)];return m("uniswap",[{tools:a,positions:async i=>{v(i);let[c,p]=await Promise.all([o.positions?o.positions(i):Promise.resolve([]),t.positions?t.positions(i):Promise.resolve([])]);return[...c,...p]}}])}var _e=h;export{z as DEEPEST_V4_POOL_ID,K as MAX_TICK,J as MEASURED_V4_POOLS,B as MIN_TICK,O as PERMIT2_ADDRESS,$ as USDG_ADDRESS,G as V4_ACTIONS,w as V4_ADD_SCHEMA,M as V4_COLLECT_SCHEMA,q as V4_DYNAMIC_FEE_FLAG,A as V4_LIST_POSITIONS_SCHEMA,V as V4_POOL_MANAGER,I as V4_POSITION_MANAGER,k as V4_REMOVE_SCHEMA,U as V4_STATE_VIEW,L as V4_UNIVERSAL_ROUTER,H as WETH_ADDRESS,F as ZERO_ADDRESS,re as amountsForLiquidity,W as computePoolId,h as createModule,T as createModulePart,ce as createPart,_e as createUniswapModule,ve as createUniswapV4Part,ae as createV4Part,te as decodePackedPositionInfo,Y as describeV4FeeBehavior,ie as encodePackedPositionInfo,ne as encodePermit2Approve,oe as encodeV4UniversalRouterFeeSwap,pe as formatSignedPreviewChanges,N as fullRangeTicks,X as isDynamicFeePool,Q as isNativeV4Currency,se as liquidityForAmounts,de as readV4Positions,ue as tokenForCurrency,ee as validateTickRange,Z as validateV4PoolKey};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../../../chunks/CUBRTOMA.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{b as MAX_TICK,c as MAX_UINT128,a as MIN_TICK,j as UNISWAP_SWAP_ROUTER02_ABI,d as UNISWAP_V3_ADDRESSES,h as UNISWAP_V3_FACTORY_ABI,e as UNISWAP_V3_FEE_TICK_SPACING,f as UNISWAP_V3_MEASURED_POOLS,i as UNISWAP_V3_POOL_ABI,g as UNISWAP_V3_POSITION_MANAGER_ABI,y as createModulePart,x as createPart,v as createUniswapV3Part,u as createUniswapV3Tools,w as createV3Part,m as decodeV3PositionTuple,z as default,o as encodeSwapRouter02ExactInputSingle,n as extractV3TokenIdsFromReceipt,l as formatPreviewDelta,s as readUniswapV3Positions,p as uniswapAddV3,q as uniswapCollectV3,t as uniswapListPositionsV3,r as uniswapRemoveV3,k as validateV3TickRange};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../../../chunks/ZJUNO5N7.js";import"../../../chunks/XEN45QST.js";import"../../../chunks/Z53DADZ4.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/MEZH7RPA.js";import"../../../chunks/74X7PXPR.js";import"../../../chunks/VBWJOG3N.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/R5CBH2CR.js";import"../../../chunks/5BP72XOA.js";import"../../../chunks/XAB4OIE3.js";import"../../../chunks/7I6TXFXR.js";import"../../../chunks/Z3FZWNAJ.js";import"../../../chunks/XN4WDN3O.js";export{b as MAX_TICK,c as MAX_UINT128,a as MIN_TICK,j as UNISWAP_SWAP_ROUTER02_ABI,d as UNISWAP_V3_ADDRESSES,h as UNISWAP_V3_FACTORY_ABI,e as UNISWAP_V3_FEE_TICK_SPACING,f as UNISWAP_V3_MEASURED_POOLS,i as UNISWAP_V3_POOL_ABI,g as UNISWAP_V3_POSITION_MANAGER_ABI,y as createModulePart,x as createPart,v as createUniswapV3Part,u as createUniswapV3Tools,w as createV3Part,m as decodeV3PositionTuple,z as default,o as encodeSwapRouter02ExactInputSingle,n as extractV3TokenIdsFromReceipt,l as formatPreviewDelta,s as readUniswapV3Positions,p as uniswapAddV3,q as uniswapCollectV3,t as uniswapListPositionsV3,r as uniswapRemoveV3,k as validateV3TickRange};
@@ -1 +1 @@
1
- import{A,B,C,D,E,F,G,H,I,J,K,L,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../../../chunks/ZERWRK6X.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"../../../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{l as DEEPEST_V4_POOL_ID,k as MAX_TICK,n as MEASURED_V4_POOLS,j as MIN_TICK,d as PERMIT2_ADDRESS,g as USDG_ADDRESS,m as V4_ACTIONS,E as V4_ADD_SCHEMA,F as V4_COLLECT_SCHEMA,i as V4_DYNAMIC_FEE_FLAG,H as V4_LIST_POSITIONS_SCHEMA,a as V4_POOL_MANAGER,b as V4_POSITION_MANAGER,G as V4_REMOVE_SCHEMA,c as V4_STATE_VIEW,e as V4_UNIVERSAL_ROUTER,f as WETH_ADDRESS,h as ZERO_ADDRESS,z as amountsForLiquidity,p as computePoolId,K as createModulePart,J as createPart,L as createUniswapV4Part,I as createV4Part,y as decodePackedPositionInfo,r as describeV4FeeBehavior,x as encodePackedPositionInfo,v as encodePermit2Approve,w as encodeV4UniversalRouterFeeSwap,B as formatSignedPreviewChanges,t as fullRangeTicks,q as isDynamicFeePool,o as isNativeV4Currency,A as liquidityForAmounts,D as readV4Positions,C as tokenForCurrency,u as validateTickRange,s as validateV4PoolKey};
1
+ import{A,B,C,D,E,F,G,H,I,J,K,L,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../../../chunks/CWQ5WXZQ.js";import"../../../chunks/RYOVSHKO.js";import"../../../chunks/XKZOMGC3.js";import"../../../chunks/PQHU5A3U.js";import"../../../chunks/F3TOOLFQ.js";import"../../../chunks/SXBGOGYQ.js";import"../../../chunks/UIJWIFGV.js";import"../../../chunks/B2LA6VVF.js";import"../../../chunks/NNJLMS7F.js";import"../../../chunks/XEN45QST.js";import"../../../chunks/Z53DADZ4.js";import"../../../chunks/LIUXNOLP.js";import"../../../chunks/MEZH7RPA.js";import"../../../chunks/TU3KHOZK.js";import"../../../chunks/74X7PXPR.js";import"../../../chunks/UB5U6SI2.js";import"../../../chunks/Z25UKUJF.js";import"../../../chunks/VBWJOG3N.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/R5CBH2CR.js";import"../../../chunks/5BP72XOA.js";import"../../../chunks/XAB4OIE3.js";import"../../../chunks/7I6TXFXR.js";import"../../../chunks/Z3FZWNAJ.js";import"../../../chunks/XN4WDN3O.js";export{l as DEEPEST_V4_POOL_ID,k as MAX_TICK,n as MEASURED_V4_POOLS,j as MIN_TICK,d as PERMIT2_ADDRESS,g as USDG_ADDRESS,m as V4_ACTIONS,E as V4_ADD_SCHEMA,F as V4_COLLECT_SCHEMA,i as V4_DYNAMIC_FEE_FLAG,H as V4_LIST_POSITIONS_SCHEMA,a as V4_POOL_MANAGER,b as V4_POSITION_MANAGER,G as V4_REMOVE_SCHEMA,c as V4_STATE_VIEW,e as V4_UNIVERSAL_ROUTER,f as WETH_ADDRESS,h as ZERO_ADDRESS,z as amountsForLiquidity,p as computePoolId,K as createModulePart,J as createPart,L as createUniswapV4Part,I as createV4Part,y as decodePackedPositionInfo,r as describeV4FeeBehavior,x as encodePackedPositionInfo,v as encodePermit2Approve,w as encodeV4UniversalRouterFeeSwap,B as formatSignedPreviewChanges,t as fullRangeTicks,q as isDynamicFeePool,o as isNativeV4Currency,A as liquidityForAmounts,D as readV4Positions,C as tokenForCurrency,u as validateTickRange,s as validateV4PoolKey};
@@ -1 +1 @@
1
- import{a as le}from"../../../chunks/JMPOXXNJ.js";import{a as re,b as J,e as T,h as se,i as ae,m as L,n as ie,o as G,p as ue,q as de,t as ce,v as me,w as pe}from"../../../chunks/VBV366XQ.js";import{b as H}from"../../../chunks/S3YSJ7XH.js";import"../../../chunks/LIUXNOLP.js";import{a as z}from"../../../chunks/P7Q6MJZH.js";import{c as ne}from"../../../chunks/ZUAXW2ZD.js";import"../../../chunks/64EN6Y7E.js";import{a as _}from"../../../chunks/VZWOWR6G.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/UL2L7NHO.js";import{a as m,i as oe}from"../../../chunks/25EOXUBI.js";import{a as j}from"../../../chunks/B5RZYFQC.js";import{a as t}from"../../../chunks/T5E4OJEU.js";import"../../../chunks/XN4WDN3O.js";import{randomUUID as ve}from"node:crypto";import{decodeFunctionData as Ie,erc20Abi as Se,parseAbi as Te}from"viem";var O=oe[m].routes.velora.address,be="https://api.velora.xyz/prices",xe="https://api.velora.xyz/transactions/4663?ignoreChecks=true",ge=(1n<<256n)-1n,Pe=new Set(["from","to","amountIn","slippageBps"]),Ve=Te(["function swapExactAmountIn(address executor, (address srcToken, address destToken, uint256 fromAmount, uint256 toAmount, uint256 quotedAmount, bytes32 metadata, address beneficiary) swapData, uint256 partnerAndFee, bytes permit, bytes executorData) payable returns (uint256 receivedAmount, uint256 submittedAmount, uint256 augustusFeeAmount)"]);function V(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function x(e){if(typeof e!="string")throw new t("Provide a token or wallet address.");if(_(e),/^0x0{40}$/i.test(e))throw new t("Use the native ETH token address, not the zero address.");return e}function we(e){if(typeof e!="string")throw new t("Provide a token address.");return _(e),H(e)}function Q(e){return ie(e)?T:e}function k(e,n,p){if(x(e).toLowerCase()!==n.toLowerCase())throw new t(`Velora ${p} does not match the requested swap.`)}function P(e){if(typeof e!="string")throw new t("Amount must be an integer string in base units.");let n=j(e);if(n>ge)throw new t("Amount exceeds the uint256 range.");return n.toString()}function fe(e){if(!V(e))throw new t("Swap arguments must be an object.");for(let q of Object.keys(e))if(!Pe.has(q))throw new t(`Unsupported Velora quote argument: ${q}.`);let n=we(e.from),p=we(e.to);if(n.toLowerCase()===p.toLowerCase())throw new t("Choose two different token addresses.");let g=P(e.amountIn);if(g==="0")throw new t("Swap amountIn must be greater than zero.");let A=e.slippageBps??J;if(typeof A!="number")throw new t("Slippage must be an integer number of bps.");return G(g,A),{from:n,to:p,amountIn:g,slippageBps:A}}function qe(e){if(!V(e))throw new t("Swap arguments must be an object.");for(let n of Object.keys(e))if(n!=="quoteId")throw new t(`Unsupported Velora swap argument: ${n}.`);if(typeof e.quoteId!="string"||!e.quoteId.trim())throw new t("Provide a Velora quoteId.");return e.quoteId}function he(e,n){me(e,n);let p=Ie({abi:Ve,data:e.data}),[,g,,A]=p.args;if(g.toAmount.toString()!==n.calldataMinAmountOut)throw new t("Velora calldata minimum output does not match the accepted quote.");if(g.quotedAmount.toString()!==n.grossAmountOut)throw new t("Velora calldata quotedAmount does not match the quoted gross output.");if(A!=="0x")throw new t("Velora calldata must not include a permit payload.")}var Ce={type:"object",additionalProperties:!1,required:["from","to","amountIn"],properties:{from:{type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},to:{type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},amountIn:{type:"string",pattern:"^[0-9]+$",description:"Positive integer amount in input-token base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:J}}};function $e(e){let n=new Map;async function p(o){try{return await o()}catch(s){throw new t(e.plainError(s))}}async function g(){let o=e.clientFor(m);if(await o.getChainId()!==m)throw new t("Velora requires an RPC on chain 4663.");return o}async function A(o,s){if(o.toLowerCase()===T.toLowerCase())return{address:o,symbol:"ETH",decimals:18,chainId:m};let[a,r]=await Promise.all([z(s,m,o,"symbol"),z(s,m,o,"decimals")]);if(typeof a!="string"||!a.trim()||!Number.isInteger(r)||r<0||r>255)throw new t("The token returned invalid symbol or decimals metadata.");return{address:o,symbol:a,decimals:r,chainId:m}}async function q(o,s,a,r){if(o.toLowerCase()===T.toLowerCase())return 0n;let d=await r.readContract({address:o,abi:Se,functionName:"allowance",args:[s,a]});if(typeof d!="bigint"||d<0n||d>ge)throw new t("The token returned an invalid allowance.");return d}function Ae(){let o=BigInt(L());for(let[s,a]of n)o>=BigInt(a.quote.expiresAt)&&n.delete(s)}function y(o){if(BigInt(L())>=BigInt(o.expiresAt))throw n.delete(o.quoteId),new se}async function D(o,s,a=!1){return p(async()=>{let r=fe(o),d=x(s),u=String(L()+re),C=await g(),[c,l]=await Promise.all([A(r.from,C),A(r.to,C)]),$=new URLSearchParams({network:String(m),srcToken:Q(c.address),srcDecimals:String(c.decimals),destToken:Q(l.address),destDecimals:String(l.decimals),amount:r.amountIn,side:"SELL"}),I=await le(e.http,`${be}?${$}`,V),i=I.value.priceRoute;if(!V(i))throw new t("Velora returned no usable price route.");k(i.srcToken,c.address,"input token"),k(i.destToken,l.address,"output token"),k(i.contractAddress,O,"router"),k(i.tokenTransferProxy,O,"token transfer proxy");let f=x(i.tokenTransferProxy);if(i.network!==m||i.srcDecimals!==c.decimals||i.destDecimals!==l.decimals||P(i.srcAmount)!==r.amountIn||i.side!=="SELL"||i.contractMethod!=="swapExactAmountIn"||i.version!=="6.2")throw new t("Velora returned a route that does not match the requested swap.");if(i.maxImpactReached===!0)throw new t("Velora reports that this route exceeds its price impact limit.");if(i.partner!=="anon"||i.partnerFee!==.01)throw new t("Velora returned an unsupported venue fee. Request a fresh quote.");if(i.destAmountAfterFee===void 0)throw new t("Velora price route is missing destAmountAfterFee.");let w=P(i.destAmount),b=BigInt(P(i.destAmountAfterFee)),R=BigInt(w)*9999n/10000n,ye=(BigInt(w)*9999n+9999n)/10000n;if(b<R||b>ye)throw new t("Velora output after fees does not match its disclosed 1 bp venue fee.");let S=(BigInt(w)-BigInt(w)/10000n-1n).toString();if(BigInt(S)<=0n)throw new t("Velora returned no positive swap output.");let B=G(S,r.slippageBps);if(B==="0")throw new t("Velora minimum output must be positive.");let F=ue(B).toString();if(BigInt(F)>BigInt(w))throw new t("Velora output is too small to cover router dust.");let U=(BigInt(w)-BigInt(S)).toString(),Y=de({provider:"velora",venueFee:U,venueFeeBps:1,oakFee:"0"}),Z=B,h={quoteId:`velora:${ve()}`,router:O,expiresAt:String(Math.min(Number(u),I.expiresAt)),amountOut:S,minAmountOut:Z,calldataMinAmountOut:F,provider:"velora",from:c.address,to:l.address,amountIn:r.amountIn,wallet:d,chainId:m,slippageBps:r.slippageBps,spender:f,value:c.address.toLowerCase()===T.toLowerCase()?r.amountIn:"0",grossAmountOut:w,destAmountAfterFee:S,venueFee:U,venueFeeBps:1,oakFee:"0",feeDisclosure:Y,input:{token:c,amount:r.amountIn},output:{token:l,amount:S},minimumOutput:{token:l,amount:Z},fee:{token:l,amount:U}},E={quote:h,wallet:d,spender:f,prepare:async()=>{if(y(h),E.tx)return structuredClone(h);let v=await ne(e.http,xe,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({srcToken:Q(c.address),destToken:Q(l.address),srcAmount:r.amountIn,destAmount:F,priceRoute:i,userAddress:d,receiver:d,srcDecimals:c.decimals,destDecimals:l.decimals})},V);if(k(v.from,d,"transaction sender"),v.chainId!==m)throw new t("Velora built a transaction for a different chain.");if(typeof v.data!="string"||!/^0x(?:[a-fA-F0-9]{2})+$/.test(v.data))throw new t("Velora returned invalid swap calldata.");let te=v.data,ke=P(v.value);if(ce(te).toString()!==F)throw new t("Velora calldata minimum does not match the net output and slippage.");let N=e.unsignedTx({to:x(v.to),data:te,value:ke,chainId:m,description:`Swap ${r.amountIn} base units of ${c.address} for at least ${B} base units of ${l.address} via velora (${O}). ${Y}`});return he(N,h),h.data=N.data,y(h),E.tx=N,structuredClone(h)}};for(y(h),Ae();n.size>=ae;)n.delete(n.keys().next().value);if(n.set(h.quoteId,E),a)return structuredClone(h);let ee=await E.prepare();return{...ee,...pe(ee)}})}async function K(o,s){return p(async()=>{let a=n.get(o);if(!a)throw new t("Quote is unknown or expired. Request a fresh Velora quote.");return k(s,a.wallet,"wallet"),a.prepare()})}async function W(o,s){return p(async()=>{let a=n.get(o);if(!a)throw new t("Quote is unknown or expired. Request a fresh Velora quote.");k(s,a.wallet,"wallet"),y(a.quote);let r=await g(),d=await q(a.quote.input.token.address,s,a.spender,r);return y(a.quote),d.toString()})}async function X(o,s,a={}){return p(async()=>{if(typeof o!="string"||!o.trim())throw new t("Provide a Velora quoteId.");let r=x(s),d=n.get(o);if(!d)throw new t("Quote is unknown or expired. Request a fresh Velora quote.");let{quote:u,spender:C}=d;y(u),k(r,d.wallet,"wallet"),await K(o,r);let c=[],l=j(a.allowance??await W(o,r));u.input.token.address.toLowerCase()!==T.toLowerCase()&&l<BigInt(u.input.amount)&&c.push(e.approval(u.input.token.address,C,u.input.amount,m));let $={...d.tx};he($,u),c.push($),y(u);let I=await e.preview(c,r);y(u);let M=0n,i=I.changes.map(({token:f,amount:w})=>{if(f={...f,address:H(f.address)},!/^-?\d+$/.test(w))throw new t("Preview returned an invalid token amount.");f.address.toLowerCase()===u.output.token.address.toLowerCase()&&(M+=BigInt(w));let b=w.startsWith("-"),R=e.formatAmount(b?w.slice(1):w,f.decimals);return`${b?"-":"+"}${R} ${f.symbol} (${f.address}, chain ${f.chainId}, ${f.decimals} decimals)`});if(M<BigInt(u.minimumOutput.amount))throw new t("Preview retained output is below the accepted minimum.");return{txs:c,preview:I,summary:`Unsigned Velora swap. Minimum output: ${u.minimumOutput.amount} base units of ${u.output.token.address} (${u.output.token.decimals} decimals, chain ${m}). ${u.feeDisclosure} Fee token: ${u.fee.token.address} (${u.fee.token.decimals} decimals). ${I.summary} ${i.join("; ")}`}})}return{name:"velora",swapProvider:{name:"velora",quote:D,build:X,prepareQuote:K,readAllowance:W,quotePrices:(o,s)=>D(o,s,!0)},tools:[{name:"velora_quote",inputSchema:Ce,execute:(o,s)=>p(()=>D(fe(o),s))},{name:"velora_swap",inputSchema:{type:"object",additionalProperties:!1,required:["quoteId"],properties:{quoteId:{type:"string",minLength:1}}},execute:(o,s)=>p(()=>X(qe(o),s))}]}}var ze=e=>({tools:$e(e).tools});export{$e as createModule,ze as createModulePart};
1
+ import{a as we}from"../../../chunks/XTUXR43N.js";import{a as re,b as J,e as b,h as se,i as ae,m as O,n as ie,o as G,q as ue,r as de,t as ce,w as me,y as pe,z as le}from"../../../chunks/XEN45QST.js";import{b as H}from"../../../chunks/Z53DADZ4.js";import"../../../chunks/LIUXNOLP.js";import{a as z}from"../../../chunks/MEZH7RPA.js";import{c as ne}from"../../../chunks/TU3KHOZK.js";import"../../../chunks/74X7PXPR.js";import{a as _}from"../../../chunks/VBWJOG3N.js";import"../../../chunks/5HCXZWUH.js";import"../../../chunks/R5CBH2CR.js";import{a as m,i as oe}from"../../../chunks/5BP72XOA.js";import"../../../chunks/XAB4OIE3.js";import{a as j}from"../../../chunks/7I6TXFXR.js";import{a as t}from"../../../chunks/Z3FZWNAJ.js";import"../../../chunks/XN4WDN3O.js";import{randomUUID as Se}from"node:crypto";import{decodeFunctionData as Te,erc20Abi as be,parseAbi as xe}from"viem";var Q=oe[m].routes.velora.address,Pe="https://api.velora.xyz/prices",Ve="https://api.velora.xyz/transactions/4663?ignoreChecks=true",Ae=(1n<<256n)-1n,qe=new Set(["from","to","amountIn","slippageBps"]),Ce=xe(["function swapExactAmountIn(address executor, (address srcToken, address destToken, uint256 fromAmount, uint256 toAmount, uint256 quotedAmount, bytes32 metadata, address beneficiary) swapData, uint256 partnerAndFee, bytes permit, bytes executorData) payable returns (uint256 receivedAmount, uint256 submittedAmount, uint256 augustusFeeAmount)"]);function V(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function x(e){if(typeof e!="string")throw new t("Provide a token or wallet address.");if(_(e),/^0x0{40}$/i.test(e))throw new t("Use the native ETH token address, not the zero address.");return e}function fe(e){if(typeof e!="string")throw new t("Provide a token address.");return _(e),H(e)}function D(e){return ie(e)?b:e}function v(e,n,p){if(x(e).toLowerCase()!==n.toLowerCase())throw new t(`Velora ${p} does not match the requested swap.`)}function P(e){if(typeof e!="string")throw new t("Amount must be an integer string in base units.");let n=j(e);if(n>Ae)throw new t("Amount exceeds the uint256 range.");return n.toString()}function he(e){if(!V(e))throw new t("Swap arguments must be an object.");for(let q of Object.keys(e))if(!qe.has(q))throw new t(`Unsupported Velora quote argument: ${q}.`);let n=fe(e.from),p=fe(e.to);if(n.toLowerCase()===p.toLowerCase())throw new t("Choose two different token addresses.");let A=P(e.amountIn);if(A==="0")throw new t("Swap amountIn must be greater than zero.");let y=e.slippageBps??J;if(typeof y!="number")throw new t("Slippage must be an integer number of bps.");return G(A,y),{from:n,to:p,amountIn:A,slippageBps:y}}function Be(e){if(!V(e))throw new t("Swap arguments must be an object.");for(let n of Object.keys(e))if(n!=="quoteId")throw new t(`Unsupported Velora swap argument: ${n}.`);if(typeof e.quoteId!="string"||!e.quoteId.trim())throw new t("Provide a Velora quoteId.");return e.quoteId}function ge(e,n){pe(e,n);let p=Te({abi:Ce,data:e.data}),[,A,,y]=p.args;if(A.toAmount.toString()!==n.calldataMinAmountOut)throw new t("Velora calldata minimum output does not match the accepted quote.");if(A.quotedAmount.toString()!==n.grossAmountOut)throw new t("Velora calldata quotedAmount does not match the quoted gross output.");if(y!=="0x")throw new t("Velora calldata must not include a permit payload.")}var $e={type:"object",additionalProperties:!1,required:["from","to","amountIn"],properties:{from:{type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},to:{type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},amountIn:{type:"string",pattern:"^[0-9]+$",description:"Positive integer amount in input-token base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:J}}};function Fe(e){let n=new Map;async function p(o){try{return await o()}catch(s){throw new t(e.plainError(s))}}async function A(){let o=e.clientFor(m);if(await o.getChainId()!==m)throw new t("Velora requires an RPC on chain 4663.");return o}async function y(o,s){if(o.toLowerCase()===b.toLowerCase())return{address:o,symbol:"ETH",decimals:18,chainId:m};let[a,r]=await Promise.all([z(s,m,o,"symbol"),z(s,m,o,"decimals")]);if(typeof a!="string"||!a.trim()||!Number.isInteger(r)||r<0||r>255)throw new t("The token returned invalid symbol or decimals metadata.");return{address:o,symbol:a,decimals:r,chainId:m}}async function q(o,s,a,r){if(o.toLowerCase()===b.toLowerCase())return 0n;let d=await r.readContract({address:o,abi:be,functionName:"allowance",args:[s,a]});if(typeof d!="bigint"||d<0n||d>Ae)throw new t("The token returned an invalid allowance.");return d}function ye(){let o=BigInt(O());for(let[s,a]of n)o>=BigInt(a.quote.expiresAt)&&n.delete(s)}function I(o){if(BigInt(O())>=BigInt(o.expiresAt))throw n.delete(o.quoteId),new se}async function M(o,s,a=!1){return p(async()=>{let r=he(o),d=x(s),u=String(O()+re),C=await A(),[c,l]=await Promise.all([y(r.from,C),y(r.to,C)]),B=new URLSearchParams({network:String(m),srcToken:D(c.address),srcDecimals:String(c.decimals),destToken:D(l.address),destDecimals:String(l.decimals),amount:r.amountIn,side:"SELL"}),S=await we(e.http,`${Pe}?${B}`,V),i=S.value.priceRoute;if(!V(i))throw new t("Velora returned no usable price route.");v(i.srcToken,c.address,"input token"),v(i.destToken,l.address,"output token"),v(i.contractAddress,Q,"router"),v(i.tokenTransferProxy,Q,"token transfer proxy");let f=x(i.tokenTransferProxy);if(i.network!==m||i.srcDecimals!==c.decimals||i.destDecimals!==l.decimals||P(i.srcAmount)!==r.amountIn||i.side!=="SELL"||i.contractMethod!=="swapExactAmountIn"||i.version!=="6.2")throw new t("Velora returned a route that does not match the requested swap.");if(i.maxImpactReached===!0)throw new t("Velora reports that this route exceeds its price impact limit.");if(i.partner!=="anon")throw new t("Velora returned an unsupported venue fee. Request a fresh quote.");let w=ue(i.partnerFee);if(i.destAmountAfterFee===void 0&&w!==0)throw new t("Velora price route is missing destAmountAfterFee.");let h=P(i.destAmount),$=BigInt(P(i.destAmountAfterFee??h)),Ie=BigInt(h)*BigInt(1e4-w)/10000n,ve=(BigInt(h)*BigInt(1e4-w)+9999n)/10000n;if($<Ie||$>ve)throw new t("Velora output after fees does not match its disclosed venue fee.");let T=(BigInt(h)-BigInt(h)*BigInt(w)/10000n-1n).toString();if(BigInt(T)<=0n)throw new t("Velora returned no positive swap output.");let F=G(T,r.slippageBps);if(F==="0")throw new t("Velora minimum output must be positive.");let E=de(F,w).toString();if(BigInt(E)>BigInt(h))throw new t("Velora output is too small to cover router dust.");let U=(BigInt(h)-BigInt(T)).toString(),Y=ce({provider:"velora",venueFee:U,venueFeeBps:w,oakFee:"0"}),Z=F,g={quoteId:`velora:${Se()}`,router:Q,expiresAt:String(Math.min(Number(u),S.expiresAt)),amountOut:T,minAmountOut:Z,calldataMinAmountOut:E,provider:"velora",from:c.address,to:l.address,amountIn:r.amountIn,wallet:d,chainId:m,slippageBps:r.slippageBps,spender:f,value:c.address.toLowerCase()===b.toLowerCase()?r.amountIn:"0",grossAmountOut:h,destAmountAfterFee:T,venueFee:U,venueFeeBps:w,oakFee:"0",feeDisclosure:Y,input:{token:c,amount:r.amountIn},output:{token:l,amount:T},minimumOutput:{token:l,amount:Z},fee:{token:l,amount:U}},L={quote:g,wallet:d,spender:f,prepare:async()=>{if(I(g),L.tx)return structuredClone(g);let k=await ne(e.http,Ve,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({srcToken:D(c.address),destToken:D(l.address),srcAmount:r.amountIn,destAmount:E,priceRoute:i,userAddress:d,receiver:d,srcDecimals:c.decimals,destDecimals:l.decimals})},V);if(v(k.from,d,"transaction sender"),k.chainId!==m)throw new t("Velora built a transaction for a different chain.");if(typeof k.data!="string"||!/^0x(?:[a-fA-F0-9]{2})+$/.test(k.data))throw new t("Velora returned invalid swap calldata.");let te=k.data,ke=P(k.value);if(me(te).toString()!==E)throw new t("Velora calldata minimum does not match the net output and slippage.");let N=e.unsignedTx({to:x(k.to),data:te,value:ke,chainId:m,description:`Swap ${r.amountIn} base units of ${c.address} for at least ${F} base units of ${l.address} via velora (${Q}). ${Y}`});return ge(N,g),g.data=N.data,I(g),L.tx=N,structuredClone(g)}};for(I(g),ye();n.size>=ae;)n.delete(n.keys().next().value);if(n.set(g.quoteId,L),a)return structuredClone(g);let ee=await L.prepare();return{...ee,...le(ee)}})}async function K(o,s){return p(async()=>{let a=n.get(o);if(!a)throw new t("Quote is unknown or expired. Request a fresh Velora quote.");return v(s,a.wallet,"wallet"),a.prepare()})}async function W(o,s){return p(async()=>{let a=n.get(o);if(!a)throw new t("Quote is unknown or expired. Request a fresh Velora quote.");v(s,a.wallet,"wallet"),I(a.quote);let r=await A(),d=await q(a.quote.input.token.address,s,a.spender,r);return I(a.quote),d.toString()})}async function X(o,s,a={}){return p(async()=>{if(typeof o!="string"||!o.trim())throw new t("Provide a Velora quoteId.");let r=x(s),d=n.get(o);if(!d)throw new t("Quote is unknown or expired. Request a fresh Velora quote.");let{quote:u,spender:C}=d;I(u),v(r,d.wallet,"wallet"),await K(o,r);let c=[],l=j(a.allowance??await W(o,r));u.input.token.address.toLowerCase()!==b.toLowerCase()&&l<BigInt(u.input.amount)&&c.push(e.approval(u.input.token.address,C,u.input.amount,m));let B={...d.tx};ge(B,u),c.push(B),I(u);let S=await e.preview(c,r);I(u);let R=0n,i=S.changes.map(({token:f,amount:w})=>{if(f={...f,address:H(f.address)},!/^-?\d+$/.test(w))throw new t("Preview returned an invalid token amount.");f.address.toLowerCase()===u.output.token.address.toLowerCase()&&(R+=BigInt(w));let h=w.startsWith("-"),$=e.formatAmount(h?w.slice(1):w,f.decimals);return`${h?"-":"+"}${$} ${f.symbol} (${f.address}, chain ${f.chainId}, ${f.decimals} decimals)`});if(R<BigInt(u.minimumOutput.amount))throw new t("Preview retained output is below the accepted minimum.");return{txs:c,preview:S,summary:`Unsigned Velora swap. Minimum output: ${u.minimumOutput.amount} base units of ${u.output.token.address} (${u.output.token.decimals} decimals, chain ${m}). ${u.feeDisclosure} Fee token: ${u.fee.token.address} (${u.fee.token.decimals} decimals). ${S.summary} ${i.join("; ")}`}})}return{name:"velora",swapProvider:{name:"velora",quote:M,build:X,prepareQuote:K,readAllowance:W,quotePrices:(o,s)=>M(o,s,!0)},tools:[{name:"velora_quote",inputSchema:$e,execute:(o,s)=>p(()=>M(he(o),s))},{name:"velora_swap",inputSchema:{type:"object",additionalProperties:!1,required:["quoteId"],properties:{quoteId:{type:"string",minLength:1}}},execute:(o,s)=>p(()=>X(Be(o),s))}]}}var Je=e=>({tools:Fe(e).tools});export{Fe as createModule,Je as createModulePart};
@@ -1 +1 @@
1
- import{a as P}from"../chunks/VZWOWR6G.js";import{a as p}from"../chunks/25EOXUBI.js";import{a as f}from"../chunks/B5RZYFQC.js";import{a as m,c as u}from"../chunks/T5E4OJEU.js";import"../chunks/XN4WDN3O.js";import{getAddress as h}from"viem";function y(i){let n=Array.isArray(i)?i.map((o,e)=>[void 0,o,e]):Object.entries(i).map(([o,e],s)=>[o,e,s]),t=[];for(let[o,e,s]of n){if(typeof e=="function"){let a=o||e.name||`module_${s}`;t.push({name:a,read:e});continue}if(e&&typeof e=="object"){let a=o||e.name||("module"in e?e.module:void 0)||`module_${s}`;typeof e.positions=="function"?t.push({name:a,read:e.positions.bind(e)}):"read"in e&&typeof e.read=="function"&&t.push({name:a,read:e.read.bind(e)})}}return t}function w(i,n){if(!i||typeof i!="object")throw new m(`Module ${n} returned an invalid position.`);if(typeof i.id!="string"||!i.id.trim())throw new m(`Module ${n} returned a position without an id.`);if(!Number.isSafeInteger(i.chainId)||i.chainId<=0)throw new m(`Module ${n} returned a position with an invalid chainId.`);if(!Array.isArray(i.assets))throw new m(`Module ${n} returned a position with invalid assets.`);let t=i.assets.map(o=>({token:{address:o.token.address,symbol:o.token.symbol,decimals:o.token.decimals,chainId:o.token.chainId},amount:f(o.amount).toString()}));return{module:i.module||n,id:i.id,chainId:i.chainId,assets:t,description:i.description}}async function $(i,n=[],t={}){P(i);let o=h(i),e=t.chainId??p,s=y(n),a=await Promise.allSettled(s.map(async r=>{let d=await r.read(o);if(!Array.isArray(d))throw new m(`Module ${r.name} did not return a position list.`);return d.map(c=>w(c,r.name))})),l=[];for(let r=0;r<a.length;r++){let d=a[r],c=s[r];d.status==="fulfilled"?l.push(...d.value):l.push({module:c.name,id:"error",chainId:e,assets:[],description:`${c.name}: ${u(d.reason)}`})}return l}export{$ as getPositions};
1
+ import{a as P}from"../chunks/VBWJOG3N.js";import{a as p}from"../chunks/5BP72XOA.js";import{a as f}from"../chunks/7I6TXFXR.js";import{a as m,d as u}from"../chunks/Z3FZWNAJ.js";import"../chunks/XN4WDN3O.js";import{getAddress as h}from"viem";function y(i){let n=Array.isArray(i)?i.map((o,e)=>[void 0,o,e]):Object.entries(i).map(([o,e],s)=>[o,e,s]),t=[];for(let[o,e,s]of n){if(typeof e=="function"){let a=o||e.name||`module_${s}`;t.push({name:a,read:e});continue}if(e&&typeof e=="object"){let a=o||e.name||("module"in e?e.module:void 0)||`module_${s}`;typeof e.positions=="function"?t.push({name:a,read:e.positions.bind(e)}):"read"in e&&typeof e.read=="function"&&t.push({name:a,read:e.read.bind(e)})}}return t}function w(i,n){if(!i||typeof i!="object")throw new m(`Module ${n} returned an invalid position.`);if(typeof i.id!="string"||!i.id.trim())throw new m(`Module ${n} returned a position without an id.`);if(!Number.isSafeInteger(i.chainId)||i.chainId<=0)throw new m(`Module ${n} returned a position with an invalid chainId.`);if(!Array.isArray(i.assets))throw new m(`Module ${n} returned a position with invalid assets.`);let t=i.assets.map(o=>({token:{address:o.token.address,symbol:o.token.symbol,decimals:o.token.decimals,chainId:o.token.chainId},amount:f(o.amount).toString()}));return{module:i.module||n,id:i.id,chainId:i.chainId,assets:t,description:i.description}}async function $(i,n=[],t={}){P(i);let o=h(i),e=t.chainId??p,s=y(n),a=await Promise.allSettled(s.map(async r=>{let d=await r.read(o);if(!Array.isArray(d))throw new m(`Module ${r.name} did not return a position list.`);return d.map(c=>w(c,r.name))})),l=[];for(let r=0;r<a.length;r++){let d=a[r],c=s[r];d.status==="fulfilled"?l.push(...d.value):l.push({module:c.name,id:"error",chainId:e,assets:[],description:`${c.name}: ${u(d.reason)}`})}return l}export{$ as getPositions};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"../chunks/ZKOMJGNH.js";import"../chunks/25EOXUBI.js";import"../chunks/B5RZYFQC.js";import"../chunks/T5E4OJEU.js";import"../chunks/XN4WDN3O.js";export{d as BURNER_NOTE_WALLET,c as NOTE_TTL,a as PRICE_NOTE_NAME,e as PRICE_NOTE_TYPEHASH,b as PRICE_NOTE_VERSION,f as eip712DomainSeparator,m as isWithinNoteGuard,j as noteDigest,g as priceNoteDomain,h as priceNoteDomainSeparator,i as priceNoteStructHash,l as recoverNoteSigner,k as signNote,o as verifyNote,n as verifyNoteOffchain};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"../chunks/PQHU5A3U.js";import"../chunks/5BP72XOA.js";import"../chunks/7I6TXFXR.js";import"../chunks/Z3FZWNAJ.js";import"../chunks/XN4WDN3O.js";export{d as BURNER_NOTE_WALLET,c as NOTE_TTL,a as PRICE_NOTE_NAME,e as PRICE_NOTE_TYPEHASH,b as PRICE_NOTE_VERSION,f as eip712DomainSeparator,m as isWithinNoteGuard,j as noteDigest,g as priceNoteDomain,h as priceNoteDomainSeparator,i as priceNoteStructHash,l as recoverNoteSigner,k as signNote,o as verifyNote,n as verifyNoteOffchain};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j}from"../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"../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{a as MAX_PRICE_AGE_SECONDS,b as USD_PARITY_E18,h as assertFreshPrice,j as getPrice,f as isCanonicalEthOrWeth,d as isCanonicalNativeEth,c as isCanonicalUsdg,e as isCanonicalWeth,g as isPriceFresh,i as sqrtRatioAtTick};
1
+ import{a,b,c,d,e,f,g,h,i,j}from"../chunks/RYOVSHKO.js";import"../chunks/XKZOMGC3.js";import"../chunks/PQHU5A3U.js";import"../chunks/F3TOOLFQ.js";import"../chunks/SXBGOGYQ.js";import"../chunks/UIJWIFGV.js";import"../chunks/B2LA6VVF.js";import"../chunks/NNJLMS7F.js";import"../chunks/XEN45QST.js";import"../chunks/Z53DADZ4.js";import"../chunks/LIUXNOLP.js";import"../chunks/MEZH7RPA.js";import"../chunks/TU3KHOZK.js";import"../chunks/74X7PXPR.js";import"../chunks/UB5U6SI2.js";import"../chunks/Z25UKUJF.js";import"../chunks/VBWJOG3N.js";import"../chunks/5HCXZWUH.js";import"../chunks/R5CBH2CR.js";import"../chunks/5BP72XOA.js";import"../chunks/XAB4OIE3.js";import"../chunks/7I6TXFXR.js";import"../chunks/Z3FZWNAJ.js";import"../chunks/XN4WDN3O.js";export{a as MAX_PRICE_AGE_SECONDS,b as USD_PARITY_E18,h as assertFreshPrice,j as getPrice,f as isCanonicalEthOrWeth,d as isCanonicalNativeEth,c as isCanonicalUsdg,e as isCanonicalWeth,g as isPriceFresh,i as sqrtRatioAtTick};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"../chunks/MGEJPRXP.js";import"../chunks/25EOXUBI.js";import"../chunks/B5RZYFQC.js";import"../chunks/T5E4OJEU.js";import"../chunks/XN4WDN3O.js";export{e as CONTINUITY_BREAKPOINTS_USD_E18,d as ENTRY_CAP_USD_E18,c as ENTRY_FLOOR_USD_E18,b as HOLDER_PRICE_BASE,a as NOHOLD_FLOOR,f as ORACLE_WINDOW_SECONDS,t as averageOakEth30m,u as averageWindowOakEth30m,o as burnerMinOut,v as checkMaxCount,w as checkMaxPrice,q as decodeObserveTickCumulatives,g as entryUsdE18,r as ethUsdFromSqrtRatioX96,n as marketCapUsdE18,p as meanTickFromCumulatives,h as noHoldPriceBase,l as oakUsdE18,m as requiredCount,j as signupBurn,k as signupTrackedCount,i as splitBurn,s as spotOakPerEthFromSqrtPriceX96};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"../chunks/XKZOMGC3.js";import"../chunks/5BP72XOA.js";import"../chunks/7I6TXFXR.js";import"../chunks/Z3FZWNAJ.js";import"../chunks/XN4WDN3O.js";export{e as CONTINUITY_BREAKPOINTS_USD_E18,d as ENTRY_CAP_USD_E18,c as ENTRY_FLOOR_USD_E18,b as HOLDER_PRICE_BASE,a as NOHOLD_FLOOR,f as ORACLE_WINDOW_SECONDS,t as averageOakEth30m,u as averageWindowOakEth30m,o as burnerMinOut,v as checkMaxCount,w as checkMaxPrice,q as decodeObserveTickCumulatives,g as entryUsdE18,r as ethUsdFromSqrtRatioX96,n as marketCapUsdE18,p as meanTickFromCumulatives,h as noHoldPriceBase,l as oakUsdE18,m as requiredCount,j as signupBurn,k as signupTrackedCount,i as splitBurn,s as spotOakPerEthFromSqrtPriceX96};
@@ -1 +1 @@
1
- import{a}from"../chunks/JMPOXXNJ.js";import"../chunks/ZUAXW2ZD.js";import"../chunks/64EN6Y7E.js";import"../chunks/5HCXZWUH.js";import"../chunks/T5E4OJEU.js";import"../chunks/XN4WDN3O.js";export{a as sharedRoute};
1
+ import{a}from"../chunks/XTUXR43N.js";import"../chunks/TU3KHOZK.js";import"../chunks/74X7PXPR.js";import"../chunks/5HCXZWUH.js";import"../chunks/Z3FZWNAJ.js";import"../chunks/XN4WDN3O.js";export{a as sharedRoute};
@@ -1 +1 @@
1
- import{a as o}from"../chunks/T5E4OJEU.js";import"../chunks/XN4WDN3O.js";function p(n,i=[]){let a=[{value:n,path:""}];for(;a.length;){let e=a.pop();if(!(!e.value||typeof e.value!="object"))for(let[t,s]of Object.entries(e.value)){let r=e.path?`${e.path}.${t}`:t,c=t.replace(/[^a-z0-9]/gi,"").toLowerCase();if(/^(?:(?:private|secret|wallet)keys?|mnemonic(?:phrase|words)?|seed(?:phrase|words|hex)?|recovery(?:phrase|words)|passphrase|password|signatures?|(?:raw)?signed(?:tx|transaction)s?|raw(?:tx|transaction)s?|serialized(?:tx|transaction)s?)$/.test(c)&&!(t==="signature"&&i.includes(r)))throw new o("Wallet secrets and signed payloads are not accepted. Sign locally.");s&&typeof s=="object"&&a.push({value:s,path:r})}}}export{p as rejectWalletSecrets};
1
+ import{a as o}from"../chunks/Z3FZWNAJ.js";import"../chunks/XN4WDN3O.js";function p(n,i=[]){let a=[{value:n,path:""}];for(;a.length;){let e=a.pop();if(!(!e.value||typeof e.value!="object"))for(let[t,s]of Object.entries(e.value)){let r=e.path?`${e.path}.${t}`:t,c=t.replace(/[^a-z0-9]/gi,"").toLowerCase();if(/^(?:(?:private|secret|wallet)keys?|mnemonic(?:phrase|words)?|seed(?:phrase|words|hex)?|recovery(?:phrase|words)|passphrase|password|signatures?|(?:raw)?signed(?:tx|transaction)s?|raw(?:tx|transaction)s?|serialized(?:tx|transaction)s?)$/.test(c)&&!(t==="signature"&&i.includes(r)))throw new o("Wallet secrets and signed payloads are not accepted. Sign locally.");s&&typeof s=="object"&&a.push({value:s,path:r})}}}export{p as rejectWalletSecrets};
@@ -1 +1 @@
1
- import{a,b,c}from"../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 NATIVE_TOKEN_ADDRESS,c as createPreview,b as normalizeNativeTokenAddress};
1
+ import{a,b,c}from"../chunks/Z53DADZ4.js";import"../chunks/LIUXNOLP.js";import"../chunks/MEZH7RPA.js";import"../chunks/VBWJOG3N.js";import"../chunks/5HCXZWUH.js";import"../chunks/R5CBH2CR.js";import"../chunks/5BP72XOA.js";import"../chunks/XAB4OIE3.js";import"../chunks/7I6TXFXR.js";import"../chunks/Z3FZWNAJ.js";import"../chunks/XN4WDN3O.js";export{a as NATIVE_TOKEN_ADDRESS,c as createPreview,b as normalizeNativeTokenAddress};
@@ -73,6 +73,7 @@ export interface SwapQuote extends Quote {
73
73
  calldataMinAmountOut?: DecimalString;
74
74
  expectedSpend?: DecimalString;
75
75
  expectedRefund?: DecimalString;
76
+ priceImpact?: 'available' | 'unavailable';
76
77
  priceImpactBps?: string | null;
77
78
  priceImpactWarning?: string;
78
79
  }
@@ -107,7 +108,10 @@ export declare function assertQuoteBinding(quote: SwapQuote, accepted: SwapQuote
107
108
  export declare function resolveNowSeconds(now?: () => number): number;
108
109
  export declare function isNativeToken(token: Address): boolean;
109
110
  export declare function computeMinAmountOut(amountOut: DecimalString, slippageBps?: number): DecimalString;
110
- export declare function veloraCalldataMinimum(net: DecimalString): bigint;
111
+ export declare const MAX_VELORA_FEE_BPS = 200;
112
+ export declare function veloraVenueFeeBps(percent: unknown): number;
113
+ export declare function veloraCalldataMinimum(net: DecimalString, feeBps?: number): bigint;
114
+ export declare function assertVeloraPartnerAndFee(word: bigint, feeBps: number): void;
111
115
  export declare function formatVenueFeeDisclosure(params: {
112
116
  provider?: string;
113
117
  venueFee: DecimalString;
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y}from"../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{b as DEFAULT_SLIPPAGE_BPS,h as ExpiredQuoteError,i as MAX_RECENT_QUOTES,e as NATIVE_ETH_ADDRESS,g as NoRouteError,c as PRICE_IMPACT_WARNING_BPS,a as QUOTE_TTL_SECONDS,f as ZERO_ADDRESS,u as assertCalldataMinAmountOut,l as assertQuoteBinding,v as assertSwapTransaction,y as buildSwapFromQuote,o as computeMinAmountOut,j as copyQuote,t as decodeSwapMinAmountOut,r as encodeKyberSwapData,s as encodeVeloraSwapData,q as formatVenueFeeDisclosure,x as getQuote,n as isNativeToken,w as normalizeQuote,d as ponsCurveSwapAbi,m as resolveNowSeconds,k as snapshotQuote,p as veloraCalldataMinimum};
1
+ import{A,B,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunks/XEN45QST.js";import"../chunks/Z53DADZ4.js";import"../chunks/LIUXNOLP.js";import"../chunks/MEZH7RPA.js";import"../chunks/74X7PXPR.js";import"../chunks/VBWJOG3N.js";import"../chunks/5HCXZWUH.js";import"../chunks/R5CBH2CR.js";import"../chunks/5BP72XOA.js";import"../chunks/XAB4OIE3.js";import"../chunks/7I6TXFXR.js";import"../chunks/Z3FZWNAJ.js";import"../chunks/XN4WDN3O.js";export{b as DEFAULT_SLIPPAGE_BPS,h as ExpiredQuoteError,i as MAX_RECENT_QUOTES,p as MAX_VELORA_FEE_BPS,e as NATIVE_ETH_ADDRESS,g as NoRouteError,c as PRICE_IMPACT_WARNING_BPS,a as QUOTE_TTL_SECONDS,f as ZERO_ADDRESS,x as assertCalldataMinAmountOut,l as assertQuoteBinding,y as assertSwapTransaction,s as assertVeloraPartnerAndFee,B as buildSwapFromQuote,o as computeMinAmountOut,j as copyQuote,w as decodeSwapMinAmountOut,u as encodeKyberSwapData,v as encodeVeloraSwapData,t as formatVenueFeeDisclosure,A as getQuote,n as isNativeToken,z as normalizeQuote,d as ponsCurveSwapAbi,m as resolveNowSeconds,k as snapshotQuote,r as veloraCalldataMinimum,q as veloraVenueFeeBps};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"../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"../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{j as MULTICALL3_ABI,b as NATIVE_ETH_TOKEN,a as STOCK_ASSETS_URL,e as USDE_TOKEN,c as USDG_TOKEN,d as WETH_TOKEN,h as assertOfficialStockIdentity,i as fetchOfficialStockTokens,l as findToken,k as getBalances,f as parseOfficialStockAssets,m as resolveQuoteToken,g as verifyOfficialStockToken};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"../chunks/SXBGOGYQ.js";import"../chunks/UIJWIFGV.js";import"../chunks/B2LA6VVF.js";import"../chunks/NNJLMS7F.js";import"../chunks/XEN45QST.js";import"../chunks/Z53DADZ4.js";import"../chunks/LIUXNOLP.js";import"../chunks/MEZH7RPA.js";import"../chunks/TU3KHOZK.js";import"../chunks/74X7PXPR.js";import"../chunks/UB5U6SI2.js";import"../chunks/Z25UKUJF.js";import"../chunks/VBWJOG3N.js";import"../chunks/5HCXZWUH.js";import"../chunks/R5CBH2CR.js";import"../chunks/5BP72XOA.js";import"../chunks/XAB4OIE3.js";import"../chunks/7I6TXFXR.js";import"../chunks/Z3FZWNAJ.js";import"../chunks/XN4WDN3O.js";export{j as MULTICALL3_ABI,b as NATIVE_ETH_TOKEN,a as STOCK_ASSETS_URL,e as USDE_TOKEN,c as USDG_TOKEN,d as WETH_TOKEN,h as assertOfficialStockIdentity,i as fetchOfficialStockTokens,l as findToken,k as getBalances,f as parseOfficialStockAssets,m as resolveQuoteToken,g as verifyOfficialStockToken};
@@ -1 +1 @@
1
- import{a,b,c,d,e}from"../chunks/VZWOWR6G.js";import"../chunks/B5RZYFQC.js";import"../chunks/T5E4OJEU.js";import"../chunks/XN4WDN3O.js";export{c as approval,a as assertAddress,d as deposit,e as redeemAll,b as unsignedTx};
1
+ import{a,b,c,d,e}from"../chunks/VBWJOG3N.js";import"../chunks/7I6TXFXR.js";import"../chunks/Z3FZWNAJ.js";import"../chunks/XN4WDN3O.js";export{c as approval,a as assertAddress,d as deposit,e as redeemAll,b as unsignedTx};
@@ -41,6 +41,8 @@ export type ProjectStep = {
41
41
  export type ActionResult = {
42
42
  txs: UnsignedTx[];
43
43
  summary: string;
44
+ hashes?: string[];
45
+ status?: 'mined';
44
46
  } | {
45
47
  steps: ProjectStep[];
46
48
  continuation?: Record<string, unknown>;
@@ -49,6 +51,7 @@ export type ActionResult = {
49
51
  export interface SenderResult {
50
52
  hashes: string[];
51
53
  summary: string;
54
+ status?: 'submitted' | 'mined' | 'final' | 'not_submitted';
52
55
  }
53
56
  export type ToolResponse<T = unknown> = {
54
57
  ok: true;
@@ -1 +1 @@
1
- import{a,b,c}from"../chunks/64EN6Y7E.js";import"../chunks/T5E4OJEU.js";import"../chunks/XN4WDN3O.js";export{a as VendorBusyError,b as vendorBudget,c as vendorBusy};
1
+ import{a,b,c}from"../chunks/74X7PXPR.js";import"../chunks/Z3FZWNAJ.js";import"../chunks/XN4WDN3O.js";export{a as VendorBusyError,b as vendorBudget,c as vendorBusy};
@@ -1 +1 @@
1
- import{b as k,c as D,d as x}from"./KFMNCJXJ.js";import{a as V}from"./S3YSJ7XH.js";import{a as T}from"./VZWOWR6G.js";import{a as c,d as j,i as O}from"./25EOXUBI.js";import{a as X,b as W}from"./B5RZYFQC.js";import{a as s}from"./T5E4OJEU.js";import{encodeFunctionData as J,erc20Abi as G,getAddress as a,isAddress as ft,parseAbi as pt}from"viem";var kt="hookr",y=a(O[4663].hookr.HookrLimitOrders.address),gt=a(O[4663].hookr.HookrRoot.address),At=a(O[4663].hookr.HookrRouter.address),wt=a(O[4663].hookr.HookrForwarder.address),Ot=a(O[4663].hookr.PoolManager.address),Bt=a(O[4663].hookr.HOOKR_Token.address),L="0x0000000000000000000000000000000000000000",ht="0x000000000000000000000000000000000000dEaD",Q=(1n<<128n)-1n,It=new Set([L.toLowerCase(),ht.toLowerCase(),y.toLowerCase(),At.toLowerCase(),wt.toLowerCase(),Ot.toLowerCase(),gt.toLowerCase()]),B=pt(["function getOrder(uint256 orderId) view returns (((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, address owner, uint40 createdAt, uint40 expiry, bool zeroForOne, uint8 status, address recipient, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable, uint256 amountOut)","function bountyBounds((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut) view returns (uint128 minBounty, uint128 defaultBounty, uint128 maxBounty)","function fill(uint256 orderId) returns (uint256 amountOut)","function claimBounty(address to) returns (uint256 amount)","function bountyOf(address keeper) view returns (uint256)","function lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)"]);function St(t){let n=t.toLowerCase();return n===L.toLowerCase()||n===V.toLowerCase()}function Tt(t,n,i){let o=n.trim();if(o.startsWith("-")){let u=o.slice(1),r=t(u,i);return r==="0"?"0":`-${r}`}return t(o,i)}function Kt(t,n,i){return W(t,n,i)}function Y(t,n){return!t.changes||t.changes.length===0?"no net ERC-20/native transfer delta on caller":t.changes.map(i=>`${Tt(n,i.amount,i.token.decimals)} ${i.token.symbol} (${i.token.address})`).join(", ")}function $t(t){if(typeof t=="bigint"){if(t<=0n)throw new s("Hookr orderId must be a positive integer.");return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<=0)throw new s("Hookr orderId must be a positive integer.");return BigInt(t)}if(typeof t=="string"&&/^\d+$/.test(t.trim())){let n=BigInt(t.trim());if(n<=0n)throw new s("Hookr orderId must be a positive integer.");return n}throw new s("Provide a positive integer Hookr orderId.")}function tt(t){if(t==null)return c;if(typeof t!="number"||!Number.isSafeInteger(t)||t!==c)throw new s(`Hookr limit orders are only supported on chain ${c}.`);return c}function Ht(t){switch(t){case 0:return"None";case 1:return"Open";case 2:return"Filled";case 3:return"Cancelled";default:return"Unknown"}}function xt(t){if(Array.isArray(t)){let[n,i,o,u,r,d,g,m,b,e,l]=t;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:i,createdAt:o,expiry:u,zeroForOne:!!r,status:d,recipient:g,amountIn:BigInt(m),minAmountOut:BigInt(b),bounty:BigInt(e),sqrtPriceLimitX96:BigInt(l)}}if(t&&typeof t=="object"){let n=t;if(n.key&&typeof n.key=="object")return{key:{currency0:n.key.currency0,currency1:n.key.currency1,fee:Number(n.key.fee),tickSpacing:Number(n.key.tickSpacing),hooks:n.key.hooks},owner:n.owner,createdAt:n.createdAt,expiry:n.expiry,zeroForOne:!!n.zeroForOne,status:n.status,recipient:n.recipient,amountIn:BigInt(n.amountIn),minAmountOut:BigInt(n.minAmountOut),bounty:BigInt(n.bounty),sqrtPriceLimitX96:BigInt(n.sqrtPriceLimitX96)}}throw new s("HookrLimitOrders returned a malformed order tuple.")}function Rt(t){if(Array.isArray(t)&&t.length>=2)return{fillable:!!t[0],amountOut:BigInt(t[1])};if(t&&typeof t=="object"&&"fillable"in t&&"amountOut"in t){let n=t;return{fillable:!!n.fillable,amountOut:BigInt(n.amountOut)}}throw new s("HookrLimitOrders returned a malformed quoteFill response.")}function Ct(t){if(Array.isArray(t)&&t.length>=3)return{minBounty:BigInt(t[0]),defaultBounty:BigInt(t[1]),maxBounty:BigInt(t[2])};if(t&&typeof t=="object"&&"minBounty"in t&&"defaultBounty"in t&&"maxBounty"in t){let n=t;return{minBounty:BigInt(n.minBounty),defaultBounty:BigInt(n.defaultBounty),maxBounty:BigInt(n.maxBounty)}}throw new s("HookrLimitOrders returned a malformed bountyBounds response.")}async function Z(t,n,i=c){if(i!==c)throw new s(`Unsupported token chain ${i}; Hookr requires chain ${c}.`);if(St(n))return{...k,chainId:i};T(n);let o=a(n),u=o.toLowerCase();if(u===D.address.toLowerCase())return{address:o,symbol:D.symbol,decimals:j,chainId:i};if(u===x.address.toLowerCase())return{address:o,symbol:x.symbol,decimals:x.decimals,chainId:i};if(u===Bt.toLowerCase())return{address:o,symbol:"HOOKR",decimals:18,chainId:i};let[r,d]=await Promise.all([t.readContract({address:o,abi:G,functionName:"symbol"}),t.readContract({address:o,abi:G,functionName:"decimals"})]),g=typeof r=="string"&&r.trim()?r.trim():o,m=Number(d);if(!Number.isInteger(m)||m<0||m>255)throw new s(`Invalid token decimals for ${o} on chain ${i}.`);return{address:o,symbol:g,decimals:m,chainId:i}}async function Dt(t){if(typeof t.getBlock!="function")throw new s("Cannot read the latest block timestamp for Hookr order expiry.");let n=await t.getBlock().catch(()=>{throw new s("Cannot read the latest block timestamp for Hookr order expiry.")});if(!n||typeof n.timestamp!="bigint"||n.timestamp<=0n)throw new s("Hookr requires a usable latest block timestamp to check order expiry.");return n.timestamp}function P(t,n=[]){if(typeof t!="string"||!ft(t,{strict:!1}))throw new s("Provide a valid recipient wallet address.");let i=a(t),o=i.toLowerCase();if(It.has(o)||n.some(u=>u.toLowerCase()===o))throw new s(`Recipient ${i} is a reserved protocol or zero address (invalid recipient).`);return i}function nt(t){if(t.minBountyEth!==void 0||t.minAmountOutDecimal!==void 0||t.rounding!==void 0)throw new s("Use minBounty and minAmountOut as base-unit integer strings.")}function E(t,n){if(t!==void 0){if(typeof t!="string"||!/^\d+$/.test(t))throw new s(`Provide ${n} as a base-unit integer string.`);return X(t)}}function Pt(t){return{name:"hookr_fill",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"HookrLimitOrders orderId as a positive integer string."},minBounty:{type:"string",description:"Optional minimum keeper bounty in wei (decimal base-unit string)."},minAmountOut:{type:"string",description:"Optional quote pre-check only, in token base-unit integer strings. Not enforced on chain: fill(uint256) enforces only the order minAmountOut."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},required:["orderId"],additionalProperties:!1},async execute(n,i){try{nt(n),T(i);let o=a(i),u=tt(n.chainId),r=$t(n.orderId),d=t.clientFor(u),[g,m,b]=await Promise.all([d.readContract({address:y,abi:B,functionName:"getOrder",args:[r]}),d.readContract({address:y,abi:B,functionName:"quoteFill",args:[r]}),Dt(d)]),e=xt(g),l=Number(e.status),h=Ht(l);if(l===0||e.owner.toLowerCase()===L.toLowerCase())throw new s(`Hookr order #${r} does not exist.`);if(l!==1)throw new s(`Hookr order #${r} is not open (current status: ${h}).`);let A=BigInt(e.expiry);if(A<b)throw new s(`Hookr order #${r} is expired (expiry ${A} < current timestamp ${b}).`);let f=Number(e.key.tickSpacing),$=Number(e.key.fee);if(!Number.isInteger(f)||f<=0)throw new s(`Hookr order #${r} has an invalid pool tickSpacing (${f}).`);if(e.amountIn<=0n||e.amountIn>Q)throw new s(`Hookr order #${r} has an invalid amountIn (${e.amountIn}).`);if(e.minAmountOut<=0n||e.minAmountOut>Q)throw new s(`Hookr order #${r} has an invalid minAmountOut (${e.minAmountOut}).`);let R=a(e.key.hooks);P(e.recipient,[R]);let et=await d.readContract({address:y,abi:B,functionName:"bountyBounds",args:[{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:$,tickSpacing:f,hooks:R},e.zeroForOne,e.amountIn,e.minAmountOut]}),w=Ct(et),C=E(n.minBounty,"minBounty"),_=C!==void 0&&C>w.minBounty?C:w.minBounty;if(e.bounty<_)throw new s(`Hookr order #${r} is underbounty: order bounty (${e.bounty} wei) is below the required keeper bounty (${_} wei).`);if(e.bounty>w.maxBounty)throw new s(`Hookr order #${r} bounty (${e.bounty} wei) exceeds maximum bounty bound (${w.maxBounty} wei).`);let I=Rt(m),ot=e.zeroForOne?e.key.currency0:e.key.currency1,rt=e.zeroForOne?e.key.currency1:e.key.currency0,[H,p]=await Promise.all([Z(d,ot,u),Z(d,rt,u)]),S=E(n.minAmountOut,"minAmountOut"),F=S!==void 0&&S>e.minAmountOut?S:e.minAmountOut;if(!I.fillable||I.amountOut<=0n||I.amountOut<F)throw new s(`Hookr order #${r} is not executable: quoted output (${I.amountOut} base units of ${p.address}) does not meet minimum output (${F} base units).`);let it=J({abi:B,functionName:"fill",args:[r]}),st=t.formatAmount(e.amountIn.toString(),H.decimals),ut=t.formatAmount(I.amountOut.toString(),p.decimals),at=t.formatAmount(e.minAmountOut.toString(),p.decimals),mt=t.formatAmount(e.bounty.toString(),18),dt=S===void 0?"":` Caller minAmountOut ${S} base units is a quote pre-check only, not enforced on chain; fill(uint256) enforces the order minimum of ${e.minAmountOut} base units.`,v=`Fill Hookr order #${r}: maker's escrow pays ${st} ${H.symbol} (${e.amountIn} base units of ${H.address}); net output goes to ${a(e.recipient)} (quoted ${ut} ${p.symbol}, order minimum ${at} ${p.symbol}, ${e.minAmountOut} base units of ${p.address}). The filler sends no tokens or ETH (value 0), pays gas, and accrues ${mt} ETH (${e.bounty} wei) bounty to ${o}, payable only via claimBounty. Pool tickSpacing ${f}; expiry ${A} inclusive.${dt}`,q=t.unsignedTx({to:y,data:it,value:"0",chainId:u,description:v}),M=await t.preview([q],o),ct=Y(M,t.formatAmount),z={token:H,amount:e.amountIn.toString()},K={token:p,amount:e.minAmountOut.toString()},lt={token:p,amount:I.amountOut.toString()},U={token:{...k,chainId:u},amount:e.bounty.toString()},yt={orderId:r.toString(),key:{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:$,tickSpacing:f,hooks:R},owner:a(e.owner),recipient:a(e.recipient),createdAt:BigInt(e.createdAt).toString(),expiry:A.toString(),zeroForOne:e.zeroForOne,status:l,statusLabel:h,amountIn:z,minAmountOut:K,bounty:U,sqrtPriceLimitX96:e.sqrtPriceLimitX96.toString()},bt={minBounty:{token:{...k,chainId:u},amount:w.minBounty.toString()},defaultBounty:{token:{...k,chainId:u},amount:w.defaultBounty.toString()},maxBounty:{token:{...k,chainId:u},amount:w.maxBounty.toString()}};return{txs:[q],summary:`${v} Preview deltas: ${ct}.`,preview:M,orderId:r.toString(),fillable:!0,amountIn:z,minAmountOut:K,quotedAmountOut:lt,bounty:U,bountyBounds:bt,order:yt}}catch(o){throw new s(t.plainError(o))}}}}function Et(t){return{name:"hookr_claim_bounty",inputSchema:{type:"object",properties:{to:{type:"string",description:"Optional recipient address for the claimed native ETH bounty (must be the signing wallet)."},minBounty:{type:"string",description:"Optional minimum claimable bounty in wei (decimal base-unit string)."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},additionalProperties:!1},async execute(n,i){try{nt(n),T(i);let o=a(i),u=tt(n.chainId),r=n.to!==void 0&&n.to!==null?P(String(n.to)):P(o);if(r!==o)throw new s("Hookr bounty recipient must be the signing wallet.");let g=await t.clientFor(u).readContract({address:y,abi:B,functionName:"bountyOf",args:[o]}),m=BigInt(g);if(m<=0n)throw new s(`No claimable Hookr keeper bounty for ${o}.`);let b=E(n.minBounty,"minBounty");if(b!==void 0&&m<b)throw new s(`Claimable Hookr bounty (${m} wei) is below the requested minimum (${b} wei).`);let e=J({abi:B,functionName:"claimBounty",args:[r]}),l=t.formatAmount(m.toString(),18),h=t.unsignedTx({to:y,data:e,value:"0",chainId:u,description:`Claim ${l} ETH (${m} wei) of accrued Hookr keeper bounty from ${y} to ${r}.`}),A=await t.preview([h],o),f=Y(A,t.formatAmount),$={token:{...k,chainId:u},amount:m.toString()};return{txs:[h],summary:`Claim ${l} ETH (${m} wei) Hookr keeper bounty to ${r}. Preview deltas: ${f}.`,preview:A,recipient:r,claimableBounty:$}}catch(o){throw new s(t.plainError(o))}}}}async function Lt(t,n){T(n);let i=a(n),o=t.clientFor(c);try{let u=await o.readContract({address:y,abi:B,functionName:"bountyOf",args:[i]}),r=BigInt(u);if(r<=0n)return[];let d=t.formatAmount(r.toString(),18);return[{module:kt,id:`hookr:bounty:${i.toLowerCase()}`,chainId:c,assets:[{token:{...k,chainId:c},amount:r.toString()}],description:`Hookr claimable keeper bounty (${d} ETH)`}]}catch(u){throw new s(t.plainError(u))}}var N=t=>({tools:[Pt(t),Et(t)],positions:n=>Lt(t,n)}),Ut=N,jt=N,Xt=N;export{kt as a,y as b,gt as c,At as d,wt as e,Ot as f,Bt as g,B as h,Tt as i,Kt as j,Pt as k,Et as l,Lt as m,N as n,Ut as o,jt as p,Xt as q};
1
+ import{b as k,c as D,d as x}from"./SXBGOGYQ.js";import{a as V}from"./Z53DADZ4.js";import{a as T}from"./VBWJOG3N.js";import{a as c,d as j,i as O}from"./5BP72XOA.js";import{a as X,b as W}from"./7I6TXFXR.js";import{a as s}from"./Z3FZWNAJ.js";import{encodeFunctionData as J,erc20Abi as G,getAddress as a,isAddress as ft,parseAbi as pt}from"viem";var kt="hookr",y=a(O[4663].hookr.HookrLimitOrders.address),gt=a(O[4663].hookr.HookrRoot.address),At=a(O[4663].hookr.HookrRouter.address),wt=a(O[4663].hookr.HookrForwarder.address),Ot=a(O[4663].hookr.PoolManager.address),Bt=a(O[4663].hookr.HOOKR_Token.address),L="0x0000000000000000000000000000000000000000",ht="0x000000000000000000000000000000000000dEaD",Q=(1n<<128n)-1n,It=new Set([L.toLowerCase(),ht.toLowerCase(),y.toLowerCase(),At.toLowerCase(),wt.toLowerCase(),Ot.toLowerCase(),gt.toLowerCase()]),B=pt(["function getOrder(uint256 orderId) view returns (((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, address owner, uint40 createdAt, uint40 expiry, bool zeroForOne, uint8 status, address recipient, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable, uint256 amountOut)","function bountyBounds((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut) view returns (uint128 minBounty, uint128 defaultBounty, uint128 maxBounty)","function fill(uint256 orderId) returns (uint256 amountOut)","function claimBounty(address to) returns (uint256 amount)","function bountyOf(address keeper) view returns (uint256)","function lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)"]);function St(t){let n=t.toLowerCase();return n===L.toLowerCase()||n===V.toLowerCase()}function Tt(t,n,i){let o=n.trim();if(o.startsWith("-")){let u=o.slice(1),r=t(u,i);return r==="0"?"0":`-${r}`}return t(o,i)}function Kt(t,n,i){return W(t,n,i)}function Y(t,n){return!t.changes||t.changes.length===0?"no net ERC-20/native transfer delta on caller":t.changes.map(i=>`${Tt(n,i.amount,i.token.decimals)} ${i.token.symbol} (${i.token.address})`).join(", ")}function $t(t){if(typeof t=="bigint"){if(t<=0n)throw new s("Hookr orderId must be a positive integer.");return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<=0)throw new s("Hookr orderId must be a positive integer.");return BigInt(t)}if(typeof t=="string"&&/^\d+$/.test(t.trim())){let n=BigInt(t.trim());if(n<=0n)throw new s("Hookr orderId must be a positive integer.");return n}throw new s("Provide a positive integer Hookr orderId.")}function tt(t){if(t==null)return c;if(typeof t!="number"||!Number.isSafeInteger(t)||t!==c)throw new s(`Hookr limit orders are only supported on chain ${c}.`);return c}function Ht(t){switch(t){case 0:return"None";case 1:return"Open";case 2:return"Filled";case 3:return"Cancelled";default:return"Unknown"}}function xt(t){if(Array.isArray(t)){let[n,i,o,u,r,d,g,m,b,e,l]=t;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:i,createdAt:o,expiry:u,zeroForOne:!!r,status:d,recipient:g,amountIn:BigInt(m),minAmountOut:BigInt(b),bounty:BigInt(e),sqrtPriceLimitX96:BigInt(l)}}if(t&&typeof t=="object"){let n=t;if(n.key&&typeof n.key=="object")return{key:{currency0:n.key.currency0,currency1:n.key.currency1,fee:Number(n.key.fee),tickSpacing:Number(n.key.tickSpacing),hooks:n.key.hooks},owner:n.owner,createdAt:n.createdAt,expiry:n.expiry,zeroForOne:!!n.zeroForOne,status:n.status,recipient:n.recipient,amountIn:BigInt(n.amountIn),minAmountOut:BigInt(n.minAmountOut),bounty:BigInt(n.bounty),sqrtPriceLimitX96:BigInt(n.sqrtPriceLimitX96)}}throw new s("HookrLimitOrders returned a malformed order tuple.")}function Rt(t){if(Array.isArray(t)&&t.length>=2)return{fillable:!!t[0],amountOut:BigInt(t[1])};if(t&&typeof t=="object"&&"fillable"in t&&"amountOut"in t){let n=t;return{fillable:!!n.fillable,amountOut:BigInt(n.amountOut)}}throw new s("HookrLimitOrders returned a malformed quoteFill response.")}function Ct(t){if(Array.isArray(t)&&t.length>=3)return{minBounty:BigInt(t[0]),defaultBounty:BigInt(t[1]),maxBounty:BigInt(t[2])};if(t&&typeof t=="object"&&"minBounty"in t&&"defaultBounty"in t&&"maxBounty"in t){let n=t;return{minBounty:BigInt(n.minBounty),defaultBounty:BigInt(n.defaultBounty),maxBounty:BigInt(n.maxBounty)}}throw new s("HookrLimitOrders returned a malformed bountyBounds response.")}async function Z(t,n,i=c){if(i!==c)throw new s(`Unsupported token chain ${i}; Hookr requires chain ${c}.`);if(St(n))return{...k,chainId:i};T(n);let o=a(n),u=o.toLowerCase();if(u===D.address.toLowerCase())return{address:o,symbol:D.symbol,decimals:j,chainId:i};if(u===x.address.toLowerCase())return{address:o,symbol:x.symbol,decimals:x.decimals,chainId:i};if(u===Bt.toLowerCase())return{address:o,symbol:"HOOKR",decimals:18,chainId:i};let[r,d]=await Promise.all([t.readContract({address:o,abi:G,functionName:"symbol"}),t.readContract({address:o,abi:G,functionName:"decimals"})]),g=typeof r=="string"&&r.trim()?r.trim():o,m=Number(d);if(!Number.isInteger(m)||m<0||m>255)throw new s(`Invalid token decimals for ${o} on chain ${i}.`);return{address:o,symbol:g,decimals:m,chainId:i}}async function Dt(t){if(typeof t.getBlock!="function")throw new s("Cannot read the latest block timestamp for Hookr order expiry.");let n=await t.getBlock().catch(()=>{throw new s("Cannot read the latest block timestamp for Hookr order expiry.")});if(!n||typeof n.timestamp!="bigint"||n.timestamp<=0n)throw new s("Hookr requires a usable latest block timestamp to check order expiry.");return n.timestamp}function P(t,n=[]){if(typeof t!="string"||!ft(t,{strict:!1}))throw new s("Provide a valid recipient wallet address.");let i=a(t),o=i.toLowerCase();if(It.has(o)||n.some(u=>u.toLowerCase()===o))throw new s(`Recipient ${i} is a reserved protocol or zero address (invalid recipient).`);return i}function nt(t){if(t.minBountyEth!==void 0||t.minAmountOutDecimal!==void 0||t.rounding!==void 0)throw new s("Use minBounty and minAmountOut as base-unit integer strings.")}function E(t,n){if(t!==void 0){if(typeof t!="string"||!/^\d+$/.test(t))throw new s(`Provide ${n} as a base-unit integer string.`);return X(t)}}function Pt(t){return{name:"hookr_fill",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"HookrLimitOrders orderId as a positive integer string."},minBounty:{type:"string",description:"Optional minimum keeper bounty in wei (decimal base-unit string)."},minAmountOut:{type:"string",description:"Optional quote pre-check only, in token base-unit integer strings. Not enforced on chain: fill(uint256) enforces only the order minAmountOut."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},required:["orderId"],additionalProperties:!1},async execute(n,i){try{nt(n),T(i);let o=a(i),u=tt(n.chainId),r=$t(n.orderId),d=t.clientFor(u),[g,m,b]=await Promise.all([d.readContract({address:y,abi:B,functionName:"getOrder",args:[r]}),d.readContract({address:y,abi:B,functionName:"quoteFill",args:[r]}),Dt(d)]),e=xt(g),l=Number(e.status),h=Ht(l);if(l===0||e.owner.toLowerCase()===L.toLowerCase())throw new s(`Hookr order #${r} does not exist.`);if(l!==1)throw new s(`Hookr order #${r} is not open (current status: ${h}).`);let A=BigInt(e.expiry);if(A<b)throw new s(`Hookr order #${r} is expired (expiry ${A} < current timestamp ${b}).`);let f=Number(e.key.tickSpacing),$=Number(e.key.fee);if(!Number.isInteger(f)||f<=0)throw new s(`Hookr order #${r} has an invalid pool tickSpacing (${f}).`);if(e.amountIn<=0n||e.amountIn>Q)throw new s(`Hookr order #${r} has an invalid amountIn (${e.amountIn}).`);if(e.minAmountOut<=0n||e.minAmountOut>Q)throw new s(`Hookr order #${r} has an invalid minAmountOut (${e.minAmountOut}).`);let R=a(e.key.hooks);P(e.recipient,[R]);let et=await d.readContract({address:y,abi:B,functionName:"bountyBounds",args:[{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:$,tickSpacing:f,hooks:R},e.zeroForOne,e.amountIn,e.minAmountOut]}),w=Ct(et),C=E(n.minBounty,"minBounty"),_=C!==void 0&&C>w.minBounty?C:w.minBounty;if(e.bounty<_)throw new s(`Hookr order #${r} is underbounty: order bounty (${e.bounty} wei) is below the required keeper bounty (${_} wei).`);if(e.bounty>w.maxBounty)throw new s(`Hookr order #${r} bounty (${e.bounty} wei) exceeds maximum bounty bound (${w.maxBounty} wei).`);let I=Rt(m),ot=e.zeroForOne?e.key.currency0:e.key.currency1,rt=e.zeroForOne?e.key.currency1:e.key.currency0,[H,p]=await Promise.all([Z(d,ot,u),Z(d,rt,u)]),S=E(n.minAmountOut,"minAmountOut"),F=S!==void 0&&S>e.minAmountOut?S:e.minAmountOut;if(!I.fillable||I.amountOut<=0n||I.amountOut<F)throw new s(`Hookr order #${r} is not executable: quoted output (${I.amountOut} base units of ${p.address}) does not meet minimum output (${F} base units).`);let it=J({abi:B,functionName:"fill",args:[r]}),st=t.formatAmount(e.amountIn.toString(),H.decimals),ut=t.formatAmount(I.amountOut.toString(),p.decimals),at=t.formatAmount(e.minAmountOut.toString(),p.decimals),mt=t.formatAmount(e.bounty.toString(),18),dt=S===void 0?"":` Caller minAmountOut ${S} base units is a quote pre-check only, not enforced on chain; fill(uint256) enforces the order minimum of ${e.minAmountOut} base units.`,v=`Fill Hookr order #${r}: maker's escrow pays ${st} ${H.symbol} (${e.amountIn} base units of ${H.address}); net output goes to ${a(e.recipient)} (quoted ${ut} ${p.symbol}, order minimum ${at} ${p.symbol}, ${e.minAmountOut} base units of ${p.address}). The filler sends no tokens or ETH (value 0), pays gas, and accrues ${mt} ETH (${e.bounty} wei) bounty to ${o}, payable only via claimBounty. Pool tickSpacing ${f}; expiry ${A} inclusive.${dt}`,q=t.unsignedTx({to:y,data:it,value:"0",chainId:u,description:v}),M=await t.preview([q],o),ct=Y(M,t.formatAmount),z={token:H,amount:e.amountIn.toString()},K={token:p,amount:e.minAmountOut.toString()},lt={token:p,amount:I.amountOut.toString()},U={token:{...k,chainId:u},amount:e.bounty.toString()},yt={orderId:r.toString(),key:{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:$,tickSpacing:f,hooks:R},owner:a(e.owner),recipient:a(e.recipient),createdAt:BigInt(e.createdAt).toString(),expiry:A.toString(),zeroForOne:e.zeroForOne,status:l,statusLabel:h,amountIn:z,minAmountOut:K,bounty:U,sqrtPriceLimitX96:e.sqrtPriceLimitX96.toString()},bt={minBounty:{token:{...k,chainId:u},amount:w.minBounty.toString()},defaultBounty:{token:{...k,chainId:u},amount:w.defaultBounty.toString()},maxBounty:{token:{...k,chainId:u},amount:w.maxBounty.toString()}};return{txs:[q],summary:`${v} Preview deltas: ${ct}.`,preview:M,orderId:r.toString(),fillable:!0,amountIn:z,minAmountOut:K,quotedAmountOut:lt,bounty:U,bountyBounds:bt,order:yt}}catch(o){throw new s(t.plainError(o))}}}}function Et(t){return{name:"hookr_claim_bounty",inputSchema:{type:"object",properties:{to:{type:"string",description:"Optional recipient address for the claimed native ETH bounty (must be the signing wallet)."},minBounty:{type:"string",description:"Optional minimum claimable bounty in wei (decimal base-unit string)."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},additionalProperties:!1},async execute(n,i){try{nt(n),T(i);let o=a(i),u=tt(n.chainId),r=n.to!==void 0&&n.to!==null?P(String(n.to)):P(o);if(r!==o)throw new s("Hookr bounty recipient must be the signing wallet.");let g=await t.clientFor(u).readContract({address:y,abi:B,functionName:"bountyOf",args:[o]}),m=BigInt(g);if(m<=0n)throw new s(`No claimable Hookr keeper bounty for ${o}.`);let b=E(n.minBounty,"minBounty");if(b!==void 0&&m<b)throw new s(`Claimable Hookr bounty (${m} wei) is below the requested minimum (${b} wei).`);let e=J({abi:B,functionName:"claimBounty",args:[r]}),l=t.formatAmount(m.toString(),18),h=t.unsignedTx({to:y,data:e,value:"0",chainId:u,description:`Claim ${l} ETH (${m} wei) of accrued Hookr keeper bounty from ${y} to ${r}.`}),A=await t.preview([h],o),f=Y(A,t.formatAmount),$={token:{...k,chainId:u},amount:m.toString()};return{txs:[h],summary:`Claim ${l} ETH (${m} wei) Hookr keeper bounty to ${r}. Preview deltas: ${f}.`,preview:A,recipient:r,claimableBounty:$}}catch(o){throw new s(t.plainError(o))}}}}async function Lt(t,n){T(n);let i=a(n),o=t.clientFor(c);try{let u=await o.readContract({address:y,abi:B,functionName:"bountyOf",args:[i]}),r=BigInt(u);if(r<=0n)return[];let d=t.formatAmount(r.toString(),18);return[{module:kt,id:`hookr:bounty:${i.toLowerCase()}`,chainId:c,assets:[{token:{...k,chainId:c},amount:r.toString()}],description:`Hookr claimable keeper bounty (${d} ETH)`}]}catch(u){throw new s(t.plainError(u))}}var N=t=>({tools:[Pt(t),Et(t)],positions:n=>Lt(t,n)}),Ut=N,jt=N,Xt=N;export{kt as a,y as b,gt as c,At as d,wt as e,Ot as f,Bt as g,B as h,Tt as i,Kt as j,Pt as k,Et as l,Lt as m,N as n,Ut as o,jt as p,Xt as q};