viem 2.43.4 → 2.44.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 (227) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js +11 -1
  3. package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -1
  4. package/_cjs/actions/wallet/sendTransactionSync.js +1 -0
  5. package/_cjs/actions/wallet/sendTransactionSync.js.map +1 -1
  6. package/_cjs/chains/definitions/codex.js +47 -0
  7. package/_cjs/chains/definitions/codex.js.map +1 -0
  8. package/_cjs/chains/definitions/codexTestnet.js +47 -0
  9. package/_cjs/chains/definitions/codexTestnet.js.map +1 -0
  10. package/_cjs/chains/definitions/paseoPassetHub.js +26 -0
  11. package/_cjs/chains/definitions/paseoPassetHub.js.map +1 -0
  12. package/_cjs/chains/definitions/{tempoTestnet.js → tempoAndantino.js} +5 -5
  13. package/_cjs/chains/definitions/tempoAndantino.js.map +1 -0
  14. package/_cjs/chains/definitions/tempoDevnet.js +7 -1
  15. package/_cjs/chains/definitions/tempoDevnet.js.map +1 -1
  16. package/_cjs/chains/definitions/tempoModerato.js +28 -0
  17. package/_cjs/chains/definitions/tempoModerato.js.map +1 -0
  18. package/_cjs/chains/index.js +23 -14
  19. package/_cjs/chains/index.js.map +1 -1
  20. package/_cjs/errors/version.js +1 -1
  21. package/_cjs/index.js.map +1 -1
  22. package/_cjs/tempo/Abis.js +610 -752
  23. package/_cjs/tempo/Abis.js.map +1 -1
  24. package/_cjs/tempo/Addresses.js +2 -2
  25. package/_cjs/tempo/Addresses.js.map +1 -1
  26. package/_cjs/tempo/Decorator.js +5 -5
  27. package/_cjs/tempo/Decorator.js.map +1 -1
  28. package/_cjs/tempo/actions/amm.js +4 -38
  29. package/_cjs/tempo/actions/amm.js.map +1 -1
  30. package/_cjs/tempo/actions/dex.js +98 -46
  31. package/_cjs/tempo/actions/dex.js.map +1 -1
  32. package/_cjs/tempo/actions/nonce.js +0 -35
  33. package/_cjs/tempo/actions/nonce.js.map +1 -1
  34. package/_cjs/tempo/actions/reward.js +81 -62
  35. package/_cjs/tempo/actions/reward.js.map +1 -1
  36. package/_cjs/tempo/actions/token.js +11 -2
  37. package/_cjs/tempo/actions/token.js.map +1 -1
  38. package/_cjs/tempo/chainConfig.js +5 -10
  39. package/_cjs/tempo/chainConfig.js.map +1 -1
  40. package/_cjs/tempo/index.js +2 -1
  41. package/_cjs/tempo/index.js.map +1 -1
  42. package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js +16 -2
  43. package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -1
  44. package/_esm/actions/wallet/sendTransactionSync.js +1 -0
  45. package/_esm/actions/wallet/sendTransactionSync.js.map +1 -1
  46. package/_esm/chains/definitions/codex.js +44 -0
  47. package/_esm/chains/definitions/codex.js.map +1 -0
  48. package/_esm/chains/definitions/codexTestnet.js +44 -0
  49. package/_esm/chains/definitions/codexTestnet.js.map +1 -0
  50. package/_esm/chains/definitions/paseoPassetHub.js +23 -0
  51. package/_esm/chains/definitions/paseoPassetHub.js.map +1 -0
  52. package/_esm/chains/definitions/{tempoTestnet.js → tempoAndantino.js} +4 -4
  53. package/_esm/chains/definitions/tempoAndantino.js.map +1 -0
  54. package/_esm/chains/definitions/tempoDevnet.js +7 -1
  55. package/_esm/chains/definitions/tempoDevnet.js.map +1 -1
  56. package/_esm/chains/definitions/tempoModerato.js +25 -0
  57. package/_esm/chains/definitions/tempoModerato.js.map +1 -0
  58. package/_esm/chains/index.js +9 -1
  59. package/_esm/chains/index.js.map +1 -1
  60. package/_esm/errors/version.js +1 -1
  61. package/_esm/index.js.map +1 -1
  62. package/_esm/tempo/Abis.js +609 -751
  63. package/_esm/tempo/Abis.js.map +1 -1
  64. package/_esm/tempo/Addresses.js +1 -1
  65. package/_esm/tempo/Addresses.js.map +1 -1
  66. package/_esm/tempo/Decorator.js +5 -5
  67. package/_esm/tempo/Decorator.js.map +1 -1
  68. package/_esm/tempo/actions/amm.js +4 -62
  69. package/_esm/tempo/actions/amm.js.map +1 -1
  70. package/_esm/tempo/actions/dex.js +192 -48
  71. package/_esm/tempo/actions/dex.js.map +1 -1
  72. package/_esm/tempo/actions/nonce.js +0 -94
  73. package/_esm/tempo/actions/nonce.js.map +1 -1
  74. package/_esm/tempo/actions/reward.js +227 -189
  75. package/_esm/tempo/actions/reward.js.map +1 -1
  76. package/_esm/tempo/actions/token.js +11 -2
  77. package/_esm/tempo/actions/token.js.map +1 -1
  78. package/_esm/tempo/chainConfig.js +2 -7
  79. package/_esm/tempo/chainConfig.js.map +1 -1
  80. package/_esm/tempo/index.js +1 -1
  81. package/_esm/tempo/index.js.map +1 -1
  82. package/_types/account-abstraction/utils/userOperation/toPackedUserOperation.d.ts.map +1 -1
  83. package/_types/actions/wallet/sendTransactionSync.d.ts.map +1 -1
  84. package/_types/celo/chainConfig.d.ts +22 -22
  85. package/_types/celo/formatters.d.ts +11 -11
  86. package/_types/chains/definitions/abstract.d.ts +14 -14
  87. package/_types/chains/definitions/abstractTestnet.d.ts +14 -14
  88. package/_types/chains/definitions/ancient8.d.ts +3 -3
  89. package/_types/chains/definitions/ancient8Sepolia.d.ts +3 -3
  90. package/_types/chains/definitions/base.d.ts +6 -6
  91. package/_types/chains/definitions/baseGoerli.d.ts +3 -3
  92. package/_types/chains/definitions/baseSepolia.d.ts +6 -6
  93. package/_types/chains/definitions/blast.d.ts +3 -3
  94. package/_types/chains/definitions/bob.d.ts +3 -3
  95. package/_types/chains/definitions/bobSepolia.d.ts +3 -3
  96. package/_types/chains/definitions/celo.d.ts +22 -22
  97. package/_types/chains/definitions/celoAlfajores.d.ts +22 -22
  98. package/_types/chains/definitions/celoSepolia.d.ts +22 -22
  99. package/_types/chains/definitions/codex.d.ts +310 -0
  100. package/_types/chains/definitions/codex.d.ts.map +1 -0
  101. package/_types/chains/definitions/codexTestnet.d.ts +310 -0
  102. package/_types/chains/definitions/codexTestnet.d.ts.map +1 -0
  103. package/_types/chains/definitions/dchain.d.ts +3 -3
  104. package/_types/chains/definitions/dchainTestnet.d.ts +3 -3
  105. package/_types/chains/definitions/elysiumTestnet.d.ts +3 -3
  106. package/_types/chains/definitions/fraxtal.d.ts +3 -3
  107. package/_types/chains/definitions/fraxtalTestnet.d.ts +3 -3
  108. package/_types/chains/definitions/funkiMainnet.d.ts +3 -3
  109. package/_types/chains/definitions/funkiSepolia.d.ts +3 -3
  110. package/_types/chains/definitions/garnet.d.ts +3 -3
  111. package/_types/chains/definitions/giwaSepolia.d.ts +6 -6
  112. package/_types/chains/definitions/ink.d.ts +3 -3
  113. package/_types/chains/definitions/inkSepolia.d.ts +3 -3
  114. package/_types/chains/definitions/lisk.d.ts +3 -3
  115. package/_types/chains/definitions/liskSepolia.d.ts +3 -3
  116. package/_types/chains/definitions/metalL2.d.ts +3 -3
  117. package/_types/chains/definitions/mode.d.ts +3 -3
  118. package/_types/chains/definitions/modeTestnet.d.ts +3 -3
  119. package/_types/chains/definitions/optimism.d.ts +3 -3
  120. package/_types/chains/definitions/optimismGoerli.d.ts +3 -3
  121. package/_types/chains/definitions/optimismSepolia.d.ts +3 -3
  122. package/_types/chains/definitions/paseoPassetHub.d.ts +48 -0
  123. package/_types/chains/definitions/paseoPassetHub.d.ts.map +1 -0
  124. package/_types/chains/definitions/pgn.d.ts +3 -3
  125. package/_types/chains/definitions/pgnTestnet.d.ts +3 -3
  126. package/_types/chains/definitions/playfiAlbireo.d.ts +14 -14
  127. package/_types/chains/definitions/pyrope.d.ts +3 -3
  128. package/_types/chains/definitions/redstone.d.ts +3 -3
  129. package/_types/chains/definitions/rss3.d.ts +3 -3
  130. package/_types/chains/definitions/rss3Sepolia.d.ts +3 -3
  131. package/_types/chains/definitions/shape.d.ts +3 -3
  132. package/_types/chains/definitions/shapeSepolia.d.ts +3 -3
  133. package/_types/chains/definitions/snax.d.ts +3 -3
  134. package/_types/chains/definitions/snaxTestnet.d.ts +3 -3
  135. package/_types/chains/definitions/soneium.d.ts +3 -3
  136. package/_types/chains/definitions/soneiumMinato.d.ts +3 -3
  137. package/_types/chains/definitions/sophon.d.ts +14 -14
  138. package/_types/chains/definitions/sophonTestnet.d.ts +14 -14
  139. package/_types/chains/definitions/superseed.d.ts +3 -3
  140. package/_types/chains/definitions/superseedSepolia.d.ts +3 -3
  141. package/_types/chains/definitions/swellchain.d.ts +3 -3
  142. package/_types/chains/definitions/swellchainTestnet.d.ts +3 -3
  143. package/_types/chains/definitions/{tempoTestnet.d.ts → tempoAndantino.d.ts} +36 -40
  144. package/_types/chains/definitions/{tempoTestnet.d.ts.map → tempoAndantino.d.ts.map} +1 -1
  145. package/_types/chains/definitions/tempoDevnet.d.ts +43 -47
  146. package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
  147. package/_types/chains/definitions/tempoLocalnet.d.ts +30 -34
  148. package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
  149. package/_types/chains/definitions/tempoModerato.d.ts +912 -0
  150. package/_types/chains/definitions/tempoModerato.d.ts.map +1 -0
  151. package/_types/chains/definitions/treasure.d.ts +14 -14
  152. package/_types/chains/definitions/treasureTopaz.d.ts +14 -14
  153. package/_types/chains/definitions/unichain.d.ts +3 -3
  154. package/_types/chains/definitions/unichainSepolia.d.ts +3 -3
  155. package/_types/chains/definitions/worldchain.d.ts +3 -3
  156. package/_types/chains/definitions/worldchainSepolia.d.ts +3 -3
  157. package/_types/chains/definitions/zircuit.d.ts +3 -3
  158. package/_types/chains/definitions/zircuitGarfieldTestnet.d.ts +3 -3
  159. package/_types/chains/definitions/zircuitTestnet.d.ts +3 -3
  160. package/_types/chains/definitions/zksync.d.ts +14 -14
  161. package/_types/chains/definitions/zksyncInMemoryNode.d.ts +14 -14
  162. package/_types/chains/definitions/zksyncLocalCustomHyperchain.d.ts +14 -14
  163. package/_types/chains/definitions/zksyncLocalHyperchain.d.ts +14 -14
  164. package/_types/chains/definitions/zksyncLocalNode.d.ts +14 -14
  165. package/_types/chains/definitions/zksyncSepoliaTestnet.d.ts +14 -14
  166. package/_types/chains/definitions/zora.d.ts +3 -3
  167. package/_types/chains/definitions/zoraSepolia.d.ts +3 -3
  168. package/_types/chains/definitions/zoraTestnet.d.ts +3 -3
  169. package/_types/chains/index.d.ts +9 -1
  170. package/_types/chains/index.d.ts.map +1 -1
  171. package/_types/errors/version.d.ts +1 -1
  172. package/_types/index.d.ts +2 -0
  173. package/_types/index.d.ts.map +1 -1
  174. package/_types/op-stack/chainConfig.d.ts +3 -3
  175. package/_types/op-stack/formatters.d.ts +3 -3
  176. package/_types/tempo/Abis.d.ts +937 -1194
  177. package/_types/tempo/Abis.d.ts.map +1 -1
  178. package/_types/tempo/Addresses.d.ts +1 -1
  179. package/_types/tempo/Addresses.d.ts.map +1 -1
  180. package/_types/tempo/Decorator.d.ts +91 -85
  181. package/_types/tempo/Decorator.d.ts.map +1 -1
  182. package/_types/tempo/actions/amm.d.ts +19 -360
  183. package/_types/tempo/actions/amm.d.ts.map +1 -1
  184. package/_types/tempo/actions/dex.d.ts +765 -237
  185. package/_types/tempo/actions/dex.d.ts.map +1 -1
  186. package/_types/tempo/actions/fee.d.ts +30 -11
  187. package/_types/tempo/actions/fee.d.ts.map +1 -1
  188. package/_types/tempo/actions/nonce.d.ts +0 -105
  189. package/_types/tempo/actions/nonce.d.ts.map +1 -1
  190. package/_types/tempo/actions/policy.d.ts +60 -0
  191. package/_types/tempo/actions/policy.d.ts.map +1 -1
  192. package/_types/tempo/actions/reward.d.ts +350 -526
  193. package/_types/tempo/actions/reward.d.ts.map +1 -1
  194. package/_types/tempo/actions/token.d.ts +368 -1984
  195. package/_types/tempo/actions/token.d.ts.map +1 -1
  196. package/_types/tempo/chainConfig.d.ts +16 -19
  197. package/_types/tempo/chainConfig.d.ts.map +1 -1
  198. package/_types/tempo/index.d.ts +1 -1
  199. package/_types/tempo/index.d.ts.map +1 -1
  200. package/_types/utils/formatters/transaction.d.ts +1 -1
  201. package/_types/utils/formatters/transactionRequest.d.ts +1 -1
  202. package/_types/zksync/chainConfig.d.ts +14 -14
  203. package/_types/zksync/formatters.d.ts +14 -14
  204. package/account-abstraction/utils/userOperation/toPackedUserOperation.ts +17 -2
  205. package/actions/wallet/sendTransactionSync.ts +1 -0
  206. package/chains/definitions/codex.ts +45 -0
  207. package/chains/definitions/codexTestnet.ts +45 -0
  208. package/chains/definitions/paseoPassetHub.ts +23 -0
  209. package/chains/definitions/{tempoTestnet.ts → tempoAndantino.ts} +3 -3
  210. package/chains/definitions/tempoDevnet.ts +7 -1
  211. package/chains/definitions/tempoModerato.ts +25 -0
  212. package/chains/index.ts +10 -1
  213. package/errors/version.ts +1 -1
  214. package/index.ts +9 -0
  215. package/package.json +2 -2
  216. package/tempo/Abis.ts +607 -752
  217. package/tempo/Addresses.ts +1 -1
  218. package/tempo/Decorator.ts +115 -106
  219. package/tempo/actions/amm.ts +13 -115
  220. package/tempo/actions/dex.ts +274 -72
  221. package/tempo/actions/nonce.ts +0 -148
  222. package/tempo/actions/reward.ts +310 -257
  223. package/tempo/actions/token.ts +16 -2
  224. package/tempo/chainConfig.ts +2 -9
  225. package/tempo/index.ts +1 -1
  226. package/_cjs/chains/definitions/tempoTestnet.js.map +0 -1
  227. package/_esm/chains/definitions/tempoTestnet.js.map +0 -1
@@ -154,8 +154,8 @@ export namespace buy {
154
154
  export function call(args: Args) {
155
155
  const { tokenIn, tokenOut, amountOut, maxAmountIn } = args
156
156
  return defineCall({
157
- address: Addresses.stablecoinExchange,
158
- abi: Abis.stablecoinExchange,
157
+ address: Addresses.stablecoinDex,
158
+ abi: Abis.stablecoinDex,
159
159
  functionName: 'swapExactAmountOut',
160
160
  args: [tokenIn, tokenOut, amountOut, maxAmountIn],
161
161
  })
@@ -325,8 +325,8 @@ export namespace cancel {
325
325
  export function call(args: Args) {
326
326
  const { orderId } = args
327
327
  return defineCall({
328
- address: Addresses.stablecoinExchange,
329
- abi: Abis.stablecoinExchange,
328
+ address: Addresses.stablecoinDex,
329
+ abi: Abis.stablecoinDex,
330
330
  functionName: 'cancel',
331
331
  args: [orderId],
332
332
  })
@@ -340,7 +340,7 @@ export namespace cancel {
340
340
  */
341
341
  export function extractEvent(logs: viem_Log[]) {
342
342
  const [log] = parseEventLogs({
343
- abi: Abis.stablecoinExchange,
343
+ abi: Abis.stablecoinDex,
344
344
  logs,
345
345
  eventName: 'OrderCancelled',
346
346
  strict: true,
@@ -404,7 +404,208 @@ export namespace cancelSync {
404
404
 
405
405
  export type ReturnValue = Compute<
406
406
  GetEventArgs<
407
- typeof Abis.stablecoinExchange,
407
+ typeof Abis.stablecoinDex,
408
+ 'OrderCancelled',
409
+ { IndexedOnly: false; Required: true }
410
+ > & {
411
+ /** Transaction receipt. */
412
+ receipt: TransactionReceipt
413
+ }
414
+ >
415
+
416
+ // TODO: exhaustive error type
417
+ export type ErrorType = BaseErrorType
418
+ }
419
+
420
+ /**
421
+ * Cancels a stale order from the orderbook.
422
+ *
423
+ * A stale order is one where the owner's balance or allowance has dropped
424
+ * below the order amount.
425
+ *
426
+ * @example
427
+ * ```ts
428
+ * import { createClient, http } from 'viem'
429
+ * import { privateKeyToAccount } from 'viem/accounts'
430
+ * import { tempo } from 'tempo.ts/chains'
431
+ * import { Actions } from 'tempo.ts/viem'
432
+ *
433
+ * const client = createClient({
434
+ * account: privateKeyToAccount('0x...'),
435
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
436
+ * transport: http(),
437
+ * })
438
+ *
439
+ * const hash = await Actions.dex.cancelStale(client, {
440
+ * orderId: 123n,
441
+ * })
442
+ * ```
443
+ *
444
+ * @param client - Client.
445
+ * @param parameters - Parameters.
446
+ * @returns The transaction hash.
447
+ */
448
+ export async function cancelStale<
449
+ chain extends Chain | undefined,
450
+ account extends Account | undefined,
451
+ >(
452
+ client: Client<Transport, chain, account>,
453
+ parameters: cancelStale.Parameters<chain, account>,
454
+ ): Promise<cancelStale.ReturnValue> {
455
+ return cancelStale.inner(writeContract, client, parameters)
456
+ }
457
+
458
+ export namespace cancelStale {
459
+ export type Parameters<
460
+ chain extends Chain | undefined = Chain | undefined,
461
+ account extends Account | undefined = Account | undefined,
462
+ > = WriteParameters<chain, account> & Args
463
+
464
+ export type Args = {
465
+ /** Order ID to cancel. */
466
+ orderId: bigint
467
+ }
468
+
469
+ export type ReturnValue = WriteContractReturnType
470
+
471
+ // TODO: exhaustive error type
472
+ export type ErrorType = BaseErrorType
473
+
474
+ /** @internal */
475
+ export async function inner<
476
+ action extends typeof writeContract | typeof writeContractSync,
477
+ chain extends Chain | undefined,
478
+ account extends Account | undefined,
479
+ >(
480
+ action: action,
481
+ client: Client<Transport, chain, account>,
482
+ parameters: cancelStale.Parameters<chain, account>,
483
+ ): Promise<ReturnType<action>> {
484
+ const { orderId, ...rest } = parameters
485
+ const call = cancelStale.call({ orderId })
486
+ return (await action(client, {
487
+ ...rest,
488
+ ...call,
489
+ } as never)) as never
490
+ }
491
+
492
+ /**
493
+ * Defines a call to the `cancelStaleOrder` function.
494
+ *
495
+ * Can be passed as a parameter to:
496
+ * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
497
+ * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
498
+ * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
499
+ *
500
+ * @example
501
+ * ```ts
502
+ * import { createClient, http, walletActions } from 'viem'
503
+ * import { tempo } from 'tempo.ts/chains'
504
+ * import { Actions } from 'tempo.ts/viem'
505
+ *
506
+ * const client = createClient({
507
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
508
+ * transport: http(),
509
+ * }).extend(walletActions)
510
+ *
511
+ * const { result } = await client.sendCalls({
512
+ * calls: [
513
+ * Actions.dex.cancelStale.call({
514
+ * orderId: 123n,
515
+ * }),
516
+ * ]
517
+ * })
518
+ * ```
519
+ *
520
+ * @param args - Arguments.
521
+ * @returns The call.
522
+ */
523
+ export function call(args: Args) {
524
+ const { orderId } = args
525
+ return defineCall({
526
+ address: Addresses.stablecoinDex,
527
+ abi: Abis.stablecoinDex,
528
+ functionName: 'cancelStaleOrder',
529
+ args: [orderId],
530
+ })
531
+ }
532
+
533
+ /**
534
+ * Extracts the `OrderCancelled` event from logs.
535
+ *
536
+ * @param logs - The logs.
537
+ * @returns The `OrderCancelled` event.
538
+ */
539
+ export function extractEvent(logs: viem_Log[]) {
540
+ const [log] = parseEventLogs({
541
+ abi: Abis.stablecoinDex,
542
+ logs,
543
+ eventName: 'OrderCancelled',
544
+ strict: true,
545
+ })
546
+ if (!log) throw new Error('`OrderCancelled` event not found.')
547
+ return log
548
+ }
549
+ }
550
+
551
+ /**
552
+ * Cancels a stale order from the orderbook and waits for confirmation.
553
+ *
554
+ * A stale order is one where the owner's balance or allowance has dropped
555
+ * below the order amount.
556
+ *
557
+ * @example
558
+ * ```ts
559
+ * import { createClient, http } from 'viem'
560
+ * import { privateKeyToAccount } from 'viem/accounts'
561
+ * import { tempo } from 'tempo.ts/chains'
562
+ * import { Actions } from 'tempo.ts/viem'
563
+ *
564
+ * const client = createClient({
565
+ * account: privateKeyToAccount('0x...'),
566
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
567
+ * transport: http(),
568
+ * })
569
+ *
570
+ * const result = await Actions.dex.cancelStaleSync(client, {
571
+ * orderId: 123n,
572
+ * })
573
+ * ```
574
+ *
575
+ * @param client - Client.
576
+ * @param parameters - Parameters.
577
+ * @returns The transaction receipt and event data.
578
+ */
579
+ export async function cancelStaleSync<
580
+ chain extends Chain | undefined,
581
+ account extends Account | undefined,
582
+ >(
583
+ client: Client<Transport, chain, account>,
584
+ parameters: cancelStaleSync.Parameters<chain, account>,
585
+ ): Promise<cancelStaleSync.ReturnValue> {
586
+ const { throwOnReceiptRevert = true, ...rest } = parameters
587
+ const receipt = await cancelStale.inner(writeContractSync, client, {
588
+ ...rest,
589
+ throwOnReceiptRevert,
590
+ } as never)
591
+ const { args } = cancelStale.extractEvent(receipt.logs)
592
+ return {
593
+ ...args,
594
+ receipt,
595
+ } as never
596
+ }
597
+
598
+ export namespace cancelStaleSync {
599
+ export type Parameters<
600
+ chain extends Chain | undefined = Chain | undefined,
601
+ account extends Account | undefined = Account | undefined,
602
+ > = cancelStale.Parameters<chain, account>
603
+
604
+ export type Args = cancelStale.Args
605
+
606
+ export type ReturnValue = Compute<
607
+ GetEventArgs<
608
+ typeof Abis.stablecoinDex,
408
609
  'OrderCancelled',
409
610
  { IndexedOnly: false; Required: true }
410
611
  > & {
@@ -520,8 +721,8 @@ export namespace createPair {
520
721
  export function call(args: Args) {
521
722
  const { base } = args
522
723
  return defineCall({
523
- address: Addresses.stablecoinExchange,
524
- abi: Abis.stablecoinExchange,
724
+ address: Addresses.stablecoinDex,
725
+ abi: Abis.stablecoinDex,
525
726
  functionName: 'createPair',
526
727
  args: [base],
527
728
  })
@@ -535,7 +736,7 @@ export namespace createPair {
535
736
  */
536
737
  export function extractEvent(logs: viem_Log[]) {
537
738
  const [log] = parseEventLogs({
538
- abi: Abis.stablecoinExchange,
739
+ abi: Abis.stablecoinDex,
539
740
  logs,
540
741
  eventName: 'PairCreated',
541
742
  strict: true,
@@ -599,7 +800,7 @@ export namespace createPairSync {
599
800
 
600
801
  export type ReturnValue = Compute<
601
802
  GetEventArgs<
602
- typeof Abis.stablecoinExchange,
803
+ typeof Abis.stablecoinDex,
603
804
  'PairCreated',
604
805
  { IndexedOnly: false; Required: true }
605
806
  > & {
@@ -665,7 +866,7 @@ export namespace getBalance {
665
866
  }
666
867
 
667
868
  export type ReturnValue = ReadContractReturnType<
668
- typeof Abis.stablecoinExchange,
869
+ typeof Abis.stablecoinDex,
669
870
  'balanceOf',
670
871
  never
671
872
  >
@@ -679,8 +880,8 @@ export namespace getBalance {
679
880
  export function call(args: Args) {
680
881
  const { account, token } = args
681
882
  return defineCall({
682
- address: Addresses.stablecoinExchange,
683
- abi: Abis.stablecoinExchange,
883
+ address: Addresses.stablecoinDex,
884
+ abi: Abis.stablecoinDex,
684
885
  args: [account, token],
685
886
  functionName: 'balanceOf',
686
887
  })
@@ -736,7 +937,7 @@ export namespace getBuyQuote {
736
937
  }
737
938
 
738
939
  export type ReturnValue = ReadContractReturnType<
739
- typeof Abis.stablecoinExchange,
940
+ typeof Abis.stablecoinDex,
740
941
  'quoteSwapExactAmountOut',
741
942
  never
742
943
  >
@@ -750,8 +951,8 @@ export namespace getBuyQuote {
750
951
  export function call(args: Args) {
751
952
  const { tokenIn, tokenOut, amountOut } = args
752
953
  return defineCall({
753
- address: Addresses.stablecoinExchange,
754
- abi: Abis.stablecoinExchange,
954
+ address: Addresses.stablecoinDex,
955
+ abi: Abis.stablecoinDex,
755
956
  args: [tokenIn, tokenOut, amountOut],
756
957
  functionName: 'quoteSwapExactAmountOut',
757
958
  })
@@ -801,7 +1002,7 @@ export namespace getOrder {
801
1002
  }
802
1003
 
803
1004
  export type ReturnValue = ReadContractReturnType<
804
- typeof Abis.stablecoinExchange,
1005
+ typeof Abis.stablecoinDex,
805
1006
  'getOrder',
806
1007
  never
807
1008
  >
@@ -815,8 +1016,8 @@ export namespace getOrder {
815
1016
  export function call(args: Args) {
816
1017
  const { orderId } = args
817
1018
  return defineCall({
818
- address: Addresses.stablecoinExchange,
819
- abi: Abis.stablecoinExchange,
1019
+ address: Addresses.stablecoinDex,
1020
+ abi: Abis.stablecoinDex,
820
1021
  args: [orderId],
821
1022
  functionName: 'getOrder',
822
1023
  })
@@ -869,7 +1070,7 @@ export namespace getOrderbook {
869
1070
  }
870
1071
 
871
1072
  export type ReturnValue = ReadContractReturnType<
872
- typeof Abis.stablecoinExchange,
1073
+ typeof Abis.stablecoinDex,
873
1074
  'books',
874
1075
  never
875
1076
  >
@@ -884,8 +1085,8 @@ export namespace getOrderbook {
884
1085
  const { base, quote } = args
885
1086
  const pairKey = getPairKey(base, quote)
886
1087
  return defineCall({
887
- address: Addresses.stablecoinExchange,
888
- abi: Abis.stablecoinExchange,
1088
+ address: Addresses.stablecoinDex,
1089
+ abi: Abis.stablecoinDex,
889
1090
  args: [pairKey],
890
1091
  functionName: 'books',
891
1092
  })
@@ -959,8 +1160,8 @@ export namespace getTickLevel {
959
1160
  export function call(args: Args) {
960
1161
  const { base, tick, isBid } = args
961
1162
  return defineCall({
962
- address: Addresses.stablecoinExchange,
963
- abi: Abis.stablecoinExchange,
1163
+ address: Addresses.stablecoinDex,
1164
+ abi: Abis.stablecoinDex,
964
1165
  args: [base, tick, isBid],
965
1166
  functionName: 'getTickLevel',
966
1167
  })
@@ -1016,7 +1217,7 @@ export namespace getSellQuote {
1016
1217
  }
1017
1218
 
1018
1219
  export type ReturnValue = ReadContractReturnType<
1019
- typeof Abis.stablecoinExchange,
1220
+ typeof Abis.stablecoinDex,
1020
1221
  'quoteSwapExactAmountIn',
1021
1222
  never
1022
1223
  >
@@ -1030,8 +1231,8 @@ export namespace getSellQuote {
1030
1231
  export function call(args: Args) {
1031
1232
  const { tokenIn, tokenOut, amountIn } = args
1032
1233
  return defineCall({
1033
- address: Addresses.stablecoinExchange,
1034
- abi: Abis.stablecoinExchange,
1234
+ address: Addresses.stablecoinDex,
1235
+ abi: Abis.stablecoinDex,
1035
1236
  args: [tokenIn, tokenOut, amountIn],
1036
1237
  functionName: 'quoteSwapExactAmountIn',
1037
1238
  })
@@ -1154,8 +1355,8 @@ export namespace place {
1154
1355
  const { token, amount, type, tick } = args
1155
1356
  const isBid = type === 'buy'
1156
1357
  return defineCall({
1157
- address: Addresses.stablecoinExchange,
1158
- abi: Abis.stablecoinExchange,
1358
+ address: Addresses.stablecoinDex,
1359
+ abi: Abis.stablecoinDex,
1159
1360
  functionName: 'place',
1160
1361
  args: [token, amount, isBid, tick],
1161
1362
  })
@@ -1169,7 +1370,7 @@ export namespace place {
1169
1370
  */
1170
1371
  export function extractEvent(logs: viem_Log[]) {
1171
1372
  const [log] = parseEventLogs({
1172
- abi: Abis.stablecoinExchange,
1373
+ abi: Abis.stablecoinDex,
1173
1374
  logs,
1174
1375
  eventName: 'OrderPlaced',
1175
1376
  strict: true,
@@ -1299,27 +1500,28 @@ export namespace placeFlip {
1299
1500
  const { token, amount, type, tick, flipTick } = args
1300
1501
  const isBid = type === 'buy'
1301
1502
  return defineCall({
1302
- address: Addresses.stablecoinExchange,
1303
- abi: Abis.stablecoinExchange,
1503
+ address: Addresses.stablecoinDex,
1504
+ abi: Abis.stablecoinDex,
1304
1505
  functionName: 'placeFlip',
1305
1506
  args: [token, amount, isBid, tick, flipTick],
1306
1507
  })
1307
1508
  }
1308
1509
 
1309
1510
  /**
1310
- * Extracts the `FlipOrderPlaced` event from logs.
1511
+ * Extracts the `OrderPlaced` event (with `isFlipOrder: true`) from logs.
1311
1512
  *
1312
1513
  * @param logs - The logs.
1313
- * @returns The `FlipOrderPlaced` event.
1514
+ * @returns The `OrderPlaced` event for a flip order.
1314
1515
  */
1315
1516
  export function extractEvent(logs: viem_Log[]) {
1316
- const [log] = parseEventLogs({
1317
- abi: Abis.stablecoinExchange,
1517
+ const parsedLogs = parseEventLogs({
1518
+ abi: Abis.stablecoinDex,
1318
1519
  logs,
1319
- eventName: 'FlipOrderPlaced',
1520
+ eventName: 'OrderPlaced',
1320
1521
  strict: true,
1321
1522
  })
1322
- if (!log) throw new Error('`FlipOrderPlaced` event not found.')
1523
+ const log = parsedLogs.find((l) => l.args.isFlipOrder)
1524
+ if (!log) throw new Error('`OrderPlaced` event (flip order) not found.')
1323
1525
  return log
1324
1526
  }
1325
1527
  }
@@ -1382,8 +1584,8 @@ export namespace placeFlipSync {
1382
1584
 
1383
1585
  export type ReturnValue = Compute<
1384
1586
  GetEventArgs<
1385
- typeof Abis.stablecoinExchange,
1386
- 'FlipOrderPlaced',
1587
+ typeof Abis.stablecoinDex,
1588
+ 'OrderPlaced',
1387
1589
  { IndexedOnly: false; Required: true }
1388
1590
  > & {
1389
1591
  /** Transaction receipt. */
@@ -1452,7 +1654,7 @@ export namespace placeSync {
1452
1654
 
1453
1655
  export type ReturnValue = Compute<
1454
1656
  GetEventArgs<
1455
- typeof Abis.stablecoinExchange,
1657
+ typeof Abis.stablecoinDex,
1456
1658
  'OrderPlaced',
1457
1659
  { IndexedOnly: false; Required: true }
1458
1660
  > & {
@@ -1580,8 +1782,8 @@ export namespace sell {
1580
1782
  export function call(args: Args) {
1581
1783
  const { tokenIn, tokenOut, amountIn, minAmountOut } = args
1582
1784
  return defineCall({
1583
- address: Addresses.stablecoinExchange,
1584
- abi: Abis.stablecoinExchange,
1785
+ address: Addresses.stablecoinDex,
1786
+ abi: Abis.stablecoinDex,
1585
1787
  functionName: 'swapExactAmountIn',
1586
1788
  args: [tokenIn, tokenOut, amountIn, minAmountOut],
1587
1789
  })
@@ -1683,15 +1885,17 @@ export function watchFlipOrderPlaced<
1683
1885
  const { onFlipOrderPlaced, maker, token, ...rest } = parameters
1684
1886
  return watchContractEvent(client, {
1685
1887
  ...rest,
1686
- address: Addresses.stablecoinExchange,
1687
- abi: Abis.stablecoinExchange,
1688
- eventName: 'FlipOrderPlaced',
1888
+ address: Addresses.stablecoinDex,
1889
+ abi: Abis.stablecoinDex,
1890
+ eventName: 'OrderPlaced',
1689
1891
  args: {
1690
1892
  ...(maker !== undefined && { maker }),
1691
1893
  ...(token !== undefined && { token }),
1692
1894
  },
1693
1895
  onLogs: (logs) => {
1694
- for (const log of logs) onFlipOrderPlaced(log.args, log)
1896
+ for (const log of logs) {
1897
+ if (log.args.isFlipOrder) onFlipOrderPlaced(log.args, log)
1898
+ }
1695
1899
  },
1696
1900
  strict: true,
1697
1901
  })
@@ -1699,8 +1903,8 @@ export function watchFlipOrderPlaced<
1699
1903
 
1700
1904
  export declare namespace watchFlipOrderPlaced {
1701
1905
  export type Args = GetEventArgs<
1702
- typeof Abis.stablecoinExchange,
1703
- 'FlipOrderPlaced',
1906
+ typeof Abis.stablecoinDex,
1907
+ 'OrderPlaced',
1704
1908
  { IndexedOnly: false; Required: true }
1705
1909
  >
1706
1910
 
@@ -1708,14 +1912,14 @@ export declare namespace watchFlipOrderPlaced {
1708
1912
  bigint,
1709
1913
  number,
1710
1914
  false,
1711
- ExtractAbiItem<typeof Abis.stablecoinExchange, 'FlipOrderPlaced'>,
1915
+ ExtractAbiItem<typeof Abis.stablecoinDex, 'OrderPlaced'>,
1712
1916
  true
1713
1917
  >
1714
1918
 
1715
1919
  export type Parameters = UnionOmit<
1716
1920
  WatchContractEventParameters<
1717
- typeof Abis.stablecoinExchange,
1718
- 'FlipOrderPlaced',
1921
+ typeof Abis.stablecoinDex,
1922
+ 'OrderPlaced',
1719
1923
  true
1720
1924
  >,
1721
1925
  'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'
@@ -1764,8 +1968,8 @@ export function watchOrderCancelled<
1764
1968
  const { onOrderCancelled, orderId, ...rest } = parameters
1765
1969
  return watchContractEvent(client, {
1766
1970
  ...rest,
1767
- address: Addresses.stablecoinExchange,
1768
- abi: Abis.stablecoinExchange,
1971
+ address: Addresses.stablecoinDex,
1972
+ abi: Abis.stablecoinDex,
1769
1973
  eventName: 'OrderCancelled',
1770
1974
  args: orderId !== undefined ? { orderId } : undefined,
1771
1975
  onLogs: (logs) => {
@@ -1777,7 +1981,7 @@ export function watchOrderCancelled<
1777
1981
 
1778
1982
  export declare namespace watchOrderCancelled {
1779
1983
  export type Args = GetEventArgs<
1780
- typeof Abis.stablecoinExchange,
1984
+ typeof Abis.stablecoinDex,
1781
1985
  'OrderCancelled',
1782
1986
  { IndexedOnly: false; Required: true }
1783
1987
  >
@@ -1786,13 +1990,13 @@ export declare namespace watchOrderCancelled {
1786
1990
  bigint,
1787
1991
  number,
1788
1992
  false,
1789
- ExtractAbiItem<typeof Abis.stablecoinExchange, 'OrderCancelled'>,
1993
+ ExtractAbiItem<typeof Abis.stablecoinDex, 'OrderCancelled'>,
1790
1994
  true
1791
1995
  >
1792
1996
 
1793
1997
  export type Parameters = UnionOmit<
1794
1998
  WatchContractEventParameters<
1795
- typeof Abis.stablecoinExchange,
1999
+ typeof Abis.stablecoinDex,
1796
2000
  'OrderCancelled',
1797
2001
  true
1798
2002
  >,
@@ -1840,8 +2044,8 @@ export function watchOrderFilled<
1840
2044
  const { onOrderFilled, maker, taker, orderId, ...rest } = parameters
1841
2045
  return watchContractEvent(client, {
1842
2046
  ...rest,
1843
- address: Addresses.stablecoinExchange,
1844
- abi: Abis.stablecoinExchange,
2047
+ address: Addresses.stablecoinDex,
2048
+ abi: Abis.stablecoinDex,
1845
2049
  eventName: 'OrderFilled',
1846
2050
  args: {
1847
2051
  ...(orderId !== undefined && { orderId }),
@@ -1857,7 +2061,7 @@ export function watchOrderFilled<
1857
2061
 
1858
2062
  export declare namespace watchOrderFilled {
1859
2063
  export type Args = GetEventArgs<
1860
- typeof Abis.stablecoinExchange,
2064
+ typeof Abis.stablecoinDex,
1861
2065
  'OrderFilled',
1862
2066
  { IndexedOnly: false; Required: true }
1863
2067
  >
@@ -1866,13 +2070,13 @@ export declare namespace watchOrderFilled {
1866
2070
  bigint,
1867
2071
  number,
1868
2072
  false,
1869
- ExtractAbiItem<typeof Abis.stablecoinExchange, 'OrderFilled'>,
2073
+ ExtractAbiItem<typeof Abis.stablecoinDex, 'OrderFilled'>,
1870
2074
  true
1871
2075
  >
1872
2076
 
1873
2077
  export type Parameters = UnionOmit<
1874
2078
  WatchContractEventParameters<
1875
- typeof Abis.stablecoinExchange,
2079
+ typeof Abis.stablecoinDex,
1876
2080
  'OrderFilled',
1877
2081
  true
1878
2082
  >,
@@ -1924,8 +2128,8 @@ export function watchOrderPlaced<
1924
2128
  const { onOrderPlaced, maker, token, ...rest } = parameters
1925
2129
  return watchContractEvent(client, {
1926
2130
  ...rest,
1927
- address: Addresses.stablecoinExchange,
1928
- abi: Abis.stablecoinExchange,
2131
+ address: Addresses.stablecoinDex,
2132
+ abi: Abis.stablecoinDex,
1929
2133
  eventName: 'OrderPlaced',
1930
2134
  args: {
1931
2135
  ...(maker !== undefined && { maker }),
@@ -1940,7 +2144,7 @@ export function watchOrderPlaced<
1940
2144
 
1941
2145
  export declare namespace watchOrderPlaced {
1942
2146
  export type Args = GetEventArgs<
1943
- typeof Abis.stablecoinExchange,
2147
+ typeof Abis.stablecoinDex,
1944
2148
  'OrderPlaced',
1945
2149
  { IndexedOnly: false; Required: true }
1946
2150
  >
@@ -1949,13 +2153,13 @@ export declare namespace watchOrderPlaced {
1949
2153
  bigint,
1950
2154
  number,
1951
2155
  false,
1952
- ExtractAbiItem<typeof Abis.stablecoinExchange, 'OrderPlaced'>,
2156
+ ExtractAbiItem<typeof Abis.stablecoinDex, 'OrderPlaced'>,
1953
2157
  true
1954
2158
  >
1955
2159
 
1956
2160
  export type Parameters = UnionOmit<
1957
2161
  WatchContractEventParameters<
1958
- typeof Abis.stablecoinExchange,
2162
+ typeof Abis.stablecoinDex,
1959
2163
  'OrderPlaced',
1960
2164
  true
1961
2165
  >,
@@ -2077,8 +2281,8 @@ export namespace withdraw {
2077
2281
  export function call(args: Args) {
2078
2282
  const { token, amount } = args
2079
2283
  return defineCall({
2080
- address: Addresses.stablecoinExchange,
2081
- abi: Abis.stablecoinExchange,
2284
+ address: Addresses.stablecoinDex,
2285
+ abi: Abis.stablecoinDex,
2082
2286
  functionName: 'withdraw',
2083
2287
  args: [token, amount],
2084
2288
  })
@@ -2144,7 +2348,5 @@ export namespace withdrawSync {
2144
2348
  }
2145
2349
 
2146
2350
  function getPairKey(base: Address, quote: Address) {
2147
- const [tokenA, tokenB] =
2148
- Hex.toBigInt(base) < Hex.toBigInt(quote) ? [base, quote] : [quote, base]
2149
- return Hash.keccak256(Hex.concat(tokenA, tokenB))
2351
+ return Hash.keccak256(Hex.concat(base, quote))
2150
2352
  }