tempo.ts 0.4.4 → 0.5.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 (39) hide show
  1. package/README.md +2 -3
  2. package/dist/chains.d.ts +15 -1
  3. package/dist/chains.d.ts.map +1 -1
  4. package/dist/chains.js +2 -1
  5. package/dist/chains.js.map +1 -1
  6. package/dist/prool/Instance.d.ts +12 -4
  7. package/dist/prool/Instance.d.ts.map +1 -1
  8. package/dist/prool/Instance.js +34 -18
  9. package/dist/prool/Instance.js.map +1 -1
  10. package/dist/viem/Actions/faucet.d.ts +34 -1
  11. package/dist/viem/Actions/faucet.d.ts.map +1 -1
  12. package/dist/viem/Actions/faucet.js +35 -0
  13. package/dist/viem/Actions/faucet.js.map +1 -1
  14. package/dist/viem/Chain.d.ts +6 -0
  15. package/dist/viem/Chain.d.ts.map +1 -1
  16. package/dist/viem/Transaction.d.ts +4 -1
  17. package/dist/viem/Transaction.d.ts.map +1 -1
  18. package/dist/viem/Transaction.js.map +1 -1
  19. package/package.json +1 -1
  20. package/src/chains.ts +2 -1
  21. package/src/ox/TransactionEnvelopeAA.test.ts +2 -663
  22. package/src/ox/e2e.test.ts +659 -0
  23. package/src/prool/Instance.ts +51 -23
  24. package/src/tsconfig.json +2 -2
  25. package/src/viem/Actions/amm.test.ts +68 -58
  26. package/src/viem/Actions/dex.test.ts +339 -283
  27. package/src/viem/Actions/faucet.ts +63 -1
  28. package/src/viem/Actions/fee.test.ts +34 -43
  29. package/src/viem/Actions/policy.test.ts +115 -81
  30. package/src/viem/Actions/reward.test.ts +92 -74
  31. package/src/viem/Actions/token.test.ts +691 -529
  32. package/src/viem/Transaction.ts +4 -1
  33. package/src/viem/e2e.test.ts +451 -472
  34. package/src/wagmi/Actions/amm.test.ts +2 -5
  35. package/src/wagmi/Actions/dex.test.ts +2 -1
  36. package/src/wagmi/Actions/token.test.ts +2 -1
  37. package/src/wagmi/Hooks/amm.test.ts +2 -5
  38. package/src/wagmi/Hooks/dex.test.ts +2 -1
  39. package/src/wagmi/Hooks/token.test.ts +2 -1
@@ -4,17 +4,17 @@ import { parseUnits } from 'viem'
4
4
  import { beforeAll, describe, expect, test } from 'vitest'
5
5
  import {
6
6
  accounts,
7
- client,
7
+ clientWithAccount,
8
8
  setupOrders,
9
9
  setupTokenPair,
10
10
  } from '../../../test/viem/config.js'
11
11
 
12
12
  describe('buy', () => {
13
13
  test('default', async () => {
14
- const { base, quote } = await setupTokenPair(client)
14
+ const { base, quote } = await setupTokenPair(clientWithAccount)
15
15
 
16
16
  // Place ask order to create liquidity
17
- await Actions.dex.placeSync(client, {
17
+ await Actions.dex.placeSync(clientWithAccount, {
18
18
  token: base,
19
19
  amount: parseUnits('500', 6),
20
20
  type: 'sell',
@@ -22,12 +22,15 @@ describe('buy', () => {
22
22
  })
23
23
 
24
24
  // Get initial balances
25
- const baseBalanceBefore = await Actions.token.getBalance(client, {
26
- token: base,
27
- })
25
+ const baseBalanceBefore = await Actions.token.getBalance(
26
+ clientWithAccount,
27
+ {
28
+ token: base,
29
+ },
30
+ )
28
31
 
29
32
  // Buy base tokens with quote tokens
30
- const { receipt } = await Actions.dex.buySync(client, {
33
+ const { receipt } = await Actions.dex.buySync(clientWithAccount, {
31
34
  tokenIn: quote,
32
35
  tokenOut: base,
33
36
  amountOut: parseUnits('100', 6),
@@ -38,7 +41,7 @@ describe('buy', () => {
38
41
  expect(receipt.status).toBe('success')
39
42
 
40
43
  // Verify balances changed
41
- const baseBalanceAfter = await Actions.token.getBalance(client, {
44
+ const baseBalanceAfter = await Actions.token.getBalance(clientWithAccount, {
42
45
  token: base,
43
46
  })
44
47
 
@@ -47,10 +50,10 @@ describe('buy', () => {
47
50
  })
48
51
 
49
52
  test('behavior: respects maxAmountIn', async () => {
50
- const { base, quote } = await setupTokenPair(client)
53
+ const { base, quote } = await setupTokenPair(clientWithAccount)
51
54
 
52
55
  // Place ask order at high price
53
- await Actions.dex.placeSync(client, {
56
+ await Actions.dex.placeSync(clientWithAccount, {
54
57
  token: base,
55
58
  amount: parseUnits('500', 6),
56
59
  type: 'sell',
@@ -59,7 +62,7 @@ describe('buy', () => {
59
62
 
60
63
  // Try to buy with insufficient maxAmountIn - should fail
61
64
  await expect(
62
- Actions.dex.buySync(client, {
65
+ Actions.dex.buySync(clientWithAccount, {
63
66
  tokenIn: quote,
64
67
  tokenOut: base,
65
68
  amountOut: parseUnits('100', 6),
@@ -69,13 +72,13 @@ describe('buy', () => {
69
72
  })
70
73
 
71
74
  test('behavior: fails with insufficient liquidity', async () => {
72
- const { base, quote } = await setupTokenPair(client)
75
+ const { base, quote } = await setupTokenPair(clientWithAccount)
73
76
 
74
77
  // Don't place any orders - no liquidity
75
78
 
76
79
  // Try to buy - should fail due to no liquidity
77
80
  await expect(
78
- Actions.dex.buySync(client, {
81
+ Actions.dex.buySync(clientWithAccount, {
79
82
  tokenIn: quote,
80
83
  tokenOut: base,
81
84
  amountOut: parseUnits('100', 6),
@@ -87,10 +90,10 @@ describe('buy', () => {
87
90
 
88
91
  describe('cancel', () => {
89
92
  test('default', async () => {
90
- const { base, quote } = await setupTokenPair(client)
93
+ const { base, quote } = await setupTokenPair(clientWithAccount)
91
94
 
92
95
  // Place a bid order
93
- const { orderId } = await Actions.dex.placeSync(client, {
96
+ const { orderId } = await Actions.dex.placeSync(clientWithAccount, {
94
97
  token: base,
95
98
  amount: parseUnits('100', 6),
96
99
  type: 'buy',
@@ -98,15 +101,15 @@ describe('cancel', () => {
98
101
  })
99
102
 
100
103
  // Check initial DEX balance (should be 0)
101
- const dexBalanceBefore = await Actions.dex.getBalance(client, {
102
- account: client.account.address,
104
+ const dexBalanceBefore = await Actions.dex.getBalance(clientWithAccount, {
105
+ account: clientWithAccount.account.address,
103
106
  token: quote,
104
107
  })
105
108
  expect(dexBalanceBefore).toBe(0n)
106
109
 
107
110
  // Cancel the order
108
111
  const { receipt, orderId: returnedOrderId } = await Actions.dex.cancelSync(
109
- client,
112
+ clientWithAccount,
110
113
  {
111
114
  orderId,
112
115
  },
@@ -117,18 +120,18 @@ describe('cancel', () => {
117
120
  expect(returnedOrderId).toBe(orderId)
118
121
 
119
122
  // Check DEX balance after cancel - tokens should be refunded to internal balance
120
- const dexBalanceAfter = await Actions.dex.getBalance(client, {
121
- account: client.account.address,
123
+ const dexBalanceAfter = await Actions.dex.getBalance(clientWithAccount, {
124
+ account: clientWithAccount.account.address,
122
125
  token: quote,
123
126
  })
124
127
  expect(dexBalanceAfter).toBeGreaterThan(0n)
125
128
  })
126
129
 
127
130
  test('behavior: only maker can cancel', async () => {
128
- const { base } = await setupTokenPair(client)
131
+ const { base } = await setupTokenPair(clientWithAccount)
129
132
 
130
133
  // Account places order
131
- const { orderId } = await Actions.dex.placeSync(client, {
134
+ const { orderId } = await Actions.dex.placeSync(clientWithAccount, {
132
135
  token: base,
133
136
  amount: parseUnits('100', 6),
134
137
  type: 'buy',
@@ -139,7 +142,7 @@ describe('cancel', () => {
139
142
  const account2 = accounts[1]
140
143
 
141
144
  // Transfer gas to account2
142
- await Actions.token.transferSync(client, {
145
+ await Actions.token.transferSync(clientWithAccount, {
143
146
  to: account2.address,
144
147
  amount: parseUnits('1', 6),
145
148
  token: 1n,
@@ -147,7 +150,7 @@ describe('cancel', () => {
147
150
 
148
151
  // Account2 tries to cancel - should fail
149
152
  await expect(
150
- Actions.dex.cancelSync(client, {
153
+ Actions.dex.cancelSync(clientWithAccount, {
151
154
  account: account2,
152
155
  orderId,
153
156
  }),
@@ -155,11 +158,11 @@ describe('cancel', () => {
155
158
  })
156
159
 
157
160
  test('behavior: cannot cancel non-existent order', async () => {
158
- await setupTokenPair(client)
161
+ await setupTokenPair(clientWithAccount)
159
162
 
160
163
  // Try to cancel an order that doesn't exist
161
164
  await expect(
162
- Actions.dex.cancelSync(client, {
165
+ Actions.dex.cancelSync(clientWithAccount, {
163
166
  orderId: 999n,
164
167
  }),
165
168
  ).rejects.toThrow('The contract function "cancel" reverted')
@@ -168,14 +171,17 @@ describe('cancel', () => {
168
171
 
169
172
  describe('createPair', () => {
170
173
  test('default', async () => {
171
- const { token: baseToken } = await Actions.token.createSync(client, {
172
- name: 'Test Base Token',
173
- symbol: 'BASE',
174
- currency: 'USD',
175
- })
174
+ const { token: baseToken } = await Actions.token.createSync(
175
+ clientWithAccount,
176
+ {
177
+ name: 'Test Base Token',
178
+ symbol: 'BASE',
179
+ currency: 'USD',
180
+ },
181
+ )
176
182
 
177
183
  const { receipt, key, base, quote } = await Actions.dex.createPairSync(
178
- client,
184
+ clientWithAccount,
179
185
  {
180
186
  base: baseToken,
181
187
  },
@@ -191,42 +197,42 @@ describe('createPair', () => {
191
197
 
192
198
  describe('getBalance', () => {
193
199
  test('default', async () => {
194
- const { base, quote } = await setupTokenPair(client)
200
+ const { base, quote } = await setupTokenPair(clientWithAccount)
195
201
 
196
202
  // Initial balance should be 0
197
- const initialBalance = await Actions.dex.getBalance(client, {
198
- account: client.account.address,
203
+ const initialBalance = await Actions.dex.getBalance(clientWithAccount, {
204
+ account: clientWithAccount.account.address,
199
205
  token: quote,
200
206
  })
201
207
  expect(initialBalance).toBe(0n)
202
208
 
203
209
  // Place and cancel order to create internal balance
204
- const { orderId } = await Actions.dex.placeSync(client, {
210
+ const { orderId } = await Actions.dex.placeSync(clientWithAccount, {
205
211
  token: base,
206
212
  amount: parseUnits('50', 6),
207
213
  type: 'buy',
208
214
  tick: Tick.fromPrice('1.0005'),
209
215
  })
210
216
 
211
- await Actions.dex.cancelSync(client, {
217
+ await Actions.dex.cancelSync(clientWithAccount, {
212
218
  orderId,
213
219
  })
214
220
 
215
221
  // Now balance should be > 0 (refunded quote tokens)
216
- const balance = await Actions.dex.getBalance(client, {
217
- account: client.account.address,
222
+ const balance = await Actions.dex.getBalance(clientWithAccount, {
223
+ account: clientWithAccount.account.address,
218
224
  token: quote,
219
225
  })
220
226
  expect(balance).toBeGreaterThan(0n)
221
227
  })
222
228
 
223
229
  test('behavior: check different account', async () => {
224
- const { quote } = await setupTokenPair(client)
230
+ const { quote } = await setupTokenPair(clientWithAccount)
225
231
 
226
232
  const account2 = accounts[1]
227
233
 
228
234
  // Check account2's balance (should be 0)
229
- const balance = await Actions.dex.getBalance(client, {
235
+ const balance = await Actions.dex.getBalance(clientWithAccount, {
230
236
  account: account2.address,
231
237
  token: quote,
232
238
  })
@@ -234,27 +240,27 @@ describe('getBalance', () => {
234
240
  })
235
241
 
236
242
  test('behavior: balances are per-token', async () => {
237
- const { base, quote } = await setupTokenPair(client)
243
+ const { base, quote } = await setupTokenPair(clientWithAccount)
238
244
 
239
245
  // Create balance in quote token
240
- const { orderId } = await Actions.dex.placeSync(client, {
246
+ const { orderId } = await Actions.dex.placeSync(clientWithAccount, {
241
247
  token: base,
242
248
  amount: parseUnits('100', 6),
243
249
  type: 'buy',
244
250
  tick: Tick.fromPrice('1.001'),
245
251
  })
246
- await Actions.dex.cancelSync(client, { orderId })
252
+ await Actions.dex.cancelSync(clientWithAccount, { orderId })
247
253
 
248
254
  // Check quote balance (should have refunded tokens)
249
- const quoteBalance = await Actions.dex.getBalance(client, {
250
- account: client.account.address,
255
+ const quoteBalance = await Actions.dex.getBalance(clientWithAccount, {
256
+ account: clientWithAccount.account.address,
251
257
  token: quote,
252
258
  })
253
259
  expect(quoteBalance).toBeGreaterThan(0n)
254
260
 
255
261
  // Check base balance (should still be 0)
256
- const baseBalance = await Actions.dex.getBalance(client, {
257
- account: client.account.address,
262
+ const baseBalance = await Actions.dex.getBalance(clientWithAccount, {
263
+ account: clientWithAccount.account.address,
258
264
  token: base,
259
265
  })
260
266
  expect(baseBalance).toBe(0n)
@@ -263,10 +269,10 @@ describe('getBalance', () => {
263
269
 
264
270
  describe('getBuyQuote', () => {
265
271
  test('default', async () => {
266
- const { base, quote } = await setupTokenPair(client)
272
+ const { base, quote } = await setupTokenPair(clientWithAccount)
267
273
 
268
274
  // Place ask orders to create liquidity
269
- await Actions.dex.placeSync(client, {
275
+ await Actions.dex.placeSync(clientWithAccount, {
270
276
  token: base,
271
277
  amount: parseUnits('500', 6),
272
278
  type: 'sell',
@@ -274,7 +280,7 @@ describe('getBuyQuote', () => {
274
280
  })
275
281
 
276
282
  // Get quote for buying base tokens
277
- const amountIn = await Actions.dex.getBuyQuote(client, {
283
+ const amountIn = await Actions.dex.getBuyQuote(clientWithAccount, {
278
284
  tokenIn: quote,
279
285
  tokenOut: base,
280
286
  amountOut: parseUnits('100', 6),
@@ -286,13 +292,13 @@ describe('getBuyQuote', () => {
286
292
  })
287
293
 
288
294
  test('behavior: fails with no liquidity', async () => {
289
- const { base, quote } = await setupTokenPair(client)
295
+ const { base, quote } = await setupTokenPair(clientWithAccount)
290
296
 
291
297
  // No orders placed - no liquidity
292
298
 
293
299
  // Quote should fail
294
300
  await expect(
295
- Actions.dex.getBuyQuote(client, {
301
+ Actions.dex.getBuyQuote(clientWithAccount, {
296
302
  tokenIn: quote,
297
303
  tokenOut: base,
298
304
  amountOut: parseUnits('100', 6),
@@ -305,10 +311,10 @@ describe('getBuyQuote', () => {
305
311
 
306
312
  describe('getOrder', () => {
307
313
  test('default', async () => {
308
- const { base } = await setupTokenPair(client)
314
+ const { base } = await setupTokenPair(clientWithAccount)
309
315
 
310
316
  // Place an order to get an order ID
311
- const { orderId } = await Actions.dex.placeSync(client, {
317
+ const { orderId } = await Actions.dex.placeSync(clientWithAccount, {
312
318
  token: base,
313
319
  amount: parseUnits('100', 6),
314
320
  type: 'buy',
@@ -316,12 +322,12 @@ describe('getOrder', () => {
316
322
  })
317
323
 
318
324
  // Get the order details
319
- const order = await Actions.dex.getOrder(client, {
325
+ const order = await Actions.dex.getOrder(clientWithAccount, {
320
326
  orderId,
321
327
  })
322
328
 
323
329
  expect(order).toBeDefined()
324
- expect(order.maker).toBe(client.account.address)
330
+ expect(order.maker).toBe(clientWithAccount.account.address)
325
331
  expect(order.isBid).toBe(true)
326
332
  expect(order.tick).toBe(Tick.fromPrice('1.001'))
327
333
  expect(order.amount).toBe(parseUnits('100', 6))
@@ -330,10 +336,10 @@ describe('getOrder', () => {
330
336
  })
331
337
 
332
338
  test('behavior: returns flip order details', async () => {
333
- const { base } = await setupTokenPair(client)
339
+ const { base } = await setupTokenPair(clientWithAccount)
334
340
 
335
341
  // Place a flip order
336
- const { orderId } = await Actions.dex.placeFlipSync(client, {
342
+ const { orderId } = await Actions.dex.placeFlipSync(clientWithAccount, {
337
343
  token: base,
338
344
  amount: parseUnits('50', 6),
339
345
  type: 'buy',
@@ -342,12 +348,12 @@ describe('getOrder', () => {
342
348
  })
343
349
 
344
350
  // Get the order details
345
- const order = await Actions.dex.getOrder(client, {
351
+ const order = await Actions.dex.getOrder(clientWithAccount, {
346
352
  orderId,
347
353
  })
348
354
 
349
355
  expect(order).toBeDefined()
350
- expect(order.maker).toBe(client.account.address)
356
+ expect(order.maker).toBe(clientWithAccount.account.address)
351
357
  expect(order.isBid).toBe(true)
352
358
  expect(order.tick).toBe(Tick.fromPrice('1.001'))
353
359
  expect(order.amount).toBe(parseUnits('50', 6))
@@ -356,21 +362,21 @@ describe('getOrder', () => {
356
362
  })
357
363
 
358
364
  test('behavior: fails for non-existent order', async () => {
359
- await setupTokenPair(client)
365
+ await setupTokenPair(clientWithAccount)
360
366
 
361
367
  // Try to get an order that doesn't exist
362
368
  await expect(
363
- Actions.dex.getOrder(client, {
369
+ Actions.dex.getOrder(clientWithAccount, {
364
370
  orderId: 999n,
365
371
  }),
366
372
  ).rejects.toThrow('The contract function "getOrder" reverted')
367
373
  })
368
374
 
369
375
  test('behavior: reflects order state after partial fill', async () => {
370
- const { base, quote } = await setupTokenPair(client)
376
+ const { base, quote } = await setupTokenPair(clientWithAccount)
371
377
 
372
378
  // Place a large sell order
373
- const { orderId } = await Actions.dex.placeSync(client, {
379
+ const { orderId } = await Actions.dex.placeSync(clientWithAccount, {
374
380
  token: base,
375
381
  amount: parseUnits('500', 6),
376
382
  type: 'sell',
@@ -378,14 +384,14 @@ describe('getOrder', () => {
378
384
  })
379
385
 
380
386
  // Get initial order state
381
- const orderBefore = await Actions.dex.getOrder(client, {
387
+ const orderBefore = await Actions.dex.getOrder(clientWithAccount, {
382
388
  orderId,
383
389
  })
384
390
  expect(orderBefore.amount).toBe(parseUnits('500', 6))
385
391
  expect(orderBefore.remaining).toBe(parseUnits('500', 6))
386
392
 
387
393
  // Partially fill the order with a buy
388
- await Actions.dex.buySync(client, {
394
+ await Actions.dex.buySync(clientWithAccount, {
389
395
  tokenIn: quote,
390
396
  tokenOut: base,
391
397
  amountOut: parseUnits('100', 6),
@@ -393,7 +399,7 @@ describe('getOrder', () => {
393
399
  })
394
400
 
395
401
  // Get order state after partial fill
396
- const orderAfter = await Actions.dex.getOrder(client, {
402
+ const orderAfter = await Actions.dex.getOrder(clientWithAccount, {
397
403
  orderId,
398
404
  })
399
405
  expect(orderAfter.amount).toBe(parseUnits('500', 6)) // amount unchanged
@@ -401,35 +407,41 @@ describe('getOrder', () => {
401
407
  })
402
408
 
403
409
  test('behavior: linked list pointers for multiple orders at same tick', async () => {
404
- const { base } = await setupTokenPair(client)
410
+ const { base } = await setupTokenPair(clientWithAccount)
405
411
 
406
412
  const tick = Tick.fromPrice('1.001')
407
413
 
408
414
  // Place first order
409
- const { orderId: orderId1 } = await Actions.dex.placeSync(client, {
410
- token: base,
411
- amount: parseUnits('100', 6),
412
- type: 'buy',
413
- tick,
414
- })
415
+ const { orderId: orderId1 } = await Actions.dex.placeSync(
416
+ clientWithAccount,
417
+ {
418
+ token: base,
419
+ amount: parseUnits('100', 6),
420
+ type: 'buy',
421
+ tick,
422
+ },
423
+ )
415
424
 
416
425
  // Place second order at same tick
417
- const { orderId: orderId2 } = await Actions.dex.placeSync(client, {
418
- token: base,
419
- amount: parseUnits('50', 6),
420
- type: 'buy',
421
- tick,
422
- })
426
+ const { orderId: orderId2 } = await Actions.dex.placeSync(
427
+ clientWithAccount,
428
+ {
429
+ token: base,
430
+ amount: parseUnits('50', 6),
431
+ type: 'buy',
432
+ tick,
433
+ },
434
+ )
423
435
 
424
436
  // Get first order
425
- const order1 = await Actions.dex.getOrder(client, {
437
+ const order1 = await Actions.dex.getOrder(clientWithAccount, {
426
438
  orderId: orderId1,
427
439
  })
428
440
  expect(order1.prev).toBe(0n) // should be 0 as it's first
429
441
  expect(order1.next).toBe(orderId2) // should point to second order
430
442
 
431
443
  // Get second order
432
- const order2 = await Actions.dex.getOrder(client, {
444
+ const order2 = await Actions.dex.getOrder(clientWithAccount, {
433
445
  orderId: orderId2,
434
446
  })
435
447
  expect(order2.prev).toBe(orderId1) // should point to first order
@@ -440,19 +452,19 @@ describe('getOrder', () => {
440
452
  describe('getOrders', () => {
441
453
  let bases: Address.Address[] = []
442
454
  beforeAll(async () => {
443
- ;({ bases } = await setupOrders(client))
455
+ ;({ bases } = await setupOrders(clientWithAccount))
444
456
  })
445
457
 
446
458
  test('default', async () => {
447
459
  // Get orders with default pagination
448
- const response = await Actions.dex.getOrders(client, {
460
+ const response = await Actions.dex.getOrders(clientWithAccount, {
449
461
  limit: 10,
450
462
  })
451
463
 
452
464
  expect(response).matchSnapshot()
453
465
 
454
466
  // Get orders with cursor
455
- const response2 = await Actions.dex.getOrders(client, {
467
+ const response2 = await Actions.dex.getOrders(clientWithAccount, {
456
468
  cursor: response.nextCursor!,
457
469
  limit: 10,
458
470
  })
@@ -462,7 +474,7 @@ describe('getOrders', () => {
462
474
 
463
475
  test.skip('behavior: filter by baseToken', async () => {
464
476
  // Get orders filtered by base1
465
- const response = await Actions.dex.getOrders(client, {
477
+ const response = await Actions.dex.getOrders(clientWithAccount, {
466
478
  filters: {
467
479
  baseToken: bases[0],
468
480
  },
@@ -480,7 +492,7 @@ describe('getOrders', () => {
480
492
 
481
493
  test('behavior: filter by isBid', async () => {
482
494
  // Get only buy orders
483
- const buyOrders = await Actions.dex.getOrders(client, {
495
+ const buyOrders = await Actions.dex.getOrders(clientWithAccount, {
484
496
  filters: {
485
497
  isBid: true,
486
498
  },
@@ -494,7 +506,7 @@ describe('getOrders', () => {
494
506
  expect(buyOrders).matchSnapshot()
495
507
 
496
508
  // Get only sell orders
497
- const sellOrders = await Actions.dex.getOrders(client, {
509
+ const sellOrders = await Actions.dex.getOrders(clientWithAccount, {
498
510
  filters: {
499
511
  isBid: false,
500
512
  },
@@ -510,9 +522,9 @@ describe('getOrders', () => {
510
522
 
511
523
  test('behavior: filter by maker', async () => {
512
524
  // Filter by account's address
513
- const response = await Actions.dex.getOrders(client, {
525
+ const response = await Actions.dex.getOrders(clientWithAccount, {
514
526
  filters: {
515
- maker: client.account.address,
527
+ maker: clientWithAccount.account.address,
516
528
  },
517
529
  limit: 5,
518
530
  })
@@ -521,7 +533,7 @@ describe('getOrders', () => {
521
533
  expect(response.orders.length).toBeGreaterThan(0)
522
534
  expect(
523
535
  response.orders.every((order) =>
524
- Address.isEqual(order.maker, client.account.address),
536
+ Address.isEqual(order.maker, clientWithAccount.account.address),
525
537
  ),
526
538
  ).toBe(true)
527
539
 
@@ -530,7 +542,7 @@ describe('getOrders', () => {
530
542
 
531
543
  test('behavior: filter by isFlip', async () => {
532
544
  // Get only non-flip orders (setupOrders creates non-flip orders)
533
- const response = await Actions.dex.getOrders(client, {
545
+ const response = await Actions.dex.getOrders(clientWithAccount, {
534
546
  filters: {
535
547
  isFlip: false,
536
548
  },
@@ -546,7 +558,7 @@ describe('getOrders', () => {
546
558
 
547
559
  test('behavior: filter by remaining range', async () => {
548
560
  // Get orders with remaining between 100 and 300
549
- const response = await Actions.dex.getOrders(client, {
561
+ const response = await Actions.dex.getOrders(clientWithAccount, {
550
562
  filters: {
551
563
  remaining: {
552
564
  min: parseUnits('100', 6),
@@ -571,7 +583,7 @@ describe('getOrders', () => {
571
583
 
572
584
  test('behavior: filter by tick range', async () => {
573
585
  // Get orders with tick between -100 and 100
574
- const response = await Actions.dex.getOrders(client, {
586
+ const response = await Actions.dex.getOrders(clientWithAccount, {
575
587
  filters: {
576
588
  tick: {
577
589
  min: -100,
@@ -592,7 +604,7 @@ describe('getOrders', () => {
592
604
 
593
605
  test('behavior: multiple filters combined', async () => {
594
606
  // Filter by multiple conditions
595
- const response = await Actions.dex.getOrders(client, {
607
+ const response = await Actions.dex.getOrders(clientWithAccount, {
596
608
  filters: {
597
609
  baseToken: bases[0],
598
610
  isBid: true,
@@ -612,10 +624,10 @@ describe('getOrders', () => {
612
624
  })
613
625
 
614
626
  test('behavior: empty result', async () => {
615
- await setupTokenPair(client)
627
+ await setupTokenPair(clientWithAccount)
616
628
 
617
629
  // Get orders with filter that matches nothing
618
- const response = await Actions.dex.getOrders(client, {
630
+ const response = await Actions.dex.getOrders(clientWithAccount, {
619
631
  filters: {
620
632
  maker: '0x0000000000000000000000000000000000000001',
621
633
  },
@@ -631,10 +643,10 @@ describe('getOrders', () => {
631
643
 
632
644
  describe('getOrderbook', () => {
633
645
  test('default', async () => {
634
- const { base, quote } = await setupTokenPair(client)
646
+ const { base, quote } = await setupTokenPair(clientWithAccount)
635
647
 
636
648
  // Get orderbook information
637
- const book = await Actions.dex.getOrderbook(client, {
649
+ const book = await Actions.dex.getOrderbook(clientWithAccount, {
638
650
  base,
639
651
  quote,
640
652
  })
@@ -647,13 +659,13 @@ describe('getOrderbook', () => {
647
659
  })
648
660
 
649
661
  test('behavior: shows best bid and ask after orders placed', async () => {
650
- const { base, quote } = await setupTokenPair(client)
662
+ const { base, quote } = await setupTokenPair(clientWithAccount)
651
663
 
652
664
  const bidTick = Tick.fromPrice('0.999')
653
665
  const askTick = Tick.fromPrice('1.001')
654
666
 
655
667
  // Place a bid order
656
- await Actions.dex.placeSync(client, {
668
+ await Actions.dex.placeSync(clientWithAccount, {
657
669
  token: base,
658
670
  amount: parseUnits('100', 6),
659
671
  type: 'buy',
@@ -661,7 +673,7 @@ describe('getOrderbook', () => {
661
673
  })
662
674
 
663
675
  // Place an ask order
664
- await Actions.dex.placeSync(client, {
676
+ await Actions.dex.placeSync(clientWithAccount, {
665
677
  token: base,
666
678
  amount: parseUnits('100', 6),
667
679
  type: 'sell',
@@ -669,7 +681,7 @@ describe('getOrderbook', () => {
669
681
  })
670
682
 
671
683
  // Get orderbook
672
- const book = await Actions.dex.getOrderbook(client, {
684
+ const book = await Actions.dex.getOrderbook(clientWithAccount, {
673
685
  base,
674
686
  quote,
675
687
  })
@@ -679,10 +691,10 @@ describe('getOrderbook', () => {
679
691
  })
680
692
 
681
693
  test('behavior: best ticks update after better orders placed', async () => {
682
- const { base, quote } = await setupTokenPair(client)
694
+ const { base, quote } = await setupTokenPair(clientWithAccount)
683
695
 
684
696
  // Place initial bid at 0.999
685
- await Actions.dex.placeSync(client, {
697
+ await Actions.dex.placeSync(clientWithAccount, {
686
698
  token: base,
687
699
  amount: parseUnits('100', 6),
688
700
  type: 'buy',
@@ -690,14 +702,14 @@ describe('getOrderbook', () => {
690
702
  })
691
703
 
692
704
  // Get orderbook
693
- const bookBefore = await Actions.dex.getOrderbook(client, {
705
+ const bookBefore = await Actions.dex.getOrderbook(clientWithAccount, {
694
706
  base,
695
707
  quote,
696
708
  })
697
709
  expect(bookBefore.bestBidTick).toBe(Tick.fromPrice('0.999'))
698
710
 
699
711
  // Place better bid at 1.0
700
- await Actions.dex.placeSync(client, {
712
+ await Actions.dex.placeSync(clientWithAccount, {
701
713
  token: base,
702
714
  amount: parseUnits('100', 6),
703
715
  type: 'buy',
@@ -705,7 +717,7 @@ describe('getOrderbook', () => {
705
717
  })
706
718
 
707
719
  // Get orderbook again
708
- const bookAfter = await Actions.dex.getOrderbook(client, {
720
+ const bookAfter = await Actions.dex.getOrderbook(clientWithAccount, {
709
721
  base,
710
722
  quote,
711
723
  })
@@ -713,17 +725,17 @@ describe('getOrderbook', () => {
713
725
  })
714
726
 
715
727
  test.skip('behavior: best ticks update after order cancellation', async () => {
716
- const { base, quote } = await setupTokenPair(client)
728
+ const { base, quote } = await setupTokenPair(clientWithAccount)
717
729
 
718
730
  // Place two bid orders at different ticks
719
- await Actions.dex.placeSync(client, {
731
+ await Actions.dex.placeSync(clientWithAccount, {
720
732
  token: base,
721
733
  amount: parseUnits('50', 6),
722
734
  type: 'buy',
723
735
  tick: Tick.fromPrice('0.999'),
724
736
  })
725
737
 
726
- const { orderId } = await Actions.dex.placeSync(client, {
738
+ const { orderId } = await Actions.dex.placeSync(clientWithAccount, {
727
739
  token: base,
728
740
  amount: parseUnits('100', 6),
729
741
  type: 'buy',
@@ -731,17 +743,17 @@ describe('getOrderbook', () => {
731
743
  })
732
744
 
733
745
  // Get orderbook - best bid should be 1.0
734
- const bookBefore = await Actions.dex.getOrderbook(client, {
746
+ const bookBefore = await Actions.dex.getOrderbook(clientWithAccount, {
735
747
  base,
736
748
  quote,
737
749
  })
738
750
  expect(bookBefore.bestBidTick).toBe(Tick.fromPrice('1.0'))
739
751
 
740
752
  // Cancel the better order
741
- await Actions.dex.cancelSync(client, { orderId })
753
+ await Actions.dex.cancelSync(clientWithAccount, { orderId })
742
754
 
743
755
  // Get orderbook again - best bid should fall back to 0.999
744
- const bookAfter = await Actions.dex.getOrderbook(client, {
756
+ const bookAfter = await Actions.dex.getOrderbook(clientWithAccount, {
745
757
  base,
746
758
  quote,
747
759
  })
@@ -749,11 +761,13 @@ describe('getOrderbook', () => {
749
761
  })
750
762
 
751
763
  test('behavior: multiple pairs have independent orderbooks', async () => {
752
- const { base: base1, quote: quote1 } = await setupTokenPair(client)
753
- const { base: base2, quote: quote2 } = await setupTokenPair(client)
764
+ const { base: base1, quote: quote1 } =
765
+ await setupTokenPair(clientWithAccount)
766
+ const { base: base2, quote: quote2 } =
767
+ await setupTokenPair(clientWithAccount)
754
768
 
755
769
  // Place order on first pair
756
- await Actions.dex.placeSync(client, {
770
+ await Actions.dex.placeSync(clientWithAccount, {
757
771
  token: base1,
758
772
  amount: parseUnits('100', 6),
759
773
  type: 'buy',
@@ -761,7 +775,7 @@ describe('getOrderbook', () => {
761
775
  })
762
776
 
763
777
  // Place order on second pair at different tick
764
- await Actions.dex.placeSync(client, {
778
+ await Actions.dex.placeSync(clientWithAccount, {
765
779
  token: base2,
766
780
  amount: parseUnits('100', 6),
767
781
  type: 'buy',
@@ -769,12 +783,12 @@ describe('getOrderbook', () => {
769
783
  })
770
784
 
771
785
  // Get orderbooks
772
- const book1 = await Actions.dex.getOrderbook(client, {
786
+ const book1 = await Actions.dex.getOrderbook(clientWithAccount, {
773
787
  base: base1,
774
788
  quote: quote1,
775
789
  })
776
790
 
777
- const book2 = await Actions.dex.getOrderbook(client, {
791
+ const book2 = await Actions.dex.getOrderbook(clientWithAccount, {
778
792
  base: base2,
779
793
  quote: quote2,
780
794
  })
@@ -787,12 +801,12 @@ describe('getOrderbook', () => {
787
801
 
788
802
  describe('getTickLevel', () => {
789
803
  test('default', async () => {
790
- const { base } = await setupTokenPair(client)
804
+ const { base } = await setupTokenPair(clientWithAccount)
791
805
 
792
806
  const tick = Tick.fromPrice('1.001')
793
807
 
794
808
  // Place an order to create liquidity at this tick
795
- const { orderId } = await Actions.dex.placeSync(client, {
809
+ const { orderId } = await Actions.dex.placeSync(clientWithAccount, {
796
810
  token: base,
797
811
  amount: parseUnits('100', 6),
798
812
  type: 'buy',
@@ -800,7 +814,7 @@ describe('getTickLevel', () => {
800
814
  })
801
815
 
802
816
  // Get the price level
803
- const level = await Actions.dex.getTickLevel(client, {
817
+ const level = await Actions.dex.getTickLevel(clientWithAccount, {
804
818
  base,
805
819
  tick,
806
820
  isBid: true,
@@ -813,12 +827,12 @@ describe('getTickLevel', () => {
813
827
  })
814
828
 
815
829
  test('behavior: empty price level', async () => {
816
- const { base } = await setupTokenPair(client)
830
+ const { base } = await setupTokenPair(clientWithAccount)
817
831
 
818
832
  const tick = Tick.fromPrice('1.001')
819
833
 
820
834
  // Query a tick with no orders
821
- const level = await Actions.dex.getTickLevel(client, {
835
+ const level = await Actions.dex.getTickLevel(clientWithAccount, {
822
836
  base,
823
837
  tick,
824
838
  isBid: true,
@@ -831,28 +845,34 @@ describe('getTickLevel', () => {
831
845
  })
832
846
 
833
847
  test('behavior: multiple orders at same tick', async () => {
834
- const { base } = await setupTokenPair(client)
848
+ const { base } = await setupTokenPair(clientWithAccount)
835
849
 
836
850
  const tick = Tick.fromPrice('1.001')
837
851
 
838
852
  // Place first order
839
- const { orderId: orderId1 } = await Actions.dex.placeSync(client, {
840
- token: base,
841
- amount: parseUnits('100', 6),
842
- type: 'buy',
843
- tick,
844
- })
853
+ const { orderId: orderId1 } = await Actions.dex.placeSync(
854
+ clientWithAccount,
855
+ {
856
+ token: base,
857
+ amount: parseUnits('100', 6),
858
+ type: 'buy',
859
+ tick,
860
+ },
861
+ )
845
862
 
846
863
  // Place second order at same tick
847
- const { orderId: orderId2 } = await Actions.dex.placeSync(client, {
848
- token: base,
849
- amount: parseUnits('50', 6),
850
- type: 'buy',
851
- tick,
852
- })
864
+ const { orderId: orderId2 } = await Actions.dex.placeSync(
865
+ clientWithAccount,
866
+ {
867
+ token: base,
868
+ amount: parseUnits('50', 6),
869
+ type: 'buy',
870
+ tick,
871
+ },
872
+ )
853
873
 
854
874
  // Get the price level
855
- const level = await Actions.dex.getTickLevel(client, {
875
+ const level = await Actions.dex.getTickLevel(clientWithAccount, {
856
876
  base,
857
877
  tick,
858
878
  isBid: true,
@@ -865,12 +885,12 @@ describe('getTickLevel', () => {
865
885
  })
866
886
 
867
887
  test('behavior: bid vs ask sides', async () => {
868
- const { base } = await setupTokenPair(client)
888
+ const { base } = await setupTokenPair(clientWithAccount)
869
889
 
870
890
  const tick = Tick.fromPrice('1.001')
871
891
 
872
892
  // Place a buy order (bid)
873
- await Actions.dex.placeSync(client, {
893
+ await Actions.dex.placeSync(clientWithAccount, {
874
894
  token: base,
875
895
  amount: parseUnits('100', 6),
876
896
  type: 'buy',
@@ -878,7 +898,7 @@ describe('getTickLevel', () => {
878
898
  })
879
899
 
880
900
  // Place a sell order (ask) at same tick
881
- await Actions.dex.placeSync(client, {
901
+ await Actions.dex.placeSync(clientWithAccount, {
882
902
  token: base,
883
903
  amount: parseUnits('50', 6),
884
904
  type: 'sell',
@@ -886,14 +906,14 @@ describe('getTickLevel', () => {
886
906
  })
887
907
 
888
908
  // Get bid side
889
- const bidLevel = await Actions.dex.getTickLevel(client, {
909
+ const bidLevel = await Actions.dex.getTickLevel(clientWithAccount, {
890
910
  base,
891
911
  tick,
892
912
  isBid: true,
893
913
  })
894
914
 
895
915
  // Get ask side
896
- const askLevel = await Actions.dex.getTickLevel(client, {
916
+ const askLevel = await Actions.dex.getTickLevel(clientWithAccount, {
897
917
  base,
898
918
  tick,
899
919
  isBid: false,
@@ -906,19 +926,22 @@ describe('getTickLevel', () => {
906
926
  })
907
927
 
908
928
  test('behavior: liquidity changes after order cancellation', async () => {
909
- const { base } = await setupTokenPair(client)
929
+ const { base } = await setupTokenPair(clientWithAccount)
910
930
 
911
931
  const tick = Tick.fromPrice('1.001')
912
932
 
913
933
  // Place orders
914
- const { orderId: orderId1 } = await Actions.dex.placeSync(client, {
915
- token: base,
916
- amount: parseUnits('100', 6),
917
- type: 'buy',
918
- tick,
919
- })
934
+ const { orderId: orderId1 } = await Actions.dex.placeSync(
935
+ clientWithAccount,
936
+ {
937
+ token: base,
938
+ amount: parseUnits('100', 6),
939
+ type: 'buy',
940
+ tick,
941
+ },
942
+ )
920
943
 
921
- await Actions.dex.placeSync(client, {
944
+ await Actions.dex.placeSync(clientWithAccount, {
922
945
  token: base,
923
946
  amount: parseUnits('50', 6),
924
947
  type: 'buy',
@@ -926,19 +949,19 @@ describe('getTickLevel', () => {
926
949
  })
927
950
 
928
951
  // Get level before cancellation
929
- const levelBefore = await Actions.dex.getTickLevel(client, {
952
+ const levelBefore = await Actions.dex.getTickLevel(clientWithAccount, {
930
953
  base,
931
954
  tick,
932
955
  isBid: true,
933
956
  })
934
957
 
935
958
  // Cancel first order
936
- await Actions.dex.cancelSync(client, {
959
+ await Actions.dex.cancelSync(clientWithAccount, {
937
960
  orderId: orderId1,
938
961
  })
939
962
 
940
963
  // Get level after cancellation
941
- const levelAfter = await Actions.dex.getTickLevel(client, {
964
+ const levelAfter = await Actions.dex.getTickLevel(clientWithAccount, {
942
965
  base,
943
966
  tick,
944
967
  isBid: true,
@@ -949,12 +972,12 @@ describe('getTickLevel', () => {
949
972
  })
950
973
 
951
974
  test('behavior: liquidity changes after partial fill', async () => {
952
- const { base, quote } = await setupTokenPair(client)
975
+ const { base, quote } = await setupTokenPair(clientWithAccount)
953
976
 
954
977
  const tick = Tick.fromPrice('1.001')
955
978
 
956
979
  // Place sell order
957
- await Actions.dex.placeSync(client, {
980
+ await Actions.dex.placeSync(clientWithAccount, {
958
981
  token: base,
959
982
  amount: parseUnits('500', 6),
960
983
  type: 'sell',
@@ -962,14 +985,14 @@ describe('getTickLevel', () => {
962
985
  })
963
986
 
964
987
  // Get level before fill
965
- const levelBefore = await Actions.dex.getTickLevel(client, {
988
+ const levelBefore = await Actions.dex.getTickLevel(clientWithAccount, {
966
989
  base,
967
990
  tick,
968
991
  isBid: false,
969
992
  })
970
993
 
971
994
  // Partially fill the order
972
- await Actions.dex.buySync(client, {
995
+ await Actions.dex.buySync(clientWithAccount, {
973
996
  tokenIn: quote,
974
997
  tokenOut: base,
975
998
  amountOut: parseUnits('100', 6),
@@ -977,7 +1000,7 @@ describe('getTickLevel', () => {
977
1000
  })
978
1001
 
979
1002
  // Get level after fill
980
- const levelAfter = await Actions.dex.getTickLevel(client, {
1003
+ const levelAfter = await Actions.dex.getTickLevel(clientWithAccount, {
981
1004
  base,
982
1005
  tick,
983
1006
  isBid: false,
@@ -988,10 +1011,10 @@ describe('getTickLevel', () => {
988
1011
  })
989
1012
 
990
1013
  test('behavior: tick at boundaries', async () => {
991
- const { base } = await setupTokenPair(client)
1014
+ const { base } = await setupTokenPair(clientWithAccount)
992
1015
 
993
1016
  // Place order at min tick
994
- await Actions.dex.placeSync(client, {
1017
+ await Actions.dex.placeSync(clientWithAccount, {
995
1018
  token: base,
996
1019
  amount: parseUnits('10', 6),
997
1020
  type: 'sell',
@@ -999,7 +1022,7 @@ describe('getTickLevel', () => {
999
1022
  })
1000
1023
 
1001
1024
  // Query min tick
1002
- const minLevel = await Actions.dex.getTickLevel(client, {
1025
+ const minLevel = await Actions.dex.getTickLevel(clientWithAccount, {
1003
1026
  base,
1004
1027
  tick: Tick.minTick,
1005
1028
  isBid: false,
@@ -1007,7 +1030,7 @@ describe('getTickLevel', () => {
1007
1030
  expect(minLevel.totalLiquidity).toBeGreaterThan(0n)
1008
1031
 
1009
1032
  // Place order at max tick
1010
- await Actions.dex.placeSync(client, {
1033
+ await Actions.dex.placeSync(clientWithAccount, {
1011
1034
  token: base,
1012
1035
  amount: parseUnits('10', 6),
1013
1036
  type: 'buy',
@@ -1015,7 +1038,7 @@ describe('getTickLevel', () => {
1015
1038
  })
1016
1039
 
1017
1040
  // Query max tick
1018
- const maxLevel = await Actions.dex.getTickLevel(client, {
1041
+ const maxLevel = await Actions.dex.getTickLevel(clientWithAccount, {
1019
1042
  base,
1020
1043
  tick: Tick.maxTick,
1021
1044
  isBid: true,
@@ -1026,10 +1049,10 @@ describe('getTickLevel', () => {
1026
1049
 
1027
1050
  describe('getSellQuote', () => {
1028
1051
  test('default', async () => {
1029
- const { base, quote } = await setupTokenPair(client)
1052
+ const { base, quote } = await setupTokenPair(clientWithAccount)
1030
1053
 
1031
1054
  // Place bid orders to create liquidity
1032
- await Actions.dex.placeSync(client, {
1055
+ await Actions.dex.placeSync(clientWithAccount, {
1033
1056
  token: base,
1034
1057
  amount: parseUnits('500', 6),
1035
1058
  type: 'buy',
@@ -1037,7 +1060,7 @@ describe('getSellQuote', () => {
1037
1060
  })
1038
1061
 
1039
1062
  // Get quote for selling base tokens
1040
- const amountOut = await Actions.dex.getSellQuote(client, {
1063
+ const amountOut = await Actions.dex.getSellQuote(clientWithAccount, {
1041
1064
  tokenIn: base,
1042
1065
  tokenOut: quote,
1043
1066
  amountIn: parseUnits('100', 6),
@@ -1049,11 +1072,11 @@ describe('getSellQuote', () => {
1049
1072
  })
1050
1073
 
1051
1074
  test('behavior: fails with no liquidity', async () => {
1052
- const { base, quote } = await setupTokenPair(client)
1075
+ const { base, quote } = await setupTokenPair(clientWithAccount)
1053
1076
 
1054
1077
  // Quote should fail with no liquidity
1055
1078
  await expect(
1056
- Actions.dex.getSellQuote(client, {
1079
+ Actions.dex.getSellQuote(clientWithAccount, {
1057
1080
  tokenIn: base,
1058
1081
  tokenOut: quote,
1059
1082
  amountIn: parseUnits('100', 6),
@@ -1065,11 +1088,11 @@ describe('getSellQuote', () => {
1065
1088
  describe('place', () => {
1066
1089
  test('default', async () => {
1067
1090
  // Setup token pair
1068
- const { base } = await setupTokenPair(client)
1091
+ const { base } = await setupTokenPair(clientWithAccount)
1069
1092
 
1070
1093
  // Place a sell order
1071
1094
  const { receipt, orderId, token, ...result } = await Actions.dex.placeSync(
1072
- client,
1095
+ clientWithAccount,
1073
1096
  {
1074
1097
  token: base,
1075
1098
  amount: parseUnits('100', 6),
@@ -1097,7 +1120,7 @@ describe('place', () => {
1097
1120
  orderId: orderId2,
1098
1121
  token: token2,
1099
1122
  ...result2
1100
- } = await Actions.dex.placeSync(client, {
1123
+ } = await Actions.dex.placeSync(clientWithAccount, {
1101
1124
  token: base,
1102
1125
  amount: parseUnits('100', 6),
1103
1126
  type: 'buy',
@@ -1117,11 +1140,11 @@ describe('place', () => {
1117
1140
  })
1118
1141
 
1119
1142
  test('behavior: tick at boundaries', async () => {
1120
- const { base } = await setupTokenPair(client)
1143
+ const { base } = await setupTokenPair(clientWithAccount)
1121
1144
 
1122
1145
  // Test at min tick (-2000)
1123
1146
  const { receipt: receipt1, ...result1 } = await Actions.dex.placeSync(
1124
- client,
1147
+ clientWithAccount,
1125
1148
  {
1126
1149
  token: base,
1127
1150
  amount: parseUnits('10', 6),
@@ -1134,7 +1157,7 @@ describe('place', () => {
1134
1157
 
1135
1158
  // Test at max tick (2000)
1136
1159
  const { receipt: receipt2, ...result2 } = await Actions.dex.placeSync(
1137
- client,
1160
+ clientWithAccount,
1138
1161
  {
1139
1162
  token: base,
1140
1163
  amount: parseUnits('10', 6),
@@ -1147,11 +1170,11 @@ describe('place', () => {
1147
1170
  })
1148
1171
 
1149
1172
  test('behavior: tick validation fails outside bounds', async () => {
1150
- const { base } = await setupTokenPair(client)
1173
+ const { base } = await setupTokenPair(clientWithAccount)
1151
1174
 
1152
1175
  // Test tick above max tix should fail
1153
1176
  await expect(
1154
- Actions.dex.placeSync(client, {
1177
+ Actions.dex.placeSync(clientWithAccount, {
1155
1178
  token: base,
1156
1179
  amount: parseUnits('10', 6),
1157
1180
  type: 'buy',
@@ -1161,7 +1184,7 @@ describe('place', () => {
1161
1184
 
1162
1185
  // Test tick below min tick should fail
1163
1186
  await expect(
1164
- Actions.dex.placeSync(client, {
1187
+ Actions.dex.placeSync(clientWithAccount, {
1165
1188
  token: base,
1166
1189
  amount: parseUnits('10', 6),
1167
1190
  type: 'sell',
@@ -1171,20 +1194,26 @@ describe('place', () => {
1171
1194
  })
1172
1195
 
1173
1196
  test('behavior: transfers from wallet', async () => {
1174
- const { base, quote } = await setupTokenPair(client)
1197
+ const { base, quote } = await setupTokenPair(clientWithAccount)
1175
1198
 
1176
1199
  // Get balances before placing order
1177
- const baseBalanceBefore = await Actions.token.getBalance(client, {
1178
- token: base,
1179
- })
1180
- const quoteBalanceBefore = await Actions.token.getBalance(client, {
1181
- token: quote,
1182
- })
1200
+ const baseBalanceBefore = await Actions.token.getBalance(
1201
+ clientWithAccount,
1202
+ {
1203
+ token: base,
1204
+ },
1205
+ )
1206
+ const quoteBalanceBefore = await Actions.token.getBalance(
1207
+ clientWithAccount,
1208
+ {
1209
+ token: quote,
1210
+ },
1211
+ )
1183
1212
 
1184
1213
  // Place a buy order - should transfer quote tokens to escrow
1185
1214
  const orderAmount = parseUnits('100', 6)
1186
1215
  const tick = Tick.fromPrice('1.001')
1187
- await Actions.dex.placeSync(client, {
1216
+ await Actions.dex.placeSync(clientWithAccount, {
1188
1217
  token: base,
1189
1218
  amount: orderAmount,
1190
1219
  type: 'buy',
@@ -1192,12 +1221,15 @@ describe('place', () => {
1192
1221
  })
1193
1222
 
1194
1223
  // Get balances after placing order
1195
- const baseBalanceAfter = await Actions.token.getBalance(client, {
1224
+ const baseBalanceAfter = await Actions.token.getBalance(clientWithAccount, {
1196
1225
  token: base,
1197
1226
  })
1198
- const quoteBalanceAfter = await Actions.token.getBalance(client, {
1199
- token: quote,
1200
- })
1227
+ const quoteBalanceAfter = await Actions.token.getBalance(
1228
+ clientWithAccount,
1229
+ {
1230
+ token: quote,
1231
+ },
1232
+ )
1201
1233
 
1202
1234
  // Base token balance should be unchanged (we're buying base, not selling)
1203
1235
  expect(baseBalanceAfter).toBe(baseBalanceBefore)
@@ -1212,25 +1244,31 @@ describe('place', () => {
1212
1244
  })
1213
1245
 
1214
1246
  test('behavior: multiple orders at same tick', async () => {
1215
- const { base } = await setupTokenPair(client)
1247
+ const { base } = await setupTokenPair(clientWithAccount)
1216
1248
 
1217
1249
  const tick = Tick.fromPrice('1.0005')
1218
1250
 
1219
1251
  // Place first order
1220
- const { orderId: orderId1 } = await Actions.dex.placeSync(client, {
1221
- token: base,
1222
- amount: parseUnits('100', 6),
1223
- type: 'buy',
1224
- tick,
1225
- })
1252
+ const { orderId: orderId1 } = await Actions.dex.placeSync(
1253
+ clientWithAccount,
1254
+ {
1255
+ token: base,
1256
+ amount: parseUnits('100', 6),
1257
+ type: 'buy',
1258
+ tick,
1259
+ },
1260
+ )
1226
1261
 
1227
1262
  // Place second order at same tick
1228
- const { orderId: orderId2 } = await Actions.dex.placeSync(client, {
1229
- token: base,
1230
- amount: parseUnits('50', 6),
1231
- type: 'buy',
1232
- tick,
1233
- })
1263
+ const { orderId: orderId2 } = await Actions.dex.placeSync(
1264
+ clientWithAccount,
1265
+ {
1266
+ token: base,
1267
+ amount: parseUnits('50', 6),
1268
+ type: 'buy',
1269
+ tick,
1270
+ },
1271
+ )
1234
1272
 
1235
1273
  // Order IDs should be different and sequential
1236
1274
  expect(orderId2).toBeGreaterThan(orderId1)
@@ -1239,11 +1277,11 @@ describe('place', () => {
1239
1277
 
1240
1278
  describe('placeFlip', () => {
1241
1279
  test('default', async () => {
1242
- const { base } = await setupTokenPair(client)
1280
+ const { base } = await setupTokenPair(clientWithAccount)
1243
1281
 
1244
1282
  // Place a flip bid order
1245
1283
  const { receipt, orderId, token, ...result } =
1246
- await Actions.dex.placeFlipSync(client, {
1284
+ await Actions.dex.placeFlipSync(clientWithAccount, {
1247
1285
  token: base,
1248
1286
  amount: parseUnits('100', 6),
1249
1287
  type: 'buy',
@@ -1268,21 +1306,24 @@ describe('placeFlip', () => {
1268
1306
  })
1269
1307
 
1270
1308
  test('behavior: flip bid requires flipTick > tick', async () => {
1271
- const { base } = await setupTokenPair(client)
1309
+ const { base } = await setupTokenPair(clientWithAccount)
1272
1310
 
1273
1311
  // Valid: flipTick > tick for bid
1274
- const { receipt: receipt1 } = await Actions.dex.placeFlipSync(client, {
1275
- token: base,
1276
- amount: parseUnits('10', 6),
1277
- type: 'buy',
1278
- tick: Tick.fromPrice('1.0005'),
1279
- flipTick: Tick.fromPrice('1.001'),
1280
- })
1312
+ const { receipt: receipt1 } = await Actions.dex.placeFlipSync(
1313
+ clientWithAccount,
1314
+ {
1315
+ token: base,
1316
+ amount: parseUnits('10', 6),
1317
+ type: 'buy',
1318
+ tick: Tick.fromPrice('1.0005'),
1319
+ flipTick: Tick.fromPrice('1.001'),
1320
+ },
1321
+ )
1281
1322
  expect(receipt1.status).toBe('success')
1282
1323
 
1283
1324
  // Invalid: flipTick <= tick for bid should fail
1284
1325
  await expect(
1285
- Actions.dex.placeFlipSync(client, {
1326
+ Actions.dex.placeFlipSync(clientWithAccount, {
1286
1327
  token: base,
1287
1328
  amount: parseUnits('10', 6),
1288
1329
  type: 'buy',
@@ -1292,7 +1333,7 @@ describe('placeFlip', () => {
1292
1333
  ).rejects.toThrow('The contract function "placeFlip" reverted')
1293
1334
 
1294
1335
  await expect(
1295
- Actions.dex.placeFlipSync(client, {
1336
+ Actions.dex.placeFlipSync(clientWithAccount, {
1296
1337
  token: base,
1297
1338
  amount: parseUnits('10', 6),
1298
1339
  type: 'buy',
@@ -1303,21 +1344,24 @@ describe('placeFlip', () => {
1303
1344
  })
1304
1345
 
1305
1346
  test('behavior: flip ask requires flipTick < tick', async () => {
1306
- const { base } = await setupTokenPair(client)
1347
+ const { base } = await setupTokenPair(clientWithAccount)
1307
1348
 
1308
1349
  // Valid: flipTick < tick for ask
1309
- const { receipt: receipt1 } = await Actions.dex.placeFlipSync(client, {
1310
- token: base,
1311
- amount: parseUnits('10', 6),
1312
- type: 'sell',
1313
- tick: Tick.fromPrice('1.001'),
1314
- flipTick: Tick.fromPrice('1.0005'),
1315
- })
1350
+ const { receipt: receipt1 } = await Actions.dex.placeFlipSync(
1351
+ clientWithAccount,
1352
+ {
1353
+ token: base,
1354
+ amount: parseUnits('10', 6),
1355
+ type: 'sell',
1356
+ tick: Tick.fromPrice('1.001'),
1357
+ flipTick: Tick.fromPrice('1.0005'),
1358
+ },
1359
+ )
1316
1360
  expect(receipt1.status).toBe('success')
1317
1361
 
1318
1362
  // Invalid: flipTick >= tick for ask should fail
1319
1363
  await expect(
1320
- Actions.dex.placeFlipSync(client, {
1364
+ Actions.dex.placeFlipSync(clientWithAccount, {
1321
1365
  token: base,
1322
1366
  amount: parseUnits('10', 6),
1323
1367
  type: 'sell',
@@ -1327,7 +1371,7 @@ describe('placeFlip', () => {
1327
1371
  ).rejects.toThrow('The contract function "placeFlip" reverted')
1328
1372
 
1329
1373
  await expect(
1330
- Actions.dex.placeFlipSync(client, {
1374
+ Actions.dex.placeFlipSync(clientWithAccount, {
1331
1375
  token: base,
1332
1376
  amount: parseUnits('10', 6),
1333
1377
  type: 'sell',
@@ -1338,10 +1382,10 @@ describe('placeFlip', () => {
1338
1382
  })
1339
1383
 
1340
1384
  test('behavior: flip ticks at boundaries', async () => {
1341
- const { base } = await setupTokenPair(client)
1385
+ const { base } = await setupTokenPair(clientWithAccount)
1342
1386
 
1343
1387
  // Flip order with ticks at extreme boundaries
1344
- const { receipt } = await Actions.dex.placeFlipSync(client, {
1388
+ const { receipt } = await Actions.dex.placeFlipSync(clientWithAccount, {
1345
1389
  token: base,
1346
1390
  amount: parseUnits('10', 6),
1347
1391
  type: 'buy',
@@ -1354,10 +1398,10 @@ describe('placeFlip', () => {
1354
1398
 
1355
1399
  describe('sell', () => {
1356
1400
  test('default', async () => {
1357
- const { base, quote } = await setupTokenPair(client)
1401
+ const { base, quote } = await setupTokenPair(clientWithAccount)
1358
1402
 
1359
1403
  // Place bid order to create liquidity
1360
- await Actions.dex.placeSync(client, {
1404
+ await Actions.dex.placeSync(clientWithAccount, {
1361
1405
  token: base,
1362
1406
  amount: parseUnits('500', 6),
1363
1407
  type: 'buy',
@@ -1365,7 +1409,7 @@ describe('sell', () => {
1365
1409
  })
1366
1410
 
1367
1411
  // Sell base tokens
1368
- const { receipt } = await Actions.dex.sellSync(client, {
1412
+ const { receipt } = await Actions.dex.sellSync(clientWithAccount, {
1369
1413
  tokenIn: base,
1370
1414
  tokenOut: quote,
1371
1415
  amountIn: parseUnits('100', 6),
@@ -1377,10 +1421,10 @@ describe('sell', () => {
1377
1421
  })
1378
1422
 
1379
1423
  test('behavior: respects minAmountOut', async () => {
1380
- const { base, quote } = await setupTokenPair(client)
1424
+ const { base, quote } = await setupTokenPair(clientWithAccount)
1381
1425
 
1382
1426
  // Place bid order at low price
1383
- await Actions.dex.placeSync(client, {
1427
+ await Actions.dex.placeSync(clientWithAccount, {
1384
1428
  token: base,
1385
1429
  amount: parseUnits('500', 6),
1386
1430
  type: 'buy',
@@ -1389,7 +1433,7 @@ describe('sell', () => {
1389
1433
 
1390
1434
  // Try to sell with too high minAmountOut - should fail
1391
1435
  await expect(
1392
- Actions.dex.sellSync(client, {
1436
+ Actions.dex.sellSync(clientWithAccount, {
1393
1437
  tokenIn: base,
1394
1438
  tokenOut: quote,
1395
1439
  amountIn: parseUnits('100', 6),
@@ -1399,13 +1443,13 @@ describe('sell', () => {
1399
1443
  })
1400
1444
 
1401
1445
  test('behavior: fails with insufficient liquidity', async () => {
1402
- const { base, quote } = await setupTokenPair(client)
1446
+ const { base, quote } = await setupTokenPair(clientWithAccount)
1403
1447
 
1404
1448
  // No orders - no liquidity
1405
1449
 
1406
1450
  // Try to sell - should fail
1407
1451
  await expect(
1408
- Actions.dex.sellSync(client, {
1452
+ Actions.dex.sellSync(clientWithAccount, {
1409
1453
  tokenIn: base,
1410
1454
  tokenOut: quote,
1411
1455
  amountIn: parseUnits('100', 6),
@@ -1417,14 +1461,14 @@ describe('sell', () => {
1417
1461
 
1418
1462
  describe('watchFlipOrderPlaced', () => {
1419
1463
  test('default', async () => {
1420
- const { base } = await setupTokenPair(client)
1464
+ const { base } = await setupTokenPair(clientWithAccount)
1421
1465
 
1422
1466
  const receivedOrders: Array<{
1423
1467
  args: Actions.dex.watchFlipOrderPlaced.Args
1424
1468
  log: Actions.dex.watchFlipOrderPlaced.Log
1425
1469
  }> = []
1426
1470
 
1427
- const unwatch = Actions.dex.watchFlipOrderPlaced(client, {
1471
+ const unwatch = Actions.dex.watchFlipOrderPlaced(clientWithAccount, {
1428
1472
  onFlipOrderPlaced: (args, log) => {
1429
1473
  receivedOrders.push({ args, log })
1430
1474
  },
@@ -1432,7 +1476,7 @@ describe('watchFlipOrderPlaced', () => {
1432
1476
 
1433
1477
  try {
1434
1478
  // Place flip order
1435
- await Actions.dex.placeFlipSync(client, {
1479
+ await Actions.dex.placeFlipSync(clientWithAccount, {
1436
1480
  token: base,
1437
1481
  amount: parseUnits('100', 6),
1438
1482
  type: 'buy',
@@ -1453,14 +1497,14 @@ describe('watchFlipOrderPlaced', () => {
1453
1497
 
1454
1498
  describe('watchOrderCancelled', () => {
1455
1499
  test('default', async () => {
1456
- const { base } = await setupTokenPair(client)
1500
+ const { base } = await setupTokenPair(clientWithAccount)
1457
1501
 
1458
1502
  const receivedCancellations: Array<{
1459
1503
  args: Actions.dex.watchOrderCancelled.Args
1460
1504
  log: Actions.dex.watchOrderCancelled.Log
1461
1505
  }> = []
1462
1506
 
1463
- const unwatch = Actions.dex.watchOrderCancelled(client, {
1507
+ const unwatch = Actions.dex.watchOrderCancelled(clientWithAccount, {
1464
1508
  onOrderCancelled: (args, log) => {
1465
1509
  receivedCancellations.push({ args, log })
1466
1510
  },
@@ -1468,7 +1512,7 @@ describe('watchOrderCancelled', () => {
1468
1512
 
1469
1513
  try {
1470
1514
  // Place order
1471
- const { orderId } = await Actions.dex.placeSync(client, {
1515
+ const { orderId } = await Actions.dex.placeSync(clientWithAccount, {
1472
1516
  token: base,
1473
1517
  amount: parseUnits('100', 6),
1474
1518
  type: 'buy',
@@ -1476,7 +1520,7 @@ describe('watchOrderCancelled', () => {
1476
1520
  })
1477
1521
 
1478
1522
  // Cancel order
1479
- await Actions.dex.cancelSync(client, {
1523
+ await Actions.dex.cancelSync(clientWithAccount, {
1480
1524
  orderId,
1481
1525
  })
1482
1526
 
@@ -1490,22 +1534,28 @@ describe('watchOrderCancelled', () => {
1490
1534
  })
1491
1535
 
1492
1536
  test('behavior: filter by orderId', async () => {
1493
- const { base } = await setupTokenPair(client)
1537
+ const { base } = await setupTokenPair(clientWithAccount)
1494
1538
 
1495
1539
  // Place two orders
1496
- const { orderId: orderId1 } = await Actions.dex.placeSync(client, {
1497
- token: base,
1498
- amount: parseUnits('100', 6),
1499
- type: 'buy',
1500
- tick: Tick.fromPrice('1.001'),
1501
- })
1540
+ const { orderId: orderId1 } = await Actions.dex.placeSync(
1541
+ clientWithAccount,
1542
+ {
1543
+ token: base,
1544
+ amount: parseUnits('100', 6),
1545
+ type: 'buy',
1546
+ tick: Tick.fromPrice('1.001'),
1547
+ },
1548
+ )
1502
1549
 
1503
- const { orderId: orderId2 } = await Actions.dex.placeSync(client, {
1504
- token: base,
1505
- amount: parseUnits('50', 6),
1506
- type: 'buy',
1507
- tick: Tick.fromPrice('1.001'),
1508
- })
1550
+ const { orderId: orderId2 } = await Actions.dex.placeSync(
1551
+ clientWithAccount,
1552
+ {
1553
+ token: base,
1554
+ amount: parseUnits('50', 6),
1555
+ type: 'buy',
1556
+ tick: Tick.fromPrice('1.001'),
1557
+ },
1558
+ )
1509
1559
 
1510
1560
  const receivedCancellations: Array<{
1511
1561
  args: Actions.dex.watchOrderCancelled.Args
@@ -1513,7 +1563,7 @@ describe('watchOrderCancelled', () => {
1513
1563
  }> = []
1514
1564
 
1515
1565
  // Watch only for cancellation of orderId1
1516
- const unwatch = Actions.dex.watchOrderCancelled(client, {
1566
+ const unwatch = Actions.dex.watchOrderCancelled(clientWithAccount, {
1517
1567
  orderId: orderId1,
1518
1568
  onOrderCancelled: (args, log) => {
1519
1569
  receivedCancellations.push({ args, log })
@@ -1522,12 +1572,12 @@ describe('watchOrderCancelled', () => {
1522
1572
 
1523
1573
  try {
1524
1574
  // Cancel orderId1 (should be captured)
1525
- await Actions.dex.cancelSync(client, {
1575
+ await Actions.dex.cancelSync(clientWithAccount, {
1526
1576
  orderId: orderId1,
1527
1577
  })
1528
1578
 
1529
1579
  // Cancel orderId2 (should NOT be captured)
1530
- await Actions.dex.cancelSync(client, {
1580
+ await Actions.dex.cancelSync(clientWithAccount, {
1531
1581
  orderId: orderId2,
1532
1582
  })
1533
1583
 
@@ -1546,14 +1596,14 @@ describe.todo('watchOrderFilled')
1546
1596
 
1547
1597
  describe('watchOrderPlaced', () => {
1548
1598
  test('default', async () => {
1549
- const { base } = await setupTokenPair(client)
1599
+ const { base } = await setupTokenPair(clientWithAccount)
1550
1600
 
1551
1601
  const receivedOrders: Array<{
1552
1602
  args: Actions.dex.watchOrderPlaced.Args
1553
1603
  log: Actions.dex.watchOrderPlaced.Log
1554
1604
  }> = []
1555
1605
 
1556
- const unwatch = Actions.dex.watchOrderPlaced(client, {
1606
+ const unwatch = Actions.dex.watchOrderPlaced(clientWithAccount, {
1557
1607
  onOrderPlaced: (args, log) => {
1558
1608
  receivedOrders.push({ args, log })
1559
1609
  },
@@ -1561,7 +1611,7 @@ describe('watchOrderPlaced', () => {
1561
1611
 
1562
1612
  try {
1563
1613
  // Place first order
1564
- await Actions.dex.placeSync(client, {
1614
+ await Actions.dex.placeSync(clientWithAccount, {
1565
1615
  token: base,
1566
1616
  amount: parseUnits('100', 6),
1567
1617
  type: 'buy',
@@ -1569,7 +1619,7 @@ describe('watchOrderPlaced', () => {
1569
1619
  })
1570
1620
 
1571
1621
  // Place second order
1572
- await Actions.dex.placeSync(client, {
1622
+ await Actions.dex.placeSync(clientWithAccount, {
1573
1623
  token: base,
1574
1624
  amount: parseUnits('50', 6),
1575
1625
  type: 'sell',
@@ -1590,8 +1640,8 @@ describe('watchOrderPlaced', () => {
1590
1640
  })
1591
1641
 
1592
1642
  test('behavior: filter by token', async () => {
1593
- const { base } = await setupTokenPair(client)
1594
- const { base: base2 } = await setupTokenPair(client)
1643
+ const { base } = await setupTokenPair(clientWithAccount)
1644
+ const { base: base2 } = await setupTokenPair(clientWithAccount)
1595
1645
 
1596
1646
  const receivedOrders: Array<{
1597
1647
  args: Actions.dex.watchOrderPlaced.Args
@@ -1599,7 +1649,7 @@ describe('watchOrderPlaced', () => {
1599
1649
  }> = []
1600
1650
 
1601
1651
  // Watch only for orders on base
1602
- const unwatch = Actions.dex.watchOrderPlaced(client, {
1652
+ const unwatch = Actions.dex.watchOrderPlaced(clientWithAccount, {
1603
1653
  token: base,
1604
1654
  onOrderPlaced: (args, log) => {
1605
1655
  receivedOrders.push({ args, log })
@@ -1608,7 +1658,7 @@ describe('watchOrderPlaced', () => {
1608
1658
 
1609
1659
  try {
1610
1660
  // Place order on base (should be captured)
1611
- await Actions.dex.placeSync(client, {
1661
+ await Actions.dex.placeSync(clientWithAccount, {
1612
1662
  token: base,
1613
1663
  amount: parseUnits('100', 6),
1614
1664
  type: 'buy',
@@ -1616,7 +1666,7 @@ describe('watchOrderPlaced', () => {
1616
1666
  })
1617
1667
 
1618
1668
  // Place order on base2 (should NOT be captured)
1619
- await Actions.dex.placeSync(client, {
1669
+ await Actions.dex.placeSync(clientWithAccount, {
1620
1670
  token: base2,
1621
1671
  amount: parseUnits('50', 6),
1622
1672
  type: 'buy',
@@ -1638,32 +1688,35 @@ describe('watchOrderPlaced', () => {
1638
1688
 
1639
1689
  describe('withdraw', () => {
1640
1690
  test('default', async () => {
1641
- const { base, quote } = await setupTokenPair(client)
1691
+ const { base, quote } = await setupTokenPair(clientWithAccount)
1642
1692
 
1643
1693
  // Create internal balance
1644
- const { orderId } = await Actions.dex.placeSync(client, {
1694
+ const { orderId } = await Actions.dex.placeSync(clientWithAccount, {
1645
1695
  token: base,
1646
1696
  amount: parseUnits('100', 6),
1647
1697
  type: 'buy',
1648
1698
  tick: Tick.fromPrice('1.001'),
1649
1699
  })
1650
1700
 
1651
- await Actions.dex.cancelSync(client, { orderId })
1701
+ await Actions.dex.cancelSync(clientWithAccount, { orderId })
1652
1702
 
1653
1703
  // Get DEX balance
1654
- const dexBalance = await Actions.dex.getBalance(client, {
1655
- account: client.account.address,
1704
+ const dexBalance = await Actions.dex.getBalance(clientWithAccount, {
1705
+ account: clientWithAccount.account.address,
1656
1706
  token: quote,
1657
1707
  })
1658
1708
  expect(dexBalance).toBeGreaterThan(0n)
1659
1709
 
1660
1710
  // Get wallet balance before withdraw
1661
- const walletBalanceBefore = await Actions.token.getBalance(client, {
1662
- token: quote,
1663
- })
1711
+ const walletBalanceBefore = await Actions.token.getBalance(
1712
+ clientWithAccount,
1713
+ {
1714
+ token: quote,
1715
+ },
1716
+ )
1664
1717
 
1665
1718
  // Withdraw from DEX
1666
- const { receipt } = await Actions.dex.withdrawSync(client, {
1719
+ const { receipt } = await Actions.dex.withdrawSync(clientWithAccount, {
1667
1720
  token: quote,
1668
1721
  amount: dexBalance,
1669
1722
  })
@@ -1672,16 +1725,19 @@ describe('withdraw', () => {
1672
1725
  expect(receipt.status).toBe('success')
1673
1726
 
1674
1727
  // Check DEX balance is now 0
1675
- const dexBalanceAfter = await Actions.dex.getBalance(client, {
1676
- account: client.account.address,
1728
+ const dexBalanceAfter = await Actions.dex.getBalance(clientWithAccount, {
1729
+ account: clientWithAccount.account.address,
1677
1730
  token: quote,
1678
1731
  })
1679
1732
  expect(dexBalanceAfter).toBe(0n)
1680
1733
 
1681
1734
  // Check wallet balance increased
1682
- const walletBalanceAfter = await Actions.token.getBalance(client, {
1683
- token: quote,
1684
- })
1735
+ const walletBalanceAfter = await Actions.token.getBalance(
1736
+ clientWithAccount,
1737
+ {
1738
+ token: quote,
1739
+ },
1740
+ )
1685
1741
  expect(walletBalanceAfter).toBeGreaterThan(walletBalanceBefore)
1686
1742
  })
1687
1743
  })