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
@@ -162,156 +162,15 @@ export declare namespace claimSync {
162
162
  type ErrorType = claim.ErrorType;
163
163
  }
164
164
  /**
165
- * Gets the total reward per second rate for all active streams.
165
+ * Distributes rewards to opted-in token holders.
166
166
  *
167
- * Returns the current aggregate per-second emission rate scaled by `ACC_PRECISION` (1e18).
168
- * This value represents the sum of all active reward streams' emission rates.
169
- * The rate decreases when streams end (via `finalizeStreams`) or are canceled.
167
+ * This function transfers `amount` of tokens from the caller into the token contract's
168
+ * reward pool and immediately distributes them to current opted-in holders by increasing
169
+ * `globalRewardPerToken`.
170
170
  *
171
- * @example
172
- * ```ts
173
- * import { createClient, http } from 'viem'
174
- * import { tempo } from 'tempo.ts/chains'
175
- * import { Actions } from 'tempo.ts/viem'
176
- *
177
- * const client = createClient({
178
- * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
179
- * transport: http(),
180
- * })
181
- *
182
- * const rate = await Actions.rewards.getTotalPerSecond(client, {
183
- * token: '0x20c0000000000000000000000000000000000001',
184
- * })
185
- * ```
186
- *
187
- * @param client - Client.
188
- * @param parameters - Parameters.
189
- * @returns The total reward per second (scaled by 1e18).
190
- */
191
- export declare function getTotalPerSecond<chain extends Chain | undefined>(client: Client<Transport, chain>, parameters: getTotalPerSecond.Parameters): Promise<getTotalPerSecond.ReturnValue>;
192
- export declare namespace getTotalPerSecond {
193
- type Parameters = ReadParameters & Args;
194
- type Args = {
195
- /** The TIP20 token address */
196
- token: Address;
197
- };
198
- type ReturnValue = ReadContractReturnType<typeof Abis.tip20, 'totalRewardPerSecond', never>;
199
- /**
200
- * Defines a call to the `totalRewardPerSecond` function.
201
- *
202
- * @param args - Arguments.
203
- * @returns The call.
204
- */
205
- function call(args: Args): {
206
- abi: [{
207
- readonly name: "totalRewardPerSecond";
208
- readonly type: "function";
209
- readonly stateMutability: "view";
210
- readonly inputs: readonly [];
211
- readonly outputs: readonly [{
212
- readonly type: "uint256";
213
- }];
214
- }];
215
- functionName: "totalRewardPerSecond";
216
- } & {
217
- args?: readonly [] | undefined;
218
- } & {
219
- address: Address;
220
- } & {
221
- data: import("../../index.js").Hex;
222
- to: Address;
223
- };
224
- }
225
- /**
226
- * Gets the reward information for a specific account.
227
- *
228
- * Returns the reward recipient address, reward per token value, and accumulated reward balance for the specified account.
229
- * This information includes:
230
- * - `rewardRecipient`: The address designated to receive rewards (zero address if opted out)
231
- * - `rewardPerToken`: The reward per token value for this account
232
- * - `rewardBalance`: The accumulated reward balance waiting to be claimed
233
- *
234
- * @example
235
- * ```ts
236
- * import { createClient, http } from 'viem'
237
- * import { tempo } from 'tempo.ts/chains'
238
- * import { Actions } from 'tempo.ts/viem'
239
- *
240
- * const client = createClient({
241
- * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
242
- * transport: http(),
243
- * })
244
- *
245
- * const info = await Actions.reward.getUserRewardInfo(client, {
246
- * token: '0x20c0000000000000000000000000000000000001',
247
- * account: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
248
- * })
249
- * ```
250
- *
251
- * @param client - Client.
252
- * @param parameters - Parameters.
253
- * @returns The user's reward information (recipient, rewardPerToken, rewardBalance).
254
- */
255
- export declare function getUserRewardInfo<chain extends Chain | undefined>(client: Client<Transport, chain>, parameters: getUserRewardInfo.Parameters): Promise<getUserRewardInfo.ReturnValue>;
256
- export declare namespace getUserRewardInfo {
257
- type Parameters = ReadParameters & Args;
258
- type Args = {
259
- /** The account address to query reward info for */
260
- account: Address;
261
- /** The TIP20 token address */
262
- token: Address;
263
- };
264
- type ReturnValue = ReadContractReturnType<typeof Abis.tip20, 'userRewardInfo', never>;
265
- /**
266
- * Defines a call to the `userRewardInfo` function.
267
- *
268
- * @param args - Arguments.
269
- * @returns The call.
270
- */
271
- function call(args: Args): {
272
- abi: [{
273
- readonly name: "userRewardInfo";
274
- readonly type: "function";
275
- readonly stateMutability: "view";
276
- readonly inputs: readonly [{
277
- readonly type: "address";
278
- readonly name: "account";
279
- }];
280
- readonly outputs: readonly [{
281
- readonly type: "tuple";
282
- readonly components: readonly [{
283
- readonly type: "address";
284
- readonly name: "rewardRecipient";
285
- }, {
286
- readonly type: "uint256";
287
- readonly name: "rewardPerToken";
288
- }, {
289
- readonly type: "uint256";
290
- readonly name: "rewardBalance";
291
- }];
292
- }];
293
- }];
294
- functionName: "userRewardInfo";
295
- } & {
296
- args: readonly [account: `0x${string}`];
297
- } & {
298
- address: Address;
299
- } & {
300
- data: import("../../index.js").Hex;
301
- to: Address;
302
- };
303
- }
304
- /**
305
- * Sets or changes the reward recipient for a token holder.
306
- *
307
- * This function allows a token holder to designate who should receive their share of rewards:
308
- * - If `recipient` is the zero address, opts out from rewards distribution.
309
- * - Otherwise, opts in and sets `recipient` as the address that will receive accrued rewards.
310
- * - Can be called with `recipient == msg.sender` to receive rewards directly.
311
- * - Automatically distributes any accrued rewards to the current recipient before changing.
312
- *
313
- * TIP-403 Policy:
314
- * - Reverts with `PolicyForbids` if `recipient` is not the zero address and either the holder or recipient is not authorized to receive tokens under the token's transfer policy.
171
+ * Notes:
172
+ * - Reverts with `InvalidAmount` if `amount == 0`.
173
+ * - The transfer from caller to pool is subject to TIP-403 policy checks.
315
174
  *
316
175
  * @example
317
176
  * ```ts
@@ -326,8 +185,8 @@ export declare namespace getUserRewardInfo {
326
185
  * transport: http(),
327
186
  * })
328
187
  *
329
- * const hash = await Actions.rewards.setRecipient(client, {
330
- * recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
188
+ * const hash = await Actions.reward.distribute(client, {
189
+ * amount: 100000000000000000000n,
331
190
  * token: '0x20c0000000000000000000000000000000000001',
332
191
  * })
333
192
  * ```
@@ -336,18 +195,17 @@ export declare namespace getUserRewardInfo {
336
195
  * @param parameters - Parameters.
337
196
  * @returns The transaction hash.
338
197
  */
339
- export declare function setRecipient<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: setRecipient.Parameters<chain, account>): Promise<setRecipient.ReturnValue>;
198
+ export declare function distribute<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: distribute.Parameters<chain, account>): Promise<distribute.ReturnValue>;
340
199
  /**
341
- * Sets or changes the reward recipient for a token holder and waits for confirmation.
200
+ * Distributes rewards to opted-in token holders and waits for confirmation.
342
201
  *
343
- * This function allows a token holder to designate who should receive their share of rewards:
344
- * - If `recipient` is the zero address, opts out from rewards distribution.
345
- * - Otherwise, opts in and sets `recipient` as the address that will receive accrued rewards.
346
- * - Can be called with `recipient == msg.sender` to receive rewards directly.
347
- * - Automatically distributes any accrued rewards to the current recipient before changing.
202
+ * This function transfers `amount` of tokens from the caller into the token contract's
203
+ * reward pool and immediately distributes them to current opted-in holders by increasing
204
+ * `globalRewardPerToken`.
348
205
  *
349
- * TIP-403 Policy:
350
- * - Reverts with `PolicyForbids` if `recipient` is not the zero address and either the holder or recipient is not authorized to receive tokens under the token's transfer policy.
206
+ * Notes:
207
+ * - Reverts with `InvalidAmount` if `amount == 0`.
208
+ * - The transfer from caller to pool is subject to TIP-403 policy checks.
351
209
  *
352
210
  * @example
353
211
  * ```ts
@@ -362,21 +220,21 @@ export declare function setRecipient<chain extends Chain | undefined, account ex
362
220
  * transport: http(),
363
221
  * })
364
222
  *
365
- * const { holder, recipient, receipt } = await Actions.rewards.setRecipientSync(client, {
366
- * recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
223
+ * const { amount, funder, receipt } = await Actions.reward.distributeSync(client, {
224
+ * amount: 100000000000000000000n,
367
225
  * token: '0x20c0000000000000000000000000000000000001',
368
226
  * })
369
227
  * ```
370
228
  *
371
229
  * @param client - Client.
372
230
  * @param parameters - Parameters.
373
- * @returns The holder, recipient, and transaction receipt.
231
+ * @returns The funder, amount, and transaction receipt.
374
232
  */
375
- export declare function setRecipientSync<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: setRecipientSync.Parameters<chain, account>): Promise<setRecipientSync.ReturnValue>;
376
- export declare namespace setRecipient {
233
+ export declare function distributeSync<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: distributeSync.Parameters<chain, account>): Promise<distributeSync.ReturnValue>;
234
+ export declare namespace distribute {
377
235
  type Args = {
378
- /** The reward recipient address (use zero address to opt out of rewards) */
379
- recipient: Address;
236
+ /** The amount of tokens to distribute (must be > 0) */
237
+ amount: bigint;
380
238
  /** The TIP20 token address */
381
239
  token: Address;
382
240
  };
@@ -386,7 +244,7 @@ export declare namespace setRecipient {
386
244
  /** @internal */
387
245
  function inner<action extends typeof writeContract | typeof writeContractSync, chain extends Chain | undefined, account extends Account | undefined>(action: action, client: Client<Transport, chain, account>, parameters: Parameters<chain, account>): Promise<ReturnType<action>>;
388
246
  /**
389
- * Defines a call to the `setRecipient` function.
247
+ * Defines a call to the `distributeReward` function.
390
248
  *
391
249
  * Can be passed as a parameter to:
392
250
  * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
@@ -405,8 +263,8 @@ export declare namespace setRecipient {
405
263
  * }).extend(walletActions)
406
264
  *
407
265
  * const hash = await client.sendTransaction({
408
- * calls: [actions.rewards.setRecipient.call({
409
- * recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
266
+ * calls: [actions.reward.distribute.call({
267
+ * amount: 100000000000000000000n,
410
268
  * token: '0x20c0000000000000000000000000000000000001',
411
269
  * })],
412
270
  * })
@@ -417,18 +275,18 @@ export declare namespace setRecipient {
417
275
  */
418
276
  function call(args: Args): {
419
277
  abi: [{
420
- readonly name: "setRewardRecipient";
278
+ readonly name: "distributeReward";
421
279
  readonly type: "function";
422
280
  readonly stateMutability: "nonpayable";
423
281
  readonly inputs: readonly [{
424
- readonly type: "address";
425
- readonly name: "recipient";
282
+ readonly type: "uint256";
283
+ readonly name: "amount";
426
284
  }];
427
285
  readonly outputs: readonly [];
428
286
  }];
429
- functionName: "setRewardRecipient";
287
+ functionName: "distributeReward";
430
288
  } & {
431
- args: readonly [recipient: `0x${string}`];
289
+ args: readonly [amount: bigint];
432
290
  } & {
433
291
  address: Address;
434
292
  } & {
@@ -436,10 +294,10 @@ export declare namespace setRecipient {
436
294
  to: Address;
437
295
  };
438
296
  /**
439
- * Extracts the `RewardRecipientSet` event from logs.
297
+ * Extracts the `RewardDistributed` event from logs.
440
298
  *
441
299
  * @param logs - The logs.
442
- * @returns The `RewardRecipientSet` event.
300
+ * @returns The `RewardDistributed` event.
443
301
  */
444
302
  function extractEvent(logs: Log[]): Log<bigint, number, false, undefined, true, readonly [{
445
303
  readonly name: "name";
@@ -686,25 +544,6 @@ export declare namespace setRecipient {
686
544
  readonly outputs: readonly [{
687
545
  readonly type: "bool";
688
546
  }];
689
- }, {
690
- readonly name: "feeRecipient";
691
- readonly type: "function";
692
- readonly stateMutability: "view";
693
- readonly inputs: readonly [];
694
- readonly outputs: readonly [{
695
- readonly type: "address";
696
- }];
697
- }, {
698
- readonly name: "setFeeRecipient";
699
- readonly type: "function";
700
- readonly stateMutability: "view";
701
- readonly inputs: readonly [{
702
- readonly type: "address";
703
- readonly name: "newRecipient";
704
- }];
705
- readonly outputs: readonly [{
706
- readonly type: "address";
707
- }];
708
547
  }, {
709
548
  readonly name: "changeTransferPolicyId";
710
549
  readonly type: "function";
@@ -783,19 +622,14 @@ export declare namespace setRecipient {
783
622
  readonly type: "bytes32";
784
623
  }];
785
624
  }, {
786
- readonly name: "startReward";
625
+ readonly name: "distributeReward";
787
626
  readonly type: "function";
788
627
  readonly stateMutability: "nonpayable";
789
628
  readonly inputs: readonly [{
790
629
  readonly type: "uint256";
791
630
  readonly name: "amount";
792
- }, {
793
- readonly type: "uint32";
794
- readonly name: "secs";
795
- }];
796
- readonly outputs: readonly [{
797
- readonly type: "uint64";
798
631
  }];
632
+ readonly outputs: readonly [];
799
633
  }, {
800
634
  readonly name: "setRewardRecipient";
801
635
  readonly type: "function";
@@ -805,17 +639,6 @@ export declare namespace setRecipient {
805
639
  readonly name: "recipient";
806
640
  }];
807
641
  readonly outputs: readonly [];
808
- }, {
809
- readonly name: "cancelReward";
810
- readonly type: "function";
811
- readonly stateMutability: "nonpayable";
812
- readonly inputs: readonly [{
813
- readonly type: "uint64";
814
- readonly name: "id";
815
- }];
816
- readonly outputs: readonly [{
817
- readonly type: "uint256";
818
- }];
819
642
  }, {
820
643
  readonly name: "claimRewards";
821
644
  readonly type: "function";
@@ -824,50 +647,6 @@ export declare namespace setRecipient {
824
647
  readonly outputs: readonly [{
825
648
  readonly type: "uint256";
826
649
  }];
827
- }, {
828
- readonly name: "finalizeStreams";
829
- readonly type: "function";
830
- readonly stateMutability: "nonpayable";
831
- readonly inputs: readonly [{
832
- readonly type: "uint64";
833
- readonly name: "timestamp";
834
- }];
835
- readonly outputs: readonly [];
836
- }, {
837
- readonly name: "getStream";
838
- readonly type: "function";
839
- readonly stateMutability: "view";
840
- readonly inputs: readonly [{
841
- readonly type: "uint64";
842
- readonly name: "id";
843
- }];
844
- readonly outputs: readonly [{
845
- readonly type: "tuple";
846
- readonly components: readonly [{
847
- readonly type: "address";
848
- readonly name: "funder";
849
- }, {
850
- readonly type: "uint64";
851
- readonly name: "startTime";
852
- }, {
853
- readonly type: "uint64";
854
- readonly name: "endTime";
855
- }, {
856
- readonly type: "uint256";
857
- readonly name: "ratePerSecondScaled";
858
- }, {
859
- readonly type: "uint256";
860
- readonly name: "amountTotal";
861
- }];
862
- }];
863
- }, {
864
- readonly name: "totalRewardPerSecond";
865
- readonly type: "function";
866
- readonly stateMutability: "view";
867
- readonly inputs: readonly [];
868
- readonly outputs: readonly [{
869
- readonly type: "uint256";
870
- }];
871
650
  }, {
872
651
  readonly name: "optedInSupply";
873
652
  readonly type: "function";
@@ -877,12 +656,12 @@ export declare namespace setRecipient {
877
656
  readonly type: "uint128";
878
657
  }];
879
658
  }, {
880
- readonly name: "nextStreamId";
659
+ readonly name: "globalRewardPerToken";
881
660
  readonly type: "function";
882
661
  readonly stateMutability: "view";
883
662
  readonly inputs: readonly [];
884
663
  readonly outputs: readonly [{
885
- readonly type: "uint64";
664
+ readonly type: "uint256";
886
665
  }];
887
666
  }, {
888
667
  readonly name: "userRewardInfo";
@@ -905,6 +684,17 @@ export declare namespace setRecipient {
905
684
  readonly name: "rewardBalance";
906
685
  }];
907
686
  }];
687
+ }, {
688
+ readonly name: "getPendingRewards";
689
+ readonly type: "function";
690
+ readonly stateMutability: "view";
691
+ readonly inputs: readonly [{
692
+ readonly type: "address";
693
+ readonly name: "account";
694
+ }];
695
+ readonly outputs: readonly [{
696
+ readonly type: "uint128";
697
+ }];
908
698
  }, {
909
699
  readonly name: "Transfer";
910
700
  readonly type: "event";
@@ -1047,37 +837,15 @@ export declare namespace setRecipient {
1047
837
  readonly indexed: true;
1048
838
  }];
1049
839
  }, {
1050
- readonly name: "RewardScheduled";
840
+ readonly name: "RewardDistributed";
1051
841
  readonly type: "event";
1052
842
  readonly inputs: readonly [{
1053
843
  readonly type: "address";
1054
844
  readonly name: "funder";
1055
845
  readonly indexed: true;
1056
- }, {
1057
- readonly type: "uint64";
1058
- readonly name: "id";
1059
- readonly indexed: true;
1060
846
  }, {
1061
847
  readonly type: "uint256";
1062
848
  readonly name: "amount";
1063
- }, {
1064
- readonly type: "uint32";
1065
- readonly name: "durationSeconds";
1066
- }];
1067
- }, {
1068
- readonly name: "RewardCanceled";
1069
- readonly type: "event";
1070
- readonly inputs: readonly [{
1071
- readonly type: "address";
1072
- readonly name: "funder";
1073
- readonly indexed: true;
1074
- }, {
1075
- readonly type: "uint64";
1076
- readonly name: "id";
1077
- readonly indexed: true;
1078
- }, {
1079
- readonly type: "uint256";
1080
- readonly name: "refund";
1081
849
  }];
1082
850
  }, {
1083
851
  readonly name: "RewardRecipientSet";
@@ -1091,18 +859,6 @@ export declare namespace setRecipient {
1091
859
  readonly name: "recipient";
1092
860
  readonly indexed: true;
1093
861
  }];
1094
- }, {
1095
- readonly name: "FeeRecipientUpdated";
1096
- readonly type: "event";
1097
- readonly inputs: readonly [{
1098
- readonly type: "address";
1099
- readonly name: "updater";
1100
- readonly indexed: true;
1101
- }, {
1102
- readonly type: "address";
1103
- readonly name: "newRecipient";
1104
- readonly indexed: true;
1105
- }];
1106
862
  }, {
1107
863
  readonly name: "InsufficientBalance";
1108
864
  readonly type: "error";
@@ -1164,14 +920,6 @@ export declare namespace setRecipient {
1164
920
  readonly name: "InvalidAmount";
1165
921
  readonly type: "error";
1166
922
  readonly inputs: readonly [];
1167
- }, {
1168
- readonly name: "NotStreamFunder";
1169
- readonly type: "error";
1170
- readonly inputs: readonly [];
1171
- }, {
1172
- readonly name: "StreamInactive";
1173
- readonly type: "error";
1174
- readonly inputs: readonly [];
1175
923
  }, {
1176
924
  readonly name: "NoOptedInSupply";
1177
925
  readonly type: "error";
@@ -1181,19 +929,19 @@ export declare namespace setRecipient {
1181
929
  readonly type: "error";
1182
930
  readonly inputs: readonly [];
1183
931
  }, {
1184
- readonly name: "RewardsDisabled";
932
+ readonly name: "ProtectedAddress";
1185
933
  readonly type: "error";
1186
934
  readonly inputs: readonly [];
1187
935
  }, {
1188
- readonly name: "ScheduledRewardsDisabled";
936
+ readonly name: "InvalidToken";
1189
937
  readonly type: "error";
1190
938
  readonly inputs: readonly [];
1191
939
  }, {
1192
- readonly name: "ProtectedAddress";
940
+ readonly name: "Uninitialized";
1193
941
  readonly type: "error";
1194
942
  readonly inputs: readonly [];
1195
943
  }, {
1196
- readonly name: "InvalidToken";
944
+ readonly name: "InvalidTransferPolicyId";
1197
945
  readonly type: "error";
1198
946
  readonly inputs: readonly [];
1199
947
  }, {
@@ -1301,38 +1049,239 @@ export declare namespace setRecipient {
1301
1049
  readonly name: "sender";
1302
1050
  readonly indexed: true;
1303
1051
  }];
1304
- }, {
1305
- readonly name: "Unauthorized";
1306
- readonly type: "error";
1307
- readonly inputs: readonly [];
1308
- }], "RewardRecipientSet">;
1309
- }
1310
- export declare namespace setRecipientSync {
1311
- type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = WriteParameters<chain, account> & setRecipient.Args;
1312
- type ReturnValue = {
1313
- /** The token holder address who set their reward recipient */
1314
- holder: Address;
1315
- /** The transaction receipt */
1316
- receipt: Awaited<ReturnType<typeof writeContractSync>>;
1317
- /** The reward recipient address (zero address indicates opt-out) */
1318
- recipient: Address;
1052
+ }, {
1053
+ readonly name: "Unauthorized";
1054
+ readonly type: "error";
1055
+ readonly inputs: readonly [];
1056
+ }], "RewardDistributed">;
1057
+ }
1058
+ export declare namespace distributeSync {
1059
+ type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = WriteParameters<chain, account> & distribute.Args;
1060
+ type ReturnValue = {
1061
+ /** The amount distributed */
1062
+ amount: bigint;
1063
+ /** The address that funded the distribution */
1064
+ funder: Address;
1065
+ /** The transaction receipt */
1066
+ receipt: Awaited<ReturnType<typeof writeContractSync>>;
1067
+ };
1068
+ type ErrorType = distribute.ErrorType;
1069
+ }
1070
+ /**
1071
+ * Gets the global reward per token value.
1072
+ *
1073
+ * Returns the current global reward per token value scaled by `ACC_PRECISION` (1e18).
1074
+ * This value increases each time rewards are distributed.
1075
+ *
1076
+ * @example
1077
+ * ```ts
1078
+ * import { createClient, http } from 'viem'
1079
+ * import { tempo } from 'tempo.ts/chains'
1080
+ * import { Actions } from 'tempo.ts/viem'
1081
+ *
1082
+ * const client = createClient({
1083
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
1084
+ * transport: http(),
1085
+ * })
1086
+ *
1087
+ * const rewardPerToken = await Actions.reward.getGlobalRewardPerToken(client, {
1088
+ * token: '0x20c0000000000000000000000000000000000001',
1089
+ * })
1090
+ * ```
1091
+ *
1092
+ * @param client - Client.
1093
+ * @param parameters - Parameters.
1094
+ * @returns The global reward per token (scaled by 1e18).
1095
+ */
1096
+ export declare function getGlobalRewardPerToken<chain extends Chain | undefined>(client: Client<Transport, chain>, parameters: getGlobalRewardPerToken.Parameters): Promise<getGlobalRewardPerToken.ReturnValue>;
1097
+ export declare namespace getGlobalRewardPerToken {
1098
+ type Parameters = ReadParameters & Args;
1099
+ type Args = {
1100
+ /** The TIP20 token address */
1101
+ token: Address;
1102
+ };
1103
+ type ReturnValue = ReadContractReturnType<typeof Abis.tip20, 'globalRewardPerToken', never>;
1104
+ /**
1105
+ * Defines a call to the `globalRewardPerToken` function.
1106
+ *
1107
+ * @param args - Arguments.
1108
+ * @returns The call.
1109
+ */
1110
+ function call(args: Args): {
1111
+ abi: [{
1112
+ readonly name: "globalRewardPerToken";
1113
+ readonly type: "function";
1114
+ readonly stateMutability: "view";
1115
+ readonly inputs: readonly [];
1116
+ readonly outputs: readonly [{
1117
+ readonly type: "uint256";
1118
+ }];
1119
+ }];
1120
+ functionName: "globalRewardPerToken";
1121
+ } & {
1122
+ args?: readonly [] | undefined;
1123
+ } & {
1124
+ address: Address;
1125
+ } & {
1126
+ data: import("../../index.js").Hex;
1127
+ to: Address;
1128
+ };
1129
+ }
1130
+ /**
1131
+ * Calculates the pending claimable rewards for an account without modifying state.
1132
+ *
1133
+ * Returns the total pending claimable reward amount, including stored balance and newly accrued rewards.
1134
+ *
1135
+ * @example
1136
+ * ```ts
1137
+ * import { createClient, http } from 'viem'
1138
+ * import { tempo } from 'tempo.ts/chains'
1139
+ * import { Actions } from 'tempo.ts/viem'
1140
+ *
1141
+ * const client = createClient({
1142
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
1143
+ * transport: http(),
1144
+ * })
1145
+ *
1146
+ * const pending = await Actions.reward.getPendingRewards(client, {
1147
+ * token: '0x20c0000000000000000000000000000000000001',
1148
+ * account: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
1149
+ * })
1150
+ * ```
1151
+ *
1152
+ * @param client - Client.
1153
+ * @param parameters - Parameters.
1154
+ * @returns The total pending claimable reward amount.
1155
+ */
1156
+ export declare function getPendingRewards<chain extends Chain | undefined>(client: Client<Transport, chain>, parameters: getPendingRewards.Parameters): Promise<getPendingRewards.ReturnValue>;
1157
+ export declare namespace getPendingRewards {
1158
+ type Parameters = ReadParameters & Args;
1159
+ type Args = {
1160
+ /** The account address to query pending rewards for */
1161
+ account: Address;
1162
+ /** The TIP20 token address */
1163
+ token: Address;
1164
+ };
1165
+ type ReturnValue = ReadContractReturnType<typeof Abis.tip20, 'getPendingRewards', never>;
1166
+ /**
1167
+ * Defines a call to the `getPendingRewards` function.
1168
+ *
1169
+ * @param args - Arguments.
1170
+ * @returns The call.
1171
+ */
1172
+ function call(args: Args): {
1173
+ abi: [{
1174
+ readonly name: "getPendingRewards";
1175
+ readonly type: "function";
1176
+ readonly stateMutability: "view";
1177
+ readonly inputs: readonly [{
1178
+ readonly type: "address";
1179
+ readonly name: "account";
1180
+ }];
1181
+ readonly outputs: readonly [{
1182
+ readonly type: "uint128";
1183
+ }];
1184
+ }];
1185
+ functionName: "getPendingRewards";
1186
+ } & {
1187
+ args: readonly [account: `0x${string}`];
1188
+ } & {
1189
+ address: Address;
1190
+ } & {
1191
+ data: import("../../index.js").Hex;
1192
+ to: Address;
1193
+ };
1194
+ }
1195
+ /**
1196
+ * Gets the reward information for a specific account.
1197
+ *
1198
+ * Returns the reward recipient address, reward per token value, and accumulated reward balance for the specified account.
1199
+ * This information includes:
1200
+ * - `rewardRecipient`: The address designated to receive rewards (zero address if opted out)
1201
+ * - `rewardPerToken`: The reward per token value for this account
1202
+ * - `rewardBalance`: The accumulated reward balance waiting to be claimed
1203
+ *
1204
+ * @example
1205
+ * ```ts
1206
+ * import { createClient, http } from 'viem'
1207
+ * import { tempo } from 'tempo.ts/chains'
1208
+ * import { Actions } from 'tempo.ts/viem'
1209
+ *
1210
+ * const client = createClient({
1211
+ * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
1212
+ * transport: http(),
1213
+ * })
1214
+ *
1215
+ * const info = await Actions.reward.getUserRewardInfo(client, {
1216
+ * token: '0x20c0000000000000000000000000000000000001',
1217
+ * account: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
1218
+ * })
1219
+ * ```
1220
+ *
1221
+ * @param client - Client.
1222
+ * @param parameters - Parameters.
1223
+ * @returns The user's reward information (recipient, rewardPerToken, rewardBalance).
1224
+ */
1225
+ export declare function getUserRewardInfo<chain extends Chain | undefined>(client: Client<Transport, chain>, parameters: getUserRewardInfo.Parameters): Promise<getUserRewardInfo.ReturnValue>;
1226
+ export declare namespace getUserRewardInfo {
1227
+ type Parameters = ReadParameters & Args;
1228
+ type Args = {
1229
+ /** The account address to query reward info for */
1230
+ account: Address;
1231
+ /** The TIP20 token address */
1232
+ token: Address;
1233
+ };
1234
+ type ReturnValue = ReadContractReturnType<typeof Abis.tip20, 'userRewardInfo', never>;
1235
+ /**
1236
+ * Defines a call to the `userRewardInfo` function.
1237
+ *
1238
+ * @param args - Arguments.
1239
+ * @returns The call.
1240
+ */
1241
+ function call(args: Args): {
1242
+ abi: [{
1243
+ readonly name: "userRewardInfo";
1244
+ readonly type: "function";
1245
+ readonly stateMutability: "view";
1246
+ readonly inputs: readonly [{
1247
+ readonly type: "address";
1248
+ readonly name: "account";
1249
+ }];
1250
+ readonly outputs: readonly [{
1251
+ readonly type: "tuple";
1252
+ readonly components: readonly [{
1253
+ readonly type: "address";
1254
+ readonly name: "rewardRecipient";
1255
+ }, {
1256
+ readonly type: "uint256";
1257
+ readonly name: "rewardPerToken";
1258
+ }, {
1259
+ readonly type: "uint256";
1260
+ readonly name: "rewardBalance";
1261
+ }];
1262
+ }];
1263
+ }];
1264
+ functionName: "userRewardInfo";
1265
+ } & {
1266
+ args: readonly [account: `0x${string}`];
1267
+ } & {
1268
+ address: Address;
1269
+ } & {
1270
+ data: import("../../index.js").Hex;
1271
+ to: Address;
1319
1272
  };
1320
- type ErrorType = setRecipient.ErrorType;
1321
1273
  }
1322
1274
  /**
1323
- * Starts a new reward stream that distributes tokens to opted-in holders.
1275
+ * Sets or changes the reward recipient for a token holder.
1324
1276
  *
1325
- * Behavior:
1326
- * - Transfers `amount` of tokens from the caller into the token contract's reward pool.
1327
- * - If `seconds == 0`: Immediately distributes `amount` to current opted-in holders by increasing `rewardPerTokenStored`.
1328
- * Returns stream ID `0`. Distribution occurs when holders interact with the token (transfers, etc.).
1329
- * - If `seconds > 0`: Starts a linear stream that emits evenly from `block.timestamp` to `block.timestamp + seconds`.
1330
- * Returns a unique stream ID for later cancellation.
1277
+ * This function allows a token holder to designate who should receive their share of rewards:
1278
+ * - If `recipient` is the zero address, opts out from rewards distribution.
1279
+ * - Otherwise, opts in and sets `recipient` as the address that will receive accrued rewards.
1280
+ * - Can be called with `recipient == msg.sender` to receive rewards directly.
1281
+ * - Automatically distributes any accrued rewards to the current recipient before changing.
1331
1282
  *
1332
- * Notes:
1333
- * - Reverts with `InvalidAmount` if `amount == 0`.
1334
- * - Allowed even when `optedInSupply == 0` (tokens distributed while no one is opted in are locked permanently).
1335
- * - The transfer from caller to pool is subject to TIP-403 policy checks.
1283
+ * TIP-403 Policy:
1284
+ * - Reverts with `PolicyForbids` if `recipient` is not the zero address and either the holder or recipient is not authorized to receive tokens under the token's transfer policy.
1336
1285
  *
1337
1286
  * @example
1338
1287
  * ```ts
@@ -1347,9 +1296,8 @@ export declare namespace setRecipientSync {
1347
1296
  * transport: http(),
1348
1297
  * })
1349
1298
  *
1350
- * const hash = await Actions.rewards.start(client, {
1351
- * amount: 100000000000000000000n,
1352
- * seconds: 86400,
1299
+ * const hash = await Actions.reward.setRecipient(client, {
1300
+ * recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
1353
1301
  * token: '0x20c0000000000000000000000000000000000001',
1354
1302
  * })
1355
1303
  * ```
@@ -1358,21 +1306,18 @@ export declare namespace setRecipientSync {
1358
1306
  * @param parameters - Parameters.
1359
1307
  * @returns The transaction hash.
1360
1308
  */
1361
- export declare function start<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: start.Parameters<chain, account>): Promise<start.ReturnValue>;
1309
+ export declare function setRecipient<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: setRecipient.Parameters<chain, account>): Promise<setRecipient.ReturnValue>;
1362
1310
  /**
1363
- * Starts a new reward stream that distributes tokens to opted-in holders and waits for confirmation.
1311
+ * Sets or changes the reward recipient for a token holder and waits for confirmation.
1364
1312
  *
1365
- * Behavior:
1366
- * - Transfers `amount` of tokens from the caller into the token contract's reward pool.
1367
- * - If `seconds == 0`: Immediately distributes `amount` to current opted-in holders by increasing `rewardPerTokenStored`.
1368
- * Returns stream ID `0`. Distribution occurs when holders interact with the token (transfers, etc.).
1369
- * - If `seconds > 0`: Starts a linear stream that emits evenly from `block.timestamp` to `block.timestamp + seconds`.
1370
- * Returns a unique stream ID for later cancellation.
1313
+ * This function allows a token holder to designate who should receive their share of rewards:
1314
+ * - If `recipient` is the zero address, opts out from rewards distribution.
1315
+ * - Otherwise, opts in and sets `recipient` as the address that will receive accrued rewards.
1316
+ * - Can be called with `recipient == msg.sender` to receive rewards directly.
1317
+ * - Automatically distributes any accrued rewards to the current recipient before changing.
1371
1318
  *
1372
- * Notes:
1373
- * - Reverts with `InvalidAmount` if `amount == 0`.
1374
- * - Allowed even when `optedInSupply == 0` (tokens distributed while no one is opted in are locked permanently).
1375
- * - The transfer from caller to pool is subject to TIP-403 policy checks.
1319
+ * TIP-403 Policy:
1320
+ * - Reverts with `PolicyForbids` if `recipient` is not the zero address and either the holder or recipient is not authorized to receive tokens under the token's transfer policy.
1376
1321
  *
1377
1322
  * @example
1378
1323
  * ```ts
@@ -1387,22 +1332,21 @@ export declare function start<chain extends Chain | undefined, account extends A
1387
1332
  * transport: http(),
1388
1333
  * })
1389
1334
  *
1390
- * const { id, receipt } = await Actions.rewards.startSync(client, {
1391
- * amount: 100000000000000000000n,
1392
- * seconds: 86400,
1335
+ * const { holder, recipient, receipt } = await Actions.reward.setRecipientSync(client, {
1336
+ * recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
1393
1337
  * token: '0x20c0000000000000000000000000000000000001',
1394
1338
  * })
1395
1339
  * ```
1396
1340
  *
1397
1341
  * @param client - Client.
1398
1342
  * @param parameters - Parameters.
1399
- * @returns The stream ID, funder, amount, duration, and transaction receipt.
1343
+ * @returns The holder, recipient, and transaction receipt.
1400
1344
  */
1401
- export declare function startSync<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: startSync.Parameters<chain, account>): Promise<startSync.ReturnValue>;
1402
- export declare namespace start {
1345
+ export declare function setRecipientSync<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: setRecipientSync.Parameters<chain, account>): Promise<setRecipientSync.ReturnValue>;
1346
+ export declare namespace setRecipient {
1403
1347
  type Args = {
1404
- /** The amount of tokens to distribute (must be > 0) */
1405
- amount: bigint;
1348
+ /** The reward recipient address (use zero address to opt out of rewards) */
1349
+ recipient: Address;
1406
1350
  /** The TIP20 token address */
1407
1351
  token: Address;
1408
1352
  };
@@ -1412,7 +1356,7 @@ export declare namespace start {
1412
1356
  /** @internal */
1413
1357
  function inner<action extends typeof writeContract | typeof writeContractSync, chain extends Chain | undefined, account extends Account | undefined>(action: action, client: Client<Transport, chain, account>, parameters: Parameters<chain, account>): Promise<ReturnType<action>>;
1414
1358
  /**
1415
- * Defines a call to the `start` function.
1359
+ * Defines a call to the `setRewardRecipient` function.
1416
1360
  *
1417
1361
  * Can be passed as a parameter to:
1418
1362
  * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
@@ -1431,9 +1375,8 @@ export declare namespace start {
1431
1375
  * }).extend(walletActions)
1432
1376
  *
1433
1377
  * const hash = await client.sendTransaction({
1434
- * calls: [actions.rewards.start.call({
1435
- * amount: 100000000000000000000n,
1436
- * seconds: 86400,
1378
+ * calls: [actions.reward.setRecipient.call({
1379
+ * recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
1437
1380
  * token: '0x20c0000000000000000000000000000000000001',
1438
1381
  * })],
1439
1382
  * })
@@ -1444,23 +1387,18 @@ export declare namespace start {
1444
1387
  */
1445
1388
  function call(args: Args): {
1446
1389
  abi: [{
1447
- readonly name: "startReward";
1390
+ readonly name: "setRewardRecipient";
1448
1391
  readonly type: "function";
1449
1392
  readonly stateMutability: "nonpayable";
1450
1393
  readonly inputs: readonly [{
1451
- readonly type: "uint256";
1452
- readonly name: "amount";
1453
- }, {
1454
- readonly type: "uint32";
1455
- readonly name: "secs";
1456
- }];
1457
- readonly outputs: readonly [{
1458
- readonly type: "uint64";
1394
+ readonly type: "address";
1395
+ readonly name: "recipient";
1459
1396
  }];
1397
+ readonly outputs: readonly [];
1460
1398
  }];
1461
- functionName: "startReward";
1399
+ functionName: "setRewardRecipient";
1462
1400
  } & {
1463
- args: readonly [amount: bigint, secs: number];
1401
+ args: readonly [recipient: `0x${string}`];
1464
1402
  } & {
1465
1403
  address: Address;
1466
1404
  } & {
@@ -1468,10 +1406,10 @@ export declare namespace start {
1468
1406
  to: Address;
1469
1407
  };
1470
1408
  /**
1471
- * Extracts the `RewardScheduled` event from logs.
1409
+ * Extracts the `RewardRecipientSet` event from logs.
1472
1410
  *
1473
1411
  * @param logs - The logs.
1474
- * @returns The `RewardScheduled` event.
1412
+ * @returns The `RewardRecipientSet` event.
1475
1413
  */
1476
1414
  function extractEvent(logs: Log[]): Log<bigint, number, false, undefined, true, readonly [{
1477
1415
  readonly name: "name";
@@ -1718,25 +1656,6 @@ export declare namespace start {
1718
1656
  readonly outputs: readonly [{
1719
1657
  readonly type: "bool";
1720
1658
  }];
1721
- }, {
1722
- readonly name: "feeRecipient";
1723
- readonly type: "function";
1724
- readonly stateMutability: "view";
1725
- readonly inputs: readonly [];
1726
- readonly outputs: readonly [{
1727
- readonly type: "address";
1728
- }];
1729
- }, {
1730
- readonly name: "setFeeRecipient";
1731
- readonly type: "function";
1732
- readonly stateMutability: "view";
1733
- readonly inputs: readonly [{
1734
- readonly type: "address";
1735
- readonly name: "newRecipient";
1736
- }];
1737
- readonly outputs: readonly [{
1738
- readonly type: "address";
1739
- }];
1740
1659
  }, {
1741
1660
  readonly name: "changeTransferPolicyId";
1742
1661
  readonly type: "function";
@@ -1815,19 +1734,14 @@ export declare namespace start {
1815
1734
  readonly type: "bytes32";
1816
1735
  }];
1817
1736
  }, {
1818
- readonly name: "startReward";
1737
+ readonly name: "distributeReward";
1819
1738
  readonly type: "function";
1820
1739
  readonly stateMutability: "nonpayable";
1821
1740
  readonly inputs: readonly [{
1822
1741
  readonly type: "uint256";
1823
1742
  readonly name: "amount";
1824
- }, {
1825
- readonly type: "uint32";
1826
- readonly name: "secs";
1827
- }];
1828
- readonly outputs: readonly [{
1829
- readonly type: "uint64";
1830
1743
  }];
1744
+ readonly outputs: readonly [];
1831
1745
  }, {
1832
1746
  readonly name: "setRewardRecipient";
1833
1747
  readonly type: "function";
@@ -1837,17 +1751,6 @@ export declare namespace start {
1837
1751
  readonly name: "recipient";
1838
1752
  }];
1839
1753
  readonly outputs: readonly [];
1840
- }, {
1841
- readonly name: "cancelReward";
1842
- readonly type: "function";
1843
- readonly stateMutability: "nonpayable";
1844
- readonly inputs: readonly [{
1845
- readonly type: "uint64";
1846
- readonly name: "id";
1847
- }];
1848
- readonly outputs: readonly [{
1849
- readonly type: "uint256";
1850
- }];
1851
1754
  }, {
1852
1755
  readonly name: "claimRewards";
1853
1756
  readonly type: "function";
@@ -1856,50 +1759,6 @@ export declare namespace start {
1856
1759
  readonly outputs: readonly [{
1857
1760
  readonly type: "uint256";
1858
1761
  }];
1859
- }, {
1860
- readonly name: "finalizeStreams";
1861
- readonly type: "function";
1862
- readonly stateMutability: "nonpayable";
1863
- readonly inputs: readonly [{
1864
- readonly type: "uint64";
1865
- readonly name: "timestamp";
1866
- }];
1867
- readonly outputs: readonly [];
1868
- }, {
1869
- readonly name: "getStream";
1870
- readonly type: "function";
1871
- readonly stateMutability: "view";
1872
- readonly inputs: readonly [{
1873
- readonly type: "uint64";
1874
- readonly name: "id";
1875
- }];
1876
- readonly outputs: readonly [{
1877
- readonly type: "tuple";
1878
- readonly components: readonly [{
1879
- readonly type: "address";
1880
- readonly name: "funder";
1881
- }, {
1882
- readonly type: "uint64";
1883
- readonly name: "startTime";
1884
- }, {
1885
- readonly type: "uint64";
1886
- readonly name: "endTime";
1887
- }, {
1888
- readonly type: "uint256";
1889
- readonly name: "ratePerSecondScaled";
1890
- }, {
1891
- readonly type: "uint256";
1892
- readonly name: "amountTotal";
1893
- }];
1894
- }];
1895
- }, {
1896
- readonly name: "totalRewardPerSecond";
1897
- readonly type: "function";
1898
- readonly stateMutability: "view";
1899
- readonly inputs: readonly [];
1900
- readonly outputs: readonly [{
1901
- readonly type: "uint256";
1902
- }];
1903
1762
  }, {
1904
1763
  readonly name: "optedInSupply";
1905
1764
  readonly type: "function";
@@ -1909,12 +1768,12 @@ export declare namespace start {
1909
1768
  readonly type: "uint128";
1910
1769
  }];
1911
1770
  }, {
1912
- readonly name: "nextStreamId";
1771
+ readonly name: "globalRewardPerToken";
1913
1772
  readonly type: "function";
1914
1773
  readonly stateMutability: "view";
1915
1774
  readonly inputs: readonly [];
1916
1775
  readonly outputs: readonly [{
1917
- readonly type: "uint64";
1776
+ readonly type: "uint256";
1918
1777
  }];
1919
1778
  }, {
1920
1779
  readonly name: "userRewardInfo";
@@ -1937,6 +1796,17 @@ export declare namespace start {
1937
1796
  readonly name: "rewardBalance";
1938
1797
  }];
1939
1798
  }];
1799
+ }, {
1800
+ readonly name: "getPendingRewards";
1801
+ readonly type: "function";
1802
+ readonly stateMutability: "view";
1803
+ readonly inputs: readonly [{
1804
+ readonly type: "address";
1805
+ readonly name: "account";
1806
+ }];
1807
+ readonly outputs: readonly [{
1808
+ readonly type: "uint128";
1809
+ }];
1940
1810
  }, {
1941
1811
  readonly name: "Transfer";
1942
1812
  readonly type: "event";
@@ -2079,37 +1949,15 @@ export declare namespace start {
2079
1949
  readonly indexed: true;
2080
1950
  }];
2081
1951
  }, {
2082
- readonly name: "RewardScheduled";
1952
+ readonly name: "RewardDistributed";
2083
1953
  readonly type: "event";
2084
1954
  readonly inputs: readonly [{
2085
1955
  readonly type: "address";
2086
1956
  readonly name: "funder";
2087
1957
  readonly indexed: true;
2088
- }, {
2089
- readonly type: "uint64";
2090
- readonly name: "id";
2091
- readonly indexed: true;
2092
1958
  }, {
2093
1959
  readonly type: "uint256";
2094
1960
  readonly name: "amount";
2095
- }, {
2096
- readonly type: "uint32";
2097
- readonly name: "durationSeconds";
2098
- }];
2099
- }, {
2100
- readonly name: "RewardCanceled";
2101
- readonly type: "event";
2102
- readonly inputs: readonly [{
2103
- readonly type: "address";
2104
- readonly name: "funder";
2105
- readonly indexed: true;
2106
- }, {
2107
- readonly type: "uint64";
2108
- readonly name: "id";
2109
- readonly indexed: true;
2110
- }, {
2111
- readonly type: "uint256";
2112
- readonly name: "refund";
2113
1961
  }];
2114
1962
  }, {
2115
1963
  readonly name: "RewardRecipientSet";
@@ -2123,18 +1971,6 @@ export declare namespace start {
2123
1971
  readonly name: "recipient";
2124
1972
  readonly indexed: true;
2125
1973
  }];
2126
- }, {
2127
- readonly name: "FeeRecipientUpdated";
2128
- readonly type: "event";
2129
- readonly inputs: readonly [{
2130
- readonly type: "address";
2131
- readonly name: "updater";
2132
- readonly indexed: true;
2133
- }, {
2134
- readonly type: "address";
2135
- readonly name: "newRecipient";
2136
- readonly indexed: true;
2137
- }];
2138
1974
  }, {
2139
1975
  readonly name: "InsufficientBalance";
2140
1976
  readonly type: "error";
@@ -2196,14 +2032,6 @@ export declare namespace start {
2196
2032
  readonly name: "InvalidAmount";
2197
2033
  readonly type: "error";
2198
2034
  readonly inputs: readonly [];
2199
- }, {
2200
- readonly name: "NotStreamFunder";
2201
- readonly type: "error";
2202
- readonly inputs: readonly [];
2203
- }, {
2204
- readonly name: "StreamInactive";
2205
- readonly type: "error";
2206
- readonly inputs: readonly [];
2207
2035
  }, {
2208
2036
  readonly name: "NoOptedInSupply";
2209
2037
  readonly type: "error";
@@ -2213,19 +2041,19 @@ export declare namespace start {
2213
2041
  readonly type: "error";
2214
2042
  readonly inputs: readonly [];
2215
2043
  }, {
2216
- readonly name: "RewardsDisabled";
2044
+ readonly name: "ProtectedAddress";
2217
2045
  readonly type: "error";
2218
2046
  readonly inputs: readonly [];
2219
2047
  }, {
2220
- readonly name: "ScheduledRewardsDisabled";
2048
+ readonly name: "InvalidToken";
2221
2049
  readonly type: "error";
2222
2050
  readonly inputs: readonly [];
2223
2051
  }, {
2224
- readonly name: "ProtectedAddress";
2052
+ readonly name: "Uninitialized";
2225
2053
  readonly type: "error";
2226
2054
  readonly inputs: readonly [];
2227
2055
  }, {
2228
- readonly name: "InvalidToken";
2056
+ readonly name: "InvalidTransferPolicyId";
2229
2057
  readonly type: "error";
2230
2058
  readonly inputs: readonly [];
2231
2059
  }, {
@@ -2337,26 +2165,22 @@ export declare namespace start {
2337
2165
  readonly name: "Unauthorized";
2338
2166
  readonly type: "error";
2339
2167
  readonly inputs: readonly [];
2340
- }], "RewardScheduled">;
2168
+ }], "RewardRecipientSet">;
2341
2169
  }
2342
- export declare namespace startSync {
2343
- type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = WriteParameters<chain, account> & start.Args;
2170
+ export declare namespace setRecipientSync {
2171
+ type Parameters<chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined> = WriteParameters<chain, account> & setRecipient.Args;
2344
2172
  type ReturnValue = {
2345
- /** The total amount allocated to the stream */
2346
- amount: bigint;
2347
- /** The duration of the stream in seconds (0 for immediate distributions) */
2348
- durationSeconds: number;
2349
- /** The address that funded the stream */
2350
- funder: Address;
2351
- /** The unique stream ID (0 for immediate distributions, >0 for streaming distributions) */
2352
- id: bigint;
2173
+ /** The token holder address who set their reward recipient */
2174
+ holder: Address;
2353
2175
  /** The transaction receipt */
2354
2176
  receipt: Awaited<ReturnType<typeof writeContractSync>>;
2177
+ /** The reward recipient address (zero address indicates opt-out) */
2178
+ recipient: Address;
2355
2179
  };
2356
- type ErrorType = start.ErrorType;
2180
+ type ErrorType = setRecipient.ErrorType;
2357
2181
  }
2358
2182
  /**
2359
- * Watches for reward scheduled events.
2183
+ * Watches for reward distributed events.
2360
2184
  *
2361
2185
  * @example
2362
2186
  * ```ts
@@ -2369,10 +2193,10 @@ export declare namespace startSync {
2369
2193
  * transport: http(),
2370
2194
  * })
2371
2195
  *
2372
- * const unwatch = Actions.reward.watchRewardScheduled(client, {
2196
+ * const unwatch = Actions.reward.watchRewardDistributed(client, {
2373
2197
  * token: '0x20c0000000000000000000000000000000000001',
2374
- * onRewardScheduled: (args, log) => {
2375
- * console.log('Reward scheduled:', args)
2198
+ * onRewardDistributed: (args, log) => {
2199
+ * console.log('Reward distributed:', args)
2376
2200
  * },
2377
2201
  * })
2378
2202
  * ```
@@ -2381,16 +2205,16 @@ export declare namespace startSync {
2381
2205
  * @param parameters - Parameters.
2382
2206
  * @returns A function to unsubscribe from the event.
2383
2207
  */
2384
- export declare function watchRewardScheduled<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: watchRewardScheduled.Parameters): WatchContractEventReturnType;
2385
- export declare namespace watchRewardScheduled {
2386
- type Args = GetEventArgs<typeof Abis.tip20, 'RewardScheduled', {
2208
+ export declare function watchRewardDistributed<chain extends Chain | undefined, account extends Account | undefined>(client: Client<Transport, chain, account>, parameters: watchRewardDistributed.Parameters): WatchContractEventReturnType;
2209
+ export declare namespace watchRewardDistributed {
2210
+ type Args = GetEventArgs<typeof Abis.tip20, 'RewardDistributed', {
2387
2211
  IndexedOnly: false;
2388
2212
  Required: true;
2389
2213
  }>;
2390
- type Log = viem_Log<bigint, number, false, ExtractAbiItem<typeof Abis.tip20, 'RewardScheduled'>, true>;
2391
- type Parameters = UnionOmit<WatchContractEventParameters<typeof Abis.tip20, 'RewardScheduled', true>, 'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'> & {
2392
- /** Callback to invoke when rewards are scheduled. */
2393
- onRewardScheduled: (args: Args, log: Log) => void;
2214
+ type Log = viem_Log<bigint, number, false, ExtractAbiItem<typeof Abis.tip20, 'RewardDistributed'>, true>;
2215
+ type Parameters = UnionOmit<WatchContractEventParameters<typeof Abis.tip20, 'RewardDistributed', true>, 'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'> & {
2216
+ /** Callback to invoke when rewards are distributed. */
2217
+ onRewardDistributed: (args: Args, log: Log) => void;
2394
2218
  /** The TIP20 token address */
2395
2219
  token: Address;
2396
2220
  };