tempo.ts 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) 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 +18 -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 +80 -118
  58. package/dist/viem/Actions/amm.d.ts.map +1 -1
  59. package/dist/viem/Actions/amm.js +47 -116
  60. package/dist/viem/Actions/amm.js.map +1 -1
  61. package/dist/viem/Actions/dex.d.ts +889 -633
  62. package/dist/viem/Actions/dex.d.ts.map +1 -1
  63. package/dist/viem/Actions/dex.js +99 -0
  64. package/dist/viem/Actions/dex.js.map +1 -1
  65. package/dist/viem/Actions/fee.d.ts +3 -17
  66. package/dist/viem/Actions/fee.d.ts.map +1 -1
  67. package/dist/viem/Actions/fee.js.map +1 -1
  68. package/dist/viem/Actions/index.d.ts +1 -0
  69. package/dist/viem/Actions/index.d.ts.map +1 -1
  70. package/dist/viem/Actions/index.js +1 -0
  71. package/dist/viem/Actions/index.js.map +1 -1
  72. package/dist/viem/Actions/reward.d.ts +3236 -0
  73. package/dist/viem/Actions/reward.d.ts.map +1 -0
  74. package/dist/viem/Actions/reward.js +725 -0
  75. package/dist/viem/Actions/reward.js.map +1 -0
  76. package/dist/viem/Actions/token.d.ts +4295 -2646
  77. package/dist/viem/Actions/token.d.ts.map +1 -1
  78. package/dist/viem/Actions/token.js +214 -335
  79. package/dist/viem/Actions/token.js.map +1 -1
  80. package/dist/viem/Addresses.d.ts +1 -2
  81. package/dist/viem/Addresses.d.ts.map +1 -1
  82. package/dist/viem/Addresses.js +1 -2
  83. package/dist/viem/Addresses.js.map +1 -1
  84. package/dist/viem/Chain.d.ts +38 -12
  85. package/dist/viem/Chain.d.ts.map +1 -1
  86. package/dist/viem/Chain.js +27 -18
  87. package/dist/viem/Chain.js.map +1 -1
  88. package/dist/viem/Decorator.d.ts +959 -405
  89. package/dist/viem/Decorator.d.ts.map +1 -1
  90. package/dist/viem/Decorator.js +13 -5
  91. package/dist/viem/Decorator.js.map +1 -1
  92. package/dist/viem/Formatters.d.ts +8 -1
  93. package/dist/viem/Formatters.d.ts.map +1 -1
  94. package/dist/viem/Formatters.js +17 -0
  95. package/dist/viem/Formatters.js.map +1 -1
  96. package/dist/viem/P256.d.ts +2 -0
  97. package/dist/viem/P256.d.ts.map +1 -0
  98. package/dist/viem/P256.js +2 -0
  99. package/dist/viem/P256.js.map +1 -0
  100. package/dist/viem/Secp256k1.d.ts +2 -0
  101. package/dist/viem/Secp256k1.d.ts.map +1 -0
  102. package/dist/viem/Secp256k1.js +2 -0
  103. package/dist/viem/Secp256k1.js.map +1 -0
  104. package/dist/viem/TokenIds.d.ts +1 -2
  105. package/dist/viem/TokenIds.d.ts.map +1 -1
  106. package/dist/viem/TokenIds.js +1 -2
  107. package/dist/viem/TokenIds.js.map +1 -1
  108. package/dist/viem/Transaction.d.ts +1 -1
  109. package/dist/viem/Transaction.d.ts.map +1 -1
  110. package/dist/viem/Transaction.js +46 -5
  111. package/dist/viem/Transaction.js.map +1 -1
  112. package/dist/viem/WebAuthnP256.d.ts +79 -0
  113. package/dist/viem/WebAuthnP256.d.ts.map +1 -0
  114. package/dist/viem/WebAuthnP256.js +95 -0
  115. package/dist/viem/WebAuthnP256.js.map +1 -0
  116. package/dist/viem/WebCryptoP256.d.ts +2 -0
  117. package/dist/viem/WebCryptoP256.d.ts.map +1 -0
  118. package/dist/viem/WebCryptoP256.js +2 -0
  119. package/dist/viem/WebCryptoP256.js.map +1 -0
  120. package/dist/viem/index.d.ts +6 -3
  121. package/dist/viem/index.d.ts.map +1 -1
  122. package/dist/viem/index.js +6 -3
  123. package/dist/viem/index.js.map +1 -1
  124. package/dist/viem/internal/account.d.ts +24 -0
  125. package/dist/viem/internal/account.d.ts.map +1 -0
  126. package/dist/viem/internal/account.js +68 -0
  127. package/dist/viem/internal/account.js.map +1 -0
  128. package/dist/viem/internal/types.d.ts +10 -0
  129. package/dist/viem/internal/types.d.ts.map +1 -1
  130. package/dist/wagmi/Actions/amm.d.ts +428 -0
  131. package/dist/wagmi/Actions/amm.d.ts.map +1 -0
  132. package/dist/wagmi/Actions/amm.js +472 -0
  133. package/dist/wagmi/Actions/amm.js.map +1 -0
  134. package/dist/wagmi/Actions/dex.d.ts +908 -0
  135. package/dist/wagmi/Actions/dex.d.ts.map +1 -0
  136. package/dist/wagmi/Actions/dex.js +1023 -0
  137. package/dist/wagmi/Actions/dex.js.map +1 -0
  138. package/dist/wagmi/Actions/fee.d.ts +111 -0
  139. package/dist/wagmi/Actions/fee.d.ts.map +1 -0
  140. package/dist/wagmi/Actions/fee.js +126 -0
  141. package/dist/wagmi/Actions/fee.js.map +1 -0
  142. package/dist/wagmi/Actions/index.d.ts +6 -0
  143. package/dist/wagmi/Actions/index.d.ts.map +1 -0
  144. package/dist/wagmi/Actions/index.js +6 -0
  145. package/dist/wagmi/Actions/index.js.map +1 -0
  146. package/dist/wagmi/Actions/reward.d.ts +348 -0
  147. package/dist/wagmi/Actions/reward.d.ts.map +1 -0
  148. package/dist/wagmi/Actions/reward.js +388 -0
  149. package/dist/wagmi/Actions/reward.js.map +1 -0
  150. package/dist/wagmi/Actions/token.d.ts +1546 -0
  151. package/dist/wagmi/Actions/token.d.ts.map +1 -0
  152. package/dist/wagmi/Actions/token.js +1712 -0
  153. package/dist/wagmi/Actions/token.js.map +1 -0
  154. package/dist/wagmi/Connector.d.ts +73 -0
  155. package/dist/wagmi/Connector.d.ts.map +1 -0
  156. package/dist/wagmi/Connector.js +249 -0
  157. package/dist/wagmi/Connector.js.map +1 -0
  158. package/dist/wagmi/Hooks/amm.d.ts +421 -0
  159. package/dist/wagmi/Hooks/amm.d.ts.map +1 -0
  160. package/dist/wagmi/Hooks/amm.js +504 -0
  161. package/dist/wagmi/Hooks/amm.js.map +1 -0
  162. package/dist/wagmi/Hooks/dex.d.ts +816 -0
  163. package/dist/wagmi/Hooks/dex.d.ts.map +1 -0
  164. package/dist/wagmi/Hooks/dex.js +973 -0
  165. package/dist/wagmi/Hooks/dex.js.map +1 -0
  166. package/dist/wagmi/Hooks/fee.d.ts +97 -0
  167. package/dist/wagmi/Hooks/fee.d.ts.map +1 -0
  168. package/dist/wagmi/Hooks/fee.js +109 -0
  169. package/dist/wagmi/Hooks/fee.js.map +1 -0
  170. package/dist/wagmi/Hooks/index.d.ts +6 -0
  171. package/dist/wagmi/Hooks/index.d.ts.map +1 -0
  172. package/dist/wagmi/Hooks/index.js +6 -0
  173. package/dist/wagmi/Hooks/index.js.map +1 -0
  174. package/dist/wagmi/Hooks/reward.d.ts +307 -0
  175. package/dist/wagmi/Hooks/reward.d.ts.map +1 -0
  176. package/dist/wagmi/Hooks/reward.js +349 -0
  177. package/dist/wagmi/Hooks/reward.js.map +1 -0
  178. package/dist/wagmi/Hooks/token.d.ts +1388 -0
  179. package/dist/wagmi/Hooks/token.d.ts.map +1 -0
  180. package/dist/wagmi/Hooks/token.js +1657 -0
  181. package/dist/wagmi/Hooks/token.js.map +1 -0
  182. package/dist/wagmi/index.d.ts +4 -0
  183. package/dist/wagmi/index.d.ts.map +1 -0
  184. package/dist/wagmi/index.js +4 -0
  185. package/dist/wagmi/index.js.map +1 -0
  186. package/package.json +54 -10
  187. package/src/chains.ts +19 -9
  188. package/src/ox/Order.test.ts +78 -0
  189. package/src/ox/Order.ts +125 -0
  190. package/src/ox/OrdersFilters.test.ts +182 -0
  191. package/src/ox/OrdersFilters.ts +125 -0
  192. package/src/ox/Pagination.test.ts +162 -0
  193. package/src/ox/Pagination.ts +164 -0
  194. package/src/ox/PoolId.test.ts +33 -0
  195. package/src/ox/PoolId.ts +27 -0
  196. package/src/ox/RpcSchema.ts +35 -0
  197. package/src/ox/SignatureEnvelope.ts +3 -1
  198. package/src/{viem → ox}/Tick.test.ts +1 -1
  199. package/src/{viem → ox}/Tick.ts +5 -0
  200. package/src/ox/Transaction.test.ts +1 -1
  201. package/src/ox/Transaction.ts +2 -1
  202. package/src/ox/TransactionEnvelopeAA.test.ts +239 -96
  203. package/src/ox/TransactionEnvelopeAA.ts +9 -7
  204. package/src/ox/TransactionRequest.ts +4 -0
  205. package/src/ox/index.ts +6 -0
  206. package/src/prool/Instance.ts +51 -37
  207. package/src/prool/internal/chain.json +104 -52
  208. package/src/tsconfig.json +9 -0
  209. package/src/viem/Abis.ts +972 -710
  210. package/src/viem/Account.ts +279 -0
  211. package/src/viem/Actions/__snapshots__/dex.test.ts.snap +850 -0
  212. package/src/viem/Actions/amm.test.ts +98 -169
  213. package/src/viem/Actions/amm.ts +68 -155
  214. package/src/viem/Actions/dex.test.ts +563 -484
  215. package/src/viem/Actions/dex.ts +173 -0
  216. package/src/viem/Actions/fee.test.ts +23 -34
  217. package/src/viem/Actions/fee.ts +7 -0
  218. package/src/viem/Actions/index.ts +1 -0
  219. package/src/viem/Actions/policy.test.ts +19 -33
  220. package/src/viem/Actions/reward.test.ts +457 -0
  221. package/src/viem/Actions/reward.ts +999 -0
  222. package/src/viem/Actions/token.test.ts +453 -287
  223. package/src/viem/Actions/token.ts +452 -540
  224. package/src/viem/Addresses.ts +1 -2
  225. package/src/viem/Chain.ts +70 -20
  226. package/src/viem/Decorator.test.ts +2 -1
  227. package/src/viem/Decorator.ts +996 -421
  228. package/src/viem/Formatters.ts +31 -5
  229. package/src/viem/P256.ts +1 -0
  230. package/src/viem/Secp256k1.ts +1 -0
  231. package/src/viem/TokenIds.ts +1 -2
  232. package/src/viem/Transaction.ts +53 -7
  233. package/src/viem/WebAuthnP256.ts +140 -0
  234. package/src/viem/WebCryptoP256.ts +1 -0
  235. package/src/viem/e2e.test.ts +1126 -297
  236. package/src/viem/index.ts +6 -3
  237. package/src/viem/internal/account.ts +107 -0
  238. package/src/viem/internal/types.ts +9 -0
  239. package/src/wagmi/Actions/__snapshots__/dex.test.ts.snap +310 -0
  240. package/src/wagmi/Actions/amm.test.ts +198 -0
  241. package/src/wagmi/Actions/amm.ts +691 -0
  242. package/src/wagmi/Actions/dex.test.ts +1507 -0
  243. package/src/wagmi/Actions/dex.ts +1640 -0
  244. package/src/wagmi/Actions/fee.test.ts +63 -0
  245. package/src/wagmi/Actions/fee.ts +208 -0
  246. package/src/wagmi/Actions/index.ts +5 -0
  247. package/src/wagmi/Actions/reward.test.ts +210 -0
  248. package/src/wagmi/Actions/reward.ts +632 -0
  249. package/src/wagmi/Actions/token.test.ts +1308 -0
  250. package/src/wagmi/Actions/token.ts +2613 -0
  251. package/src/wagmi/Connector.test.ts +53 -0
  252. package/src/wagmi/Connector.ts +367 -0
  253. package/src/wagmi/Hooks/__snapshots__/dex.test.ts.snap +457 -0
  254. package/src/wagmi/Hooks/amm.test.ts +424 -0
  255. package/src/wagmi/Hooks/amm.ts +806 -0
  256. package/src/wagmi/Hooks/dex.test.ts +1017 -0
  257. package/src/wagmi/Hooks/dex.ts +1685 -0
  258. package/src/wagmi/Hooks/fee.test.ts +166 -0
  259. package/src/wagmi/Hooks/fee.ts +206 -0
  260. package/src/wagmi/Hooks/index.ts +5 -0
  261. package/src/wagmi/Hooks/reward.test.ts +219 -0
  262. package/src/wagmi/Hooks/reward.ts +672 -0
  263. package/src/wagmi/Hooks/token.test.ts +1670 -0
  264. package/src/wagmi/Hooks/token.ts +2906 -0
  265. package/src/wagmi/index.ts +3 -0
  266. package/src/wagmi/internal/types.ts +16 -0
  267. package/dist/viem/Client.d.ts +0 -27
  268. package/dist/viem/Client.d.ts.map +0 -1
  269. package/dist/viem/Client.js +0 -28
  270. package/dist/viem/Client.js.map +0 -1
  271. package/dist/viem/Tick.d.ts.map +0 -1
  272. package/dist/viem/Tick.js.map +0 -1
  273. package/src/viem/Client.bench-d.ts +0 -8
  274. package/src/viem/Client.test.ts +0 -178
  275. package/src/viem/Client.ts +0 -91
  276. /package/dist/{viem → ox}/Tick.js +0 -0
@@ -0,0 +1,806 @@
1
+ import type { DefaultError } 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 UseMutationParameters,
9
+ type UseQueryReturnType,
10
+ useMutation,
11
+ useQuery,
12
+ } from 'wagmi/query'
13
+
14
+ import type { ExactPartial, UnionCompute } from '../../internal/types.js'
15
+ import * as Actions from '../Actions/amm.js'
16
+
17
+ /**
18
+ * Hook for getting the reserves for a liquidity pool.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * import { Hooks } from 'tempo.ts/wagmi'
23
+ *
24
+ * function App() {
25
+ * const { data, isLoading } = Hooks.amm.usePool({
26
+ * userToken: '0x...',
27
+ * validatorToken: '0x...',
28
+ * })
29
+ *
30
+ * if (isLoading) return <div>Loading...</div>
31
+ * return (
32
+ * <div>
33
+ * User Token Reserve: {data?.reserveUserToken.toString()}
34
+ * Validator Token Reserve: {data?.reserveValidatorToken.toString()}
35
+ * </div>
36
+ * )
37
+ * }
38
+ * ```
39
+ *
40
+ * @param parameters - Parameters.
41
+ * @returns Query result with the pool reserves.
42
+ */
43
+ export function usePool<
44
+ config extends Config = ResolvedRegister['config'],
45
+ selectData = Actions.getPool.ReturnValue,
46
+ >(parameters: usePool.Parameters<config, selectData>) {
47
+ const { userToken, validatorToken, query = {} } = parameters
48
+
49
+ const config = useConfig(parameters)
50
+ const chainId = useChainId({ config })
51
+
52
+ const options = Actions.getPool.queryOptions(config, {
53
+ ...parameters,
54
+ chainId: parameters.chainId ?? chainId,
55
+ query: undefined,
56
+ } as never)
57
+ const enabled = Boolean(
58
+ userToken !== undefined &&
59
+ validatorToken !== undefined &&
60
+ (query.enabled ?? true),
61
+ )
62
+
63
+ return useQuery({ ...query, ...options, enabled })
64
+ }
65
+
66
+ export declare namespace usePool {
67
+ export type Parameters<
68
+ config extends Config = ResolvedRegister['config'],
69
+ selectData = Actions.getPool.ReturnValue,
70
+ > = ConfigParameter<config> &
71
+ QueryParameter<
72
+ Actions.getPool.ReturnValue,
73
+ DefaultError,
74
+ selectData,
75
+ Actions.getPool.QueryKey<config>
76
+ > &
77
+ ExactPartial<
78
+ Omit<Actions.getPool.queryOptions.Parameters<config, selectData>, 'query'>
79
+ >
80
+
81
+ export type ReturnValue<selectData = Actions.getPool.ReturnValue> =
82
+ UseQueryReturnType<selectData, Error>
83
+ }
84
+
85
+ /**
86
+ * Hook for getting the LP token balance for an account in a specific pool.
87
+ *
88
+ * @example
89
+ * ```tsx
90
+ * import { Hooks } from 'tempo.ts/wagmi'
91
+ *
92
+ * function App() {
93
+ * const { data: poolId } = Hooks.amm.usePoolId({
94
+ * userToken: '0x...',
95
+ * validatorToken: '0x...',
96
+ * })
97
+ *
98
+ * const { data, isLoading } = Hooks.amm.useLiquidityBalance({
99
+ * poolId,
100
+ * address: '0x20c...0055',
101
+ * })
102
+ *
103
+ * if (isLoading) return <div>Loading...</div>
104
+ * return <div>LP Balance: {data?.toString()}</div>
105
+ * }
106
+ * ```
107
+ *
108
+ * @param parameters - Parameters.
109
+ * @returns Query result with the LP token balance.
110
+ */
111
+ export function useLiquidityBalance<
112
+ config extends Config = ResolvedRegister['config'],
113
+ selectData = Actions.getLiquidityBalance.ReturnValue,
114
+ >(parameters: useLiquidityBalance.Parameters<config, selectData> = {}) {
115
+ const { address, poolId, userToken, validatorToken, query = {} } = parameters
116
+
117
+ const config = useConfig(parameters)
118
+ const chainId = useChainId({ config })
119
+
120
+ const options = Actions.getLiquidityBalance.queryOptions(config, {
121
+ ...parameters,
122
+ chainId: parameters.chainId ?? chainId,
123
+ query: undefined,
124
+ } as never)
125
+ const enabled = Boolean(
126
+ address &&
127
+ (poolId || (userToken !== undefined && validatorToken !== undefined)) &&
128
+ (query.enabled ?? true),
129
+ )
130
+
131
+ return useQuery({ ...query, ...options, enabled })
132
+ }
133
+
134
+ export declare namespace useLiquidityBalance {
135
+ export type Parameters<
136
+ config extends Config = ResolvedRegister['config'],
137
+ selectData = Actions.getLiquidityBalance.ReturnValue,
138
+ > = ConfigParameter<config> &
139
+ QueryParameter<
140
+ Actions.getLiquidityBalance.ReturnValue,
141
+ DefaultError,
142
+ selectData,
143
+ Actions.getLiquidityBalance.QueryKey<config>
144
+ > &
145
+ ExactPartial<
146
+ Omit<
147
+ Actions.getLiquidityBalance.queryOptions.Parameters<config, selectData>,
148
+ 'query'
149
+ >
150
+ >
151
+
152
+ export type ReturnValue<
153
+ selectData = Actions.getLiquidityBalance.ReturnValue,
154
+ > = UseQueryReturnType<selectData, Error>
155
+ }
156
+
157
+ /**
158
+ * Hook for performing a rebalance swap from validator token to user token.
159
+ *
160
+ * @example
161
+ * ```tsx
162
+ * import { Hooks } from 'tempo.ts/wagmi'
163
+ *
164
+ * function App() {
165
+ * const { mutate, isPending } = Hooks.amm.useRebalanceSwap()
166
+ *
167
+ * return (
168
+ * <button
169
+ * onClick={() =>
170
+ * mutate({
171
+ * userToken: '0x...',
172
+ * validatorToken: '0x...',
173
+ * amountOut: 100n,
174
+ * to: '0x...',
175
+ * })
176
+ * }
177
+ * disabled={isPending}
178
+ * >
179
+ * Rebalance Swap
180
+ * </button>
181
+ * )
182
+ * }
183
+ * ```
184
+ *
185
+ * @param parameters - Parameters.
186
+ * @returns Mutation result.
187
+ */
188
+ export function useRebalanceSwap<
189
+ config extends Config = ResolvedRegister['config'],
190
+ context = unknown,
191
+ >(
192
+ parameters: useRebalanceSwap.Parameters<config, context> = {},
193
+ ): useRebalanceSwap.ReturnType<config, context> {
194
+ const { mutation } = parameters
195
+ const config = useConfig(parameters)
196
+ return useMutation({
197
+ ...mutation,
198
+ async mutationFn(variables) {
199
+ return Actions.rebalanceSwap(config, variables)
200
+ },
201
+ mutationKey: ['rebalanceSwap'],
202
+ })
203
+ }
204
+
205
+ export declare namespace useRebalanceSwap {
206
+ type Parameters<
207
+ config extends Config = Config,
208
+ context = unknown,
209
+ > = ConfigParameter<config> & {
210
+ mutation?:
211
+ | UseMutationParameters<
212
+ Actions.rebalanceSwap.ReturnValue,
213
+ DefaultError,
214
+ Actions.rebalanceSwap.Parameters<config>,
215
+ context
216
+ >
217
+ | undefined
218
+ }
219
+
220
+ type ReturnType<
221
+ config extends Config = Config,
222
+ context = unknown,
223
+ > = UseMutationResult<
224
+ Actions.rebalanceSwap.ReturnValue,
225
+ DefaultError,
226
+ Actions.rebalanceSwap.Parameters<config>,
227
+ context
228
+ >
229
+ }
230
+
231
+ /**
232
+ * Hook for performing a rebalance swap from validator token to user token.
233
+ *
234
+ * Note: This is a synchronous hook that waits for the transaction
235
+ * to be included on a block before returning a response.
236
+ *
237
+ * @example
238
+ * ```tsx
239
+ * import { Hooks } from 'tempo.ts/wagmi'
240
+ *
241
+ * function App() {
242
+ * const { mutate, isPending } = Hooks.amm.useRebalanceSwapSync()
243
+ *
244
+ * return (
245
+ * <button
246
+ * onClick={() =>
247
+ * mutate({
248
+ * userToken: '0x...',
249
+ * validatorToken: '0x...',
250
+ * amountOut: 100n,
251
+ * to: '0x...',
252
+ * })
253
+ * }
254
+ * disabled={isPending}
255
+ * >
256
+ * Rebalance Swap
257
+ * </button>
258
+ * )
259
+ * }
260
+ * ```
261
+ *
262
+ * @param parameters - Parameters.
263
+ * @returns Mutation result.
264
+ */
265
+ export function useRebalanceSwapSync<
266
+ config extends Config = ResolvedRegister['config'],
267
+ context = unknown,
268
+ >(
269
+ parameters: useRebalanceSwapSync.Parameters<config, context> = {},
270
+ ): useRebalanceSwapSync.ReturnType<config, context> {
271
+ const { mutation } = parameters
272
+ const config = useConfig(parameters)
273
+ return useMutation({
274
+ ...mutation,
275
+ async mutationFn(variables) {
276
+ return Actions.rebalanceSwapSync(config, variables)
277
+ },
278
+ mutationKey: ['rebalanceSwapSync'],
279
+ })
280
+ }
281
+
282
+ export declare namespace useRebalanceSwapSync {
283
+ type Parameters<
284
+ config extends Config = Config,
285
+ context = unknown,
286
+ > = ConfigParameter<config> & {
287
+ mutation?:
288
+ | UseMutationParameters<
289
+ Actions.rebalanceSwapSync.ReturnValue,
290
+ DefaultError,
291
+ Actions.rebalanceSwapSync.Parameters<config>,
292
+ context
293
+ >
294
+ | undefined
295
+ }
296
+
297
+ type ReturnType<
298
+ config extends Config = Config,
299
+ context = unknown,
300
+ > = UseMutationResult<
301
+ Actions.rebalanceSwapSync.ReturnValue,
302
+ DefaultError,
303
+ Actions.rebalanceSwapSync.Parameters<config>,
304
+ context
305
+ >
306
+ }
307
+
308
+ /**
309
+ * Hook for adding liquidity to a pool.
310
+ *
311
+ * @example
312
+ * ```tsx
313
+ * import { Hooks } from 'tempo.ts/wagmi'
314
+ *
315
+ * function App() {
316
+ * const { mutate, isPending } = Hooks.amm.useMint()
317
+ *
318
+ * return (
319
+ * <button
320
+ * onClick={() =>
321
+ * mutate({
322
+ * userToken: {
323
+ * address: '0x20c0...beef',
324
+ * amount: 100n,
325
+ * },
326
+ * validatorToken: {
327
+ * address: '0x20c0...babe',
328
+ * amount: 100n,
329
+ * },
330
+ * to: '0xfeed...fede',
331
+ * })
332
+ * }
333
+ * disabled={isPending}
334
+ * >
335
+ * Add Liquidity
336
+ * </button>
337
+ * )
338
+ * }
339
+ * ```
340
+ *
341
+ * @param parameters - Parameters.
342
+ * @returns Mutation result.
343
+ */
344
+ export function useMint<
345
+ config extends Config = ResolvedRegister['config'],
346
+ context = unknown,
347
+ >(
348
+ parameters: useMint.Parameters<config, context> = {},
349
+ ): useMint.ReturnType<config, context> {
350
+ const { mutation } = parameters
351
+ const config = useConfig(parameters)
352
+ return useMutation({
353
+ ...mutation,
354
+ async mutationFn(variables) {
355
+ return Actions.mint(config, variables)
356
+ },
357
+ mutationKey: ['mint'],
358
+ })
359
+ }
360
+
361
+ export declare namespace useMint {
362
+ type Parameters<
363
+ config extends Config = Config,
364
+ context = unknown,
365
+ > = ConfigParameter<config> & {
366
+ mutation?:
367
+ | UseMutationParameters<
368
+ Actions.mint.ReturnValue,
369
+ DefaultError,
370
+ Actions.mint.Parameters<config>,
371
+ context
372
+ >
373
+ | undefined
374
+ }
375
+
376
+ type ReturnType<
377
+ config extends Config = Config,
378
+ context = unknown,
379
+ > = UseMutationResult<
380
+ Actions.mint.ReturnValue,
381
+ DefaultError,
382
+ Actions.mint.Parameters<config>,
383
+ context
384
+ >
385
+ }
386
+
387
+ /**
388
+ * Hook for adding liquidity to a pool.
389
+ *
390
+ * Note: This is a synchronous hook that waits for the transaction
391
+ * to be included on a block before returning a response.
392
+ *
393
+ * @example
394
+ * ```tsx
395
+ * import { Hooks } from 'tempo.ts/wagmi'
396
+ *
397
+ * function App() {
398
+ * const { mutate, isPending } = Hooks.amm.useMintSync()
399
+ *
400
+ * return (
401
+ * <button
402
+ * onClick={() =>
403
+ * mutate({
404
+ * userToken: {
405
+ * address: '0x20c0...beef',
406
+ * amount: 100n,
407
+ * },
408
+ * validatorToken: {
409
+ * address: '0x20c0...babe',
410
+ * amount: 100n,
411
+ * },
412
+ * to: '0xfeed...fede',
413
+ * })
414
+ * }
415
+ * disabled={isPending}
416
+ * >
417
+ * Add Liquidity
418
+ * </button>
419
+ * )
420
+ * }
421
+ * ```
422
+ *
423
+ * @param parameters - Parameters.
424
+ * @returns Mutation result.
425
+ */
426
+ export function useMintSync<
427
+ config extends Config = ResolvedRegister['config'],
428
+ context = unknown,
429
+ >(
430
+ parameters: useMintSync.Parameters<config, context> = {},
431
+ ): useMintSync.ReturnType<config, context> {
432
+ const { mutation } = parameters
433
+ const config = useConfig(parameters)
434
+ return useMutation({
435
+ ...mutation,
436
+ async mutationFn(variables) {
437
+ return Actions.mintSync(config, variables)
438
+ },
439
+ mutationKey: ['mintSync'],
440
+ })
441
+ }
442
+
443
+ export declare namespace useMintSync {
444
+ type Parameters<
445
+ config extends Config = Config,
446
+ context = unknown,
447
+ > = ConfigParameter<config> & {
448
+ mutation?:
449
+ | UseMutationParameters<
450
+ Actions.mintSync.ReturnValue,
451
+ DefaultError,
452
+ Actions.mintSync.Parameters<config>,
453
+ context
454
+ >
455
+ | undefined
456
+ }
457
+
458
+ type ReturnType<
459
+ config extends Config = Config,
460
+ context = unknown,
461
+ > = UseMutationResult<
462
+ Actions.mintSync.ReturnValue,
463
+ DefaultError,
464
+ Actions.mintSync.Parameters<config>,
465
+ context
466
+ >
467
+ }
468
+
469
+ /**
470
+ * Hook for removing liquidity from a pool.
471
+ *
472
+ * @example
473
+ * ```tsx
474
+ * import { Hooks } from 'tempo.ts/wagmi'
475
+ *
476
+ * function App() {
477
+ * const { mutate, isPending } = Hooks.amm.useBurn()
478
+ *
479
+ * return (
480
+ * <button
481
+ * onClick={() =>
482
+ * mutate({
483
+ * userToken: '0x20c0...beef',
484
+ * validatorToken: '0x20c0...babe',
485
+ * liquidity: 50n,
486
+ * to: '0xfeed...fede',
487
+ * })
488
+ * }
489
+ * disabled={isPending}
490
+ * >
491
+ * Remove Liquidity
492
+ * </button>
493
+ * )
494
+ * }
495
+ * ```
496
+ *
497
+ * @param parameters - Parameters.
498
+ * @returns Mutation result.
499
+ */
500
+ export function useBurn<
501
+ config extends Config = ResolvedRegister['config'],
502
+ context = unknown,
503
+ >(
504
+ parameters: useBurn.Parameters<config, context> = {},
505
+ ): useBurn.ReturnType<config, context> {
506
+ const { mutation } = parameters
507
+ const config = useConfig(parameters)
508
+ return useMutation({
509
+ ...mutation,
510
+ async mutationFn(variables) {
511
+ return Actions.burn(config, variables)
512
+ },
513
+ mutationKey: ['burn'],
514
+ })
515
+ }
516
+
517
+ export declare namespace useBurn {
518
+ type Parameters<
519
+ config extends Config = Config,
520
+ context = unknown,
521
+ > = ConfigParameter<config> & {
522
+ mutation?:
523
+ | UseMutationParameters<
524
+ Actions.burn.ReturnValue,
525
+ DefaultError,
526
+ Actions.burn.Parameters<config>,
527
+ context
528
+ >
529
+ | undefined
530
+ }
531
+
532
+ type ReturnType<
533
+ config extends Config = Config,
534
+ context = unknown,
535
+ > = UseMutationResult<
536
+ Actions.burn.ReturnValue,
537
+ DefaultError,
538
+ Actions.burn.Parameters<config>,
539
+ context
540
+ >
541
+ }
542
+
543
+ /**
544
+ * Hook for removing liquidity from a pool.
545
+ *
546
+ * Note: This is a synchronous hook that waits for the transaction
547
+ * to be included on a block before returning a response.
548
+ *
549
+ * @example
550
+ * ```tsx
551
+ * import { Hooks } from 'tempo.ts/wagmi'
552
+ *
553
+ * function App() {
554
+ * const { mutate, isPending } = Hooks.amm.useBurnSync()
555
+ *
556
+ * return (
557
+ * <button
558
+ * onClick={() =>
559
+ * mutate({
560
+ * userToken: '0x20c0...beef',
561
+ * validatorToken: '0x20c0...babe',
562
+ * liquidity: 50n,
563
+ * to: '0xfeed...fede',
564
+ * })
565
+ * }
566
+ * disabled={isPending}
567
+ * >
568
+ * Remove Liquidity
569
+ * </button>
570
+ * )
571
+ * }
572
+ * ```
573
+ *
574
+ * @param parameters - Parameters.
575
+ * @returns Mutation result.
576
+ */
577
+ export function useBurnSync<
578
+ config extends Config = ResolvedRegister['config'],
579
+ context = unknown,
580
+ >(
581
+ parameters: useBurnSync.Parameters<config, context> = {},
582
+ ): useBurnSync.ReturnType<config, context> {
583
+ const { mutation } = parameters
584
+ const config = useConfig(parameters)
585
+ return useMutation({
586
+ ...mutation,
587
+ async mutationFn(variables) {
588
+ return Actions.burnSync(config, variables)
589
+ },
590
+ mutationKey: ['burnSync'],
591
+ })
592
+ }
593
+
594
+ export declare namespace useBurnSync {
595
+ type Parameters<
596
+ config extends Config = Config,
597
+ context = unknown,
598
+ > = ConfigParameter<config> & {
599
+ mutation?:
600
+ | UseMutationParameters<
601
+ Actions.burnSync.ReturnValue,
602
+ DefaultError,
603
+ Actions.burnSync.Parameters<config>,
604
+ context
605
+ >
606
+ | undefined
607
+ }
608
+
609
+ type ReturnType<
610
+ config extends Config = Config,
611
+ context = unknown,
612
+ > = UseMutationResult<
613
+ Actions.burnSync.ReturnValue,
614
+ DefaultError,
615
+ Actions.burnSync.Parameters<config>,
616
+ context
617
+ >
618
+ }
619
+
620
+ /**
621
+ * Hook for watching rebalance swap events.
622
+ *
623
+ * @example
624
+ * ```tsx
625
+ * import { Hooks } from 'tempo.ts/wagmi'
626
+ *
627
+ * function App() {
628
+ * Hooks.amm.useWatchRebalanceSwap({
629
+ * onRebalanceSwap(args) {
630
+ * console.log('Rebalance swap:', args)
631
+ * },
632
+ * })
633
+ *
634
+ * return <div>Watching for rebalance swaps...</div>
635
+ * }
636
+ * ```
637
+ *
638
+ * @param parameters - Parameters.
639
+ */
640
+ export function useWatchRebalanceSwap<
641
+ config extends Config = ResolvedRegister['config'],
642
+ >(parameters: useWatchRebalanceSwap.Parameters<config> = {}) {
643
+ const { enabled = true, onRebalanceSwap, ...rest } = parameters
644
+
645
+ const config = useConfig({ config: parameters.config })
646
+ const configChainId = useChainId({ config })
647
+ const chainId = parameters.chainId ?? configChainId
648
+
649
+ useEffect(() => {
650
+ if (!enabled) return
651
+ if (!onRebalanceSwap) return
652
+ return Actions.watchRebalanceSwap(config, {
653
+ ...rest,
654
+ chainId,
655
+ onRebalanceSwap,
656
+ })
657
+ }, [config, enabled, onRebalanceSwap, rest, chainId])
658
+ }
659
+
660
+ export declare namespace useWatchRebalanceSwap {
661
+ type Parameters<config extends Config = Config> = UnionCompute<
662
+ ExactPartial<Actions.watchRebalanceSwap.Parameters<config>> &
663
+ ConfigParameter<config> & { enabled?: boolean | undefined }
664
+ >
665
+ }
666
+
667
+ /**
668
+ * Hook for watching fee swap events.
669
+ *
670
+ * @example
671
+ * ```tsx
672
+ * import { Hooks } from 'tempo.ts/wagmi'
673
+ *
674
+ * function App() {
675
+ * Hooks.amm.useWatchFeeSwap({
676
+ * onFeeSwap(args) {
677
+ * console.log('Fee swap:', args)
678
+ * },
679
+ * })
680
+ *
681
+ * return <div>Watching for fee swaps...</div>
682
+ * }
683
+ * ```
684
+ *
685
+ * @param parameters - Parameters.
686
+ */
687
+ export function useWatchFeeSwap<
688
+ config extends Config = ResolvedRegister['config'],
689
+ >(parameters: useWatchFeeSwap.Parameters<config> = {}) {
690
+ const { enabled = true, onFeeSwap, ...rest } = parameters
691
+
692
+ const config = useConfig({ config: parameters.config })
693
+ const configChainId = useChainId({ config })
694
+ const chainId = parameters.chainId ?? configChainId
695
+
696
+ useEffect(() => {
697
+ if (!enabled) return
698
+ if (!onFeeSwap) return
699
+ return Actions.watchFeeSwap(config, {
700
+ ...rest,
701
+ chainId,
702
+ onFeeSwap,
703
+ })
704
+ }, [config, enabled, onFeeSwap, rest, chainId])
705
+ }
706
+
707
+ export declare namespace useWatchFeeSwap {
708
+ type Parameters<config extends Config = Config> = UnionCompute<
709
+ ExactPartial<Actions.watchFeeSwap.Parameters<config>> &
710
+ ConfigParameter<config> & { enabled?: boolean | undefined }
711
+ >
712
+ }
713
+
714
+ /**
715
+ * Hook for watching liquidity mint events.
716
+ *
717
+ * @example
718
+ * ```tsx
719
+ * import { Hooks } from 'tempo.ts/wagmi'
720
+ *
721
+ * function App() {
722
+ * Hooks.amm.useWatchMint({
723
+ * onMint(args) {
724
+ * console.log('Liquidity added:', args)
725
+ * },
726
+ * })
727
+ *
728
+ * return <div>Watching for liquidity additions...</div>
729
+ * }
730
+ * ```
731
+ *
732
+ * @param parameters - Parameters.
733
+ */
734
+ export function useWatchMint<
735
+ config extends Config = ResolvedRegister['config'],
736
+ >(parameters: useWatchMint.Parameters<config> = {}) {
737
+ const { enabled = true, onMint, ...rest } = parameters
738
+
739
+ const config = useConfig({ config: parameters.config })
740
+ const configChainId = useChainId({ config })
741
+ const chainId = parameters.chainId ?? configChainId
742
+
743
+ useEffect(() => {
744
+ if (!enabled) return
745
+ if (!onMint) return
746
+ return Actions.watchMint(config, {
747
+ ...rest,
748
+ chainId,
749
+ onMint,
750
+ })
751
+ }, [config, enabled, onMint, rest, chainId])
752
+ }
753
+
754
+ export declare namespace useWatchMint {
755
+ type Parameters<config extends Config = Config> = UnionCompute<
756
+ ExactPartial<Actions.watchMint.Parameters<config>> &
757
+ ConfigParameter<config> & { enabled?: boolean | undefined }
758
+ >
759
+ }
760
+
761
+ /**
762
+ * Hook for watching liquidity burn events.
763
+ *
764
+ * @example
765
+ * ```tsx
766
+ * import { Hooks } from 'tempo.ts/wagmi'
767
+ *
768
+ * function App() {
769
+ * Hooks.amm.useWatchBurn({
770
+ * onBurn(args) {
771
+ * console.log('Liquidity removed:', args)
772
+ * },
773
+ * })
774
+ *
775
+ * return <div>Watching for liquidity removals...</div>
776
+ * }
777
+ * ```
778
+ *
779
+ * @param parameters - Parameters.
780
+ */
781
+ export function useWatchBurn<
782
+ config extends Config = ResolvedRegister['config'],
783
+ >(parameters: useWatchBurn.Parameters<config> = {}) {
784
+ const { enabled = true, onBurn, ...rest } = parameters
785
+
786
+ const config = useConfig({ config: parameters.config })
787
+ const configChainId = useChainId({ config })
788
+ const chainId = parameters.chainId ?? configChainId
789
+
790
+ useEffect(() => {
791
+ if (!enabled) return
792
+ if (!onBurn) return
793
+ return Actions.watchBurn(config, {
794
+ ...rest,
795
+ chainId,
796
+ onBurn,
797
+ })
798
+ }, [config, enabled, onBurn, rest, chainId])
799
+ }
800
+
801
+ export declare namespace useWatchBurn {
802
+ type Parameters<config extends Config = Config> = UnionCompute<
803
+ ExactPartial<Actions.watchBurn.Parameters<config>> &
804
+ ConfigParameter<config> & { enabled?: boolean | undefined }
805
+ >
806
+ }