viem 2.43.5 → 2.44.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.
- package/CHANGELOG.md +48 -0
- package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js +11 -1
- package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -1
- package/_cjs/actions/wallet/sendTransactionSync.js +1 -0
- package/_cjs/actions/wallet/sendTransactionSync.js.map +1 -1
- package/_cjs/chains/definitions/codex.js +47 -0
- package/_cjs/chains/definitions/codex.js.map +1 -0
- package/_cjs/chains/definitions/codexTestnet.js +47 -0
- package/_cjs/chains/definitions/codexTestnet.js.map +1 -0
- package/_cjs/chains/definitions/paseoPassetHub.js +26 -0
- package/_cjs/chains/definitions/paseoPassetHub.js.map +1 -0
- package/_cjs/chains/definitions/{tempoTestnet.js → tempoAndantino.js} +5 -5
- package/_cjs/chains/definitions/tempoAndantino.js.map +1 -0
- package/_cjs/chains/definitions/tempoDevnet.js +6 -0
- package/_cjs/chains/definitions/tempoDevnet.js.map +1 -1
- package/_cjs/chains/definitions/tempoModerato.js +28 -0
- package/_cjs/chains/definitions/tempoModerato.js.map +1 -0
- package/_cjs/chains/index.js +23 -14
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/tempo/Abis.js +610 -752
- package/_cjs/tempo/Abis.js.map +1 -1
- package/_cjs/tempo/Addresses.js +2 -2
- package/_cjs/tempo/Addresses.js.map +1 -1
- package/_cjs/tempo/Decorator.js +5 -5
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/actions/amm.js +4 -38
- package/_cjs/tempo/actions/amm.js.map +1 -1
- package/_cjs/tempo/actions/dex.js +98 -46
- package/_cjs/tempo/actions/dex.js.map +1 -1
- package/_cjs/tempo/actions/nonce.js +0 -35
- package/_cjs/tempo/actions/nonce.js.map +1 -1
- package/_cjs/tempo/actions/reward.js +81 -62
- package/_cjs/tempo/actions/reward.js.map +1 -1
- package/_cjs/tempo/actions/token.js +11 -2
- package/_cjs/tempo/actions/token.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +7 -6
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/index.js +2 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js +16 -2
- package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -1
- package/_esm/actions/wallet/sendTransactionSync.js +1 -0
- package/_esm/actions/wallet/sendTransactionSync.js.map +1 -1
- package/_esm/chains/definitions/codex.js +44 -0
- package/_esm/chains/definitions/codex.js.map +1 -0
- package/_esm/chains/definitions/codexTestnet.js +44 -0
- package/_esm/chains/definitions/codexTestnet.js.map +1 -0
- package/_esm/chains/definitions/paseoPassetHub.js +23 -0
- package/_esm/chains/definitions/paseoPassetHub.js.map +1 -0
- package/_esm/chains/definitions/{tempoTestnet.js → tempoAndantino.js} +4 -4
- package/_esm/chains/definitions/tempoAndantino.js.map +1 -0
- package/_esm/chains/definitions/tempoDevnet.js +6 -0
- package/_esm/chains/definitions/tempoDevnet.js.map +1 -1
- package/_esm/chains/definitions/tempoModerato.js +25 -0
- package/_esm/chains/definitions/tempoModerato.js.map +1 -0
- package/_esm/chains/index.js +9 -1
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/tempo/Abis.js +609 -751
- package/_esm/tempo/Abis.js.map +1 -1
- package/_esm/tempo/Addresses.js +1 -1
- package/_esm/tempo/Addresses.js.map +1 -1
- package/_esm/tempo/Decorator.js +5 -5
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/actions/amm.js +4 -62
- package/_esm/tempo/actions/amm.js.map +1 -1
- package/_esm/tempo/actions/dex.js +192 -48
- package/_esm/tempo/actions/dex.js.map +1 -1
- package/_esm/tempo/actions/nonce.js +0 -94
- package/_esm/tempo/actions/nonce.js.map +1 -1
- package/_esm/tempo/actions/reward.js +227 -189
- package/_esm/tempo/actions/reward.js.map +1 -1
- package/_esm/tempo/actions/token.js +11 -2
- package/_esm/tempo/actions/token.js.map +1 -1
- package/_esm/tempo/chainConfig.js +5 -3
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/index.js +1 -1
- package/_esm/tempo/index.js.map +1 -1
- package/_types/account-abstraction/utils/userOperation/toPackedUserOperation.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransactionSync.d.ts.map +1 -1
- package/_types/celo/chainConfig.d.ts +22 -22
- package/_types/celo/formatters.d.ts +11 -11
- package/_types/chains/definitions/abstract.d.ts +14 -14
- package/_types/chains/definitions/abstractTestnet.d.ts +14 -14
- package/_types/chains/definitions/ancient8.d.ts +3 -3
- package/_types/chains/definitions/ancient8Sepolia.d.ts +3 -3
- package/_types/chains/definitions/base.d.ts +6 -6
- package/_types/chains/definitions/baseGoerli.d.ts +3 -3
- package/_types/chains/definitions/baseSepolia.d.ts +6 -6
- package/_types/chains/definitions/blast.d.ts +3 -3
- package/_types/chains/definitions/bob.d.ts +3 -3
- package/_types/chains/definitions/bobSepolia.d.ts +3 -3
- package/_types/chains/definitions/celo.d.ts +22 -22
- package/_types/chains/definitions/celoAlfajores.d.ts +22 -22
- package/_types/chains/definitions/celoSepolia.d.ts +22 -22
- package/_types/chains/definitions/codex.d.ts +310 -0
- package/_types/chains/definitions/codex.d.ts.map +1 -0
- package/_types/chains/definitions/codexTestnet.d.ts +310 -0
- package/_types/chains/definitions/codexTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/dchain.d.ts +3 -3
- package/_types/chains/definitions/dchainTestnet.d.ts +3 -3
- package/_types/chains/definitions/elysiumTestnet.d.ts +3 -3
- package/_types/chains/definitions/fraxtal.d.ts +3 -3
- package/_types/chains/definitions/fraxtalTestnet.d.ts +3 -3
- package/_types/chains/definitions/funkiMainnet.d.ts +3 -3
- package/_types/chains/definitions/funkiSepolia.d.ts +3 -3
- package/_types/chains/definitions/garnet.d.ts +3 -3
- package/_types/chains/definitions/giwaSepolia.d.ts +6 -6
- package/_types/chains/definitions/ink.d.ts +3 -3
- package/_types/chains/definitions/inkSepolia.d.ts +3 -3
- package/_types/chains/definitions/lisk.d.ts +3 -3
- package/_types/chains/definitions/liskSepolia.d.ts +3 -3
- package/_types/chains/definitions/metalL2.d.ts +3 -3
- package/_types/chains/definitions/mode.d.ts +3 -3
- package/_types/chains/definitions/modeTestnet.d.ts +3 -3
- package/_types/chains/definitions/optimism.d.ts +3 -3
- package/_types/chains/definitions/optimismGoerli.d.ts +3 -3
- package/_types/chains/definitions/optimismSepolia.d.ts +3 -3
- package/_types/chains/definitions/paseoPassetHub.d.ts +48 -0
- package/_types/chains/definitions/paseoPassetHub.d.ts.map +1 -0
- package/_types/chains/definitions/pgn.d.ts +3 -3
- package/_types/chains/definitions/pgnTestnet.d.ts +3 -3
- package/_types/chains/definitions/playfiAlbireo.d.ts +14 -14
- package/_types/chains/definitions/pyrope.d.ts +3 -3
- package/_types/chains/definitions/redstone.d.ts +3 -3
- package/_types/chains/definitions/rss3.d.ts +3 -3
- package/_types/chains/definitions/rss3Sepolia.d.ts +3 -3
- package/_types/chains/definitions/shape.d.ts +3 -3
- package/_types/chains/definitions/shapeSepolia.d.ts +3 -3
- package/_types/chains/definitions/snax.d.ts +3 -3
- package/_types/chains/definitions/snaxTestnet.d.ts +3 -3
- package/_types/chains/definitions/soneium.d.ts +3 -3
- package/_types/chains/definitions/soneiumMinato.d.ts +3 -3
- package/_types/chains/definitions/sophon.d.ts +14 -14
- package/_types/chains/definitions/sophonTestnet.d.ts +14 -14
- package/_types/chains/definitions/superseed.d.ts +3 -3
- package/_types/chains/definitions/superseedSepolia.d.ts +3 -3
- package/_types/chains/definitions/swellchain.d.ts +3 -3
- package/_types/chains/definitions/swellchainTestnet.d.ts +3 -3
- package/_types/chains/definitions/{tempoTestnet.d.ts → tempoAndantino.d.ts} +34 -34
- package/_types/chains/definitions/tempoAndantino.d.ts.map +1 -0
- package/_types/chains/definitions/tempoDevnet.d.ts +39 -39
- package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoLocalnet.d.ts +28 -28
- package/_types/chains/definitions/tempoModerato.d.ts +916 -0
- package/_types/chains/definitions/{tempoTestnet.d.ts.map → tempoModerato.d.ts.map} +1 -1
- package/_types/chains/definitions/treasure.d.ts +14 -14
- package/_types/chains/definitions/treasureTopaz.d.ts +14 -14
- package/_types/chains/definitions/unichain.d.ts +3 -3
- package/_types/chains/definitions/unichainSepolia.d.ts +3 -3
- package/_types/chains/definitions/worldchain.d.ts +3 -3
- package/_types/chains/definitions/worldchainSepolia.d.ts +3 -3
- package/_types/chains/definitions/zircuit.d.ts +3 -3
- package/_types/chains/definitions/zircuitGarfieldTestnet.d.ts +3 -3
- package/_types/chains/definitions/zircuitTestnet.d.ts +3 -3
- package/_types/chains/definitions/zksync.d.ts +14 -14
- package/_types/chains/definitions/zksyncInMemoryNode.d.ts +14 -14
- package/_types/chains/definitions/zksyncLocalCustomHyperchain.d.ts +14 -14
- package/_types/chains/definitions/zksyncLocalHyperchain.d.ts +14 -14
- package/_types/chains/definitions/zksyncLocalNode.d.ts +14 -14
- package/_types/chains/definitions/zksyncSepoliaTestnet.d.ts +14 -14
- package/_types/chains/definitions/zora.d.ts +3 -3
- package/_types/chains/definitions/zoraSepolia.d.ts +3 -3
- package/_types/chains/definitions/zoraTestnet.d.ts +3 -3
- package/_types/chains/index.d.ts +9 -1
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +2 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/op-stack/chainConfig.d.ts +3 -3
- package/_types/op-stack/formatters.d.ts +3 -3
- package/_types/tempo/Abis.d.ts +937 -1194
- package/_types/tempo/Abis.d.ts.map +1 -1
- package/_types/tempo/Addresses.d.ts +1 -1
- package/_types/tempo/Addresses.d.ts.map +1 -1
- package/_types/tempo/Decorator.d.ts +91 -85
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/actions/amm.d.ts +19 -360
- package/_types/tempo/actions/amm.d.ts.map +1 -1
- package/_types/tempo/actions/dex.d.ts +765 -237
- package/_types/tempo/actions/dex.d.ts.map +1 -1
- package/_types/tempo/actions/fee.d.ts +30 -11
- package/_types/tempo/actions/fee.d.ts.map +1 -1
- package/_types/tempo/actions/nonce.d.ts +0 -105
- package/_types/tempo/actions/nonce.d.ts.map +1 -1
- package/_types/tempo/actions/policy.d.ts +60 -0
- package/_types/tempo/actions/policy.d.ts.map +1 -1
- package/_types/tempo/actions/reward.d.ts +350 -526
- package/_types/tempo/actions/reward.d.ts.map +1 -1
- package/_types/tempo/actions/token.d.ts +368 -1984
- package/_types/tempo/actions/token.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts +15 -16
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +1 -1
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/tempo/internal/types.d.ts +1 -1
- package/_types/tempo/internal/types.d.ts.map +1 -1
- package/_types/utils/formatters/transaction.d.ts +1 -1
- package/_types/utils/formatters/transactionRequest.d.ts +1 -1
- package/_types/zksync/chainConfig.d.ts +14 -14
- package/_types/zksync/formatters.d.ts +14 -14
- package/account-abstraction/utils/userOperation/toPackedUserOperation.ts +17 -2
- package/actions/wallet/sendTransactionSync.ts +1 -0
- package/chains/definitions/codex.ts +45 -0
- package/chains/definitions/codexTestnet.ts +45 -0
- package/chains/definitions/paseoPassetHub.ts +23 -0
- package/chains/definitions/{tempoTestnet.ts → tempoAndantino.ts} +3 -3
- package/chains/definitions/tempoDevnet.ts +6 -0
- package/chains/definitions/tempoModerato.ts +25 -0
- package/chains/index.ts +10 -1
- package/errors/version.ts +1 -1
- package/index.ts +9 -0
- package/package.json +2 -2
- package/tempo/Abis.ts +607 -752
- package/tempo/Addresses.ts +1 -1
- package/tempo/Decorator.ts +115 -106
- package/tempo/actions/amm.ts +13 -115
- package/tempo/actions/dex.ts +274 -72
- package/tempo/actions/nonce.ts +0 -148
- package/tempo/actions/reward.ts +310 -257
- package/tempo/actions/token.ts +16 -2
- package/tempo/chainConfig.ts +7 -4
- package/tempo/index.ts +1 -1
- package/tempo/internal/types.ts +6 -1
- package/_cjs/chains/definitions/tempoTestnet.js.map +0 -1
- package/_esm/chains/definitions/tempoTestnet.js.map +0 -1
|
@@ -148,11 +148,163 @@ export async function claimSync(client, parameters) {
|
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
|
-
*
|
|
151
|
+
* Distributes rewards to opted-in token holders.
|
|
152
152
|
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
153
|
+
* This function transfers `amount` of tokens from the caller into the token contract's
|
|
154
|
+
* reward pool and immediately distributes them to current opted-in holders by increasing
|
|
155
|
+
* `globalRewardPerToken`.
|
|
156
|
+
*
|
|
157
|
+
* Notes:
|
|
158
|
+
* - Reverts with `InvalidAmount` if `amount == 0`.
|
|
159
|
+
* - The transfer from caller to pool is subject to TIP-403 policy checks.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* import { createClient, http } from 'viem'
|
|
164
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
165
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
166
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
167
|
+
*
|
|
168
|
+
* const client = createClient({
|
|
169
|
+
* account: privateKeyToAccount('0x...'),
|
|
170
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
171
|
+
* transport: http(),
|
|
172
|
+
* })
|
|
173
|
+
*
|
|
174
|
+
* const hash = await Actions.reward.distribute(client, {
|
|
175
|
+
* amount: 100000000000000000000n,
|
|
176
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
177
|
+
* })
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @param client - Client.
|
|
181
|
+
* @param parameters - Parameters.
|
|
182
|
+
* @returns The transaction hash.
|
|
183
|
+
*/
|
|
184
|
+
export async function distribute(client, parameters) {
|
|
185
|
+
return distribute.inner(writeContract, client, parameters);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Distributes rewards to opted-in token holders and waits for confirmation.
|
|
189
|
+
*
|
|
190
|
+
* This function transfers `amount` of tokens from the caller into the token contract's
|
|
191
|
+
* reward pool and immediately distributes them to current opted-in holders by increasing
|
|
192
|
+
* `globalRewardPerToken`.
|
|
193
|
+
*
|
|
194
|
+
* Notes:
|
|
195
|
+
* - Reverts with `InvalidAmount` if `amount == 0`.
|
|
196
|
+
* - The transfer from caller to pool is subject to TIP-403 policy checks.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* import { createClient, http } from 'viem'
|
|
201
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
202
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
203
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
204
|
+
*
|
|
205
|
+
* const client = createClient({
|
|
206
|
+
* account: privateKeyToAccount('0x...'),
|
|
207
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
208
|
+
* transport: http(),
|
|
209
|
+
* })
|
|
210
|
+
*
|
|
211
|
+
* const { amount, funder, receipt } = await Actions.reward.distributeSync(client, {
|
|
212
|
+
* amount: 100000000000000000000n,
|
|
213
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
214
|
+
* })
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* @param client - Client.
|
|
218
|
+
* @param parameters - Parameters.
|
|
219
|
+
* @returns The funder, amount, and transaction receipt.
|
|
220
|
+
*/
|
|
221
|
+
export async function distributeSync(client, parameters) {
|
|
222
|
+
const { throwOnReceiptRevert = true, ...rest } = parameters;
|
|
223
|
+
const receipt = await distribute.inner(writeContractSync, client, {
|
|
224
|
+
...rest,
|
|
225
|
+
throwOnReceiptRevert,
|
|
226
|
+
});
|
|
227
|
+
const { args } = distribute.extractEvent(receipt.logs);
|
|
228
|
+
return {
|
|
229
|
+
...args,
|
|
230
|
+
receipt,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
(function (distribute) {
|
|
234
|
+
/** @internal */
|
|
235
|
+
async function inner(action, client, parameters) {
|
|
236
|
+
const { amount, token, ...rest } = parameters;
|
|
237
|
+
const call = distribute.call({ amount, token });
|
|
238
|
+
return (await action(client, {
|
|
239
|
+
...rest,
|
|
240
|
+
...call,
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
distribute.inner = inner;
|
|
244
|
+
/**
|
|
245
|
+
* Defines a call to the `distributeReward` function.
|
|
246
|
+
*
|
|
247
|
+
* Can be passed as a parameter to:
|
|
248
|
+
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
249
|
+
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
|
|
250
|
+
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* import { createClient, http, walletActions } from 'viem'
|
|
255
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
256
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
257
|
+
*
|
|
258
|
+
* const client = createClient({
|
|
259
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
260
|
+
* transport: http(),
|
|
261
|
+
* }).extend(walletActions)
|
|
262
|
+
*
|
|
263
|
+
* const hash = await client.sendTransaction({
|
|
264
|
+
* calls: [actions.reward.distribute.call({
|
|
265
|
+
* amount: 100000000000000000000n,
|
|
266
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
267
|
+
* })],
|
|
268
|
+
* })
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* @param args - Arguments.
|
|
272
|
+
* @returns The call.
|
|
273
|
+
*/
|
|
274
|
+
function call(args) {
|
|
275
|
+
const { amount, token } = args;
|
|
276
|
+
return defineCall({
|
|
277
|
+
address: token,
|
|
278
|
+
abi: Abis.tip20,
|
|
279
|
+
args: [amount],
|
|
280
|
+
functionName: 'distributeReward',
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
distribute.call = call;
|
|
284
|
+
/**
|
|
285
|
+
* Extracts the `RewardDistributed` event from logs.
|
|
286
|
+
*
|
|
287
|
+
* @param logs - The logs.
|
|
288
|
+
* @returns The `RewardDistributed` event.
|
|
289
|
+
*/
|
|
290
|
+
function extractEvent(logs) {
|
|
291
|
+
const [log] = parseEventLogs({
|
|
292
|
+
abi: Abis.tip20,
|
|
293
|
+
logs,
|
|
294
|
+
eventName: 'RewardDistributed',
|
|
295
|
+
strict: true,
|
|
296
|
+
});
|
|
297
|
+
if (!log)
|
|
298
|
+
throw new Error('`RewardDistributed` event not found.');
|
|
299
|
+
return log;
|
|
300
|
+
}
|
|
301
|
+
distribute.extractEvent = extractEvent;
|
|
302
|
+
})(distribute || (distribute = {}));
|
|
303
|
+
/**
|
|
304
|
+
* Gets the global reward per token value.
|
|
305
|
+
*
|
|
306
|
+
* Returns the current global reward per token value scaled by `ACC_PRECISION` (1e18).
|
|
307
|
+
* This value increases each time rewards are distributed.
|
|
156
308
|
*
|
|
157
309
|
* @example
|
|
158
310
|
* ```ts
|
|
@@ -165,24 +317,24 @@ export async function claimSync(client, parameters) {
|
|
|
165
317
|
* transport: http(),
|
|
166
318
|
* })
|
|
167
319
|
*
|
|
168
|
-
* const
|
|
320
|
+
* const rewardPerToken = await Actions.reward.getGlobalRewardPerToken(client, {
|
|
169
321
|
* token: '0x20c0000000000000000000000000000000000001',
|
|
170
322
|
* })
|
|
171
323
|
* ```
|
|
172
324
|
*
|
|
173
325
|
* @param client - Client.
|
|
174
326
|
* @param parameters - Parameters.
|
|
175
|
-
* @returns The
|
|
327
|
+
* @returns The global reward per token (scaled by 1e18).
|
|
176
328
|
*/
|
|
177
|
-
export async function
|
|
329
|
+
export async function getGlobalRewardPerToken(client, parameters) {
|
|
178
330
|
return readContract(client, {
|
|
179
331
|
...parameters,
|
|
180
|
-
...
|
|
332
|
+
...getGlobalRewardPerToken.call(parameters),
|
|
181
333
|
});
|
|
182
334
|
}
|
|
183
|
-
(function (
|
|
335
|
+
(function (getGlobalRewardPerToken) {
|
|
184
336
|
/**
|
|
185
|
-
* Defines a call to the `
|
|
337
|
+
* Defines a call to the `globalRewardPerToken` function.
|
|
186
338
|
*
|
|
187
339
|
* @param args - Arguments.
|
|
188
340
|
* @returns The call.
|
|
@@ -193,11 +345,61 @@ export async function getTotalPerSecond(client, parameters) {
|
|
|
193
345
|
address: token,
|
|
194
346
|
abi: Abis.tip20,
|
|
195
347
|
args: [],
|
|
196
|
-
functionName: '
|
|
348
|
+
functionName: 'globalRewardPerToken',
|
|
197
349
|
});
|
|
198
350
|
}
|
|
199
|
-
|
|
200
|
-
})(
|
|
351
|
+
getGlobalRewardPerToken.call = call;
|
|
352
|
+
})(getGlobalRewardPerToken || (getGlobalRewardPerToken = {}));
|
|
353
|
+
/**
|
|
354
|
+
* Calculates the pending claimable rewards for an account without modifying state.
|
|
355
|
+
*
|
|
356
|
+
* Returns the total pending claimable reward amount, including stored balance and newly accrued rewards.
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```ts
|
|
360
|
+
* import { createClient, http } from 'viem'
|
|
361
|
+
* import { tempo } from 'tempo.ts/chains'
|
|
362
|
+
* import { Actions } from 'tempo.ts/viem'
|
|
363
|
+
*
|
|
364
|
+
* const client = createClient({
|
|
365
|
+
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
366
|
+
* transport: http(),
|
|
367
|
+
* })
|
|
368
|
+
*
|
|
369
|
+
* const pending = await Actions.reward.getPendingRewards(client, {
|
|
370
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
371
|
+
* account: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
|
|
372
|
+
* })
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* @param client - Client.
|
|
376
|
+
* @param parameters - Parameters.
|
|
377
|
+
* @returns The total pending claimable reward amount.
|
|
378
|
+
*/
|
|
379
|
+
export async function getPendingRewards(client, parameters) {
|
|
380
|
+
return readContract(client, {
|
|
381
|
+
...parameters,
|
|
382
|
+
...getPendingRewards.call(parameters),
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
(function (getPendingRewards) {
|
|
386
|
+
/**
|
|
387
|
+
* Defines a call to the `getPendingRewards` function.
|
|
388
|
+
*
|
|
389
|
+
* @param args - Arguments.
|
|
390
|
+
* @returns The call.
|
|
391
|
+
*/
|
|
392
|
+
function call(args) {
|
|
393
|
+
const { account, token } = args;
|
|
394
|
+
return defineCall({
|
|
395
|
+
address: token,
|
|
396
|
+
abi: Abis.tip20,
|
|
397
|
+
args: [account],
|
|
398
|
+
functionName: 'getPendingRewards',
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
getPendingRewards.call = call;
|
|
402
|
+
})(getPendingRewards || (getPendingRewards = {}));
|
|
201
403
|
/**
|
|
202
404
|
* Gets the reward information for a specific account.
|
|
203
405
|
*
|
|
@@ -277,7 +479,7 @@ export async function getUserRewardInfo(client, parameters) {
|
|
|
277
479
|
* transport: http(),
|
|
278
480
|
* })
|
|
279
481
|
*
|
|
280
|
-
* const hash = await Actions.
|
|
482
|
+
* const hash = await Actions.reward.setRecipient(client, {
|
|
281
483
|
* recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
|
|
282
484
|
* token: '0x20c0000000000000000000000000000000000001',
|
|
283
485
|
* })
|
|
@@ -315,7 +517,7 @@ export async function setRecipient(client, parameters) {
|
|
|
315
517
|
* transport: http(),
|
|
316
518
|
* })
|
|
317
519
|
*
|
|
318
|
-
* const { holder, recipient, receipt } = await Actions.
|
|
520
|
+
* const { holder, recipient, receipt } = await Actions.reward.setRecipientSync(client, {
|
|
319
521
|
* recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
|
|
320
522
|
* token: '0x20c0000000000000000000000000000000000001',
|
|
321
523
|
* })
|
|
@@ -349,7 +551,7 @@ export async function setRecipientSync(client, parameters) {
|
|
|
349
551
|
}
|
|
350
552
|
setRecipient.inner = inner;
|
|
351
553
|
/**
|
|
352
|
-
* Defines a call to the `
|
|
554
|
+
* Defines a call to the `setRewardRecipient` function.
|
|
353
555
|
*
|
|
354
556
|
* Can be passed as a parameter to:
|
|
355
557
|
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
@@ -368,7 +570,7 @@ export async function setRecipientSync(client, parameters) {
|
|
|
368
570
|
* }).extend(walletActions)
|
|
369
571
|
*
|
|
370
572
|
* const hash = await client.sendTransaction({
|
|
371
|
-
* calls: [actions.
|
|
573
|
+
* calls: [actions.reward.setRecipient.call({
|
|
372
574
|
* recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
|
|
373
575
|
* token: '0x20c0000000000000000000000000000000000001',
|
|
374
576
|
* })],
|
|
@@ -408,171 +610,7 @@ export async function setRecipientSync(client, parameters) {
|
|
|
408
610
|
setRecipient.extractEvent = extractEvent;
|
|
409
611
|
})(setRecipient || (setRecipient = {}));
|
|
410
612
|
/**
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
* Behavior:
|
|
414
|
-
* - Transfers `amount` of tokens from the caller into the token contract's reward pool.
|
|
415
|
-
* - If `seconds == 0`: Immediately distributes `amount` to current opted-in holders by increasing `rewardPerTokenStored`.
|
|
416
|
-
* Returns stream ID `0`. Distribution occurs when holders interact with the token (transfers, etc.).
|
|
417
|
-
* - If `seconds > 0`: Starts a linear stream that emits evenly from `block.timestamp` to `block.timestamp + seconds`.
|
|
418
|
-
* Returns a unique stream ID for later cancellation.
|
|
419
|
-
*
|
|
420
|
-
* Notes:
|
|
421
|
-
* - Reverts with `InvalidAmount` if `amount == 0`.
|
|
422
|
-
* - Allowed even when `optedInSupply == 0` (tokens distributed while no one is opted in are locked permanently).
|
|
423
|
-
* - The transfer from caller to pool is subject to TIP-403 policy checks.
|
|
424
|
-
*
|
|
425
|
-
* @example
|
|
426
|
-
* ```ts
|
|
427
|
-
* import { createClient, http } from 'viem'
|
|
428
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
429
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
430
|
-
* import { privateKeyToAccount } from 'viem/accounts'
|
|
431
|
-
*
|
|
432
|
-
* const client = createClient({
|
|
433
|
-
* account: privateKeyToAccount('0x...'),
|
|
434
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
435
|
-
* transport: http(),
|
|
436
|
-
* })
|
|
437
|
-
*
|
|
438
|
-
* const hash = await Actions.rewards.start(client, {
|
|
439
|
-
* amount: 100000000000000000000n,
|
|
440
|
-
* seconds: 86400,
|
|
441
|
-
* token: '0x20c0000000000000000000000000000000000001',
|
|
442
|
-
* })
|
|
443
|
-
* ```
|
|
444
|
-
*
|
|
445
|
-
* @param client - Client.
|
|
446
|
-
* @param parameters - Parameters.
|
|
447
|
-
* @returns The transaction hash.
|
|
448
|
-
*/
|
|
449
|
-
export async function start(client, parameters) {
|
|
450
|
-
return start.inner(writeContract, client, parameters);
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Starts a new reward stream that distributes tokens to opted-in holders and waits for confirmation.
|
|
454
|
-
*
|
|
455
|
-
* Behavior:
|
|
456
|
-
* - Transfers `amount` of tokens from the caller into the token contract's reward pool.
|
|
457
|
-
* - If `seconds == 0`: Immediately distributes `amount` to current opted-in holders by increasing `rewardPerTokenStored`.
|
|
458
|
-
* Returns stream ID `0`. Distribution occurs when holders interact with the token (transfers, etc.).
|
|
459
|
-
* - If `seconds > 0`: Starts a linear stream that emits evenly from `block.timestamp` to `block.timestamp + seconds`.
|
|
460
|
-
* Returns a unique stream ID for later cancellation.
|
|
461
|
-
*
|
|
462
|
-
* Notes:
|
|
463
|
-
* - Reverts with `InvalidAmount` if `amount == 0`.
|
|
464
|
-
* - Allowed even when `optedInSupply == 0` (tokens distributed while no one is opted in are locked permanently).
|
|
465
|
-
* - The transfer from caller to pool is subject to TIP-403 policy checks.
|
|
466
|
-
*
|
|
467
|
-
* @example
|
|
468
|
-
* ```ts
|
|
469
|
-
* import { createClient, http } from 'viem'
|
|
470
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
471
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
472
|
-
* import { privateKeyToAccount } from 'viem/accounts'
|
|
473
|
-
*
|
|
474
|
-
* const client = createClient({
|
|
475
|
-
* account: privateKeyToAccount('0x...'),
|
|
476
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
477
|
-
* transport: http(),
|
|
478
|
-
* })
|
|
479
|
-
*
|
|
480
|
-
* const { id, receipt } = await Actions.rewards.startSync(client, {
|
|
481
|
-
* amount: 100000000000000000000n,
|
|
482
|
-
* seconds: 86400,
|
|
483
|
-
* token: '0x20c0000000000000000000000000000000000001',
|
|
484
|
-
* })
|
|
485
|
-
* ```
|
|
486
|
-
*
|
|
487
|
-
* @param client - Client.
|
|
488
|
-
* @param parameters - Parameters.
|
|
489
|
-
* @returns The stream ID, funder, amount, duration, and transaction receipt.
|
|
490
|
-
*/
|
|
491
|
-
export async function startSync(client, parameters) {
|
|
492
|
-
const { throwOnReceiptRevert = true, ...rest } = parameters;
|
|
493
|
-
const receipt = await start.inner(writeContractSync, client, {
|
|
494
|
-
...rest,
|
|
495
|
-
throwOnReceiptRevert,
|
|
496
|
-
});
|
|
497
|
-
const { args } = start.extractEvent(receipt.logs);
|
|
498
|
-
return {
|
|
499
|
-
...args,
|
|
500
|
-
receipt,
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
(function (start) {
|
|
504
|
-
/** @internal */
|
|
505
|
-
async function inner(action, client, parameters) {
|
|
506
|
-
const { amount, token, ...rest } = parameters;
|
|
507
|
-
const call = start.call({ amount, token });
|
|
508
|
-
return (await action(client, {
|
|
509
|
-
...rest,
|
|
510
|
-
...call,
|
|
511
|
-
}));
|
|
512
|
-
}
|
|
513
|
-
start.inner = inner;
|
|
514
|
-
/**
|
|
515
|
-
* Defines a call to the `start` function.
|
|
516
|
-
*
|
|
517
|
-
* Can be passed as a parameter to:
|
|
518
|
-
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
519
|
-
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
|
|
520
|
-
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
|
|
521
|
-
*
|
|
522
|
-
* @example
|
|
523
|
-
* ```ts
|
|
524
|
-
* import { createClient, http, walletActions } from 'viem'
|
|
525
|
-
* import { tempo } from 'tempo.ts/chains'
|
|
526
|
-
* import { Actions } from 'tempo.ts/viem'
|
|
527
|
-
*
|
|
528
|
-
* const client = createClient({
|
|
529
|
-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
530
|
-
* transport: http(),
|
|
531
|
-
* }).extend(walletActions)
|
|
532
|
-
*
|
|
533
|
-
* const hash = await client.sendTransaction({
|
|
534
|
-
* calls: [actions.rewards.start.call({
|
|
535
|
-
* amount: 100000000000000000000n,
|
|
536
|
-
* seconds: 86400,
|
|
537
|
-
* token: '0x20c0000000000000000000000000000000000001',
|
|
538
|
-
* })],
|
|
539
|
-
* })
|
|
540
|
-
* ```
|
|
541
|
-
*
|
|
542
|
-
* @param args - Arguments.
|
|
543
|
-
* @returns The call.
|
|
544
|
-
*/
|
|
545
|
-
function call(args) {
|
|
546
|
-
const { amount, token } = args;
|
|
547
|
-
return defineCall({
|
|
548
|
-
address: token,
|
|
549
|
-
abi: Abis.tip20,
|
|
550
|
-
args: [amount, 0],
|
|
551
|
-
functionName: 'startReward',
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
start.call = call;
|
|
555
|
-
/**
|
|
556
|
-
* Extracts the `RewardScheduled` event from logs.
|
|
557
|
-
*
|
|
558
|
-
* @param logs - The logs.
|
|
559
|
-
* @returns The `RewardScheduled` event.
|
|
560
|
-
*/
|
|
561
|
-
function extractEvent(logs) {
|
|
562
|
-
const [log] = parseEventLogs({
|
|
563
|
-
abi: Abis.tip20,
|
|
564
|
-
logs,
|
|
565
|
-
eventName: 'RewardScheduled',
|
|
566
|
-
strict: true,
|
|
567
|
-
});
|
|
568
|
-
if (!log)
|
|
569
|
-
throw new Error('`RewardScheduled` event not found.');
|
|
570
|
-
return log;
|
|
571
|
-
}
|
|
572
|
-
start.extractEvent = extractEvent;
|
|
573
|
-
})(start || (start = {}));
|
|
574
|
-
/**
|
|
575
|
-
* Watches for reward scheduled events.
|
|
613
|
+
* Watches for reward distributed events.
|
|
576
614
|
*
|
|
577
615
|
* @example
|
|
578
616
|
* ```ts
|
|
@@ -585,10 +623,10 @@ export async function startSync(client, parameters) {
|
|
|
585
623
|
* transport: http(),
|
|
586
624
|
* })
|
|
587
625
|
*
|
|
588
|
-
* const unwatch = Actions.reward.
|
|
626
|
+
* const unwatch = Actions.reward.watchRewardDistributed(client, {
|
|
589
627
|
* token: '0x20c0000000000000000000000000000000000001',
|
|
590
|
-
*
|
|
591
|
-
* console.log('Reward
|
|
628
|
+
* onRewardDistributed: (args, log) => {
|
|
629
|
+
* console.log('Reward distributed:', args)
|
|
592
630
|
* },
|
|
593
631
|
* })
|
|
594
632
|
* ```
|
|
@@ -597,16 +635,16 @@ export async function startSync(client, parameters) {
|
|
|
597
635
|
* @param parameters - Parameters.
|
|
598
636
|
* @returns A function to unsubscribe from the event.
|
|
599
637
|
*/
|
|
600
|
-
export function
|
|
601
|
-
const {
|
|
638
|
+
export function watchRewardDistributed(client, parameters) {
|
|
639
|
+
const { onRewardDistributed, token, ...rest } = parameters;
|
|
602
640
|
return watchContractEvent(client, {
|
|
603
641
|
...rest,
|
|
604
642
|
address: token,
|
|
605
643
|
abi: Abis.tip20,
|
|
606
|
-
eventName: '
|
|
644
|
+
eventName: 'RewardDistributed',
|
|
607
645
|
onLogs: (logs) => {
|
|
608
646
|
for (const log of logs)
|
|
609
|
-
|
|
647
|
+
onRewardDistributed(log.args, log);
|
|
610
648
|
},
|
|
611
649
|
strict: true,
|
|
612
650
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reward.js","sourceRoot":"","sources":["../../../tempo/actions/reward.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAKnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAA;AAE/E,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAQ7E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAClE,OAAO,KAAK,IAAI,MAAM,YAAY,CAAA;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAIzB,MAAyC,EACzC,UAA4C;IAE5C,OAAO,KAAK,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,CAAC,CAAA;AACvD,CAAC;AAED,WAAiB,KAAK;IAgBpB,gBAAgB;IACT,KAAK,UAAU,KAAK,CAKzB,MAAc,EACd,MAAyC,EACzC,UAAsC;QAEtC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,UAAU,CAAA;QACrC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;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AC;QACD,MAAM,EAAE,IAAI;KACb,CAAC,CAAA;AACJ,CAAC;AA8BD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,uBAAuB,CAIrC,MAAyC,EACzC,UAA8C;IAE9C,MAAM,EAAE,oBAAoB,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,UAAU,CAAA;IAC3D,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,GAAG,IAAI;QACP,OAAO,EAAE,KAAK;QACd,GAAG,EAAE,IAAI,CAAC,KAAK;QACf,SAAS,EAAE,oBAAoB;QAC/B,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACf,KAAK,MAAM,GAAG,IAAI,IAAI;gBAAE,oBAAoB,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QAC7D,CAAC;QACD,MAAM,EAAE,IAAI;KACb,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -649,11 +649,18 @@ export async function create(client, parameters) {
|
|
|
649
649
|
* @returns The call.
|
|
650
650
|
*/
|
|
651
651
|
function call(args) {
|
|
652
|
-
const { name, symbol, currency, quoteToken = Addresses.pathUsd, admin, } = args;
|
|
652
|
+
const { name, symbol, currency, quoteToken = Addresses.pathUsd, admin, salt = Hex.random(32), } = args;
|
|
653
653
|
return defineCall({
|
|
654
654
|
address: Addresses.tip20Factory,
|
|
655
655
|
abi: Abis.tip20Factory,
|
|
656
|
-
args: [
|
|
656
|
+
args: [
|
|
657
|
+
name,
|
|
658
|
+
symbol,
|
|
659
|
+
currency,
|
|
660
|
+
TokenId.toAddress(quoteToken),
|
|
661
|
+
admin,
|
|
662
|
+
salt,
|
|
663
|
+
],
|
|
657
664
|
functionName: 'createToken',
|
|
658
665
|
});
|
|
659
666
|
}
|
|
@@ -711,9 +718,11 @@ export async function createSync(client, parameters) {
|
|
|
711
718
|
throwOnReceiptRevert,
|
|
712
719
|
});
|
|
713
720
|
const { args } = create.extractEvent(receipt.logs);
|
|
721
|
+
const tokenId = TokenId.fromAddress(args.token);
|
|
714
722
|
return {
|
|
715
723
|
...args,
|
|
716
724
|
receipt,
|
|
725
|
+
tokenId,
|
|
717
726
|
};
|
|
718
727
|
}
|
|
719
728
|
/**
|