tempo.ts 0.1.5 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/README.md +33 -2
  2. package/dist/chains.d.ts +509 -115
  3. package/dist/chains.d.ts.map +1 -1
  4. package/dist/chains.js +20 -9
  5. package/dist/chains.js.map +1 -1
  6. package/dist/ox/Order.d.ts +92 -0
  7. package/dist/ox/Order.d.ts.map +1 -0
  8. package/dist/ox/Order.js +88 -0
  9. package/dist/ox/Order.js.map +1 -0
  10. package/dist/ox/OrdersFilters.d.ts +72 -0
  11. package/dist/ox/OrdersFilters.d.ts.map +1 -0
  12. package/dist/ox/OrdersFilters.js +100 -0
  13. package/dist/ox/OrdersFilters.js.map +1 -0
  14. package/dist/ox/Pagination.d.ts +128 -0
  15. package/dist/ox/Pagination.d.ts.map +1 -0
  16. package/dist/ox/Pagination.js +78 -0
  17. package/dist/ox/Pagination.js.map +1 -0
  18. package/dist/ox/PoolId.d.ts +18 -0
  19. package/dist/ox/PoolId.d.ts.map +1 -0
  20. package/dist/ox/PoolId.js +13 -0
  21. package/dist/ox/PoolId.js.map +1 -0
  22. package/dist/ox/RpcSchema.d.ts +32 -0
  23. package/dist/ox/RpcSchema.d.ts.map +1 -0
  24. package/dist/ox/RpcSchema.js +2 -0
  25. package/dist/ox/RpcSchema.js.map +1 -0
  26. package/dist/ox/SignatureEnvelope.d.ts +1 -1
  27. package/dist/ox/SignatureEnvelope.d.ts.map +1 -1
  28. package/dist/ox/SignatureEnvelope.js.map +1 -1
  29. package/dist/{viem → ox}/Tick.d.ts +4 -0
  30. package/dist/ox/Tick.d.ts.map +1 -0
  31. package/dist/ox/Tick.js.map +1 -0
  32. package/dist/ox/Transaction.d.ts.map +1 -1
  33. package/dist/ox/Transaction.js +2 -1
  34. package/dist/ox/Transaction.js.map +1 -1
  35. package/dist/ox/TransactionEnvelopeAA.d.ts +6 -6
  36. package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -1
  37. package/dist/ox/TransactionEnvelopeAA.js +4 -2
  38. package/dist/ox/TransactionEnvelopeAA.js.map +1 -1
  39. package/dist/ox/TransactionRequest.d.ts +4 -0
  40. package/dist/ox/TransactionRequest.d.ts.map +1 -1
  41. package/dist/ox/TransactionRequest.js.map +1 -1
  42. package/dist/ox/index.d.ts +6 -0
  43. package/dist/ox/index.d.ts.map +1 -1
  44. package/dist/ox/index.js +6 -0
  45. package/dist/ox/index.js.map +1 -1
  46. package/dist/prool/Instance.d.ts.map +1 -1
  47. package/dist/prool/Instance.js +20 -4
  48. package/dist/prool/Instance.js.map +1 -1
  49. package/dist/viem/Abis.d.ts +1469 -1082
  50. package/dist/viem/Abis.d.ts.map +1 -1
  51. package/dist/viem/Abis.js +932 -671
  52. package/dist/viem/Abis.js.map +1 -1
  53. package/dist/viem/Account.d.ts +150 -0
  54. package/dist/viem/Account.d.ts.map +1 -0
  55. package/dist/viem/Account.js +221 -0
  56. package/dist/viem/Account.js.map +1 -0
  57. package/dist/viem/Actions/amm.d.ts +144 -161
  58. package/dist/viem/Actions/amm.d.ts.map +1 -1
  59. package/dist/viem/Actions/amm.js +109 -163
  60. package/dist/viem/Actions/amm.js.map +1 -1
  61. package/dist/viem/Actions/dex.d.ts +920 -664
  62. package/dist/viem/Actions/dex.d.ts.map +1 -1
  63. package/dist/viem/Actions/dex.js +129 -30
  64. package/dist/viem/Actions/dex.js.map +1 -1
  65. package/dist/viem/Actions/faucet.d.ts +34 -0
  66. package/dist/viem/Actions/faucet.d.ts.map +1 -0
  67. package/dist/viem/Actions/faucet.js +33 -0
  68. package/dist/viem/Actions/faucet.js.map +1 -0
  69. package/dist/viem/Actions/fee.d.ts +16 -30
  70. package/dist/viem/Actions/fee.d.ts.map +1 -1
  71. package/dist/viem/Actions/fee.js +13 -13
  72. package/dist/viem/Actions/fee.js.map +1 -1
  73. package/dist/viem/Actions/index.d.ts +2 -0
  74. package/dist/viem/Actions/index.d.ts.map +1 -1
  75. package/dist/viem/Actions/index.js +2 -0
  76. package/dist/viem/Actions/index.js.map +1 -1
  77. package/dist/viem/Actions/policy.d.ts +46 -46
  78. package/dist/viem/Actions/policy.js +46 -46
  79. package/dist/viem/Actions/reward.d.ts +3236 -0
  80. package/dist/viem/Actions/reward.d.ts.map +1 -0
  81. package/dist/viem/Actions/reward.js +725 -0
  82. package/dist/viem/Actions/reward.js.map +1 -0
  83. package/dist/viem/Actions/token.d.ts +4399 -2750
  84. package/dist/viem/Actions/token.d.ts.map +1 -1
  85. package/dist/viem/Actions/token.js +361 -482
  86. package/dist/viem/Actions/token.js.map +1 -1
  87. package/dist/viem/Addresses.d.ts +1 -2
  88. package/dist/viem/Addresses.d.ts.map +1 -1
  89. package/dist/viem/Addresses.js +1 -2
  90. package/dist/viem/Addresses.js.map +1 -1
  91. package/dist/viem/Chain.d.ts +38 -12
  92. package/dist/viem/Chain.d.ts.map +1 -1
  93. package/dist/viem/Chain.js +27 -18
  94. package/dist/viem/Chain.js.map +1 -1
  95. package/dist/viem/Decorator.d.ts +1009 -428
  96. package/dist/viem/Decorator.d.ts.map +1 -1
  97. package/dist/viem/Decorator.js +17 -5
  98. package/dist/viem/Decorator.js.map +1 -1
  99. package/dist/viem/Formatters.d.ts +8 -1
  100. package/dist/viem/Formatters.d.ts.map +1 -1
  101. package/dist/viem/Formatters.js +17 -0
  102. package/dist/viem/Formatters.js.map +1 -1
  103. package/dist/viem/P256.d.ts +2 -0
  104. package/dist/viem/P256.d.ts.map +1 -0
  105. package/dist/viem/P256.js +2 -0
  106. package/dist/viem/P256.js.map +1 -0
  107. package/dist/viem/Secp256k1.d.ts +2 -0
  108. package/dist/viem/Secp256k1.d.ts.map +1 -0
  109. package/dist/viem/Secp256k1.js +2 -0
  110. package/dist/viem/Secp256k1.js.map +1 -0
  111. package/dist/viem/TokenIds.d.ts +1 -2
  112. package/dist/viem/TokenIds.d.ts.map +1 -1
  113. package/dist/viem/TokenIds.js +1 -2
  114. package/dist/viem/TokenIds.js.map +1 -1
  115. package/dist/viem/Transaction.d.ts +1 -1
  116. package/dist/viem/Transaction.d.ts.map +1 -1
  117. package/dist/viem/Transaction.js +46 -5
  118. package/dist/viem/Transaction.js.map +1 -1
  119. package/dist/viem/WebAuthnP256.d.ts +79 -0
  120. package/dist/viem/WebAuthnP256.d.ts.map +1 -0
  121. package/dist/viem/WebAuthnP256.js +95 -0
  122. package/dist/viem/WebAuthnP256.js.map +1 -0
  123. package/dist/viem/WebCryptoP256.d.ts +2 -0
  124. package/dist/viem/WebCryptoP256.d.ts.map +1 -0
  125. package/dist/viem/WebCryptoP256.js +2 -0
  126. package/dist/viem/WebCryptoP256.js.map +1 -0
  127. package/dist/viem/index.d.ts +6 -3
  128. package/dist/viem/index.d.ts.map +1 -1
  129. package/dist/viem/index.js +6 -3
  130. package/dist/viem/index.js.map +1 -1
  131. package/dist/viem/internal/account.d.ts +24 -0
  132. package/dist/viem/internal/account.d.ts.map +1 -0
  133. package/dist/viem/internal/account.js +68 -0
  134. package/dist/viem/internal/account.js.map +1 -0
  135. package/dist/viem/internal/types.d.ts +10 -0
  136. package/dist/viem/internal/types.d.ts.map +1 -1
  137. package/dist/wagmi/Actions/amm.d.ts +428 -0
  138. package/dist/wagmi/Actions/amm.d.ts.map +1 -0
  139. package/dist/wagmi/Actions/amm.js +472 -0
  140. package/dist/wagmi/Actions/amm.js.map +1 -0
  141. package/dist/wagmi/Actions/dex.d.ts +908 -0
  142. package/dist/wagmi/Actions/dex.d.ts.map +1 -0
  143. package/dist/wagmi/Actions/dex.js +1023 -0
  144. package/dist/wagmi/Actions/dex.js.map +1 -0
  145. package/dist/wagmi/Actions/faucet.d.ts +35 -0
  146. package/dist/wagmi/Actions/faucet.d.ts.map +1 -0
  147. package/dist/wagmi/Actions/faucet.js +33 -0
  148. package/dist/wagmi/Actions/faucet.js.map +1 -0
  149. package/dist/wagmi/Actions/fee.d.ts +111 -0
  150. package/dist/wagmi/Actions/fee.d.ts.map +1 -0
  151. package/dist/wagmi/Actions/fee.js +126 -0
  152. package/dist/wagmi/Actions/fee.js.map +1 -0
  153. package/dist/wagmi/Actions/index.d.ts +7 -0
  154. package/dist/wagmi/Actions/index.d.ts.map +1 -0
  155. package/dist/wagmi/Actions/index.js +7 -0
  156. package/dist/wagmi/Actions/index.js.map +1 -0
  157. package/dist/wagmi/Actions/reward.d.ts +348 -0
  158. package/dist/wagmi/Actions/reward.d.ts.map +1 -0
  159. package/dist/wagmi/Actions/reward.js +388 -0
  160. package/dist/wagmi/Actions/reward.js.map +1 -0
  161. package/dist/wagmi/Actions/token.d.ts +1546 -0
  162. package/dist/wagmi/Actions/token.d.ts.map +1 -0
  163. package/dist/wagmi/Actions/token.js +1712 -0
  164. package/dist/wagmi/Actions/token.js.map +1 -0
  165. package/dist/wagmi/Connector.d.ts +81 -0
  166. package/dist/wagmi/Connector.d.ts.map +1 -0
  167. package/dist/wagmi/Connector.js +261 -0
  168. package/dist/wagmi/Connector.js.map +1 -0
  169. package/dist/wagmi/Hooks/amm.d.ts +421 -0
  170. package/dist/wagmi/Hooks/amm.d.ts.map +1 -0
  171. package/dist/wagmi/Hooks/amm.js +504 -0
  172. package/dist/wagmi/Hooks/amm.js.map +1 -0
  173. package/dist/wagmi/Hooks/dex.d.ts +816 -0
  174. package/dist/wagmi/Hooks/dex.d.ts.map +1 -0
  175. package/dist/wagmi/Hooks/dex.js +973 -0
  176. package/dist/wagmi/Hooks/dex.js.map +1 -0
  177. package/dist/wagmi/Hooks/faucet.d.ts +39 -0
  178. package/dist/wagmi/Hooks/faucet.d.ts.map +1 -0
  179. package/dist/wagmi/Hooks/faucet.js +40 -0
  180. package/dist/wagmi/Hooks/faucet.js.map +1 -0
  181. package/dist/wagmi/Hooks/fee.d.ts +97 -0
  182. package/dist/wagmi/Hooks/fee.d.ts.map +1 -0
  183. package/dist/wagmi/Hooks/fee.js +109 -0
  184. package/dist/wagmi/Hooks/fee.js.map +1 -0
  185. package/dist/wagmi/Hooks/index.d.ts +7 -0
  186. package/dist/wagmi/Hooks/index.d.ts.map +1 -0
  187. package/dist/wagmi/Hooks/index.js +7 -0
  188. package/dist/wagmi/Hooks/index.js.map +1 -0
  189. package/dist/wagmi/Hooks/reward.d.ts +307 -0
  190. package/dist/wagmi/Hooks/reward.d.ts.map +1 -0
  191. package/dist/wagmi/Hooks/reward.js +349 -0
  192. package/dist/wagmi/Hooks/reward.js.map +1 -0
  193. package/dist/wagmi/Hooks/token.d.ts +1388 -0
  194. package/dist/wagmi/Hooks/token.d.ts.map +1 -0
  195. package/dist/wagmi/Hooks/token.js +1657 -0
  196. package/dist/wagmi/Hooks/token.js.map +1 -0
  197. package/dist/wagmi/index.d.ts +4 -0
  198. package/dist/wagmi/index.d.ts.map +1 -0
  199. package/dist/wagmi/index.js +4 -0
  200. package/dist/wagmi/index.js.map +1 -0
  201. package/package.json +54 -10
  202. package/src/chains.ts +21 -9
  203. package/src/ox/Order.test.ts +78 -0
  204. package/src/ox/Order.ts +125 -0
  205. package/src/ox/OrdersFilters.test.ts +182 -0
  206. package/src/ox/OrdersFilters.ts +125 -0
  207. package/src/ox/Pagination.test.ts +162 -0
  208. package/src/ox/Pagination.ts +164 -0
  209. package/src/ox/PoolId.test.ts +33 -0
  210. package/src/ox/PoolId.ts +27 -0
  211. package/src/ox/RpcSchema.ts +35 -0
  212. package/src/ox/SignatureEnvelope.ts +3 -1
  213. package/src/{viem → ox}/Tick.test.ts +1 -1
  214. package/src/{viem → ox}/Tick.ts +5 -0
  215. package/src/ox/Transaction.test.ts +1 -1
  216. package/src/ox/Transaction.ts +2 -1
  217. package/src/ox/TransactionEnvelopeAA.test.ts +239 -96
  218. package/src/ox/TransactionEnvelopeAA.ts +9 -7
  219. package/src/ox/TransactionRequest.ts +4 -0
  220. package/src/ox/index.ts +6 -0
  221. package/src/prool/Instance.ts +51 -37
  222. package/src/prool/internal/chain.json +104 -52
  223. package/src/tsconfig.json +9 -0
  224. package/src/viem/Abis.ts +972 -710
  225. package/src/viem/Account.ts +279 -0
  226. package/src/viem/Actions/__snapshots__/dex.test.ts.snap +850 -0
  227. package/src/viem/Actions/amm.test.ts +173 -169
  228. package/src/viem/Actions/amm.ts +131 -203
  229. package/src/viem/Actions/dex.test.ts +563 -484
  230. package/src/viem/Actions/dex.ts +203 -30
  231. package/src/viem/Actions/faucet.ts +50 -0
  232. package/src/viem/Actions/fee.test.ts +23 -34
  233. package/src/viem/Actions/fee.ts +20 -13
  234. package/src/viem/Actions/index.ts +2 -0
  235. package/src/viem/Actions/policy.test.ts +19 -33
  236. package/src/viem/Actions/policy.ts +46 -46
  237. package/src/viem/Actions/reward.test.ts +457 -0
  238. package/src/viem/Actions/reward.ts +999 -0
  239. package/src/viem/Actions/token.test.ts +453 -287
  240. package/src/viem/Actions/token.ts +605 -693
  241. package/src/viem/Addresses.ts +1 -2
  242. package/src/viem/Chain.bench-d.ts +12 -0
  243. package/src/viem/Chain.ts +70 -20
  244. package/src/viem/Decorator.bench-d.ts +1 -1
  245. package/src/viem/Decorator.test.ts +3 -1
  246. package/src/viem/Decorator.ts +1049 -442
  247. package/src/viem/Formatters.ts +31 -5
  248. package/src/viem/P256.ts +1 -0
  249. package/src/viem/Secp256k1.ts +1 -0
  250. package/src/viem/TokenIds.ts +1 -2
  251. package/src/viem/Transaction.ts +53 -7
  252. package/src/viem/WebAuthnP256.ts +140 -0
  253. package/src/viem/WebCryptoP256.ts +1 -0
  254. package/src/viem/e2e.test.ts +1126 -297
  255. package/src/viem/index.ts +6 -3
  256. package/src/viem/internal/account.ts +107 -0
  257. package/src/viem/internal/types.ts +9 -0
  258. package/src/wagmi/Actions/__snapshots__/dex.test.ts.snap +310 -0
  259. package/src/wagmi/Actions/amm.test.ts +198 -0
  260. package/src/wagmi/Actions/amm.ts +691 -0
  261. package/src/wagmi/Actions/dex.test.ts +1507 -0
  262. package/src/wagmi/Actions/dex.ts +1640 -0
  263. package/src/wagmi/Actions/faucet.ts +46 -0
  264. package/src/wagmi/Actions/fee.test.ts +63 -0
  265. package/src/wagmi/Actions/fee.ts +208 -0
  266. package/src/wagmi/Actions/index.ts +6 -0
  267. package/src/wagmi/Actions/reward.test.ts +210 -0
  268. package/src/wagmi/Actions/reward.ts +632 -0
  269. package/src/wagmi/Actions/token.test.ts +1308 -0
  270. package/src/wagmi/Actions/token.ts +2613 -0
  271. package/src/wagmi/Connector.test.ts +53 -0
  272. package/src/wagmi/Connector.ts +390 -0
  273. package/src/wagmi/Hooks/__snapshots__/dex.test.ts.snap +457 -0
  274. package/src/wagmi/Hooks/amm.test.ts +424 -0
  275. package/src/wagmi/Hooks/amm.ts +806 -0
  276. package/src/wagmi/Hooks/dex.test.ts +1017 -0
  277. package/src/wagmi/Hooks/dex.ts +1685 -0
  278. package/src/wagmi/Hooks/faucet.ts +76 -0
  279. package/src/wagmi/Hooks/fee.test.ts +166 -0
  280. package/src/wagmi/Hooks/fee.ts +206 -0
  281. package/src/wagmi/Hooks/index.ts +6 -0
  282. package/src/wagmi/Hooks/reward.test.ts +219 -0
  283. package/src/wagmi/Hooks/reward.ts +672 -0
  284. package/src/wagmi/Hooks/token.test.ts +1670 -0
  285. package/src/wagmi/Hooks/token.ts +2906 -0
  286. package/src/wagmi/index.ts +3 -0
  287. package/src/wagmi/internal/types.ts +16 -0
  288. package/dist/viem/Client.d.ts +0 -27
  289. package/dist/viem/Client.d.ts.map +0 -1
  290. package/dist/viem/Client.js +0 -28
  291. package/dist/viem/Client.js.map +0 -1
  292. package/dist/viem/Tick.d.ts.map +0 -1
  293. package/dist/viem/Tick.js.map +0 -1
  294. package/src/viem/Client.bench-d.ts +0 -8
  295. package/src/viem/Client.test.ts +0 -178
  296. package/src/viem/Client.ts +0 -91
  297. /package/dist/{viem → ox}/Tick.js +0 -0
@@ -0,0 +1,1685 @@
1
+ import type { DefaultError, InfiniteData } from '@tanstack/query-core'
2
+ import type { UseMutationResult } from '@tanstack/react-query'
3
+ import type { Config, ResolvedRegister } from '@wagmi/core'
4
+ import { useEffect } from 'react'
5
+ import { useChainId, useConfig } from 'wagmi'
6
+ import type { ConfigParameter, QueryParameter } from 'wagmi/internal'
7
+ import {
8
+ type UseInfiniteQueryReturnType,
9
+ type UseMutationParameters,
10
+ type UseQueryReturnType,
11
+ useInfiniteQuery,
12
+ useMutation,
13
+ useQuery,
14
+ } from 'wagmi/query'
15
+ import type { ExactPartial, UnionCompute } from '../../internal/types.js'
16
+
17
+ import {
18
+ buy,
19
+ buySync,
20
+ cancel,
21
+ cancelSync,
22
+ createPair,
23
+ createPairSync,
24
+ getBalance,
25
+ getBuyQuote,
26
+ getOrder,
27
+ getOrderbook,
28
+ getOrders,
29
+ getPriceLevel,
30
+ getSellQuote,
31
+ place,
32
+ placeFlip,
33
+ placeFlipSync,
34
+ placeSync,
35
+ sell,
36
+ sellSync,
37
+ watchFlipOrderPlaced,
38
+ watchOrderCancelled,
39
+ watchOrderFilled,
40
+ watchOrderPlaced,
41
+ withdraw,
42
+ withdrawSync,
43
+ } from '../Actions/dex.js'
44
+
45
+ /**
46
+ * Hook for buying a specific amount of tokens.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * import { Hooks } from 'tempo.ts/wagmi'
51
+ *
52
+ * function App() {
53
+ * const { mutate, isPending } = Hooks.dex.useBuy()
54
+ *
55
+ * return (
56
+ * <button
57
+ * onClick={() => mutate({
58
+ * tokenIn: '0x20c...11',
59
+ * tokenOut: '0x20c...20',
60
+ * amountOut: parseUnits('100', 6),
61
+ * maxAmountIn: parseUnits('105', 6),
62
+ * })}
63
+ * disabled={isPending}
64
+ * >
65
+ * Buy Tokens
66
+ * </button>
67
+ * )
68
+ * }
69
+ * ```
70
+ *
71
+ * @param parameters - Parameters.
72
+ * @returns Mutation result.
73
+ */
74
+ export function useBuy<
75
+ config extends Config = ResolvedRegister['config'],
76
+ context = unknown,
77
+ >(
78
+ parameters: useBuy.Parameters<config, context> = {},
79
+ ): useBuy.ReturnType<config, context> {
80
+ const { mutation } = parameters
81
+ const config = useConfig(parameters)
82
+ return useMutation({
83
+ ...mutation,
84
+ async mutationFn(variables) {
85
+ return buy(config, variables)
86
+ },
87
+ mutationKey: ['buy'],
88
+ })
89
+ }
90
+
91
+ export declare namespace useBuy {
92
+ type Parameters<
93
+ config extends Config = Config,
94
+ context = unknown,
95
+ > = ConfigParameter<config> & {
96
+ mutation?:
97
+ | UseMutationParameters<
98
+ buy.ReturnValue,
99
+ buy.ErrorType,
100
+ buy.Parameters<config>,
101
+ context
102
+ >
103
+ | undefined
104
+ }
105
+
106
+ type ReturnType<
107
+ config extends Config = Config,
108
+ context = unknown,
109
+ > = UseMutationResult<
110
+ buy.ReturnValue,
111
+ buy.ErrorType,
112
+ buy.Parameters<config>,
113
+ context
114
+ >
115
+ }
116
+
117
+ /**
118
+ * Hook for buying a specific amount of tokens.
119
+ *
120
+ * Note: This is a synchronous hook that waits for the transaction
121
+ * to be included on a block before returning a response.
122
+ *
123
+ * @example
124
+ * ```tsx
125
+ * import { Hooks } from 'tempo.ts/wagmi'
126
+ *
127
+ * function App() {
128
+ * const { mutate, isPending } = Hooks.dex.useBuySync()
129
+ *
130
+ * return (
131
+ * <button
132
+ * onClick={() => mutate({
133
+ * tokenIn: '0x20c...11',
134
+ * tokenOut: '0x20c...20',
135
+ * amountOut: parseUnits('100', 6),
136
+ * maxAmountIn: parseUnits('105', 6),
137
+ * })}
138
+ * disabled={isPending}
139
+ * >
140
+ * Buy Tokens
141
+ * </button>
142
+ * )
143
+ * }
144
+ * ```
145
+ *
146
+ * @param parameters - Parameters.
147
+ * @returns Mutation result.
148
+ */
149
+ export function useBuySync<
150
+ config extends Config = ResolvedRegister['config'],
151
+ context = unknown,
152
+ >(
153
+ parameters: useBuySync.Parameters<config, context> = {},
154
+ ): useBuySync.ReturnType<config, context> {
155
+ const { mutation } = parameters
156
+ const config = useConfig(parameters)
157
+ return useMutation({
158
+ ...mutation,
159
+ async mutationFn(variables) {
160
+ return buySync(config, variables)
161
+ },
162
+ mutationKey: ['buySync'],
163
+ })
164
+ }
165
+
166
+ export declare namespace useBuySync {
167
+ type Parameters<
168
+ config extends Config = Config,
169
+ context = unknown,
170
+ > = ConfigParameter<config> & {
171
+ mutation?:
172
+ | UseMutationParameters<
173
+ buySync.ReturnValue,
174
+ buySync.ErrorType,
175
+ buySync.Parameters<config>,
176
+ context
177
+ >
178
+ | undefined
179
+ }
180
+
181
+ type ReturnType<
182
+ config extends Config = Config,
183
+ context = unknown,
184
+ > = UseMutationResult<
185
+ buySync.ReturnValue,
186
+ buySync.ErrorType,
187
+ buySync.Parameters<config>,
188
+ context
189
+ >
190
+ }
191
+
192
+ /**
193
+ * Hook for canceling an order from the orderbook.
194
+ *
195
+ * @example
196
+ * ```tsx
197
+ * import { Hooks } from 'tempo.ts/wagmi'
198
+ *
199
+ * function App() {
200
+ * const { mutate, isPending } = Hooks.dex.useCancel()
201
+ *
202
+ * return (
203
+ * <button
204
+ * onClick={() => mutate({ orderId: 123n })}
205
+ * disabled={isPending}
206
+ * >
207
+ * Cancel Order
208
+ * </button>
209
+ * )
210
+ * }
211
+ * ```
212
+ *
213
+ * @param parameters - Parameters.
214
+ * @returns Mutation result.
215
+ */
216
+ export function useCancel<
217
+ config extends Config = ResolvedRegister['config'],
218
+ context = unknown,
219
+ >(
220
+ parameters: useCancel.Parameters<config, context> = {},
221
+ ): useCancel.ReturnType<config, context> {
222
+ const { mutation } = parameters
223
+ const config = useConfig(parameters)
224
+ return useMutation({
225
+ ...mutation,
226
+ async mutationFn(variables) {
227
+ return cancel(config, variables)
228
+ },
229
+ mutationKey: ['cancel'],
230
+ })
231
+ }
232
+
233
+ export declare namespace useCancel {
234
+ type Parameters<
235
+ config extends Config = Config,
236
+ context = unknown,
237
+ > = ConfigParameter<config> & {
238
+ mutation?:
239
+ | UseMutationParameters<
240
+ cancel.ReturnValue,
241
+ cancel.ErrorType,
242
+ cancel.Parameters<config>,
243
+ context
244
+ >
245
+ | undefined
246
+ }
247
+
248
+ type ReturnType<
249
+ config extends Config = Config,
250
+ context = unknown,
251
+ > = UseMutationResult<
252
+ cancel.ReturnValue,
253
+ cancel.ErrorType,
254
+ cancel.Parameters<config>,
255
+ context
256
+ >
257
+ }
258
+
259
+ /**
260
+ * Hook for canceling an order from the orderbook.
261
+ *
262
+ * Note: This is a synchronous hook that waits for the transaction
263
+ * to be included on a block before returning a response.
264
+ *
265
+ * @example
266
+ * ```tsx
267
+ * import { Hooks } from 'tempo.ts/wagmi'
268
+ *
269
+ * function App() {
270
+ * const { mutate, isPending } = Hooks.dex.useCancelSync()
271
+ *
272
+ * return (
273
+ * <button
274
+ * onClick={() => mutate({ orderId: 123n })}
275
+ * disabled={isPending}
276
+ * >
277
+ * Cancel Order
278
+ * </button>
279
+ * )
280
+ * }
281
+ * ```
282
+ *
283
+ * @param parameters - Parameters.
284
+ * @returns Mutation result.
285
+ */
286
+ export function useCancelSync<
287
+ config extends Config = ResolvedRegister['config'],
288
+ context = unknown,
289
+ >(
290
+ parameters: useCancelSync.Parameters<config, context> = {},
291
+ ): useCancelSync.ReturnType<config, context> {
292
+ const { mutation } = parameters
293
+ const config = useConfig(parameters)
294
+ return useMutation({
295
+ ...mutation,
296
+ async mutationFn(variables) {
297
+ return cancelSync(config, variables)
298
+ },
299
+ mutationKey: ['cancelSync'],
300
+ })
301
+ }
302
+
303
+ export declare namespace useCancelSync {
304
+ type Parameters<
305
+ config extends Config = Config,
306
+ context = unknown,
307
+ > = ConfigParameter<config> & {
308
+ mutation?:
309
+ | UseMutationParameters<
310
+ cancelSync.ReturnValue,
311
+ cancelSync.ErrorType,
312
+ cancelSync.Parameters<config>,
313
+ context
314
+ >
315
+ | undefined
316
+ }
317
+
318
+ type ReturnType<
319
+ config extends Config = Config,
320
+ context = unknown,
321
+ > = UseMutationResult<
322
+ cancelSync.ReturnValue,
323
+ cancelSync.ErrorType,
324
+ cancelSync.Parameters<config>,
325
+ context
326
+ >
327
+ }
328
+
329
+ /**
330
+ * Hook for creating a new trading pair on the DEX.
331
+ *
332
+ * @example
333
+ * ```tsx
334
+ * import { Hooks } from 'tempo.ts/wagmi'
335
+ *
336
+ * function App() {
337
+ * const { mutate, isPending } = Hooks.dex.useCreatePair()
338
+ *
339
+ * return (
340
+ * <button
341
+ * onClick={() => mutate({ base: '0x20c...11' })}
342
+ * disabled={isPending}
343
+ * >
344
+ * Create Pair
345
+ * </button>
346
+ * )
347
+ * }
348
+ * ```
349
+ *
350
+ * @param parameters - Parameters.
351
+ * @returns Mutation result.
352
+ */
353
+ export function useCreatePair<
354
+ config extends Config = ResolvedRegister['config'],
355
+ context = unknown,
356
+ >(
357
+ parameters: useCreatePair.Parameters<config, context> = {},
358
+ ): useCreatePair.ReturnType<config, context> {
359
+ const { mutation } = parameters
360
+ const config = useConfig(parameters)
361
+ return useMutation({
362
+ ...mutation,
363
+ async mutationFn(variables) {
364
+ return createPair(config, variables)
365
+ },
366
+ mutationKey: ['createPair'],
367
+ })
368
+ }
369
+
370
+ export declare namespace useCreatePair {
371
+ type Parameters<
372
+ config extends Config = Config,
373
+ context = unknown,
374
+ > = ConfigParameter<config> & {
375
+ mutation?:
376
+ | UseMutationParameters<
377
+ createPair.ReturnValue,
378
+ createPair.ErrorType,
379
+ createPair.Parameters<config>,
380
+ context
381
+ >
382
+ | undefined
383
+ }
384
+
385
+ type ReturnType<
386
+ config extends Config = Config,
387
+ context = unknown,
388
+ > = UseMutationResult<
389
+ createPair.ReturnValue,
390
+ createPair.ErrorType,
391
+ createPair.Parameters<config>,
392
+ context
393
+ >
394
+ }
395
+
396
+ /**
397
+ * Hook for creating a new trading pair on the DEX.
398
+ *
399
+ * Note: This is a synchronous hook that waits for the transaction
400
+ * to be included on a block before returning a response.
401
+ *
402
+ * @example
403
+ * ```tsx
404
+ * import { Hooks } from 'tempo.ts/wagmi'
405
+ *
406
+ * function App() {
407
+ * const { mutate, isPending } = Hooks.dex.useCreatePairSync()
408
+ *
409
+ * return (
410
+ * <button
411
+ * onClick={() => mutate({ base: '0x20c...11' })}
412
+ * disabled={isPending}
413
+ * >
414
+ * Create Pair
415
+ * </button>
416
+ * )
417
+ * }
418
+ * ```
419
+ *
420
+ * @param parameters - Parameters.
421
+ * @returns Mutation result.
422
+ */
423
+ export function useCreatePairSync<
424
+ config extends Config = ResolvedRegister['config'],
425
+ context = unknown,
426
+ >(
427
+ parameters: useCreatePairSync.Parameters<config, context> = {},
428
+ ): useCreatePairSync.ReturnType<config, context> {
429
+ const { mutation } = parameters
430
+ const config = useConfig(parameters)
431
+ return useMutation({
432
+ ...mutation,
433
+ async mutationFn(variables) {
434
+ return createPairSync(config, variables)
435
+ },
436
+ mutationKey: ['createPairSync'],
437
+ })
438
+ }
439
+
440
+ export declare namespace useCreatePairSync {
441
+ type Parameters<
442
+ config extends Config = Config,
443
+ context = unknown,
444
+ > = ConfigParameter<config> & {
445
+ mutation?:
446
+ | UseMutationParameters<
447
+ createPairSync.ReturnValue,
448
+ createPairSync.ErrorType,
449
+ createPairSync.Parameters<config>,
450
+ context
451
+ >
452
+ | undefined
453
+ }
454
+
455
+ type ReturnType<
456
+ config extends Config = Config,
457
+ context = unknown,
458
+ > = UseMutationResult<
459
+ createPairSync.ReturnValue,
460
+ createPairSync.ErrorType,
461
+ createPairSync.Parameters<config>,
462
+ context
463
+ >
464
+ }
465
+
466
+ /**
467
+ * Hook for getting a user's token balance on the DEX.
468
+ *
469
+ * @example
470
+ * ```tsx
471
+ * import { Hooks } from 'tempo.ts/wagmi'
472
+ *
473
+ * function App() {
474
+ * const { data, isLoading } = Hooks.dex.useBalance({
475
+ * account: '0x...',
476
+ * token: '0x20c...11',
477
+ * })
478
+ *
479
+ * if (isLoading) return <div>Loading...</div>
480
+ * return <div>Balance: {data}</div>
481
+ * }
482
+ * ```
483
+ *
484
+ * @param parameters - Parameters.
485
+ * @returns Query result with the user's token balance on the DEX.
486
+ */
487
+ export function useBalance<
488
+ config extends Config = ResolvedRegister['config'],
489
+ selectData = getBalance.ReturnValue,
490
+ >(parameters: useBalance.Parameters<config, selectData>) {
491
+ const { account, query = {} } = parameters
492
+
493
+ const config = useConfig(parameters)
494
+ const chainId = useChainId({ config })
495
+
496
+ const options = getBalance.queryOptions(config, {
497
+ ...parameters,
498
+ chainId: parameters.chainId ?? chainId,
499
+ query: undefined,
500
+ })
501
+ const enabled = Boolean(account && (query.enabled ?? true))
502
+
503
+ return useQuery({ ...query, ...options, enabled })
504
+ }
505
+
506
+ export declare namespace useBalance {
507
+ export type Parameters<
508
+ config extends Config = ResolvedRegister['config'],
509
+ selectData = getBalance.ReturnValue,
510
+ > = ConfigParameter<config> &
511
+ QueryParameter<
512
+ getBalance.ReturnValue,
513
+ DefaultError,
514
+ selectData,
515
+ getBalance.QueryKey<config>
516
+ > &
517
+ Omit<getBalance.queryOptions.Parameters<config, selectData>, 'query'>
518
+
519
+ export type ReturnValue<selectData = getBalance.ReturnValue> =
520
+ UseQueryReturnType<selectData, Error>
521
+ }
522
+
523
+ /**
524
+ * Hook for getting the quote for buying a specific amount of tokens.
525
+ *
526
+ * @example
527
+ * ```tsx
528
+ * import { Hooks } from 'tempo.ts/wagmi'
529
+ *
530
+ * function App() {
531
+ * const { data, isLoading } = Hooks.dex.useBuyQuote({
532
+ * amountOut: parseUnits('100', 6),
533
+ * tokenIn: '0x20c...11',
534
+ * tokenOut: '0x20c...20',
535
+ * })
536
+ *
537
+ * if (isLoading) return <div>Loading...</div>
538
+ * return <div>Required Input: {data}</div>
539
+ * }
540
+ * ```
541
+ *
542
+ * @param parameters - Parameters.
543
+ * @returns Query result with the amount of tokenIn needed.
544
+ */
545
+ export function useBuyQuote<
546
+ config extends Config = ResolvedRegister['config'],
547
+ selectData = getBuyQuote.ReturnValue,
548
+ >(parameters: useBuyQuote.Parameters<config, selectData>) {
549
+ const { query = {} } = parameters
550
+
551
+ const config = useConfig(parameters)
552
+ const chainId = useChainId({ config })
553
+
554
+ const options = getBuyQuote.queryOptions(config, {
555
+ ...parameters,
556
+ chainId: parameters.chainId ?? chainId,
557
+ query: undefined,
558
+ })
559
+ const enabled = Boolean(
560
+ parameters.tokenIn &&
561
+ parameters.tokenOut &&
562
+ parameters.amountOut &&
563
+ (query.enabled ?? true),
564
+ )
565
+
566
+ return useQuery({ ...query, ...options, enabled })
567
+ }
568
+
569
+ export declare namespace useBuyQuote {
570
+ export type Parameters<
571
+ config extends Config = ResolvedRegister['config'],
572
+ selectData = getBuyQuote.ReturnValue,
573
+ > = ConfigParameter<config> &
574
+ QueryParameter<
575
+ getBuyQuote.ReturnValue,
576
+ DefaultError,
577
+ selectData,
578
+ getBuyQuote.QueryKey<config>
579
+ > &
580
+ Omit<getBuyQuote.queryOptions.Parameters<config, selectData>, 'query'>
581
+
582
+ export type ReturnValue<selectData = getBuyQuote.ReturnValue> =
583
+ UseQueryReturnType<selectData, Error>
584
+ }
585
+
586
+ /**
587
+ * Hook for getting an order's details from the orderbook.
588
+ *
589
+ * @example
590
+ * ```tsx
591
+ * import { Hooks } from 'tempo.ts/wagmi'
592
+ *
593
+ * function App() {
594
+ * const { data, isLoading } = Hooks.dex.useOrder({
595
+ * orderId: 123n,
596
+ * })
597
+ *
598
+ * if (isLoading) return <div>Loading...</div>
599
+ * return <div>Order: {JSON.stringify(data)}</div>
600
+ * }
601
+ * ```
602
+ *
603
+ * @param parameters - Parameters.
604
+ * @returns Query result with the order details.
605
+ */
606
+ export function useOrder<
607
+ config extends Config = ResolvedRegister['config'],
608
+ selectData = getOrder.ReturnValue,
609
+ >(parameters: useOrder.Parameters<config, selectData>) {
610
+ const { query = {} } = parameters
611
+
612
+ const config = useConfig(parameters)
613
+ const chainId = useChainId({ config })
614
+
615
+ const options = getOrder.queryOptions(config, {
616
+ ...parameters,
617
+ chainId: parameters.chainId ?? chainId,
618
+ query: undefined,
619
+ })
620
+ const enabled = Boolean(
621
+ parameters.orderId !== undefined && (query.enabled ?? true),
622
+ )
623
+
624
+ return useQuery({ ...query, ...options, enabled })
625
+ }
626
+
627
+ export declare namespace useOrder {
628
+ export type Parameters<
629
+ config extends Config = ResolvedRegister['config'],
630
+ selectData = getOrder.ReturnValue,
631
+ > = ConfigParameter<config> &
632
+ QueryParameter<
633
+ getOrder.ReturnValue,
634
+ DefaultError,
635
+ selectData,
636
+ getOrder.QueryKey<config>
637
+ > &
638
+ Omit<getOrder.queryOptions.Parameters<config, selectData>, 'query'>
639
+
640
+ export type ReturnValue<selectData = getOrder.ReturnValue> =
641
+ UseQueryReturnType<selectData, Error>
642
+ }
643
+
644
+ /**
645
+ * Hook for getting paginated orders from the orderbook.
646
+ *
647
+ * @example
648
+ * ```tsx
649
+ * import { Hooks } from 'tempo.ts/wagmi'
650
+ *
651
+ * function App() {
652
+ * const { data, fetchNextPage, hasNextPage, isFetchingNextPage } = Hooks.dex.useGetOrders({
653
+ * limit: 10,
654
+ * filters: {
655
+ * baseToken: '0x20c0...',
656
+ * isBid: true,
657
+ * }
658
+ * })
659
+ *
660
+ * return (
661
+ * <div>
662
+ * {data?.pages.map((page, i) => (
663
+ * <div key={i}>
664
+ * {page.orders.map((order) => (
665
+ * <div key={order.orderId.toString()}>{order.amount.toString()}</div>
666
+ * ))}
667
+ * </div>
668
+ * ))}
669
+ * {hasNextPage && (
670
+ * <button onClick={() => fetchNextPage()} disabled={isFetchingNextPage}>
671
+ * Load More
672
+ * </button>
673
+ * )}
674
+ * </div>
675
+ * )
676
+ * }
677
+ * ```
678
+ *
679
+ * @param parameters - Parameters.
680
+ * @returns Infinite query result with paginated orders.
681
+ */
682
+ export function useGetOrders<
683
+ config extends Config = ResolvedRegister['config'],
684
+ selectData = getOrders.ReturnValue,
685
+ >(parameters: useGetOrders.Parameters<config, selectData> = {}) {
686
+ const { query = {}, ...rest } = parameters
687
+
688
+ const config = useConfig(parameters)
689
+ const chainId = useChainId({ config })
690
+
691
+ const options = getOrders.infiniteQueryOptions(config, {
692
+ ...rest,
693
+ chainId: parameters.chainId ?? chainId,
694
+ query: undefined,
695
+ })
696
+
697
+ return useInfiniteQuery({
698
+ ...query,
699
+ ...options,
700
+ } as never) as useGetOrders.ReturnValue<selectData>
701
+ }
702
+
703
+ export declare namespace useGetOrders {
704
+ export type Parameters<
705
+ config extends Config = ResolvedRegister['config'],
706
+ selectData = getOrders.ReturnValue,
707
+ > = ConfigParameter<config> &
708
+ Omit<
709
+ QueryParameter<
710
+ getOrders.ReturnValue,
711
+ DefaultError,
712
+ selectData,
713
+ getOrders.QueryKey<config>
714
+ >,
715
+ 'queryFn' | 'queryKey'
716
+ > &
717
+ ExactPartial<
718
+ Omit<
719
+ getOrders.infiniteQueryOptions.Parameters<config, selectData>,
720
+ 'query'
721
+ >
722
+ >
723
+
724
+ export type ReturnValue<selectData = getOrders.ReturnValue> =
725
+ UseInfiniteQueryReturnType<InfiniteData<selectData>, Error>
726
+ }
727
+
728
+ /**
729
+ * Hook for getting orderbook information for a trading pair.
730
+ *
731
+ * @example
732
+ * ```tsx
733
+ * import { Hooks } from 'tempo.ts/wagmi'
734
+ *
735
+ * function App() {
736
+ * const { data, isLoading } = Hooks.dex.useOrderbook({
737
+ * base: '0x20c...11',
738
+ * quote: '0x20c...20',
739
+ * })
740
+ *
741
+ * if (isLoading) return <div>Loading...</div>
742
+ * return <div>Orderbook: {JSON.stringify(data)}</div>
743
+ * }
744
+ * ```
745
+ *
746
+ * @param parameters - Parameters.
747
+ * @returns Query result with the orderbook information.
748
+ */
749
+ export function useOrderbook<
750
+ config extends Config = ResolvedRegister['config'],
751
+ selectData = getOrderbook.ReturnValue,
752
+ >(parameters: useOrderbook.Parameters<config, selectData>) {
753
+ const { query = {} } = parameters
754
+
755
+ const config = useConfig(parameters)
756
+ const chainId = useChainId({ config })
757
+
758
+ const options = getOrderbook.queryOptions(config, {
759
+ ...parameters,
760
+ chainId: parameters.chainId ?? chainId,
761
+ query: undefined,
762
+ })
763
+ const enabled = Boolean(
764
+ parameters.base && parameters.quote && (query.enabled ?? true),
765
+ )
766
+
767
+ return useQuery({ ...query, ...options, enabled })
768
+ }
769
+
770
+ export declare namespace useOrderbook {
771
+ export type Parameters<
772
+ config extends Config = ResolvedRegister['config'],
773
+ selectData = getOrderbook.ReturnValue,
774
+ > = ConfigParameter<config> &
775
+ QueryParameter<
776
+ getOrderbook.ReturnValue,
777
+ DefaultError,
778
+ selectData,
779
+ getOrderbook.QueryKey<config>
780
+ > &
781
+ Omit<getOrderbook.queryOptions.Parameters<config, selectData>, 'query'>
782
+
783
+ export type ReturnValue<selectData = getOrderbook.ReturnValue> =
784
+ UseQueryReturnType<selectData, Error>
785
+ }
786
+
787
+ /**
788
+ * Hook for getting the price level information at a specific tick.
789
+ *
790
+ * @example
791
+ * ```tsx
792
+ * import { Hooks } from 'tempo.ts/wagmi'
793
+ *
794
+ * function App() {
795
+ * const { data, isLoading } = Hooks.dex.usePriceLevel({
796
+ * base: '0x20c...11',
797
+ * tick: Tick.fromPrice('1.001'),
798
+ * isBid: true,
799
+ * })
800
+ *
801
+ * if (isLoading) return <div>Loading...</div>
802
+ * return <div>Price Level: {JSON.stringify(data)}</div>
803
+ * }
804
+ * ```
805
+ *
806
+ * @param parameters - Parameters.
807
+ * @returns Query result with the price level information.
808
+ */
809
+ export function usePriceLevel<
810
+ config extends Config = ResolvedRegister['config'],
811
+ selectData = getPriceLevel.ReturnValue,
812
+ >(parameters: usePriceLevel.Parameters<config, selectData>) {
813
+ const { query = {} } = parameters
814
+
815
+ const config = useConfig(parameters)
816
+ const chainId = useChainId({ config })
817
+
818
+ const options = getPriceLevel.queryOptions(config, {
819
+ ...parameters,
820
+ chainId: parameters.chainId ?? chainId,
821
+ query: undefined,
822
+ })
823
+ const enabled = Boolean(
824
+ parameters.base &&
825
+ parameters.tick !== undefined &&
826
+ parameters.isBid !== undefined &&
827
+ (query.enabled ?? true),
828
+ )
829
+
830
+ return useQuery({ ...query, ...options, enabled })
831
+ }
832
+
833
+ export declare namespace usePriceLevel {
834
+ export type Parameters<
835
+ config extends Config = ResolvedRegister['config'],
836
+ selectData = getPriceLevel.ReturnValue,
837
+ > = ConfigParameter<config> &
838
+ QueryParameter<
839
+ getPriceLevel.ReturnValue,
840
+ DefaultError,
841
+ selectData,
842
+ getPriceLevel.QueryKey<config>
843
+ > &
844
+ Omit<getPriceLevel.queryOptions.Parameters<config, selectData>, 'query'>
845
+
846
+ export type ReturnValue<selectData = getPriceLevel.ReturnValue> =
847
+ UseQueryReturnType<selectData, Error>
848
+ }
849
+
850
+ /**
851
+ * Hook for getting the quote for selling a specific amount of tokens.
852
+ *
853
+ * @example
854
+ * ```tsx
855
+ * import { Hooks } from 'tempo.ts/wagmi'
856
+ *
857
+ * function App() {
858
+ * const { data, isLoading } = Hooks.dex.useSellQuote({
859
+ * amountIn: parseUnits('100', 6),
860
+ * tokenIn: '0x20c...11',
861
+ * tokenOut: '0x20c...20',
862
+ * })
863
+ *
864
+ * if (isLoading) return <div>Loading...</div>
865
+ * return <div>Expected Output: {data}</div>
866
+ * }
867
+ * ```
868
+ *
869
+ * @param parameters - Parameters.
870
+ * @returns Query result with the amount of tokenOut received.
871
+ */
872
+ export function useSellQuote<
873
+ config extends Config = ResolvedRegister['config'],
874
+ selectData = getSellQuote.ReturnValue,
875
+ >(parameters: useSellQuote.Parameters<config, selectData>) {
876
+ const { query = {} } = parameters
877
+
878
+ const config = useConfig(parameters)
879
+ const chainId = useChainId({ config })
880
+
881
+ const options = getSellQuote.queryOptions(config, {
882
+ ...parameters,
883
+ chainId: parameters.chainId ?? chainId,
884
+ query: undefined,
885
+ })
886
+ const enabled = Boolean(
887
+ parameters.tokenIn &&
888
+ parameters.tokenOut &&
889
+ parameters.amountIn &&
890
+ (query.enabled ?? true),
891
+ )
892
+
893
+ return useQuery({ ...query, ...options, enabled })
894
+ }
895
+
896
+ export declare namespace useSellQuote {
897
+ export type Parameters<
898
+ config extends Config = ResolvedRegister['config'],
899
+ selectData = getSellQuote.ReturnValue,
900
+ > = ConfigParameter<config> &
901
+ QueryParameter<
902
+ getSellQuote.ReturnValue,
903
+ DefaultError,
904
+ selectData,
905
+ getSellQuote.QueryKey<config>
906
+ > &
907
+ Omit<getSellQuote.queryOptions.Parameters<config, selectData>, 'query'>
908
+
909
+ export type ReturnValue<selectData = getSellQuote.ReturnValue> =
910
+ UseQueryReturnType<selectData, Error>
911
+ }
912
+
913
+ /**
914
+ * Hook for placing a limit order on the orderbook.
915
+ *
916
+ * @example
917
+ * ```tsx
918
+ * import { Hooks } from 'tempo.ts/wagmi'
919
+ *
920
+ * function App() {
921
+ * const { mutate, isPending } = Hooks.dex.usePlace()
922
+ *
923
+ * return (
924
+ * <button
925
+ * onClick={() => mutate({
926
+ * amount: parseUnits('100', 6),
927
+ * tick: Tick.fromPrice('0.99'),
928
+ * token: '0x20c...11',
929
+ * type: 'buy',
930
+ * })}
931
+ * disabled={isPending}
932
+ * >
933
+ * Place Order
934
+ * </button>
935
+ * )
936
+ * }
937
+ * ```
938
+ *
939
+ * @param parameters - Parameters.
940
+ * @returns Mutation result.
941
+ */
942
+ export function usePlace<
943
+ config extends Config = ResolvedRegister['config'],
944
+ context = unknown,
945
+ >(
946
+ parameters: usePlace.Parameters<config, context> = {},
947
+ ): usePlace.ReturnType<config, context> {
948
+ const { mutation } = parameters
949
+ const config = useConfig(parameters)
950
+ return useMutation({
951
+ ...mutation,
952
+ async mutationFn(variables) {
953
+ return place(config, variables)
954
+ },
955
+ mutationKey: ['place'],
956
+ })
957
+ }
958
+
959
+ export declare namespace usePlace {
960
+ type Parameters<
961
+ config extends Config = Config,
962
+ context = unknown,
963
+ > = ConfigParameter<config> & {
964
+ mutation?:
965
+ | UseMutationParameters<
966
+ place.ReturnValue,
967
+ place.ErrorType,
968
+ place.Parameters<config>,
969
+ context
970
+ >
971
+ | undefined
972
+ }
973
+
974
+ type ReturnType<
975
+ config extends Config = Config,
976
+ context = unknown,
977
+ > = UseMutationResult<
978
+ place.ReturnValue,
979
+ place.ErrorType,
980
+ place.Parameters<config>,
981
+ context
982
+ >
983
+ }
984
+
985
+ /**
986
+ * Hook for placing a flip order that automatically flips when filled.
987
+ *
988
+ * @example
989
+ * ```tsx
990
+ * import { Hooks } from 'tempo.ts/wagmi'
991
+ *
992
+ * function App() {
993
+ * const { mutate, isPending } = Hooks.dex.usePlaceFlip()
994
+ *
995
+ * return (
996
+ * <button
997
+ * onClick={() => mutate({
998
+ * amount: parseUnits('100', 6),
999
+ * flipTick: Tick.fromPrice('1.01'),
1000
+ * tick: Tick.fromPrice('0.99'),
1001
+ * token: '0x20c...11',
1002
+ * type: 'buy',
1003
+ * })}
1004
+ * disabled={isPending}
1005
+ * >
1006
+ * Place Flip Order
1007
+ * </button>
1008
+ * )
1009
+ * }
1010
+ * ```
1011
+ *
1012
+ * @param parameters - Parameters.
1013
+ * @returns Mutation result.
1014
+ */
1015
+ export function usePlaceFlip<
1016
+ config extends Config = ResolvedRegister['config'],
1017
+ context = unknown,
1018
+ >(
1019
+ parameters: usePlaceFlip.Parameters<config, context> = {},
1020
+ ): usePlaceFlip.ReturnType<config, context> {
1021
+ const { mutation } = parameters
1022
+ const config = useConfig(parameters)
1023
+ return useMutation({
1024
+ ...mutation,
1025
+ async mutationFn(variables) {
1026
+ return placeFlip(config, variables)
1027
+ },
1028
+ mutationKey: ['placeFlip'],
1029
+ })
1030
+ }
1031
+
1032
+ export declare namespace usePlaceFlip {
1033
+ type Parameters<
1034
+ config extends Config = Config,
1035
+ context = unknown,
1036
+ > = ConfigParameter<config> & {
1037
+ mutation?:
1038
+ | UseMutationParameters<
1039
+ placeFlip.ReturnValue,
1040
+ placeFlip.ErrorType,
1041
+ placeFlip.Parameters<config>,
1042
+ context
1043
+ >
1044
+ | undefined
1045
+ }
1046
+
1047
+ type ReturnType<
1048
+ config extends Config = Config,
1049
+ context = unknown,
1050
+ > = UseMutationResult<
1051
+ placeFlip.ReturnValue,
1052
+ placeFlip.ErrorType,
1053
+ placeFlip.Parameters<config>,
1054
+ context
1055
+ >
1056
+ }
1057
+
1058
+ /**
1059
+ * Hook for placing a flip order that automatically flips when filled.
1060
+ *
1061
+ * Note: This is a synchronous hook that waits for the transaction
1062
+ * to be included on a block before returning a response.
1063
+ *
1064
+ * @example
1065
+ * ```tsx
1066
+ * import { Hooks } from 'tempo.ts/wagmi'
1067
+ *
1068
+ * function App() {
1069
+ * const { mutate, isPending } = Hooks.dex.usePlaceFlipSync()
1070
+ *
1071
+ * return (
1072
+ * <button
1073
+ * onClick={() => mutate({
1074
+ * amount: parseUnits('100', 6),
1075
+ * flipTick: Tick.fromPrice('1.01'),
1076
+ * tick: Tick.fromPrice('0.99'),
1077
+ * token: '0x20c...11',
1078
+ * type: 'buy',
1079
+ * })}
1080
+ * disabled={isPending}
1081
+ * >
1082
+ * Place Flip Order
1083
+ * </button>
1084
+ * )
1085
+ * }
1086
+ * ```
1087
+ *
1088
+ * @param parameters - Parameters.
1089
+ * @returns Mutation result.
1090
+ */
1091
+ export function usePlaceFlipSync<
1092
+ config extends Config = ResolvedRegister['config'],
1093
+ context = unknown,
1094
+ >(
1095
+ parameters: usePlaceFlipSync.Parameters<config, context> = {},
1096
+ ): usePlaceFlipSync.ReturnType<config, context> {
1097
+ const { mutation } = parameters
1098
+ const config = useConfig(parameters)
1099
+ return useMutation({
1100
+ ...mutation,
1101
+ async mutationFn(variables) {
1102
+ return placeFlipSync(config, variables)
1103
+ },
1104
+ mutationKey: ['placeFlipSync'],
1105
+ })
1106
+ }
1107
+
1108
+ export declare namespace usePlaceFlipSync {
1109
+ type Parameters<
1110
+ config extends Config = Config,
1111
+ context = unknown,
1112
+ > = ConfigParameter<config> & {
1113
+ mutation?:
1114
+ | UseMutationParameters<
1115
+ placeFlipSync.ReturnValue,
1116
+ placeFlipSync.ErrorType,
1117
+ placeFlipSync.Parameters<config>,
1118
+ context
1119
+ >
1120
+ | undefined
1121
+ }
1122
+
1123
+ type ReturnType<
1124
+ config extends Config = Config,
1125
+ context = unknown,
1126
+ > = UseMutationResult<
1127
+ placeFlipSync.ReturnValue,
1128
+ placeFlipSync.ErrorType,
1129
+ placeFlipSync.Parameters<config>,
1130
+ context
1131
+ >
1132
+ }
1133
+
1134
+ /**
1135
+ * Hook for placing a limit order on the orderbook.
1136
+ *
1137
+ * Note: This is a synchronous hook that waits for the transaction
1138
+ * to be included on a block before returning a response.
1139
+ *
1140
+ * @example
1141
+ * ```tsx
1142
+ * import { Hooks } from 'tempo.ts/wagmi'
1143
+ *
1144
+ * function App() {
1145
+ * const { mutate, isPending } = Hooks.dex.usePlaceSync()
1146
+ *
1147
+ * return (
1148
+ * <button
1149
+ * onClick={() => mutate({
1150
+ * amount: parseUnits('100', 6),
1151
+ * tick: Tick.fromPrice('0.99'),
1152
+ * token: '0x20c...11',
1153
+ * type: 'buy',
1154
+ * })}
1155
+ * disabled={isPending}
1156
+ * >
1157
+ * Place Order
1158
+ * </button>
1159
+ * )
1160
+ * }
1161
+ * ```
1162
+ *
1163
+ * @param parameters - Parameters.
1164
+ * @returns Mutation result.
1165
+ */
1166
+ export function usePlaceSync<
1167
+ config extends Config = ResolvedRegister['config'],
1168
+ context = unknown,
1169
+ >(
1170
+ parameters: usePlaceSync.Parameters<config, context> = {},
1171
+ ): usePlaceSync.ReturnType<config, context> {
1172
+ const { mutation } = parameters
1173
+ const config = useConfig(parameters)
1174
+ return useMutation({
1175
+ ...mutation,
1176
+ async mutationFn(variables) {
1177
+ return placeSync(config, variables)
1178
+ },
1179
+ mutationKey: ['placeSync'],
1180
+ })
1181
+ }
1182
+
1183
+ export declare namespace usePlaceSync {
1184
+ type Parameters<
1185
+ config extends Config = Config,
1186
+ context = unknown,
1187
+ > = ConfigParameter<config> & {
1188
+ mutation?:
1189
+ | UseMutationParameters<
1190
+ placeSync.ReturnValue,
1191
+ placeSync.ErrorType,
1192
+ placeSync.Parameters<config>,
1193
+ context
1194
+ >
1195
+ | undefined
1196
+ }
1197
+
1198
+ type ReturnType<
1199
+ config extends Config = Config,
1200
+ context = unknown,
1201
+ > = UseMutationResult<
1202
+ placeSync.ReturnValue,
1203
+ placeSync.ErrorType,
1204
+ placeSync.Parameters<config>,
1205
+ context
1206
+ >
1207
+ }
1208
+
1209
+ /**
1210
+ * Hook for selling a specific amount of tokens.
1211
+ *
1212
+ * @example
1213
+ * ```tsx
1214
+ * import { Hooks } from 'tempo.ts/wagmi'
1215
+ *
1216
+ * function App() {
1217
+ * const { mutate, isPending } = Hooks.dex.useSell()
1218
+ *
1219
+ * return (
1220
+ * <button
1221
+ * onClick={() => mutate({
1222
+ * amountIn: parseUnits('100', 6),
1223
+ * minAmountOut: parseUnits('95', 6),
1224
+ * tokenIn: '0x20c...11',
1225
+ * tokenOut: '0x20c...20',
1226
+ * })}
1227
+ * disabled={isPending}
1228
+ * >
1229
+ * Sell Tokens
1230
+ * </button>
1231
+ * )
1232
+ * }
1233
+ * ```
1234
+ *
1235
+ * @param parameters - Parameters.
1236
+ * @returns Mutation result.
1237
+ */
1238
+ export function useSell<
1239
+ config extends Config = ResolvedRegister['config'],
1240
+ context = unknown,
1241
+ >(
1242
+ parameters: useSell.Parameters<config, context> = {},
1243
+ ): useSell.ReturnType<config, context> {
1244
+ const { mutation } = parameters
1245
+ const config = useConfig(parameters)
1246
+ return useMutation({
1247
+ ...mutation,
1248
+ async mutationFn(variables) {
1249
+ return sell(config, variables)
1250
+ },
1251
+ mutationKey: ['sell'],
1252
+ })
1253
+ }
1254
+
1255
+ export declare namespace useSell {
1256
+ type Parameters<
1257
+ config extends Config = Config,
1258
+ context = unknown,
1259
+ > = ConfigParameter<config> & {
1260
+ mutation?:
1261
+ | UseMutationParameters<
1262
+ sell.ReturnValue,
1263
+ sell.ErrorType,
1264
+ sell.Parameters<config>,
1265
+ context
1266
+ >
1267
+ | undefined
1268
+ }
1269
+
1270
+ type ReturnType<
1271
+ config extends Config = Config,
1272
+ context = unknown,
1273
+ > = UseMutationResult<
1274
+ sell.ReturnValue,
1275
+ sell.ErrorType,
1276
+ sell.Parameters<config>,
1277
+ context
1278
+ >
1279
+ }
1280
+
1281
+ /**
1282
+ * Hook for selling a specific amount of tokens.
1283
+ *
1284
+ * Note: This is a synchronous hook that waits for the transaction
1285
+ * to be included on a block before returning a response.
1286
+ *
1287
+ * @example
1288
+ * ```tsx
1289
+ * import { Hooks } from 'tempo.ts/wagmi'
1290
+ *
1291
+ * function App() {
1292
+ * const { mutate, isPending } = Hooks.dex.useSellSync()
1293
+ *
1294
+ * return (
1295
+ * <button
1296
+ * onClick={() => mutate({
1297
+ * amountIn: parseUnits('100', 6),
1298
+ * minAmountOut: parseUnits('95', 6),
1299
+ * tokenIn: '0x20c...11',
1300
+ * tokenOut: '0x20c...20',
1301
+ * })}
1302
+ * disabled={isPending}
1303
+ * >
1304
+ * Sell Tokens
1305
+ * </button>
1306
+ * )
1307
+ * }
1308
+ * ```
1309
+ *
1310
+ * @param parameters - Parameters.
1311
+ * @returns Mutation result.
1312
+ */
1313
+ export function useSellSync<
1314
+ config extends Config = ResolvedRegister['config'],
1315
+ context = unknown,
1316
+ >(
1317
+ parameters: useSellSync.Parameters<config, context> = {},
1318
+ ): useSellSync.ReturnType<config, context> {
1319
+ const { mutation } = parameters
1320
+ const config = useConfig(parameters)
1321
+ return useMutation({
1322
+ ...mutation,
1323
+ async mutationFn(variables) {
1324
+ return sellSync(config, variables)
1325
+ },
1326
+ mutationKey: ['sellSync'],
1327
+ })
1328
+ }
1329
+
1330
+ export declare namespace useSellSync {
1331
+ type Parameters<
1332
+ config extends Config = Config,
1333
+ context = unknown,
1334
+ > = ConfigParameter<config> & {
1335
+ mutation?:
1336
+ | UseMutationParameters<
1337
+ sellSync.ReturnValue,
1338
+ sellSync.ErrorType,
1339
+ sellSync.Parameters<config>,
1340
+ context
1341
+ >
1342
+ | undefined
1343
+ }
1344
+
1345
+ type ReturnType<
1346
+ config extends Config = Config,
1347
+ context = unknown,
1348
+ > = UseMutationResult<
1349
+ sellSync.ReturnValue,
1350
+ sellSync.ErrorType,
1351
+ sellSync.Parameters<config>,
1352
+ context
1353
+ >
1354
+ }
1355
+
1356
+ /**
1357
+ * Hook for withdrawing tokens from the DEX to the caller's wallet.
1358
+ *
1359
+ * @example
1360
+ * ```tsx
1361
+ * import { Hooks } from 'tempo.ts/wagmi'
1362
+ *
1363
+ * function App() {
1364
+ * const { mutate, isPending } = Hooks.dex.useWithdraw()
1365
+ *
1366
+ * return (
1367
+ * <button
1368
+ * onClick={() => mutate({
1369
+ * amount: 100n,
1370
+ * token: '0x20c...11',
1371
+ * })}
1372
+ * disabled={isPending}
1373
+ * >
1374
+ * Withdraw
1375
+ * </button>
1376
+ * )
1377
+ * }
1378
+ * ```
1379
+ *
1380
+ * @param parameters - Parameters.
1381
+ * @returns Mutation result.
1382
+ */
1383
+ export function useWithdraw<
1384
+ config extends Config = ResolvedRegister['config'],
1385
+ context = unknown,
1386
+ >(
1387
+ parameters: useWithdraw.Parameters<config, context> = {},
1388
+ ): useWithdraw.ReturnType<config, context> {
1389
+ const { mutation } = parameters
1390
+ const config = useConfig(parameters)
1391
+ return useMutation({
1392
+ ...mutation,
1393
+ async mutationFn(variables) {
1394
+ return withdraw(config, variables)
1395
+ },
1396
+ mutationKey: ['withdraw'],
1397
+ })
1398
+ }
1399
+
1400
+ export declare namespace useWithdraw {
1401
+ type Parameters<
1402
+ config extends Config = Config,
1403
+ context = unknown,
1404
+ > = ConfigParameter<config> & {
1405
+ mutation?:
1406
+ | UseMutationParameters<
1407
+ withdraw.ReturnValue,
1408
+ withdraw.ErrorType,
1409
+ withdraw.Parameters<config>,
1410
+ context
1411
+ >
1412
+ | undefined
1413
+ }
1414
+
1415
+ type ReturnType<
1416
+ config extends Config = Config,
1417
+ context = unknown,
1418
+ > = UseMutationResult<
1419
+ withdraw.ReturnValue,
1420
+ withdraw.ErrorType,
1421
+ withdraw.Parameters<config>,
1422
+ context
1423
+ >
1424
+ }
1425
+
1426
+ /**
1427
+ * Hook for withdrawing tokens from the DEX to the caller's wallet.
1428
+ *
1429
+ * Note: This is a synchronous hook that waits for the transaction
1430
+ * to be included on a block before returning a response.
1431
+ *
1432
+ * @example
1433
+ * ```tsx
1434
+ * import { Hooks } from 'tempo.ts/wagmi'
1435
+ *
1436
+ * function App() {
1437
+ * const { mutate, isPending } = Hooks.dex.useWithdrawSync()
1438
+ *
1439
+ * return (
1440
+ * <button
1441
+ * onClick={() => mutate({
1442
+ * amount: 100n,
1443
+ * token: '0x20c...11',
1444
+ * })}
1445
+ * disabled={isPending}
1446
+ * >
1447
+ * Withdraw
1448
+ * </button>
1449
+ * )
1450
+ * }
1451
+ * ```
1452
+ *
1453
+ * @param parameters - Parameters.
1454
+ * @returns Mutation result.
1455
+ */
1456
+ export function useWithdrawSync<
1457
+ config extends Config = ResolvedRegister['config'],
1458
+ context = unknown,
1459
+ >(
1460
+ parameters: useWithdrawSync.Parameters<config, context> = {},
1461
+ ): useWithdrawSync.ReturnType<config, context> {
1462
+ const { mutation } = parameters
1463
+ const config = useConfig(parameters)
1464
+ return useMutation({
1465
+ ...mutation,
1466
+ async mutationFn(variables) {
1467
+ return withdrawSync(config, variables)
1468
+ },
1469
+ mutationKey: ['withdrawSync'],
1470
+ })
1471
+ }
1472
+
1473
+ export declare namespace useWithdrawSync {
1474
+ type Parameters<
1475
+ config extends Config = Config,
1476
+ context = unknown,
1477
+ > = ConfigParameter<config> & {
1478
+ mutation?:
1479
+ | UseMutationParameters<
1480
+ withdrawSync.ReturnValue,
1481
+ withdrawSync.ErrorType,
1482
+ withdrawSync.Parameters<config>,
1483
+ context
1484
+ >
1485
+ | undefined
1486
+ }
1487
+
1488
+ type ReturnType<
1489
+ config extends Config = Config,
1490
+ context = unknown,
1491
+ > = UseMutationResult<
1492
+ withdrawSync.ReturnValue,
1493
+ withdrawSync.ErrorType,
1494
+ withdrawSync.Parameters<config>,
1495
+ context
1496
+ >
1497
+ }
1498
+
1499
+ /**
1500
+ * Hook for watching flip order placement events on the DEX.
1501
+ *
1502
+ * @example
1503
+ * ```tsx
1504
+ * import { Hooks } from 'tempo.ts/wagmi'
1505
+ *
1506
+ * function App() {
1507
+ * Hooks.dex.useWatchFlipOrderPlaced({
1508
+ * onFlipOrderPlaced(args) {
1509
+ * console.log('Flip order placed:', args)
1510
+ * },
1511
+ * })
1512
+ *
1513
+ * return <div>Watching for flip order placements...</div>
1514
+ * }
1515
+ * ```
1516
+ *
1517
+ * @param parameters - Parameters.
1518
+ */
1519
+ export function useWatchFlipOrderPlaced<
1520
+ config extends Config = ResolvedRegister['config'],
1521
+ >(parameters: useWatchFlipOrderPlaced.Parameters<config> = {}) {
1522
+ const { enabled = true, onFlipOrderPlaced, ...rest } = parameters
1523
+
1524
+ const config = useConfig({ config: parameters.config })
1525
+ const configChainId = useChainId({ config })
1526
+ const chainId = parameters.chainId ?? configChainId
1527
+
1528
+ useEffect(() => {
1529
+ if (!enabled) return
1530
+ if (!onFlipOrderPlaced) return
1531
+ return watchFlipOrderPlaced(config, {
1532
+ ...rest,
1533
+ chainId,
1534
+ onFlipOrderPlaced,
1535
+ })
1536
+ }, [config, enabled, onFlipOrderPlaced, rest, chainId])
1537
+ }
1538
+
1539
+ export declare namespace useWatchFlipOrderPlaced {
1540
+ type Parameters<config extends Config = Config> = UnionCompute<
1541
+ ExactPartial<watchFlipOrderPlaced.Parameters<config>> &
1542
+ ConfigParameter<config> & { enabled?: boolean | undefined }
1543
+ >
1544
+ }
1545
+
1546
+ /**
1547
+ * Hook for watching order cancellation events on the DEX.
1548
+ *
1549
+ * @example
1550
+ * ```tsx
1551
+ * import { Hooks } from 'tempo.ts/wagmi'
1552
+ *
1553
+ * function App() {
1554
+ * Hooks.dex.useWatchOrderCancelled({
1555
+ * onOrderCancelled(args) {
1556
+ * console.log('Order cancelled:', args)
1557
+ * },
1558
+ * })
1559
+ *
1560
+ * return <div>Watching for order cancellations...</div>
1561
+ * }
1562
+ * ```
1563
+ *
1564
+ * @param parameters - Parameters.
1565
+ */
1566
+ export function useWatchOrderCancelled<
1567
+ config extends Config = ResolvedRegister['config'],
1568
+ >(parameters: useWatchOrderCancelled.Parameters<config> = {}) {
1569
+ const { enabled = true, onOrderCancelled, ...rest } = parameters
1570
+
1571
+ const config = useConfig({ config: parameters.config })
1572
+ const configChainId = useChainId({ config })
1573
+ const chainId = parameters.chainId ?? configChainId
1574
+
1575
+ useEffect(() => {
1576
+ if (!enabled) return
1577
+ if (!onOrderCancelled) return
1578
+ return watchOrderCancelled(config, {
1579
+ ...rest,
1580
+ chainId,
1581
+ onOrderCancelled,
1582
+ })
1583
+ }, [config, enabled, onOrderCancelled, rest, chainId])
1584
+ }
1585
+
1586
+ export declare namespace useWatchOrderCancelled {
1587
+ type Parameters<config extends Config = Config> = UnionCompute<
1588
+ ExactPartial<watchOrderCancelled.Parameters<config>> &
1589
+ ConfigParameter<config> & { enabled?: boolean | undefined }
1590
+ >
1591
+ }
1592
+
1593
+ /**
1594
+ * Hook for watching order filled events on the DEX.
1595
+ *
1596
+ * @example
1597
+ * ```tsx
1598
+ * import { Hooks } from 'tempo.ts/wagmi'
1599
+ *
1600
+ * function App() {
1601
+ * Hooks.dex.useWatchOrderFilled({
1602
+ * onOrderFilled(args) {
1603
+ * console.log('Order filled:', args)
1604
+ * },
1605
+ * })
1606
+ *
1607
+ * return <div>Watching for order fills...</div>
1608
+ * }
1609
+ * ```
1610
+ *
1611
+ * @param parameters - Parameters.
1612
+ */
1613
+ export function useWatchOrderFilled<
1614
+ config extends Config = ResolvedRegister['config'],
1615
+ >(parameters: useWatchOrderFilled.Parameters<config> = {}) {
1616
+ const { enabled = true, onOrderFilled, ...rest } = parameters
1617
+
1618
+ const config = useConfig({ config: parameters.config })
1619
+ const configChainId = useChainId({ config })
1620
+ const chainId = parameters.chainId ?? configChainId
1621
+
1622
+ useEffect(() => {
1623
+ if (!enabled) return
1624
+ if (!onOrderFilled) return
1625
+ return watchOrderFilled(config, {
1626
+ ...rest,
1627
+ chainId,
1628
+ onOrderFilled,
1629
+ })
1630
+ }, [config, enabled, onOrderFilled, rest, chainId])
1631
+ }
1632
+
1633
+ export declare namespace useWatchOrderFilled {
1634
+ type Parameters<config extends Config = Config> = UnionCompute<
1635
+ ExactPartial<watchOrderFilled.Parameters<config>> &
1636
+ ConfigParameter<config> & { enabled?: boolean | undefined }
1637
+ >
1638
+ }
1639
+
1640
+ /**
1641
+ * Hook for watching order placement events on the DEX.
1642
+ *
1643
+ * @example
1644
+ * ```tsx
1645
+ * import { Hooks } from 'tempo.ts/wagmi'
1646
+ *
1647
+ * function App() {
1648
+ * Hooks.dex.useWatchOrderPlaced({
1649
+ * onOrderPlaced(args) {
1650
+ * console.log('Order placed:', args)
1651
+ * },
1652
+ * })
1653
+ *
1654
+ * return <div>Watching for order placements...</div>
1655
+ * }
1656
+ * ```
1657
+ *
1658
+ * @param parameters - Parameters.
1659
+ */
1660
+ export function useWatchOrderPlaced<
1661
+ config extends Config = ResolvedRegister['config'],
1662
+ >(parameters: useWatchOrderPlaced.Parameters<config> = {}) {
1663
+ const { enabled = true, onOrderPlaced, ...rest } = parameters
1664
+
1665
+ const config = useConfig({ config: parameters.config })
1666
+ const configChainId = useChainId({ config })
1667
+ const chainId = parameters.chainId ?? configChainId
1668
+
1669
+ useEffect(() => {
1670
+ if (!enabled) return
1671
+ if (!onOrderPlaced) return
1672
+ return watchOrderPlaced(config, {
1673
+ ...rest,
1674
+ chainId,
1675
+ onOrderPlaced,
1676
+ })
1677
+ }, [config, enabled, onOrderPlaced, rest, chainId])
1678
+ }
1679
+
1680
+ export declare namespace useWatchOrderPlaced {
1681
+ type Parameters<config extends Config = Config> = UnionCompute<
1682
+ ExactPartial<watchOrderPlaced.Parameters<config>> &
1683
+ ConfigParameter<config> & { enabled?: boolean | undefined }
1684
+ >
1685
+ }