tempo.ts 0.12.0 → 0.13.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 (123) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +28 -34
  3. package/package.json +2 -28
  4. package/dist/wagmi/Actions/amm.d.ts +0 -418
  5. package/dist/wagmi/Actions/amm.d.ts.map +0 -1
  6. package/dist/wagmi/Actions/amm.js +0 -462
  7. package/dist/wagmi/Actions/amm.js.map +0 -1
  8. package/dist/wagmi/Actions/dex.d.ts +0 -864
  9. package/dist/wagmi/Actions/dex.d.ts.map +0 -1
  10. package/dist/wagmi/Actions/dex.js +0 -968
  11. package/dist/wagmi/Actions/dex.js.map +0 -1
  12. package/dist/wagmi/Actions/faucet.d.ts +0 -66
  13. package/dist/wagmi/Actions/faucet.d.ts.map +0 -1
  14. package/dist/wagmi/Actions/faucet.js +0 -64
  15. package/dist/wagmi/Actions/faucet.js.map +0 -1
  16. package/dist/wagmi/Actions/fee.d.ts +0 -111
  17. package/dist/wagmi/Actions/fee.d.ts.map +0 -1
  18. package/dist/wagmi/Actions/fee.js +0 -126
  19. package/dist/wagmi/Actions/fee.js.map +0 -1
  20. package/dist/wagmi/Actions/index.d.ts +0 -9
  21. package/dist/wagmi/Actions/index.d.ts.map +0 -1
  22. package/dist/wagmi/Actions/index.js +0 -9
  23. package/dist/wagmi/Actions/index.js.map +0 -1
  24. package/dist/wagmi/Actions/nonce.d.ts +0 -77
  25. package/dist/wagmi/Actions/nonce.d.ts.map +0 -1
  26. package/dist/wagmi/Actions/nonce.js +0 -87
  27. package/dist/wagmi/Actions/nonce.js.map +0 -1
  28. package/dist/wagmi/Actions/policy.d.ts +0 -480
  29. package/dist/wagmi/Actions/policy.d.ts.map +0 -1
  30. package/dist/wagmi/Actions/policy.js +0 -530
  31. package/dist/wagmi/Actions/policy.js.map +0 -1
  32. package/dist/wagmi/Actions/reward.d.ts +0 -346
  33. package/dist/wagmi/Actions/reward.d.ts.map +0 -1
  34. package/dist/wagmi/Actions/reward.js +0 -382
  35. package/dist/wagmi/Actions/reward.js.map +0 -1
  36. package/dist/wagmi/Actions/token.d.ts +0 -1546
  37. package/dist/wagmi/Actions/token.d.ts.map +0 -1
  38. package/dist/wagmi/Actions/token.js +0 -1712
  39. package/dist/wagmi/Actions/token.js.map +0 -1
  40. package/dist/wagmi/Connector.d.ts +0 -91
  41. package/dist/wagmi/Connector.d.ts.map +0 -1
  42. package/dist/wagmi/Connector.js +0 -473
  43. package/dist/wagmi/Connector.js.map +0 -1
  44. package/dist/wagmi/Hooks/amm.d.ts +0 -411
  45. package/dist/wagmi/Hooks/amm.d.ts.map +0 -1
  46. package/dist/wagmi/Hooks/amm.js +0 -494
  47. package/dist/wagmi/Hooks/amm.js.map +0 -1
  48. package/dist/wagmi/Hooks/dex.d.ts +0 -773
  49. package/dist/wagmi/Hooks/dex.d.ts.map +0 -1
  50. package/dist/wagmi/Hooks/dex.js +0 -921
  51. package/dist/wagmi/Hooks/dex.js.map +0 -1
  52. package/dist/wagmi/Hooks/faucet.d.ts +0 -71
  53. package/dist/wagmi/Hooks/faucet.d.ts.map +0 -1
  54. package/dist/wagmi/Hooks/faucet.js +0 -76
  55. package/dist/wagmi/Hooks/faucet.js.map +0 -1
  56. package/dist/wagmi/Hooks/fee.d.ts +0 -97
  57. package/dist/wagmi/Hooks/fee.d.ts.map +0 -1
  58. package/dist/wagmi/Hooks/fee.js +0 -109
  59. package/dist/wagmi/Hooks/fee.js.map +0 -1
  60. package/dist/wagmi/Hooks/index.d.ts +0 -9
  61. package/dist/wagmi/Hooks/index.d.ts.map +0 -1
  62. package/dist/wagmi/Hooks/index.js +0 -9
  63. package/dist/wagmi/Hooks/index.js.map +0 -1
  64. package/dist/wagmi/Hooks/nonce.d.ts +0 -59
  65. package/dist/wagmi/Hooks/nonce.d.ts.map +0 -1
  66. package/dist/wagmi/Hooks/nonce.js +0 -75
  67. package/dist/wagmi/Hooks/nonce.js.map +0 -1
  68. package/dist/wagmi/Hooks/policy.d.ts +0 -423
  69. package/dist/wagmi/Hooks/policy.d.ts.map +0 -1
  70. package/dist/wagmi/Hooks/policy.js +0 -510
  71. package/dist/wagmi/Hooks/policy.js.map +0 -1
  72. package/dist/wagmi/Hooks/reward.d.ts +0 -305
  73. package/dist/wagmi/Hooks/reward.d.ts.map +0 -1
  74. package/dist/wagmi/Hooks/reward.js +0 -368
  75. package/dist/wagmi/Hooks/reward.js.map +0 -1
  76. package/dist/wagmi/Hooks/token.d.ts +0 -1388
  77. package/dist/wagmi/Hooks/token.d.ts.map +0 -1
  78. package/dist/wagmi/Hooks/token.js +0 -1657
  79. package/dist/wagmi/Hooks/token.js.map +0 -1
  80. package/dist/wagmi/KeyManager.d.ts +0 -60
  81. package/dist/wagmi/KeyManager.d.ts.map +0 -1
  82. package/dist/wagmi/KeyManager.js +0 -106
  83. package/dist/wagmi/KeyManager.js.map +0 -1
  84. package/dist/wagmi/index.d.ts +0 -5
  85. package/dist/wagmi/index.d.ts.map +0 -1
  86. package/dist/wagmi/index.js +0 -5
  87. package/dist/wagmi/index.js.map +0 -1
  88. package/src/wagmi/Actions/amm.test.ts +0 -208
  89. package/src/wagmi/Actions/amm.ts +0 -690
  90. package/src/wagmi/Actions/dex.test.ts +0 -1482
  91. package/src/wagmi/Actions/dex.ts +0 -1540
  92. package/src/wagmi/Actions/faucet.ts +0 -89
  93. package/src/wagmi/Actions/fee.test.ts +0 -63
  94. package/src/wagmi/Actions/fee.ts +0 -211
  95. package/src/wagmi/Actions/index.ts +0 -8
  96. package/src/wagmi/Actions/nonce.test.ts +0 -82
  97. package/src/wagmi/Actions/nonce.ts +0 -139
  98. package/src/wagmi/Actions/policy.test.ts +0 -461
  99. package/src/wagmi/Actions/policy.ts +0 -817
  100. package/src/wagmi/Actions/reward.test.ts +0 -216
  101. package/src/wagmi/Actions/reward.ts +0 -613
  102. package/src/wagmi/Actions/token.test.ts +0 -1309
  103. package/src/wagmi/Actions/token.ts +0 -2644
  104. package/src/wagmi/Connector.test.ts +0 -56
  105. package/src/wagmi/Connector.ts +0 -670
  106. package/src/wagmi/Hooks/amm.test.ts +0 -564
  107. package/src/wagmi/Hooks/amm.ts +0 -796
  108. package/src/wagmi/Hooks/dex.test.ts +0 -992
  109. package/src/wagmi/Hooks/dex.ts +0 -1598
  110. package/src/wagmi/Hooks/faucet.ts +0 -144
  111. package/src/wagmi/Hooks/fee.test.ts +0 -166
  112. package/src/wagmi/Hooks/fee.ts +0 -206
  113. package/src/wagmi/Hooks/index.ts +0 -8
  114. package/src/wagmi/Hooks/nonce.test.ts +0 -142
  115. package/src/wagmi/Hooks/nonce.ts +0 -117
  116. package/src/wagmi/Hooks/policy.test.ts +0 -665
  117. package/src/wagmi/Hooks/policy.ts +0 -873
  118. package/src/wagmi/Hooks/reward.test.ts +0 -249
  119. package/src/wagmi/Hooks/reward.ts +0 -645
  120. package/src/wagmi/Hooks/token.test.ts +0 -1183
  121. package/src/wagmi/Hooks/token.ts +0 -2906
  122. package/src/wagmi/KeyManager.ts +0 -172
  123. package/src/wagmi/index.ts +0 -7
@@ -1,564 +0,0 @@
1
- import { type Address, parseUnits } from 'viem'
2
- import { describe, expect, test, vi } from 'vitest'
3
- import { useConnect } from 'wagmi'
4
- import { addresses } from '../../../test/config.js'
5
- import { accounts } from '../../../test/viem/config.js'
6
- import { config, renderHook } from '../../../test/wagmi/config.js'
7
- import * as hooks from './amm.js'
8
- import * as tokenHooks from './token.js'
9
-
10
- const account = accounts[0]
11
-
12
- describe('usePool', () => {
13
- test('default', async () => {
14
- const { result } = await renderHook(() =>
15
- hooks.usePool({
16
- userToken: addresses.alphaUsd,
17
- validatorToken: '0x20c0000000000000000000000000000000000001',
18
- }),
19
- )
20
-
21
- await vi.waitFor(() => expect(result.current.isSuccess).toBeTruthy(), {
22
- timeout: 10_000,
23
- })
24
-
25
- expect(result.current.data).toMatchInlineSnapshot(`
26
- {
27
- "reserveUserToken": 0n,
28
- "reserveValidatorToken": 0n,
29
- "totalSupply": 0n,
30
- }
31
- `)
32
- })
33
-
34
- test('reactivity: token parameters', async () => {
35
- let userToken: Address | undefined
36
- let validatorToken: Address | undefined
37
-
38
- const { result, rerender } = await renderHook(() =>
39
- hooks.usePool({
40
- userToken,
41
- validatorToken,
42
- }),
43
- )
44
-
45
- await vi.waitFor(() => result.current.fetchStatus === 'idle')
46
-
47
- // Should be disabled when tokens are undefined
48
- expect(result.current.data).toBeUndefined()
49
- expect(result.current.isPending).toBe(true)
50
- expect(result.current.isEnabled).toBe(false)
51
-
52
- // Set tokens
53
- userToken = addresses.alphaUsd
54
- validatorToken = '0x20c0000000000000000000000000000000000001'
55
- rerender()
56
-
57
- await vi.waitFor(() => expect(result.current.isSuccess).toBeTruthy())
58
-
59
- // Should now be enabled and have data
60
- expect(result.current.isEnabled).toBe(true)
61
- expect(result.current.data).toBeDefined()
62
- })
63
- })
64
-
65
- describe('useLiquidityBalance', () => {
66
- test('default', async () => {
67
- const { result } = await renderHook(() =>
68
- hooks.useLiquidityBalance({
69
- address: account.address,
70
- userToken: addresses.alphaUsd,
71
- validatorToken: '0x20c0000000000000000000000000000000000001',
72
- }),
73
- )
74
-
75
- await vi.waitFor(() => expect(result.current.isSuccess).toBeTruthy(), {
76
- timeout: 5_000,
77
- })
78
-
79
- expect(result.current.data).toMatchInlineSnapshot(`0n`)
80
- })
81
-
82
- test('reactivity: poolId and address parameters', async () => {
83
- let userToken: Address | undefined
84
- let validatorToken: Address | undefined
85
- let address: Address | undefined
86
-
87
- const { result, rerender } = await renderHook(() =>
88
- hooks.useLiquidityBalance({
89
- userToken,
90
- validatorToken,
91
- address,
92
- }),
93
- )
94
-
95
- await vi.waitFor(() => result.current.fetchStatus === 'idle')
96
-
97
- // Should be disabled when parameters are undefined
98
- expect(result.current.data).toBeUndefined()
99
- expect(result.current.isPending).toBe(true)
100
- expect(result.current.isEnabled).toBe(false)
101
-
102
- // Set parameters
103
- userToken = addresses.alphaUsd
104
- validatorToken = '0x20c0000000000000000000000000000000000001'
105
- address = account.address
106
- rerender()
107
-
108
- await vi.waitFor(() => expect(result.current.isSuccess).toBeTruthy())
109
-
110
- // Should now be enabled and have data
111
- expect(result.current.isEnabled).toBe(true)
112
- expect(result.current.data).toBeDefined()
113
- })
114
- })
115
-
116
- describe('useMintSync', () => {
117
- test('default', async () => {
118
- const { result } = await renderHook(() => ({
119
- connect: useConnect(),
120
- createSync: tokenHooks.useCreateSync(),
121
- grantRolesSync: tokenHooks.useGrantRolesSync(),
122
- mintTokenSync: tokenHooks.useMintSync(),
123
- mintSync: hooks.useMintSync(),
124
- }))
125
-
126
- await result.current.connect.connectAsync({
127
- connector: config.connectors[0]!,
128
- })
129
-
130
- // Create a new token for testing
131
- const { token } = await result.current.createSync.mutateAsync({
132
- name: 'Test Token',
133
- symbol: 'TEST',
134
- currency: 'USD',
135
- })
136
-
137
- // Grant issuer role to mint tokens
138
- await result.current.grantRolesSync.mutateAsync({
139
- token,
140
- roles: ['issuer'],
141
- to: account.address,
142
- })
143
-
144
- // Mint some tokens to account
145
- await result.current.mintTokenSync.mutateAsync({
146
- to: account.address,
147
- amount: parseUnits('1000', 6),
148
- token,
149
- })
150
-
151
- // Add liquidity to pool
152
- const data = await result.current.mintSync.mutateAsync({
153
- userTokenAddress: token,
154
- validatorTokenAddress: addresses.alphaUsd,
155
- validatorTokenAmount: parseUnits('100', 6),
156
- to: account.address,
157
- })
158
-
159
- await vi.waitFor(() =>
160
- expect(result.current.mintSync.isSuccess).toBeTruthy(),
161
- )
162
-
163
- expect(data.receipt).toBeDefined()
164
- expect(data.amountValidatorToken).toBe(parseUnits('100', 6))
165
- })
166
- })
167
-
168
- describe.skip('useBurnSync', () => {
169
- test('default', async () => {
170
- const { result } = await renderHook(() => ({
171
- connect: useConnect(),
172
- createSync: tokenHooks.useCreateSync(),
173
- grantRolesSync: tokenHooks.useGrantRolesSync(),
174
- mintTokenSync: tokenHooks.useMintSync(),
175
- mintSync: hooks.useMintSync(),
176
- burnSync: hooks.useBurnSync(),
177
- transferSync: tokenHooks.useTransferSync(),
178
- getLiquidityBalance: hooks.useLiquidityBalance,
179
- }))
180
-
181
- await result.current.connect.connectAsync({
182
- connector: config.connectors[0]!,
183
- })
184
-
185
- // Create a new token for testing
186
- const { token } = await result.current.createSync.mutateAsync({
187
- name: 'Test Token 5',
188
- symbol: 'TEST5',
189
- currency: 'USD',
190
- })
191
-
192
- // Grant issuer role to mint tokens
193
- await result.current.grantRolesSync.mutateAsync({
194
- token,
195
- roles: ['issuer'],
196
- to: account.address,
197
- })
198
-
199
- // Mint some tokens to account
200
- await result.current.mintTokenSync.mutateAsync({
201
- to: account.address,
202
- amount: parseUnits('1000', 6),
203
- token,
204
- })
205
-
206
- // Add liquidity to pool
207
- await result.current.mintSync.mutateAsync({
208
- userTokenAddress: token,
209
- validatorTokenAddress: addresses.alphaUsd,
210
- validatorTokenAmount: parseUnits('100', 6),
211
- to: account.address,
212
- })
213
-
214
- // TODO(TEMPO-1183): Remove this janky fix to get some user token in the pool
215
- await result.current.transferSync.mutateAsync({
216
- to: '0x30D861999070Ae03B9548501DBd573E11A9f59Ee',
217
- amount: 600n,
218
- token: token,
219
- feeToken: token,
220
- })
221
-
222
- // Get LP balance before burn
223
- const { result: balanceResult } = await renderHook(() =>
224
- result.current.getLiquidityBalance({
225
- userToken: token,
226
- validatorToken: addresses.alphaUsd,
227
- address: account.address,
228
- }),
229
- )
230
-
231
- await vi.waitFor(() => expect(balanceResult.current.isSuccess).toBeTruthy())
232
-
233
- const lpBalanceBefore = balanceResult.current.data!
234
-
235
- // Burn half of LP tokens
236
- const data = await result.current.burnSync.mutateAsync({
237
- userToken: token,
238
- validatorToken: addresses.alphaUsd,
239
- liquidity: lpBalanceBefore / 2n,
240
- to: account.address,
241
- })
242
-
243
- await vi.waitFor(() =>
244
- expect(result.current.burnSync.isSuccess).toBeTruthy(),
245
- )
246
-
247
- expect(data.receipt).toBeDefined()
248
- expect(data.liquidity).toBe(lpBalanceBefore / 2n)
249
- })
250
- })
251
-
252
- describe.skip('useRebalanceSwapSync', () => {
253
- test('default', async () => {
254
- const { result } = await renderHook(() => ({
255
- connect: useConnect(),
256
- createSync: tokenHooks.useCreateSync(),
257
- grantRolesSync: tokenHooks.useGrantRolesSync(),
258
- mintTokenSync: tokenHooks.useMintSync(),
259
- mintSync: hooks.useMintSync(),
260
- transferSync: tokenHooks.useTransferSync(),
261
- rebalanceSwapSync: hooks.useRebalanceSwapSync(),
262
- }))
263
-
264
- await result.current.connect.connectAsync({
265
- connector: config.connectors[0]!,
266
- })
267
-
268
- // Create a new token for testing
269
- const { token } = await result.current.createSync.mutateAsync({
270
- name: 'Test Token 6',
271
- symbol: 'TEST6',
272
- currency: 'USD',
273
- })
274
-
275
- // Grant issuer role to mint tokens
276
- await result.current.grantRolesSync.mutateAsync({
277
- token,
278
- roles: ['issuer'],
279
- to: account.address,
280
- })
281
-
282
- // Mint some tokens to account
283
- await result.current.mintTokenSync.mutateAsync({
284
- to: account.address,
285
- amount: parseUnits('1000', 6),
286
- token,
287
- })
288
-
289
- // Add liquidity to pool
290
- await result.current.mintSync.mutateAsync({
291
- userTokenAddress: token,
292
- validatorTokenAddress: addresses.alphaUsd,
293
- validatorTokenAmount: parseUnits('100', 6),
294
- to: account.address,
295
- })
296
-
297
- // TODO(TEMPO-1183): Remove this janky fix to get some user token in the pool
298
- await result.current.transferSync.mutateAsync({
299
- to: '0x30D861999070Ae03B9548501DBd573E11A9f59Ee',
300
- amount: 600n,
301
- token: token,
302
- feeToken: token,
303
- })
304
-
305
- const account2 = accounts[1]
306
-
307
- // Perform rebalance swap
308
- const data = await result.current.rebalanceSwapSync.mutateAsync({
309
- userToken: token,
310
- validatorToken: addresses.alphaUsd,
311
- amountOut: 100n,
312
- to: account2.address,
313
- })
314
-
315
- await vi.waitFor(() =>
316
- expect(result.current.rebalanceSwapSync.isSuccess).toBeTruthy(),
317
- )
318
-
319
- expect(data.receipt).toBeDefined()
320
- expect(data.amountOut).toBe(100n)
321
- expect(data.swapper).toBe(account.address)
322
- })
323
- })
324
-
325
- describe.skip('useWatchRebalanceSwap', () => {
326
- test('default', async () => {
327
- const { result: connectResult } = await renderHook(() => ({
328
- connect: useConnect(),
329
- createSync: tokenHooks.useCreateSync(),
330
- grantRolesSync: tokenHooks.useGrantRolesSync(),
331
- mintTokenSync: tokenHooks.useMintSync(),
332
- mintSync: hooks.useMintSync(),
333
- transferSync: tokenHooks.useTransferSync(),
334
- rebalanceSwapSync: hooks.useRebalanceSwapSync(),
335
- }))
336
-
337
- await connectResult.current.connect.connectAsync({
338
- connector: config.connectors[0]!,
339
- })
340
-
341
- // Create a new token for testing
342
- const { token } = await connectResult.current.createSync.mutateAsync({
343
- name: 'Test Token 3',
344
- symbol: 'TEST3',
345
- currency: 'USD',
346
- })
347
-
348
- // Grant issuer role to mint tokens
349
- await connectResult.current.grantRolesSync.mutateAsync({
350
- token,
351
- roles: ['issuer'],
352
- to: account.address,
353
- })
354
-
355
- // Mint some tokens to account
356
- await connectResult.current.mintTokenSync.mutateAsync({
357
- to: account.address,
358
- amount: parseUnits('1000', 6),
359
- token,
360
- })
361
-
362
- // Add liquidity to pool
363
- await connectResult.current.mintSync.mutateAsync({
364
- userTokenAddress: token,
365
- validatorTokenAddress: addresses.alphaUsd,
366
- validatorTokenAmount: parseUnits('100', 6),
367
- to: account.address,
368
- })
369
-
370
- // TODO(TEMPO-1183): Remove this janky fix to get some user token in the pool
371
- await connectResult.current.transferSync.mutateAsync({
372
- to: '0x30D861999070Ae03B9548501DBd573E11A9f59Ee',
373
- amount: 600n,
374
- token: token,
375
- feeToken: token,
376
- })
377
-
378
- const events: any[] = []
379
- await renderHook(() =>
380
- hooks.useWatchRebalanceSwap({
381
- onRebalanceSwap(args) {
382
- events.push(args)
383
- },
384
- }),
385
- )
386
-
387
- const account2 = accounts[1]
388
-
389
- // Perform rebalance swap
390
- await connectResult.current.rebalanceSwapSync.mutateAsync({
391
- userToken: token,
392
- validatorToken: addresses.alphaUsd,
393
- amountOut: 100n,
394
- to: account2.address,
395
- })
396
-
397
- await vi.waitUntil(() => events.length >= 1)
398
-
399
- expect(events.length).toBeGreaterThanOrEqual(1)
400
- expect(events[0]?.userToken.toLowerCase()).toBe(token.toLowerCase())
401
- expect(events[0]?.validatorToken.toLowerCase()).toBe(
402
- addresses.alphaUsd.toLowerCase(),
403
- )
404
- expect(events[0]?.amountOut).toBe(100n)
405
- })
406
- })
407
-
408
- describe('useWatchMint', () => {
409
- test('default', async () => {
410
- const { result: connectResult } = await renderHook(() => ({
411
- connect: useConnect(),
412
- createSync: tokenHooks.useCreateSync(),
413
- grantRolesSync: tokenHooks.useGrantRolesSync(),
414
- mintTokenSync: tokenHooks.useMintSync(),
415
- mintSync: hooks.useMintSync(),
416
- }))
417
-
418
- await connectResult.current.connect.connectAsync({
419
- connector: config.connectors[0]!,
420
- })
421
-
422
- // Create a new token for testing
423
- const { token } = await connectResult.current.createSync.mutateAsync({
424
- name: 'Test Token 2',
425
- symbol: 'TEST2',
426
- currency: 'USD',
427
- })
428
-
429
- // Grant issuer role to mint tokens
430
- await connectResult.current.grantRolesSync.mutateAsync({
431
- token,
432
- roles: ['issuer'],
433
- to: account.address,
434
- })
435
-
436
- // Mint some tokens to account
437
- await connectResult.current.mintTokenSync.mutateAsync({
438
- to: account.address,
439
- amount: parseUnits('1000', 6),
440
- token,
441
- })
442
-
443
- const events: any[] = []
444
- await renderHook(() =>
445
- hooks.useWatchMint({
446
- onMint(args) {
447
- events.push(args)
448
- },
449
- }),
450
- )
451
-
452
- // Add liquidity to pool
453
- await connectResult.current.mintSync.mutateAsync({
454
- userTokenAddress: token,
455
- validatorTokenAddress: addresses.alphaUsd,
456
- validatorTokenAmount: parseUnits('100', 6),
457
- to: account.address,
458
- })
459
-
460
- await vi.waitUntil(() => events.length >= 1)
461
-
462
- expect(events.length).toBeGreaterThanOrEqual(1)
463
- expect(events[0]?.userToken.address.toLowerCase()).toBe(token.toLowerCase())
464
- expect(events[0]?.validatorToken.address.toLowerCase()).toBe(
465
- addresses.alphaUsd.toLowerCase(),
466
- )
467
- expect(events[0]?.validatorToken.amount).toBe(parseUnits('100', 6))
468
- })
469
- })
470
-
471
- describe.skip('useWatchBurn', () => {
472
- test('default', async () => {
473
- const { result: connectResult } = await renderHook(() => ({
474
- connect: useConnect(),
475
- createSync: tokenHooks.useCreateSync(),
476
- grantRolesSync: tokenHooks.useGrantRolesSync(),
477
- mintTokenSync: tokenHooks.useMintSync(),
478
- mintSync: hooks.useMintSync(),
479
- burnSync: hooks.useBurnSync(),
480
- transferSync: tokenHooks.useTransferSync(),
481
- getLiquidityBalance: hooks.useLiquidityBalance,
482
- }))
483
-
484
- await connectResult.current.connect.connectAsync({
485
- connector: config.connectors[0]!,
486
- })
487
-
488
- // Create a new token for testing
489
- const { token } = await connectResult.current.createSync.mutateAsync({
490
- name: 'Test Token 4',
491
- symbol: 'TEST4',
492
- currency: 'USD',
493
- })
494
-
495
- // Grant issuer role to mint tokens
496
- await connectResult.current.grantRolesSync.mutateAsync({
497
- token,
498
- roles: ['issuer'],
499
- to: account.address,
500
- })
501
-
502
- // Mint some tokens to account
503
- await connectResult.current.mintTokenSync.mutateAsync({
504
- to: account.address,
505
- amount: parseUnits('1000', 6),
506
- token,
507
- })
508
-
509
- // Add liquidity to pool
510
- await connectResult.current.mintSync.mutateAsync({
511
- userTokenAddress: token,
512
- validatorTokenAddress: addresses.alphaUsd,
513
- validatorTokenAmount: parseUnits('100', 6),
514
- to: account.address,
515
- })
516
-
517
- // TODO(TEMPO-1183): Remove this janky fix to get some user token in the pool
518
- await connectResult.current.transferSync.mutateAsync({
519
- to: '0x30D861999070Ae03B9548501DBd573E11A9f59Ee',
520
- amount: 600n,
521
- token: token,
522
- feeToken: token,
523
- })
524
-
525
- // Get LP balance
526
- const { result: balanceResult } = await renderHook(() =>
527
- connectResult.current.getLiquidityBalance({
528
- userToken: token,
529
- validatorToken: addresses.alphaUsd,
530
- address: account.address,
531
- }),
532
- )
533
-
534
- await vi.waitFor(() => expect(balanceResult.current.isSuccess).toBeTruthy())
535
-
536
- const lpBalance = balanceResult.current.data!
537
-
538
- const events: any[] = []
539
- await renderHook(() =>
540
- hooks.useWatchBurn({
541
- onBurn(args) {
542
- events.push(args)
543
- },
544
- }),
545
- )
546
-
547
- // Burn LP tokens
548
- await connectResult.current.burnSync.mutateAsync({
549
- userToken: token,
550
- validatorToken: addresses.alphaUsd,
551
- liquidity: lpBalance / 2n,
552
- to: account.address,
553
- })
554
-
555
- await vi.waitUntil(() => events.length >= 1)
556
-
557
- expect(events.length).toBeGreaterThanOrEqual(1)
558
- expect(events[0]?.userToken.toLowerCase()).toBe(token.toLowerCase())
559
- expect(events[0]?.validatorToken.toLowerCase()).toBe(
560
- addresses.alphaUsd.toLowerCase(),
561
- )
562
- expect(events[0]?.liquidity).toBe(lpBalance / 2n)
563
- })
564
- })