tempo.ts 0.0.6 → 0.1.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 (195) hide show
  1. package/dist/chains.d.ts +244 -541
  2. package/dist/chains.d.ts.map +1 -1
  3. package/dist/chains.js +10 -23
  4. package/dist/chains.js.map +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/ox/SignatureEnvelope.d.ts +245 -0
  7. package/dist/ox/SignatureEnvelope.d.ts.map +1 -0
  8. package/dist/ox/SignatureEnvelope.js +437 -0
  9. package/dist/ox/SignatureEnvelope.js.map +1 -0
  10. package/dist/ox/Transaction.d.ts +61 -24
  11. package/dist/ox/Transaction.d.ts.map +1 -1
  12. package/dist/ox/Transaction.js +63 -18
  13. package/dist/ox/Transaction.js.map +1 -1
  14. package/dist/ox/TransactionEnvelopeAA.d.ts +461 -0
  15. package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -0
  16. package/dist/ox/TransactionEnvelopeAA.js +528 -0
  17. package/dist/ox/TransactionEnvelopeAA.js.map +1 -0
  18. package/dist/ox/TransactionRequest.d.ts +7 -5
  19. package/dist/ox/TransactionRequest.d.ts.map +1 -1
  20. package/dist/ox/TransactionRequest.js +21 -12
  21. package/dist/ox/TransactionRequest.js.map +1 -1
  22. package/dist/ox/index.d.ts +5 -4
  23. package/dist/ox/index.d.ts.map +1 -1
  24. package/dist/ox/index.js +5 -4
  25. package/dist/ox/index.js.map +1 -1
  26. package/dist/prool/Instance.d.ts +0 -4
  27. package/dist/prool/Instance.d.ts.map +1 -1
  28. package/dist/prool/Instance.js +7 -7
  29. package/dist/prool/Instance.js.map +1 -1
  30. package/dist/prool/index.d.ts +1 -1
  31. package/dist/prool/index.d.ts.map +1 -1
  32. package/dist/prool/index.js +1 -1
  33. package/dist/prool/index.js.map +1 -1
  34. package/dist/viem/{abis.d.ts → Abis.d.ts} +523 -9
  35. package/dist/viem/Abis.d.ts.map +1 -0
  36. package/dist/viem/{abis.js → Abis.js} +321 -9
  37. package/dist/viem/Abis.js.map +1 -0
  38. package/dist/viem/{actions → Actions}/amm.d.ts +21 -21
  39. package/dist/viem/Actions/amm.d.ts.map +1 -0
  40. package/dist/viem/{actions → Actions}/amm.js +55 -43
  41. package/dist/viem/Actions/amm.js.map +1 -0
  42. package/dist/viem/Actions/dex.d.ts +3263 -0
  43. package/dist/viem/Actions/dex.d.ts.map +1 -0
  44. package/dist/viem/Actions/dex.js +1357 -0
  45. package/dist/viem/Actions/dex.js.map +1 -0
  46. package/dist/viem/{actions → Actions}/fee.d.ts +8 -8
  47. package/dist/viem/Actions/fee.d.ts.map +1 -0
  48. package/dist/viem/{actions → Actions}/fee.js +14 -13
  49. package/dist/viem/Actions/fee.js.map +1 -0
  50. package/dist/viem/Actions/index.d.ts +6 -0
  51. package/dist/viem/Actions/index.d.ts.map +1 -0
  52. package/dist/viem/Actions/index.js +6 -0
  53. package/dist/viem/Actions/index.js.map +1 -0
  54. package/dist/viem/{actions → Actions}/policy.d.ts +19 -19
  55. package/dist/viem/Actions/policy.d.ts.map +1 -0
  56. package/dist/viem/{actions → Actions}/policy.js +59 -46
  57. package/dist/viem/Actions/policy.js.map +1 -0
  58. package/dist/viem/{actions → Actions}/token.d.ts +3275 -698
  59. package/dist/viem/Actions/token.d.ts.map +1 -0
  60. package/dist/viem/{actions → Actions}/token.js +458 -84
  61. package/dist/viem/Actions/token.js.map +1 -0
  62. package/dist/viem/Addresses.d.ts +9 -0
  63. package/dist/viem/Addresses.d.ts.map +1 -0
  64. package/dist/viem/Addresses.js +9 -0
  65. package/dist/viem/Addresses.js.map +1 -0
  66. package/dist/viem/{chain.d.ts → Chain.d.ts} +81 -57
  67. package/dist/viem/Chain.d.ts.map +1 -0
  68. package/dist/viem/{chain.js → Chain.js} +7 -7
  69. package/dist/viem/Chain.js.map +1 -0
  70. package/dist/viem/{client.d.ts → Client.d.ts} +4 -4
  71. package/dist/viem/Client.d.ts.map +1 -0
  72. package/dist/viem/{client.js → Client.js} +3 -3
  73. package/dist/viem/Client.js.map +1 -0
  74. package/dist/viem/{decorator.d.ts → Decorator.d.ts} +507 -5
  75. package/dist/viem/Decorator.d.ts.map +1 -0
  76. package/dist/viem/{decorator.js → Decorator.js} +31 -5
  77. package/dist/viem/Decorator.js.map +1 -0
  78. package/dist/viem/{formatters.d.ts → Formatters.d.ts} +2 -2
  79. package/dist/viem/Formatters.d.ts.map +1 -0
  80. package/dist/viem/{formatters.js → Formatters.js} +24 -17
  81. package/dist/viem/Formatters.js.map +1 -0
  82. package/dist/viem/Tick.d.ts +111 -0
  83. package/dist/viem/Tick.d.ts.map +1 -0
  84. package/dist/viem/Tick.js +127 -0
  85. package/dist/viem/Tick.js.map +1 -0
  86. package/dist/viem/TokenIds.d.ts +3 -0
  87. package/dist/viem/TokenIds.d.ts.map +1 -0
  88. package/dist/viem/TokenIds.js +3 -0
  89. package/dist/viem/TokenIds.js.map +1 -0
  90. package/dist/viem/Transaction.d.ts +57 -0
  91. package/dist/viem/Transaction.d.ts.map +1 -0
  92. package/dist/viem/Transaction.js +137 -0
  93. package/dist/viem/Transaction.js.map +1 -0
  94. package/dist/viem/{transport.d.ts → Transport.d.ts} +3 -3
  95. package/dist/viem/Transport.d.ts.map +1 -0
  96. package/dist/viem/{transport.js → Transport.js} +3 -3
  97. package/dist/viem/Transport.js.map +1 -0
  98. package/dist/viem/index.d.ts +13 -9
  99. package/dist/viem/index.d.ts.map +1 -1
  100. package/dist/viem/index.js +13 -9
  101. package/dist/viem/index.js.map +1 -1
  102. package/dist/viem/{types.d.ts → internal/types.d.ts} +3 -3
  103. package/dist/viem/internal/types.d.ts.map +1 -0
  104. package/dist/viem/{types.js.map → internal/types.js.map} +1 -1
  105. package/dist/viem/internal/utils.d.ts.map +1 -0
  106. package/dist/viem/internal/utils.js.map +1 -0
  107. package/package.json +87 -101
  108. package/src/chains.ts +10 -24
  109. package/src/ox/SignatureEnvelope.test.ts +1252 -0
  110. package/src/ox/SignatureEnvelope.ts +709 -0
  111. package/src/ox/Transaction.test.ts +144 -89
  112. package/src/ox/Transaction.ts +104 -29
  113. package/src/ox/TransactionEnvelopeAA.test.ts +1533 -0
  114. package/src/ox/TransactionEnvelopeAA.ts +858 -0
  115. package/src/ox/TransactionRequest.ts +25 -17
  116. package/src/ox/index.ts +2 -1
  117. package/src/prool/Instance.ts +6 -14
  118. package/src/prool/internal/chain.json +101 -27
  119. package/src/viem/{abis.ts → Abis.ts} +322 -8
  120. package/src/viem/{actions → Actions}/amm.test.ts +65 -68
  121. package/src/viem/{actions → Actions}/amm.ts +72 -60
  122. package/src/viem/Actions/dex.test.ts +1608 -0
  123. package/src/viem/Actions/dex.ts +2026 -0
  124. package/src/viem/{actions → Actions}/fee.test.ts +34 -36
  125. package/src/viem/{actions → Actions}/fee.ts +18 -17
  126. package/src/viem/{actions → Actions}/index.ts +1 -0
  127. package/src/viem/{actions → Actions}/policy.test.ts +2 -2
  128. package/src/viem/{actions → Actions}/policy.ts +77 -64
  129. package/src/viem/{actions → Actions}/token.test.ts +419 -64
  130. package/src/viem/{actions → Actions}/token.ts +751 -145
  131. package/src/viem/Addresses.ts +9 -0
  132. package/src/viem/{chain.ts → Chain.ts} +6 -6
  133. package/src/viem/{client.bench-d.ts → Client.bench-d.ts} +2 -2
  134. package/src/viem/{client.test.ts → Client.test.ts} +31 -6
  135. package/src/viem/{client.ts → Client.ts} +1 -1
  136. package/src/viem/{decorator.bench-d.ts → Decorator.bench-d.ts} +2 -2
  137. package/src/viem/{decorator.test.ts → Decorator.test.ts} +1 -0
  138. package/src/viem/{decorator.ts → Decorator.ts} +586 -4
  139. package/src/viem/{formatters.ts → Formatters.ts} +31 -20
  140. package/src/viem/Tick.test.ts +281 -0
  141. package/src/viem/Tick.ts +176 -0
  142. package/src/viem/TokenIds.ts +2 -0
  143. package/src/viem/Transaction.ts +303 -0
  144. package/src/viem/{transport.ts → Transport.ts} +5 -5
  145. package/src/viem/e2e.test.ts +153 -78
  146. package/src/viem/index.ts +13 -9
  147. package/src/viem/{types.ts → internal/types.ts} +3 -3
  148. package/dist/ox/TransactionEnvelopeFeeToken.d.ts +0 -393
  149. package/dist/ox/TransactionEnvelopeFeeToken.d.ts.map +0 -1
  150. package/dist/ox/TransactionEnvelopeFeeToken.js +0 -452
  151. package/dist/ox/TransactionEnvelopeFeeToken.js.map +0 -1
  152. package/dist/viem/abis.d.ts.map +0 -1
  153. package/dist/viem/abis.js.map +0 -1
  154. package/dist/viem/actions/amm.d.ts.map +0 -1
  155. package/dist/viem/actions/amm.js.map +0 -1
  156. package/dist/viem/actions/fee.d.ts.map +0 -1
  157. package/dist/viem/actions/fee.js.map +0 -1
  158. package/dist/viem/actions/index.d.ts +0 -5
  159. package/dist/viem/actions/index.d.ts.map +0 -1
  160. package/dist/viem/actions/index.js +0 -5
  161. package/dist/viem/actions/index.js.map +0 -1
  162. package/dist/viem/actions/policy.d.ts.map +0 -1
  163. package/dist/viem/actions/policy.js.map +0 -1
  164. package/dist/viem/actions/token.d.ts.map +0 -1
  165. package/dist/viem/actions/token.js.map +0 -1
  166. package/dist/viem/addresses.d.ts +0 -8
  167. package/dist/viem/addresses.d.ts.map +0 -1
  168. package/dist/viem/addresses.js +0 -8
  169. package/dist/viem/addresses.js.map +0 -1
  170. package/dist/viem/chain.d.ts.map +0 -1
  171. package/dist/viem/chain.js.map +0 -1
  172. package/dist/viem/client.d.ts.map +0 -1
  173. package/dist/viem/client.js.map +0 -1
  174. package/dist/viem/decorator.d.ts.map +0 -1
  175. package/dist/viem/decorator.js.map +0 -1
  176. package/dist/viem/formatters.d.ts.map +0 -1
  177. package/dist/viem/formatters.js.map +0 -1
  178. package/dist/viem/transaction.d.ts +0 -54
  179. package/dist/viem/transaction.d.ts.map +0 -1
  180. package/dist/viem/transaction.js +0 -108
  181. package/dist/viem/transaction.js.map +0 -1
  182. package/dist/viem/transport.d.ts.map +0 -1
  183. package/dist/viem/transport.js.map +0 -1
  184. package/dist/viem/types.d.ts.map +0 -1
  185. package/dist/viem/utils.d.ts.map +0 -1
  186. package/dist/viem/utils.js.map +0 -1
  187. package/src/ox/TransactionEnvelopeFeeToken.test.ts +0 -1119
  188. package/src/ox/TransactionEnvelopeFeeToken.ts +0 -717
  189. package/src/prool/internal/consensus.toml +0 -32
  190. package/src/viem/addresses.ts +0 -10
  191. package/src/viem/transaction.ts +0 -253
  192. /package/dist/viem/{types.js → internal/types.js} +0 -0
  193. /package/dist/viem/{utils.d.ts → internal/utils.d.ts} +0 -0
  194. /package/dist/viem/{utils.js → internal/utils.js} +0 -0
  195. /package/src/viem/{utils.ts → internal/utils.ts} +0 -0
@@ -1,13 +1,10 @@
1
1
  import { setTimeout } from 'node:timers/promises'
2
- import * as actions from 'tempo.ts/viem/actions'
2
+ import { Abis, Actions, Addresses, createTempoClient } from 'tempo.ts/viem'
3
3
  import { parseEther, publicActions } from 'viem'
4
4
  import { mnemonicToAccount } from 'viem/accounts'
5
5
  import { writeContractSync } from 'viem/actions'
6
6
  import { describe, expect, test } from 'vitest'
7
7
  import { tempoTest } from '../../../test/viem/config.js'
8
- import { tip20Abi } from '../abis.js'
9
- import { usdAddress } from '../addresses.js'
10
- import { createTempoClient } from '../client.js'
11
8
 
12
9
  const account = mnemonicToAccount(
13
10
  'test test test test test test test test test test test junk',
@@ -25,34 +22,34 @@ const client = createTempoClient({
25
22
 
26
23
  async function setupPoolWithLiquidity() {
27
24
  // Create a new token for testing
28
- const { token } = await actions.token.createSync(client, {
25
+ const { token } = await Actions.token.createSync(client, {
29
26
  name: 'Test Token',
30
27
  symbol: 'TEST',
31
28
  currency: 'USD',
32
29
  })
33
30
 
34
31
  // Grant issuer role to mint tokens
35
- await actions.token.grantRolesSync(client, {
32
+ await Actions.token.grantRolesSync(client, {
36
33
  token,
37
34
  roles: ['issuer'],
38
35
  to: client.account.address,
39
36
  })
40
37
 
41
38
  // Mint some tokens to account
42
- await actions.token.mintSync(client, {
39
+ await Actions.token.mintSync(client, {
43
40
  to: account.address,
44
41
  amount: parseEther('1000'),
45
42
  token,
46
43
  })
47
44
 
48
45
  // Add liquidity to pool
49
- await actions.amm.mintSync(client, {
46
+ await Actions.amm.mintSync(client, {
50
47
  userToken: {
51
48
  address: token,
52
49
  amount: parseEther('100'),
53
50
  },
54
51
  validatorToken: {
55
- address: usdAddress,
52
+ address: Addresses.defaultFeeToken,
56
53
  amount: parseEther('100'),
57
54
  },
58
55
  to: account.address,
@@ -63,8 +60,8 @@ async function setupPoolWithLiquidity() {
63
60
 
64
61
  describe('getPoolId', () => {
65
62
  test('default', async () => {
66
- const poolId = await actions.amm.getPoolId(client, {
67
- userToken: usdAddress,
63
+ const poolId = await Actions.amm.getPoolId(client, {
64
+ userToken: Addresses.defaultFeeToken,
68
65
  validatorToken: '0x20c0000000000000000000000000000000000001',
69
66
  })
70
67
  expect(poolId).toBeDefined()
@@ -72,7 +69,7 @@ describe('getPoolId', () => {
72
69
  })
73
70
 
74
71
  test('behavior: token id', async () => {
75
- const poolId = await actions.amm.getPoolId(client, {
72
+ const poolId = await Actions.amm.getPoolId(client, {
76
73
  userToken: 0n,
77
74
  validatorToken: 1n,
78
75
  })
@@ -83,8 +80,8 @@ describe('getPoolId', () => {
83
80
 
84
81
  describe('getPool', () => {
85
82
  test('default', async () => {
86
- const pool = await actions.amm.getPool(client, {
87
- userToken: usdAddress,
83
+ const pool = await Actions.amm.getPool(client, {
84
+ userToken: Addresses.defaultFeeToken,
88
85
  validatorToken: '0x20c0000000000000000000000000000000000001',
89
86
  })
90
87
  expect(pool).toMatchObject({
@@ -96,22 +93,22 @@ describe('getPool', () => {
96
93
 
97
94
  describe('getTotalSupply', () => {
98
95
  test('default', async () => {
99
- const poolId = await actions.amm.getPoolId(client, {
100
- userToken: usdAddress,
96
+ const poolId = await Actions.amm.getPoolId(client, {
97
+ userToken: Addresses.defaultFeeToken,
101
98
  validatorToken: '0x20c0000000000000000000000000000000000001',
102
99
  })
103
- const totalSupply = await actions.amm.getTotalSupply(client, { poolId })
100
+ const totalSupply = await Actions.amm.getTotalSupply(client, { poolId })
104
101
  expect(typeof totalSupply).toBe('bigint')
105
102
  })
106
103
  })
107
104
 
108
105
  describe('getLiquidityBalance', () => {
109
106
  test('default', async () => {
110
- const poolId = await actions.amm.getPoolId(client, {
111
- userToken: usdAddress,
107
+ const poolId = await Actions.amm.getPoolId(client, {
108
+ userToken: Addresses.defaultFeeToken,
112
109
  validatorToken: '0x20c0000000000000000000000000000000000001',
113
110
  })
114
- const balance = await actions.amm.getLiquidityBalance(client, {
111
+ const balance = await Actions.amm.getLiquidityBalance(client, {
115
112
  poolId,
116
113
  address: account.address,
117
114
  })
@@ -122,28 +119,28 @@ describe('getLiquidityBalance', () => {
122
119
  describe('mint', () => {
123
120
  test('default', async () => {
124
121
  // Create a new token for testing
125
- const { token } = await actions.token.createSync(client, {
122
+ const { token } = await Actions.token.createSync(client, {
126
123
  name: 'Test Token',
127
124
  symbol: 'TEST',
128
125
  currency: 'USD',
129
126
  })
130
127
 
131
128
  // Grant issuer role to mint tokens
132
- await actions.token.grantRolesSync(client, {
129
+ await Actions.token.grantRolesSync(client, {
133
130
  token,
134
131
  roles: ['issuer'],
135
132
  to: client.account.address,
136
133
  })
137
134
 
138
135
  // Mint some tokens to account
139
- await actions.token.mintSync(client, {
136
+ await Actions.token.mintSync(client, {
140
137
  to: account.address,
141
138
  amount: parseEther('1000'),
142
139
  token,
143
140
  })
144
141
 
145
142
  // Add liquidity to pool
146
- const { receipt: mintReceipt, ...mintResult } = await actions.amm.mintSync(
143
+ const { receipt: mintReceipt, ...mintResult } = await Actions.amm.mintSync(
147
144
  client,
148
145
  {
149
146
  userToken: {
@@ -151,7 +148,7 @@ describe('mint', () => {
151
148
  amount: parseEther('100'),
152
149
  },
153
150
  validatorToken: {
154
- address: usdAddress,
151
+ address: Addresses.defaultFeeToken,
155
152
  amount: parseEther('100'),
156
153
  },
157
154
  to: account.address,
@@ -164,25 +161,25 @@ describe('mint', () => {
164
161
  "amountValidatorToken": 100000000000000000000n,
165
162
  "liquidity": 4999999999999999999999999999999999999000n,
166
163
  "sender": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
167
- "userToken": "0x20C0000000000000000000000000000000000001",
168
- "validatorToken": "0x20C0000000000000000000000000000000000000",
164
+ "userToken": "0x20C0000000000000000000000000000000000004",
165
+ "validatorToken": "0x20C0000000000000000000000000000000000001",
169
166
  }
170
167
  `)
171
168
 
172
169
  // Verify pool reserves
173
- const pool = await actions.amm.getPool(client, {
170
+ const pool = await Actions.amm.getPool(client, {
174
171
  userToken: token,
175
- validatorToken: usdAddress,
172
+ validatorToken: Addresses.defaultFeeToken,
176
173
  })
177
174
  expect(pool.reserveUserToken).toBe(parseEther('100'))
178
175
  expect(pool.reserveValidatorToken).toBe(parseEther('100'))
179
176
 
180
177
  // Verify LP token balance
181
- const poolId = await actions.amm.getPoolId(client, {
178
+ const poolId = await Actions.amm.getPoolId(client, {
182
179
  userToken: token,
183
- validatorToken: usdAddress,
180
+ validatorToken: Addresses.defaultFeeToken,
184
181
  })
185
- const lpBalance = await actions.amm.getLiquidityBalance(client, {
182
+ const lpBalance = await Actions.amm.getLiquidityBalance(client, {
186
183
  poolId,
187
184
  address: account.address,
188
185
  })
@@ -195,21 +192,21 @@ describe('burn', () => {
195
192
  const { tokenAddress } = await setupPoolWithLiquidity()
196
193
 
197
194
  // Get LP balance before burn
198
- const poolId = await actions.amm.getPoolId(client, {
195
+ const poolId = await Actions.amm.getPoolId(client, {
199
196
  userToken: tokenAddress,
200
- validatorToken: usdAddress,
197
+ validatorToken: Addresses.defaultFeeToken,
201
198
  })
202
- const lpBalanceBefore = await actions.amm.getLiquidityBalance(client, {
199
+ const lpBalanceBefore = await Actions.amm.getLiquidityBalance(client, {
203
200
  poolId,
204
201
  address: account.address,
205
202
  })
206
203
 
207
204
  // Burn half of LP tokens
208
- const { receipt: burnReceipt, ...burnResult } = await actions.amm.burnSync(
205
+ const { receipt: burnReceipt, ...burnResult } = await Actions.amm.burnSync(
209
206
  client,
210
207
  {
211
208
  userToken: tokenAddress,
212
- validatorToken: usdAddress,
209
+ validatorToken: Addresses.defaultFeeToken,
213
210
  liquidity: lpBalanceBefore / 2n,
214
211
  to: account.address,
215
212
  },
@@ -222,13 +219,13 @@ describe('burn', () => {
222
219
  "liquidity": 2499999999999999999999999999999999999500n,
223
220
  "sender": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
224
221
  "to": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
225
- "userToken": "0x20C0000000000000000000000000000000000001",
226
- "validatorToken": "0x20C0000000000000000000000000000000000000",
222
+ "userToken": "0x20C0000000000000000000000000000000000004",
223
+ "validatorToken": "0x20C0000000000000000000000000000000000001",
227
224
  }
228
225
  `)
229
226
 
230
227
  // Verify LP balance decreased
231
- const lpBalanceAfter = await actions.amm.getLiquidityBalance(client, {
228
+ const lpBalanceAfter = await Actions.amm.getLiquidityBalance(client, {
232
229
  poolId,
233
230
  address: account.address,
234
231
  })
@@ -236,9 +233,9 @@ describe('burn', () => {
236
233
  expect(lpBalanceAfter).toBe(lpBalanceBefore / 2n)
237
234
 
238
235
  // Verify pool reserves decreased
239
- const pool = await actions.amm.getPool(client, {
236
+ const pool = await Actions.amm.getPool(client, {
240
237
  userToken: tokenAddress,
241
- validatorToken: usdAddress,
238
+ validatorToken: Addresses.defaultFeeToken,
242
239
  })
243
240
  expect(pool.reserveUserToken).toBeLessThan(parseEther('100'))
244
241
  expect(pool.reserveValidatorToken).toBeLessThan(parseEther('100'))
@@ -250,16 +247,16 @@ describe('rebalanceSwap', () => {
250
247
  const { tokenAddress } = await setupPoolWithLiquidity()
251
248
 
252
249
  // Get balance before swap
253
- const balanceBefore = await actions.token.getBalance(client, {
250
+ const balanceBefore = await Actions.token.getBalance(client, {
254
251
  token: tokenAddress,
255
252
  account: account2.address,
256
253
  })
257
254
 
258
255
  // Perform rebalance swap
259
256
  const { receipt: swapReceipt, ...swapResult } =
260
- await actions.amm.rebalanceSwapSync(client, {
257
+ await Actions.amm.rebalanceSwapSync(client, {
261
258
  userToken: tokenAddress,
262
- validatorToken: usdAddress,
259
+ validatorToken: Addresses.defaultFeeToken,
263
260
  amountOut: parseEther('10'),
264
261
  to: account2.address,
265
262
  account: account,
@@ -270,13 +267,13 @@ describe('rebalanceSwap', () => {
270
267
  "amountIn": 9985000000000000001n,
271
268
  "amountOut": 10000000000000000000n,
272
269
  "swapper": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
273
- "userToken": "0x20C0000000000000000000000000000000000001",
274
- "validatorToken": "0x20C0000000000000000000000000000000000000",
270
+ "userToken": "0x20C0000000000000000000000000000000000004",
271
+ "validatorToken": "0x20C0000000000000000000000000000000000001",
275
272
  }
276
273
  `)
277
274
 
278
275
  // Verify balance increased
279
- const balanceAfter = await actions.token.getBalance(client, {
276
+ const balanceAfter = await Actions.token.getBalance(client, {
280
277
  token: tokenAddress,
281
278
  account: account2.address,
282
279
  })
@@ -289,16 +286,16 @@ describe('watchRebalanceSwap', () => {
289
286
  const { tokenAddress } = await setupPoolWithLiquidity()
290
287
 
291
288
  let eventArgs: any = null
292
- const unwatch = actions.amm.watchRebalanceSwap(client, {
289
+ const unwatch = Actions.amm.watchRebalanceSwap(client, {
293
290
  onRebalanceSwap: (args) => {
294
291
  eventArgs = args
295
292
  },
296
293
  })
297
294
 
298
295
  // Perform rebalance swap
299
- await actions.amm.rebalanceSwapSync(client, {
296
+ await Actions.amm.rebalanceSwapSync(client, {
300
297
  userToken: tokenAddress,
301
- validatorToken: usdAddress,
298
+ validatorToken: Addresses.defaultFeeToken,
302
299
  amountOut: parseEther('10'),
303
300
  to: account2.address,
304
301
  account: account,
@@ -309,7 +306,7 @@ describe('watchRebalanceSwap', () => {
309
306
  expect(eventArgs).toBeDefined()
310
307
  expect(eventArgs.userToken.toLowerCase()).toBe(tokenAddress.toLowerCase())
311
308
  expect(eventArgs.validatorToken.toLowerCase()).toBe(
312
- usdAddress.toLowerCase(),
309
+ Addresses.defaultFeeToken.toLowerCase(),
313
310
  )
314
311
  expect(eventArgs.amountOut).toBe(parseEther('10'))
315
312
 
@@ -320,21 +317,21 @@ describe('watchRebalanceSwap', () => {
320
317
  describe('watchMint', () => {
321
318
  test('default', async () => {
322
319
  // Create a new token for testing
323
- const { token } = await actions.token.createSync(client, {
320
+ const { token } = await Actions.token.createSync(client, {
324
321
  name: 'Test Token 2',
325
322
  symbol: 'TEST2',
326
323
  currency: 'USD',
327
324
  })
328
325
 
329
326
  // Grant issuer role to mint tokens
330
- await actions.token.grantRolesSync(client, {
327
+ await Actions.token.grantRolesSync(client, {
331
328
  token,
332
329
  roles: ['issuer'],
333
330
  to: client.account.address,
334
331
  })
335
332
 
336
333
  // Mint some tokens to account
337
- await actions.token.mintSync(client, {
334
+ await Actions.token.mintSync(client, {
338
335
  to: account.address,
339
336
  amount: parseEther('1000'),
340
337
  token,
@@ -342,27 +339,27 @@ describe('watchMint', () => {
342
339
 
343
340
  // Mint USD to account
344
341
  await writeContractSync(client, {
345
- abi: tip20Abi,
346
- address: usdAddress,
342
+ abi: Abis.tip20,
343
+ address: Addresses.defaultFeeToken,
347
344
  functionName: 'transfer',
348
345
  args: [account.address, parseEther('1000')],
349
346
  })
350
347
 
351
348
  let eventArgs: any = null
352
- const unwatch = actions.amm.watchMint(client, {
349
+ const unwatch = Actions.amm.watchMint(client, {
353
350
  onMint: (args) => {
354
351
  eventArgs = args
355
352
  },
356
353
  })
357
354
 
358
355
  // Add liquidity to pool
359
- await actions.amm.mintSync(client, {
356
+ await Actions.amm.mintSync(client, {
360
357
  userToken: {
361
358
  address: token,
362
359
  amount: parseEther('100'),
363
360
  },
364
361
  validatorToken: {
365
- address: usdAddress,
362
+ address: Addresses.defaultFeeToken,
366
363
  amount: parseEther('100'),
367
364
  },
368
365
  to: account.address,
@@ -373,7 +370,7 @@ describe('watchMint', () => {
373
370
  expect(eventArgs).toBeDefined()
374
371
  expect(eventArgs.userToken.address.toLowerCase()).toBe(token.toLowerCase())
375
372
  expect(eventArgs.validatorToken.address.toLowerCase()).toBe(
376
- usdAddress.toLowerCase(),
373
+ Addresses.defaultFeeToken.toLowerCase(),
377
374
  )
378
375
  expect(eventArgs.userToken.amount).toBe(parseEther('100'))
379
376
  expect(eventArgs.validatorToken.amount).toBe(parseEther('100'))
@@ -387,26 +384,26 @@ describe('watchBurn', () => {
387
384
  const { tokenAddress } = await setupPoolWithLiquidity()
388
385
 
389
386
  // Get LP balance
390
- const poolId = await actions.amm.getPoolId(client, {
387
+ const poolId = await Actions.amm.getPoolId(client, {
391
388
  userToken: tokenAddress,
392
- validatorToken: usdAddress,
389
+ validatorToken: Addresses.defaultFeeToken,
393
390
  })
394
- const lpBalance = await actions.amm.getLiquidityBalance(client, {
391
+ const lpBalance = await Actions.amm.getLiquidityBalance(client, {
395
392
  poolId,
396
393
  address: account.address,
397
394
  })
398
395
 
399
396
  let eventArgs: any = null
400
- const unwatch = actions.amm.watchBurn(client, {
397
+ const unwatch = Actions.amm.watchBurn(client, {
401
398
  onBurn: (args) => {
402
399
  eventArgs = args
403
400
  },
404
401
  })
405
402
 
406
403
  // Burn LP tokens
407
- await actions.amm.burnSync(client, {
404
+ await Actions.amm.burnSync(client, {
408
405
  userToken: tokenAddress,
409
- validatorToken: usdAddress,
406
+ validatorToken: Addresses.defaultFeeToken,
410
407
  liquidity: lpBalance / 2n,
411
408
  to: account.address,
412
409
  })
@@ -416,7 +413,7 @@ describe('watchBurn', () => {
416
413
  expect(eventArgs).toBeDefined()
417
414
  expect(eventArgs.userToken.toLowerCase()).toBe(tokenAddress.toLowerCase())
418
415
  expect(eventArgs.validatorToken.toLowerCase()).toBe(
419
- usdAddress.toLowerCase(),
416
+ Addresses.defaultFeeToken.toLowerCase(),
420
417
  )
421
418
  expect(eventArgs.liquidity).toBe(lpBalance / 2n)
422
419