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,973 @@
1
+ import { useEffect } from 'react';
2
+ import { useChainId, useConfig } from 'wagmi';
3
+ import { useInfiniteQuery, useMutation, useQuery, } from 'wagmi/query';
4
+ import { buy, buySync, cancel, cancelSync, createPair, createPairSync, getBalance, getBuyQuote, getOrder, getOrderbook, getOrders, getPriceLevel, getSellQuote, place, placeFlip, placeFlipSync, placeSync, sell, sellSync, watchFlipOrderPlaced, watchOrderCancelled, watchOrderFilled, watchOrderPlaced, withdraw, withdrawSync, } from '../Actions/dex.js';
5
+ /**
6
+ * Hook for buying a specific amount of tokens.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * import { Hooks } from 'tempo.ts/wagmi'
11
+ *
12
+ * function App() {
13
+ * const { mutate, isPending } = Hooks.dex.useBuy()
14
+ *
15
+ * return (
16
+ * <button
17
+ * onClick={() => mutate({
18
+ * tokenIn: '0x20c...11',
19
+ * tokenOut: '0x20c...20',
20
+ * amountOut: parseUnits('100', 6),
21
+ * maxAmountIn: parseUnits('105', 6),
22
+ * })}
23
+ * disabled={isPending}
24
+ * >
25
+ * Buy Tokens
26
+ * </button>
27
+ * )
28
+ * }
29
+ * ```
30
+ *
31
+ * @param parameters - Parameters.
32
+ * @returns Mutation result.
33
+ */
34
+ export function useBuy(parameters = {}) {
35
+ const { mutation } = parameters;
36
+ const config = useConfig(parameters);
37
+ return useMutation({
38
+ ...mutation,
39
+ async mutationFn(variables) {
40
+ return buy(config, variables);
41
+ },
42
+ mutationKey: ['buy'],
43
+ });
44
+ }
45
+ /**
46
+ * Hook for buying a specific amount of tokens.
47
+ *
48
+ * Note: This is a synchronous hook that waits for the transaction
49
+ * to be included on a block before returning a response.
50
+ *
51
+ * @example
52
+ * ```tsx
53
+ * import { Hooks } from 'tempo.ts/wagmi'
54
+ *
55
+ * function App() {
56
+ * const { mutate, isPending } = Hooks.dex.useBuySync()
57
+ *
58
+ * return (
59
+ * <button
60
+ * onClick={() => mutate({
61
+ * tokenIn: '0x20c...11',
62
+ * tokenOut: '0x20c...20',
63
+ * amountOut: parseUnits('100', 6),
64
+ * maxAmountIn: parseUnits('105', 6),
65
+ * })}
66
+ * disabled={isPending}
67
+ * >
68
+ * Buy Tokens
69
+ * </button>
70
+ * )
71
+ * }
72
+ * ```
73
+ *
74
+ * @param parameters - Parameters.
75
+ * @returns Mutation result.
76
+ */
77
+ export function useBuySync(parameters = {}) {
78
+ const { mutation } = parameters;
79
+ const config = useConfig(parameters);
80
+ return useMutation({
81
+ ...mutation,
82
+ async mutationFn(variables) {
83
+ return buySync(config, variables);
84
+ },
85
+ mutationKey: ['buySync'],
86
+ });
87
+ }
88
+ /**
89
+ * Hook for canceling an order from the orderbook.
90
+ *
91
+ * @example
92
+ * ```tsx
93
+ * import { Hooks } from 'tempo.ts/wagmi'
94
+ *
95
+ * function App() {
96
+ * const { mutate, isPending } = Hooks.dex.useCancel()
97
+ *
98
+ * return (
99
+ * <button
100
+ * onClick={() => mutate({ orderId: 123n })}
101
+ * disabled={isPending}
102
+ * >
103
+ * Cancel Order
104
+ * </button>
105
+ * )
106
+ * }
107
+ * ```
108
+ *
109
+ * @param parameters - Parameters.
110
+ * @returns Mutation result.
111
+ */
112
+ export function useCancel(parameters = {}) {
113
+ const { mutation } = parameters;
114
+ const config = useConfig(parameters);
115
+ return useMutation({
116
+ ...mutation,
117
+ async mutationFn(variables) {
118
+ return cancel(config, variables);
119
+ },
120
+ mutationKey: ['cancel'],
121
+ });
122
+ }
123
+ /**
124
+ * Hook for canceling an order from the orderbook.
125
+ *
126
+ * Note: This is a synchronous hook that waits for the transaction
127
+ * to be included on a block before returning a response.
128
+ *
129
+ * @example
130
+ * ```tsx
131
+ * import { Hooks } from 'tempo.ts/wagmi'
132
+ *
133
+ * function App() {
134
+ * const { mutate, isPending } = Hooks.dex.useCancelSync()
135
+ *
136
+ * return (
137
+ * <button
138
+ * onClick={() => mutate({ orderId: 123n })}
139
+ * disabled={isPending}
140
+ * >
141
+ * Cancel Order
142
+ * </button>
143
+ * )
144
+ * }
145
+ * ```
146
+ *
147
+ * @param parameters - Parameters.
148
+ * @returns Mutation result.
149
+ */
150
+ export function useCancelSync(parameters = {}) {
151
+ const { mutation } = parameters;
152
+ const config = useConfig(parameters);
153
+ return useMutation({
154
+ ...mutation,
155
+ async mutationFn(variables) {
156
+ return cancelSync(config, variables);
157
+ },
158
+ mutationKey: ['cancelSync'],
159
+ });
160
+ }
161
+ /**
162
+ * Hook for creating a new trading pair on the DEX.
163
+ *
164
+ * @example
165
+ * ```tsx
166
+ * import { Hooks } from 'tempo.ts/wagmi'
167
+ *
168
+ * function App() {
169
+ * const { mutate, isPending } = Hooks.dex.useCreatePair()
170
+ *
171
+ * return (
172
+ * <button
173
+ * onClick={() => mutate({ base: '0x20c...11' })}
174
+ * disabled={isPending}
175
+ * >
176
+ * Create Pair
177
+ * </button>
178
+ * )
179
+ * }
180
+ * ```
181
+ *
182
+ * @param parameters - Parameters.
183
+ * @returns Mutation result.
184
+ */
185
+ export function useCreatePair(parameters = {}) {
186
+ const { mutation } = parameters;
187
+ const config = useConfig(parameters);
188
+ return useMutation({
189
+ ...mutation,
190
+ async mutationFn(variables) {
191
+ return createPair(config, variables);
192
+ },
193
+ mutationKey: ['createPair'],
194
+ });
195
+ }
196
+ /**
197
+ * Hook for creating a new trading pair on the DEX.
198
+ *
199
+ * Note: This is a synchronous hook that waits for the transaction
200
+ * to be included on a block before returning a response.
201
+ *
202
+ * @example
203
+ * ```tsx
204
+ * import { Hooks } from 'tempo.ts/wagmi'
205
+ *
206
+ * function App() {
207
+ * const { mutate, isPending } = Hooks.dex.useCreatePairSync()
208
+ *
209
+ * return (
210
+ * <button
211
+ * onClick={() => mutate({ base: '0x20c...11' })}
212
+ * disabled={isPending}
213
+ * >
214
+ * Create Pair
215
+ * </button>
216
+ * )
217
+ * }
218
+ * ```
219
+ *
220
+ * @param parameters - Parameters.
221
+ * @returns Mutation result.
222
+ */
223
+ export function useCreatePairSync(parameters = {}) {
224
+ const { mutation } = parameters;
225
+ const config = useConfig(parameters);
226
+ return useMutation({
227
+ ...mutation,
228
+ async mutationFn(variables) {
229
+ return createPairSync(config, variables);
230
+ },
231
+ mutationKey: ['createPairSync'],
232
+ });
233
+ }
234
+ /**
235
+ * Hook for getting a user's token balance on the DEX.
236
+ *
237
+ * @example
238
+ * ```tsx
239
+ * import { Hooks } from 'tempo.ts/wagmi'
240
+ *
241
+ * function App() {
242
+ * const { data, isLoading } = Hooks.dex.useBalance({
243
+ * account: '0x...',
244
+ * token: '0x20c...11',
245
+ * })
246
+ *
247
+ * if (isLoading) return <div>Loading...</div>
248
+ * return <div>Balance: {data}</div>
249
+ * }
250
+ * ```
251
+ *
252
+ * @param parameters - Parameters.
253
+ * @returns Query result with the user's token balance on the DEX.
254
+ */
255
+ export function useBalance(parameters) {
256
+ const { account, query = {} } = parameters;
257
+ const config = useConfig(parameters);
258
+ const chainId = useChainId({ config });
259
+ const options = getBalance.queryOptions(config, {
260
+ ...parameters,
261
+ chainId: parameters.chainId ?? chainId,
262
+ query: undefined,
263
+ });
264
+ const enabled = Boolean(account && (query.enabled ?? true));
265
+ return useQuery({ ...query, ...options, enabled });
266
+ }
267
+ /**
268
+ * Hook for getting the quote for buying a specific amount of tokens.
269
+ *
270
+ * @example
271
+ * ```tsx
272
+ * import { Hooks } from 'tempo.ts/wagmi'
273
+ *
274
+ * function App() {
275
+ * const { data, isLoading } = Hooks.dex.useBuyQuote({
276
+ * amountOut: parseUnits('100', 6),
277
+ * tokenIn: '0x20c...11',
278
+ * tokenOut: '0x20c...20',
279
+ * })
280
+ *
281
+ * if (isLoading) return <div>Loading...</div>
282
+ * return <div>Required Input: {data}</div>
283
+ * }
284
+ * ```
285
+ *
286
+ * @param parameters - Parameters.
287
+ * @returns Query result with the amount of tokenIn needed.
288
+ */
289
+ export function useBuyQuote(parameters) {
290
+ const { query = {} } = parameters;
291
+ const config = useConfig(parameters);
292
+ const chainId = useChainId({ config });
293
+ const options = getBuyQuote.queryOptions(config, {
294
+ ...parameters,
295
+ chainId: parameters.chainId ?? chainId,
296
+ query: undefined,
297
+ });
298
+ const enabled = Boolean(parameters.tokenIn &&
299
+ parameters.tokenOut &&
300
+ parameters.amountOut &&
301
+ (query.enabled ?? true));
302
+ return useQuery({ ...query, ...options, enabled });
303
+ }
304
+ /**
305
+ * Hook for getting an order's details from the orderbook.
306
+ *
307
+ * @example
308
+ * ```tsx
309
+ * import { Hooks } from 'tempo.ts/wagmi'
310
+ *
311
+ * function App() {
312
+ * const { data, isLoading } = Hooks.dex.useOrder({
313
+ * orderId: 123n,
314
+ * })
315
+ *
316
+ * if (isLoading) return <div>Loading...</div>
317
+ * return <div>Order: {JSON.stringify(data)}</div>
318
+ * }
319
+ * ```
320
+ *
321
+ * @param parameters - Parameters.
322
+ * @returns Query result with the order details.
323
+ */
324
+ export function useOrder(parameters) {
325
+ const { query = {} } = parameters;
326
+ const config = useConfig(parameters);
327
+ const chainId = useChainId({ config });
328
+ const options = getOrder.queryOptions(config, {
329
+ ...parameters,
330
+ chainId: parameters.chainId ?? chainId,
331
+ query: undefined,
332
+ });
333
+ const enabled = Boolean(parameters.orderId !== undefined && (query.enabled ?? true));
334
+ return useQuery({ ...query, ...options, enabled });
335
+ }
336
+ /**
337
+ * Hook for getting paginated orders from the orderbook.
338
+ *
339
+ * @example
340
+ * ```tsx
341
+ * import { Hooks } from 'tempo.ts/wagmi'
342
+ *
343
+ * function App() {
344
+ * const { data, fetchNextPage, hasNextPage, isFetchingNextPage } = Hooks.dex.useGetOrders({
345
+ * limit: 10,
346
+ * filters: {
347
+ * baseToken: '0x20c0...',
348
+ * isBid: true,
349
+ * }
350
+ * })
351
+ *
352
+ * return (
353
+ * <div>
354
+ * {data?.pages.map((page, i) => (
355
+ * <div key={i}>
356
+ * {page.orders.map((order) => (
357
+ * <div key={order.orderId.toString()}>{order.amount.toString()}</div>
358
+ * ))}
359
+ * </div>
360
+ * ))}
361
+ * {hasNextPage && (
362
+ * <button onClick={() => fetchNextPage()} disabled={isFetchingNextPage}>
363
+ * Load More
364
+ * </button>
365
+ * )}
366
+ * </div>
367
+ * )
368
+ * }
369
+ * ```
370
+ *
371
+ * @param parameters - Parameters.
372
+ * @returns Infinite query result with paginated orders.
373
+ */
374
+ export function useGetOrders(parameters = {}) {
375
+ const { query = {}, ...rest } = parameters;
376
+ const config = useConfig(parameters);
377
+ const chainId = useChainId({ config });
378
+ const options = getOrders.infiniteQueryOptions(config, {
379
+ ...rest,
380
+ chainId: parameters.chainId ?? chainId,
381
+ query: undefined,
382
+ });
383
+ return useInfiniteQuery({
384
+ ...query,
385
+ ...options,
386
+ });
387
+ }
388
+ /**
389
+ * Hook for getting orderbook information for a trading pair.
390
+ *
391
+ * @example
392
+ * ```tsx
393
+ * import { Hooks } from 'tempo.ts/wagmi'
394
+ *
395
+ * function App() {
396
+ * const { data, isLoading } = Hooks.dex.useOrderbook({
397
+ * base: '0x20c...11',
398
+ * quote: '0x20c...20',
399
+ * })
400
+ *
401
+ * if (isLoading) return <div>Loading...</div>
402
+ * return <div>Orderbook: {JSON.stringify(data)}</div>
403
+ * }
404
+ * ```
405
+ *
406
+ * @param parameters - Parameters.
407
+ * @returns Query result with the orderbook information.
408
+ */
409
+ export function useOrderbook(parameters) {
410
+ const { query = {} } = parameters;
411
+ const config = useConfig(parameters);
412
+ const chainId = useChainId({ config });
413
+ const options = getOrderbook.queryOptions(config, {
414
+ ...parameters,
415
+ chainId: parameters.chainId ?? chainId,
416
+ query: undefined,
417
+ });
418
+ const enabled = Boolean(parameters.base && parameters.quote && (query.enabled ?? true));
419
+ return useQuery({ ...query, ...options, enabled });
420
+ }
421
+ /**
422
+ * Hook for getting the price level information at a specific tick.
423
+ *
424
+ * @example
425
+ * ```tsx
426
+ * import { Hooks } from 'tempo.ts/wagmi'
427
+ *
428
+ * function App() {
429
+ * const { data, isLoading } = Hooks.dex.usePriceLevel({
430
+ * base: '0x20c...11',
431
+ * tick: Tick.fromPrice('1.001'),
432
+ * isBid: true,
433
+ * })
434
+ *
435
+ * if (isLoading) return <div>Loading...</div>
436
+ * return <div>Price Level: {JSON.stringify(data)}</div>
437
+ * }
438
+ * ```
439
+ *
440
+ * @param parameters - Parameters.
441
+ * @returns Query result with the price level information.
442
+ */
443
+ export function usePriceLevel(parameters) {
444
+ const { query = {} } = parameters;
445
+ const config = useConfig(parameters);
446
+ const chainId = useChainId({ config });
447
+ const options = getPriceLevel.queryOptions(config, {
448
+ ...parameters,
449
+ chainId: parameters.chainId ?? chainId,
450
+ query: undefined,
451
+ });
452
+ const enabled = Boolean(parameters.base &&
453
+ parameters.tick !== undefined &&
454
+ parameters.isBid !== undefined &&
455
+ (query.enabled ?? true));
456
+ return useQuery({ ...query, ...options, enabled });
457
+ }
458
+ /**
459
+ * Hook for getting the quote for selling a specific amount of tokens.
460
+ *
461
+ * @example
462
+ * ```tsx
463
+ * import { Hooks } from 'tempo.ts/wagmi'
464
+ *
465
+ * function App() {
466
+ * const { data, isLoading } = Hooks.dex.useSellQuote({
467
+ * amountIn: parseUnits('100', 6),
468
+ * tokenIn: '0x20c...11',
469
+ * tokenOut: '0x20c...20',
470
+ * })
471
+ *
472
+ * if (isLoading) return <div>Loading...</div>
473
+ * return <div>Expected Output: {data}</div>
474
+ * }
475
+ * ```
476
+ *
477
+ * @param parameters - Parameters.
478
+ * @returns Query result with the amount of tokenOut received.
479
+ */
480
+ export function useSellQuote(parameters) {
481
+ const { query = {} } = parameters;
482
+ const config = useConfig(parameters);
483
+ const chainId = useChainId({ config });
484
+ const options = getSellQuote.queryOptions(config, {
485
+ ...parameters,
486
+ chainId: parameters.chainId ?? chainId,
487
+ query: undefined,
488
+ });
489
+ const enabled = Boolean(parameters.tokenIn &&
490
+ parameters.tokenOut &&
491
+ parameters.amountIn &&
492
+ (query.enabled ?? true));
493
+ return useQuery({ ...query, ...options, enabled });
494
+ }
495
+ /**
496
+ * Hook for placing a limit order on the orderbook.
497
+ *
498
+ * @example
499
+ * ```tsx
500
+ * import { Hooks } from 'tempo.ts/wagmi'
501
+ *
502
+ * function App() {
503
+ * const { mutate, isPending } = Hooks.dex.usePlace()
504
+ *
505
+ * return (
506
+ * <button
507
+ * onClick={() => mutate({
508
+ * amount: parseUnits('100', 6),
509
+ * tick: Tick.fromPrice('0.99'),
510
+ * token: '0x20c...11',
511
+ * type: 'buy',
512
+ * })}
513
+ * disabled={isPending}
514
+ * >
515
+ * Place Order
516
+ * </button>
517
+ * )
518
+ * }
519
+ * ```
520
+ *
521
+ * @param parameters - Parameters.
522
+ * @returns Mutation result.
523
+ */
524
+ export function usePlace(parameters = {}) {
525
+ const { mutation } = parameters;
526
+ const config = useConfig(parameters);
527
+ return useMutation({
528
+ ...mutation,
529
+ async mutationFn(variables) {
530
+ return place(config, variables);
531
+ },
532
+ mutationKey: ['place'],
533
+ });
534
+ }
535
+ /**
536
+ * Hook for placing a flip order that automatically flips when filled.
537
+ *
538
+ * @example
539
+ * ```tsx
540
+ * import { Hooks } from 'tempo.ts/wagmi'
541
+ *
542
+ * function App() {
543
+ * const { mutate, isPending } = Hooks.dex.usePlaceFlip()
544
+ *
545
+ * return (
546
+ * <button
547
+ * onClick={() => mutate({
548
+ * amount: parseUnits('100', 6),
549
+ * flipTick: Tick.fromPrice('1.01'),
550
+ * tick: Tick.fromPrice('0.99'),
551
+ * token: '0x20c...11',
552
+ * type: 'buy',
553
+ * })}
554
+ * disabled={isPending}
555
+ * >
556
+ * Place Flip Order
557
+ * </button>
558
+ * )
559
+ * }
560
+ * ```
561
+ *
562
+ * @param parameters - Parameters.
563
+ * @returns Mutation result.
564
+ */
565
+ export function usePlaceFlip(parameters = {}) {
566
+ const { mutation } = parameters;
567
+ const config = useConfig(parameters);
568
+ return useMutation({
569
+ ...mutation,
570
+ async mutationFn(variables) {
571
+ return placeFlip(config, variables);
572
+ },
573
+ mutationKey: ['placeFlip'],
574
+ });
575
+ }
576
+ /**
577
+ * Hook for placing a flip order that automatically flips when filled.
578
+ *
579
+ * Note: This is a synchronous hook that waits for the transaction
580
+ * to be included on a block before returning a response.
581
+ *
582
+ * @example
583
+ * ```tsx
584
+ * import { Hooks } from 'tempo.ts/wagmi'
585
+ *
586
+ * function App() {
587
+ * const { mutate, isPending } = Hooks.dex.usePlaceFlipSync()
588
+ *
589
+ * return (
590
+ * <button
591
+ * onClick={() => mutate({
592
+ * amount: parseUnits('100', 6),
593
+ * flipTick: Tick.fromPrice('1.01'),
594
+ * tick: Tick.fromPrice('0.99'),
595
+ * token: '0x20c...11',
596
+ * type: 'buy',
597
+ * })}
598
+ * disabled={isPending}
599
+ * >
600
+ * Place Flip Order
601
+ * </button>
602
+ * )
603
+ * }
604
+ * ```
605
+ *
606
+ * @param parameters - Parameters.
607
+ * @returns Mutation result.
608
+ */
609
+ export function usePlaceFlipSync(parameters = {}) {
610
+ const { mutation } = parameters;
611
+ const config = useConfig(parameters);
612
+ return useMutation({
613
+ ...mutation,
614
+ async mutationFn(variables) {
615
+ return placeFlipSync(config, variables);
616
+ },
617
+ mutationKey: ['placeFlipSync'],
618
+ });
619
+ }
620
+ /**
621
+ * Hook for placing a limit order on the orderbook.
622
+ *
623
+ * Note: This is a synchronous hook that waits for the transaction
624
+ * to be included on a block before returning a response.
625
+ *
626
+ * @example
627
+ * ```tsx
628
+ * import { Hooks } from 'tempo.ts/wagmi'
629
+ *
630
+ * function App() {
631
+ * const { mutate, isPending } = Hooks.dex.usePlaceSync()
632
+ *
633
+ * return (
634
+ * <button
635
+ * onClick={() => mutate({
636
+ * amount: parseUnits('100', 6),
637
+ * tick: Tick.fromPrice('0.99'),
638
+ * token: '0x20c...11',
639
+ * type: 'buy',
640
+ * })}
641
+ * disabled={isPending}
642
+ * >
643
+ * Place Order
644
+ * </button>
645
+ * )
646
+ * }
647
+ * ```
648
+ *
649
+ * @param parameters - Parameters.
650
+ * @returns Mutation result.
651
+ */
652
+ export function usePlaceSync(parameters = {}) {
653
+ const { mutation } = parameters;
654
+ const config = useConfig(parameters);
655
+ return useMutation({
656
+ ...mutation,
657
+ async mutationFn(variables) {
658
+ return placeSync(config, variables);
659
+ },
660
+ mutationKey: ['placeSync'],
661
+ });
662
+ }
663
+ /**
664
+ * Hook for selling a specific amount of tokens.
665
+ *
666
+ * @example
667
+ * ```tsx
668
+ * import { Hooks } from 'tempo.ts/wagmi'
669
+ *
670
+ * function App() {
671
+ * const { mutate, isPending } = Hooks.dex.useSell()
672
+ *
673
+ * return (
674
+ * <button
675
+ * onClick={() => mutate({
676
+ * amountIn: parseUnits('100', 6),
677
+ * minAmountOut: parseUnits('95', 6),
678
+ * tokenIn: '0x20c...11',
679
+ * tokenOut: '0x20c...20',
680
+ * })}
681
+ * disabled={isPending}
682
+ * >
683
+ * Sell Tokens
684
+ * </button>
685
+ * )
686
+ * }
687
+ * ```
688
+ *
689
+ * @param parameters - Parameters.
690
+ * @returns Mutation result.
691
+ */
692
+ export function useSell(parameters = {}) {
693
+ const { mutation } = parameters;
694
+ const config = useConfig(parameters);
695
+ return useMutation({
696
+ ...mutation,
697
+ async mutationFn(variables) {
698
+ return sell(config, variables);
699
+ },
700
+ mutationKey: ['sell'],
701
+ });
702
+ }
703
+ /**
704
+ * Hook for selling a specific amount of tokens.
705
+ *
706
+ * Note: This is a synchronous hook that waits for the transaction
707
+ * to be included on a block before returning a response.
708
+ *
709
+ * @example
710
+ * ```tsx
711
+ * import { Hooks } from 'tempo.ts/wagmi'
712
+ *
713
+ * function App() {
714
+ * const { mutate, isPending } = Hooks.dex.useSellSync()
715
+ *
716
+ * return (
717
+ * <button
718
+ * onClick={() => mutate({
719
+ * amountIn: parseUnits('100', 6),
720
+ * minAmountOut: parseUnits('95', 6),
721
+ * tokenIn: '0x20c...11',
722
+ * tokenOut: '0x20c...20',
723
+ * })}
724
+ * disabled={isPending}
725
+ * >
726
+ * Sell Tokens
727
+ * </button>
728
+ * )
729
+ * }
730
+ * ```
731
+ *
732
+ * @param parameters - Parameters.
733
+ * @returns Mutation result.
734
+ */
735
+ export function useSellSync(parameters = {}) {
736
+ const { mutation } = parameters;
737
+ const config = useConfig(parameters);
738
+ return useMutation({
739
+ ...mutation,
740
+ async mutationFn(variables) {
741
+ return sellSync(config, variables);
742
+ },
743
+ mutationKey: ['sellSync'],
744
+ });
745
+ }
746
+ /**
747
+ * Hook for withdrawing tokens from the DEX to the caller's wallet.
748
+ *
749
+ * @example
750
+ * ```tsx
751
+ * import { Hooks } from 'tempo.ts/wagmi'
752
+ *
753
+ * function App() {
754
+ * const { mutate, isPending } = Hooks.dex.useWithdraw()
755
+ *
756
+ * return (
757
+ * <button
758
+ * onClick={() => mutate({
759
+ * amount: 100n,
760
+ * token: '0x20c...11',
761
+ * })}
762
+ * disabled={isPending}
763
+ * >
764
+ * Withdraw
765
+ * </button>
766
+ * )
767
+ * }
768
+ * ```
769
+ *
770
+ * @param parameters - Parameters.
771
+ * @returns Mutation result.
772
+ */
773
+ export function useWithdraw(parameters = {}) {
774
+ const { mutation } = parameters;
775
+ const config = useConfig(parameters);
776
+ return useMutation({
777
+ ...mutation,
778
+ async mutationFn(variables) {
779
+ return withdraw(config, variables);
780
+ },
781
+ mutationKey: ['withdraw'],
782
+ });
783
+ }
784
+ /**
785
+ * Hook for withdrawing tokens from the DEX to the caller's wallet.
786
+ *
787
+ * Note: This is a synchronous hook that waits for the transaction
788
+ * to be included on a block before returning a response.
789
+ *
790
+ * @example
791
+ * ```tsx
792
+ * import { Hooks } from 'tempo.ts/wagmi'
793
+ *
794
+ * function App() {
795
+ * const { mutate, isPending } = Hooks.dex.useWithdrawSync()
796
+ *
797
+ * return (
798
+ * <button
799
+ * onClick={() => mutate({
800
+ * amount: 100n,
801
+ * token: '0x20c...11',
802
+ * })}
803
+ * disabled={isPending}
804
+ * >
805
+ * Withdraw
806
+ * </button>
807
+ * )
808
+ * }
809
+ * ```
810
+ *
811
+ * @param parameters - Parameters.
812
+ * @returns Mutation result.
813
+ */
814
+ export function useWithdrawSync(parameters = {}) {
815
+ const { mutation } = parameters;
816
+ const config = useConfig(parameters);
817
+ return useMutation({
818
+ ...mutation,
819
+ async mutationFn(variables) {
820
+ return withdrawSync(config, variables);
821
+ },
822
+ mutationKey: ['withdrawSync'],
823
+ });
824
+ }
825
+ /**
826
+ * Hook for watching flip order placement events on the DEX.
827
+ *
828
+ * @example
829
+ * ```tsx
830
+ * import { Hooks } from 'tempo.ts/wagmi'
831
+ *
832
+ * function App() {
833
+ * Hooks.dex.useWatchFlipOrderPlaced({
834
+ * onFlipOrderPlaced(args) {
835
+ * console.log('Flip order placed:', args)
836
+ * },
837
+ * })
838
+ *
839
+ * return <div>Watching for flip order placements...</div>
840
+ * }
841
+ * ```
842
+ *
843
+ * @param parameters - Parameters.
844
+ */
845
+ export function useWatchFlipOrderPlaced(parameters = {}) {
846
+ const { enabled = true, onFlipOrderPlaced, ...rest } = parameters;
847
+ const config = useConfig({ config: parameters.config });
848
+ const configChainId = useChainId({ config });
849
+ const chainId = parameters.chainId ?? configChainId;
850
+ useEffect(() => {
851
+ if (!enabled)
852
+ return;
853
+ if (!onFlipOrderPlaced)
854
+ return;
855
+ return watchFlipOrderPlaced(config, {
856
+ ...rest,
857
+ chainId,
858
+ onFlipOrderPlaced,
859
+ });
860
+ }, [config, enabled, onFlipOrderPlaced, rest, chainId]);
861
+ }
862
+ /**
863
+ * Hook for watching order cancellation events on the DEX.
864
+ *
865
+ * @example
866
+ * ```tsx
867
+ * import { Hooks } from 'tempo.ts/wagmi'
868
+ *
869
+ * function App() {
870
+ * Hooks.dex.useWatchOrderCancelled({
871
+ * onOrderCancelled(args) {
872
+ * console.log('Order cancelled:', args)
873
+ * },
874
+ * })
875
+ *
876
+ * return <div>Watching for order cancellations...</div>
877
+ * }
878
+ * ```
879
+ *
880
+ * @param parameters - Parameters.
881
+ */
882
+ export function useWatchOrderCancelled(parameters = {}) {
883
+ const { enabled = true, onOrderCancelled, ...rest } = parameters;
884
+ const config = useConfig({ config: parameters.config });
885
+ const configChainId = useChainId({ config });
886
+ const chainId = parameters.chainId ?? configChainId;
887
+ useEffect(() => {
888
+ if (!enabled)
889
+ return;
890
+ if (!onOrderCancelled)
891
+ return;
892
+ return watchOrderCancelled(config, {
893
+ ...rest,
894
+ chainId,
895
+ onOrderCancelled,
896
+ });
897
+ }, [config, enabled, onOrderCancelled, rest, chainId]);
898
+ }
899
+ /**
900
+ * Hook for watching order filled events on the DEX.
901
+ *
902
+ * @example
903
+ * ```tsx
904
+ * import { Hooks } from 'tempo.ts/wagmi'
905
+ *
906
+ * function App() {
907
+ * Hooks.dex.useWatchOrderFilled({
908
+ * onOrderFilled(args) {
909
+ * console.log('Order filled:', args)
910
+ * },
911
+ * })
912
+ *
913
+ * return <div>Watching for order fills...</div>
914
+ * }
915
+ * ```
916
+ *
917
+ * @param parameters - Parameters.
918
+ */
919
+ export function useWatchOrderFilled(parameters = {}) {
920
+ const { enabled = true, onOrderFilled, ...rest } = parameters;
921
+ const config = useConfig({ config: parameters.config });
922
+ const configChainId = useChainId({ config });
923
+ const chainId = parameters.chainId ?? configChainId;
924
+ useEffect(() => {
925
+ if (!enabled)
926
+ return;
927
+ if (!onOrderFilled)
928
+ return;
929
+ return watchOrderFilled(config, {
930
+ ...rest,
931
+ chainId,
932
+ onOrderFilled,
933
+ });
934
+ }, [config, enabled, onOrderFilled, rest, chainId]);
935
+ }
936
+ /**
937
+ * Hook for watching order placement events on the DEX.
938
+ *
939
+ * @example
940
+ * ```tsx
941
+ * import { Hooks } from 'tempo.ts/wagmi'
942
+ *
943
+ * function App() {
944
+ * Hooks.dex.useWatchOrderPlaced({
945
+ * onOrderPlaced(args) {
946
+ * console.log('Order placed:', args)
947
+ * },
948
+ * })
949
+ *
950
+ * return <div>Watching for order placements...</div>
951
+ * }
952
+ * ```
953
+ *
954
+ * @param parameters - Parameters.
955
+ */
956
+ export function useWatchOrderPlaced(parameters = {}) {
957
+ const { enabled = true, onOrderPlaced, ...rest } = parameters;
958
+ const config = useConfig({ config: parameters.config });
959
+ const configChainId = useChainId({ config });
960
+ const chainId = parameters.chainId ?? configChainId;
961
+ useEffect(() => {
962
+ if (!enabled)
963
+ return;
964
+ if (!onOrderPlaced)
965
+ return;
966
+ return watchOrderPlaced(config, {
967
+ ...rest,
968
+ chainId,
969
+ onOrderPlaced,
970
+ });
971
+ }, [config, enabled, onOrderPlaced, rest, chainId]);
972
+ }
973
+ //# sourceMappingURL=dex.js.map