tempo.ts 0.1.4 → 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 (277) 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 +5 -0
  47. package/dist/prool/Instance.d.ts.map +1 -1
  48. package/dist/prool/Instance.js +32 -8
  49. package/dist/prool/Instance.js.map +1 -1
  50. package/dist/viem/Abis.d.ts +1469 -1082
  51. package/dist/viem/Abis.d.ts.map +1 -1
  52. package/dist/viem/Abis.js +932 -671
  53. package/dist/viem/Abis.js.map +1 -1
  54. package/dist/viem/Account.d.ts +150 -0
  55. package/dist/viem/Account.d.ts.map +1 -0
  56. package/dist/viem/Account.js +221 -0
  57. package/dist/viem/Account.js.map +1 -0
  58. package/dist/viem/Actions/amm.d.ts +80 -118
  59. package/dist/viem/Actions/amm.d.ts.map +1 -1
  60. package/dist/viem/Actions/amm.js +47 -116
  61. package/dist/viem/Actions/amm.js.map +1 -1
  62. package/dist/viem/Actions/dex.d.ts +889 -633
  63. package/dist/viem/Actions/dex.d.ts.map +1 -1
  64. package/dist/viem/Actions/dex.js +99 -0
  65. package/dist/viem/Actions/dex.js.map +1 -1
  66. package/dist/viem/Actions/fee.d.ts +3 -17
  67. package/dist/viem/Actions/fee.d.ts.map +1 -1
  68. package/dist/viem/Actions/fee.js.map +1 -1
  69. package/dist/viem/Actions/index.d.ts +1 -0
  70. package/dist/viem/Actions/index.d.ts.map +1 -1
  71. package/dist/viem/Actions/index.js +1 -0
  72. package/dist/viem/Actions/index.js.map +1 -1
  73. package/dist/viem/Actions/reward.d.ts +3236 -0
  74. package/dist/viem/Actions/reward.d.ts.map +1 -0
  75. package/dist/viem/Actions/reward.js +725 -0
  76. package/dist/viem/Actions/reward.js.map +1 -0
  77. package/dist/viem/Actions/token.d.ts +4295 -2646
  78. package/dist/viem/Actions/token.d.ts.map +1 -1
  79. package/dist/viem/Actions/token.js +214 -335
  80. package/dist/viem/Actions/token.js.map +1 -1
  81. package/dist/viem/Addresses.d.ts +1 -2
  82. package/dist/viem/Addresses.d.ts.map +1 -1
  83. package/dist/viem/Addresses.js +1 -2
  84. package/dist/viem/Addresses.js.map +1 -1
  85. package/dist/viem/Chain.d.ts +38 -12
  86. package/dist/viem/Chain.d.ts.map +1 -1
  87. package/dist/viem/Chain.js +27 -18
  88. package/dist/viem/Chain.js.map +1 -1
  89. package/dist/viem/Decorator.d.ts +959 -405
  90. package/dist/viem/Decorator.d.ts.map +1 -1
  91. package/dist/viem/Decorator.js +13 -5
  92. package/dist/viem/Decorator.js.map +1 -1
  93. package/dist/viem/Formatters.d.ts +8 -1
  94. package/dist/viem/Formatters.d.ts.map +1 -1
  95. package/dist/viem/Formatters.js +17 -0
  96. package/dist/viem/Formatters.js.map +1 -1
  97. package/dist/viem/P256.d.ts +2 -0
  98. package/dist/viem/P256.d.ts.map +1 -0
  99. package/dist/viem/P256.js +2 -0
  100. package/dist/viem/P256.js.map +1 -0
  101. package/dist/viem/Secp256k1.d.ts +2 -0
  102. package/dist/viem/Secp256k1.d.ts.map +1 -0
  103. package/dist/viem/Secp256k1.js +2 -0
  104. package/dist/viem/Secp256k1.js.map +1 -0
  105. package/dist/viem/TokenIds.d.ts +1 -2
  106. package/dist/viem/TokenIds.d.ts.map +1 -1
  107. package/dist/viem/TokenIds.js +1 -2
  108. package/dist/viem/TokenIds.js.map +1 -1
  109. package/dist/viem/Transaction.d.ts +1 -1
  110. package/dist/viem/Transaction.d.ts.map +1 -1
  111. package/dist/viem/Transaction.js +46 -5
  112. package/dist/viem/Transaction.js.map +1 -1
  113. package/dist/viem/WebAuthnP256.d.ts +79 -0
  114. package/dist/viem/WebAuthnP256.d.ts.map +1 -0
  115. package/dist/viem/WebAuthnP256.js +95 -0
  116. package/dist/viem/WebAuthnP256.js.map +1 -0
  117. package/dist/viem/WebCryptoP256.d.ts +2 -0
  118. package/dist/viem/WebCryptoP256.d.ts.map +1 -0
  119. package/dist/viem/WebCryptoP256.js +2 -0
  120. package/dist/viem/WebCryptoP256.js.map +1 -0
  121. package/dist/viem/index.d.ts +6 -3
  122. package/dist/viem/index.d.ts.map +1 -1
  123. package/dist/viem/index.js +6 -3
  124. package/dist/viem/index.js.map +1 -1
  125. package/dist/viem/internal/account.d.ts +24 -0
  126. package/dist/viem/internal/account.d.ts.map +1 -0
  127. package/dist/viem/internal/account.js +68 -0
  128. package/dist/viem/internal/account.js.map +1 -0
  129. package/dist/viem/internal/types.d.ts +10 -0
  130. package/dist/viem/internal/types.d.ts.map +1 -1
  131. package/dist/wagmi/Actions/amm.d.ts +428 -0
  132. package/dist/wagmi/Actions/amm.d.ts.map +1 -0
  133. package/dist/wagmi/Actions/amm.js +472 -0
  134. package/dist/wagmi/Actions/amm.js.map +1 -0
  135. package/dist/wagmi/Actions/dex.d.ts +908 -0
  136. package/dist/wagmi/Actions/dex.d.ts.map +1 -0
  137. package/dist/wagmi/Actions/dex.js +1023 -0
  138. package/dist/wagmi/Actions/dex.js.map +1 -0
  139. package/dist/wagmi/Actions/fee.d.ts +111 -0
  140. package/dist/wagmi/Actions/fee.d.ts.map +1 -0
  141. package/dist/wagmi/Actions/fee.js +126 -0
  142. package/dist/wagmi/Actions/fee.js.map +1 -0
  143. package/dist/wagmi/Actions/index.d.ts +6 -0
  144. package/dist/wagmi/Actions/index.d.ts.map +1 -0
  145. package/dist/wagmi/Actions/index.js +6 -0
  146. package/dist/wagmi/Actions/index.js.map +1 -0
  147. package/dist/wagmi/Actions/reward.d.ts +348 -0
  148. package/dist/wagmi/Actions/reward.d.ts.map +1 -0
  149. package/dist/wagmi/Actions/reward.js +388 -0
  150. package/dist/wagmi/Actions/reward.js.map +1 -0
  151. package/dist/wagmi/Actions/token.d.ts +1546 -0
  152. package/dist/wagmi/Actions/token.d.ts.map +1 -0
  153. package/dist/wagmi/Actions/token.js +1712 -0
  154. package/dist/wagmi/Actions/token.js.map +1 -0
  155. package/dist/wagmi/Connector.d.ts +73 -0
  156. package/dist/wagmi/Connector.d.ts.map +1 -0
  157. package/dist/wagmi/Connector.js +249 -0
  158. package/dist/wagmi/Connector.js.map +1 -0
  159. package/dist/wagmi/Hooks/amm.d.ts +421 -0
  160. package/dist/wagmi/Hooks/amm.d.ts.map +1 -0
  161. package/dist/wagmi/Hooks/amm.js +504 -0
  162. package/dist/wagmi/Hooks/amm.js.map +1 -0
  163. package/dist/wagmi/Hooks/dex.d.ts +816 -0
  164. package/dist/wagmi/Hooks/dex.d.ts.map +1 -0
  165. package/dist/wagmi/Hooks/dex.js +973 -0
  166. package/dist/wagmi/Hooks/dex.js.map +1 -0
  167. package/dist/wagmi/Hooks/fee.d.ts +97 -0
  168. package/dist/wagmi/Hooks/fee.d.ts.map +1 -0
  169. package/dist/wagmi/Hooks/fee.js +109 -0
  170. package/dist/wagmi/Hooks/fee.js.map +1 -0
  171. package/dist/wagmi/Hooks/index.d.ts +6 -0
  172. package/dist/wagmi/Hooks/index.d.ts.map +1 -0
  173. package/dist/wagmi/Hooks/index.js +6 -0
  174. package/dist/wagmi/Hooks/index.js.map +1 -0
  175. package/dist/wagmi/Hooks/reward.d.ts +307 -0
  176. package/dist/wagmi/Hooks/reward.d.ts.map +1 -0
  177. package/dist/wagmi/Hooks/reward.js +349 -0
  178. package/dist/wagmi/Hooks/reward.js.map +1 -0
  179. package/dist/wagmi/Hooks/token.d.ts +1388 -0
  180. package/dist/wagmi/Hooks/token.d.ts.map +1 -0
  181. package/dist/wagmi/Hooks/token.js +1657 -0
  182. package/dist/wagmi/Hooks/token.js.map +1 -0
  183. package/dist/wagmi/index.d.ts +4 -0
  184. package/dist/wagmi/index.d.ts.map +1 -0
  185. package/dist/wagmi/index.js +4 -0
  186. package/dist/wagmi/index.js.map +1 -0
  187. package/package.json +54 -10
  188. package/src/chains.ts +19 -9
  189. package/src/ox/Order.test.ts +78 -0
  190. package/src/ox/Order.ts +125 -0
  191. package/src/ox/OrdersFilters.test.ts +182 -0
  192. package/src/ox/OrdersFilters.ts +125 -0
  193. package/src/ox/Pagination.test.ts +162 -0
  194. package/src/ox/Pagination.ts +164 -0
  195. package/src/ox/PoolId.test.ts +33 -0
  196. package/src/ox/PoolId.ts +27 -0
  197. package/src/ox/RpcSchema.ts +35 -0
  198. package/src/ox/SignatureEnvelope.ts +3 -1
  199. package/src/{viem → ox}/Tick.test.ts +1 -1
  200. package/src/{viem → ox}/Tick.ts +5 -0
  201. package/src/ox/Transaction.test.ts +1 -1
  202. package/src/ox/Transaction.ts +2 -1
  203. package/src/ox/TransactionEnvelopeAA.test.ts +239 -96
  204. package/src/ox/TransactionEnvelopeAA.ts +9 -7
  205. package/src/ox/TransactionRequest.ts +4 -0
  206. package/src/ox/index.ts +6 -0
  207. package/src/prool/Instance.ts +75 -38
  208. package/src/prool/internal/chain.json +104 -52
  209. package/src/tsconfig.json +9 -0
  210. package/src/viem/Abis.ts +972 -710
  211. package/src/viem/Account.ts +279 -0
  212. package/src/viem/Actions/__snapshots__/dex.test.ts.snap +850 -0
  213. package/src/viem/Actions/amm.test.ts +98 -169
  214. package/src/viem/Actions/amm.ts +68 -155
  215. package/src/viem/Actions/dex.test.ts +563 -484
  216. package/src/viem/Actions/dex.ts +173 -0
  217. package/src/viem/Actions/fee.test.ts +23 -34
  218. package/src/viem/Actions/fee.ts +7 -0
  219. package/src/viem/Actions/index.ts +1 -0
  220. package/src/viem/Actions/policy.test.ts +19 -33
  221. package/src/viem/Actions/reward.test.ts +457 -0
  222. package/src/viem/Actions/reward.ts +999 -0
  223. package/src/viem/Actions/token.test.ts +453 -287
  224. package/src/viem/Actions/token.ts +452 -540
  225. package/src/viem/Addresses.ts +1 -2
  226. package/src/viem/Chain.ts +70 -20
  227. package/src/viem/Decorator.test.ts +2 -1
  228. package/src/viem/Decorator.ts +996 -421
  229. package/src/viem/Formatters.ts +31 -5
  230. package/src/viem/P256.ts +1 -0
  231. package/src/viem/Secp256k1.ts +1 -0
  232. package/src/viem/TokenIds.ts +1 -2
  233. package/src/viem/Transaction.ts +53 -7
  234. package/src/viem/WebAuthnP256.ts +140 -0
  235. package/src/viem/WebCryptoP256.ts +1 -0
  236. package/src/viem/e2e.test.ts +1126 -297
  237. package/src/viem/index.ts +6 -3
  238. package/src/viem/internal/account.ts +107 -0
  239. package/src/viem/internal/types.ts +9 -0
  240. package/src/wagmi/Actions/__snapshots__/dex.test.ts.snap +310 -0
  241. package/src/wagmi/Actions/amm.test.ts +198 -0
  242. package/src/wagmi/Actions/amm.ts +691 -0
  243. package/src/wagmi/Actions/dex.test.ts +1507 -0
  244. package/src/wagmi/Actions/dex.ts +1640 -0
  245. package/src/wagmi/Actions/fee.test.ts +63 -0
  246. package/src/wagmi/Actions/fee.ts +208 -0
  247. package/src/wagmi/Actions/index.ts +5 -0
  248. package/src/wagmi/Actions/reward.test.ts +210 -0
  249. package/src/wagmi/Actions/reward.ts +632 -0
  250. package/src/wagmi/Actions/token.test.ts +1308 -0
  251. package/src/wagmi/Actions/token.ts +2613 -0
  252. package/src/wagmi/Connector.test.ts +53 -0
  253. package/src/wagmi/Connector.ts +367 -0
  254. package/src/wagmi/Hooks/__snapshots__/dex.test.ts.snap +457 -0
  255. package/src/wagmi/Hooks/amm.test.ts +424 -0
  256. package/src/wagmi/Hooks/amm.ts +806 -0
  257. package/src/wagmi/Hooks/dex.test.ts +1017 -0
  258. package/src/wagmi/Hooks/dex.ts +1685 -0
  259. package/src/wagmi/Hooks/fee.test.ts +166 -0
  260. package/src/wagmi/Hooks/fee.ts +206 -0
  261. package/src/wagmi/Hooks/index.ts +5 -0
  262. package/src/wagmi/Hooks/reward.test.ts +219 -0
  263. package/src/wagmi/Hooks/reward.ts +672 -0
  264. package/src/wagmi/Hooks/token.test.ts +1670 -0
  265. package/src/wagmi/Hooks/token.ts +2906 -0
  266. package/src/wagmi/index.ts +3 -0
  267. package/src/wagmi/internal/types.ts +16 -0
  268. package/dist/viem/Client.d.ts +0 -27
  269. package/dist/viem/Client.d.ts.map +0 -1
  270. package/dist/viem/Client.js +0 -28
  271. package/dist/viem/Client.js.map +0 -1
  272. package/dist/viem/Tick.d.ts.map +0 -1
  273. package/dist/viem/Tick.js.map +0 -1
  274. package/src/viem/Client.bench-d.ts +0 -8
  275. package/src/viem/Client.test.ts +0 -178
  276. package/src/viem/Client.ts +0 -91
  277. /package/dist/{viem → ox}/Tick.js +0 -0
@@ -1,6 +1,9 @@
1
+ import * as Hash from 'ox/Hash'
2
+ import * as Hex from 'ox/Hex'
1
3
  import {
2
4
  type Account,
3
5
  type Address,
6
+ type BaseErrorType,
4
7
  type Chain,
5
8
  type Client,
6
9
  type ExtractAbiItem,
@@ -22,6 +25,9 @@ import {
22
25
  writeContractSync,
23
26
  } from 'viem/actions'
24
27
  import type { Compute, UnionOmit } from '../../internal/types.js'
28
+ import * as Order from '../../ox/Order.js'
29
+ import * as OrdersFilters from '../../ox/OrdersFilters.js'
30
+ import * as Pagination from '../../ox/Pagination.js'
25
31
  import * as Abis from '../Abis.js'
26
32
  import * as Addresses from '../Addresses.js'
27
33
  import type {
@@ -93,6 +99,9 @@ export namespace buy {
93
99
 
94
100
  export type ReturnValue = WriteContractReturnType
95
101
 
102
+ // TODO: exhaustive error type
103
+ export type ErrorType = BaseErrorType
104
+
96
105
  /** @internal */
97
106
  export async function inner<
98
107
  action extends typeof writeContract | typeof writeContractSync,
@@ -211,6 +220,9 @@ export namespace buySync {
211
220
  /** Transaction receipt. */
212
221
  receipt: TransactionReceipt
213
222
  }>
223
+
224
+ // TODO: exhaustive error type
225
+ export type ErrorType = BaseErrorType
214
226
  }
215
227
 
216
228
  /**
@@ -261,6 +273,9 @@ export namespace cancel {
261
273
 
262
274
  export type ReturnValue = WriteContractReturnType
263
275
 
276
+ // TODO: exhaustive error type
277
+ export type ErrorType = BaseErrorType
278
+
264
279
  /** @internal */
265
280
  export async function inner<
266
281
  action extends typeof writeContract | typeof writeContractSync,
@@ -400,6 +415,9 @@ export namespace cancelSync {
400
415
  receipt: TransactionReceipt
401
416
  }
402
417
  >
418
+
419
+ // TODO: exhaustive error type
420
+ export type ErrorType = BaseErrorType
403
421
  }
404
422
 
405
423
  /**
@@ -450,6 +468,9 @@ export namespace createPair {
450
468
 
451
469
  export type ReturnValue = WriteContractReturnType
452
470
 
471
+ // TODO: exhaustive error type
472
+ export type ErrorType = BaseErrorType
473
+
453
474
  /** @internal */
454
475
  export async function inner<
455
476
  action extends typeof writeContract | typeof writeContractSync,
@@ -589,6 +610,9 @@ export namespace createPairSync {
589
610
  receipt: TransactionReceipt
590
611
  }
591
612
  >
613
+
614
+ // TODO: exhaustive error type
615
+ export type ErrorType = BaseErrorType
592
616
  }
593
617
 
594
618
  /**
@@ -802,6 +826,125 @@ export namespace getOrder {
802
826
  }
803
827
  }
804
828
 
829
+ /**
830
+ * Gets paginated orders from the orderbook.
831
+ *
832
+ * @example
833
+ * ```ts
834
+ * import { createClient, http } from 'viem'
835
+ * import { tempo } from 'tempo.ts/chains'
836
+ * import { Actions } from 'tempo.ts/viem'
837
+ *
838
+ * const client = createClient({
839
+ * chain: tempo,
840
+ * transport: http(),
841
+ * })
842
+ *
843
+ * const { items, nextCursor } = await Actions.dex.getOrders(client, {
844
+ * limit: 100,
845
+ * filters: {
846
+ * baseToken: '0x20c0...',
847
+ * isBid: true,
848
+ * }
849
+ * })
850
+ * ```
851
+ *
852
+ * @param client - Client.
853
+ * @param parameters - Parameters.
854
+ * @returns Paginated orders and next cursor.
855
+ */
856
+ export async function getOrders<chain extends Chain | undefined>(
857
+ client: Client<Transport, chain>,
858
+ parameters: getOrders.Parameters = {},
859
+ ): Promise<getOrders.ReturnValue> {
860
+ const params = Pagination.toRpcParameters(parameters, {
861
+ toRpcFilters: OrdersFilters.toRpc,
862
+ })
863
+ const response = await client.request<any>({
864
+ method: 'dex_getOrders',
865
+ params: [params],
866
+ })
867
+ return Pagination.fromRpcResponse(response, {
868
+ key: 'orders',
869
+ fromRpc: Order.fromRpc,
870
+ })
871
+ }
872
+
873
+ export namespace getOrders {
874
+ export type Parameters = Pagination.Params<OrdersFilters.OrdersFilters>
875
+
876
+ export type ReturnValue = Pagination.Response<'orders', Order.Order>
877
+ }
878
+
879
+ /**
880
+ * Gets orderbook information for a trading pair.
881
+ *
882
+ * @example
883
+ * ```ts
884
+ * import { createClient, http } from 'viem'
885
+ * import { tempo } from 'tempo.ts/chains'
886
+ * import { Actions } from 'tempo.ts/viem'
887
+ *
888
+ * const client = createClient({
889
+ * chain: tempo,
890
+ * transport: http(),
891
+ * })
892
+ *
893
+ * const book = await Actions.dex.getOrderbook(client, {
894
+ * base: '0x20c...11',
895
+ * quote: '0x20c...20',
896
+ * })
897
+ * ```
898
+ *
899
+ * @param client - Client.
900
+ * @param parameters - Parameters.
901
+ * @returns The orderbook information.
902
+ */
903
+ export async function getOrderbook<chain extends Chain | undefined>(
904
+ client: Client<Transport, chain>,
905
+ parameters: getOrderbook.Parameters,
906
+ ): Promise<getOrderbook.ReturnValue> {
907
+ const { base, quote, ...rest } = parameters
908
+ return readContract(client, {
909
+ ...rest,
910
+ ...getOrderbook.call({ base, quote }),
911
+ })
912
+ }
913
+
914
+ export namespace getOrderbook {
915
+ export type Parameters = ReadParameters & Args
916
+
917
+ export type Args = {
918
+ /** Address of the base token. */
919
+ base: Address
920
+ /** Address of the quote token. */
921
+ quote: Address
922
+ }
923
+
924
+ export type ReturnValue = ReadContractReturnType<
925
+ typeof Abis.stablecoinExchange,
926
+ 'books',
927
+ never
928
+ >
929
+
930
+ /**
931
+ * Defines a call to the `books` function.
932
+ *
933
+ * @param args - Arguments.
934
+ * @returns The call.
935
+ */
936
+ export function call(args: Args) {
937
+ const { base, quote } = args
938
+ const pairKey = getPairKey(base, quote)
939
+ return defineCall({
940
+ address: Addresses.stablecoinExchange,
941
+ abi: Abis.stablecoinExchange,
942
+ args: [pairKey],
943
+ functionName: 'books',
944
+ })
945
+ }
946
+ }
947
+
805
948
  /**
806
949
  * Gets the price level information at a specific tick.
807
950
  *
@@ -1001,6 +1144,9 @@ export namespace place {
1001
1144
 
1002
1145
  export type ReturnValue = WriteContractReturnType
1003
1146
 
1147
+ // TODO: exhaustive error type
1148
+ export type ErrorType = BaseErrorType
1149
+
1004
1150
  /** @internal */
1005
1151
  export async function inner<
1006
1152
  action extends typeof writeContract | typeof writeContractSync,
@@ -1142,6 +1288,9 @@ export namespace placeFlip {
1142
1288
 
1143
1289
  export type ReturnValue = WriteContractReturnType
1144
1290
 
1291
+ // TODO: exhaustive error type
1292
+ export type ErrorType = BaseErrorType
1293
+
1145
1294
  /** @internal */
1146
1295
  export async function inner<
1147
1296
  action extends typeof writeContract | typeof writeContractSync,
@@ -1290,6 +1439,9 @@ export namespace placeFlipSync {
1290
1439
  receipt: TransactionReceipt
1291
1440
  }
1292
1441
  >
1442
+
1443
+ // TODO: exhaustive error type
1444
+ export type ErrorType = BaseErrorType
1293
1445
  }
1294
1446
 
1295
1447
  /**
@@ -1357,6 +1509,9 @@ export namespace placeSync {
1357
1509
  receipt: TransactionReceipt
1358
1510
  }
1359
1511
  >
1512
+
1513
+ // TODO: exhaustive error type
1514
+ export type ErrorType = BaseErrorType
1360
1515
  }
1361
1516
 
1362
1517
  /**
@@ -1416,6 +1571,9 @@ export namespace sell {
1416
1571
 
1417
1572
  export type ReturnValue = WriteContractReturnType
1418
1573
 
1574
+ // TODO: exhaustive error type
1575
+ export type ErrorType = BaseErrorType
1576
+
1419
1577
  /** @internal */
1420
1578
  export async function inner<
1421
1579
  action extends typeof writeContract | typeof writeContractSync,
@@ -1534,6 +1692,9 @@ export namespace sellSync {
1534
1692
  /** Transaction receipt. */
1535
1693
  receipt: TransactionReceipt
1536
1694
  }>
1695
+
1696
+ // TODO: exhaustive error type
1697
+ export type ErrorType = BaseErrorType
1537
1698
  }
1538
1699
 
1539
1700
  /**
@@ -1909,6 +2070,9 @@ export namespace withdraw {
1909
2070
 
1910
2071
  export type ReturnValue = WriteContractReturnType
1911
2072
 
2073
+ // TODO: exhaustive error type
2074
+ export type ErrorType = BaseErrorType
2075
+
1912
2076
  /** @internal */
1913
2077
  export async function inner<
1914
2078
  action extends typeof writeContract | typeof writeContractSync,
@@ -2023,4 +2187,13 @@ export namespace withdrawSync {
2023
2187
  /** Transaction receipt. */
2024
2188
  receipt: TransactionReceipt
2025
2189
  }>
2190
+
2191
+ // TODO: exhaustive error type
2192
+ export type ErrorType = BaseErrorType
2193
+ }
2194
+
2195
+ function getPairKey(base: Address, quote: Address) {
2196
+ const [tokenA, tokenB] =
2197
+ Hex.toBigInt(base) < Hex.toBigInt(quote) ? [base, quote] : [quote, base]
2198
+ return Hash.keccak256(Hex.concat(tokenA, tokenB))
2026
2199
  }
@@ -1,44 +1,33 @@
1
1
  import { setTimeout } from 'node:timers/promises'
2
- import { Abis, Addresses, createTempoClient } from 'tempo.ts/viem'
3
- import { parseEther, publicActions } from 'viem'
4
- import { mnemonicToAccount } from 'viem/accounts'
2
+ import { Abis } from 'tempo.ts/viem'
3
+ import { parseUnits } from 'viem'
5
4
  import { writeContractSync } from 'viem/actions'
6
- import { describe, expect, test } from 'vitest'
7
- import { tempoTest } from '../../../test/viem/config.js'
5
+ import { afterEach, describe, expect, test } from 'vitest'
6
+ import { accounts, client, rpcUrl } from '../../../test/viem/config.js'
8
7
  import * as actions from './index.js'
9
8
 
10
- const account = mnemonicToAccount(
11
- 'test test test test test test test test test test test junk',
12
- )
13
- const account2 = mnemonicToAccount(
14
- 'test test test test test test test test test test test junk',
15
- { accountIndex: 1 },
16
- )
17
- const account3 = mnemonicToAccount(
18
- 'test test test test test test test test test test test junk',
19
- { accountIndex: 2 },
20
- )
9
+ const account = accounts[0]
10
+ const account2 = accounts[1]
11
+ const account3 = accounts[2]
21
12
 
22
- const client = createTempoClient({
23
- account,
24
- chain: tempoTest,
25
- pollingInterval: 100,
26
- }).extend(publicActions)
13
+ afterEach(async () => {
14
+ await fetch(`${rpcUrl}/restart`)
15
+ })
27
16
 
28
17
  describe('getUserToken', () => {
29
18
  test('default', async () => {
30
19
  // Fund accounts
31
20
  await writeContractSync(client, {
32
21
  abi: Abis.tip20,
33
- address: Addresses.defaultFeeToken,
22
+ address: '0x20c0000000000000000000000000000000000001',
34
23
  functionName: 'transfer',
35
- args: [account2.address, parseEther('100')],
24
+ args: [account2.address, parseUnits('100', 6)],
36
25
  })
37
26
  await writeContractSync(client, {
38
27
  abi: Abis.tip20,
39
- address: Addresses.defaultFeeToken,
28
+ address: '0x20c0000000000000000000000000000000000001',
40
29
  functionName: 'transfer',
41
- args: [account3.address, parseEther('100')],
30
+ args: [account3.address, parseUnits('100', 6)],
42
31
  })
43
32
 
44
33
  // Set token (address)
@@ -137,7 +126,7 @@ describe('setUserToken', () => {
137
126
  })
138
127
  })
139
128
 
140
- describe('watchSetUserToken', () => {
129
+ describe('watchSetUserToken', async () => {
141
130
  test('default', async () => {
142
131
  const receivedSets: Array<{
143
132
  args: actions.fee.watchSetUserToken.Args
@@ -155,9 +144,9 @@ describe('watchSetUserToken', () => {
155
144
  // Set token for account2
156
145
  await writeContractSync(client, {
157
146
  abi: Abis.tip20,
158
- address: Addresses.defaultFeeToken,
147
+ address: '0x20c0000000000000000000000000000000000001',
159
148
  functionName: 'transfer',
160
- args: [account2.address, parseEther('1')],
149
+ args: [account2.address, parseUnits('1', 6)],
161
150
  })
162
151
 
163
152
  await actions.fee.setUserTokenSync(client, {
@@ -168,9 +157,9 @@ describe('watchSetUserToken', () => {
168
157
  // Set token for account3
169
158
  await writeContractSync(client, {
170
159
  abi: Abis.tip20,
171
- address: Addresses.defaultFeeToken,
160
+ address: '0x20c0000000000000000000000000000000000001',
172
161
  functionName: 'transfer',
173
- args: [account3.address, parseEther('1')],
162
+ args: [account3.address, parseUnits('1', 6)],
174
163
  })
175
164
 
176
165
  await actions.fee.setUserTokenSync(client, {
@@ -219,16 +208,16 @@ describe('watchSetUserToken', () => {
219
208
  // Transfer gas to accounts
220
209
  await writeContractSync(client, {
221
210
  abi: Abis.tip20,
222
- address: Addresses.defaultFeeToken,
211
+ address: '0x20c0000000000000000000000000000000000001',
223
212
  functionName: 'transfer',
224
- args: [account2.address, parseEther('1')],
213
+ args: [account2.address, parseUnits('1', 6)],
225
214
  })
226
215
 
227
216
  await writeContractSync(client, {
228
217
  abi: Abis.tip20,
229
- address: Addresses.defaultFeeToken,
218
+ address: '0x20c0000000000000000000000000000000000001',
230
219
  functionName: 'transfer',
231
- args: [account3.address, parseEther('1')],
220
+ args: [account3.address, parseUnits('1', 6)],
232
221
  })
233
222
 
234
223
  // Set token for account2 (should be captured)
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  type Account,
3
3
  type Address,
4
+ type BaseErrorType,
4
5
  type Chain,
5
6
  type Client,
6
7
  type ExtractAbiItem,
@@ -156,6 +157,9 @@ export namespace setUserToken {
156
157
 
157
158
  export type ReturnValue = WriteContractReturnType
158
159
 
160
+ // TODO: exhaustive error type
161
+ export type ErrorType = BaseErrorType
162
+
159
163
  /** @internal */
160
164
  export async function inner<
161
165
  action extends typeof writeContract | typeof writeContractSync,
@@ -291,6 +295,9 @@ export namespace setUserTokenSync {
291
295
  receipt: TransactionReceipt
292
296
  }
293
297
  >
298
+
299
+ // TODO: exhaustive error type
300
+ export type ErrorType = BaseErrorType
294
301
  }
295
302
 
296
303
  /**
@@ -2,4 +2,5 @@ export * as amm from './amm.js'
2
2
  export * as dex from './dex.js'
3
3
  export * as fee from './fee.js'
4
4
  export * as policy from './policy.js'
5
+ export * as reward from './reward.js'
5
6
  export * as token from './token.js'
@@ -1,28 +1,11 @@
1
1
  import { setTimeout } from 'node:timers/promises'
2
- import { publicActions } from 'viem'
3
- import { mnemonicToAccount } from 'viem/accounts'
4
- import { describe, expect, test } from 'vitest'
5
- import { tempoTest } from '../../../test/viem/config.js'
6
- import { createTempoClient } from '../Client.js'
2
+ import { beforeAll, describe, expect, test } from 'vitest'
3
+ import { accounts, client, rpcUrl } from '../../../test/viem/config.js'
7
4
  import * as actions from './index.js'
8
5
 
9
- const account = mnemonicToAccount(
10
- 'test test test test test test test test test test test junk',
11
- )
12
- const account2 = mnemonicToAccount(
13
- 'test test test test test test test test test test test junk',
14
- { accountIndex: 1 },
15
- )
16
- const account3 = mnemonicToAccount(
17
- 'test test test test test test test test test test test junk',
18
- { accountIndex: 2 },
19
- )
20
-
21
- const client = createTempoClient({
22
- account,
23
- chain: tempoTest,
24
- pollingInterval: 100,
25
- }).extend(publicActions)
6
+ const account = accounts[0]
7
+ const account2 = accounts[1]
8
+ const account3 = accounts[2]
26
9
 
27
10
  describe('create', () => {
28
11
  test('default', async () => {
@@ -58,7 +41,7 @@ describe('create', () => {
58
41
  expect(blacklistReceipt).toBeDefined()
59
42
  expect(blacklistResult).toMatchInlineSnapshot(`
60
43
  {
61
- "policyId": 2n,
44
+ "policyId": 3n,
62
45
  "policyType": 1,
63
46
  "updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
64
47
  }
@@ -120,7 +103,7 @@ describe('setAdmin', () => {
120
103
  expect(setAdminResult).toMatchInlineSnapshot(`
121
104
  {
122
105
  "admin": "0x8C8d35429F74ec245F8Ef2f4Fd1e551cFF97d650",
123
- "policyId": 2n,
106
+ "policyId": 4n,
124
107
  "updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
125
108
  }
126
109
  `)
@@ -163,7 +146,7 @@ describe('modifyWhitelist', () => {
163
146
  {
164
147
  "account": "0x8C8d35429F74ec245F8Ef2f4Fd1e551cFF97d650",
165
148
  "allowed": true,
166
- "policyId": 2n,
149
+ "policyId": 5n,
167
150
  "updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
168
151
  }
169
152
  `)
@@ -189,7 +172,7 @@ describe('modifyWhitelist', () => {
189
172
  {
190
173
  "account": "0x8C8d35429F74ec245F8Ef2f4Fd1e551cFF97d650",
191
174
  "allowed": false,
192
- "policyId": 2n,
175
+ "policyId": 5n,
193
176
  "updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
194
177
  }
195
178
  `)
@@ -232,7 +215,7 @@ describe('modifyBlacklist', () => {
232
215
  expect(addBlacklistResult).toMatchInlineSnapshot(`
233
216
  {
234
217
  "account": "0x8C8d35429F74ec245F8Ef2f4Fd1e551cFF97d650",
235
- "policyId": 2n,
218
+ "policyId": 6n,
236
219
  "restricted": true,
237
220
  "updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
238
221
  }
@@ -258,7 +241,7 @@ describe('modifyBlacklist', () => {
258
241
  expect(removeBlacklistResult).toMatchInlineSnapshot(`
259
242
  {
260
243
  "account": "0x8C8d35429F74ec245F8Ef2f4Fd1e551cFF97d650",
261
- "policyId": 2n,
244
+ "policyId": 6n,
262
245
  "restricted": false,
263
246
  "updater": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
264
247
  }
@@ -397,13 +380,17 @@ describe('watchCreate', () => {
397
380
  unwatch()
398
381
 
399
382
  expect(logs.length).toBe(1)
400
- expect(logs[0].args.policyId).toBe(2n)
383
+ expect(logs[0].args.policyId).toBeDefined()
401
384
  expect(logs[0].args.updater).toBe(account.address)
402
385
  expect(logs[0].args.type).toBe('whitelist')
403
386
  })
404
387
  })
405
388
 
406
389
  describe('watchAdminUpdated', () => {
390
+ beforeAll(async () => {
391
+ await fetch(`${rpcUrl}/restart`)
392
+ })
393
+
407
394
  test('default', async () => {
408
395
  // create policy
409
396
  const { policyId } = await actions.policy.createSync(client, {
@@ -426,8 +413,7 @@ describe('watchAdminUpdated', () => {
426
413
  await setTimeout(500)
427
414
  unwatch()
428
415
 
429
- expect(logs.length).toBe(1)
430
- expect(logs[0].args.policyId).toBe(2n)
416
+ expect(logs[0].args.policyId).toBeDefined()
431
417
  expect(logs[0].args.updater).toBe(account.address)
432
418
  expect(logs[0].args.admin).toBe(account2.address)
433
419
  })
@@ -465,7 +451,7 @@ describe('watchWhitelistUpdated', () => {
465
451
  unwatch()
466
452
 
467
453
  expect(logs.length).toBe(2)
468
- expect(logs[0].args.policyId).toBe(2n)
454
+ expect(logs[0].args.policyId).toBeDefined()
469
455
  expect(logs[0].args.updater).toBe(account.address)
470
456
  expect(logs[0].args.account).toBe(account2.address)
471
457
  expect(logs[0].args.allowed).toBe(true)
@@ -505,7 +491,7 @@ describe('watchBlacklistUpdated', () => {
505
491
  unwatch()
506
492
 
507
493
  expect(logs.length).toBe(2)
508
- expect(logs[0].args.policyId).toBe(2n)
494
+ expect(logs[0].args.policyId).toBeDefined()
509
495
  expect(logs[0].args.updater).toBe(account.address)
510
496
  expect(logs[0].args.account).toBe(account2.address)
511
497
  expect(logs[0].args.restricted).toBe(true)