tempo.ts 0.1.5 → 0.2.1

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 (297) hide show
  1. package/README.md +33 -2
  2. package/dist/chains.d.ts +509 -115
  3. package/dist/chains.d.ts.map +1 -1
  4. package/dist/chains.js +20 -9
  5. package/dist/chains.js.map +1 -1
  6. package/dist/ox/Order.d.ts +92 -0
  7. package/dist/ox/Order.d.ts.map +1 -0
  8. package/dist/ox/Order.js +88 -0
  9. package/dist/ox/Order.js.map +1 -0
  10. package/dist/ox/OrdersFilters.d.ts +72 -0
  11. package/dist/ox/OrdersFilters.d.ts.map +1 -0
  12. package/dist/ox/OrdersFilters.js +100 -0
  13. package/dist/ox/OrdersFilters.js.map +1 -0
  14. package/dist/ox/Pagination.d.ts +128 -0
  15. package/dist/ox/Pagination.d.ts.map +1 -0
  16. package/dist/ox/Pagination.js +78 -0
  17. package/dist/ox/Pagination.js.map +1 -0
  18. package/dist/ox/PoolId.d.ts +18 -0
  19. package/dist/ox/PoolId.d.ts.map +1 -0
  20. package/dist/ox/PoolId.js +13 -0
  21. package/dist/ox/PoolId.js.map +1 -0
  22. package/dist/ox/RpcSchema.d.ts +32 -0
  23. package/dist/ox/RpcSchema.d.ts.map +1 -0
  24. package/dist/ox/RpcSchema.js +2 -0
  25. package/dist/ox/RpcSchema.js.map +1 -0
  26. package/dist/ox/SignatureEnvelope.d.ts +1 -1
  27. package/dist/ox/SignatureEnvelope.d.ts.map +1 -1
  28. package/dist/ox/SignatureEnvelope.js.map +1 -1
  29. package/dist/{viem → ox}/Tick.d.ts +4 -0
  30. package/dist/ox/Tick.d.ts.map +1 -0
  31. package/dist/ox/Tick.js.map +1 -0
  32. package/dist/ox/Transaction.d.ts.map +1 -1
  33. package/dist/ox/Transaction.js +2 -1
  34. package/dist/ox/Transaction.js.map +1 -1
  35. package/dist/ox/TransactionEnvelopeAA.d.ts +6 -6
  36. package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -1
  37. package/dist/ox/TransactionEnvelopeAA.js +4 -2
  38. package/dist/ox/TransactionEnvelopeAA.js.map +1 -1
  39. package/dist/ox/TransactionRequest.d.ts +4 -0
  40. package/dist/ox/TransactionRequest.d.ts.map +1 -1
  41. package/dist/ox/TransactionRequest.js.map +1 -1
  42. package/dist/ox/index.d.ts +6 -0
  43. package/dist/ox/index.d.ts.map +1 -1
  44. package/dist/ox/index.js +6 -0
  45. package/dist/ox/index.js.map +1 -1
  46. package/dist/prool/Instance.d.ts.map +1 -1
  47. package/dist/prool/Instance.js +20 -4
  48. package/dist/prool/Instance.js.map +1 -1
  49. package/dist/viem/Abis.d.ts +1469 -1082
  50. package/dist/viem/Abis.d.ts.map +1 -1
  51. package/dist/viem/Abis.js +932 -671
  52. package/dist/viem/Abis.js.map +1 -1
  53. package/dist/viem/Account.d.ts +150 -0
  54. package/dist/viem/Account.d.ts.map +1 -0
  55. package/dist/viem/Account.js +221 -0
  56. package/dist/viem/Account.js.map +1 -0
  57. package/dist/viem/Actions/amm.d.ts +144 -161
  58. package/dist/viem/Actions/amm.d.ts.map +1 -1
  59. package/dist/viem/Actions/amm.js +109 -163
  60. package/dist/viem/Actions/amm.js.map +1 -1
  61. package/dist/viem/Actions/dex.d.ts +920 -664
  62. package/dist/viem/Actions/dex.d.ts.map +1 -1
  63. package/dist/viem/Actions/dex.js +129 -30
  64. package/dist/viem/Actions/dex.js.map +1 -1
  65. package/dist/viem/Actions/faucet.d.ts +34 -0
  66. package/dist/viem/Actions/faucet.d.ts.map +1 -0
  67. package/dist/viem/Actions/faucet.js +33 -0
  68. package/dist/viem/Actions/faucet.js.map +1 -0
  69. package/dist/viem/Actions/fee.d.ts +16 -30
  70. package/dist/viem/Actions/fee.d.ts.map +1 -1
  71. package/dist/viem/Actions/fee.js +13 -13
  72. package/dist/viem/Actions/fee.js.map +1 -1
  73. package/dist/viem/Actions/index.d.ts +2 -0
  74. package/dist/viem/Actions/index.d.ts.map +1 -1
  75. package/dist/viem/Actions/index.js +2 -0
  76. package/dist/viem/Actions/index.js.map +1 -1
  77. package/dist/viem/Actions/policy.d.ts +46 -46
  78. package/dist/viem/Actions/policy.js +46 -46
  79. package/dist/viem/Actions/reward.d.ts +3236 -0
  80. package/dist/viem/Actions/reward.d.ts.map +1 -0
  81. package/dist/viem/Actions/reward.js +725 -0
  82. package/dist/viem/Actions/reward.js.map +1 -0
  83. package/dist/viem/Actions/token.d.ts +4399 -2750
  84. package/dist/viem/Actions/token.d.ts.map +1 -1
  85. package/dist/viem/Actions/token.js +361 -482
  86. package/dist/viem/Actions/token.js.map +1 -1
  87. package/dist/viem/Addresses.d.ts +1 -2
  88. package/dist/viem/Addresses.d.ts.map +1 -1
  89. package/dist/viem/Addresses.js +1 -2
  90. package/dist/viem/Addresses.js.map +1 -1
  91. package/dist/viem/Chain.d.ts +38 -12
  92. package/dist/viem/Chain.d.ts.map +1 -1
  93. package/dist/viem/Chain.js +27 -18
  94. package/dist/viem/Chain.js.map +1 -1
  95. package/dist/viem/Decorator.d.ts +1009 -428
  96. package/dist/viem/Decorator.d.ts.map +1 -1
  97. package/dist/viem/Decorator.js +17 -5
  98. package/dist/viem/Decorator.js.map +1 -1
  99. package/dist/viem/Formatters.d.ts +8 -1
  100. package/dist/viem/Formatters.d.ts.map +1 -1
  101. package/dist/viem/Formatters.js +17 -0
  102. package/dist/viem/Formatters.js.map +1 -1
  103. package/dist/viem/P256.d.ts +2 -0
  104. package/dist/viem/P256.d.ts.map +1 -0
  105. package/dist/viem/P256.js +2 -0
  106. package/dist/viem/P256.js.map +1 -0
  107. package/dist/viem/Secp256k1.d.ts +2 -0
  108. package/dist/viem/Secp256k1.d.ts.map +1 -0
  109. package/dist/viem/Secp256k1.js +2 -0
  110. package/dist/viem/Secp256k1.js.map +1 -0
  111. package/dist/viem/TokenIds.d.ts +1 -2
  112. package/dist/viem/TokenIds.d.ts.map +1 -1
  113. package/dist/viem/TokenIds.js +1 -2
  114. package/dist/viem/TokenIds.js.map +1 -1
  115. package/dist/viem/Transaction.d.ts +1 -1
  116. package/dist/viem/Transaction.d.ts.map +1 -1
  117. package/dist/viem/Transaction.js +46 -5
  118. package/dist/viem/Transaction.js.map +1 -1
  119. package/dist/viem/WebAuthnP256.d.ts +79 -0
  120. package/dist/viem/WebAuthnP256.d.ts.map +1 -0
  121. package/dist/viem/WebAuthnP256.js +95 -0
  122. package/dist/viem/WebAuthnP256.js.map +1 -0
  123. package/dist/viem/WebCryptoP256.d.ts +2 -0
  124. package/dist/viem/WebCryptoP256.d.ts.map +1 -0
  125. package/dist/viem/WebCryptoP256.js +2 -0
  126. package/dist/viem/WebCryptoP256.js.map +1 -0
  127. package/dist/viem/index.d.ts +6 -3
  128. package/dist/viem/index.d.ts.map +1 -1
  129. package/dist/viem/index.js +6 -3
  130. package/dist/viem/index.js.map +1 -1
  131. package/dist/viem/internal/account.d.ts +24 -0
  132. package/dist/viem/internal/account.d.ts.map +1 -0
  133. package/dist/viem/internal/account.js +68 -0
  134. package/dist/viem/internal/account.js.map +1 -0
  135. package/dist/viem/internal/types.d.ts +10 -0
  136. package/dist/viem/internal/types.d.ts.map +1 -1
  137. package/dist/wagmi/Actions/amm.d.ts +428 -0
  138. package/dist/wagmi/Actions/amm.d.ts.map +1 -0
  139. package/dist/wagmi/Actions/amm.js +472 -0
  140. package/dist/wagmi/Actions/amm.js.map +1 -0
  141. package/dist/wagmi/Actions/dex.d.ts +908 -0
  142. package/dist/wagmi/Actions/dex.d.ts.map +1 -0
  143. package/dist/wagmi/Actions/dex.js +1023 -0
  144. package/dist/wagmi/Actions/dex.js.map +1 -0
  145. package/dist/wagmi/Actions/faucet.d.ts +35 -0
  146. package/dist/wagmi/Actions/faucet.d.ts.map +1 -0
  147. package/dist/wagmi/Actions/faucet.js +33 -0
  148. package/dist/wagmi/Actions/faucet.js.map +1 -0
  149. package/dist/wagmi/Actions/fee.d.ts +111 -0
  150. package/dist/wagmi/Actions/fee.d.ts.map +1 -0
  151. package/dist/wagmi/Actions/fee.js +126 -0
  152. package/dist/wagmi/Actions/fee.js.map +1 -0
  153. package/dist/wagmi/Actions/index.d.ts +7 -0
  154. package/dist/wagmi/Actions/index.d.ts.map +1 -0
  155. package/dist/wagmi/Actions/index.js +7 -0
  156. package/dist/wagmi/Actions/index.js.map +1 -0
  157. package/dist/wagmi/Actions/reward.d.ts +348 -0
  158. package/dist/wagmi/Actions/reward.d.ts.map +1 -0
  159. package/dist/wagmi/Actions/reward.js +388 -0
  160. package/dist/wagmi/Actions/reward.js.map +1 -0
  161. package/dist/wagmi/Actions/token.d.ts +1546 -0
  162. package/dist/wagmi/Actions/token.d.ts.map +1 -0
  163. package/dist/wagmi/Actions/token.js +1712 -0
  164. package/dist/wagmi/Actions/token.js.map +1 -0
  165. package/dist/wagmi/Connector.d.ts +81 -0
  166. package/dist/wagmi/Connector.d.ts.map +1 -0
  167. package/dist/wagmi/Connector.js +261 -0
  168. package/dist/wagmi/Connector.js.map +1 -0
  169. package/dist/wagmi/Hooks/amm.d.ts +421 -0
  170. package/dist/wagmi/Hooks/amm.d.ts.map +1 -0
  171. package/dist/wagmi/Hooks/amm.js +504 -0
  172. package/dist/wagmi/Hooks/amm.js.map +1 -0
  173. package/dist/wagmi/Hooks/dex.d.ts +816 -0
  174. package/dist/wagmi/Hooks/dex.d.ts.map +1 -0
  175. package/dist/wagmi/Hooks/dex.js +973 -0
  176. package/dist/wagmi/Hooks/dex.js.map +1 -0
  177. package/dist/wagmi/Hooks/faucet.d.ts +39 -0
  178. package/dist/wagmi/Hooks/faucet.d.ts.map +1 -0
  179. package/dist/wagmi/Hooks/faucet.js +40 -0
  180. package/dist/wagmi/Hooks/faucet.js.map +1 -0
  181. package/dist/wagmi/Hooks/fee.d.ts +97 -0
  182. package/dist/wagmi/Hooks/fee.d.ts.map +1 -0
  183. package/dist/wagmi/Hooks/fee.js +109 -0
  184. package/dist/wagmi/Hooks/fee.js.map +1 -0
  185. package/dist/wagmi/Hooks/index.d.ts +7 -0
  186. package/dist/wagmi/Hooks/index.d.ts.map +1 -0
  187. package/dist/wagmi/Hooks/index.js +7 -0
  188. package/dist/wagmi/Hooks/index.js.map +1 -0
  189. package/dist/wagmi/Hooks/reward.d.ts +307 -0
  190. package/dist/wagmi/Hooks/reward.d.ts.map +1 -0
  191. package/dist/wagmi/Hooks/reward.js +349 -0
  192. package/dist/wagmi/Hooks/reward.js.map +1 -0
  193. package/dist/wagmi/Hooks/token.d.ts +1388 -0
  194. package/dist/wagmi/Hooks/token.d.ts.map +1 -0
  195. package/dist/wagmi/Hooks/token.js +1657 -0
  196. package/dist/wagmi/Hooks/token.js.map +1 -0
  197. package/dist/wagmi/index.d.ts +4 -0
  198. package/dist/wagmi/index.d.ts.map +1 -0
  199. package/dist/wagmi/index.js +4 -0
  200. package/dist/wagmi/index.js.map +1 -0
  201. package/package.json +54 -10
  202. package/src/chains.ts +21 -9
  203. package/src/ox/Order.test.ts +78 -0
  204. package/src/ox/Order.ts +125 -0
  205. package/src/ox/OrdersFilters.test.ts +182 -0
  206. package/src/ox/OrdersFilters.ts +125 -0
  207. package/src/ox/Pagination.test.ts +162 -0
  208. package/src/ox/Pagination.ts +164 -0
  209. package/src/ox/PoolId.test.ts +33 -0
  210. package/src/ox/PoolId.ts +27 -0
  211. package/src/ox/RpcSchema.ts +35 -0
  212. package/src/ox/SignatureEnvelope.ts +3 -1
  213. package/src/{viem → ox}/Tick.test.ts +1 -1
  214. package/src/{viem → ox}/Tick.ts +5 -0
  215. package/src/ox/Transaction.test.ts +1 -1
  216. package/src/ox/Transaction.ts +2 -1
  217. package/src/ox/TransactionEnvelopeAA.test.ts +239 -96
  218. package/src/ox/TransactionEnvelopeAA.ts +9 -7
  219. package/src/ox/TransactionRequest.ts +4 -0
  220. package/src/ox/index.ts +6 -0
  221. package/src/prool/Instance.ts +51 -37
  222. package/src/prool/internal/chain.json +104 -52
  223. package/src/tsconfig.json +9 -0
  224. package/src/viem/Abis.ts +972 -710
  225. package/src/viem/Account.ts +279 -0
  226. package/src/viem/Actions/__snapshots__/dex.test.ts.snap +850 -0
  227. package/src/viem/Actions/amm.test.ts +173 -169
  228. package/src/viem/Actions/amm.ts +131 -203
  229. package/src/viem/Actions/dex.test.ts +563 -484
  230. package/src/viem/Actions/dex.ts +203 -30
  231. package/src/viem/Actions/faucet.ts +50 -0
  232. package/src/viem/Actions/fee.test.ts +23 -34
  233. package/src/viem/Actions/fee.ts +20 -13
  234. package/src/viem/Actions/index.ts +2 -0
  235. package/src/viem/Actions/policy.test.ts +19 -33
  236. package/src/viem/Actions/policy.ts +46 -46
  237. package/src/viem/Actions/reward.test.ts +457 -0
  238. package/src/viem/Actions/reward.ts +999 -0
  239. package/src/viem/Actions/token.test.ts +453 -287
  240. package/src/viem/Actions/token.ts +605 -693
  241. package/src/viem/Addresses.ts +1 -2
  242. package/src/viem/Chain.bench-d.ts +12 -0
  243. package/src/viem/Chain.ts +70 -20
  244. package/src/viem/Decorator.bench-d.ts +1 -1
  245. package/src/viem/Decorator.test.ts +3 -1
  246. package/src/viem/Decorator.ts +1049 -442
  247. package/src/viem/Formatters.ts +31 -5
  248. package/src/viem/P256.ts +1 -0
  249. package/src/viem/Secp256k1.ts +1 -0
  250. package/src/viem/TokenIds.ts +1 -2
  251. package/src/viem/Transaction.ts +53 -7
  252. package/src/viem/WebAuthnP256.ts +140 -0
  253. package/src/viem/WebCryptoP256.ts +1 -0
  254. package/src/viem/e2e.test.ts +1126 -297
  255. package/src/viem/index.ts +6 -3
  256. package/src/viem/internal/account.ts +107 -0
  257. package/src/viem/internal/types.ts +9 -0
  258. package/src/wagmi/Actions/__snapshots__/dex.test.ts.snap +310 -0
  259. package/src/wagmi/Actions/amm.test.ts +198 -0
  260. package/src/wagmi/Actions/amm.ts +691 -0
  261. package/src/wagmi/Actions/dex.test.ts +1507 -0
  262. package/src/wagmi/Actions/dex.ts +1640 -0
  263. package/src/wagmi/Actions/faucet.ts +46 -0
  264. package/src/wagmi/Actions/fee.test.ts +63 -0
  265. package/src/wagmi/Actions/fee.ts +208 -0
  266. package/src/wagmi/Actions/index.ts +6 -0
  267. package/src/wagmi/Actions/reward.test.ts +210 -0
  268. package/src/wagmi/Actions/reward.ts +632 -0
  269. package/src/wagmi/Actions/token.test.ts +1308 -0
  270. package/src/wagmi/Actions/token.ts +2613 -0
  271. package/src/wagmi/Connector.test.ts +53 -0
  272. package/src/wagmi/Connector.ts +390 -0
  273. package/src/wagmi/Hooks/__snapshots__/dex.test.ts.snap +457 -0
  274. package/src/wagmi/Hooks/amm.test.ts +424 -0
  275. package/src/wagmi/Hooks/amm.ts +806 -0
  276. package/src/wagmi/Hooks/dex.test.ts +1017 -0
  277. package/src/wagmi/Hooks/dex.ts +1685 -0
  278. package/src/wagmi/Hooks/faucet.ts +76 -0
  279. package/src/wagmi/Hooks/fee.test.ts +166 -0
  280. package/src/wagmi/Hooks/fee.ts +206 -0
  281. package/src/wagmi/Hooks/index.ts +6 -0
  282. package/src/wagmi/Hooks/reward.test.ts +219 -0
  283. package/src/wagmi/Hooks/reward.ts +672 -0
  284. package/src/wagmi/Hooks/token.test.ts +1670 -0
  285. package/src/wagmi/Hooks/token.ts +2906 -0
  286. package/src/wagmi/index.ts +3 -0
  287. package/src/wagmi/internal/types.ts +16 -0
  288. package/dist/viem/Client.d.ts +0 -27
  289. package/dist/viem/Client.d.ts.map +0 -1
  290. package/dist/viem/Client.js +0 -28
  291. package/dist/viem/Client.js.map +0 -1
  292. package/dist/viem/Tick.d.ts.map +0 -1
  293. package/dist/viem/Tick.js.map +0 -1
  294. package/src/viem/Client.bench-d.ts +0 -8
  295. package/src/viem/Client.test.ts +0 -178
  296. package/src/viem/Client.ts +0 -91
  297. /package/dist/{viem → ox}/Tick.js +0 -0
@@ -1,116 +1,39 @@
1
1
  import { setTimeout } from 'node:timers/promises'
2
- import { Abis, Actions, Addresses, createTempoClient } from 'tempo.ts/viem'
3
- import { parseEther, publicActions } from 'viem'
4
- import { mnemonicToAccount } from 'viem/accounts'
2
+ import { Abis, Actions } from 'tempo.ts/viem'
3
+ import { parseUnits } from 'viem'
5
4
  import { writeContractSync } from 'viem/actions'
6
5
  import { describe, expect, test } from 'vitest'
7
- import { tempoTest } from '../../../test/viem/config.js'
8
-
9
- const account = mnemonicToAccount(
10
- 'test test test test test test test test test test test junk',
11
- )
12
- const account2 = mnemonicToAccount(
13
- 'test test test test test test test test test test test junk',
14
- { accountIndex: 1 },
15
- )
16
-
17
- const client = createTempoClient({
18
- account,
19
- chain: tempoTest,
20
- pollingInterval: 100,
21
- }).extend(publicActions)
22
-
23
- async function setupPoolWithLiquidity() {
24
- // Create a new token for testing
25
- const { token } = await Actions.token.createSync(client, {
26
- name: 'Test Token',
27
- symbol: 'TEST',
28
- currency: 'USD',
29
- })
30
-
31
- // Grant issuer role to mint tokens
32
- await Actions.token.grantRolesSync(client, {
33
- token,
34
- roles: ['issuer'],
35
- to: client.account.address,
36
- })
37
-
38
- // Mint some tokens to account
39
- await Actions.token.mintSync(client, {
40
- to: account.address,
41
- amount: parseEther('1000'),
42
- token,
43
- })
44
-
45
- // Add liquidity to pool
46
- await Actions.amm.mintSync(client, {
47
- userToken: {
48
- address: token,
49
- amount: parseEther('100'),
50
- },
51
- validatorToken: {
52
- address: Addresses.defaultFeeToken,
53
- amount: parseEther('100'),
54
- },
55
- to: account.address,
56
- })
57
-
58
- return { tokenAddress: token }
59
- }
6
+ import {
7
+ accounts,
8
+ client,
9
+ setupPoolWithLiquidity,
10
+ } from '../../../test/viem/config.js'
60
11
 
61
- describe('getPoolId', () => {
62
- test('default', async () => {
63
- const poolId = await Actions.amm.getPoolId(client, {
64
- userToken: Addresses.defaultFeeToken,
65
- validatorToken: '0x20c0000000000000000000000000000000000001',
66
- })
67
- expect(poolId).toBeDefined()
68
- expect(typeof poolId).toBe('string')
69
- })
70
-
71
- test('behavior: token id', async () => {
72
- const poolId = await Actions.amm.getPoolId(client, {
73
- userToken: 0n,
74
- validatorToken: 1n,
75
- })
76
- expect(poolId).toBeDefined()
77
- expect(typeof poolId).toBe('string')
78
- })
79
- })
12
+ const account = accounts[0]
13
+ const account2 = accounts[1]
80
14
 
81
15
  describe('getPool', () => {
82
16
  test('default', async () => {
83
17
  const pool = await Actions.amm.getPool(client, {
84
- userToken: Addresses.defaultFeeToken,
85
- validatorToken: '0x20c0000000000000000000000000000000000001',
86
- })
87
- expect(pool).toMatchObject({
88
- reserveUserToken: expect.any(BigInt),
89
- reserveValidatorToken: expect.any(BigInt),
90
- })
91
- })
92
- })
93
-
94
- describe('getTotalSupply', () => {
95
- test('default', async () => {
96
- const poolId = await Actions.amm.getPoolId(client, {
97
- userToken: Addresses.defaultFeeToken,
18
+ userToken: 1n,
98
19
  validatorToken: '0x20c0000000000000000000000000000000000001',
99
20
  })
100
- const totalSupply = await Actions.amm.getTotalSupply(client, { poolId })
101
- expect(typeof totalSupply).toBe('bigint')
21
+ expect(pool).toMatchInlineSnapshot(`
22
+ {
23
+ "reserveUserToken": 0n,
24
+ "reserveValidatorToken": 0n,
25
+ "totalSupply": 0n,
26
+ }
27
+ `)
102
28
  })
103
29
  })
104
30
 
105
31
  describe('getLiquidityBalance', () => {
106
32
  test('default', async () => {
107
- const poolId = await Actions.amm.getPoolId(client, {
108
- userToken: Addresses.defaultFeeToken,
109
- validatorToken: '0x20c0000000000000000000000000000000000001',
110
- })
111
33
  const balance = await Actions.amm.getLiquidityBalance(client, {
112
- poolId,
113
34
  address: account.address,
35
+ userToken: 1n,
36
+ validatorToken: '0x20c0000000000000000000000000000000000001',
114
37
  })
115
38
  expect(typeof balance).toBe('bigint')
116
39
  })
@@ -135,7 +58,7 @@ describe('mint', () => {
135
58
  // Mint some tokens to account
136
59
  await Actions.token.mintSync(client, {
137
60
  to: account.address,
138
- amount: parseEther('1000'),
61
+ amount: parseUnits('1000', 6),
139
62
  token,
140
63
  })
141
64
 
@@ -145,11 +68,11 @@ describe('mint', () => {
145
68
  {
146
69
  userToken: {
147
70
  address: token,
148
- amount: parseEther('100'),
71
+ amount: parseUnits('100', 6),
149
72
  },
150
73
  validatorToken: {
151
- address: Addresses.defaultFeeToken,
152
- amount: parseEther('100'),
74
+ address: 1n,
75
+ amount: parseUnits('100', 6),
153
76
  },
154
77
  to: account.address,
155
78
  },
@@ -157,9 +80,9 @@ describe('mint', () => {
157
80
  expect(mintReceipt).toBeDefined()
158
81
  expect(mintResult).toMatchInlineSnapshot(`
159
82
  {
160
- "amountUserToken": 100000000000000000000n,
161
- "amountValidatorToken": 100000000000000000000n,
162
- "liquidity": 4999999999999999999999999999999999999000n,
83
+ "amountUserToken": 100000000n,
84
+ "amountValidatorToken": 100000000n,
85
+ "liquidity": 4999999999999000n,
163
86
  "sender": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
164
87
  "userToken": "0x20C0000000000000000000000000000000000004",
165
88
  "validatorToken": "0x20C0000000000000000000000000000000000001",
@@ -169,65 +92,141 @@ describe('mint', () => {
169
92
  // Verify pool reserves
170
93
  const pool = await Actions.amm.getPool(client, {
171
94
  userToken: token,
172
- validatorToken: Addresses.defaultFeeToken,
95
+ validatorToken: 1n,
173
96
  })
174
- expect(pool.reserveUserToken).toBe(parseEther('100'))
175
- expect(pool.reserveValidatorToken).toBe(parseEther('100'))
97
+ expect(pool).toMatchInlineSnapshot(`
98
+ {
99
+ "reserveUserToken": 100000000n,
100
+ "reserveValidatorToken": 100000000n,
101
+ "totalSupply": 5000000000000000n,
102
+ }
103
+ `)
176
104
 
177
105
  // Verify LP token balance
178
- const poolId = await Actions.amm.getPoolId(client, {
179
- userToken: token,
180
- validatorToken: Addresses.defaultFeeToken,
181
- })
182
106
  const lpBalance = await Actions.amm.getLiquidityBalance(client, {
183
- poolId,
184
107
  address: account.address,
108
+ userToken: token,
109
+ validatorToken: 1n,
185
110
  })
186
111
  expect(lpBalance).toBeGreaterThan(0n)
187
112
  })
113
+
114
+ test('behavior: single-sided mint (mintWithValidatorToken)', async () => {
115
+ // Create a new token for testing
116
+ const { token } = await Actions.token.createSync(client, {
117
+ name: 'Test Token 2',
118
+ symbol: 'TEST2',
119
+ currency: 'USD',
120
+ })
121
+
122
+ // Grant issuer role to mint tokens
123
+ await Actions.token.grantRolesSync(client, {
124
+ token,
125
+ roles: ['issuer'],
126
+ to: client.account.address,
127
+ })
128
+
129
+ // Mint some tokens to account
130
+ await Actions.token.mintSync(client, {
131
+ to: account.address,
132
+ amount: parseUnits('1000', 6),
133
+ token,
134
+ })
135
+
136
+ // First, establish initial liquidity with two-sided mint
137
+ await Actions.amm.mintSync(client, {
138
+ userToken: {
139
+ address: token,
140
+ amount: parseUnits('100', 6),
141
+ },
142
+ validatorToken: {
143
+ address: 1n,
144
+ amount: parseUnits('100', 6),
145
+ },
146
+ to: account.address,
147
+ })
148
+
149
+ // Get initial pool state
150
+ const poolBefore = await Actions.amm.getPool(client, {
151
+ userToken: token,
152
+ validatorToken: 1n,
153
+ })
154
+
155
+ // Add single-sided liquidity (only validatorToken)
156
+ const { receipt: mintReceipt, ...mintResult } = await Actions.amm.mintSync(
157
+ client,
158
+ {
159
+ userToken: {
160
+ address: token,
161
+ },
162
+ validatorToken: {
163
+ address: 1n,
164
+ amount: parseUnits('50', 6),
165
+ },
166
+ to: account.address,
167
+ },
168
+ )
169
+
170
+ expect(mintReceipt).toBeDefined()
171
+ // amountUserToken should be 0 for single-sided mint
172
+ expect(mintResult.amountUserToken).toBe(0n)
173
+ expect(mintResult.amountValidatorToken).toBe(parseUnits('50', 6))
174
+ expect(mintResult.liquidity).toBeGreaterThan(0n)
175
+
176
+ // Verify pool reserves - only validatorToken should increase
177
+ const poolAfter = await Actions.amm.getPool(client, {
178
+ userToken: token,
179
+ validatorToken: 1n,
180
+ })
181
+
182
+ expect(poolAfter.reserveUserToken).toBe(poolBefore.reserveUserToken)
183
+ expect(poolAfter.reserveValidatorToken).toBe(
184
+ poolBefore.reserveValidatorToken + parseUnits('50', 6),
185
+ )
186
+ expect(poolAfter.totalSupply).toBeGreaterThan(poolBefore.totalSupply)
187
+ })
188
188
  })
189
189
 
190
190
  describe('burn', () => {
191
191
  test('default', async () => {
192
- const { tokenAddress } = await setupPoolWithLiquidity()
192
+ const { tokenAddress } = await setupPoolWithLiquidity(client)
193
193
 
194
194
  // Get LP balance before burn
195
- const poolId = await Actions.amm.getPoolId(client, {
196
- userToken: tokenAddress,
197
- validatorToken: Addresses.defaultFeeToken,
198
- })
199
195
  const lpBalanceBefore = await Actions.amm.getLiquidityBalance(client, {
200
- poolId,
201
196
  address: account.address,
197
+ userToken: tokenAddress,
198
+ validatorToken: 1n,
202
199
  })
203
200
 
204
201
  // Burn half of LP tokens
205
- const { receipt: burnReceipt, ...burnResult } = await Actions.amm.burnSync(
206
- client,
207
- {
208
- userToken: tokenAddress,
209
- validatorToken: Addresses.defaultFeeToken,
210
- liquidity: lpBalanceBefore / 2n,
211
- to: account.address,
212
- },
213
- )
202
+ const {
203
+ receipt: burnReceipt,
204
+ userToken,
205
+ ...burnResult
206
+ } = await Actions.amm.burnSync(client, {
207
+ userToken: tokenAddress,
208
+ validatorToken: 1n,
209
+ liquidity: lpBalanceBefore / 2n,
210
+ to: account.address,
211
+ })
214
212
  expect(burnReceipt).toBeDefined()
213
+ expect(userToken).toBe(tokenAddress)
215
214
  expect(burnResult).toMatchInlineSnapshot(`
216
215
  {
217
- "amountUserToken": 49999999999999999999n,
218
- "amountValidatorToken": 49999999999999999999n,
219
- "liquidity": 2499999999999999999999999999999999999500n,
216
+ "amountUserToken": 49999999n,
217
+ "amountValidatorToken": 49999999n,
218
+ "liquidity": 2499999999999500n,
220
219
  "sender": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
221
220
  "to": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
222
- "userToken": "0x20C0000000000000000000000000000000000004",
223
221
  "validatorToken": "0x20C0000000000000000000000000000000000001",
224
222
  }
225
223
  `)
226
224
 
227
225
  // Verify LP balance decreased
228
226
  const lpBalanceAfter = await Actions.amm.getLiquidityBalance(client, {
229
- poolId,
230
227
  address: account.address,
228
+ userToken: tokenAddress,
229
+ validatorToken: 1n,
231
230
  })
232
231
  expect(lpBalanceAfter).toBeLessThan(lpBalanceBefore)
233
232
  expect(lpBalanceAfter).toBe(lpBalanceBefore / 2n)
@@ -235,16 +234,21 @@ describe('burn', () => {
235
234
  // Verify pool reserves decreased
236
235
  const pool = await Actions.amm.getPool(client, {
237
236
  userToken: tokenAddress,
238
- validatorToken: Addresses.defaultFeeToken,
237
+ validatorToken: 1n,
239
238
  })
240
- expect(pool.reserveUserToken).toBeLessThan(parseEther('100'))
241
- expect(pool.reserveValidatorToken).toBeLessThan(parseEther('100'))
239
+ expect(pool).toMatchInlineSnapshot(`
240
+ {
241
+ "reserveUserToken": 50000001n,
242
+ "reserveValidatorToken": 50000001n,
243
+ "totalSupply": 2500000000000500n,
244
+ }
245
+ `)
242
246
  })
243
247
  })
244
248
 
245
249
  describe('rebalanceSwap', () => {
246
250
  test('default', async () => {
247
- const { tokenAddress } = await setupPoolWithLiquidity()
251
+ const { tokenAddress } = await setupPoolWithLiquidity(client)
248
252
 
249
253
  // Get balance before swap
250
254
  const balanceBefore = await Actions.token.getBalance(client, {
@@ -253,21 +257,24 @@ describe('rebalanceSwap', () => {
253
257
  })
254
258
 
255
259
  // Perform rebalance swap
256
- const { receipt: swapReceipt, ...swapResult } =
257
- await Actions.amm.rebalanceSwapSync(client, {
258
- userToken: tokenAddress,
259
- validatorToken: Addresses.defaultFeeToken,
260
- amountOut: parseEther('10'),
261
- to: account2.address,
262
- account: account,
263
- })
260
+ const {
261
+ receipt: swapReceipt,
262
+ userToken,
263
+ ...swapResult
264
+ } = await Actions.amm.rebalanceSwapSync(client, {
265
+ userToken: tokenAddress,
266
+ validatorToken: 1n,
267
+ amountOut: parseUnits('10', 6),
268
+ to: account2.address,
269
+ account: account,
270
+ })
264
271
  expect(swapReceipt).toBeDefined()
272
+ expect(userToken).toBe(tokenAddress)
265
273
  expect(swapResult).toMatchInlineSnapshot(`
266
274
  {
267
- "amountIn": 9985000000000000001n,
268
- "amountOut": 10000000000000000000n,
275
+ "amountIn": 9985001n,
276
+ "amountOut": 10000000n,
269
277
  "swapper": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
270
- "userToken": "0x20C0000000000000000000000000000000000004",
271
278
  "validatorToken": "0x20C0000000000000000000000000000000000001",
272
279
  }
273
280
  `)
@@ -277,13 +284,13 @@ describe('rebalanceSwap', () => {
277
284
  token: tokenAddress,
278
285
  account: account2.address,
279
286
  })
280
- expect(balanceAfter).toBe(balanceBefore + parseEther('10'))
287
+ expect(balanceAfter).toBe(balanceBefore + parseUnits('10', 6))
281
288
  })
282
289
  })
283
290
 
284
291
  describe('watchRebalanceSwap', () => {
285
292
  test('default', async () => {
286
- const { tokenAddress } = await setupPoolWithLiquidity()
293
+ const { tokenAddress } = await setupPoolWithLiquidity(client)
287
294
 
288
295
  let eventArgs: any = null
289
296
  const unwatch = Actions.amm.watchRebalanceSwap(client, {
@@ -295,8 +302,8 @@ describe('watchRebalanceSwap', () => {
295
302
  // Perform rebalance swap
296
303
  await Actions.amm.rebalanceSwapSync(client, {
297
304
  userToken: tokenAddress,
298
- validatorToken: Addresses.defaultFeeToken,
299
- amountOut: parseEther('10'),
305
+ validatorToken: 1n,
306
+ amountOut: parseUnits('10', 6),
300
307
  to: account2.address,
301
308
  account: account,
302
309
  })
@@ -306,9 +313,9 @@ describe('watchRebalanceSwap', () => {
306
313
  expect(eventArgs).toBeDefined()
307
314
  expect(eventArgs.userToken.toLowerCase()).toBe(tokenAddress.toLowerCase())
308
315
  expect(eventArgs.validatorToken.toLowerCase()).toBe(
309
- Addresses.defaultFeeToken.toLowerCase(),
316
+ '0x20c0000000000000000000000000000000000001',
310
317
  )
311
- expect(eventArgs.amountOut).toBe(parseEther('10'))
318
+ expect(eventArgs.amountOut).toBe(parseUnits('10', 6))
312
319
 
313
320
  unwatch()
314
321
  })
@@ -333,16 +340,16 @@ describe('watchMint', () => {
333
340
  // Mint some tokens to account
334
341
  await Actions.token.mintSync(client, {
335
342
  to: account.address,
336
- amount: parseEther('1000'),
343
+ amount: parseUnits('1000', 6),
337
344
  token,
338
345
  })
339
346
 
340
347
  // Mint USD to account
341
348
  await writeContractSync(client, {
342
349
  abi: Abis.tip20,
343
- address: Addresses.defaultFeeToken,
350
+ address: '0x20c0000000000000000000000000000000000001',
344
351
  functionName: 'transfer',
345
- args: [account.address, parseEther('1000')],
352
+ args: [account.address, parseUnits('1000', 6)],
346
353
  })
347
354
 
348
355
  let eventArgs: any = null
@@ -356,11 +363,11 @@ describe('watchMint', () => {
356
363
  await Actions.amm.mintSync(client, {
357
364
  userToken: {
358
365
  address: token,
359
- amount: parseEther('100'),
366
+ amount: parseUnits('100', 6),
360
367
  },
361
368
  validatorToken: {
362
- address: Addresses.defaultFeeToken,
363
- amount: parseEther('100'),
369
+ address: 1n,
370
+ amount: parseUnits('100', 6),
364
371
  },
365
372
  to: account.address,
366
373
  })
@@ -370,10 +377,10 @@ describe('watchMint', () => {
370
377
  expect(eventArgs).toBeDefined()
371
378
  expect(eventArgs.userToken.address.toLowerCase()).toBe(token.toLowerCase())
372
379
  expect(eventArgs.validatorToken.address.toLowerCase()).toBe(
373
- Addresses.defaultFeeToken.toLowerCase(),
380
+ '0x20c0000000000000000000000000000000000001',
374
381
  )
375
- expect(eventArgs.userToken.amount).toBe(parseEther('100'))
376
- expect(eventArgs.validatorToken.amount).toBe(parseEther('100'))
382
+ expect(eventArgs.userToken.amount).toBe(parseUnits('100', 6))
383
+ expect(eventArgs.validatorToken.amount).toBe(parseUnits('100', 6))
377
384
 
378
385
  unwatch()
379
386
  })
@@ -381,15 +388,12 @@ describe('watchMint', () => {
381
388
 
382
389
  describe('watchBurn', () => {
383
390
  test('default', async () => {
384
- const { tokenAddress } = await setupPoolWithLiquidity()
391
+ const { tokenAddress } = await setupPoolWithLiquidity(client)
385
392
 
386
393
  // Get LP balance
387
- const poolId = await Actions.amm.getPoolId(client, {
388
- userToken: tokenAddress,
389
- validatorToken: Addresses.defaultFeeToken,
390
- })
391
394
  const lpBalance = await Actions.amm.getLiquidityBalance(client, {
392
- poolId,
395
+ userToken: tokenAddress,
396
+ validatorToken: 1n,
393
397
  address: account.address,
394
398
  })
395
399
 
@@ -403,7 +407,7 @@ describe('watchBurn', () => {
403
407
  // Burn LP tokens
404
408
  await Actions.amm.burnSync(client, {
405
409
  userToken: tokenAddress,
406
- validatorToken: Addresses.defaultFeeToken,
410
+ validatorToken: 1n,
407
411
  liquidity: lpBalance / 2n,
408
412
  to: account.address,
409
413
  })
@@ -413,7 +417,7 @@ describe('watchBurn', () => {
413
417
  expect(eventArgs).toBeDefined()
414
418
  expect(eventArgs.userToken.toLowerCase()).toBe(tokenAddress.toLowerCase())
415
419
  expect(eventArgs.validatorToken.toLowerCase()).toBe(
416
- Addresses.defaultFeeToken.toLowerCase(),
420
+ '0x20c0000000000000000000000000000000000001',
417
421
  )
418
422
  expect(eventArgs.liquidity).toBe(lpBalance / 2n)
419
423