@oakagentkit/core 0.1.9 → 0.2.0

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 (171) hide show
  1. package/build/dist/api/deployments.d.ts +26 -0
  2. package/build/dist/api/deployments.js +1 -0
  3. package/build/dist/api/history.js +1 -1
  4. package/build/dist/api/modules/beefy/clm.js +1 -1
  5. package/build/dist/api/modules/beefy/guard.js +1 -1
  6. package/build/dist/api/modules/beefy/index.js +1 -1
  7. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  8. package/build/dist/api/modules/clanker/index.js +1 -1
  9. package/build/dist/api/modules/grove/index.js +1 -1
  10. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  11. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  12. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  13. package/build/dist/api/modules/hoodlock/index.js +1 -1
  14. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  15. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  16. package/build/dist/api/modules/hoodlock/public.js +1 -1
  17. package/build/dist/api/modules/hookr/actions.js +1 -1
  18. package/build/dist/api/modules/hookr/addons.js +1 -1
  19. package/build/dist/api/modules/hookr/contracts.js +1 -1
  20. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  21. package/build/dist/api/modules/hookr/discovery.js +1 -1
  22. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  23. package/build/dist/api/modules/hookr/index.js +1 -1
  24. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  25. package/build/dist/api/modules/hookr/relay.js +1 -1
  26. package/build/dist/api/modules/kyberswap/index.js +1 -1
  27. package/build/dist/api/modules/kyberswap/source-pools.d.ts +22 -3
  28. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  29. package/build/dist/api/modules/longbow/administration.js +1 -1
  30. package/build/dist/api/modules/longbow/fixed.js +1 -1
  31. package/build/dist/api/modules/longbow/index.js +1 -1
  32. package/build/dist/api/modules/meridian/index.js +1 -1
  33. package/build/dist/api/modules/meridian/rfq.js +1 -1
  34. package/build/dist/api/modules/morpho/bundles.js +1 -1
  35. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  36. package/build/dist/api/modules/morpho/index.js +1 -1
  37. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  38. package/build/dist/api/modules/morpho/midnight.js +1 -1
  39. package/build/dist/api/modules/morpho/protocol.js +1 -1
  40. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  41. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  42. package/build/dist/api/modules/netnet/card-read.js +1 -1
  43. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  44. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  45. package/build/dist/api/modules/netnet/financial.js +1 -1
  46. package/build/dist/api/modules/netnet/index.js +1 -1
  47. package/build/dist/api/modules/orbio/index.js +1 -1
  48. package/build/dist/api/modules/pons/claim.js +1 -1
  49. package/build/dist/api/modules/pons/index.js +1 -1
  50. package/build/dist/api/modules/pons/launch-status.js +1 -1
  51. package/build/dist/api/modules/pons/reads.js +1 -1
  52. package/build/dist/api/modules/pons/trade.js +1 -1
  53. package/build/dist/api/modules/poolstrade/index.js +1 -1
  54. package/build/dist/api/modules/priors/index.js +1 -1
  55. package/build/dist/api/modules/relay/discovery.js +1 -1
  56. package/build/dist/api/modules/relay/inbound.js +1 -1
  57. package/build/dist/api/modules/relay/index.js +1 -1
  58. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  59. package/build/dist/api/modules/steakhouse/index.js +1 -1
  60. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  61. package/build/dist/api/modules/steakhouse/management.js +1 -1
  62. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  63. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  64. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  65. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  66. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  67. package/build/dist/api/modules/tickerspring/index.js +1 -1
  68. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  69. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  70. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  71. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  72. package/build/dist/api/modules/tickerspring/research.js +1 -1
  73. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  74. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  75. package/build/dist/api/modules/uniswap/auction.js +1 -1
  76. package/build/dist/api/modules/uniswap/batch.js +1 -1
  77. package/build/dist/api/modules/uniswap/common.js +1 -1
  78. package/build/dist/api/modules/uniswap/fees.js +1 -1
  79. package/build/dist/api/modules/uniswap/index.js +1 -1
  80. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  81. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  82. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  83. package/build/dist/api/modules/uniswap/pools.js +1 -1
  84. package/build/dist/api/modules/uniswap/position.js +1 -1
  85. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  86. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  87. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  88. package/build/dist/api/modules/uniswap/trade.js +1 -1
  89. package/build/dist/api/modules/uniswap/v2.js +1 -1
  90. package/build/dist/api/modules/uniswap/v3.js +1 -1
  91. package/build/dist/api/modules/uniswap/v4.js +1 -1
  92. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  93. package/build/dist/api/modules/velora/claims.js +1 -1
  94. package/build/dist/api/modules/velora/index.js +1 -1
  95. package/build/dist/api/prices.js +1 -1
  96. package/build/dist/api/routes.d.ts +2 -0
  97. package/build/dist/api/routes.js +1 -1
  98. package/build/dist/api/send.js +1 -1
  99. package/build/dist/api/signing-registry.js +1 -1
  100. package/build/dist/api/simulate.js +1 -1
  101. package/build/dist/api/swap.js +1 -1
  102. package/build/dist/api/tokens.js +1 -1
  103. package/build/dist/chunks/{QOY4AANB.js → 2SNQWKHA.js} +1 -1
  104. package/build/dist/chunks/{FYTF2QMS.js → 3ACEWCKZ.js} +1 -1
  105. package/build/dist/chunks/{HZUWK5B2.js → 46ZA2R5L.js} +1 -1
  106. package/build/dist/chunks/{W6G2QGYF.js → 4IPW5WZ4.js} +1 -1
  107. package/build/dist/chunks/{JRZLKIYB.js → 55NX776C.js} +1 -1
  108. package/build/dist/chunks/{2EGFALNH.js → 5FTSKYQH.js} +1 -1
  109. package/build/dist/chunks/{OJP7Y4AM.js → 5HW6JKME.js} +1 -1
  110. package/build/dist/chunks/{ZL3KVABO.js → 5VXNQFYJ.js} +1 -1
  111. package/build/dist/chunks/{ITIIHCZK.js → 64AF7ECA.js} +1 -1
  112. package/build/dist/chunks/{FLXID6I3.js → 6LLOTPH2.js} +1 -1
  113. package/build/dist/chunks/{CXMC3T6B.js → 6PU2CMQZ.js} +1 -1
  114. package/build/dist/chunks/{E2IVNGLC.js → 7BTELNNI.js} +1 -1
  115. package/build/dist/chunks/{C5LR6F4B.js → 7T4BYFD4.js} +1 -1
  116. package/build/dist/chunks/{6SB3FB3P.js → 7Z5IM2QZ.js} +1 -1
  117. package/build/dist/chunks/{JOMK32QW.js → A25P24G2.js} +1 -1
  118. package/build/dist/chunks/{FL3EF72E.js → ANQ43XJA.js} +1 -1
  119. package/build/dist/chunks/{B72Q2EQ2.js → BFVLBENV.js} +1 -1
  120. package/build/dist/chunks/{QH3AL3UN.js → BV3AHLH5.js} +1 -1
  121. package/build/dist/chunks/{EKGHKEKV.js → BXN3MDS4.js} +1 -1
  122. package/build/dist/chunks/CAU44UWP.js +1 -0
  123. package/build/dist/chunks/{HACP2Q6D.js → D6VP3N27.js} +2 -2
  124. package/build/dist/chunks/{37QNUNED.js → DLIOZCEG.js} +1 -1
  125. package/build/dist/chunks/EA6IYKIB.js +1 -0
  126. package/build/dist/chunks/{SYZ55RCX.js → EYYUWFUR.js} +1 -1
  127. package/build/dist/chunks/{HF2AGJZC.js → FSPNOVKB.js} +1 -1
  128. package/build/dist/chunks/G4PDM3MX.js +1 -0
  129. package/build/dist/chunks/{ZPNGV34U.js → GHDDVBPK.js} +1 -1
  130. package/build/dist/chunks/{OK3TQFXZ.js → GSI5COTD.js} +1 -1
  131. package/build/dist/chunks/{CAYBSVA6.js → HRG2VVPY.js} +1 -1
  132. package/build/dist/chunks/{MWWYIFXJ.js → ITV52TIE.js} +1 -1
  133. package/build/dist/chunks/{4CDR7F4I.js → IUXOUKQN.js} +1 -1
  134. package/build/dist/chunks/{5H3MQWH7.js → JC4SYMBV.js} +1 -1
  135. package/build/dist/chunks/{KEPQXFHU.js → JREVERSC.js} +1 -1
  136. package/build/dist/chunks/{NUWL6TJM.js → K463HFGC.js} +1 -1
  137. package/build/dist/chunks/{VCWDJQDE.js → KQFDLDHL.js} +1 -1
  138. package/build/dist/chunks/{LFKSXD3S.js → LI7FYINH.js} +1 -1
  139. package/build/dist/chunks/{4X6JEMSF.js → N6RL3SUZ.js} +1 -1
  140. package/build/dist/chunks/{E7ASOYQI.js → NBRMUFJP.js} +1 -1
  141. package/build/dist/chunks/{UEYFMXV3.js → NIOBE2LK.js} +1 -1
  142. package/build/dist/chunks/NMFVXBTL.js +1 -0
  143. package/build/dist/chunks/{REGJY5RC.js → NO57NGRV.js} +1 -1
  144. package/build/dist/chunks/{SEW7UP5U.js → O5SU2I3G.js} +1 -1
  145. package/build/dist/chunks/{P6ELT4ZV.js → PJ65ZOQ7.js} +1 -1
  146. package/build/dist/chunks/{B7V7AA5A.js → QCD33HMD.js} +1 -1
  147. package/build/dist/chunks/{SS7U3CMZ.js → QQWF6A4P.js} +1 -1
  148. package/build/dist/chunks/{NNZ4SZZ4.js → QZM7CWZW.js} +1 -1
  149. package/build/dist/chunks/{HYIEQG4X.js → QZTUMSQY.js} +1 -1
  150. package/build/dist/chunks/{JVTVOK6P.js → R7D256HG.js} +1 -1
  151. package/build/dist/chunks/{Z4LJ2GTX.js → RTBOMWCB.js} +1 -1
  152. package/build/dist/chunks/{EHVPRQHS.js → SDICP7BT.js} +1 -1
  153. package/build/dist/chunks/{L2MTPRU7.js → T3NPRRTY.js} +1 -1
  154. package/build/dist/chunks/{BQLLTY4L.js → TNRDCBGO.js} +1 -1
  155. package/build/dist/chunks/{IKP3Z3RX.js → U3FMCX3L.js} +1 -1
  156. package/build/dist/chunks/{WHT45EFX.js → UIIJWIR6.js} +1 -1
  157. package/build/dist/chunks/{K2LWX3PZ.js → UMK564HS.js} +1 -1
  158. package/build/dist/chunks/{AIWZGIZ6.js → UPPYXY74.js} +1 -1
  159. package/build/dist/chunks/{XCFA73P2.js → VJ3W2V3B.js} +1 -1
  160. package/build/dist/chunks/{RNEMTLQG.js → VY3P34PY.js} +1 -1
  161. package/build/dist/chunks/{2LM5C7FQ.js → WDGPCPQJ.js} +1 -1
  162. package/build/dist/chunks/{PHXWBC4O.js → XKRWJCYE.js} +1 -1
  163. package/build/dist/chunks/{E2Q5IA67.js → Y2IWPNEW.js} +1 -1
  164. package/build/dist/chunks/{YONRUWN7.js → ZCGVBK5K.js} +1 -1
  165. package/build/dist/chunks/{BBQVTEYB.js → ZGXNTWYG.js} +1 -1
  166. package/build/dist/chunks/{CS55ERS3.js → ZYR5LSVB.js} +1 -1
  167. package/package.json +1 -1
  168. package/build/dist/chunks/2O6A6WEX.js +0 -1
  169. package/build/dist/chunks/3Z3U4YPA.js +0 -1
  170. package/build/dist/chunks/EAEQOS7Y.js +0 -1
  171. package/build/dist/chunks/ZQI7B2Z7.js +0 -1
@@ -1 +1 @@
1
- import{a as S,b as D,c as H}from"./SYZ55RCX.js";import{a as O}from"./XCFA73P2.js";import{a as C}from"./UWOFA6GV.js";import{c as _,f as I}from"./73N3TOJL.js";import{a as d}from"./XPFVT2EA.js";import{a as r}from"./5YS5V2LK.js";import{encodeFunctionData as T,erc20Abi as L,getAddress as c,parseAbi as q,zeroAddress as M}from"viem";var k={timeShares:{factory:"timeFactory",abi:[{name:"SCALE",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_ASSETS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MIN_LOCK_DAYS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint32"}]},{name:"MAX_LOCK_DAYS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint32"}]},{name:"FOREVER",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint32"}]},{name:"MAX_LOCK_AMOUNT",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MIN_LOCK_DIVISOR",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"minLockAmount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_TIP_BPS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint16"}]},{name:"MIN_TIP_GROWTH",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_ISSUE_DAYS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_CLAIM_DAYS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"token",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"tipBps",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint16"}]},{name:"tipCap",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"assetCount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"currencyAt",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"address"}]},{name:"lockedTotal",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"pendingLocks",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256",name:"amount"},{type:"uint256",name:"tick"},{type:"uint256",name:"firstLock"}]},{name:"nextDrop",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"heldAt",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"blockNumber"}],outputs:[{type:"uint256"}]},{name:"lockEpochs",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"lockId"}],outputs:[{type:"uint256",name:"joinEpoch"},{type:"uint256",name:"leaveEpoch"}]},{name:"sweepable",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"from"},{type:"uint256",name:"max"}],outputs:[{type:"uint256[]",name:"ids"},{type:"uint256",name:"next"}]},{name:"lockCount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"lockAt",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"lockId"}],outputs:[{type:"tuple",components:[{type:"address",name:"owner"},{type:"uint64",name:"lockedAt"},{type:"uint32",name:"firstDay"},{type:"uint128",name:"amount"},{type:"uint32",name:"lastDay"},{type:"uint64",name:"unlockedAt"}]}]},{name:"isIssued",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"lockId"},{type:"uint256",name:"day"}],outputs:[{type:"bool"}]},{name:"unitSupply",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"day"}],outputs:[{type:"uint256"}]},{name:"currentDay",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"pointCount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"pointAt",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"k"}],outputs:[{type:"uint64",name:"timestamp"},{type:"uint256[]",name:"indexes"}]},{name:"index",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"carry",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"pulled",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"paid",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"held",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"dayIndex",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"day"},{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"claimable",type:"function",stateMutability:"view",inputs:[{type:"address",name:"holder"},{type:"uint256",name:"day"},{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"lockClaimable",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"lockId"},{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"lock",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"amount"},{type:"uint32",name:"numberOfDays"}],outputs:[{type:"uint256",name:"lockId"}]},{name:"issue",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"lockId"},{type:"uint256",name:"day"},{type:"address",name:"to"}],outputs:[]},{name:"issueRange",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"lockId"},{type:"uint256",name:"firstDay"},{type:"uint256",name:"lastDay"},{type:"address",name:"to"}],outputs:[]},{name:"unlock",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"lockId"},{type:"address",name:"to"}],outputs:[]},{name:"syncAssets",type:"function",stateMutability:"nonpayable",inputs:[],outputs:[]},{name:"catchUp",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"max"}],outputs:[{type:"bool",name:"done"}]},{name:"settle",type:"function",stateMutability:"nonpayable",inputs:[],outputs:[]},{name:"roll",type:"function",stateMutability:"nonpayable",inputs:[],outputs:[{type:"uint256",name:"tip"}]},{name:"sweepDrops",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256[]",name:"dropIds"},{type:"uint256",name:"claimGas"}],outputs:[{type:"uint256[]",name:"amounts"}]},{name:"claim",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"day"},{type:"uint256",name:"asset"},{type:"address",name:"to"}],outputs:[{type:"uint256",name:"amount"}]},{name:"claimMany",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256[]",name:"days_"},{type:"uint256",name:"asset"},{type:"address",name:"to"}],outputs:[{type:"uint256",name:"amount"}]},{name:"claimLock",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"lockId"},{type:"uint256",name:"asset"},{type:"address",name:"to"}],outputs:[{type:"uint256",name:"amount"}]},{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{type:"address",name:"owner"},{type:"uint256",name:"id"}],outputs:[{type:"uint256"}]},{name:"allowance",type:"function",stateMutability:"view",inputs:[{type:"address",name:"owner"},{type:"address",name:"spender"},{type:"uint256",name:"id"}],outputs:[{type:"uint256"}]},{name:"transfer",type:"function",stateMutability:"nonpayable",inputs:[{type:"address",name:"receiver"},{type:"uint256",name:"id"},{type:"uint256",name:"amount"}],outputs:[{type:"bool"}]}]},dayWrapper:{factory:"wrapperFactory",abi:[{name:"shares",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"day",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"assetCount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"basket",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"previewRedeem",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"amount"}],outputs:[{type:"uint256[]",name:"cash"}]},{name:"deposit",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"amount"},{type:"address",name:"to"}],outputs:[]},{name:"redeem",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"amount"},{type:"address",name:"to"}],outputs:[{type:"uint256[]",name:"cash"}]},{name:"redeemShort",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"amount"},{type:"address",name:"to"}],outputs:[{type:"uint256[]",name:"cash"}]},{name:"owedTo",type:"function",stateMutability:"view",inputs:[{type:"address",name:"owner"},{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"claimOwed",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"asset"},{type:"address",name:"to"}],outputs:[]},{name:"collect",type:"function",stateMutability:"nonpayable",inputs:[],outputs:[]},{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{type:"address",name:"owner"}],outputs:[{type:"uint256"}]},{name:"totalSupply",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"transfer",type:"function",stateMutability:"nonpayable",inputs:[{type:"address",name:"to"},{type:"uint256",name:"amount"}],outputs:[{type:"bool"}]}]},compounder:{factory:"compoundFactory",abi:[{name:"MIN_SHARES",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_BANDS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_BAND_TICKS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"int24"}]},{name:"MAX_TIP_BPS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint16"}]},{name:"CLAIM_GAS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"ADD_GAS_FLOOR",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"ANCHOR_DRIFT",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"ANCHOR_PERIOD",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"ANCHOR_TOLERANCE",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"int24"}]},{name:"DROP_SCAN",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"DROP_CLAIM_GAS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"parked",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"dropId"}],outputs:[{type:"bool"}]},{name:"syncSides",type:"function",stateMutability:"nonpayable",inputs:[],outputs:[{type:"uint256",name:"count"}]},{name:"token",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"poolManager",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"poolId",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"bytes32"}]},{name:"poolKey",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"tuple",components:[{type:"address",name:"currency0"},{type:"address",name:"currency1"},{type:"uint24",name:"fee"},{type:"int24",name:"tickSpacing"},{type:"address",name:"hooks"}]}]},{name:"quote",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"tokenIsCurrency0",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"bool"}]},{name:"bandTicks",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"int24"}]},{name:"tipBps",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint16"}]},{name:"tipCap",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint128"}]},{name:"reserve",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"bands",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"tuple[]",components:[{type:"int24",name:"tickLower"},{type:"int24",name:"tickUpper"},{type:"uint128",name:"liquidity"}]}]},{name:"anchor",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"tuple",components:[{type:"int24",name:"high"},{type:"int24",name:"low"},{type:"uint40",name:"lookedAt"}]}]},{name:"creator",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"nextDrop",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"holdings",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256",name:"tokens"},{type:"uint256",name:"quote"}]},{name:"deposit",type:"function",stateMutability:"payable",inputs:[{type:"uint256",name:"tokensMax"},{type:"uint256",name:"quoteMax"},{type:"address",name:"to"},{type:"uint256",name:"minShares"},{type:"uint256",name:"deadline"}],outputs:[{type:"uint256",name:"shares"},{type:"uint256",name:"tokens"},{type:"uint256",name:"quote"}]},{name:"redeem",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"shares"},{type:"address",name:"to"},{type:"uint256",name:"minTokens"},{type:"uint256",name:"minQuote"},{type:"uint256",name:"deadline"}],outputs:[{type:"uint256",name:"tokens"},{type:"uint256",name:"quote"}]},{name:"redeemUnlocked",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"shares"},{type:"address",name:"to"},{type:"uint256",name:"minTokens"},{type:"uint256",name:"minQuote"},{type:"uint256",name:"deadline"}],outputs:[{type:"uint256",name:"tokens"},{type:"uint256",name:"quote"}]},{name:"poke",type:"function",stateMutability:"nonpayable",inputs:[],outputs:[{type:"uint256",name:"tip"}]},{name:"claimDrops",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256[]",name:"dropIds"}],outputs:[{type:"uint256",name:"tip"}]},{name:"listSide",type:"function",stateMutability:"nonpayable",inputs:[{type:"address",name:"asset"}],outputs:[{type:"uint256",name:"side"}]},{name:"SCALE",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_SIDES",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"SIDE_READ_GAS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"DEAD",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"sideCount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"fixedSideCount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"sideAt",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"side"}],outputs:[{type:"tuple",components:[{type:"address",name:"currency"},{type:"uint256",name:"index"},{type:"uint256",name:"carry"},{type:"uint128",name:"recognized"},{type:"uint128",name:"paid"},{type:"uint128",name:"dropped"},{type:"uint40",name:"droppedAt"}]}]},{name:"sideOf",type:"function",stateMutability:"view",inputs:[{type:"address",name:"currency"}],outputs:[{type:"bool",name:"listed"},{type:"uint256",name:"side"}]},{name:"dropStream",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"earningSupply",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"sideClaimable",type:"function",stateMutability:"view",inputs:[{type:"address",name:"account"},{type:"uint256",name:"side"}],outputs:[{type:"uint256"}]},{name:"claimSide",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"side"},{type:"address",name:"to"}],outputs:[{type:"uint256",name:"amount"}]},{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{type:"address",name:"owner"}],outputs:[{type:"uint256"}]},{name:"totalSupply",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"transfer",type:"function",stateMutability:"nonpayable",inputs:[{type:"address",name:"to"},{type:"uint256",name:"amount"}],outputs:[{type:"bool"}]}]}};var $=q(["function approve(address spender,uint256 id,uint256 amount) returns (bool)"]),x=t=>I(t,"Provide the documented Hookr add-on parameters."),W=t=>["view","pure"].includes(t.stateMutability);function R(t){return Object.entries(k).flatMap(([e,i])=>i.abi.filter(n=>W(n)===t).map(n=>({role:e,fn:n})))}function N(t){return{type:"object",oneOf:R(t).map(({role:e,fn:i})=>({type:"object",properties:{addon:{const:e},token:_,...e==="dayWrapper"?{day:C()}:{},function:{const:i.name},params:D(i.inputs)},required:["addon","token",...e==="dayWrapper"?["day"]:[],"function","params"],additionalProperties:!1}))}}function E(t,e){let i=R(e).find(a=>a.role===t.addon&&a.fn.name===t.function);if(!i)throw new r("Choose a documented Hookr add-on function.");let n=["addon","token","function","params",...i.role==="dayWrapper"?["day"]:[]];if(Object.keys(t).length!==n.length||Object.keys(t).some(a=>!n.includes(a)))throw new r("Provide exactly the documented Hookr add-on arguments.");let s;try{s=c(String(t.token))}catch{throw new r("Provide a valid revenue token address.")}let p=0n;if(i.role==="dayWrapper"){if(typeof t.day!="string"||!/^(0|[1-9][0-9]*)$/.test(t.day)||t.day.length>78||BigInt(t.day)>=1n<<256n)throw new r("Provide a wrapper day as a decimal integer string.");p=BigInt(t.day)}return{...i,token:s,day:p,...H(i.fn,x(t.params))}}async function P(t,e,i,n){let s=t.clientFor(d),p=async(f,b,v=[])=>s.readContract({address:c(S[f].address),abi:S[f].abi,functionName:b,args:v}),a=x(await p("tokenizer","tokenizations",[i]));if(typeof a.createdAt!="bigint"||a.createdAt<=0n||c(String(a.creator))===M)throw new r("Current Hookr tokenizer has no matching token record; legacy add-ons need their generation-specific route.");let m=e==="compounder"?void 0:c(String(await p("timeFactory","sharesOf",[i]))),u=e==="timeShares"?m:e==="compounder"?c(String(await p("compoundFactory","vaultOf",[i]))):c(String(await p("wrapperFactory","wrapperOf",[m,n])));if(u===M||m===M)throw new r("Hookr add-on is not open yet. Open it with its pinned factory through hookr_action first.");let y=k[e].abi,l=await s.readContract({address:u,abi:y,functionName:e==="dayWrapper"?"shares":"token"});if(c(String(l))!==(e==="dayWrapper"?m:i))throw new r("Hookr add-on disagrees with its factory record.");if(e==="dayWrapper"&&await s.readContract({address:u,abi:y,functionName:"day"})!==n)throw new r("Hookr day wrapper disagrees with its factory day.");return{target:u,shares:m}}async function X(t,e,i){if(t.network==="testnet")throw new r("Hookr add-ons require mainnet, chain 4663.");let{role:n,token:s,day:p,fn:a,values:m,params:u}=E(e,!1),{target:y,shares:l}=await P(t,n,s,p),f=[],b=[],v=0n,h=t.clientFor(d),A=async(o,w)=>{if(w<0n||w>=1n<<128n)throw new r("Hookr add-on funding exceeds its bounded exact approval.");if(!w)return;if(o===M){v+=w,b.push({token:O,amount:w,to:y});return}let g=await h.readContract({address:o,abi:L,functionName:"allowance",args:[i,y]});g>0n&&g!==w&&f.push(t.approval(o,y,"0",d)),f.push(t.approval(o,y,w.toString(),d)),b.push({token:o,amount:w})};if(n==="timeShares"&&a.name==="lock"&&await A(s,u.amount),n==="dayWrapper"&&a.name==="deposit"){let o=u.amount;if(o<=0n||o>=1n<<128n)throw new r("Hookr wrapper deposit needs a positive bounded share amount.");f.push(t.unsignedTx({chainId:d,to:l,value:"0",data:T({abi:$,functionName:"approve",args:[y,p,o]}),description:`Approve exactly ${o} time shares of day ${p} to the factory-recorded wrapper ${y}.`})),b.push({token:l,id:p,amount:o,to:y})}if(n==="compounder"&&a.name==="deposit"){let o=c(String(await h.readContract({address:y,abi:k.compounder.abi,functionName:"quote"})));await A(s,u.tokensMax),await A(o,u.quoteMax)}if(["redeem","redeemShort","redeemUnlocked"].includes(a.name)&&b.push({token:y,amount:u.shares??u.amount,to:M}),a.name==="transfer"&&b.push({token:y,amount:u.amount,to:c(String(u.receiver??u.to)),...n==="timeShares"?{id:u.id}:{}}),u.deadline!==void 0){let o=await h.getBlock();if(typeof o.timestamp!="bigint"||u.deadline<o.timestamp)throw new r("Hookr add-on deadline expired or chain time is unavailable.")}return f.push(t.unsignedTx({chainId:d,to:y,value:v.toString(),data:T({abi:[a],functionName:a.name,args:m}),description:`Hookr ${n}.${a.name}: ${JSON.stringify(e.params)}. Token ${s}${n==="dayWrapper"?`; day ${p}`:""}. Review lock duration, recipients and minimum outputs.`})),{txs:f,inputs:b}}function Z(t){return[{name:"hookr_addon_read",inputSchema:{...N(!0),description:"Read factory-verified current Hookr revenue time shares, day wrappers or compounders: locks, day income, unwrap baskets, bands and side assets. Open factories via hookr_action."},execute:async e=>{let{role:i,token:n,day:s,fn:p,values:a}=E(e,!0),{target:m}=await P(t,i,n,s),u=await t.clientFor(d).readContract({address:m,abi:[p],functionName:p.name,args:a});return{chainId:d,token:n,contract:m,function:p.name,result:JSON.parse(JSON.stringify(u,(y,l)=>typeof l=="bigint"?l.toString():l))}}},{name:"hookr_addon_action",inputSchema:{...N(!1),description:"Preview current Hookr time-share lock/issue/unlock/roll/claims, day wrap/unwrap/owed claims, or compound deposit/redeem/poke/side claims. Exact approvals, factory provenance and local human confirmation required."},execute:async(e,i)=>{let{txs:n}=await X(t,e,i),s=await t.preview(n,i);return{txs:n,preview:s,summary:`Hookr ${e.addon}.${e.function}; verify the receipt and read the resulting lock or balances.`}}}]}export{X as a,Z as b};
1
+ import{a as S,b as D,c as H}from"./EYYUWFUR.js";import{a as O}from"./VJ3W2V3B.js";import{a as C}from"./UWOFA6GV.js";import{c as _,f as I}from"./73N3TOJL.js";import{a as d}from"./XPFVT2EA.js";import{a as r}from"./5YS5V2LK.js";import{encodeFunctionData as T,erc20Abi as L,getAddress as c,parseAbi as q,zeroAddress as M}from"viem";var k={timeShares:{factory:"timeFactory",abi:[{name:"SCALE",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_ASSETS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MIN_LOCK_DAYS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint32"}]},{name:"MAX_LOCK_DAYS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint32"}]},{name:"FOREVER",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint32"}]},{name:"MAX_LOCK_AMOUNT",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MIN_LOCK_DIVISOR",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"minLockAmount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_TIP_BPS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint16"}]},{name:"MIN_TIP_GROWTH",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_ISSUE_DAYS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_CLAIM_DAYS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"token",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"tipBps",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint16"}]},{name:"tipCap",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"assetCount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"currencyAt",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"address"}]},{name:"lockedTotal",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"pendingLocks",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256",name:"amount"},{type:"uint256",name:"tick"},{type:"uint256",name:"firstLock"}]},{name:"nextDrop",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"heldAt",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"blockNumber"}],outputs:[{type:"uint256"}]},{name:"lockEpochs",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"lockId"}],outputs:[{type:"uint256",name:"joinEpoch"},{type:"uint256",name:"leaveEpoch"}]},{name:"sweepable",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"from"},{type:"uint256",name:"max"}],outputs:[{type:"uint256[]",name:"ids"},{type:"uint256",name:"next"}]},{name:"lockCount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"lockAt",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"lockId"}],outputs:[{type:"tuple",components:[{type:"address",name:"owner"},{type:"uint64",name:"lockedAt"},{type:"uint32",name:"firstDay"},{type:"uint128",name:"amount"},{type:"uint32",name:"lastDay"},{type:"uint64",name:"unlockedAt"}]}]},{name:"isIssued",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"lockId"},{type:"uint256",name:"day"}],outputs:[{type:"bool"}]},{name:"unitSupply",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"day"}],outputs:[{type:"uint256"}]},{name:"currentDay",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"pointCount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"pointAt",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"k"}],outputs:[{type:"uint64",name:"timestamp"},{type:"uint256[]",name:"indexes"}]},{name:"index",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"carry",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"pulled",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"paid",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"held",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"dayIndex",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"day"},{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"claimable",type:"function",stateMutability:"view",inputs:[{type:"address",name:"holder"},{type:"uint256",name:"day"},{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"lockClaimable",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"lockId"},{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"lock",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"amount"},{type:"uint32",name:"numberOfDays"}],outputs:[{type:"uint256",name:"lockId"}]},{name:"issue",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"lockId"},{type:"uint256",name:"day"},{type:"address",name:"to"}],outputs:[]},{name:"issueRange",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"lockId"},{type:"uint256",name:"firstDay"},{type:"uint256",name:"lastDay"},{type:"address",name:"to"}],outputs:[]},{name:"unlock",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"lockId"},{type:"address",name:"to"}],outputs:[]},{name:"syncAssets",type:"function",stateMutability:"nonpayable",inputs:[],outputs:[]},{name:"catchUp",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"max"}],outputs:[{type:"bool",name:"done"}]},{name:"settle",type:"function",stateMutability:"nonpayable",inputs:[],outputs:[]},{name:"roll",type:"function",stateMutability:"nonpayable",inputs:[],outputs:[{type:"uint256",name:"tip"}]},{name:"sweepDrops",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256[]",name:"dropIds"},{type:"uint256",name:"claimGas"}],outputs:[{type:"uint256[]",name:"amounts"}]},{name:"claim",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"day"},{type:"uint256",name:"asset"},{type:"address",name:"to"}],outputs:[{type:"uint256",name:"amount"}]},{name:"claimMany",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256[]",name:"days_"},{type:"uint256",name:"asset"},{type:"address",name:"to"}],outputs:[{type:"uint256",name:"amount"}]},{name:"claimLock",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"lockId"},{type:"uint256",name:"asset"},{type:"address",name:"to"}],outputs:[{type:"uint256",name:"amount"}]},{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{type:"address",name:"owner"},{type:"uint256",name:"id"}],outputs:[{type:"uint256"}]},{name:"allowance",type:"function",stateMutability:"view",inputs:[{type:"address",name:"owner"},{type:"address",name:"spender"},{type:"uint256",name:"id"}],outputs:[{type:"uint256"}]},{name:"transfer",type:"function",stateMutability:"nonpayable",inputs:[{type:"address",name:"receiver"},{type:"uint256",name:"id"},{type:"uint256",name:"amount"}],outputs:[{type:"bool"}]}]},dayWrapper:{factory:"wrapperFactory",abi:[{name:"shares",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"day",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"assetCount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"basket",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"previewRedeem",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"amount"}],outputs:[{type:"uint256[]",name:"cash"}]},{name:"deposit",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"amount"},{type:"address",name:"to"}],outputs:[]},{name:"redeem",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"amount"},{type:"address",name:"to"}],outputs:[{type:"uint256[]",name:"cash"}]},{name:"redeemShort",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"amount"},{type:"address",name:"to"}],outputs:[{type:"uint256[]",name:"cash"}]},{name:"owedTo",type:"function",stateMutability:"view",inputs:[{type:"address",name:"owner"},{type:"uint256",name:"asset"}],outputs:[{type:"uint256"}]},{name:"claimOwed",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"asset"},{type:"address",name:"to"}],outputs:[]},{name:"collect",type:"function",stateMutability:"nonpayable",inputs:[],outputs:[]},{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{type:"address",name:"owner"}],outputs:[{type:"uint256"}]},{name:"totalSupply",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"transfer",type:"function",stateMutability:"nonpayable",inputs:[{type:"address",name:"to"},{type:"uint256",name:"amount"}],outputs:[{type:"bool"}]}]},compounder:{factory:"compoundFactory",abi:[{name:"MIN_SHARES",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_BANDS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_BAND_TICKS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"int24"}]},{name:"MAX_TIP_BPS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint16"}]},{name:"CLAIM_GAS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"ADD_GAS_FLOOR",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"ANCHOR_DRIFT",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"ANCHOR_PERIOD",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"ANCHOR_TOLERANCE",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"int24"}]},{name:"DROP_SCAN",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"DROP_CLAIM_GAS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"parked",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"dropId"}],outputs:[{type:"bool"}]},{name:"syncSides",type:"function",stateMutability:"nonpayable",inputs:[],outputs:[{type:"uint256",name:"count"}]},{name:"token",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"poolManager",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"poolId",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"bytes32"}]},{name:"poolKey",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"tuple",components:[{type:"address",name:"currency0"},{type:"address",name:"currency1"},{type:"uint24",name:"fee"},{type:"int24",name:"tickSpacing"},{type:"address",name:"hooks"}]}]},{name:"quote",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"tokenIsCurrency0",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"bool"}]},{name:"bandTicks",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"int24"}]},{name:"tipBps",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint16"}]},{name:"tipCap",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint128"}]},{name:"reserve",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"bands",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"tuple[]",components:[{type:"int24",name:"tickLower"},{type:"int24",name:"tickUpper"},{type:"uint128",name:"liquidity"}]}]},{name:"anchor",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"tuple",components:[{type:"int24",name:"high"},{type:"int24",name:"low"},{type:"uint40",name:"lookedAt"}]}]},{name:"creator",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"nextDrop",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"holdings",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256",name:"tokens"},{type:"uint256",name:"quote"}]},{name:"deposit",type:"function",stateMutability:"payable",inputs:[{type:"uint256",name:"tokensMax"},{type:"uint256",name:"quoteMax"},{type:"address",name:"to"},{type:"uint256",name:"minShares"},{type:"uint256",name:"deadline"}],outputs:[{type:"uint256",name:"shares"},{type:"uint256",name:"tokens"},{type:"uint256",name:"quote"}]},{name:"redeem",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"shares"},{type:"address",name:"to"},{type:"uint256",name:"minTokens"},{type:"uint256",name:"minQuote"},{type:"uint256",name:"deadline"}],outputs:[{type:"uint256",name:"tokens"},{type:"uint256",name:"quote"}]},{name:"redeemUnlocked",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"shares"},{type:"address",name:"to"},{type:"uint256",name:"minTokens"},{type:"uint256",name:"minQuote"},{type:"uint256",name:"deadline"}],outputs:[{type:"uint256",name:"tokens"},{type:"uint256",name:"quote"}]},{name:"poke",type:"function",stateMutability:"nonpayable",inputs:[],outputs:[{type:"uint256",name:"tip"}]},{name:"claimDrops",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256[]",name:"dropIds"}],outputs:[{type:"uint256",name:"tip"}]},{name:"listSide",type:"function",stateMutability:"nonpayable",inputs:[{type:"address",name:"asset"}],outputs:[{type:"uint256",name:"side"}]},{name:"SCALE",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"MAX_SIDES",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"SIDE_READ_GAS",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"DEAD",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{name:"sideCount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"fixedSideCount",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"sideAt",type:"function",stateMutability:"view",inputs:[{type:"uint256",name:"side"}],outputs:[{type:"tuple",components:[{type:"address",name:"currency"},{type:"uint256",name:"index"},{type:"uint256",name:"carry"},{type:"uint128",name:"recognized"},{type:"uint128",name:"paid"},{type:"uint128",name:"dropped"},{type:"uint40",name:"droppedAt"}]}]},{name:"sideOf",type:"function",stateMutability:"view",inputs:[{type:"address",name:"currency"}],outputs:[{type:"bool",name:"listed"},{type:"uint256",name:"side"}]},{name:"dropStream",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"earningSupply",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"sideClaimable",type:"function",stateMutability:"view",inputs:[{type:"address",name:"account"},{type:"uint256",name:"side"}],outputs:[{type:"uint256"}]},{name:"claimSide",type:"function",stateMutability:"nonpayable",inputs:[{type:"uint256",name:"side"},{type:"address",name:"to"}],outputs:[{type:"uint256",name:"amount"}]},{name:"balanceOf",type:"function",stateMutability:"view",inputs:[{type:"address",name:"owner"}],outputs:[{type:"uint256"}]},{name:"totalSupply",type:"function",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{name:"transfer",type:"function",stateMutability:"nonpayable",inputs:[{type:"address",name:"to"},{type:"uint256",name:"amount"}],outputs:[{type:"bool"}]}]}};var $=q(["function approve(address spender,uint256 id,uint256 amount) returns (bool)"]),x=t=>I(t,"Provide the documented Hookr add-on parameters."),W=t=>["view","pure"].includes(t.stateMutability);function R(t){return Object.entries(k).flatMap(([e,i])=>i.abi.filter(n=>W(n)===t).map(n=>({role:e,fn:n})))}function N(t){return{type:"object",oneOf:R(t).map(({role:e,fn:i})=>({type:"object",properties:{addon:{const:e},token:_,...e==="dayWrapper"?{day:C()}:{},function:{const:i.name},params:D(i.inputs)},required:["addon","token",...e==="dayWrapper"?["day"]:[],"function","params"],additionalProperties:!1}))}}function E(t,e){let i=R(e).find(a=>a.role===t.addon&&a.fn.name===t.function);if(!i)throw new r("Choose a documented Hookr add-on function.");let n=["addon","token","function","params",...i.role==="dayWrapper"?["day"]:[]];if(Object.keys(t).length!==n.length||Object.keys(t).some(a=>!n.includes(a)))throw new r("Provide exactly the documented Hookr add-on arguments.");let s;try{s=c(String(t.token))}catch{throw new r("Provide a valid revenue token address.")}let p=0n;if(i.role==="dayWrapper"){if(typeof t.day!="string"||!/^(0|[1-9][0-9]*)$/.test(t.day)||t.day.length>78||BigInt(t.day)>=1n<<256n)throw new r("Provide a wrapper day as a decimal integer string.");p=BigInt(t.day)}return{...i,token:s,day:p,...H(i.fn,x(t.params))}}async function P(t,e,i,n){let s=t.clientFor(d),p=async(f,b,v=[])=>s.readContract({address:c(S[f].address),abi:S[f].abi,functionName:b,args:v}),a=x(await p("tokenizer","tokenizations",[i]));if(typeof a.createdAt!="bigint"||a.createdAt<=0n||c(String(a.creator))===M)throw new r("Current Hookr tokenizer has no matching token record; legacy add-ons need their generation-specific route.");let m=e==="compounder"?void 0:c(String(await p("timeFactory","sharesOf",[i]))),u=e==="timeShares"?m:e==="compounder"?c(String(await p("compoundFactory","vaultOf",[i]))):c(String(await p("wrapperFactory","wrapperOf",[m,n])));if(u===M||m===M)throw new r("Hookr add-on is not open yet. Open it with its pinned factory through hookr_action first.");let y=k[e].abi,l=await s.readContract({address:u,abi:y,functionName:e==="dayWrapper"?"shares":"token"});if(c(String(l))!==(e==="dayWrapper"?m:i))throw new r("Hookr add-on disagrees with its factory record.");if(e==="dayWrapper"&&await s.readContract({address:u,abi:y,functionName:"day"})!==n)throw new r("Hookr day wrapper disagrees with its factory day.");return{target:u,shares:m}}async function X(t,e,i){if(t.network==="testnet")throw new r("Hookr add-ons require mainnet, chain 4663.");let{role:n,token:s,day:p,fn:a,values:m,params:u}=E(e,!1),{target:y,shares:l}=await P(t,n,s,p),f=[],b=[],v=0n,h=t.clientFor(d),A=async(o,w)=>{if(w<0n||w>=1n<<128n)throw new r("Hookr add-on funding exceeds its bounded exact approval.");if(!w)return;if(o===M){v+=w,b.push({token:O,amount:w,to:y});return}let g=await h.readContract({address:o,abi:L,functionName:"allowance",args:[i,y]});g>0n&&g!==w&&f.push(t.approval(o,y,"0",d)),f.push(t.approval(o,y,w.toString(),d)),b.push({token:o,amount:w})};if(n==="timeShares"&&a.name==="lock"&&await A(s,u.amount),n==="dayWrapper"&&a.name==="deposit"){let o=u.amount;if(o<=0n||o>=1n<<128n)throw new r("Hookr wrapper deposit needs a positive bounded share amount.");f.push(t.unsignedTx({chainId:d,to:l,value:"0",data:T({abi:$,functionName:"approve",args:[y,p,o]}),description:`Approve exactly ${o} time shares of day ${p} to the factory-recorded wrapper ${y}.`})),b.push({token:l,id:p,amount:o,to:y})}if(n==="compounder"&&a.name==="deposit"){let o=c(String(await h.readContract({address:y,abi:k.compounder.abi,functionName:"quote"})));await A(s,u.tokensMax),await A(o,u.quoteMax)}if(["redeem","redeemShort","redeemUnlocked"].includes(a.name)&&b.push({token:y,amount:u.shares??u.amount,to:M}),a.name==="transfer"&&b.push({token:y,amount:u.amount,to:c(String(u.receiver??u.to)),...n==="timeShares"?{id:u.id}:{}}),u.deadline!==void 0){let o=await h.getBlock();if(typeof o.timestamp!="bigint"||u.deadline<o.timestamp)throw new r("Hookr add-on deadline expired or chain time is unavailable.")}return f.push(t.unsignedTx({chainId:d,to:y,value:v.toString(),data:T({abi:[a],functionName:a.name,args:m}),description:`Hookr ${n}.${a.name}: ${JSON.stringify(e.params)}. Token ${s}${n==="dayWrapper"?`; day ${p}`:""}. Review lock duration, recipients and minimum outputs.`})),{txs:f,inputs:b}}function Z(t){return[{name:"hookr_addon_read",inputSchema:{...N(!0),description:"Read factory-verified current Hookr revenue time shares, day wrappers or compounders: locks, day income, unwrap baskets, bands and side assets. Open factories via hookr_action."},execute:async e=>{let{role:i,token:n,day:s,fn:p,values:a}=E(e,!0),{target:m}=await P(t,i,n,s),u=await t.clientFor(d).readContract({address:m,abi:[p],functionName:p.name,args:a});return{chainId:d,token:n,contract:m,function:p.name,result:JSON.parse(JSON.stringify(u,(y,l)=>typeof l=="bigint"?l.toString():l))}}},{name:"hookr_addon_action",inputSchema:{...N(!1),description:"Preview current Hookr time-share lock/issue/unlock/roll/claims, day wrap/unwrap/owed claims, or compound deposit/redeem/poke/side claims. Exact approvals, factory provenance and local human confirmation required."},execute:async(e,i)=>{let{txs:n}=await X(t,e,i),s=await t.preview(n,i);return{txs:n,preview:s,summary:`Hookr ${e.addon}.${e.function}; verify the receipt and read the resulting lock or balances.`}}}]}export{X as a,Z as b};
@@ -1 +1 @@
1
- import{n as k}from"./EAEQOS7Y.js";import{b as T}from"./6IM6A5VA.js";import{a as y}from"./OG5HRQU4.js";import{b as R}from"./UWOFA6GV.js";import{c as _,d as I,g as v,i as $,n as V}from"./73N3TOJL.js";import{a as u}from"./XPFVT2EA.js";import{a as o}from"./5YS5V2LK.js";import{encodeFunctionData as D,erc20Abi as O,getAddress as C,parseAbi as S}from"viem";var N=C("0x0000000000bbf5c5fd284e657f01bd000933c96d"),b=C("0x0a0d53b6684c7b32b4cbef5fe8483bfcc8406742"),U=C("0x00700052c0608F670705380a4900e0a8080010CC"),x=S(["function getCollectedFees(address partner,address token) view returns (uint256)","function withdrawAllFees(address token,address recipient) returns (uint256 amount)","function getBalance(address token,address partner) view returns (uint256)","function withdrawAllERC20(address token,address recipient) returns (bool)","function withdrawNative(uint256 amount,address owner,address receiver)"]),H=(1n<<256n)-1n,P={type:"string",enum:["market","delta"]};function p(t){return $(t,"Provide a token or wallet address.",I)}function A(t){if(t!=="market"&&t!=="delta")throw new o("Choose market or delta fees.");return t}function B(t){return V(t,"Amount must be positive and within uint256.",{notString:"Amount must be a decimal base-unit string.",positive:!0}).toString()}function E(t,m,d){if(d=p(d),t==="velora_unwrap_deth"){for(let e of Object.keys(m))if(e!=="amount")throw new o(`Unsupported ${t} argument: ${e}.`);let a=B(m.amount);return{tx:T({to:b,chainId:u,value:"0",data:D({abi:x,functionName:"withdrawNative",args:[BigInt(a),d,d]}),description:`Unwrap ${a} dETH base units into the same amount of native ETH for ${d} on chain ${u}.`}),inputs:[{token:b,amount:a}]}}if(t!=="velora_claim_fees")throw new o("Unknown Velora claim action.");for(let a of Object.keys(m))if(!["token","kind"].includes(a))throw new o(`Unsupported ${t} argument: ${a}.`);let f=p(m.token);if(k(f))throw new o("Velora fee claims require an ERC-20 token address.");let c=A(m.kind);return{tx:T({to:c==="delta"?N:U,chainId:u,value:"0",data:D({abi:x,functionName:c==="delta"?"withdrawAllFees":"withdrawAllERC20",args:[f,d]}),description:`Claim the full accrued ${c} fee balance of ${f} to ${d} on chain ${u}. Receipt amount can change before mining; no minimum is encoded.`}),inputs:[]}}function Q(t,m,d,f){let{tx:c}=E(m,d,f),a=t[0];if(t.length!==1||!a||a.chainId!==c.chainId||!v(a.to,c.to)||!v(a.data,c.data)||a.value!==c.value)throw new o("Velora claim calldata, recipient, amount or destination differs from the request.")}function X(t){let m=async()=>{let e=t.clientFor(u);if(await e.getChainId()!==u)throw new o("Velora requires an RPC on chain 4663.");return e};async function d(e){if(e===b)return{address:e,symbol:"dETH",decimals:18,chainId:u};let n=await m(),[s,i]=await Promise.all([y(n,u,e,"symbol"),y(n,u,e,"decimals")]);if(typeof s!="string"||!s.trim()||!Number.isInteger(i)||i<0||i>255)throw new o("Velora fee token metadata is unavailable.");return{address:e,symbol:s,decimals:i,chainId:u}}async function f(e,n){let s=A(e.kind),i=p(e.token);if(k(i))throw new o("Velora fee claims require an ERC-20 token address.");let r=await(await m()).readContract({address:s==="delta"?N:U,abi:x,functionName:s==="delta"?"getCollectedFees":"getBalance",args:s==="delta"?[n,i]:[i,n]});if(typeof r!="bigint"||r<0n||r>H)throw new o("Velora fee balance is unavailable.");return r}function c(e,n,s,i){return{name:e,inputSchema:{type:"object",additionalProperties:!1,properties:n,required:s},execute:async(w,r)=>{try{r=p(r);for(let l of Object.keys(w))if(!Object.hasOwn(n,l))throw new o(`Unsupported ${e} argument: ${l}.`);return await i(w,r)}catch(l){throw new o(t.plainError(l))}}}}let a={token:_,kind:P};return[c("velora_fee_balance",a,["token","kind"],async(e,n)=>({kind:A(e.kind),token:await d(p(e.token)),amount:(await f(e,n)).toString()})),c("velora_claim_fees",a,["token","kind"],async(e,n)=>{let{tx:s}=E("velora_claim_fees",e,n),i=await f(e,n);if(i===0n)throw new o("No accrued Velora fees for this wallet and token.");let w=await d(p(e.token)),r=[s],l=await t.preview(r,n);return{txs:r,preview:l,estimatedReceipt:{token:w,amount:i.toString()},summary:`${s.description} ${l.summary}`}}),c("velora_unwrap_deth",{amount:R("Positive amount of wallet-held dETH in base units (18 decimals).")},["amount"],async(e,n)=>{let{tx:s,inputs:i}=E("velora_unwrap_deth",e,n),r=await(await m()).readContract({address:b,abi:O,functionName:"balanceOf",args:[n]});if(typeof r!="bigint"||r<0n||r>H)throw new o("Wallet dETH balance is unavailable.");if(r<BigInt(i[0].amount))throw new o("Insufficient wallet-held dETH. An active native Delta order must first settle, expire or cancel.");let l=[s],g=await t.preview(l,n);if(g.changes.filter(h=>h.token.chainId===u&&k(h.token.address)).reduce((h,F)=>h+BigInt(F.amount),0n)<BigInt(i[0].amount))throw new o("Velora dETH preview does not return the requested native ETH amount.");return{txs:l,preview:g,summary:`${s.description} ${g.summary}`}})]}export{N as a,b,U as c,x as d,E as e,Q as f,X as g};
1
+ import{n as k}from"./CAU44UWP.js";import{a as y}from"./OG5HRQU4.js";import{b as T}from"./6IM6A5VA.js";import{b as R}from"./UWOFA6GV.js";import{c as _,d as I,g as v,i as $,n as V}from"./73N3TOJL.js";import{a as u}from"./XPFVT2EA.js";import{a as o}from"./5YS5V2LK.js";import{encodeFunctionData as D,erc20Abi as O,getAddress as C,parseAbi as S}from"viem";var N=C("0x0000000000bbf5c5fd284e657f01bd000933c96d"),b=C("0x0a0d53b6684c7b32b4cbef5fe8483bfcc8406742"),U=C("0x00700052c0608F670705380a4900e0a8080010CC"),x=S(["function getCollectedFees(address partner,address token) view returns (uint256)","function withdrawAllFees(address token,address recipient) returns (uint256 amount)","function getBalance(address token,address partner) view returns (uint256)","function withdrawAllERC20(address token,address recipient) returns (bool)","function withdrawNative(uint256 amount,address owner,address receiver)"]),H=(1n<<256n)-1n,P={type:"string",enum:["market","delta"]};function p(t){return $(t,"Provide a token or wallet address.",I)}function A(t){if(t!=="market"&&t!=="delta")throw new o("Choose market or delta fees.");return t}function B(t){return V(t,"Amount must be positive and within uint256.",{notString:"Amount must be a decimal base-unit string.",positive:!0}).toString()}function E(t,m,d){if(d=p(d),t==="velora_unwrap_deth"){for(let e of Object.keys(m))if(e!=="amount")throw new o(`Unsupported ${t} argument: ${e}.`);let a=B(m.amount);return{tx:T({to:b,chainId:u,value:"0",data:D({abi:x,functionName:"withdrawNative",args:[BigInt(a),d,d]}),description:`Unwrap ${a} dETH base units into the same amount of native ETH for ${d} on chain ${u}.`}),inputs:[{token:b,amount:a}]}}if(t!=="velora_claim_fees")throw new o("Unknown Velora claim action.");for(let a of Object.keys(m))if(!["token","kind"].includes(a))throw new o(`Unsupported ${t} argument: ${a}.`);let f=p(m.token);if(k(f))throw new o("Velora fee claims require an ERC-20 token address.");let c=A(m.kind);return{tx:T({to:c==="delta"?N:U,chainId:u,value:"0",data:D({abi:x,functionName:c==="delta"?"withdrawAllFees":"withdrawAllERC20",args:[f,d]}),description:`Claim the full accrued ${c} fee balance of ${f} to ${d} on chain ${u}. Receipt amount can change before mining; no minimum is encoded.`}),inputs:[]}}function Q(t,m,d,f){let{tx:c}=E(m,d,f),a=t[0];if(t.length!==1||!a||a.chainId!==c.chainId||!v(a.to,c.to)||!v(a.data,c.data)||a.value!==c.value)throw new o("Velora claim calldata, recipient, amount or destination differs from the request.")}function X(t){let m=async()=>{let e=t.clientFor(u);if(await e.getChainId()!==u)throw new o("Velora requires an RPC on chain 4663.");return e};async function d(e){if(e===b)return{address:e,symbol:"dETH",decimals:18,chainId:u};let n=await m(),[s,i]=await Promise.all([y(n,u,e,"symbol"),y(n,u,e,"decimals")]);if(typeof s!="string"||!s.trim()||!Number.isInteger(i)||i<0||i>255)throw new o("Velora fee token metadata is unavailable.");return{address:e,symbol:s,decimals:i,chainId:u}}async function f(e,n){let s=A(e.kind),i=p(e.token);if(k(i))throw new o("Velora fee claims require an ERC-20 token address.");let r=await(await m()).readContract({address:s==="delta"?N:U,abi:x,functionName:s==="delta"?"getCollectedFees":"getBalance",args:s==="delta"?[n,i]:[i,n]});if(typeof r!="bigint"||r<0n||r>H)throw new o("Velora fee balance is unavailable.");return r}function c(e,n,s,i){return{name:e,inputSchema:{type:"object",additionalProperties:!1,properties:n,required:s},execute:async(w,r)=>{try{r=p(r);for(let l of Object.keys(w))if(!Object.hasOwn(n,l))throw new o(`Unsupported ${e} argument: ${l}.`);return await i(w,r)}catch(l){throw new o(t.plainError(l))}}}}let a={token:_,kind:P};return[c("velora_fee_balance",a,["token","kind"],async(e,n)=>({kind:A(e.kind),token:await d(p(e.token)),amount:(await f(e,n)).toString()})),c("velora_claim_fees",a,["token","kind"],async(e,n)=>{let{tx:s}=E("velora_claim_fees",e,n),i=await f(e,n);if(i===0n)throw new o("No accrued Velora fees for this wallet and token.");let w=await d(p(e.token)),r=[s],l=await t.preview(r,n);return{txs:r,preview:l,estimatedReceipt:{token:w,amount:i.toString()},summary:`${s.description} ${l.summary}`}}),c("velora_unwrap_deth",{amount:R("Positive amount of wallet-held dETH in base units (18 decimals).")},["amount"],async(e,n)=>{let{tx:s,inputs:i}=E("velora_unwrap_deth",e,n),r=await(await m()).readContract({address:b,abi:O,functionName:"balanceOf",args:[n]});if(typeof r!="bigint"||r<0n||r>H)throw new o("Wallet dETH balance is unavailable.");if(r<BigInt(i[0].amount))throw new o("Insufficient wallet-held dETH. An active native Delta order must first settle, expire or cancel.");let l=[s],g=await t.preview(l,n);if(g.changes.filter(h=>h.token.chainId===u&&k(h.token.address)).reduce((h,F)=>h+BigInt(F.amount),0n)<BigInt(i[0].amount))throw new o("Velora dETH preview does not return the requested native ETH amount.");return{txs:l,preview:g,summary:`${s.description} ${g.summary}`}})]}export{N as a,b,U as c,x as d,E as e,Q as f,X as g};
@@ -1 +1 @@
1
- import{a as H,b as z}from"./LIUXNOLP.js";import{a as O,b as B}from"./6IM6A5VA.js";import{a as _}from"./OG5HRQU4.js";import{a as $,b as M,i as R,s as S}from"./XPFVT2EA.js";import{b as D,c as E,d as U}from"./EG6M6SSO.js";import{a as u,b as N,c as I,d as F}from"./5YS5V2LK.js";import{decodeFunctionResult as J,encodeFunctionData as Q,erc20Abi as q,getAddress as G,isAddress as X,toEventSelector as Y,toHex as v,zeroAddress as Z}from"viem";var C="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";function ee(e){let r=e.toLowerCase();return r===Z||r===C?C:e}var te=Y("Transfer(address,address,uint256)"),K="Preview note: simulation transfer-based token changes exclude gas and do not prove external settlement.";function A(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function P(){throw new u("The endpoint returned an unexpected simulation response.")}async function L(e,r,d,a){let s=await e.getChainId();if(s!==r)throw new u(`Preview is on chain ${r}, but the endpoint reports chain ${s}.`);let i=await H(e),t=await z(e,i);if(i.number===null||typeof i.baseFeePerGas!="bigint"||i.baseFeePerGas<0n||typeof t!="bigint"||t<0n)throw new u("Current block base fee and gas price are unavailable or inconsistent. Retry the preview.");let n=t<i.baseFeePerGas?i.baseFeePerGas:t,y=D(i.gasLimit),b=d.map(f=>({from:a,to:f.to,data:f.data,value:v(BigInt(f.value)),gasPrice:v(n),gas:v(y)})),w=()=>e.request({method:"eth_simulateV1",params:[{blockStateCalls:[{blockOverrides:{baseFeePerGas:v(i.baseFeePerGas)},calls:b}],validation:!1,traceTransfers:!0},v(i.number)]},{retryCount:0});try{return await w()}catch(f){if(!I(f))throw f;let o=await e.getBalance({address:a,blockNumber:i.number}),c=await Promise.all(d.map(m=>e.estimateGas({account:a,to:m.to,data:m.data,value:BigInt(m.value),gas:y,blockNumber:i.number}).catch(()=>{}))),p=o;for(let[m,l]of b.entries()){let g=BigInt(l.value),x=U(D(i.gasLimit,c[m]),p,g,n,a,r),T=c[m];if(T!==void 0&&T>x)throw new u(E(a,r,o-p+g+T*n,o));l.gas=v(x),p-=g}let h=await w();if(Array.isArray(h)&&A(h[0])&&Array.isArray(h[0].calls))for(let[m,l]of h[0].calls.entries()){let g=b[m];if(g&&A(l)&&l.status==="0x0"&&typeof l.gasUsed=="string"&&/^0x[0-9a-f]+$/i.test(l.gasUsed)&&BigInt(l.gasUsed)>=BigInt(g.gas))throw new u(E(a,r,BigInt(g.value)+(BigInt(g.gas)+1n)*n,o))}return h}}function V(e,r,d,a){(!Array.isArray(e)||e.length!==1||!A(e[0])||!Array.isArray(e[0].calls)||e[0].calls.length!==r)&&P();let s=new Map;for(let[i,t]of e[0].calls.entries()){if(A(t)||P(),t.status==="0x0")throw new u(`Preview call ${i+1} on chain ${a} reverted. ${F(t.error)}`);(t.status!=="0x1"||t.error||!Array.isArray(t.logs))&&P();for(let n of t.logs){if((!A(n)||!Array.isArray(n.topics))&&P(),typeof n.topics[0]!="string"||n.topics[0].toLowerCase()!==te||n.topics.length===4)continue;(n.topics.length!==3||typeof n.address!="string"||!X(n.address,{strict:!1})||typeof n.data!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n.data)||!n.topics.slice(1).every(c=>typeof c=="string"&&/^0x0{24}[0-9a-fA-F]{40}$/.test(c)))&&P();let y=n.topics[1].slice(-40).toLowerCase(),b=n.topics[2].slice(-40).toLowerCase(),w=d.slice(2).toLowerCase(),f=BigInt(n.data),o=(b===w?f:0n)-(y===w?f:0n);if(o!==0n){let c=ee(n.address.toLowerCase());s.set(c,(s.get(c)??0n)+o)}}}return s}async function W(e,r,d,a){let s=r===$?S.mainnet:r===M?S.testnet:void 0,i=s&&[{address:s.usdg,symbol:"USDG",decimals:6},{address:s.weth,symbol:"WETH",decimals:18},...r===$?[{address:R[4663].meridian.CollateralToken_USDe.address,symbol:"USDe",decimals:18}]:[]].find(n=>n.address.toLowerCase()===e);if(i)return{...i,address:G(e),chainId:r};let t;if(e===C){let n=d.chain?.nativeCurrency??(r===4663?{symbol:"ETH",decimals:18}:void 0);if(!n)throw new u(`Native token metadata is unavailable for chain ${r}.`);t={address:e,chainId:r,symbol:n.symbol,decimals:n.decimals}}else if(a)t=await a(e,r,d);else{let n=await _(d,r,e,"decimals");t={address:e,chainId:r,symbol:e,decimals:n}}if(!t||typeof t.address!="string"||t.address.toLowerCase()!==e||t.chainId!==r||typeof t.symbol!="string"||!t.symbol.trim()||!Number.isInteger(t.decimals)||t.decimals<0||t.decimals>255)throw new u(`Invalid token metadata for ${e} on chain ${r}.`);return{address:e===C?e:G(e),chainId:r,symbol:e===C?t.symbol:G(e),decimals:t.decimals}}function le(e){return async(r,d)=>{O(d);let a=r.map(B),s=a[0]?.chainId;if(s===void 0)return{txs:a,changes:[],summary:K};let i=a.find(t=>t.chainId!==s);if(i)throw new u(`Preview cannot combine chain ${s} with chain ${i.chainId}. Preview each chain separately.`);try{let t=e.clientFor(s),n;try{n=await L(t,s,a,d)}catch(o){if(!N(o,-32601,-32004)||!e.anvilFor)throw o;t=await e.anvilFor(s),n=await L(t,s,a,d)}let y=V(n,a.length,d,s),b=new Map,w=[];for(let[o,c]of y)if(c!==0n)try{b.set(o,await W(o,s,t,e.tokenFor))}catch(p){if(o===C||e.tokenFor||(await t.getCode({address:o})??"0x")!=="0x")throw p;w.push(o)}if(w.length){let o=w.flatMap(m=>["symbol","decimals"].map(l=>B({to:m,data:Q({abi:q,functionName:l}),value:"0",chainId:s,description:`Read simulated token ${l}.`}))),c=await L(t,s,[...a,...o],d);(!Array.isArray(c)||c.length!==1||!A(c[0])||!Array.isArray(c[0].calls)||c[0].calls.length!==a.length+o.length)&&P();let p=c[0].calls,h=V([{calls:p.slice(0,a.length)}],a.length,d,s);if(y.size!==h.size||[...y].some(([m,l])=>h.get(m)!==l))throw new u("Simulation changed while reading new-token metadata. Refresh the preview.");for(let[m,l]of w.entries()){let g=(T,j)=>{let k=p[a.length+m*2+j];if(!A(k)||k.status!=="0x1"||k.error||typeof k.returnData!="string"||!/^0x[0-9a-fA-F]+$/.test(k.returnData))throw new u(`Invalid simulated token metadata for ${l} on chain ${s}.`);return J({abi:q,functionName:T,data:k.returnData})},x={address:l,chainId:s,symbol:g("symbol",0),decimals:g("decimals",1)};b.set(l,await W(l,s,t,async()=>x))}}let f=[...y].filter(([,o])=>o!==0n).map(([o,c])=>({token:b.get(o),amount:c.toString()}));return{txs:a,changes:f,summary:K}}catch(t){throw new u(`Preview on chain ${s} failed: ${F(t)}`)}}}export{C as a,ee as b,le as c};
1
+ import{a as H,b as z}from"./LIUXNOLP.js";import{a as _}from"./OG5HRQU4.js";import{a as O,b as B}from"./6IM6A5VA.js";import{b as D,c as E,d as U}from"./EG6M6SSO.js";import{a as $,b as M,i as R,s as S}from"./XPFVT2EA.js";import{a as u,b as N,c as I,d as F}from"./5YS5V2LK.js";import{decodeFunctionResult as J,encodeFunctionData as Q,erc20Abi as q,getAddress as G,isAddress as X,toEventSelector as Y,toHex as v,zeroAddress as Z}from"viem";var C="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";function ee(e){let r=e.toLowerCase();return r===Z||r===C?C:e}var te=Y("Transfer(address,address,uint256)"),K="Preview note: simulation transfer-based token changes exclude gas and do not prove external settlement.";function A(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function P(){throw new u("The endpoint returned an unexpected simulation response.")}async function L(e,r,d,a){let s=await e.getChainId();if(s!==r)throw new u(`Preview is on chain ${r}, but the endpoint reports chain ${s}.`);let i=await H(e),t=await z(e,i);if(i.number===null||typeof i.baseFeePerGas!="bigint"||i.baseFeePerGas<0n||typeof t!="bigint"||t<0n)throw new u("Current block base fee and gas price are unavailable or inconsistent. Retry the preview.");let n=t<i.baseFeePerGas?i.baseFeePerGas:t,y=D(i.gasLimit),b=d.map(f=>({from:a,to:f.to,data:f.data,value:v(BigInt(f.value)),gasPrice:v(n),gas:v(y)})),w=()=>e.request({method:"eth_simulateV1",params:[{blockStateCalls:[{blockOverrides:{baseFeePerGas:v(i.baseFeePerGas)},calls:b}],validation:!1,traceTransfers:!0},v(i.number)]},{retryCount:0});try{return await w()}catch(f){if(!I(f))throw f;let o=await e.getBalance({address:a,blockNumber:i.number}),c=await Promise.all(d.map(m=>e.estimateGas({account:a,to:m.to,data:m.data,value:BigInt(m.value),gas:y,blockNumber:i.number}).catch(()=>{}))),p=o;for(let[m,l]of b.entries()){let g=BigInt(l.value),x=U(D(i.gasLimit,c[m]),p,g,n,a,r),T=c[m];if(T!==void 0&&T>x)throw new u(E(a,r,o-p+g+T*n,o));l.gas=v(x),p-=g}let h=await w();if(Array.isArray(h)&&A(h[0])&&Array.isArray(h[0].calls))for(let[m,l]of h[0].calls.entries()){let g=b[m];if(g&&A(l)&&l.status==="0x0"&&typeof l.gasUsed=="string"&&/^0x[0-9a-f]+$/i.test(l.gasUsed)&&BigInt(l.gasUsed)>=BigInt(g.gas))throw new u(E(a,r,BigInt(g.value)+(BigInt(g.gas)+1n)*n,o))}return h}}function V(e,r,d,a){(!Array.isArray(e)||e.length!==1||!A(e[0])||!Array.isArray(e[0].calls)||e[0].calls.length!==r)&&P();let s=new Map;for(let[i,t]of e[0].calls.entries()){if(A(t)||P(),t.status==="0x0")throw new u(`Preview call ${i+1} on chain ${a} reverted. ${F(t.error)}`);(t.status!=="0x1"||t.error||!Array.isArray(t.logs))&&P();for(let n of t.logs){if((!A(n)||!Array.isArray(n.topics))&&P(),typeof n.topics[0]!="string"||n.topics[0].toLowerCase()!==te||n.topics.length===4)continue;(n.topics.length!==3||typeof n.address!="string"||!X(n.address,{strict:!1})||typeof n.data!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n.data)||!n.topics.slice(1).every(c=>typeof c=="string"&&/^0x0{24}[0-9a-fA-F]{40}$/.test(c)))&&P();let y=n.topics[1].slice(-40).toLowerCase(),b=n.topics[2].slice(-40).toLowerCase(),w=d.slice(2).toLowerCase(),f=BigInt(n.data),o=(b===w?f:0n)-(y===w?f:0n);if(o!==0n){let c=ee(n.address.toLowerCase());s.set(c,(s.get(c)??0n)+o)}}}return s}async function W(e,r,d,a){let s=r===$?S.mainnet:r===M?S.testnet:void 0,i=s&&[{address:s.usdg,symbol:"USDG",decimals:6},{address:s.weth,symbol:"WETH",decimals:18},...r===$?[{address:R[4663].meridian.CollateralToken_USDe.address,symbol:"USDe",decimals:18}]:[]].find(n=>n.address.toLowerCase()===e);if(i)return{...i,address:G(e),chainId:r};let t;if(e===C){let n=d.chain?.nativeCurrency??(r===4663?{symbol:"ETH",decimals:18}:void 0);if(!n)throw new u(`Native token metadata is unavailable for chain ${r}.`);t={address:e,chainId:r,symbol:n.symbol,decimals:n.decimals}}else if(a)t=await a(e,r,d);else{let n=await _(d,r,e,"decimals");t={address:e,chainId:r,symbol:e,decimals:n}}if(!t||typeof t.address!="string"||t.address.toLowerCase()!==e||t.chainId!==r||typeof t.symbol!="string"||!t.symbol.trim()||!Number.isInteger(t.decimals)||t.decimals<0||t.decimals>255)throw new u(`Invalid token metadata for ${e} on chain ${r}.`);return{address:e===C?e:G(e),chainId:r,symbol:e===C?t.symbol:G(e),decimals:t.decimals}}function le(e){return async(r,d)=>{O(d);let a=r.map(B),s=a[0]?.chainId;if(s===void 0)return{txs:a,changes:[],summary:K};let i=a.find(t=>t.chainId!==s);if(i)throw new u(`Preview cannot combine chain ${s} with chain ${i.chainId}. Preview each chain separately.`);try{let t=e.clientFor(s),n;try{n=await L(t,s,a,d)}catch(o){if(!N(o,-32601,-32004)||!e.anvilFor)throw o;t=await e.anvilFor(s),n=await L(t,s,a,d)}let y=V(n,a.length,d,s),b=new Map,w=[];for(let[o,c]of y)if(c!==0n)try{b.set(o,await W(o,s,t,e.tokenFor))}catch(p){if(o===C||e.tokenFor||(await t.getCode({address:o})??"0x")!=="0x")throw p;w.push(o)}if(w.length){let o=w.flatMap(m=>["symbol","decimals"].map(l=>B({to:m,data:Q({abi:q,functionName:l}),value:"0",chainId:s,description:`Read simulated token ${l}.`}))),c=await L(t,s,[...a,...o],d);(!Array.isArray(c)||c.length!==1||!A(c[0])||!Array.isArray(c[0].calls)||c[0].calls.length!==a.length+o.length)&&P();let p=c[0].calls,h=V([{calls:p.slice(0,a.length)}],a.length,d,s);if(y.size!==h.size||[...y].some(([m,l])=>h.get(m)!==l))throw new u("Simulation changed while reading new-token metadata. Refresh the preview.");for(let[m,l]of w.entries()){let g=(T,j)=>{let k=p[a.length+m*2+j];if(!A(k)||k.status!=="0x1"||k.error||typeof k.returnData!="string"||!/^0x[0-9a-fA-F]+$/.test(k.returnData))throw new u(`Invalid simulated token metadata for ${l} on chain ${s}.`);return J({abi:q,functionName:T,data:k.returnData})},x={address:l,chainId:s,symbol:g("symbol",0),decimals:g("decimals",1)};b.set(l,await W(l,s,t,async()=>x))}}let f=[...y].filter(([,o])=>o!==0n).map(([o,c])=>({token:b.get(o),amount:c.toString()}));return{txs:a,changes:f,summary:K}}catch(t){throw new u(`Preview on chain ${s} failed: ${F(t)}`)}}}export{C as a,ee as b,le as c};
@@ -1 +1 @@
1
- import{b as le,o as K}from"./EAEQOS7Y.js";import{b as x}from"./UWOFA6GV.js";import{c as W,f as de,h as y,i as ce,l as ue}from"./73N3TOJL.js";import{a as k,i as oe,j as G}from"./XPFVT2EA.js";import{a as N}from"./5YS5V2LK.js";import{a as O}from"./JXOEJPJ4.js";import{randomBytes as ge,randomUUID as he}from"node:crypto";import{isDeepStrictEqual as pe}from"node:util";import{decodeFunctionData as me,encodeAbiParameters as ne,erc20Abi as J,keccak256 as ie,parseAbi as re,parseAbiParameters as ae,toEventSelector as be,zeroAddress as L}from"viem";var se=oe[k].meridian,Q=se.PredictionMarketEscrow.address,V=se.SecondaryMarketEscrow.address,$={address:se.CollateralToken_USDe.address,chainId:k,symbol:"USDe",decimals:18},we="wss://relayer.predict.meridian.xyz/auction",ke=ae("(address conditionResolver,bytes conditionId,uint8 predictedOutcome)[]"),Ie=ae("bytes32,uint256,uint256,address,address,address,bytes"),Se=ae("address,address,address,address,uint256,uint256"),X=re(["function isNonceUsed(address,uint256) view returns (bool)"]),Be=re(["function mint(((address conditionResolver,bytes conditionId,uint8 predictedOutcome)[] picks,uint256 predictorCollateral,uint256 counterpartyCollateral,address predictor,address counterparty,uint256 predictorNonce,uint256 counterpartyNonce,uint256 predictorDeadline,uint256 counterpartyDeadline,bytes predictorSignature,bytes counterpartySignature,bytes32 refCode,bytes predictorSessionKeyData,bytes counterpartySessionKeyData,address predictorSponsor,bytes predictorSponsorData) request)"]),Me=re(["function executeTrade((address token,address collateral,address seller,address buyer,uint256 tokenAmount,uint256 price,uint256 sellerNonce,uint256 buyerNonce,uint256 sellerDeadline,uint256 buyerDeadline,bytes sellerSignature,bytes buyerSignature,bytes32 refCode,bytes sellerSessionKeyData,bytes buyerSessionKeyData) request)"]),$e=be("Transfer(address,address,uint256)"),Ae=[{name:"predictionHash",type:"bytes32"},{name:"signer",type:"address"},{name:"collateral",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}],Ce=[{name:"tradeHash",type:"bytes32"},{name:"signer",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}];function i(n){throw new N(n)}function _(n){return de(n,"Meridian returned an invalid exchange object.")}function M(n,t,d=!1){return d&&typeof n=="number"&&Number.isSafeInteger(n)&&n>=0&&(n=String(n)),(typeof n!="string"||!/^\d+$/.test(n)||BigInt(n)>=1n<<256n)&&i(`Provide ${t} as a decimal base-unit integer string.`),n}function F(n){let t=Number(n);return(!Number.isSafeInteger(t)||t<0||BigInt(t)!==BigInt(n))&&i("Meridian signing terms cannot be represented exactly as JSON numbers."),t}function R(n){let t="Provide a nonzero token, resolver or wallet address.";return ue(ce(n,t),t)}function Z(n,t){return(typeof n!="string"||!/^0x(?:[0-9a-fA-F]{2})+$/.test(n)||t!==void 0&&n.length!==2+t*2)&&i("Meridian returned invalid hexadecimal data."),n}function v(n){return(typeof n!="string"||n.length===0||n.length>256)&&i("Meridian returned an invalid exchange identifier."),n}function j(){return BigInt(Math.floor(Date.now()/1e3))}function ve(n,t){let d=n==="buy"?["picks","stake","minCounterpartyCollateral","usdgAmountIn","slippageBps","continuation","signature"]:["token","amount","minPrice","slippageBps","continuation","signature"];Object.keys(t).some(S=>!d.includes(S))&&i("Unsupported Meridian arguments; use the tool input schema."),t.slippageBps!==void 0&&(typeof t.slippageBps!="number"||!Number.isInteger(t.slippageBps)||t.slippageBps<0||t.slippageBps>=1e4)&&i("Slippage must be an integer from 0 to 9999 basis points.");let c=t.slippageBps;if(n==="sell"){let S=M(t.amount,"the position amount");BigInt(S)===0n&&i("The position amount must be positive.");let B=R(t.token);(y(B,$.address)||y(B,G))&&i("Choose a Meridian position token to sell.");let A;if(t.minPrice!==void 0){let e=M(t.minPrice,"the minimum sale price");BigInt(e)<=1n&&i("The minimum sale price must be greater than 1 base unit."),A=e}else{let e=BigInt(S)/100n>10n**18n?BigInt(S)/100n:10n**18n;A=c===void 0?e.toString():K(e.toString(),c)}return{side:n,token:B,amount:S,minPrice:A,priceFloorSource:t.minPrice===void 0?"default":"explicit",...c===void 0?{}:{slippageBps:c}}}(!Array.isArray(t.picks)||t.picks.length<1||t.picks.length>10)&&i("Provide between one and ten Meridian picks.");let m=t.picks.map(S=>{let B=_(S);return(Object.keys(B).some(A=>!["conditionResolver","conditionId","predictedOutcome"].includes(A))||B.predictedOutcome!==0&&B.predictedOutcome!==1)&&i("Each pick needs a resolver, condition ID and outcome 0 or 1."),{conditionResolver:R(B.conditionResolver),conditionId:Z(B.conditionId),predictedOutcome:B.predictedOutcome}}).sort((S,B)=>{let A=`${S.conditionResolver.toLowerCase()}:${S.conditionId.toLowerCase()}:${S.predictedOutcome}`,e=`${B.conditionResolver.toLowerCase()}:${B.conditionId.toLowerCase()}:${B.predictedOutcome}`;return A<e?-1:A>e?1:0}),g=m.map(S=>`${S.conditionResolver.toLowerCase()}:${S.conditionId.toLowerCase()}`);new Set(g).size!==m.length&&i("Do not repeat a condition in the same prediction.");let l=M(t.stake,"the USDe stake");BigInt(l)<10n**18n&&i("Meridian requires a stake of at least 1 USDe.");let I=t.usdgAmountIn===void 0?void 0:M(t.usdgAmountIn,"the USDG swap amount");I!==void 0&&BigInt(I)===0n&&i("The USDG swap amount must be positive.");let D=t.minCounterpartyCollateral!==void 0?M(t.minCounterpartyCollateral,"the minimum counterparty collateral"):K(l,c??le);return BigInt(D)<=1n&&i("The minimum counterparty collateral must be greater than 1 base unit."),{side:n,picks:m,stake:l,minCounterpartyCollateral:D,...I===void 0?{}:{usdgAmountIn:I},...c===void 0?{}:{slippageBps:c}}}var ee=class{constructor(t,d){this.id=t;this.prefix=d;this.socket=new globalThis.WebSocket(we),this.socket.addEventListener("open",()=>{this.opened=!0,this.notify?.()}),this.socket.addEventListener("close",()=>this.stop("Meridian exchange socket was lost. Start a fresh auction.")),this.socket.addEventListener("error",()=>this.stop("Meridian exchange socket failed. Start a fresh auction.")),this.socket.addEventListener("message",c=>{try{(typeof c.data!="string"||c.data.length>65536)&&i("Meridian returned a malformed exchange message.");let m=_(JSON.parse(c.data));if(m.type==="pong")return;let g=v(m.type),l=_(m.payload);if(g==="error"&&i("Meridian rejected or failed the exchange. Start a fresh auction."),g===`${d}.ack`){this.auctionId===void 0?((l.id!==t||this.accepting||l.accepted!==void 0)&&i("Meridian acknowledged a different exchange."),l.error!==void 0&&i(`Meridian rejected the exchange: ${O(v(l.error))}.`),this.auctionId=v(l.auctionId)):((!this.accepting||l.auctionId!==this.auctionId||l.id!==void 0&&l.id!==t)&&i("Meridian acknowledged a different exchange."),l.error!==void 0&&i(`Meridian rejected acceptance: ${O(v(l.error))}.`),l.accepted!==!0&&i("Meridian rejected acceptance of the exchange."));return}if((!g.startsWith(`${d}.`)||l.auctionId!==this.auctionId||!this.auctionId)&&i("Meridian returned a message for a different exchange."),["error","rejected","failed","expired"].some(I=>g===`${d}.${I}`)){let I=["reason","makerReason"].flatMap(D=>l[D]===void 0?[]:[`${D}=${O(v(l[D]))}`]);i(`Meridian exchange ${g.slice(d.length+1)}${I.length?`: ${I.join("; ")}`:""}. Start a fresh auction.`)}if((g===`${d}.pending`||g===`${d}.filled`)&&!this.accepting&&i("Meridian returned settlement before acceptance."),g===`${d}.pending`)return;this.queue.length>=16&&i("Meridian returned too many exchange messages."),this.queue.push({type:g,payload:l}),this.notify?.()}catch(m){this.stop(m instanceof N?m.message:"Meridian rejected or returned an invalid exchange message. Start a fresh auction.")}})}id;prefix;socket;queue=[];notify;error;auctionId;accepting=!1;opened=!1;check(){if(this.error)throw this.error;this.socket.readyState>1&&i("Meridian exchange socket was lost. Start a fresh auction.")}stop(t){this.error??=new N(t),this.notify?.(),this.socket.readyState<2&&this.socket.close()}async wait(t,d=3e4){return new Promise((c,m)=>{let g=setTimeout(()=>this.stop("Meridian exchange timed out. Start a fresh auction."),d),l=()=>{try{if(this.check(),t===void 0?!this.opened:!this.queue.length)return;let I=t===void 0?void 0:this.queue.shift();I&&I.type!==`${this.prefix}.${t}`&&i("Meridian returned an unexpected exchange stage."),clearTimeout(g),this.notify=void 0,c(I?.payload??{})}catch(I){clearTimeout(g),this.notify=void 0,m(I)}};this.notify=l,l()})}send(t,d){this.check(),this.socket.readyState!==1&&i("Meridian exchange socket is not open."),t==="accept"&&(this.accepting=!0),this.socket.send(JSON.stringify({...t==="start"?{id:this.id}:{},type:`${this.prefix}.${t}`,payload:d}))}};function te(n){return ie(ne(ke,[n]))}function De(n,t,d){return ie(ne(Ie,[te(n.picks),BigInt(n.stake),BigInt(d.counterpartyCollateral),t,d.counterparty,L,"0x"]))}function qe(n,t,d,c){return ie(ne(Se,[n.token,$.address,t,d,BigInt(n.amount),BigInt(c)]))}function Y(n,t){let{input:d,wallet:c,nonce:m,deadline:g}=n,l={name:d.side==="buy"?"PredictionMarketEscrow":"SecondaryMarketEscrow",version:"1",chainId:k,verifyingContract:n.continuation.escrowContract};return(!m||!g)&&i("Meridian exchange is missing its signing terms."),d.side==="buy"?(t||i("Meridian has not returned a winning bid."),{domain:l,primaryType:"MintApproval",types:{MintApproval:Ae},message:{predictionHash:De(d,c,t),signer:c,collateral:d.stake,nonce:m,deadline:g}}):{domain:l,primaryType:"TradeApproval",types:{TradeApproval:Ce},message:{tradeHash:qe(d,c,t?t.buyer:L,t?t.price:"0"),signer:c,nonce:m,deadline:g}}}function fe(n){let t=[BigInt(n.deadline)],d=n.continuation;if(d.stage==="primary_accept"||d.stage==="secondary_accept"){t.push(BigInt(d.acceptDeadline));let c=d.winningBid;d.stage==="primary_accept"&&t.push(BigInt(c.counterpartyDeadline)),c.buyerDeadline!==void 0&&t.push(BigInt(M(c.buyerDeadline,"the buyer deadline",!0)))}return t.reduce((c,m)=>c<m?c:m)}function H(n){n.channel?.check(),n.deadline&&j()>=fe(n)&&i("Meridian exchange expired. Start a fresh auction.")}var Oe=n=>{let t=new Map;function d(e){clearTimeout(e.timer),t.delete(e.continuation.requestId),e.channel?.stop("Meridian exchange is closed or expired. Start a fresh auction.")}function c(e,a){clearTimeout(e.timer),e.timer=setTimeout(()=>d(e),a),e.timer.unref?.()}function m(e){let{wallet:a,chainId:s,escrowContract:f,requestId:u}=e.continuation;return{wallet:a,chainId:s,escrowContract:f,requestId:u}}function g(e){return e.side!=="sell"?"":` Effective minimum sale proceeds: ${e.minPrice} USDe base units (${$.address}, 18 decimals). ${e.priceFloorSource==="explicit"?"Caller minPrice is unchanged; slippageBps does not reduce this floor.":`Default floor with ${e.slippageBps??0} bps slippage applied.`}`}async function l(e){let{input:a,wallet:s}=e,f=n.clientFor(k),u=a.side==="buy"?$.address:a.token,r=a.side==="buy"?a.stake:a.amount,[h,w]=await Promise.all([f.readContract({address:u,abi:J,functionName:"balanceOf",args:[s]}),f.readContract({address:u,abi:J,functionName:"allowance",args:[s,e.continuation.escrowContract]})]);if(a.side==="sell"&&await f.readContract({address:u,abi:J,functionName:"decimals"})!==18&&i("Meridian position tokens must have 18 decimals."),h>=BigInt(r)&&w>=BigInt(r))return;(e.continuation.stage==="primary_accept"||e.continuation.stage==="secondary_accept")&&i("Meridian prerequisites changed during the auction. Start a fresh auction after funding and approval.");let p,C;if(h<BigInt(r)){a.side==="sell"&&i("The wallet does not have enough position tokens to sell."),a.usdgAmountIn||i("Not enough USDe. Provide usdgAmountIn in USDG base units to quote a swap before the auction.");let b=await n.quoteSwap({from:G,to:$.address,amountIn:a.usdgAmountIn,...a.slippageBps===void 0?{}:{slippageBps:a.slippageBps}},s);(j()>=BigInt(M(b.expiresAt,"the swap expiry"))||BigInt(M(b.minAmountOut,"the swap minimum"))+h<BigInt(r))&&i("The USDG swap minimum does not cover the USDe stake, or the quote expired. Request a fresh quote with sufficient input.");let o=await n.buildSwap(b.quoteId,s);(!("txs"in o)||!o.txs.length)&&i("The swap coordinator did not return prerequisite transactions."),p=o.txs,C=`${o.summary} Minimum USDe output: ${b.minAmountOut} base units (18 decimals).`}else p=[n.approval(u,e.continuation.escrowContract,r,k)],C=`Approve exactly ${r} base units (18 decimals) of ${u} for ${e.continuation.escrowContract} on chain ${k}.`;p.some(b=>b.chainId!==k)&&i("Meridian prerequisite transactions must use chain 4663.");let q=await n.preview(p,s),T=q.changes.map(b=>{let o=b.amount.startsWith("-");return`${o?"-":"+"}${n.formatAmount(o?b.amount.slice(1):b.amount,b.token.decimals)} ${b.token.symbol} (${b.token.address}, chain ${b.token.chainId}, ${b.token.decimals} decimals)`}).join("; ");return e.channel?.stop("Meridian prerequisites must be mined before the auction."),e.channel=void 0,e.deadline=void 0,e.nonce=void 0,e.continuation={...m(e),stage:"prerequisites"},{steps:p.map(b=>({kind:"tx",tx:b})),continuation:structuredClone(e.continuation),summary:`${C}${g(a)} ${q.summary} ${T}. Mine these prerequisites before continuing; no RFQ has started.`}}function I(e){let a=e.continuation;a.stage==="prerequisites"&&i("Meridian prerequisites need to finish before signing."),H(e),c(e,Number(fe(e)-j())*1e3);let s=e.input,f=s.side==="buy"?`Stake ${s.stake} base units of USDe (${$.address}, 18 decimals)`:`Sell ${s.amount} base units of position ${s.token} (18 decimals)`,u=a.stage==="secondary_start"?"Initial buyer-zero, price-zero intent only.":a.stage==="primary_accept"?`Counterparty ${a.winningBid.counterparty}; counterparty collateral ${a.winningBid.counterpartyCollateral} USDe base units; counterparty deadline ${a.winningBid.counterpartyDeadline}.`:`Buyer ${a.winningBid.buyer}; receive ${a.winningBid.price} USDe base units (${$.address}, 18 decimals).`;return{steps:[{kind:"typedData",request:structuredClone(a.request)}],continuation:structuredClone(a),summary:`${f} on chain ${k}.${g(s)} Approval was checked on chain. ${u} Sign locally for domain ${a.request.domain.name}, version 1, escrow ${a.escrowContract}, signature deadline ${e.deadline}${"acceptDeadline"in a?`, acceptance deadline ${a.acceptDeadline}`:""}. External relayer settlement is pending; a signature is not a fill.`}}async function D(e){let a=await e.channel.wait("result"),s=_(a.winningBid),f=v(a.auctionId);s.auctionId!==f&&i("Meridian winning bid belongs to another auction.");let u=M(a.acceptDeadline,"the acceptance deadline",!0);if(e.input.side==="buy"){let r={auctionId:f,counterparty:v(s.counterparty),counterpartyCollateral:M(s.counterpartyCollateral,"the counterparty collateral"),counterpartyNonce:M(s.counterpartyNonce,"the counterparty nonce",!0),counterpartyDeadline:M(s.counterpartyDeadline,"the counterparty deadline",!0),receivedAt:v(s.receivedAt)};R(r.counterparty),(!Number.isFinite(Date.parse(r.receivedAt))||BigInt(r.counterpartyCollateral)<=1n||BigInt(r.counterpartyCollateral)<BigInt(e.input.minCounterpartyCollateral))&&i("Meridian winning bid counterparty collateral is below the caller minimum."),e.continuation={...m(e),stage:"primary_accept",auctionId:f,winningBid:r,acceptDeadline:u,request:Y(e,r)}}else{let r={auctionId:f,buyer:v(s.buyer),price:M(s.price,"the sale price"),...s.buyerDeadline!==void 0?{buyerDeadline:M(s.buyerDeadline,"the buyer deadline",!0)}:{},...s.buyerNonce!==void 0?{buyerNonce:M(s.buyerNonce,"the buyer nonce",!0)}:{},...s.receivedAt!==void 0?{receivedAt:v(s.receivedAt)}:{}};R(r.buyer),(BigInt(r.price)<=1n||BigInt(r.price)<BigInt(e.input.minPrice))&&i("Meridian winning bid sale price is below the caller minimum."),e.continuation={...m(e),stage:"secondary_accept",auctionId:f,winningBid:r,acceptDeadline:u,request:Y(e,r)}}return I(e)}async function S(e,a){let s=e.continuation;s.stage!=="primary_accept"&&s.stage!=="secondary_accept"&&i("Meridian exchange is not ready for acceptance."),H(e),e.channel.send("accept",{auctionId:s.auctionId,[e.input.side==="buy"?"predictorSignature":"sellerSignature"]:a}),c(e,15e4);let f=await e.channel.wait("filled",12e4),u=Z(f.transactionHash,32),r=n.clientFor(k),[h,w]=await Promise.all([r.waitForTransactionReceipt({hash:u,timeout:12e4}),r.getTransaction({hash:u})]);(h.status!=="success"||!y(h.transactionHash,u)||!y(w.hash,u)||!y(h.to,s.escrowContract)||!y(w.to,s.escrowContract)||w.chainId!==k)&&i("Meridian fill has no matching successful receipt on chain 4663.");let{input:p,wallet:C}=e;if(p.side==="buy"&&s.stage==="primary_accept"){let o=me({abi:Be,data:w.input}).args[0];(!y(te([...o.picks]),te(p.picks))||o.predictorCollateral!==BigInt(p.stake)||o.counterpartyCollateral!==BigInt(s.winningBid.counterpartyCollateral)||!y(o.predictor,C)||!y(o.counterparty,s.winningBid.counterparty)||o.predictorNonce!==BigInt(e.nonce)||o.predictorDeadline!==BigInt(e.deadline)||!y(o.predictorSponsor,L)||o.predictorSponsorData!=="0x"||!y(o.predictorSignature,a))&&i("Meridian mint receipt does not match the accepted prediction.")}else if(p.side==="sell"&&s.stage==="secondary_accept"){let o=me({abi:Me,data:w.input}).args[0];(!y(o.token,p.token)||!y(o.collateral,$.address)||!y(o.seller,C)||!y(o.buyer,s.winningBid.buyer)||o.tokenAmount!==BigInt(p.amount)||o.price!==BigInt(s.winningBid.price)||o.sellerNonce!==BigInt(e.nonce)||o.sellerDeadline!==BigInt(e.deadline)||!y(o.sellerSignature,a))&&i("Meridian sale receipt does not match the accepted trade.")}let q=new Map,T=new Map;for(let o of h.logs){if(o.topics[0]!==$e||o.topics.length!==3)continue;(!/^0x[0-9a-fA-F]{64}$/.test(o.data)||!o.topics.slice(1).every(ye=>/^0x0{24}[0-9a-fA-F]{40}$/.test(ye)))&&i("Meridian receipt has malformed transfer logs.");let E=`0x${o.topics[1].slice(-40)}`,U=`0x${o.topics[2].slice(-40)}`,P=o.address.toLowerCase(),z=BigInt(o.data);q.set(P,(q.get(P)??0n)+(y(U,C)?z:0n)-(y(E,C)?z:0n)),y(E,L)&&y(U,C)&&T.set(P,(T.get(P)??0n)+z)}let b;if(p.side==="buy"&&s.stage==="primary_accept"){let o=BigInt(p.stake)+BigInt(s.winningBid.counterpartyCollateral),E=[...T].filter(([U,P])=>!y(U,$.address)&&P===o&&q.get(U)===o);(E.length!==1||q.get($.address.toLowerCase())!==-BigInt(p.stake))&&i("Meridian mint receipt does not prove the expected collateral and position delta."),b=`${o} base units received in position ${E[0][0]}`}else p.side==="sell"&&s.stage==="secondary_accept"?((q.get(p.token.toLowerCase())!==-BigInt(p.amount)||q.get($.address.toLowerCase())!==BigInt(s.winningBid.price))&&i("Meridian sale receipt does not prove the expected collateral and position delta."),b=`${p.amount} base units sold from position ${p.token}; ${s.winningBid.price} USDe base units received`):i("Meridian fill has a different exchange stage.");return{txs:[],hashes:[u],status:"mined",summary:`Mined: ${u}. Status: mined. Meridian ${p.side} filled by the external relayer. Successful receipt and transfer deltas verified on chain ${k}: ${b} (18 decimals); collateral USDe ${$.address} (18 decimals).`}}async function B(e,a,s){let f=R(s),u=ve(e,a),r;if(a.continuation!==void 0){let h=_(a.continuation),w=t.get(v(h.requestId));w||i("Meridian exchange is lost or expired. Start a fresh auction."),(!y(w.wallet,f)||!pe(w.input,u)||!pe(w.continuation,h))&&i("Meridian continuation or arguments do not match the active wallet exchange."),w.busy&&i("Meridian exchange is already processing this continuation."),r=w}else{a.signature!==void 0&&i("A signature requires an active Meridian continuation."),t.size>=1e3&&i("Too many active Meridian exchanges. Please try again later.");let h=he(),w=setTimeout(()=>{let p=t.get(h);p&&d(p)},9e5);w.unref?.(),r={input:u,wallet:f,continuation:{stage:"prerequisites",wallet:f,chainId:k,escrowContract:e==="buy"?Q:V,requestId:h},busy:!1,timer:w},t.set(h,r)}r.busy=!0;try{H(r),await n.clientFor(k).getChainId()!==k&&i("Meridian requires an RPC on chain 4663.");let h=r.continuation.stage;h==="prerequisites"&&a.signature!==void 0&&i("Do not sign before Meridian prerequisites have mined.");let w=await l(r);if(w)return w;if(h==="prerequisites")return r.nonce=(ge(4).readUInt32BE()+1).toString(),r.deadline=(j()+300n).toString(),await n.clientFor(k).readContract({address:r.continuation.escrowContract,abi:X,functionName:"isNonceUsed",args:[f,BigInt(r.nonce)]})&&i(`Meridian ${e==="buy"?"predictor":"seller"} nonce is already used. Start a fresh auction.`),r.channel=new ee(r.continuation.requestId,e==="buy"?"auction":"secondary.auction"),await r.channel.wait(),u.side==="buy"?(r.channel.send("start",{id:r.continuation.requestId,picks:u.picks,predictorCollateral:u.stake,predictor:f,predictorNonce:F(r.nonce),predictorDeadline:F(r.deadline),chainId:k,escrowContract:Q,mode:"blind"}),await D(r)):(r.continuation={...m(r),stage:"secondary_start",request:Y(r)},I(r));let p=Z(a.signature);if(e==="sell"&&await n.clientFor(k).readContract({address:V,abi:X,functionName:"isNonceUsed",args:[f,BigInt(r.nonce)]})&&i("Meridian seller nonce is already used. Start a fresh auction."),e==="buy"&&await n.clientFor(k).readContract({address:Q,abi:X,functionName:"isNonceUsed",args:[f,BigInt(r.nonce)]})&&i("Meridian predictor nonce is already used. Start a fresh auction."),H(r),h==="secondary_start"&&u.side==="sell")return r.channel.send("start",{id:r.continuation.requestId,token:u.token,collateral:$.address,tokenAmount:u.amount,seller:f,sellerNonce:F(r.nonce),sellerDeadline:F(r.deadline),chainId:k,escrowContract:V,mode:"blind",sellerSignature:p}),await D(r);let C=await S(r,p);return d(r),C}catch(h){throw d(r),new N(n.plainError(h))}finally{r.busy=!1}}let A={continuation:{type:"object"},signature:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$"}};return{tools:[{name:"meridian_buy",inputSchema:{type:"object",additionalProperties:!1,required:["picks","stake"],properties:{...A,stake:x("USDe stake in base units, 18 decimals, chain 4663."),minCounterpartyCollateral:x("Optional caller minimum counterparty collateral in USDe base units, 18 decimals."),usdgAmountIn:x("Optional exact USDG swap input in base units, 6 decimals, if USDe balance is insufficient."),slippageBps:{type:"integer",minimum:0,maximum:9999},picks:{type:"array",minItems:1,maxItems:10,items:{type:"object",additionalProperties:!1,required:["conditionResolver","conditionId","predictedOutcome"],properties:{conditionResolver:W,conditionId:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$"},predictedOutcome:{type:"integer",enum:[0,1]}}}}}},execute:(e,a)=>B("buy",e,a)},{name:"meridian_sell",inputSchema:{type:"object",additionalProperties:!1,required:["token","amount"],properties:{...A,token:{...W,description:"Position token address on chain 4663."},amount:x("Position amount in base units, 18 decimals."),minPrice:x("Optional minimum total sale proceeds in USDe base units, 18 decimals. Explicit minPrice is never reduced by slippageBps."),slippageBps:{type:"integer",minimum:0,maximum:9999,description:"Applied only to the default sale floor when minPrice is omitted."}}},execute:(e,a)=>B("sell",e,a)}]}};export{Ae as a,Ce as b,Oe as c};
1
+ import{b as le,o as K}from"./CAU44UWP.js";import{b as x}from"./UWOFA6GV.js";import{c as W,f as de,h as y,i as ce,l as ue}from"./73N3TOJL.js";import{a as k,i as oe,j as G}from"./XPFVT2EA.js";import{a as N}from"./5YS5V2LK.js";import{a as O}from"./JXOEJPJ4.js";import{randomBytes as ge,randomUUID as he}from"node:crypto";import{isDeepStrictEqual as pe}from"node:util";import{decodeFunctionData as me,encodeAbiParameters as ne,erc20Abi as J,keccak256 as ie,parseAbi as re,parseAbiParameters as ae,toEventSelector as be,zeroAddress as L}from"viem";var se=oe[k].meridian,Q=se.PredictionMarketEscrow.address,V=se.SecondaryMarketEscrow.address,$={address:se.CollateralToken_USDe.address,chainId:k,symbol:"USDe",decimals:18},we="wss://relayer.predict.meridian.xyz/auction",ke=ae("(address conditionResolver,bytes conditionId,uint8 predictedOutcome)[]"),Ie=ae("bytes32,uint256,uint256,address,address,address,bytes"),Se=ae("address,address,address,address,uint256,uint256"),X=re(["function isNonceUsed(address,uint256) view returns (bool)"]),Be=re(["function mint(((address conditionResolver,bytes conditionId,uint8 predictedOutcome)[] picks,uint256 predictorCollateral,uint256 counterpartyCollateral,address predictor,address counterparty,uint256 predictorNonce,uint256 counterpartyNonce,uint256 predictorDeadline,uint256 counterpartyDeadline,bytes predictorSignature,bytes counterpartySignature,bytes32 refCode,bytes predictorSessionKeyData,bytes counterpartySessionKeyData,address predictorSponsor,bytes predictorSponsorData) request)"]),Me=re(["function executeTrade((address token,address collateral,address seller,address buyer,uint256 tokenAmount,uint256 price,uint256 sellerNonce,uint256 buyerNonce,uint256 sellerDeadline,uint256 buyerDeadline,bytes sellerSignature,bytes buyerSignature,bytes32 refCode,bytes sellerSessionKeyData,bytes buyerSessionKeyData) request)"]),$e=be("Transfer(address,address,uint256)"),Ae=[{name:"predictionHash",type:"bytes32"},{name:"signer",type:"address"},{name:"collateral",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}],Ce=[{name:"tradeHash",type:"bytes32"},{name:"signer",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}];function i(n){throw new N(n)}function _(n){return de(n,"Meridian returned an invalid exchange object.")}function M(n,t,d=!1){return d&&typeof n=="number"&&Number.isSafeInteger(n)&&n>=0&&(n=String(n)),(typeof n!="string"||!/^\d+$/.test(n)||BigInt(n)>=1n<<256n)&&i(`Provide ${t} as a decimal base-unit integer string.`),n}function F(n){let t=Number(n);return(!Number.isSafeInteger(t)||t<0||BigInt(t)!==BigInt(n))&&i("Meridian signing terms cannot be represented exactly as JSON numbers."),t}function R(n){let t="Provide a nonzero token, resolver or wallet address.";return ue(ce(n,t),t)}function Z(n,t){return(typeof n!="string"||!/^0x(?:[0-9a-fA-F]{2})+$/.test(n)||t!==void 0&&n.length!==2+t*2)&&i("Meridian returned invalid hexadecimal data."),n}function v(n){return(typeof n!="string"||n.length===0||n.length>256)&&i("Meridian returned an invalid exchange identifier."),n}function j(){return BigInt(Math.floor(Date.now()/1e3))}function ve(n,t){let d=n==="buy"?["picks","stake","minCounterpartyCollateral","usdgAmountIn","slippageBps","continuation","signature"]:["token","amount","minPrice","slippageBps","continuation","signature"];Object.keys(t).some(S=>!d.includes(S))&&i("Unsupported Meridian arguments; use the tool input schema."),t.slippageBps!==void 0&&(typeof t.slippageBps!="number"||!Number.isInteger(t.slippageBps)||t.slippageBps<0||t.slippageBps>=1e4)&&i("Slippage must be an integer from 0 to 9999 basis points.");let c=t.slippageBps;if(n==="sell"){let S=M(t.amount,"the position amount");BigInt(S)===0n&&i("The position amount must be positive.");let B=R(t.token);(y(B,$.address)||y(B,G))&&i("Choose a Meridian position token to sell.");let A;if(t.minPrice!==void 0){let e=M(t.minPrice,"the minimum sale price");BigInt(e)<=1n&&i("The minimum sale price must be greater than 1 base unit."),A=e}else{let e=BigInt(S)/100n>10n**18n?BigInt(S)/100n:10n**18n;A=c===void 0?e.toString():K(e.toString(),c)}return{side:n,token:B,amount:S,minPrice:A,priceFloorSource:t.minPrice===void 0?"default":"explicit",...c===void 0?{}:{slippageBps:c}}}(!Array.isArray(t.picks)||t.picks.length<1||t.picks.length>10)&&i("Provide between one and ten Meridian picks.");let m=t.picks.map(S=>{let B=_(S);return(Object.keys(B).some(A=>!["conditionResolver","conditionId","predictedOutcome"].includes(A))||B.predictedOutcome!==0&&B.predictedOutcome!==1)&&i("Each pick needs a resolver, condition ID and outcome 0 or 1."),{conditionResolver:R(B.conditionResolver),conditionId:Z(B.conditionId),predictedOutcome:B.predictedOutcome}}).sort((S,B)=>{let A=`${S.conditionResolver.toLowerCase()}:${S.conditionId.toLowerCase()}:${S.predictedOutcome}`,e=`${B.conditionResolver.toLowerCase()}:${B.conditionId.toLowerCase()}:${B.predictedOutcome}`;return A<e?-1:A>e?1:0}),g=m.map(S=>`${S.conditionResolver.toLowerCase()}:${S.conditionId.toLowerCase()}`);new Set(g).size!==m.length&&i("Do not repeat a condition in the same prediction.");let l=M(t.stake,"the USDe stake");BigInt(l)<10n**18n&&i("Meridian requires a stake of at least 1 USDe.");let I=t.usdgAmountIn===void 0?void 0:M(t.usdgAmountIn,"the USDG swap amount");I!==void 0&&BigInt(I)===0n&&i("The USDG swap amount must be positive.");let D=t.minCounterpartyCollateral!==void 0?M(t.minCounterpartyCollateral,"the minimum counterparty collateral"):K(l,c??le);return BigInt(D)<=1n&&i("The minimum counterparty collateral must be greater than 1 base unit."),{side:n,picks:m,stake:l,minCounterpartyCollateral:D,...I===void 0?{}:{usdgAmountIn:I},...c===void 0?{}:{slippageBps:c}}}var ee=class{constructor(t,d){this.id=t;this.prefix=d;this.socket=new globalThis.WebSocket(we),this.socket.addEventListener("open",()=>{this.opened=!0,this.notify?.()}),this.socket.addEventListener("close",()=>this.stop("Meridian exchange socket was lost. Start a fresh auction.")),this.socket.addEventListener("error",()=>this.stop("Meridian exchange socket failed. Start a fresh auction.")),this.socket.addEventListener("message",c=>{try{(typeof c.data!="string"||c.data.length>65536)&&i("Meridian returned a malformed exchange message.");let m=_(JSON.parse(c.data));if(m.type==="pong")return;let g=v(m.type),l=_(m.payload);if(g==="error"&&i("Meridian rejected or failed the exchange. Start a fresh auction."),g===`${d}.ack`){this.auctionId===void 0?((l.id!==t||this.accepting||l.accepted!==void 0)&&i("Meridian acknowledged a different exchange."),l.error!==void 0&&i(`Meridian rejected the exchange: ${O(v(l.error))}.`),this.auctionId=v(l.auctionId)):((!this.accepting||l.auctionId!==this.auctionId||l.id!==void 0&&l.id!==t)&&i("Meridian acknowledged a different exchange."),l.error!==void 0&&i(`Meridian rejected acceptance: ${O(v(l.error))}.`),l.accepted!==!0&&i("Meridian rejected acceptance of the exchange."));return}if((!g.startsWith(`${d}.`)||l.auctionId!==this.auctionId||!this.auctionId)&&i("Meridian returned a message for a different exchange."),["error","rejected","failed","expired"].some(I=>g===`${d}.${I}`)){let I=["reason","makerReason"].flatMap(D=>l[D]===void 0?[]:[`${D}=${O(v(l[D]))}`]);i(`Meridian exchange ${g.slice(d.length+1)}${I.length?`: ${I.join("; ")}`:""}. Start a fresh auction.`)}if((g===`${d}.pending`||g===`${d}.filled`)&&!this.accepting&&i("Meridian returned settlement before acceptance."),g===`${d}.pending`)return;this.queue.length>=16&&i("Meridian returned too many exchange messages."),this.queue.push({type:g,payload:l}),this.notify?.()}catch(m){this.stop(m instanceof N?m.message:"Meridian rejected or returned an invalid exchange message. Start a fresh auction.")}})}id;prefix;socket;queue=[];notify;error;auctionId;accepting=!1;opened=!1;check(){if(this.error)throw this.error;this.socket.readyState>1&&i("Meridian exchange socket was lost. Start a fresh auction.")}stop(t){this.error??=new N(t),this.notify?.(),this.socket.readyState<2&&this.socket.close()}async wait(t,d=3e4){return new Promise((c,m)=>{let g=setTimeout(()=>this.stop("Meridian exchange timed out. Start a fresh auction."),d),l=()=>{try{if(this.check(),t===void 0?!this.opened:!this.queue.length)return;let I=t===void 0?void 0:this.queue.shift();I&&I.type!==`${this.prefix}.${t}`&&i("Meridian returned an unexpected exchange stage."),clearTimeout(g),this.notify=void 0,c(I?.payload??{})}catch(I){clearTimeout(g),this.notify=void 0,m(I)}};this.notify=l,l()})}send(t,d){this.check(),this.socket.readyState!==1&&i("Meridian exchange socket is not open."),t==="accept"&&(this.accepting=!0),this.socket.send(JSON.stringify({...t==="start"?{id:this.id}:{},type:`${this.prefix}.${t}`,payload:d}))}};function te(n){return ie(ne(ke,[n]))}function De(n,t,d){return ie(ne(Ie,[te(n.picks),BigInt(n.stake),BigInt(d.counterpartyCollateral),t,d.counterparty,L,"0x"]))}function qe(n,t,d,c){return ie(ne(Se,[n.token,$.address,t,d,BigInt(n.amount),BigInt(c)]))}function Y(n,t){let{input:d,wallet:c,nonce:m,deadline:g}=n,l={name:d.side==="buy"?"PredictionMarketEscrow":"SecondaryMarketEscrow",version:"1",chainId:k,verifyingContract:n.continuation.escrowContract};return(!m||!g)&&i("Meridian exchange is missing its signing terms."),d.side==="buy"?(t||i("Meridian has not returned a winning bid."),{domain:l,primaryType:"MintApproval",types:{MintApproval:Ae},message:{predictionHash:De(d,c,t),signer:c,collateral:d.stake,nonce:m,deadline:g}}):{domain:l,primaryType:"TradeApproval",types:{TradeApproval:Ce},message:{tradeHash:qe(d,c,t?t.buyer:L,t?t.price:"0"),signer:c,nonce:m,deadline:g}}}function fe(n){let t=[BigInt(n.deadline)],d=n.continuation;if(d.stage==="primary_accept"||d.stage==="secondary_accept"){t.push(BigInt(d.acceptDeadline));let c=d.winningBid;d.stage==="primary_accept"&&t.push(BigInt(c.counterpartyDeadline)),c.buyerDeadline!==void 0&&t.push(BigInt(M(c.buyerDeadline,"the buyer deadline",!0)))}return t.reduce((c,m)=>c<m?c:m)}function H(n){n.channel?.check(),n.deadline&&j()>=fe(n)&&i("Meridian exchange expired. Start a fresh auction.")}var Oe=n=>{let t=new Map;function d(e){clearTimeout(e.timer),t.delete(e.continuation.requestId),e.channel?.stop("Meridian exchange is closed or expired. Start a fresh auction.")}function c(e,a){clearTimeout(e.timer),e.timer=setTimeout(()=>d(e),a),e.timer.unref?.()}function m(e){let{wallet:a,chainId:s,escrowContract:f,requestId:u}=e.continuation;return{wallet:a,chainId:s,escrowContract:f,requestId:u}}function g(e){return e.side!=="sell"?"":` Effective minimum sale proceeds: ${e.minPrice} USDe base units (${$.address}, 18 decimals). ${e.priceFloorSource==="explicit"?"Caller minPrice is unchanged; slippageBps does not reduce this floor.":`Default floor with ${e.slippageBps??0} bps slippage applied.`}`}async function l(e){let{input:a,wallet:s}=e,f=n.clientFor(k),u=a.side==="buy"?$.address:a.token,r=a.side==="buy"?a.stake:a.amount,[h,w]=await Promise.all([f.readContract({address:u,abi:J,functionName:"balanceOf",args:[s]}),f.readContract({address:u,abi:J,functionName:"allowance",args:[s,e.continuation.escrowContract]})]);if(a.side==="sell"&&await f.readContract({address:u,abi:J,functionName:"decimals"})!==18&&i("Meridian position tokens must have 18 decimals."),h>=BigInt(r)&&w>=BigInt(r))return;(e.continuation.stage==="primary_accept"||e.continuation.stage==="secondary_accept")&&i("Meridian prerequisites changed during the auction. Start a fresh auction after funding and approval.");let p,C;if(h<BigInt(r)){a.side==="sell"&&i("The wallet does not have enough position tokens to sell."),a.usdgAmountIn||i("Not enough USDe. Provide usdgAmountIn in USDG base units to quote a swap before the auction.");let b=await n.quoteSwap({from:G,to:$.address,amountIn:a.usdgAmountIn,...a.slippageBps===void 0?{}:{slippageBps:a.slippageBps}},s);(j()>=BigInt(M(b.expiresAt,"the swap expiry"))||BigInt(M(b.minAmountOut,"the swap minimum"))+h<BigInt(r))&&i("The USDG swap minimum does not cover the USDe stake, or the quote expired. Request a fresh quote with sufficient input.");let o=await n.buildSwap(b.quoteId,s);(!("txs"in o)||!o.txs.length)&&i("The swap coordinator did not return prerequisite transactions."),p=o.txs,C=`${o.summary} Minimum USDe output: ${b.minAmountOut} base units (18 decimals).`}else p=[n.approval(u,e.continuation.escrowContract,r,k)],C=`Approve exactly ${r} base units (18 decimals) of ${u} for ${e.continuation.escrowContract} on chain ${k}.`;p.some(b=>b.chainId!==k)&&i("Meridian prerequisite transactions must use chain 4663.");let q=await n.preview(p,s),T=q.changes.map(b=>{let o=b.amount.startsWith("-");return`${o?"-":"+"}${n.formatAmount(o?b.amount.slice(1):b.amount,b.token.decimals)} ${b.token.symbol} (${b.token.address}, chain ${b.token.chainId}, ${b.token.decimals} decimals)`}).join("; ");return e.channel?.stop("Meridian prerequisites must be mined before the auction."),e.channel=void 0,e.deadline=void 0,e.nonce=void 0,e.continuation={...m(e),stage:"prerequisites"},{steps:p.map(b=>({kind:"tx",tx:b})),continuation:structuredClone(e.continuation),summary:`${C}${g(a)} ${q.summary} ${T}. Mine these prerequisites before continuing; no RFQ has started.`}}function I(e){let a=e.continuation;a.stage==="prerequisites"&&i("Meridian prerequisites need to finish before signing."),H(e),c(e,Number(fe(e)-j())*1e3);let s=e.input,f=s.side==="buy"?`Stake ${s.stake} base units of USDe (${$.address}, 18 decimals)`:`Sell ${s.amount} base units of position ${s.token} (18 decimals)`,u=a.stage==="secondary_start"?"Initial buyer-zero, price-zero intent only.":a.stage==="primary_accept"?`Counterparty ${a.winningBid.counterparty}; counterparty collateral ${a.winningBid.counterpartyCollateral} USDe base units; counterparty deadline ${a.winningBid.counterpartyDeadline}.`:`Buyer ${a.winningBid.buyer}; receive ${a.winningBid.price} USDe base units (${$.address}, 18 decimals).`;return{steps:[{kind:"typedData",request:structuredClone(a.request)}],continuation:structuredClone(a),summary:`${f} on chain ${k}.${g(s)} Approval was checked on chain. ${u} Sign locally for domain ${a.request.domain.name}, version 1, escrow ${a.escrowContract}, signature deadline ${e.deadline}${"acceptDeadline"in a?`, acceptance deadline ${a.acceptDeadline}`:""}. External relayer settlement is pending; a signature is not a fill.`}}async function D(e){let a=await e.channel.wait("result"),s=_(a.winningBid),f=v(a.auctionId);s.auctionId!==f&&i("Meridian winning bid belongs to another auction.");let u=M(a.acceptDeadline,"the acceptance deadline",!0);if(e.input.side==="buy"){let r={auctionId:f,counterparty:v(s.counterparty),counterpartyCollateral:M(s.counterpartyCollateral,"the counterparty collateral"),counterpartyNonce:M(s.counterpartyNonce,"the counterparty nonce",!0),counterpartyDeadline:M(s.counterpartyDeadline,"the counterparty deadline",!0),receivedAt:v(s.receivedAt)};R(r.counterparty),(!Number.isFinite(Date.parse(r.receivedAt))||BigInt(r.counterpartyCollateral)<=1n||BigInt(r.counterpartyCollateral)<BigInt(e.input.minCounterpartyCollateral))&&i("Meridian winning bid counterparty collateral is below the caller minimum."),e.continuation={...m(e),stage:"primary_accept",auctionId:f,winningBid:r,acceptDeadline:u,request:Y(e,r)}}else{let r={auctionId:f,buyer:v(s.buyer),price:M(s.price,"the sale price"),...s.buyerDeadline!==void 0?{buyerDeadline:M(s.buyerDeadline,"the buyer deadline",!0)}:{},...s.buyerNonce!==void 0?{buyerNonce:M(s.buyerNonce,"the buyer nonce",!0)}:{},...s.receivedAt!==void 0?{receivedAt:v(s.receivedAt)}:{}};R(r.buyer),(BigInt(r.price)<=1n||BigInt(r.price)<BigInt(e.input.minPrice))&&i("Meridian winning bid sale price is below the caller minimum."),e.continuation={...m(e),stage:"secondary_accept",auctionId:f,winningBid:r,acceptDeadline:u,request:Y(e,r)}}return I(e)}async function S(e,a){let s=e.continuation;s.stage!=="primary_accept"&&s.stage!=="secondary_accept"&&i("Meridian exchange is not ready for acceptance."),H(e),e.channel.send("accept",{auctionId:s.auctionId,[e.input.side==="buy"?"predictorSignature":"sellerSignature"]:a}),c(e,15e4);let f=await e.channel.wait("filled",12e4),u=Z(f.transactionHash,32),r=n.clientFor(k),[h,w]=await Promise.all([r.waitForTransactionReceipt({hash:u,timeout:12e4}),r.getTransaction({hash:u})]);(h.status!=="success"||!y(h.transactionHash,u)||!y(w.hash,u)||!y(h.to,s.escrowContract)||!y(w.to,s.escrowContract)||w.chainId!==k)&&i("Meridian fill has no matching successful receipt on chain 4663.");let{input:p,wallet:C}=e;if(p.side==="buy"&&s.stage==="primary_accept"){let o=me({abi:Be,data:w.input}).args[0];(!y(te([...o.picks]),te(p.picks))||o.predictorCollateral!==BigInt(p.stake)||o.counterpartyCollateral!==BigInt(s.winningBid.counterpartyCollateral)||!y(o.predictor,C)||!y(o.counterparty,s.winningBid.counterparty)||o.predictorNonce!==BigInt(e.nonce)||o.predictorDeadline!==BigInt(e.deadline)||!y(o.predictorSponsor,L)||o.predictorSponsorData!=="0x"||!y(o.predictorSignature,a))&&i("Meridian mint receipt does not match the accepted prediction.")}else if(p.side==="sell"&&s.stage==="secondary_accept"){let o=me({abi:Me,data:w.input}).args[0];(!y(o.token,p.token)||!y(o.collateral,$.address)||!y(o.seller,C)||!y(o.buyer,s.winningBid.buyer)||o.tokenAmount!==BigInt(p.amount)||o.price!==BigInt(s.winningBid.price)||o.sellerNonce!==BigInt(e.nonce)||o.sellerDeadline!==BigInt(e.deadline)||!y(o.sellerSignature,a))&&i("Meridian sale receipt does not match the accepted trade.")}let q=new Map,T=new Map;for(let o of h.logs){if(o.topics[0]!==$e||o.topics.length!==3)continue;(!/^0x[0-9a-fA-F]{64}$/.test(o.data)||!o.topics.slice(1).every(ye=>/^0x0{24}[0-9a-fA-F]{40}$/.test(ye)))&&i("Meridian receipt has malformed transfer logs.");let E=`0x${o.topics[1].slice(-40)}`,U=`0x${o.topics[2].slice(-40)}`,P=o.address.toLowerCase(),z=BigInt(o.data);q.set(P,(q.get(P)??0n)+(y(U,C)?z:0n)-(y(E,C)?z:0n)),y(E,L)&&y(U,C)&&T.set(P,(T.get(P)??0n)+z)}let b;if(p.side==="buy"&&s.stage==="primary_accept"){let o=BigInt(p.stake)+BigInt(s.winningBid.counterpartyCollateral),E=[...T].filter(([U,P])=>!y(U,$.address)&&P===o&&q.get(U)===o);(E.length!==1||q.get($.address.toLowerCase())!==-BigInt(p.stake))&&i("Meridian mint receipt does not prove the expected collateral and position delta."),b=`${o} base units received in position ${E[0][0]}`}else p.side==="sell"&&s.stage==="secondary_accept"?((q.get(p.token.toLowerCase())!==-BigInt(p.amount)||q.get($.address.toLowerCase())!==BigInt(s.winningBid.price))&&i("Meridian sale receipt does not prove the expected collateral and position delta."),b=`${p.amount} base units sold from position ${p.token}; ${s.winningBid.price} USDe base units received`):i("Meridian fill has a different exchange stage.");return{txs:[],hashes:[u],status:"mined",summary:`Mined: ${u}. Status: mined. Meridian ${p.side} filled by the external relayer. Successful receipt and transfer deltas verified on chain ${k}: ${b} (18 decimals); collateral USDe ${$.address} (18 decimals).`}}async function B(e,a,s){let f=R(s),u=ve(e,a),r;if(a.continuation!==void 0){let h=_(a.continuation),w=t.get(v(h.requestId));w||i("Meridian exchange is lost or expired. Start a fresh auction."),(!y(w.wallet,f)||!pe(w.input,u)||!pe(w.continuation,h))&&i("Meridian continuation or arguments do not match the active wallet exchange."),w.busy&&i("Meridian exchange is already processing this continuation."),r=w}else{a.signature!==void 0&&i("A signature requires an active Meridian continuation."),t.size>=1e3&&i("Too many active Meridian exchanges. Please try again later.");let h=he(),w=setTimeout(()=>{let p=t.get(h);p&&d(p)},9e5);w.unref?.(),r={input:u,wallet:f,continuation:{stage:"prerequisites",wallet:f,chainId:k,escrowContract:e==="buy"?Q:V,requestId:h},busy:!1,timer:w},t.set(h,r)}r.busy=!0;try{H(r),await n.clientFor(k).getChainId()!==k&&i("Meridian requires an RPC on chain 4663.");let h=r.continuation.stage;h==="prerequisites"&&a.signature!==void 0&&i("Do not sign before Meridian prerequisites have mined.");let w=await l(r);if(w)return w;if(h==="prerequisites")return r.nonce=(ge(4).readUInt32BE()+1).toString(),r.deadline=(j()+300n).toString(),await n.clientFor(k).readContract({address:r.continuation.escrowContract,abi:X,functionName:"isNonceUsed",args:[f,BigInt(r.nonce)]})&&i(`Meridian ${e==="buy"?"predictor":"seller"} nonce is already used. Start a fresh auction.`),r.channel=new ee(r.continuation.requestId,e==="buy"?"auction":"secondary.auction"),await r.channel.wait(),u.side==="buy"?(r.channel.send("start",{id:r.continuation.requestId,picks:u.picks,predictorCollateral:u.stake,predictor:f,predictorNonce:F(r.nonce),predictorDeadline:F(r.deadline),chainId:k,escrowContract:Q,mode:"blind"}),await D(r)):(r.continuation={...m(r),stage:"secondary_start",request:Y(r)},I(r));let p=Z(a.signature);if(e==="sell"&&await n.clientFor(k).readContract({address:V,abi:X,functionName:"isNonceUsed",args:[f,BigInt(r.nonce)]})&&i("Meridian seller nonce is already used. Start a fresh auction."),e==="buy"&&await n.clientFor(k).readContract({address:Q,abi:X,functionName:"isNonceUsed",args:[f,BigInt(r.nonce)]})&&i("Meridian predictor nonce is already used. Start a fresh auction."),H(r),h==="secondary_start"&&u.side==="sell")return r.channel.send("start",{id:r.continuation.requestId,token:u.token,collateral:$.address,tokenAmount:u.amount,seller:f,sellerNonce:F(r.nonce),sellerDeadline:F(r.deadline),chainId:k,escrowContract:V,mode:"blind",sellerSignature:p}),await D(r);let C=await S(r,p);return d(r),C}catch(h){throw d(r),new N(n.plainError(h))}finally{r.busy=!1}}let A={continuation:{type:"object"},signature:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$"}};return{tools:[{name:"meridian_buy",inputSchema:{type:"object",additionalProperties:!1,required:["picks","stake"],properties:{...A,stake:x("USDe stake in base units, 18 decimals, chain 4663."),minCounterpartyCollateral:x("Optional caller minimum counterparty collateral in USDe base units, 18 decimals."),usdgAmountIn:x("Optional exact USDG swap input in base units, 6 decimals, if USDe balance is insufficient."),slippageBps:{type:"integer",minimum:0,maximum:9999},picks:{type:"array",minItems:1,maxItems:10,items:{type:"object",additionalProperties:!1,required:["conditionResolver","conditionId","predictedOutcome"],properties:{conditionResolver:W,conditionId:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$"},predictedOutcome:{type:"integer",enum:[0,1]}}}}}},execute:(e,a)=>B("buy",e,a)},{name:"meridian_sell",inputSchema:{type:"object",additionalProperties:!1,required:["token","amount"],properties:{...A,token:{...W,description:"Position token address on chain 4663."},amount:x("Position amount in base units, 18 decimals."),minPrice:x("Optional minimum total sale proceeds in USDe base units, 18 decimals. Explicit minPrice is never reduced by slippageBps."),slippageBps:{type:"integer",minimum:0,maximum:9999,description:"Applied only to the default sale floor when minPrice is omitted."}}},execute:(e,a)=>B("sell",e,a)}]}};export{Ae as a,Ce as b,Oe as c};
@@ -1 +1 @@
1
- import{b as q}from"./EHVPRQHS.js";import{b as S}from"./HZUWK5B2.js";import{b as le}from"./AXYOJBX6.js";import{a as _}from"./6IM6A5VA.js";import{g as B,i as ue}from"./73N3TOJL.js";import{a as H}from"./RETS2ZEK.js";import{a as u,i as N}from"./XPFVT2EA.js";import{a as c}from"./5YS5V2LK.js";import{a as ce}from"./JXOEJPJ4.js";import{encodeFunctionData as z,erc20Abi as me,getAddress as m,isAddress as he,parseAbi as U,zeroAddress as ke}from"viem";var T=m(N[u].hoodlock.locker.address),C=m(N[u].hoodlock.burner.address),v=m(N[u].hoodlock.liquidityLocker.address),j=m(N[u].uniswap.v3_position_manager.address),K=m(N[u].uniswap.v4_position_manager.address),qe="0x000000000000000000000000000000000000dEaD",Ae=3153600000n,Te=1000000000000n,fe=65535,D=U(["function fee() view returns (uint256)","function lock(address token, uint256 amount, uint256 unlockTime) payable returns (uint256 lockId)","function getLock(uint256 lockId) view returns (address owner, address token, uint256 amount, uint256 unlockTime, bool withdrawn)","function locksByOwner(address owner) view returns (uint256[])","function locksByToken(address token) view returns (uint256[])"]),ee=U(["function fee() view returns (uint256)","function burn(address token, uint256 amount) payable returns (uint256 burnId)","function DEAD() view returns (address)","function getBurn(uint256 burnId) view returns (address burner, address token, uint256 amount, uint256 timestamp)","function totalBurnedOf(address token) view returns (uint256)"]),O=U(["function fixedFee() view returns (uint256)","function collectFeeBps() view returns (uint16)","function paused() view returns (bool)","function lock(address manager, uint256 tokenId, uint256 unlockTime, address feeRecipient, bool acceptUnverifiedHook, uint16 maxCollectFeeBps) payable returns (uint256 lockId)","function lockIdOf(address manager, uint256 tokenId) view returns (uint256)","function getLock(uint256 lockId) view returns (address owner, uint40 unlockTime, uint16 collectFeeBps, bool isV4, bool hookVerified, bool withdrawn, address feeRecipient, address token0, address token1, uint256 tokenId)","function locksOf(address owner) view returns (uint256[])"]),ye=U(["function approve(address to, uint256 tokenId)"]);function $e(e,o,t){let a=o.trim();if(a.startsWith("-")){let k=a.slice(1),i=e(k,t);return i==="0"?"0":`-${i}`}return e(a,t)}function pe(e,o){return o.length===0?"no ERC-20 transfer deltas":o.map(t=>`${$e(e.formatAmount,t.amount,t.token.decimals)} ${t.token.symbol}`).join(", ")}function E(e,o="token"){if(typeof e!="string"||!e.trim())throw new c(`Provide a valid ${o} contract address.`);if(!he(e,{strict:!1}))throw new c(`Identify ${o} by chain and contract address, not by symbol.`);return m(e)}async function W(e,o){try{return await o()}catch(t){throw new c(e.plainError(t))}}function we(e){if(typeof e!="string")throw new c("Amount must be a non-negative integer string in base units.");let o=H(e);if(o<=0n)throw new c("Amount must be greater than zero.");return o}async function ge(e){let o=await e.getBlock();if(!o||typeof o.timestamp!="bigint")throw new c("Could not read the current chain timestamp. Please try again.");return o.timestamp}function ve(e,o){if(typeof e!="string"||!/^\d+$/.test(e.trim()))throw new c("unlockTime must be a non-negative integer string in Unix seconds.");let t=BigInt(e.trim());if(t>=Te)throw new c("unlockTime appears to be in milliseconds; provide Unix seconds at most 100 years (3153600000 seconds) in the future.");if(t<=o)throw new c(`unlockTime (${t}) must be in the future (greater than current timestamp ${o}).`);let a=o+Ae;if(t>a)throw new c(`unlockTime (${t}) exceeds the 100-year maximum lock duration (3153600000 seconds; max ${a}).`);return t}async function oe(e,o,t=u){let a=m(o),[k,i]=await Promise.all([e.readContract({address:a,abi:me,functionName:"symbol"}),e.readContract({address:a,abi:me,functionName:"decimals"})]);return{address:a,symbol:ce(String(k)),decimals:Number(i),chainId:t}}function Se(e,o){if(e==null)return o;let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/.test(e.trim())?Number(e.trim()):NaN;if(!Number.isInteger(t)||t<0||t>fe)throw new c("maxCollectFeeBps must be an integer between 0 and 65535.");if(t<o)throw new c(`Live collectFeeBps (${o}) exceeds maxCollectFeeBps (${t}): collect fee changed.`);return Math.min(t,o)}function Le(e){return e.tokenId!==void 0||e.manager!==void 0||e.feeRecipient!==void 0||e.maxCollectFeeBps!==void 0||e.acceptUnverifiedHook!==void 0||e.kind==="v3"||e.kind==="lp"||e.kind==="v4"||e.version==="v3"||e.version==="v4"}async function xe(e,o,t){_(t);let a=m(t),k=o.kind==="v4"||o.version==="v4",i=o.manager!==void 0?E(o.manager,"manager"):k?K:j,g=i===K;if(i!==j&&!g)throw new c(`Unsupported position manager ${i}; use the configured Uniswap v3 or v4 manager.`);if(k&&!g||g&&(o.kind==="v3"||o.version==="v3"))throw new c("The requested version disagrees with the position manager.");if(o.acceptUnverifiedHook!==void 0&&typeof o.acceptUnverifiedHook!="boolean")throw new c("acceptUnverifiedHook must be a boolean.");let b=o.acceptUnverifiedHook===!0;if(!g&&b)throw new c("Uniswap v3 has no hooks; omit acceptUnverifiedHook.");let s=g?"v4":"v3";if(typeof o.tokenId!="string")throw new c("Provide an NFT tokenId as a decimal string.");let f=String(o.tokenId).trim(),d=H(f),l=ue(o.feeRecipient,"Provide an explicit feeRecipient address for LP position locks."),p=e.clientFor(u),[x,I,h]=await Promise.all([ge(p),p.readContract({address:v,abi:O,functionName:"fixedFee"}),p.readContract({address:v,abi:O,functionName:"collectFeeBps"})]),y,$=!0;if(g){let P=U(["function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey, uint256 info)","function getPositionLiquidity(uint256 tokenId) view returns (uint128)","function ownerOf(uint256 tokenId) view returns (address)"]),[Y,J,M]=await Promise.all([p.readContract({address:i,abi:P,functionName:"getPoolAndPositionInfo",args:[d]}),p.readContract({address:i,abi:P,functionName:"getPositionLiquidity",args:[d]}),p.readContract({address:i,abi:P,functionName:"ownerOf",args:[d]})]);if(m(M)!==a)throw new c("This wallet does not own that v4 position NFT.");if(J<=0n)throw new c("The v4 position has no liquidity to lock.");if(y=m(Y[0].hooks),$=y===ke||await p.readContract({address:v,abi:U(["function hookAllowed(address) view returns (bool)"]),functionName:"hookAllowed",args:[y]}),!$&&!b)throw new c(`Unverified v4 hook ${y}; review its risks and explicitly set acceptUnverifiedHook: true to proceed.`)}let A=ve(o.unlockTime,x),n=BigInt(I),r=Number(h);if(!Number.isInteger(r)||r<0||r>fe)throw new c(`Invalid on-chain collectFeeBps (${String(h)}).`);if(o.maxFee!==void 0){let P=H(String(o.maxFee));if(n>P)throw new c(`Live fixedFee (${n}) exceeds maxFee (${P}).`)}let w=Se(o.maxCollectFeeBps,r),L=(r/100).toString(),R=e.unsignedTx({to:i,data:z({abi:ye,functionName:"approve",args:[v,d]}),value:"0",chainId:u,description:`Approve Uniswap ${s} position NFT #${d} on ${i} for HoodLock LiquidityLocker ${v}.`}),F=e.unsignedTx({to:v,data:z({abi:O,functionName:"lock",args:[i,d,A,l,b,w]}),value:n.toString(),chainId:u,description:`Lock Uniswap ${s} NFT #${d} in HoodLock LiquidityLocker (${v}) until ${A} with feeRecipient ${l}, upfront fixedFee ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei), and ongoing collect fee ${r} bps (${L}% of collected LP fees, frozen per lock).`}),X=[R,F],V=await e.preview(X,a),Q=`Approve and lock Uniswap ${s} NFT #${d} (manager ${i}) in HoodLock LiquidityLocker ${v} until Unix ${A}. Upfront fixedFee: ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei). Ongoing LP fee share: ${r} bps (${L}% of collected LP fees, frozen per lock; maxCollectFeeBps=${w}) with feeRecipient ${l}. V4 hook: ${y??"none"}, reviewed: ${$}; acceptUnverifiedHook=${b}.`;return q(e,{txs:V.txs,summary:Q,preview:V,kind:s,contract:v,manager:i,tokenId:d.toString(),unlockTime:A.toString(),feeRecipient:l,acceptUnverifiedHook:b,collectFeeBps:r,maxCollectFeeBps:w,fixedFee:{token:S,amount:n.toString()}},v,n)}async function Ie(e,o,t){_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(u),[g,b,s]=await Promise.all([ge(i),i.readContract({address:T,abi:D,functionName:"fee"}),oe(i,k,u)]),f=we(o.amount),d=ve(o.unlockTime,g),l=BigInt(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(l>A)throw new c(`Live lock fee (${l}) exceeds maxFee (${A}).`)}let p=e.approval(s.address,T,f.toString(),u),x=e.unsignedTx({to:T,data:z({abi:D,functionName:"lock",args:[s.address,f,d]}),value:l.toString(),chainId:u,description:`Lock ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) in HoodLock Locker ${T} until ${d} with exact fee ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei).`}),I=[p,x],h=await e.preview(I,a),y=pe(e,h.changes),$=`Approve and lock ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) in HoodLock Locker ${T} until Unix ${d}. Exact fee: ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei). Preview changes: ${y}.`;return q(e,{txs:h.txs,summary:$,preview:h,kind:"token",contract:T,token:s,amount:f.toString(),unlockTime:d.toString(),fee:{token:S,amount:l.toString()}},T,l)}function Pe(e){return{name:"hoodlock_lock",inputSchema:{type:"object",properties:{kind:{type:"string",enum:["token","v2","v3","v4"],description:"Lock mode: token/v2 LP via Locker, or Uniswap v3/v4 NFT via LiquidityLocker."},token:{type:"string",description:"ERC-20 token or v2 LP token contract address on chain 4663 (for token/v2 locks)."},amount:{type:"string",description:"Token amount as an integer string in base units (for token/v2 locks)."},manager:{type:"string",description:"Configured Uniswap v3 or v4 position manager; inferred from kind when omitted."},tokenId:{type:"string",description:"Uniswap NFT position tokenId as a decimal string."},feeRecipient:{type:"string",description:"Explicit recipient address for collected LP fees during a position lock."},acceptUnverifiedHook:{type:"boolean",description:"Explicit v4 unreviewed-hook consent; default false. A reviewed hook is not a safety guarantee."},maxFee:{type:"string",description:"Maximum upfront ETH fee in wei; the exact live fee is sent."},maxCollectFeeBps:{type:"number",description:"Maximum acceptable ongoing LP collect fee in bps (uint16, must be >= live collectFeeBps)."},unlockTime:{type:"string",description:"Unlock timestamp in Unix seconds (must be > now and <= now + 100 years)."}},required:["unlockTime"],additionalProperties:!1},async execute(o,t){return W(e,async()=>Le(o)?xe(e,o,t):Ie(e,o,t))}}}function Ce(e){return{name:"hoodlock_burn",inputSchema:{type:"object",properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663 to send to the dead address via HoodLock Burner."},amount:{type:"string",description:"Amount to burn as an integer string in base units."}},required:["token","amount"],additionalProperties:!1},async execute(o,t){return W(e,async()=>{_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(u),[g,b,s]=await Promise.all([i.readContract({address:C,abi:ee,functionName:"fee"}),i.readContract({address:C,abi:ee,functionName:"DEAD"}),oe(i,k,u)]),f=we(o.amount),d=BigInt(g),l=m(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(d>A)throw new c(`Live burn fee (${d}) exceeds maxFee (${A}).`)}let p=e.approval(s.address,C,f.toString(),u),x=e.unsignedTx({to:C,data:z({abi:ee,functionName:"burn",args:[s.address,f]}),value:d.toString(),chainId:u,description:`Send ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${C} (totalSupply is unchanged) with exact fee ${e.formatAmount(d.toString(),S.decimals)} ETH (${d} wei).`}),I=[p,x],h=await e.preview(I,a),y=pe(e,h.changes),$=`Approve and send ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${C}. Note: tokens are transferred to ${l} and totalSupply is unchanged. Exact fee: ${e.formatAmount(d.toString(),S.decimals)} ETH (${d} wei). Preview changes: ${y}.`;return q(e,{txs:h.txs,summary:$,preview:h,contract:C,deadAddress:l,token:s,amount:f.toString(),fee:{token:S,amount:d.toString()},totalSupplyReduced:!1},C,d)})}}}async function be(e,o,t){_(o);let a=m(o),k=t?E(t,"token"):void 0,i=e.clientFor(u),g=[],b=new Set,s=n=>{for(let r of n){let w=r.toString();b.has(w)||(b.add(w),g.push(r))}};if(k){let[n,r]=await Promise.all([i.readContract({address:T,abi:D,functionName:"locksByToken",args:[k]}),i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]})]);s(n),s(r)}else{let n=await i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]});s(n)}let d=(await Promise.all(g.map(async n=>{let r=await i.readContract({address:T,abi:D,functionName:"getLock",args:[n]});return{id:n,owner:m(r[0]),token:m(r[1]),amount:BigInt(r[2]),unlockTime:BigInt(r[3]),withdrawn:!!r[4]}}))).filter(n=>!n.withdrawn&&n.amount>0n&&B(n.owner,a)&&(!k||B(n.token,k))),l=new Map,p=async n=>{let r=n.toLowerCase(),w=l.get(r);if(w)return w;let L=n===ke?S:await oe(i,n,u);return l.set(r,L),L},x=[],I=[];for(let n of d){let r=await p(n.token),w=n.amount.toString(),L=n.unlockTime.toString(),R={token:r,amount:w};x.push({lockId:n.id.toString(),kind:"token",contract:T,chainId:u,owner:n.owner,token:r,amount:w,asset:R,unlockTime:L,withdrawn:!1}),I.push({module:"hoodlock",id:`lock:${n.id.toString()}`,chainId:u,assets:[R],description:`HoodLock token lock #${n.id} of ${e.formatAmount(w,r.decimals)} ${r.symbol} (${r.address}) until Unix ${L}.`})}let h=await i.readContract({address:v,abi:O,functionName:"locksOf",args:[a]}),y=[...new Set(h.map(n=>n.toString()))].map(n=>BigInt(n)),$=[];for(let n of y){let r=await i.readContract({address:v,abi:O,functionName:"getLock",args:[n]}),[w,L,R,F,X,V,Q,P,Y,J]=r,M=m(w);if(V||!B(M,a))continue;let ne=m(P),te=m(Y);if(k&&!B(ne,k)&&!B(te,k))continue;let[ie,re]=await Promise.all([p(ne),p(te)]),se=m(Q),ae=Number(R),de=BigInt(L).toString(),Z=BigInt(J).toString();$.push({lockId:n.toString(),kind:F?"v4":"v3",contract:v,manager:F?K:j,chainId:u,owner:M,tokenId:Z,unlockTime:de,collectFeeBps:ae,feeRecipient:se,hookVerified:!!X,token0:ie,token1:re,withdrawn:!1}),I.push({module:"hoodlock",id:`lp-lock:${n.toString()}`,chainId:u,assets:[{token:{address:F?K:j,symbol:`UNI-${F?"V4":"V3"} #${Z}`,decimals:0,chainId:u},amount:"1"}],description:`HoodLock Uniswap ${F?"v4":"v3"} LP lock #${n} (NFT #${Z}, ${ie.symbol}/${re.symbol}, feeRecipient ${se}, collectFeeBps ${ae}) until Unix ${de}. One NFT held in LiquidityLocker custody for ${M}. Underlying token amounts are not valued.`})}let A=`Found ${x.length} active token lock(s) and ${$.length} active Uniswap v3/v4 LP lock(s) for ${a}.`;return{locks:x,lpLocks:$,positions:I,summary:A}}function Fe(e){return{name:"hoodlock_list_locks",inputSchema:{type:"object",properties:{owner:{type:"string",description:"Optional owner wallet address to query (defaults to the authenticated wallet)."},token:{type:"string",description:"Optional ERC-20 or LP token address to filter active locks owned by the wallet."}},additionalProperties:!1},async execute(o,t){let a=o.owner!==void 0?E(o.owner,"owner"):m(t),k=o.token!==void 0?E(o.token,"token"):void 0;return W(e,()=>be(e,a,k))}}}function Re(e){return async o=>(await W(e,()=>be(e,o))).positions}var G=e=>({tools:[Pe(e),Ce(e),Fe(e)],positions:Re(e)}),ze=G,je=G,Ke=e=>le("hoodlock",[G(e)]),We=G;export{T as a,C as b,v as c,j as d,K as e,qe as f,Ae as g,$e as h,Pe as i,Ce as j,Fe as k,Re as l,G as m,ze as n,je as o,Ke as p,We as q};
1
+ import{b as q}from"./SDICP7BT.js";import{b as S}from"./46ZA2R5L.js";import{b as le}from"./AXYOJBX6.js";import{a as _}from"./6IM6A5VA.js";import{g as B,i as ue}from"./73N3TOJL.js";import{a as H}from"./RETS2ZEK.js";import{a as u,i as N}from"./XPFVT2EA.js";import{a as c}from"./5YS5V2LK.js";import{a as ce}from"./JXOEJPJ4.js";import{encodeFunctionData as z,erc20Abi as me,getAddress as m,isAddress as he,parseAbi as U,zeroAddress as ke}from"viem";var T=m(N[u].hoodlock.locker.address),C=m(N[u].hoodlock.burner.address),v=m(N[u].hoodlock.liquidityLocker.address),j=m(N[u].uniswap.v3_position_manager.address),K=m(N[u].uniswap.v4_position_manager.address),qe="0x000000000000000000000000000000000000dEaD",Ae=3153600000n,Te=1000000000000n,fe=65535,D=U(["function fee() view returns (uint256)","function lock(address token, uint256 amount, uint256 unlockTime) payable returns (uint256 lockId)","function getLock(uint256 lockId) view returns (address owner, address token, uint256 amount, uint256 unlockTime, bool withdrawn)","function locksByOwner(address owner) view returns (uint256[])","function locksByToken(address token) view returns (uint256[])"]),ee=U(["function fee() view returns (uint256)","function burn(address token, uint256 amount) payable returns (uint256 burnId)","function DEAD() view returns (address)","function getBurn(uint256 burnId) view returns (address burner, address token, uint256 amount, uint256 timestamp)","function totalBurnedOf(address token) view returns (uint256)"]),O=U(["function fixedFee() view returns (uint256)","function collectFeeBps() view returns (uint16)","function paused() view returns (bool)","function lock(address manager, uint256 tokenId, uint256 unlockTime, address feeRecipient, bool acceptUnverifiedHook, uint16 maxCollectFeeBps) payable returns (uint256 lockId)","function lockIdOf(address manager, uint256 tokenId) view returns (uint256)","function getLock(uint256 lockId) view returns (address owner, uint40 unlockTime, uint16 collectFeeBps, bool isV4, bool hookVerified, bool withdrawn, address feeRecipient, address token0, address token1, uint256 tokenId)","function locksOf(address owner) view returns (uint256[])"]),ye=U(["function approve(address to, uint256 tokenId)"]);function $e(e,o,t){let a=o.trim();if(a.startsWith("-")){let k=a.slice(1),i=e(k,t);return i==="0"?"0":`-${i}`}return e(a,t)}function pe(e,o){return o.length===0?"no ERC-20 transfer deltas":o.map(t=>`${$e(e.formatAmount,t.amount,t.token.decimals)} ${t.token.symbol}`).join(", ")}function E(e,o="token"){if(typeof e!="string"||!e.trim())throw new c(`Provide a valid ${o} contract address.`);if(!he(e,{strict:!1}))throw new c(`Identify ${o} by chain and contract address, not by symbol.`);return m(e)}async function W(e,o){try{return await o()}catch(t){throw new c(e.plainError(t))}}function we(e){if(typeof e!="string")throw new c("Amount must be a non-negative integer string in base units.");let o=H(e);if(o<=0n)throw new c("Amount must be greater than zero.");return o}async function ge(e){let o=await e.getBlock();if(!o||typeof o.timestamp!="bigint")throw new c("Could not read the current chain timestamp. Please try again.");return o.timestamp}function ve(e,o){if(typeof e!="string"||!/^\d+$/.test(e.trim()))throw new c("unlockTime must be a non-negative integer string in Unix seconds.");let t=BigInt(e.trim());if(t>=Te)throw new c("unlockTime appears to be in milliseconds; provide Unix seconds at most 100 years (3153600000 seconds) in the future.");if(t<=o)throw new c(`unlockTime (${t}) must be in the future (greater than current timestamp ${o}).`);let a=o+Ae;if(t>a)throw new c(`unlockTime (${t}) exceeds the 100-year maximum lock duration (3153600000 seconds; max ${a}).`);return t}async function oe(e,o,t=u){let a=m(o),[k,i]=await Promise.all([e.readContract({address:a,abi:me,functionName:"symbol"}),e.readContract({address:a,abi:me,functionName:"decimals"})]);return{address:a,symbol:ce(String(k)),decimals:Number(i),chainId:t}}function Se(e,o){if(e==null)return o;let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/.test(e.trim())?Number(e.trim()):NaN;if(!Number.isInteger(t)||t<0||t>fe)throw new c("maxCollectFeeBps must be an integer between 0 and 65535.");if(t<o)throw new c(`Live collectFeeBps (${o}) exceeds maxCollectFeeBps (${t}): collect fee changed.`);return Math.min(t,o)}function Le(e){return e.tokenId!==void 0||e.manager!==void 0||e.feeRecipient!==void 0||e.maxCollectFeeBps!==void 0||e.acceptUnverifiedHook!==void 0||e.kind==="v3"||e.kind==="lp"||e.kind==="v4"||e.version==="v3"||e.version==="v4"}async function xe(e,o,t){_(t);let a=m(t),k=o.kind==="v4"||o.version==="v4",i=o.manager!==void 0?E(o.manager,"manager"):k?K:j,g=i===K;if(i!==j&&!g)throw new c(`Unsupported position manager ${i}; use the configured Uniswap v3 or v4 manager.`);if(k&&!g||g&&(o.kind==="v3"||o.version==="v3"))throw new c("The requested version disagrees with the position manager.");if(o.acceptUnverifiedHook!==void 0&&typeof o.acceptUnverifiedHook!="boolean")throw new c("acceptUnverifiedHook must be a boolean.");let b=o.acceptUnverifiedHook===!0;if(!g&&b)throw new c("Uniswap v3 has no hooks; omit acceptUnverifiedHook.");let s=g?"v4":"v3";if(typeof o.tokenId!="string")throw new c("Provide an NFT tokenId as a decimal string.");let f=String(o.tokenId).trim(),d=H(f),l=ue(o.feeRecipient,"Provide an explicit feeRecipient address for LP position locks."),p=e.clientFor(u),[x,I,h]=await Promise.all([ge(p),p.readContract({address:v,abi:O,functionName:"fixedFee"}),p.readContract({address:v,abi:O,functionName:"collectFeeBps"})]),y,$=!0;if(g){let P=U(["function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey, uint256 info)","function getPositionLiquidity(uint256 tokenId) view returns (uint128)","function ownerOf(uint256 tokenId) view returns (address)"]),[Y,J,M]=await Promise.all([p.readContract({address:i,abi:P,functionName:"getPoolAndPositionInfo",args:[d]}),p.readContract({address:i,abi:P,functionName:"getPositionLiquidity",args:[d]}),p.readContract({address:i,abi:P,functionName:"ownerOf",args:[d]})]);if(m(M)!==a)throw new c("This wallet does not own that v4 position NFT.");if(J<=0n)throw new c("The v4 position has no liquidity to lock.");if(y=m(Y[0].hooks),$=y===ke||await p.readContract({address:v,abi:U(["function hookAllowed(address) view returns (bool)"]),functionName:"hookAllowed",args:[y]}),!$&&!b)throw new c(`Unverified v4 hook ${y}; review its risks and explicitly set acceptUnverifiedHook: true to proceed.`)}let A=ve(o.unlockTime,x),n=BigInt(I),r=Number(h);if(!Number.isInteger(r)||r<0||r>fe)throw new c(`Invalid on-chain collectFeeBps (${String(h)}).`);if(o.maxFee!==void 0){let P=H(String(o.maxFee));if(n>P)throw new c(`Live fixedFee (${n}) exceeds maxFee (${P}).`)}let w=Se(o.maxCollectFeeBps,r),L=(r/100).toString(),R=e.unsignedTx({to:i,data:z({abi:ye,functionName:"approve",args:[v,d]}),value:"0",chainId:u,description:`Approve Uniswap ${s} position NFT #${d} on ${i} for HoodLock LiquidityLocker ${v}.`}),F=e.unsignedTx({to:v,data:z({abi:O,functionName:"lock",args:[i,d,A,l,b,w]}),value:n.toString(),chainId:u,description:`Lock Uniswap ${s} NFT #${d} in HoodLock LiquidityLocker (${v}) until ${A} with feeRecipient ${l}, upfront fixedFee ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei), and ongoing collect fee ${r} bps (${L}% of collected LP fees, frozen per lock).`}),X=[R,F],V=await e.preview(X,a),Q=`Approve and lock Uniswap ${s} NFT #${d} (manager ${i}) in HoodLock LiquidityLocker ${v} until Unix ${A}. Upfront fixedFee: ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei). Ongoing LP fee share: ${r} bps (${L}% of collected LP fees, frozen per lock; maxCollectFeeBps=${w}) with feeRecipient ${l}. V4 hook: ${y??"none"}, reviewed: ${$}; acceptUnverifiedHook=${b}.`;return q(e,{txs:V.txs,summary:Q,preview:V,kind:s,contract:v,manager:i,tokenId:d.toString(),unlockTime:A.toString(),feeRecipient:l,acceptUnverifiedHook:b,collectFeeBps:r,maxCollectFeeBps:w,fixedFee:{token:S,amount:n.toString()}},v,n)}async function Ie(e,o,t){_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(u),[g,b,s]=await Promise.all([ge(i),i.readContract({address:T,abi:D,functionName:"fee"}),oe(i,k,u)]),f=we(o.amount),d=ve(o.unlockTime,g),l=BigInt(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(l>A)throw new c(`Live lock fee (${l}) exceeds maxFee (${A}).`)}let p=e.approval(s.address,T,f.toString(),u),x=e.unsignedTx({to:T,data:z({abi:D,functionName:"lock",args:[s.address,f,d]}),value:l.toString(),chainId:u,description:`Lock ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) in HoodLock Locker ${T} until ${d} with exact fee ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei).`}),I=[p,x],h=await e.preview(I,a),y=pe(e,h.changes),$=`Approve and lock ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) in HoodLock Locker ${T} until Unix ${d}. Exact fee: ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei). Preview changes: ${y}.`;return q(e,{txs:h.txs,summary:$,preview:h,kind:"token",contract:T,token:s,amount:f.toString(),unlockTime:d.toString(),fee:{token:S,amount:l.toString()}},T,l)}function Pe(e){return{name:"hoodlock_lock",inputSchema:{type:"object",properties:{kind:{type:"string",enum:["token","v2","v3","v4"],description:"Lock mode: token/v2 LP via Locker, or Uniswap v3/v4 NFT via LiquidityLocker."},token:{type:"string",description:"ERC-20 token or v2 LP token contract address on chain 4663 (for token/v2 locks)."},amount:{type:"string",description:"Token amount as an integer string in base units (for token/v2 locks)."},manager:{type:"string",description:"Configured Uniswap v3 or v4 position manager; inferred from kind when omitted."},tokenId:{type:"string",description:"Uniswap NFT position tokenId as a decimal string."},feeRecipient:{type:"string",description:"Explicit recipient address for collected LP fees during a position lock."},acceptUnverifiedHook:{type:"boolean",description:"Explicit v4 unreviewed-hook consent; default false. A reviewed hook is not a safety guarantee."},maxFee:{type:"string",description:"Maximum upfront ETH fee in wei; the exact live fee is sent."},maxCollectFeeBps:{type:"number",description:"Maximum acceptable ongoing LP collect fee in bps (uint16, must be >= live collectFeeBps)."},unlockTime:{type:"string",description:"Unlock timestamp in Unix seconds (must be > now and <= now + 100 years)."}},required:["unlockTime"],additionalProperties:!1},async execute(o,t){return W(e,async()=>Le(o)?xe(e,o,t):Ie(e,o,t))}}}function Ce(e){return{name:"hoodlock_burn",inputSchema:{type:"object",properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663 to send to the dead address via HoodLock Burner."},amount:{type:"string",description:"Amount to burn as an integer string in base units."}},required:["token","amount"],additionalProperties:!1},async execute(o,t){return W(e,async()=>{_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(u),[g,b,s]=await Promise.all([i.readContract({address:C,abi:ee,functionName:"fee"}),i.readContract({address:C,abi:ee,functionName:"DEAD"}),oe(i,k,u)]),f=we(o.amount),d=BigInt(g),l=m(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(d>A)throw new c(`Live burn fee (${d}) exceeds maxFee (${A}).`)}let p=e.approval(s.address,C,f.toString(),u),x=e.unsignedTx({to:C,data:z({abi:ee,functionName:"burn",args:[s.address,f]}),value:d.toString(),chainId:u,description:`Send ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${C} (totalSupply is unchanged) with exact fee ${e.formatAmount(d.toString(),S.decimals)} ETH (${d} wei).`}),I=[p,x],h=await e.preview(I,a),y=pe(e,h.changes),$=`Approve and send ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${C}. Note: tokens are transferred to ${l} and totalSupply is unchanged. Exact fee: ${e.formatAmount(d.toString(),S.decimals)} ETH (${d} wei). Preview changes: ${y}.`;return q(e,{txs:h.txs,summary:$,preview:h,contract:C,deadAddress:l,token:s,amount:f.toString(),fee:{token:S,amount:d.toString()},totalSupplyReduced:!1},C,d)})}}}async function be(e,o,t){_(o);let a=m(o),k=t?E(t,"token"):void 0,i=e.clientFor(u),g=[],b=new Set,s=n=>{for(let r of n){let w=r.toString();b.has(w)||(b.add(w),g.push(r))}};if(k){let[n,r]=await Promise.all([i.readContract({address:T,abi:D,functionName:"locksByToken",args:[k]}),i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]})]);s(n),s(r)}else{let n=await i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]});s(n)}let d=(await Promise.all(g.map(async n=>{let r=await i.readContract({address:T,abi:D,functionName:"getLock",args:[n]});return{id:n,owner:m(r[0]),token:m(r[1]),amount:BigInt(r[2]),unlockTime:BigInt(r[3]),withdrawn:!!r[4]}}))).filter(n=>!n.withdrawn&&n.amount>0n&&B(n.owner,a)&&(!k||B(n.token,k))),l=new Map,p=async n=>{let r=n.toLowerCase(),w=l.get(r);if(w)return w;let L=n===ke?S:await oe(i,n,u);return l.set(r,L),L},x=[],I=[];for(let n of d){let r=await p(n.token),w=n.amount.toString(),L=n.unlockTime.toString(),R={token:r,amount:w};x.push({lockId:n.id.toString(),kind:"token",contract:T,chainId:u,owner:n.owner,token:r,amount:w,asset:R,unlockTime:L,withdrawn:!1}),I.push({module:"hoodlock",id:`lock:${n.id.toString()}`,chainId:u,assets:[R],description:`HoodLock token lock #${n.id} of ${e.formatAmount(w,r.decimals)} ${r.symbol} (${r.address}) until Unix ${L}.`})}let h=await i.readContract({address:v,abi:O,functionName:"locksOf",args:[a]}),y=[...new Set(h.map(n=>n.toString()))].map(n=>BigInt(n)),$=[];for(let n of y){let r=await i.readContract({address:v,abi:O,functionName:"getLock",args:[n]}),[w,L,R,F,X,V,Q,P,Y,J]=r,M=m(w);if(V||!B(M,a))continue;let ne=m(P),te=m(Y);if(k&&!B(ne,k)&&!B(te,k))continue;let[ie,re]=await Promise.all([p(ne),p(te)]),se=m(Q),ae=Number(R),de=BigInt(L).toString(),Z=BigInt(J).toString();$.push({lockId:n.toString(),kind:F?"v4":"v3",contract:v,manager:F?K:j,chainId:u,owner:M,tokenId:Z,unlockTime:de,collectFeeBps:ae,feeRecipient:se,hookVerified:!!X,token0:ie,token1:re,withdrawn:!1}),I.push({module:"hoodlock",id:`lp-lock:${n.toString()}`,chainId:u,assets:[{token:{address:F?K:j,symbol:`UNI-${F?"V4":"V3"} #${Z}`,decimals:0,chainId:u},amount:"1"}],description:`HoodLock Uniswap ${F?"v4":"v3"} LP lock #${n} (NFT #${Z}, ${ie.symbol}/${re.symbol}, feeRecipient ${se}, collectFeeBps ${ae}) until Unix ${de}. One NFT held in LiquidityLocker custody for ${M}. Underlying token amounts are not valued.`})}let A=`Found ${x.length} active token lock(s) and ${$.length} active Uniswap v3/v4 LP lock(s) for ${a}.`;return{locks:x,lpLocks:$,positions:I,summary:A}}function Fe(e){return{name:"hoodlock_list_locks",inputSchema:{type:"object",properties:{owner:{type:"string",description:"Optional owner wallet address to query (defaults to the authenticated wallet)."},token:{type:"string",description:"Optional ERC-20 or LP token address to filter active locks owned by the wallet."}},additionalProperties:!1},async execute(o,t){let a=o.owner!==void 0?E(o.owner,"owner"):m(t),k=o.token!==void 0?E(o.token,"token"):void 0;return W(e,()=>be(e,a,k))}}}function Re(e){return async o=>(await W(e,()=>be(e,o))).positions}var G=e=>({tools:[Pe(e),Ce(e),Fe(e)],positions:Re(e)}),ze=G,je=G,Ke=e=>le("hoodlock",[G(e)]),We=G;export{T as a,C as b,v as c,j as d,K as e,qe as f,Ae as g,$e as h,Pe as i,Ce as j,Fe as k,Re as l,G as m,ze as n,je as o,Ke as p,We as q};
@@ -1 +1 @@
1
- import{b as j}from"./HZUWK5B2.js";import{c as z}from"./MYBDO5SA.js";import{d as O}from"./VXLJRRKV.js";import{g as $}from"./73N3TOJL.js";import{a as D,b as M}from"./RETS2ZEK.js";import{a as F,i as q}from"./XPFVT2EA.js";import{a as i}from"./5YS5V2LK.js";import{encodeAbiParameters as le,encodeFunctionData as Y,erc20Abi as K,getAddress as G,isAddress as se,keccak256 as W,parseAbi as ce,parseAbiParameters as me,zeroAddress as J}from"viem";var x=F,S=G(q[x].hoodlock.airdrop.address),Z="https://hoodlock.tech",P=25e4,ue=256,ye=604800n,ge=30n,V=250000000000000000n,X=0xffffffffn,fe=(1n<<64n)-1n,ee=(1n<<128n)-1n,oe="0x0000000000000000000000000000000000000000000000000000000000000000",pe="0x1111111111111111111111111111111111111111",be=me("uint256, address, uint256"),H=ce(["function quote(uint32 maxClaims) view returns (uint256)","function create(address token, bytes32 merkleRoot, uint256 total, uint32 maxClaims, uint64 endTime, string uri) payable returns (uint256 id)","function claim(uint256 id, uint256 index, address account, uint256 amount, bytes32[] proof)","function getAirdrop(uint256 id) view returns (address creator, uint64 endTime, uint32 maxClaims, address token, uint32 claims, bool swept, bytes32 merkleRoot, uint128 total, uint128 remaining)","function isClaimed(uint256 id, uint256 index) view returns (bool)"]);function xe(o,e,t){let n=e.trim();if(n.startsWith("-")){let r=n.slice(1);return`-${o.formatAmount(r,t)}`}let d=n.startsWith("+")?n.slice(1):n;return o.formatAmount(d,t)}function ne(o,e){if(!e.changes.length)return e.summary;let t=e.changes.map(n=>`${xe(o,n.amount,n.token.decimals)} ${n.token.symbol}`).join(", ");return`${e.summary} (${t})`}async function Ae(o,e){try{let[t,n]=await Promise.all([o.readContract({address:e,abi:K,functionName:"symbol"}),o.readContract({address:e,abi:K,functionName:"decimals"})]),d=typeof t=="string"&&t.trim()?t.trim():"TOKEN",r=Number(n);return{symbol:d,decimals:Number.isInteger(r)&&r>=0&&r<=255?r:18}}catch{return{symbol:"TOKEN",decimals:18}}}function w(o,e,t){if(typeof e=="string"&&e.includes(".")){if(t?.decimals===void 0)throw new i(`Decimal string amount "${e}" requires explicit token decimals; amount inputs are base-unit integer strings by default.`);let d=t.rounding!==void 0?M(e,t.decimals,t.rounding):o?o.parseAmount(e,t.decimals):M(e,t.decimals),r=D(d);if(r<=0n)throw new i("Airdrop entry amount must be positive.");return r}let n;try{if(typeof e=="bigint")n=e;else if(typeof e=="string")n=D(e.trim());else throw new i("Amount must be a non-negative integer string in base units.")}catch(d){throw d instanceof i?d:new i(`Invalid airdrop amount "${String(e)}".`,{cause:d})}if(n<=0n)throw new i("Airdrop entry amount must be strictly positive (> 0).");return n}function I(o,e){try{let t=typeof o=="bigint"?o:BigInt(String(o).trim());if(t<0n)throw new i(`${e} must be non-negative.`);return t}catch(t){throw t instanceof i?t:new i(`Invalid ${e}: ${String(o)}`,{cause:t})}}function A(o,e){if(typeof o!="string"||!se(o,{strict:!1}))throw new i(`Invalid ${e} address "${String(o)}": token/account must be a valid EVM address, never a symbol.`);return G(o)}function N(o,e,t){let n=typeof o=="bigint"?o:BigInt(o);if(n<0n||n>X)throw new i(`Airdrop leaf index must be in 0..${X.toString()}.`);let d=A(e,"account"),r=w(void 0,t),s=le(be,[n,d,r]);return W(W(s))}function te(o,e){let t=o;for(let n of e)t=O(t,n);return t}function De(o){try{let e=N(o.index,o.account,o.amount),t=te(e,o.proof);return $(t,o.root)}catch{return!1}}function L(o,e){if(!Array.isArray(o)||o.length===0)throw new i("Airdrop entries list cannot be empty; maxClaims must be in 1..250000.");if(o.length>P)throw new i(`Airdrop entries length (${o.length}) exceeds maxClaims limit of ${P}.`);let t=[],n=0n;for(let a=0;a<o.length;a+=1){let l=o[a];if(!l)throw new i(`Missing airdrop entry at position ${a}.`);let c=l.index??a;if(!Number.isInteger(c)||c!==a)throw new i(`Airdrop entry index at position ${a} must be contiguous ${a} (got ${String(c)}).`);let u=A(l.account,`entries[${a}].account`),g=w(e?.context,l.amount,e);n+=g,t.push({index:c,account:u,amount:g.toString()})}if(n<=0n||n>ee)throw new i("Airdrop total amount must be > 0 and fit in uint128.");let d=t.map(a=>N(a.index,a.account,a.amount)),r=[d];for(;r[r.length-1].length>1;){let a=r[r.length-1],l=[];for(let c=0;c<a.length;c+=2){let u=a[c],g=a[c+1];g===void 0?l.push(u):l.push(O(u,g))}r.push(l)}let s=r[r.length-1][0];if(s.toLowerCase()===oe)throw new i("Computed Merkle root cannot be zero.");let f=r.length>1?r[1]:r[0],m=t.map((a,l)=>{let c=[],u=l;for(let g=0;g<r.length-1;g+=1){let y=r[g],b=u^1;b<y.length&&c.push(y[b]),u=Math.floor(u/2)}return{index:a.index,account:a.account,amount:a.amount,leaf:d[l],proof:c}}),p={format:"openzeppelin-standard-merkle-tree-v1",leafEncoding:["uint256","address","uint256"],root:s,totalAmount:n.toString(),maxClaims:t.length,values:t.map(a=>[a.index,a.account,a.amount]),entries:t};return{root:s,leaves:d,level1:f,totalAmount:n.toString(),maxClaims:t.length,entries:t,proofs:m,list:p}}function he(o){if(!o||!Array.isArray(o.entries)&&!Array.isArray(o.values))throw new i("Saved airdrop list is missing entries/values.");let e=Array.isArray(o.entries)&&o.entries.length>0?o.entries:o.values.map(([n,d,r])=>({index:n,account:d,amount:r})),t=L(e);if(o.root&&!$(t.root,o.root))throw new i(`Rebuilt tree root ${t.root} does not match saved list root ${o.root}.`);if(o.maxClaims!==void 0&&t.maxClaims!==o.maxClaims)throw new i(`Rebuilt maxClaims (${t.maxClaims}) does not match saved list maxClaims (${o.maxClaims}).`);if(o.totalAmount!==void 0&&t.totalAmount!==o.totalAmount)throw new i(`Rebuilt totalAmount (${t.totalAmount}) does not match saved list totalAmount (${o.totalAmount}).`);return t}async function re(o,e){return z(o.http,e,{method:"GET"},t=>t!==null&&typeof t=="object")}async function we(o,e,t){let n=A(e.token,"token");if(n===J)throw new i("Airdrop token cannot be the zero address.");let d=L(e.entries,{decimals:e.decimals,rounding:e.rounding,context:o}),r=e.maxClaims??d.maxClaims;if(!Number.isInteger(r)||r<1||r>P||r!==d.maxClaims)throw new i(`maxClaims (${String(r)}) must equal entries.length (${d.maxClaims}) and be in 1..${P}.`);let s=BigInt(d.totalAmount),f=e.total!==void 0?w(o,e.total,{decimals:e.decimals,rounding:e.rounding}):s;if(f<s)throw new i(`Airdrop total (${f.toString()}) is less than the sum of entry amounts (${s.toString()}).`);if(f<=0n||f>ee)throw new i("Airdrop total must be positive and fit in uint128.");let m=e.uri??"",p=new TextEncoder().encode(m).byteLength;if(p>ue)throw new i(`Airdrop URI length (${p} bytes) exceeds 256-byte limit.`);let a=e.endTime!==void 0?I(e.endTime,"endTime"):0n;if(a>fe)throw new i("endTime exceeds uint64 maximum.");let l=o.clientFor(x),c=await l.getCode({address:n});if(!c||c==="0x")throw new i(`Token ${n} has no contract code on chain ${x}.`);let u;if(a!==0n){let R=(await l.getBlock()).timestamp,U=e.inclusionMargin!==void 0?I(e.inclusionMargin,"inclusionMargin"):ge;if(U<=0n)throw new i("inclusionMargin must be at least 1 second to leave room for signing and inclusion after the already-mined block.");let _=R+U,v=e.inclusionTime!==void 0?I(e.inclusionTime,"inclusionTime"):_;if(v<_)throw new i(`inclusionTime (${v.toString()}) must be after the already-mined block (${R.toString()}) with room for signing and inclusion (>= ${_.toString()}).`);u=v;let B=v+ye;if(a<B)throw new i(`endTime (${a.toString()}) is too short (window too short): must be 0 or at least inclusion time (${v.toString()}) + 604800 (7 days >= ${B.toString()}, after already-mined block.timestamp ${R.toString()}).`)}let g=await l.readContract({address:S,abi:H,functionName:"quote",args:[r]}),y=typeof g=="bigint"?g:BigInt(String(g));if(y<0n||y>V)throw new i(`HoodLock quote(uint32) fee (${y.toString()}) exceeds max fee cap (${V.toString()}).`);let b=o.formatAmount(y.toString(),j.decimals),h=o.approval(n,S,f.toString(),x),k=o.unsignedTx({chainId:x,to:S,data:Y({abi:H,functionName:"create",args:[n,d.root,f,r,a,m]}),value:y.toString(),description:`Create HoodLock airdrop (${r} claims, total ${f.toString()}, quote fee ${b} ETH (${y.toString()} wei))`}),C=[h,k],T=A(e.account??t??pe,"wallet"),E=await o.preview(C,T),ae=y>0n?` Quote fee: -${b} ETH (${b} ETH / ${y.toString()} wei).`:" Quote fee: 0 ETH (0 wei).",de=`${ne(o,E)}${ae}`;return{kind:"hoodlock_airdrop_create",chainId:x,token:n,merkleRoot:d.root,totalAmount:d.totalAmount,total:f.toString(),maxClaims:r,endTime:a,...u!==void 0?{inclusionTime:u}:{},uri:m,quoteFee:y,list:d.list,proofs:d.proofs,txs:C,preview:E,summary:de}}async function Q(o,e,t,n){if(n.savedProof){let m=A(n.savedProof.account,"savedProof.account");if(m!==t)throw new i(`savedProof account (${m}) does not match claim account (${t}).`);return{index:n.savedProof.index,amount:w(o,n.savedProof.amount),proof:n.savedProof.proof}}if(n.proof!==void 0&&n.index!==void 0&&n.amount!==void 0){let m=Number(n.index);if(!Number.isInteger(m)||m<0)throw new i(`Invalid claim index: ${String(n.index)}`);return{index:m,amount:w(o,n.amount),proof:n.proof}}if(n.list||n.entries){let p=(n.list?he(n.list):L(n.entries,{context:o})).proofs.find(a=>!(!$(a.account,t)||n.index!==void 0&&a.index!==Number(n.index)));if(!p)throw new i(`Account ${t} was not found in the saved airdrop list.`);return{index:p.index,amount:w(o,p.amount),proof:p.proof}}let d=`${Z}/api/airdrop/${e.toString()}/proof?address=${t}`,r=await re(o,d),s=r?.data??r;if(!s||s.index===void 0||s.amount===void 0||!Array.isArray(s.proof))throw new i(`No valid proof returned from HoodLock API for airdrop ${e.toString()} and account ${t}.`);let f=Number(s.index);if(!Number.isInteger(f)||f<0)throw new i(`Invalid index in API proof: ${String(s.index)}`);return{index:f,amount:w(o,s.amount),proof:s.proof}}async function ie(o,e){let t=o.clientFor(x),n=await t.readContract({address:S,abi:H,functionName:"getAirdrop",args:[e.id]}),[d,r,s,f,m,p,a,,l]=n,c=BigInt(r),u=Number(s),g=Number(m),y=BigInt(l),b=A(f,"airdrop.token");if(d===J||a.toLowerCase()===oe)throw new i(`Airdrop ${e.id.toString()} does not exist.`);if(p)throw new i(`Airdrop ${e.id.toString()} has already been swept.`);if(c>0n&&(await t.getBlock()).timestamp>=c)throw new i(`Airdrop ${e.id.toString()} expired at timestamp ${c.toString()}.`);if(g>=u)throw new i(`Airdrop ${e.id.toString()} has reached maxClaims (${u}).`);let[h,k]=await Promise.all([t.readContract({address:S,abi:H,functionName:"isClaimed",args:[e.id,BigInt(e.index)]}),Ae(t,b)]);if(h)throw new i(`Airdrop ${e.id.toString()} index ${e.index} has already been claimed.`);if(y<e.amount)throw new i(`Airdrop ${e.id.toString()} remaining balance (${y.toString()}) is less than claim amount (${e.amount.toString()}).`);let C=N(e.index,e.account,e.amount),T=te(C,e.proof);if(!$(T,a))throw new i(`Computed Merkle root ${T} does not match on-chain airdrop root ${a} (bad proof).`);return{tokenAddress:b,tokenMeta:k,merkleRoot:a,leaf:C}}async function ke(o,e){let{tokenAddress:t,tokenMeta:n,merkleRoot:d,leaf:r}=await ie(o,e),s=e.caller??e.account,f=!$(s,e.account),m=o.formatAmount(e.amount.toString(),n.decimals),p=o.unsignedTx({chainId:x,to:S,data:Y({abi:H,functionName:"claim",args:[e.id,BigInt(e.index),e.account,e.amount,[...e.proof]]}),value:"0",description:f?`Claim ${m} ${n.symbol} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for recipient ${e.account} (caller ${s} pays gas only, token delta 0)`:`Claim ${m} ${n.symbol} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for ${e.account}`}),a=[p],l=await o.preview(a,s),c,u,g=e.amount.toString(),y;if(f){let b=l.changes.filter(h=>h.amount.trim().startsWith("-"));c={...l,changes:b,summary:`${l.summary} Recipient ${e.account} receives ${m} ${n.symbol} (${e.amount.toString()} base units); caller ${s} change is 0 (gas only).`},u=`Third-party claim from HoodLock airdrop #${e.id.toString()} (index ${e.index}): recipient ${e.account} receives ${m} ${n.symbol} (${e.amount.toString()} base units of ${t}); caller ${s} own token change is 0 (gas only). ${l.summary}`,y="0"}else c=l,u=`Claim ${m} ${n.symbol} (${e.amount.toString()} base units of ${t}) from HoodLock airdrop #${e.id.toString()} (index ${e.index}) for recipient ${e.account}. ${ne(o,c)}`,y=e.amount.toString();return{kind:"hoodlock_airdrop_claim",chainId:x,id:e.id,index:e.index,account:e.account,recipient:e.account,caller:e.caller,token:t,amount:e.amount.toString(),recipientDelta:g,senderDelta:y,leaf:r,merkleRoot:d,proof:[...e.proof],tx:p,txs:a,preview:c,summary:u}}async function $e(o,e,t){let n=A(e.account??t??"","account"),d=e.caller!==void 0?A(e.caller,"caller"):t!==void 0?A(t,"wallet"):void 0;if(e.id!==void 0){let l=I(e.id,"id"),c=await Q(o,l,n,e);return ke(o,{id:l,index:c.index,account:n,caller:d,amount:c.amount,proof:c.proof})}let r=`${Z}/api/airdrop/eligible?address=${n}`,s=await re(o,r),f=Array.isArray(s)?s:s?.claimable??s?.eligible??s?.airdrops??s?.claims??[],m=[];for(let l of f){let c=l.id??l.airdropId;if(c!==void 0)try{let u=I(c,"eligible.id"),g,y,b;if(l.index!==void 0&&l.amount!==void 0&&Array.isArray(l.proof))g=Number(l.index),y=w(o,l.amount),b=l.proof;else{let k=await Q(o,u,n,{id:u,account:n});g=k.index,y=k.amount,b=k.proof}let h=await ie(o,{id:u,index:g,account:n,amount:y,proof:b});m.push({id:u.toString(),index:g,account:n,token:h.tokenAddress,amount:y.toString(),proof:[...b],merkleRoot:h.merkleRoot})}catch{continue}}let p=m.length===0?`No verified eligible HoodLock airdrops were returned by the index for ${n}. Discovery can lag after creation; this does not prove there are no claims. If you know the airdrop id, call hoodlock_airdrop_claim with id and account to resolve its list/proof and verify it on-chain.`:`Found ${m.length} eligible HoodLock airdrop(s) for ${n}: ${m.map(l=>`#${l.id}`).join(", ")}. Discovery can lag after creation. Choose an id, or pass a known new id, to hoodlock_airdrop_claim to verify and build a claim transaction.`;return{kind:"hoodlock_airdrop_eligible",chainId:x,account:n,recipient:n,caller:d,recipientDelta:"0",senderDelta:"0",eligible:m,claims:[],tx:void 0,txs:[],preview:{txs:[],changes:[],summary:p},summary:p}}var Se=o=>({tools:[{name:"hoodlock_airdrop_create",inputSchema:{type:"object",required:["token","entries"],additionalProperties:!1,properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663"},entries:{type:"array",description:"Ordered airdrop entries [{ index?, account, amount }] with base-unit integer string amounts"},total:{type:"string",description:"Optional total funded token amount as a base-unit integer string (>= sum of entries)"},maxClaims:{type:"number",description:"Optional claim count (must equal entries.length in 1..250000)"},endTime:{type:"number",description:"Unix timestamp in seconds (0 for non-sweepable or >= inclusion time + 604800)"},inclusionTime:{type:"number",description:"Optional expected transaction inclusion Unix timestamp in seconds (> already-mined block.timestamp)"},inclusionMargin:{type:"number",description:"Optional signing and inclusion margin in seconds above the already-mined block.timestamp (>= 1, default 30)"},uri:{type:"string",description:"Metadata URI (<= 256 UTF-8 bytes)"},decimals:{type:"number",description:"Optional token decimals when converting human decimal entry amounts via parseAmount"},rounding:{type:"string",enum:["floor","ceil"],description:"Optional rounding mode (floor or ceil) when converting decimal amounts"},account:{type:"string",description:"Optional creator wallet address for preview simulation"}}},execute:async(e,t)=>we(o,e,t)},{name:"hoodlock_airdrop_claim",inputSchema:{type:"object",required:["account"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional airdrop ID (omit to query eligible airdrops)"},account:{type:"string",description:"Leaf recipient address that receives the tokens"},caller:{type:"string",description:"Optional caller/relayer address submitting the tx (pays gas only, receives 0 tokens)"},index:{type:"number",description:"Optional leaf index when supplying proof directly or selecting from list/entries"},amount:{type:"string",description:"Optional leaf amount as a base-unit integer string"},proof:{type:"array",items:{type:"string"},description:"Optional Merkle sibling proof array of 32-byte hex strings"},savedProof:{type:"object",description:"Optional saved proof item ({ index, account, amount, leaf?, proof }) from hoodlock_airdrop_create"},list:{type:"object",description:"Optional saved airdrop list ({ format, leafEncoding, root, totalAmount, maxClaims, values, entries }) to rebuild proof locally"},entries:{type:"array",description:"Optional airdrop entries array ([{ index?, account, amount }]) to rebuild proof locally"}}},execute:async(e,t)=>$e(o,e,t)}]}),Me=Se;export{K as a,x as b,S as c,Z as d,P as e,ue as f,ye as g,ge as h,V as i,H as j,xe as k,N as l,te as m,De as n,L as o,he as p,Se as q,Me as r};
1
+ import{b as j}from"./46ZA2R5L.js";import{c as z}from"./MYBDO5SA.js";import{d as O}from"./VXLJRRKV.js";import{g as $}from"./73N3TOJL.js";import{a as D,b as M}from"./RETS2ZEK.js";import{a as F,i as q}from"./XPFVT2EA.js";import{a as i}from"./5YS5V2LK.js";import{encodeAbiParameters as le,encodeFunctionData as Y,erc20Abi as K,getAddress as G,isAddress as se,keccak256 as W,parseAbi as ce,parseAbiParameters as me,zeroAddress as J}from"viem";var x=F,S=G(q[x].hoodlock.airdrop.address),Z="https://hoodlock.tech",P=25e4,ue=256,ye=604800n,ge=30n,V=250000000000000000n,X=0xffffffffn,fe=(1n<<64n)-1n,ee=(1n<<128n)-1n,oe="0x0000000000000000000000000000000000000000000000000000000000000000",pe="0x1111111111111111111111111111111111111111",be=me("uint256, address, uint256"),H=ce(["function quote(uint32 maxClaims) view returns (uint256)","function create(address token, bytes32 merkleRoot, uint256 total, uint32 maxClaims, uint64 endTime, string uri) payable returns (uint256 id)","function claim(uint256 id, uint256 index, address account, uint256 amount, bytes32[] proof)","function getAirdrop(uint256 id) view returns (address creator, uint64 endTime, uint32 maxClaims, address token, uint32 claims, bool swept, bytes32 merkleRoot, uint128 total, uint128 remaining)","function isClaimed(uint256 id, uint256 index) view returns (bool)"]);function xe(o,e,t){let n=e.trim();if(n.startsWith("-")){let r=n.slice(1);return`-${o.formatAmount(r,t)}`}let d=n.startsWith("+")?n.slice(1):n;return o.formatAmount(d,t)}function ne(o,e){if(!e.changes.length)return e.summary;let t=e.changes.map(n=>`${xe(o,n.amount,n.token.decimals)} ${n.token.symbol}`).join(", ");return`${e.summary} (${t})`}async function Ae(o,e){try{let[t,n]=await Promise.all([o.readContract({address:e,abi:K,functionName:"symbol"}),o.readContract({address:e,abi:K,functionName:"decimals"})]),d=typeof t=="string"&&t.trim()?t.trim():"TOKEN",r=Number(n);return{symbol:d,decimals:Number.isInteger(r)&&r>=0&&r<=255?r:18}}catch{return{symbol:"TOKEN",decimals:18}}}function w(o,e,t){if(typeof e=="string"&&e.includes(".")){if(t?.decimals===void 0)throw new i(`Decimal string amount "${e}" requires explicit token decimals; amount inputs are base-unit integer strings by default.`);let d=t.rounding!==void 0?M(e,t.decimals,t.rounding):o?o.parseAmount(e,t.decimals):M(e,t.decimals),r=D(d);if(r<=0n)throw new i("Airdrop entry amount must be positive.");return r}let n;try{if(typeof e=="bigint")n=e;else if(typeof e=="string")n=D(e.trim());else throw new i("Amount must be a non-negative integer string in base units.")}catch(d){throw d instanceof i?d:new i(`Invalid airdrop amount "${String(e)}".`,{cause:d})}if(n<=0n)throw new i("Airdrop entry amount must be strictly positive (> 0).");return n}function I(o,e){try{let t=typeof o=="bigint"?o:BigInt(String(o).trim());if(t<0n)throw new i(`${e} must be non-negative.`);return t}catch(t){throw t instanceof i?t:new i(`Invalid ${e}: ${String(o)}`,{cause:t})}}function A(o,e){if(typeof o!="string"||!se(o,{strict:!1}))throw new i(`Invalid ${e} address "${String(o)}": token/account must be a valid EVM address, never a symbol.`);return G(o)}function N(o,e,t){let n=typeof o=="bigint"?o:BigInt(o);if(n<0n||n>X)throw new i(`Airdrop leaf index must be in 0..${X.toString()}.`);let d=A(e,"account"),r=w(void 0,t),s=le(be,[n,d,r]);return W(W(s))}function te(o,e){let t=o;for(let n of e)t=O(t,n);return t}function De(o){try{let e=N(o.index,o.account,o.amount),t=te(e,o.proof);return $(t,o.root)}catch{return!1}}function L(o,e){if(!Array.isArray(o)||o.length===0)throw new i("Airdrop entries list cannot be empty; maxClaims must be in 1..250000.");if(o.length>P)throw new i(`Airdrop entries length (${o.length}) exceeds maxClaims limit of ${P}.`);let t=[],n=0n;for(let a=0;a<o.length;a+=1){let l=o[a];if(!l)throw new i(`Missing airdrop entry at position ${a}.`);let c=l.index??a;if(!Number.isInteger(c)||c!==a)throw new i(`Airdrop entry index at position ${a} must be contiguous ${a} (got ${String(c)}).`);let u=A(l.account,`entries[${a}].account`),g=w(e?.context,l.amount,e);n+=g,t.push({index:c,account:u,amount:g.toString()})}if(n<=0n||n>ee)throw new i("Airdrop total amount must be > 0 and fit in uint128.");let d=t.map(a=>N(a.index,a.account,a.amount)),r=[d];for(;r[r.length-1].length>1;){let a=r[r.length-1],l=[];for(let c=0;c<a.length;c+=2){let u=a[c],g=a[c+1];g===void 0?l.push(u):l.push(O(u,g))}r.push(l)}let s=r[r.length-1][0];if(s.toLowerCase()===oe)throw new i("Computed Merkle root cannot be zero.");let f=r.length>1?r[1]:r[0],m=t.map((a,l)=>{let c=[],u=l;for(let g=0;g<r.length-1;g+=1){let y=r[g],b=u^1;b<y.length&&c.push(y[b]),u=Math.floor(u/2)}return{index:a.index,account:a.account,amount:a.amount,leaf:d[l],proof:c}}),p={format:"openzeppelin-standard-merkle-tree-v1",leafEncoding:["uint256","address","uint256"],root:s,totalAmount:n.toString(),maxClaims:t.length,values:t.map(a=>[a.index,a.account,a.amount]),entries:t};return{root:s,leaves:d,level1:f,totalAmount:n.toString(),maxClaims:t.length,entries:t,proofs:m,list:p}}function he(o){if(!o||!Array.isArray(o.entries)&&!Array.isArray(o.values))throw new i("Saved airdrop list is missing entries/values.");let e=Array.isArray(o.entries)&&o.entries.length>0?o.entries:o.values.map(([n,d,r])=>({index:n,account:d,amount:r})),t=L(e);if(o.root&&!$(t.root,o.root))throw new i(`Rebuilt tree root ${t.root} does not match saved list root ${o.root}.`);if(o.maxClaims!==void 0&&t.maxClaims!==o.maxClaims)throw new i(`Rebuilt maxClaims (${t.maxClaims}) does not match saved list maxClaims (${o.maxClaims}).`);if(o.totalAmount!==void 0&&t.totalAmount!==o.totalAmount)throw new i(`Rebuilt totalAmount (${t.totalAmount}) does not match saved list totalAmount (${o.totalAmount}).`);return t}async function re(o,e){return z(o.http,e,{method:"GET"},t=>t!==null&&typeof t=="object")}async function we(o,e,t){let n=A(e.token,"token");if(n===J)throw new i("Airdrop token cannot be the zero address.");let d=L(e.entries,{decimals:e.decimals,rounding:e.rounding,context:o}),r=e.maxClaims??d.maxClaims;if(!Number.isInteger(r)||r<1||r>P||r!==d.maxClaims)throw new i(`maxClaims (${String(r)}) must equal entries.length (${d.maxClaims}) and be in 1..${P}.`);let s=BigInt(d.totalAmount),f=e.total!==void 0?w(o,e.total,{decimals:e.decimals,rounding:e.rounding}):s;if(f<s)throw new i(`Airdrop total (${f.toString()}) is less than the sum of entry amounts (${s.toString()}).`);if(f<=0n||f>ee)throw new i("Airdrop total must be positive and fit in uint128.");let m=e.uri??"",p=new TextEncoder().encode(m).byteLength;if(p>ue)throw new i(`Airdrop URI length (${p} bytes) exceeds 256-byte limit.`);let a=e.endTime!==void 0?I(e.endTime,"endTime"):0n;if(a>fe)throw new i("endTime exceeds uint64 maximum.");let l=o.clientFor(x),c=await l.getCode({address:n});if(!c||c==="0x")throw new i(`Token ${n} has no contract code on chain ${x}.`);let u;if(a!==0n){let R=(await l.getBlock()).timestamp,U=e.inclusionMargin!==void 0?I(e.inclusionMargin,"inclusionMargin"):ge;if(U<=0n)throw new i("inclusionMargin must be at least 1 second to leave room for signing and inclusion after the already-mined block.");let _=R+U,v=e.inclusionTime!==void 0?I(e.inclusionTime,"inclusionTime"):_;if(v<_)throw new i(`inclusionTime (${v.toString()}) must be after the already-mined block (${R.toString()}) with room for signing and inclusion (>= ${_.toString()}).`);u=v;let B=v+ye;if(a<B)throw new i(`endTime (${a.toString()}) is too short (window too short): must be 0 or at least inclusion time (${v.toString()}) + 604800 (7 days >= ${B.toString()}, after already-mined block.timestamp ${R.toString()}).`)}let g=await l.readContract({address:S,abi:H,functionName:"quote",args:[r]}),y=typeof g=="bigint"?g:BigInt(String(g));if(y<0n||y>V)throw new i(`HoodLock quote(uint32) fee (${y.toString()}) exceeds max fee cap (${V.toString()}).`);let b=o.formatAmount(y.toString(),j.decimals),h=o.approval(n,S,f.toString(),x),k=o.unsignedTx({chainId:x,to:S,data:Y({abi:H,functionName:"create",args:[n,d.root,f,r,a,m]}),value:y.toString(),description:`Create HoodLock airdrop (${r} claims, total ${f.toString()}, quote fee ${b} ETH (${y.toString()} wei))`}),C=[h,k],T=A(e.account??t??pe,"wallet"),E=await o.preview(C,T),ae=y>0n?` Quote fee: -${b} ETH (${b} ETH / ${y.toString()} wei).`:" Quote fee: 0 ETH (0 wei).",de=`${ne(o,E)}${ae}`;return{kind:"hoodlock_airdrop_create",chainId:x,token:n,merkleRoot:d.root,totalAmount:d.totalAmount,total:f.toString(),maxClaims:r,endTime:a,...u!==void 0?{inclusionTime:u}:{},uri:m,quoteFee:y,list:d.list,proofs:d.proofs,txs:C,preview:E,summary:de}}async function Q(o,e,t,n){if(n.savedProof){let m=A(n.savedProof.account,"savedProof.account");if(m!==t)throw new i(`savedProof account (${m}) does not match claim account (${t}).`);return{index:n.savedProof.index,amount:w(o,n.savedProof.amount),proof:n.savedProof.proof}}if(n.proof!==void 0&&n.index!==void 0&&n.amount!==void 0){let m=Number(n.index);if(!Number.isInteger(m)||m<0)throw new i(`Invalid claim index: ${String(n.index)}`);return{index:m,amount:w(o,n.amount),proof:n.proof}}if(n.list||n.entries){let p=(n.list?he(n.list):L(n.entries,{context:o})).proofs.find(a=>!(!$(a.account,t)||n.index!==void 0&&a.index!==Number(n.index)));if(!p)throw new i(`Account ${t} was not found in the saved airdrop list.`);return{index:p.index,amount:w(o,p.amount),proof:p.proof}}let d=`${Z}/api/airdrop/${e.toString()}/proof?address=${t}`,r=await re(o,d),s=r?.data??r;if(!s||s.index===void 0||s.amount===void 0||!Array.isArray(s.proof))throw new i(`No valid proof returned from HoodLock API for airdrop ${e.toString()} and account ${t}.`);let f=Number(s.index);if(!Number.isInteger(f)||f<0)throw new i(`Invalid index in API proof: ${String(s.index)}`);return{index:f,amount:w(o,s.amount),proof:s.proof}}async function ie(o,e){let t=o.clientFor(x),n=await t.readContract({address:S,abi:H,functionName:"getAirdrop",args:[e.id]}),[d,r,s,f,m,p,a,,l]=n,c=BigInt(r),u=Number(s),g=Number(m),y=BigInt(l),b=A(f,"airdrop.token");if(d===J||a.toLowerCase()===oe)throw new i(`Airdrop ${e.id.toString()} does not exist.`);if(p)throw new i(`Airdrop ${e.id.toString()} has already been swept.`);if(c>0n&&(await t.getBlock()).timestamp>=c)throw new i(`Airdrop ${e.id.toString()} expired at timestamp ${c.toString()}.`);if(g>=u)throw new i(`Airdrop ${e.id.toString()} has reached maxClaims (${u}).`);let[h,k]=await Promise.all([t.readContract({address:S,abi:H,functionName:"isClaimed",args:[e.id,BigInt(e.index)]}),Ae(t,b)]);if(h)throw new i(`Airdrop ${e.id.toString()} index ${e.index} has already been claimed.`);if(y<e.amount)throw new i(`Airdrop ${e.id.toString()} remaining balance (${y.toString()}) is less than claim amount (${e.amount.toString()}).`);let C=N(e.index,e.account,e.amount),T=te(C,e.proof);if(!$(T,a))throw new i(`Computed Merkle root ${T} does not match on-chain airdrop root ${a} (bad proof).`);return{tokenAddress:b,tokenMeta:k,merkleRoot:a,leaf:C}}async function ke(o,e){let{tokenAddress:t,tokenMeta:n,merkleRoot:d,leaf:r}=await ie(o,e),s=e.caller??e.account,f=!$(s,e.account),m=o.formatAmount(e.amount.toString(),n.decimals),p=o.unsignedTx({chainId:x,to:S,data:Y({abi:H,functionName:"claim",args:[e.id,BigInt(e.index),e.account,e.amount,[...e.proof]]}),value:"0",description:f?`Claim ${m} ${n.symbol} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for recipient ${e.account} (caller ${s} pays gas only, token delta 0)`:`Claim ${m} ${n.symbol} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for ${e.account}`}),a=[p],l=await o.preview(a,s),c,u,g=e.amount.toString(),y;if(f){let b=l.changes.filter(h=>h.amount.trim().startsWith("-"));c={...l,changes:b,summary:`${l.summary} Recipient ${e.account} receives ${m} ${n.symbol} (${e.amount.toString()} base units); caller ${s} change is 0 (gas only).`},u=`Third-party claim from HoodLock airdrop #${e.id.toString()} (index ${e.index}): recipient ${e.account} receives ${m} ${n.symbol} (${e.amount.toString()} base units of ${t}); caller ${s} own token change is 0 (gas only). ${l.summary}`,y="0"}else c=l,u=`Claim ${m} ${n.symbol} (${e.amount.toString()} base units of ${t}) from HoodLock airdrop #${e.id.toString()} (index ${e.index}) for recipient ${e.account}. ${ne(o,c)}`,y=e.amount.toString();return{kind:"hoodlock_airdrop_claim",chainId:x,id:e.id,index:e.index,account:e.account,recipient:e.account,caller:e.caller,token:t,amount:e.amount.toString(),recipientDelta:g,senderDelta:y,leaf:r,merkleRoot:d,proof:[...e.proof],tx:p,txs:a,preview:c,summary:u}}async function $e(o,e,t){let n=A(e.account??t??"","account"),d=e.caller!==void 0?A(e.caller,"caller"):t!==void 0?A(t,"wallet"):void 0;if(e.id!==void 0){let l=I(e.id,"id"),c=await Q(o,l,n,e);return ke(o,{id:l,index:c.index,account:n,caller:d,amount:c.amount,proof:c.proof})}let r=`${Z}/api/airdrop/eligible?address=${n}`,s=await re(o,r),f=Array.isArray(s)?s:s?.claimable??s?.eligible??s?.airdrops??s?.claims??[],m=[];for(let l of f){let c=l.id??l.airdropId;if(c!==void 0)try{let u=I(c,"eligible.id"),g,y,b;if(l.index!==void 0&&l.amount!==void 0&&Array.isArray(l.proof))g=Number(l.index),y=w(o,l.amount),b=l.proof;else{let k=await Q(o,u,n,{id:u,account:n});g=k.index,y=k.amount,b=k.proof}let h=await ie(o,{id:u,index:g,account:n,amount:y,proof:b});m.push({id:u.toString(),index:g,account:n,token:h.tokenAddress,amount:y.toString(),proof:[...b],merkleRoot:h.merkleRoot})}catch{continue}}let p=m.length===0?`No verified eligible HoodLock airdrops were returned by the index for ${n}. Discovery can lag after creation; this does not prove there are no claims. If you know the airdrop id, call hoodlock_airdrop_claim with id and account to resolve its list/proof and verify it on-chain.`:`Found ${m.length} eligible HoodLock airdrop(s) for ${n}: ${m.map(l=>`#${l.id}`).join(", ")}. Discovery can lag after creation. Choose an id, or pass a known new id, to hoodlock_airdrop_claim to verify and build a claim transaction.`;return{kind:"hoodlock_airdrop_eligible",chainId:x,account:n,recipient:n,caller:d,recipientDelta:"0",senderDelta:"0",eligible:m,claims:[],tx:void 0,txs:[],preview:{txs:[],changes:[],summary:p},summary:p}}var Se=o=>({tools:[{name:"hoodlock_airdrop_create",inputSchema:{type:"object",required:["token","entries"],additionalProperties:!1,properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663"},entries:{type:"array",description:"Ordered airdrop entries [{ index?, account, amount }] with base-unit integer string amounts"},total:{type:"string",description:"Optional total funded token amount as a base-unit integer string (>= sum of entries)"},maxClaims:{type:"number",description:"Optional claim count (must equal entries.length in 1..250000)"},endTime:{type:"number",description:"Unix timestamp in seconds (0 for non-sweepable or >= inclusion time + 604800)"},inclusionTime:{type:"number",description:"Optional expected transaction inclusion Unix timestamp in seconds (> already-mined block.timestamp)"},inclusionMargin:{type:"number",description:"Optional signing and inclusion margin in seconds above the already-mined block.timestamp (>= 1, default 30)"},uri:{type:"string",description:"Metadata URI (<= 256 UTF-8 bytes)"},decimals:{type:"number",description:"Optional token decimals when converting human decimal entry amounts via parseAmount"},rounding:{type:"string",enum:["floor","ceil"],description:"Optional rounding mode (floor or ceil) when converting decimal amounts"},account:{type:"string",description:"Optional creator wallet address for preview simulation"}}},execute:async(e,t)=>we(o,e,t)},{name:"hoodlock_airdrop_claim",inputSchema:{type:"object",required:["account"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional airdrop ID (omit to query eligible airdrops)"},account:{type:"string",description:"Leaf recipient address that receives the tokens"},caller:{type:"string",description:"Optional caller/relayer address submitting the tx (pays gas only, receives 0 tokens)"},index:{type:"number",description:"Optional leaf index when supplying proof directly or selecting from list/entries"},amount:{type:"string",description:"Optional leaf amount as a base-unit integer string"},proof:{type:"array",items:{type:"string"},description:"Optional Merkle sibling proof array of 32-byte hex strings"},savedProof:{type:"object",description:"Optional saved proof item ({ index, account, amount, leaf?, proof }) from hoodlock_airdrop_create"},list:{type:"object",description:"Optional saved airdrop list ({ format, leafEncoding, root, totalAmount, maxClaims, values, entries }) to rebuild proof locally"},entries:{type:"array",description:"Optional airdrop entries array ([{ index?, account, amount }]) to rebuild proof locally"}}},execute:async(e,t)=>$e(o,e,t)}]}),Me=Se;export{K as a,x as b,S as c,Z as d,P as e,ue as f,ye as g,ge as h,V as i,H as j,xe as k,N as l,te as m,De as n,L as o,he as p,Se as q,Me as r};
@@ -1 +1 @@
1
- import{a as A}from"./4X6JEMSF.js";import{a,b as g,c as b,e as w,f as x,g as h}from"./ITIIHCZK.js";import{a as r}from"./UWOFA6GV.js";import{c as y}from"./73N3TOJL.js";import{a as m}from"./XPFVT2EA.js";import{a as i}from"./5YS5V2LK.js";import{encodeAbiParameters as S,encodeFunctionData as B,encodePacked as T,erc20Abi as I,getAddress as q,parseAbi as C,parseAbiParameters as N,zeroAddress as R}from"viem";var O=q("0x0000ffffbe8efe702c8703ae3477ff5de3d319c0"),$=N("(address currency,address tokensRecipient,address fundsRecipient,uint64 startBlock,uint64 endBlock,uint64 claimBlock,uint256 tickSpacing,address validationHook,uint256 floorPrice,uint128 requiredCurrencyRaised,bytes auctionStepsData)"),P=C(["function create(address token,uint256 amount,bytes configData,bytes32 salt) returns (address)","function getAddress(address token,uint256 amount,bytes configData,bytes32 salt,address sender) view returns (address)"]),Q=C(["function distributeToken(address token,(address strategy,uint128 amount,bytes configData) distribution,bytes32 salt) payable"]),v={token:y,amount:r(),currency:y,startBlock:r(),endBlock:r(),claimBlock:r(),tickSpacing:r(),floorPrice:r(),requiredCurrencyRaised:r(),salt:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},steps:{type:"array",minItems:1,maxItems:100,items:{type:"object",additionalProperties:!1,required:["mps","duration"],properties:{mps:r(),duration:r()}}}};function D(e,t){let s=a(e.startBlock,"startBlock",64),o=a(e.endBlock,"endBlock",64),c=a(e.claimBlock,"claimBlock",64);if(o<=s||c<o)throw new i("Auction needs startBlock < endBlock <= claimBlock.");if(!Array.isArray(e.steps)||e.steps.length<1||e.steps.length>100)throw new i("Provide 1 to 100 issuance steps.");let u="0x",p=0n,l=0n;for(let d of e.steps){if(!d||typeof d!="object"||Array.isArray(d))throw new i("Each step requires mps and duration decimal strings.");h(d,["mps","duration"]);let n=d,k=a(n.mps,"mps",24,!0),f=a(n.duration,"duration",40);u=`${u}${T(["uint24","uint40"],[Number(k),Number(f)]).slice(2)}`,l+=k*f,p+=f}if(l!==10000000n||p!==o-s)throw new i("Issuance must total exactly 10000000 MPS and its durations must equal endBlock - startBlock.");return S($,[{currency:b(e.currency),tokensRecipient:t,fundsRecipient:t,startBlock:s,endBlock:o,claimBlock:c,tickSpacing:a(e.tickSpacing,"tickSpacing"),validationHook:R,floorPrice:a(e.floorPrice,"floorPrice"),requiredCurrencyRaised:a(e.requiredCurrencyRaised??"0","requiredCurrencyRaised",128,!0),auctionStepsData:u}])}function U(e){return{tools:[{name:"uniswap_create_auction",inputSchema:{type:"object",additionalProperties:!1,required:["token","amount","currency","startBlock","endBlock","claimBlock","tickSpacing","floorPrice","steps","salt"],properties:v},async execute(t,s){h(t,Object.keys(v));let o=g(t.token),c=a(t.amount,"amount",128);if(o===R||o===b(t.currency))throw new i("Auction sale token must be an ERC-20 distinct from its payment currency.");let u=D(t,s);if(typeof t.salt!="string"||!/^0x[0-9a-fA-F]{64}$/.test(t.salt))throw new i("Provide a 32-byte deployment salt.");let p=t.salt,l=e.clientFor(m),d=await l.getBlockNumber();if(BigInt(String(t.startBlock))<=d)throw new i("Choose a future auction startBlock with time for confirmation and approvals.");let n=await l.readContract({address:A,abi:P,functionName:"getAddress",args:[o,c,u,p,s]});if((await l.getCode({address:n})??"0x")!=="0x")throw new i("This auction already exists; choose a fresh salt or configuration.");let k=await w(e,o),f=[e.unsignedTx({to:A,data:B({abi:P,functionName:"create",args:[o,c,u,p]}),value:"0",chainId:m,description:`Create CCA ${n}; proceeds and unsold tokens go to ${s}.`}),e.unsignedTx({to:o,data:B({abi:I,functionName:"transfer",args:[n,c]}),value:"0",chainId:m,description:`Fund the factory-predicted auction ${n} with exactly ${c} base units of ${o}.`}),e.unsignedTx({to:n,data:B({abi:C(["function onTokensReceived()"]),functionName:"onTokensReceived"}),value:"0",chainId:m,description:`Activate CCA ${n} after its sale tokens arrive.`})];return{...await x(e,f,s,"Create/fund/activate a standalone CCA in three separately confirmed transactions, not an LBP-managed liquidity launch. If interrupted, inspect the predicted address and journal before recovery; do not transfer tokens twice. Raw prices are payment-base-units per sale-token-base-unit in Q96. No validation hook or off-chain signature; all proceeds and unsold tokens go to the signing wallet."),auction:n,sale:{token:k,amount:c.toString()}}}}]}}export{O as a,$ as b,P as c,Q as d,D as e,U as f};
1
+ import{a as A}from"./N6RL3SUZ.js";import{a,b as g,c as b,e as w,f as x,g as h}from"./64AF7ECA.js";import{a as r}from"./UWOFA6GV.js";import{c as y}from"./73N3TOJL.js";import{a as m}from"./XPFVT2EA.js";import{a as i}from"./5YS5V2LK.js";import{encodeAbiParameters as S,encodeFunctionData as B,encodePacked as T,erc20Abi as I,getAddress as q,parseAbi as C,parseAbiParameters as N,zeroAddress as R}from"viem";var O=q("0x0000ffffbe8efe702c8703ae3477ff5de3d319c0"),$=N("(address currency,address tokensRecipient,address fundsRecipient,uint64 startBlock,uint64 endBlock,uint64 claimBlock,uint256 tickSpacing,address validationHook,uint256 floorPrice,uint128 requiredCurrencyRaised,bytes auctionStepsData)"),P=C(["function create(address token,uint256 amount,bytes configData,bytes32 salt) returns (address)","function getAddress(address token,uint256 amount,bytes configData,bytes32 salt,address sender) view returns (address)"]),Q=C(["function distributeToken(address token,(address strategy,uint128 amount,bytes configData) distribution,bytes32 salt) payable"]),v={token:y,amount:r(),currency:y,startBlock:r(),endBlock:r(),claimBlock:r(),tickSpacing:r(),floorPrice:r(),requiredCurrencyRaised:r(),salt:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},steps:{type:"array",minItems:1,maxItems:100,items:{type:"object",additionalProperties:!1,required:["mps","duration"],properties:{mps:r(),duration:r()}}}};function D(e,t){let s=a(e.startBlock,"startBlock",64),o=a(e.endBlock,"endBlock",64),c=a(e.claimBlock,"claimBlock",64);if(o<=s||c<o)throw new i("Auction needs startBlock < endBlock <= claimBlock.");if(!Array.isArray(e.steps)||e.steps.length<1||e.steps.length>100)throw new i("Provide 1 to 100 issuance steps.");let u="0x",p=0n,l=0n;for(let d of e.steps){if(!d||typeof d!="object"||Array.isArray(d))throw new i("Each step requires mps and duration decimal strings.");h(d,["mps","duration"]);let n=d,k=a(n.mps,"mps",24,!0),f=a(n.duration,"duration",40);u=`${u}${T(["uint24","uint40"],[Number(k),Number(f)]).slice(2)}`,l+=k*f,p+=f}if(l!==10000000n||p!==o-s)throw new i("Issuance must total exactly 10000000 MPS and its durations must equal endBlock - startBlock.");return S($,[{currency:b(e.currency),tokensRecipient:t,fundsRecipient:t,startBlock:s,endBlock:o,claimBlock:c,tickSpacing:a(e.tickSpacing,"tickSpacing"),validationHook:R,floorPrice:a(e.floorPrice,"floorPrice"),requiredCurrencyRaised:a(e.requiredCurrencyRaised??"0","requiredCurrencyRaised",128,!0),auctionStepsData:u}])}function U(e){return{tools:[{name:"uniswap_create_auction",inputSchema:{type:"object",additionalProperties:!1,required:["token","amount","currency","startBlock","endBlock","claimBlock","tickSpacing","floorPrice","steps","salt"],properties:v},async execute(t,s){h(t,Object.keys(v));let o=g(t.token),c=a(t.amount,"amount",128);if(o===R||o===b(t.currency))throw new i("Auction sale token must be an ERC-20 distinct from its payment currency.");let u=D(t,s);if(typeof t.salt!="string"||!/^0x[0-9a-fA-F]{64}$/.test(t.salt))throw new i("Provide a 32-byte deployment salt.");let p=t.salt,l=e.clientFor(m),d=await l.getBlockNumber();if(BigInt(String(t.startBlock))<=d)throw new i("Choose a future auction startBlock with time for confirmation and approvals.");let n=await l.readContract({address:A,abi:P,functionName:"getAddress",args:[o,c,u,p,s]});if((await l.getCode({address:n})??"0x")!=="0x")throw new i("This auction already exists; choose a fresh salt or configuration.");let k=await w(e,o),f=[e.unsignedTx({to:A,data:B({abi:P,functionName:"create",args:[o,c,u,p]}),value:"0",chainId:m,description:`Create CCA ${n}; proceeds and unsold tokens go to ${s}.`}),e.unsignedTx({to:o,data:B({abi:I,functionName:"transfer",args:[n,c]}),value:"0",chainId:m,description:`Fund the factory-predicted auction ${n} with exactly ${c} base units of ${o}.`}),e.unsignedTx({to:n,data:B({abi:C(["function onTokensReceived()"]),functionName:"onTokensReceived"}),value:"0",chainId:m,description:`Activate CCA ${n} after its sale tokens arrive.`})];return{...await x(e,f,s,"Create/fund/activate a standalone CCA in three separately confirmed transactions, not an LBP-managed liquidity launch. If interrupted, inspect the predicted address and journal before recovery; do not transfer tokens twice. Raw prices are payment-base-units per sale-token-base-unit in Q96. No validation hook or off-chain signature; all proceeds and unsold tokens go to the signing wallet."),auction:n,sale:{token:k,amount:c.toString()}}}}]}}export{O as a,$ as b,P as c,Q as d,D as e,U as f};
@@ -1 +1 @@
1
- import{a as h}from"./HF2AGJZC.js";import{d as k,h as V}from"./JVTVOK6P.js";import{a as P,v as O}from"./FL3EF72E.js";import{a as g,b as f,f as M,g as A}from"./ITIIHCZK.js";import{a as b}from"./UWOFA6GV.js";import{c as _,g as T}from"./73N3TOJL.js";import{a as y}from"./XPFVT2EA.js";import{a as l}from"./5YS5V2LK.js";import{encodeFunctionData as c,parseAbi as j,zeroAddress as I}from"viem";var n=j(["function owner() view returns (address)","function feeTo() view returns (address)","function feeToSetter() view returns (address)","function protocolFeeController() view returns (address)","function setFeeTo(address)","function setFeeToSetter(address)","function setOwner(address)","function enableFeeAmount(uint24,int24)","function setFeeProtocol(uint8,uint8)","function collectProtocol(address,uint128,uint128) returns (uint128,uint128)","function transferOwnership(address)","function setProtocolFeeController(address)","function setProtocolFee((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks),uint24)","function collectProtocolFees(address recipient,address currency,uint256 amount) returns (uint256)"]),E=["set_fee_recipient","set_fee_setter","set_owner","enable_fee","set_pool_fee","collect_protocol","set_controller"],R={version:{type:"string",enum:["v2","v3","v4"]},operation:{type:"string",enum:E},target:_,token0:_,token1:_,fee:{type:"integer"},tickSpacing:{type:"integer"},fee0:{type:"integer"},fee1:{type:"integer"},currency:_,amount:b(),amount0Max:b(),amount1Max:b(),poolKey:{type:"object"}};function L(w){let x=async e=>{let i=w.clientFor(y);if(e==="v2"){let[o,t]=await Promise.all([i.readContract({address:h,abi:n,functionName:"feeToSetter"}),i.readContract({address:h,abi:n,functionName:"feeTo"})]);return{version:e,contract:h,owner:o,feeRecipient:t}}if(e==="v3")return{version:e,contract:k.factory,owner:await i.readContract({address:k.factory,abi:n,functionName:"owner"})};if(e==="v4"){let[o,t]=await Promise.all([i.readContract({address:P,abi:n,functionName:"owner"}),i.readContract({address:P,abi:n,functionName:"protocolFeeController"})]);return{version:e,contract:P,owner:o,controller:t}}throw new l("Provide protocol version v2, v3 or v4.")};return{tools:[{name:"uniswap_protocol_status",inputSchema:{type:"object",additionalProperties:!1,required:["version"],properties:{version:R.version}},async execute(e){return A(e,["version"]),x(e.version)}},{name:"uniswap_protocol_admin",inputSchema:{type:"object",additionalProperties:!1,required:["version","operation"],properties:R},async execute(e,i){let{version:o,operation:t}=e,v=await x(o),K=w.clientFor(y),C=o==="v4"&&["set_pool_fee","collect_protocol"].includes(String(t))?"controller"in v?v.controller:void 0:v.owner;if(!C||!T(C,i))throw new l("The signing wallet does not hold the required Uniswap owner/controller role.");let N=v.contract,s,a,F=()=>{let r=f(e.target);if(r===I)throw new l("Administration target must be nonzero.");return r},u=(r,d,p,m)=>{if(typeof r!="number"||!Number.isInteger(r)||r<p||r>m)throw new l(`${d} must be an integer from ${p} to ${m}.`);return r};if(o==="v2"&&t==="set_fee_recipient")a=["target"],s=c({abi:n,functionName:"setFeeTo",args:[f(e.target)]});else if(o==="v2"&&t==="set_fee_setter")a=["target"],s=c({abi:n,functionName:"setFeeToSetter",args:[F()]});else if(o==="v3"&&t==="set_owner")a=["target"],s=c({abi:n,functionName:"setOwner",args:[F()]});else if(o==="v3"&&t==="enable_fee")a=["fee","tickSpacing"],s=c({abi:n,functionName:"enableFeeAmount",args:[u(e.fee,"fee",0,999999),u(e.tickSpacing,"tickSpacing",1,16383)]});else if(o==="v3"&&["set_pool_fee","collect_protocol"].includes(String(t))){a=["token0","token1","fee",...t==="set_pool_fee"?["fee0","fee1"]:["amount0Max","amount1Max"]];let r=f(e.token0),d=f(e.token1),p=u(e.fee,"fee",0,999999);if(N=await K.readContract({address:k.factory,abi:V,functionName:"getPool",args:[r,d,p]}),N===I)throw new l("No factory-verified v3 pool exists for these tokens and fee.");if(t==="set_pool_fee"){let m=$=>{let S=u($,"fee divisor",0,10);if(S!==0&&S<4)throw new l("V3 protocol fee divisors must be zero or 4 through 10.");return S};s=c({abi:n,functionName:"setFeeProtocol",args:[m(e.fee0),m(e.fee1)]})}else s=c({abi:n,functionName:"collectProtocol",args:[i,g(e.amount0Max,"amount0Max",128,!0),g(e.amount1Max,"amount1Max",128,!0)]})}else if(o==="v4"&&t==="set_owner")a=["target"],s=c({abi:n,functionName:"transferOwnership",args:[F()]});else if(o==="v4"&&t==="set_controller")a=["target"],s=c({abi:n,functionName:"setProtocolFeeController",args:[f(e.target)]});else if(o==="v4"&&t==="set_pool_fee"){a=["poolKey","fee0","fee1"];let r=O(e.poolKey),d=u(e.fee0,"fee0 pips",0,1e3),p=u(e.fee1,"fee1 pips",0,1e3);s=c({abi:n,functionName:"setProtocolFee",args:[r,d+(p<<12)]})}else if(o==="v4"&&t==="collect_protocol")a=["currency","amount"],s=c({abi:n,functionName:"collectProtocolFees",args:[i,f(e.currency),g(e.amount,"amount",256,!0)]});else throw new l("This operation is not supported by the selected Uniswap protocol version.");return A(e,["version","operation",...a]),M(w,[w.unsignedTx({to:N,data:s,value:"0",chainId:y,description:`Uniswap ${o} protocol administration: ${t}. Role holder ${i}.`})],i,"Privileged protocol operation. Review the exact role/recipient/fee changes. Protocol fee collections pay the signing wallet; no wallet token approval is required.")}}]}}export{n as a,L as b};
1
+ import{d as k,h as V}from"./R7D256HG.js";import{a as h}from"./FSPNOVKB.js";import{a as P,v as O}from"./ANQ43XJA.js";import{a as g,b as f,f as M,g as A}from"./64AF7ECA.js";import{a as b}from"./UWOFA6GV.js";import{c as _,g as T}from"./73N3TOJL.js";import{a as y}from"./XPFVT2EA.js";import{a as l}from"./5YS5V2LK.js";import{encodeFunctionData as c,parseAbi as j,zeroAddress as I}from"viem";var n=j(["function owner() view returns (address)","function feeTo() view returns (address)","function feeToSetter() view returns (address)","function protocolFeeController() view returns (address)","function setFeeTo(address)","function setFeeToSetter(address)","function setOwner(address)","function enableFeeAmount(uint24,int24)","function setFeeProtocol(uint8,uint8)","function collectProtocol(address,uint128,uint128) returns (uint128,uint128)","function transferOwnership(address)","function setProtocolFeeController(address)","function setProtocolFee((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks),uint24)","function collectProtocolFees(address recipient,address currency,uint256 amount) returns (uint256)"]),E=["set_fee_recipient","set_fee_setter","set_owner","enable_fee","set_pool_fee","collect_protocol","set_controller"],R={version:{type:"string",enum:["v2","v3","v4"]},operation:{type:"string",enum:E},target:_,token0:_,token1:_,fee:{type:"integer"},tickSpacing:{type:"integer"},fee0:{type:"integer"},fee1:{type:"integer"},currency:_,amount:b(),amount0Max:b(),amount1Max:b(),poolKey:{type:"object"}};function L(w){let x=async e=>{let i=w.clientFor(y);if(e==="v2"){let[o,t]=await Promise.all([i.readContract({address:h,abi:n,functionName:"feeToSetter"}),i.readContract({address:h,abi:n,functionName:"feeTo"})]);return{version:e,contract:h,owner:o,feeRecipient:t}}if(e==="v3")return{version:e,contract:k.factory,owner:await i.readContract({address:k.factory,abi:n,functionName:"owner"})};if(e==="v4"){let[o,t]=await Promise.all([i.readContract({address:P,abi:n,functionName:"owner"}),i.readContract({address:P,abi:n,functionName:"protocolFeeController"})]);return{version:e,contract:P,owner:o,controller:t}}throw new l("Provide protocol version v2, v3 or v4.")};return{tools:[{name:"uniswap_protocol_status",inputSchema:{type:"object",additionalProperties:!1,required:["version"],properties:{version:R.version}},async execute(e){return A(e,["version"]),x(e.version)}},{name:"uniswap_protocol_admin",inputSchema:{type:"object",additionalProperties:!1,required:["version","operation"],properties:R},async execute(e,i){let{version:o,operation:t}=e,v=await x(o),K=w.clientFor(y),C=o==="v4"&&["set_pool_fee","collect_protocol"].includes(String(t))?"controller"in v?v.controller:void 0:v.owner;if(!C||!T(C,i))throw new l("The signing wallet does not hold the required Uniswap owner/controller role.");let N=v.contract,s,a,F=()=>{let r=f(e.target);if(r===I)throw new l("Administration target must be nonzero.");return r},u=(r,d,p,m)=>{if(typeof r!="number"||!Number.isInteger(r)||r<p||r>m)throw new l(`${d} must be an integer from ${p} to ${m}.`);return r};if(o==="v2"&&t==="set_fee_recipient")a=["target"],s=c({abi:n,functionName:"setFeeTo",args:[f(e.target)]});else if(o==="v2"&&t==="set_fee_setter")a=["target"],s=c({abi:n,functionName:"setFeeToSetter",args:[F()]});else if(o==="v3"&&t==="set_owner")a=["target"],s=c({abi:n,functionName:"setOwner",args:[F()]});else if(o==="v3"&&t==="enable_fee")a=["fee","tickSpacing"],s=c({abi:n,functionName:"enableFeeAmount",args:[u(e.fee,"fee",0,999999),u(e.tickSpacing,"tickSpacing",1,16383)]});else if(o==="v3"&&["set_pool_fee","collect_protocol"].includes(String(t))){a=["token0","token1","fee",...t==="set_pool_fee"?["fee0","fee1"]:["amount0Max","amount1Max"]];let r=f(e.token0),d=f(e.token1),p=u(e.fee,"fee",0,999999);if(N=await K.readContract({address:k.factory,abi:V,functionName:"getPool",args:[r,d,p]}),N===I)throw new l("No factory-verified v3 pool exists for these tokens and fee.");if(t==="set_pool_fee"){let m=$=>{let S=u($,"fee divisor",0,10);if(S!==0&&S<4)throw new l("V3 protocol fee divisors must be zero or 4 through 10.");return S};s=c({abi:n,functionName:"setFeeProtocol",args:[m(e.fee0),m(e.fee1)]})}else s=c({abi:n,functionName:"collectProtocol",args:[i,g(e.amount0Max,"amount0Max",128,!0),g(e.amount1Max,"amount1Max",128,!0)]})}else if(o==="v4"&&t==="set_owner")a=["target"],s=c({abi:n,functionName:"transferOwnership",args:[F()]});else if(o==="v4"&&t==="set_controller")a=["target"],s=c({abi:n,functionName:"setProtocolFeeController",args:[f(e.target)]});else if(o==="v4"&&t==="set_pool_fee"){a=["poolKey","fee0","fee1"];let r=O(e.poolKey),d=u(e.fee0,"fee0 pips",0,1e3),p=u(e.fee1,"fee1 pips",0,1e3);s=c({abi:n,functionName:"setProtocolFee",args:[r,d+(p<<12)]})}else if(o==="v4"&&t==="collect_protocol")a=["currency","amount"],s=c({abi:n,functionName:"collectProtocolFees",args:[i,f(e.currency),g(e.amount,"amount",256,!0)]});else throw new l("This operation is not supported by the selected Uniswap protocol version.");return A(e,["version","operation",...a]),M(w,[w.unsignedTx({to:N,data:s,value:"0",chainId:y,description:`Uniswap ${o} protocol administration: ${t}. Role holder ${i}.`})],i,"Privileged protocol operation. Review the exact role/recipient/fee changes. Protocol fee collections pay the signing wallet; no wallet token approval is required.")}}]}}export{n as a,L as b};