@boostxyz/sdk 0.0.0-alpha.7 → 0.0.0-alpha.9
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/dist/Actions/Action.cjs +1 -1
- package/dist/Actions/Action.js +1 -1
- package/dist/Actions/ContractAction.d.ts +46 -3
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +37 -10
- package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +257 -11
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +249 -82
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.d.ts +2 -2
- package/dist/AllowLists/AllowList.js +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +33 -4
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +52 -37
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs.map +1 -1
- package/dist/AllowLists/SimpleDenyList.d.ts +31 -2
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +41 -129
- package/dist/AllowLists/SimpleDenyList.js.map +1 -1
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.cjs.map +1 -1
- package/dist/Auth/PassthroughAuth.js +4 -4
- package/dist/Auth/PassthroughAuth.js.map +1 -1
- package/dist/Boost.cjs +1 -1
- package/dist/Boost.cjs.map +1 -1
- package/dist/Boost.d.ts +93 -1
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +151 -5
- package/dist/Boost.js.map +1 -1
- package/dist/BoostCore.cjs +2 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +45 -7
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +352 -305
- package/dist/BoostCore.js.map +1 -1
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.cjs.map +1 -1
- package/dist/BoostRegistry.d.ts +18 -4
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +36 -25
- package/dist/BoostRegistry.js.map +1 -1
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.js +1 -1
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +40 -2
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +53 -36
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/SimpleBudget.d.ts +33 -2
- package/dist/Budgets/SimpleBudget.d.ts.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +54 -2
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/Contract.cjs +1 -1
- package/dist/Deployable/Contract.cjs.map +1 -1
- package/dist/Deployable/Contract.js +1 -1
- package/dist/Deployable/Contract.js.map +1 -1
- package/dist/Deployable/Deployable.cjs.map +1 -1
- package/dist/Deployable/Deployable.d.ts +8 -2
- package/dist/Deployable/Deployable.d.ts.map +1 -1
- package/dist/Deployable/Deployable.js +6 -0
- package/dist/Deployable/Deployable.js.map +1 -1
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.cjs.map +1 -1
- package/dist/Deployable/DeployableTarget.d.ts +4 -3
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.js +31 -28
- package/dist/Deployable/DeployableTarget.js.map +1 -1
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts +35 -5
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +33 -21
- package/dist/Incentives/AllowListIncentive.js.map +1 -1
- package/dist/Incentives/CGDAIncentive.cjs +1 -1
- package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
- package/dist/Incentives/CGDAIncentive.d.ts +89 -5
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +44 -23
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +67 -6
- package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
- package/dist/Incentives/ERC20Incentive.d.ts +49 -5
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +46 -27
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/Incentives/ERC20VariableIncentive.d.ts +42 -5
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.cjs.map +1 -1
- package/dist/Incentives/Incentive.js +48 -32
- package/dist/Incentives/Incentive.js.map +1 -1
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -1
- package/dist/Incentives/PointsIncentive.d.ts +49 -5
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +38 -21
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts +298 -5
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +151 -26
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.js +1 -1
- package/dist/claiming.cjs +2 -0
- package/dist/claiming.cjs.map +1 -0
- package/dist/claiming.d.ts +43 -0
- package/dist/claiming.d.ts.map +1 -0
- package/dist/claiming.js +17 -0
- package/dist/claiming.js.map +1 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +15 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +30 -21
- package/dist/errors.js.map +1 -1
- package/dist/{generated-DGpIVcv5.js → generated-57_Kffpz.js} +293 -282
- package/dist/generated-57_Kffpz.js.map +1 -0
- package/dist/{generated-Cd-Fe7W7.cjs → generated-wKBNvm48.cjs} +3 -3
- package/dist/generated-wKBNvm48.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -124
- package/dist/transfers.cjs +2 -0
- package/dist/transfers.cjs.map +1 -0
- package/dist/transfers.d.ts +198 -0
- package/dist/transfers.d.ts.map +1 -0
- package/dist/transfers.js +84 -0
- package/dist/transfers.js.map +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +2 -1371
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +26 -653
- package/dist/utils.js.map +1 -1
- package/package.json +17 -3
- package/src/Actions/Action.test.ts +5 -4
- package/src/Actions/ContractAction.test.ts +4 -6
- package/src/Actions/ContractAction.ts +73 -10
- package/src/Actions/ERC721MintAction.test.ts +2 -2
- package/src/Actions/ERC721MintAction.ts +70 -16
- package/src/Actions/EventAction.test.ts +43 -17
- package/src/Actions/EventAction.ts +451 -26
- package/src/AllowLists/SimpleAllowList.ts +51 -7
- package/src/AllowLists/SimpleDenyList.ts +47 -109
- package/src/Auth/PassthroughAuth.ts +1 -1
- package/src/Boost.ts +136 -1
- package/src/BoostCore.test.ts +4 -11
- package/src/BoostCore.ts +114 -45
- package/src/BoostRegistry.ts +39 -21
- package/src/Budgets/ManagedBudget.ts +69 -16
- package/src/Budgets/SimpleBudget.ts +57 -14
- package/src/Budgets/VestingBudget.ts +79 -9
- package/src/Deployable/Contract.ts +1 -1
- package/src/Deployable/Deployable.ts +8 -2
- package/src/Deployable/DeployableTarget.ts +19 -6
- package/src/Incentives/AllowListIncentive.test.ts +2 -5
- package/src/Incentives/AllowListIncentive.ts +59 -15
- package/src/Incentives/CGDAIncentive.test.ts +3 -7
- package/src/Incentives/CGDAIncentive.ts +123 -19
- package/src/Incentives/ERC1155Incentive.test.ts +2 -13
- package/src/Incentives/ERC1155Incentive.ts +104 -22
- package/src/Incentives/ERC20Incentive.test.ts +6 -17
- package/src/Incentives/ERC20Incentive.ts +86 -21
- package/src/Incentives/ERC20VariableIncentive.test.ts +4 -24
- package/src/Incentives/ERC20VariableIncentive.ts +71 -19
- package/src/Incentives/Incentive.test.ts +1 -1
- package/src/Incentives/PointsIncentive.test.ts +3 -6
- package/src/Incentives/PointsIncentive.ts +79 -17
- package/src/Validators/SignerValidator.test.ts +3 -7
- package/src/Validators/SignerValidator.ts +422 -13
- package/src/claiming.ts +56 -0
- package/src/errors.ts +19 -1
- package/src/index.ts +10 -7
- package/src/transfers.ts +284 -0
- package/src/utils.ts +3 -2052
- package/dist/generated-Cd-Fe7W7.cjs.map +0 -1
- package/dist/generated-DGpIVcv5.js.map +0 -1
|
@@ -18,7 +18,12 @@ import {
|
|
|
18
18
|
writeErc20IncentiveDrawRaffle,
|
|
19
19
|
} from '@boostxyz/evm';
|
|
20
20
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20Incentive.sol/ERC20Incentive.json';
|
|
21
|
-
import
|
|
21
|
+
import {
|
|
22
|
+
type Address,
|
|
23
|
+
type ContractEventName,
|
|
24
|
+
type Hex,
|
|
25
|
+
encodeAbiParameters,
|
|
26
|
+
} from 'viem';
|
|
22
27
|
import type {
|
|
23
28
|
DeployableOptions,
|
|
24
29
|
GenericDeployableParams,
|
|
@@ -26,18 +31,51 @@ import type {
|
|
|
26
31
|
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
27
32
|
import {
|
|
28
33
|
type ClaimPayload,
|
|
29
|
-
type
|
|
34
|
+
type StrategyType,
|
|
35
|
+
prepareClaimPayload,
|
|
36
|
+
} from '../claiming';
|
|
37
|
+
import {
|
|
30
38
|
type GenericLog,
|
|
31
39
|
type ReadParams,
|
|
32
40
|
RegistryType,
|
|
33
|
-
type StrategyType,
|
|
34
41
|
type WriteParams,
|
|
35
|
-
prepareClaimPayload,
|
|
36
|
-
prepareERC20IncentivePayload,
|
|
37
42
|
} from '../utils';
|
|
38
43
|
|
|
39
44
|
export { erc20IncentiveAbi };
|
|
40
|
-
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The object representation of a `ERC20Incentive.InitPayload`
|
|
48
|
+
*
|
|
49
|
+
* @export
|
|
50
|
+
* @interface ERC20IncentivePayload
|
|
51
|
+
* @typedef {ERC20IncentivePayload}
|
|
52
|
+
*/
|
|
53
|
+
export interface ERC20IncentivePayload {
|
|
54
|
+
/**
|
|
55
|
+
* The address of the incentivized asset.
|
|
56
|
+
*
|
|
57
|
+
* @type {Address}
|
|
58
|
+
*/
|
|
59
|
+
asset: Address;
|
|
60
|
+
/**
|
|
61
|
+
* The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
|
|
62
|
+
*
|
|
63
|
+
* @type {StrategyType}
|
|
64
|
+
*/
|
|
65
|
+
strategy: StrategyType;
|
|
66
|
+
/**
|
|
67
|
+
* The amount of the asset to distribute.
|
|
68
|
+
*
|
|
69
|
+
* @type {bigint}
|
|
70
|
+
*/
|
|
71
|
+
reward: bigint;
|
|
72
|
+
/**
|
|
73
|
+
* How many times can this incentive be claimed.
|
|
74
|
+
*
|
|
75
|
+
* @type {bigint}
|
|
76
|
+
*/
|
|
77
|
+
limit: bigint;
|
|
78
|
+
}
|
|
41
79
|
|
|
42
80
|
/**
|
|
43
81
|
* A generic `viem.Log` event with support for `ERC20Incentive` event types.
|
|
@@ -94,7 +132,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
94
132
|
* @returns {unknown}
|
|
95
133
|
*/
|
|
96
134
|
public async owner(params?: ReadParams<typeof erc20IncentiveAbi, 'owner'>) {
|
|
97
|
-
return readErc20IncentiveOwner(this._config, {
|
|
135
|
+
return await readErc20IncentiveOwner(this._config, {
|
|
98
136
|
address: this.assertValidAddress(),
|
|
99
137
|
args: [],
|
|
100
138
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -113,7 +151,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
113
151
|
public async currentReward(
|
|
114
152
|
params?: ReadParams<typeof erc20IncentiveAbi, 'currentReward'>,
|
|
115
153
|
) {
|
|
116
|
-
return readErc20IncentiveCurrentReward(this._config, {
|
|
154
|
+
return await readErc20IncentiveCurrentReward(this._config, {
|
|
117
155
|
address: this.assertValidAddress(),
|
|
118
156
|
args: [],
|
|
119
157
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -130,7 +168,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
130
168
|
* @returns {Promise<bigint>}
|
|
131
169
|
*/
|
|
132
170
|
public async claims(params?: ReadParams<typeof erc20IncentiveAbi, 'claims'>) {
|
|
133
|
-
return readErc20IncentiveClaims(this._config, {
|
|
171
|
+
return await readErc20IncentiveClaims(this._config, {
|
|
134
172
|
address: this.assertValidAddress(),
|
|
135
173
|
args: [],
|
|
136
174
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -151,7 +189,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
151
189
|
address: Address,
|
|
152
190
|
params?: ReadParams<typeof erc20IncentiveAbi, 'claimed'>,
|
|
153
191
|
) {
|
|
154
|
-
return readErc20IncentiveClaimed(this._config, {
|
|
192
|
+
return await readErc20IncentiveClaimed(this._config, {
|
|
155
193
|
address: this.assertValidAddress(),
|
|
156
194
|
args: [address],
|
|
157
195
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -168,7 +206,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
168
206
|
* @returns {Promise<Address>}
|
|
169
207
|
*/
|
|
170
208
|
public async asset(params?: ReadParams<typeof erc20IncentiveAbi, 'asset'>) {
|
|
171
|
-
return readErc20IncentiveAsset(this._config, {
|
|
209
|
+
return await readErc20IncentiveAsset(this._config, {
|
|
172
210
|
address: this.assertValidAddress(),
|
|
173
211
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
174
212
|
...(params as any),
|
|
@@ -183,7 +221,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
183
221
|
* @param {?ReadParams<typeof erc20IncentiveAbi, 'strategy'>} [params]
|
|
184
222
|
* @returns {Promise<StrategyType>}
|
|
185
223
|
*/
|
|
186
|
-
public
|
|
224
|
+
public strategy(
|
|
187
225
|
params?: ReadParams<typeof erc20IncentiveAbi, 'strategy'>,
|
|
188
226
|
): Promise<StrategyType> {
|
|
189
227
|
return readErc20IncentiveStrategy(this._config, {
|
|
@@ -202,7 +240,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
202
240
|
* @returns {Promise<bigint>}
|
|
203
241
|
*/
|
|
204
242
|
public async reward(params?: ReadParams<typeof erc20IncentiveAbi, 'reward'>) {
|
|
205
|
-
return readErc20IncentiveReward(this._config, {
|
|
243
|
+
return await readErc20IncentiveReward(this._config, {
|
|
206
244
|
address: this.assertValidAddress(),
|
|
207
245
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
208
246
|
...(params as any),
|
|
@@ -218,7 +256,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
218
256
|
* @returns {unknown}
|
|
219
257
|
*/
|
|
220
258
|
public async limit(params?: ReadParams<typeof erc20IncentiveAbi, 'limit'>) {
|
|
221
|
-
return readErc20IncentiveLimit(this._config, {
|
|
259
|
+
return await readErc20IncentiveLimit(this._config, {
|
|
222
260
|
address: this.assertValidAddress(),
|
|
223
261
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
224
262
|
...(params as any),
|
|
@@ -238,7 +276,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
238
276
|
i: bigint,
|
|
239
277
|
params?: ReadParams<typeof erc20IncentiveAbi, 'entries'>,
|
|
240
278
|
) {
|
|
241
|
-
return readErc20IncentiveEntries(this._config, {
|
|
279
|
+
return await readErc20IncentiveEntries(this._config, {
|
|
242
280
|
address: this.assertValidAddress(),
|
|
243
281
|
args: [i],
|
|
244
282
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -255,11 +293,11 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
255
293
|
* @param {?WriteParams<typeof erc20IncentiveAbi, 'claim'>} [params]
|
|
256
294
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
257
295
|
*/
|
|
258
|
-
|
|
296
|
+
protected async claim(
|
|
259
297
|
payload: ClaimPayload,
|
|
260
298
|
params?: WriteParams<typeof erc20IncentiveAbi, 'claim'>,
|
|
261
299
|
) {
|
|
262
|
-
return this.awaitResult(this.claimRaw(payload, params));
|
|
300
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
263
301
|
}
|
|
264
302
|
|
|
265
303
|
/**
|
|
@@ -271,7 +309,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
271
309
|
* @param {?WriteParams<typeof erc20IncentiveAbi, 'claim'>} [params]
|
|
272
310
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
273
311
|
*/
|
|
274
|
-
|
|
312
|
+
protected async claimRaw(
|
|
275
313
|
payload: ClaimPayload,
|
|
276
314
|
params?: WriteParams<typeof erc20IncentiveAbi, 'claim'>,
|
|
277
315
|
) {
|
|
@@ -302,7 +340,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
302
340
|
payload: ClaimPayload,
|
|
303
341
|
params?: WriteParams<typeof erc20IncentiveAbi, 'clawback'>,
|
|
304
342
|
) {
|
|
305
|
-
return this.awaitResult(this.clawbackRaw(payload, params));
|
|
343
|
+
return await this.awaitResult(this.clawbackRaw(payload, params));
|
|
306
344
|
}
|
|
307
345
|
|
|
308
346
|
/**
|
|
@@ -345,7 +383,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
345
383
|
payload: ClaimPayload,
|
|
346
384
|
params?: ReadParams<typeof erc20IncentiveAbi, 'isClaimable'>,
|
|
347
385
|
) {
|
|
348
|
-
return readErc20IncentiveIsClaimable(this._config, {
|
|
386
|
+
return await readErc20IncentiveIsClaimable(this._config, {
|
|
349
387
|
address: this.assertValidAddress(),
|
|
350
388
|
args: [prepareClaimPayload(payload)],
|
|
351
389
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -364,7 +402,7 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
364
402
|
public async drawRaffle(
|
|
365
403
|
params?: WriteParams<typeof erc20IncentiveAbi, 'drawRaffle'>,
|
|
366
404
|
) {
|
|
367
|
-
return this.awaitResult(this.drawRaffleRaw(params));
|
|
405
|
+
return await this.awaitResult(this.drawRaffleRaw(params));
|
|
368
406
|
}
|
|
369
407
|
|
|
370
408
|
/**
|
|
@@ -415,3 +453,30 @@ export class ERC20Incentive extends DeployableTarget<
|
|
|
415
453
|
};
|
|
416
454
|
}
|
|
417
455
|
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Given a {@link ERC20IncentivePayload}, properly encode a `ERC20Incentive.InitPayload` for use with {@link ERC20Incentive} initialization.
|
|
459
|
+
*
|
|
460
|
+
* @param {ERC20IncentivePayload} param0
|
|
461
|
+
* @param {Address} param0.asset - The address of the incentivized asset.
|
|
462
|
+
* @param {StrategyType} param0.strategy - The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
|
|
463
|
+
* @param {bigint} param0.reward - The amount of the asset to distribute.
|
|
464
|
+
* @param {bigint} param0.limit - How many times can this incentive be claimed.
|
|
465
|
+
* @returns {*}
|
|
466
|
+
*/
|
|
467
|
+
export function prepareERC20IncentivePayload({
|
|
468
|
+
asset,
|
|
469
|
+
strategy,
|
|
470
|
+
reward,
|
|
471
|
+
limit,
|
|
472
|
+
}: ERC20IncentivePayload) {
|
|
473
|
+
return encodeAbiParameters(
|
|
474
|
+
[
|
|
475
|
+
{ type: 'address', name: 'asset' },
|
|
476
|
+
{ type: 'uint8', name: 'strategy' },
|
|
477
|
+
{ type: 'uint256', name: 'reward' },
|
|
478
|
+
{ type: 'uint256', name: 'limit' },
|
|
479
|
+
],
|
|
480
|
+
[asset, strategy, reward, limit],
|
|
481
|
+
);
|
|
482
|
+
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
readMockErc20BalanceOf,
|
|
3
|
-
readMockErc20TotalSupply,
|
|
4
|
-
} from '@boostxyz/evm';
|
|
1
|
+
import { readMockErc20BalanceOf } from '@boostxyz/evm';
|
|
5
2
|
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
encodeAbiParameters,
|
|
9
|
-
encodePacked,
|
|
10
|
-
isAddress,
|
|
11
|
-
keccak256,
|
|
12
|
-
pad,
|
|
13
|
-
parseEther,
|
|
14
|
-
zeroAddress,
|
|
15
|
-
} from 'viem';
|
|
16
|
-
import { toHex } from 'viem';
|
|
3
|
+
import { encodeAbiParameters, isAddress, parseEther, zeroAddress } from 'viem';
|
|
17
4
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
18
5
|
import { accounts } from '../../test/accounts';
|
|
19
6
|
import {
|
|
@@ -24,11 +11,6 @@ import {
|
|
|
24
11
|
freshBoost,
|
|
25
12
|
fundBudget,
|
|
26
13
|
} from '../../test/helpers';
|
|
27
|
-
import {
|
|
28
|
-
StrategyType,
|
|
29
|
-
prepareClaimPayload,
|
|
30
|
-
prepareSignerValidatorClaimDataPayload,
|
|
31
|
-
} from '../utils';
|
|
32
14
|
import { ERC20VariableIncentive } from './ERC20VariableIncentive';
|
|
33
15
|
|
|
34
16
|
const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
|
|
@@ -74,14 +56,13 @@ describe('ERC20VariableIncentive', () => {
|
|
|
74
56
|
|
|
75
57
|
const claimant = trustedSigner.account;
|
|
76
58
|
const incentiveQuantity = 1;
|
|
77
|
-
const claimDataPayload = await
|
|
59
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
78
60
|
signer: trustedSigner,
|
|
79
61
|
incentiveData: encodeAbiParameters(
|
|
80
62
|
[{ name: '', type: 'uint256' }],
|
|
81
63
|
[parseEther('1')],
|
|
82
64
|
),
|
|
83
65
|
chainId: defaultOptions.config.chains[0].id,
|
|
84
|
-
validator: boost.validator.assertValidAddress(),
|
|
85
66
|
incentiveQuantity,
|
|
86
67
|
claimant,
|
|
87
68
|
boostId: boost.id,
|
|
@@ -121,14 +102,13 @@ describe('ERC20VariableIncentive', () => {
|
|
|
121
102
|
|
|
122
103
|
const claimant = trustedSigner.account;
|
|
123
104
|
const incentiveQuantity = 1;
|
|
124
|
-
const claimDataPayload = await
|
|
105
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
125
106
|
signer: trustedSigner,
|
|
126
107
|
incentiveData: encodeAbiParameters(
|
|
127
108
|
[{ name: '', type: 'uint256' }],
|
|
128
109
|
[parseEther('1')],
|
|
129
110
|
),
|
|
130
111
|
chainId: defaultOptions.config.chains[0].id,
|
|
131
|
-
validator: boost.validator.assertValidAddress(),
|
|
132
112
|
incentiveQuantity,
|
|
133
113
|
claimant,
|
|
134
114
|
boostId: boost.id,
|
|
@@ -15,25 +15,53 @@ import {
|
|
|
15
15
|
writeErc20VariableIncentiveClawback,
|
|
16
16
|
} from '@boostxyz/evm';
|
|
17
17
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20VariableIncentive.sol/ERC20VariableIncentive.json';
|
|
18
|
-
import
|
|
18
|
+
import {
|
|
19
|
+
type Address,
|
|
20
|
+
type ContractEventName,
|
|
21
|
+
type Hex,
|
|
22
|
+
encodeAbiParameters,
|
|
23
|
+
} from 'viem';
|
|
19
24
|
import type {
|
|
20
25
|
DeployableOptions,
|
|
21
26
|
GenericDeployableParams,
|
|
22
27
|
} from '../Deployable/Deployable';
|
|
23
28
|
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
29
|
+
import { type ClaimPayload, prepareClaimPayload } from '../claiming';
|
|
24
30
|
import {
|
|
25
|
-
type ClaimPayload,
|
|
26
|
-
type ERC20VariableIncentivePayload,
|
|
27
31
|
type GenericLog,
|
|
28
32
|
type ReadParams,
|
|
29
33
|
RegistryType,
|
|
30
34
|
type WriteParams,
|
|
31
|
-
prepareClaimPayload,
|
|
32
|
-
prepareERC20VariableIncentivePayload,
|
|
33
35
|
} from '../utils';
|
|
34
36
|
|
|
35
37
|
export { erc20VariableIncentiveAbi };
|
|
36
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The object representation of a `ERC20VariableIncentivePayload.InitPayload`
|
|
40
|
+
*
|
|
41
|
+
* @export
|
|
42
|
+
* @interface ERC20VariableIncentivePayload
|
|
43
|
+
* @typedef {ERC20VariableIncentivePayload}
|
|
44
|
+
*/
|
|
45
|
+
export interface ERC20VariableIncentivePayload {
|
|
46
|
+
/**
|
|
47
|
+
* The address of the incentivized asset.
|
|
48
|
+
*
|
|
49
|
+
* @type {Address}
|
|
50
|
+
*/
|
|
51
|
+
asset: Address;
|
|
52
|
+
/**
|
|
53
|
+
* The amount of the asset to distribute.
|
|
54
|
+
*
|
|
55
|
+
* @type {bigint}
|
|
56
|
+
*/
|
|
57
|
+
reward: bigint;
|
|
58
|
+
/**
|
|
59
|
+
* How many times can this incentive be claimed.
|
|
60
|
+
*
|
|
61
|
+
* @type {bigint}
|
|
62
|
+
*/
|
|
63
|
+
limit: bigint;
|
|
64
|
+
}
|
|
37
65
|
|
|
38
66
|
/**
|
|
39
67
|
* A generic `viem.Log` event with support for `ERC20VariableIncentive` event types.
|
|
@@ -92,7 +120,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
92
120
|
public async owner(
|
|
93
121
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'owner'>,
|
|
94
122
|
) {
|
|
95
|
-
return readErc20VariableIncentiveOwner(this._config, {
|
|
123
|
+
return await readErc20VariableIncentiveOwner(this._config, {
|
|
96
124
|
address: this.assertValidAddress(),
|
|
97
125
|
args: [],
|
|
98
126
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -111,7 +139,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
111
139
|
public async totalClaimed(
|
|
112
140
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'totalClaimed'>,
|
|
113
141
|
) {
|
|
114
|
-
return readErc20VariableIncentiveTotalClaimed(this._config, {
|
|
142
|
+
return await readErc20VariableIncentiveTotalClaimed(this._config, {
|
|
115
143
|
address: this.assertValidAddress(),
|
|
116
144
|
args: [],
|
|
117
145
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -130,7 +158,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
130
158
|
public async currentReward(
|
|
131
159
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'currentReward'>,
|
|
132
160
|
) {
|
|
133
|
-
return readErc20VariableIncentiveCurrentReward(this._config, {
|
|
161
|
+
return await readErc20VariableIncentiveCurrentReward(this._config, {
|
|
134
162
|
address: this.assertValidAddress(),
|
|
135
163
|
args: [],
|
|
136
164
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -149,7 +177,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
149
177
|
public async claims(
|
|
150
178
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'claims'>,
|
|
151
179
|
) {
|
|
152
|
-
return readErc20VariableIncentiveClaims(this._config, {
|
|
180
|
+
return await readErc20VariableIncentiveClaims(this._config, {
|
|
153
181
|
address: this.assertValidAddress(),
|
|
154
182
|
args: [],
|
|
155
183
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -170,7 +198,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
170
198
|
address: Address,
|
|
171
199
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'claimed'>,
|
|
172
200
|
) {
|
|
173
|
-
return readErc20VariableIncentiveClaimed(this._config, {
|
|
201
|
+
return await readErc20VariableIncentiveClaimed(this._config, {
|
|
174
202
|
address: this.assertValidAddress(),
|
|
175
203
|
args: [address],
|
|
176
204
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -189,7 +217,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
189
217
|
public async asset(
|
|
190
218
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'asset'>,
|
|
191
219
|
) {
|
|
192
|
-
return readErc20VariableIncentiveAsset(this._config, {
|
|
220
|
+
return await readErc20VariableIncentiveAsset(this._config, {
|
|
193
221
|
address: this.assertValidAddress(),
|
|
194
222
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
195
223
|
...(params as any),
|
|
@@ -207,7 +235,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
207
235
|
public async reward(
|
|
208
236
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'reward'>,
|
|
209
237
|
) {
|
|
210
|
-
return readErc20VariableIncentiveReward(this._config, {
|
|
238
|
+
return await readErc20VariableIncentiveReward(this._config, {
|
|
211
239
|
address: this.assertValidAddress(),
|
|
212
240
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
213
241
|
...(params as any),
|
|
@@ -225,7 +253,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
225
253
|
public async limit(
|
|
226
254
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'limit'>,
|
|
227
255
|
) {
|
|
228
|
-
return readErc20VariableIncentiveLimit(this._config, {
|
|
256
|
+
return await readErc20VariableIncentiveLimit(this._config, {
|
|
229
257
|
address: this.assertValidAddress(),
|
|
230
258
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
231
259
|
...(params as any),
|
|
@@ -241,11 +269,11 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
241
269
|
* @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>} [params]
|
|
242
270
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
243
271
|
*/
|
|
244
|
-
|
|
272
|
+
protected async claim(
|
|
245
273
|
payload: ClaimPayload,
|
|
246
274
|
params?: WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>,
|
|
247
275
|
) {
|
|
248
|
-
return this.awaitResult(this.claimRaw(payload, params));
|
|
276
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
249
277
|
}
|
|
250
278
|
|
|
251
279
|
/**
|
|
@@ -257,7 +285,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
257
285
|
* @param {?WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>} [params]
|
|
258
286
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
259
287
|
*/
|
|
260
|
-
|
|
288
|
+
protected async claimRaw(
|
|
261
289
|
payload: ClaimPayload,
|
|
262
290
|
params?: WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>,
|
|
263
291
|
) {
|
|
@@ -288,7 +316,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
288
316
|
payload: ClaimPayload,
|
|
289
317
|
params?: WriteParams<typeof erc20VariableIncentiveAbi, 'clawback'>,
|
|
290
318
|
) {
|
|
291
|
-
return this.awaitResult(this.clawbackRaw(payload, params));
|
|
319
|
+
return await this.awaitResult(this.clawbackRaw(payload, params));
|
|
292
320
|
}
|
|
293
321
|
|
|
294
322
|
/**
|
|
@@ -334,7 +362,7 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
334
362
|
payload: ClaimPayload,
|
|
335
363
|
params?: ReadParams<typeof erc20VariableIncentiveAbi, 'isClaimable'>,
|
|
336
364
|
) {
|
|
337
|
-
return readErc20VariableIncentiveIsClaimable(this._config, {
|
|
365
|
+
return await readErc20VariableIncentiveIsClaimable(this._config, {
|
|
338
366
|
address: this.assertValidAddress(),
|
|
339
367
|
args: [prepareClaimPayload(payload)],
|
|
340
368
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -366,3 +394,27 @@ export class ERC20VariableIncentive extends DeployableTarget<
|
|
|
366
394
|
};
|
|
367
395
|
}
|
|
368
396
|
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Given a {@link ERC20VariableIncentivePayload}, properly encode a ` ERC20VariableIncentive.InitPayload` for use with {@link ERC20VariableIncentive} initialization.
|
|
400
|
+
*
|
|
401
|
+
* @param {ERC20VariableIncentivePayload} param0
|
|
402
|
+
* @param {Address} param0.asset - The address of the incentivized asset.
|
|
403
|
+
* @param {bigint} param0.reward - The amount of the asset to distribute.
|
|
404
|
+
* @param {bigint} param0.limit - How many times can this incentive be claimed.
|
|
405
|
+
* @returns {*}
|
|
406
|
+
*/
|
|
407
|
+
export function prepareERC20VariableIncentivePayload({
|
|
408
|
+
asset,
|
|
409
|
+
reward,
|
|
410
|
+
limit,
|
|
411
|
+
}: ERC20VariableIncentivePayload) {
|
|
412
|
+
return encodeAbiParameters(
|
|
413
|
+
[
|
|
414
|
+
{ type: 'address', name: 'asset' },
|
|
415
|
+
{ type: 'uint256', name: 'reward' },
|
|
416
|
+
{ type: 'uint256', name: 'limit' },
|
|
417
|
+
],
|
|
418
|
+
[asset, reward, limit],
|
|
419
|
+
);
|
|
420
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { zeroAddress } from 'viem';
|
|
2
2
|
import { describe, expect, test } from 'vitest';
|
|
3
3
|
import { defaultOptions } from '../../test/helpers';
|
|
4
|
-
import { StrategyType } from '../
|
|
4
|
+
import { StrategyType } from '../claiming';
|
|
5
5
|
import {
|
|
6
6
|
AllowListIncentive,
|
|
7
7
|
CGDAIncentive,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { readPointsBalanceOf, writePointsGrantRoles } from '@boostxyz/evm';
|
|
2
2
|
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
3
|
-
import { signMessage } from '@wagmi/core';
|
|
4
3
|
import { isAddress, pad, parseEther, zeroAddress } from 'viem';
|
|
5
4
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
6
5
|
import type { MockPoints } from '../../test/MockPoints';
|
|
@@ -12,7 +11,7 @@ import {
|
|
|
12
11
|
freshBoost,
|
|
13
12
|
freshPoints,
|
|
14
13
|
} from '../../test/helpers';
|
|
15
|
-
import { bytes4
|
|
14
|
+
import { bytes4 } from '../utils';
|
|
16
15
|
import { PointsIncentive } from './PointsIncentive';
|
|
17
16
|
|
|
18
17
|
let fixtures: Fixtures, points: MockPoints;
|
|
@@ -55,11 +54,10 @@ describe('PointsIncentive', () => {
|
|
|
55
54
|
const claimant = trustedSigner.account;
|
|
56
55
|
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
57
56
|
const incentiveQuantity = 1;
|
|
58
|
-
const claimDataPayload = await
|
|
57
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
59
58
|
signer: trustedSigner,
|
|
60
59
|
incentiveData,
|
|
61
60
|
chainId: defaultOptions.config.chains[0].id,
|
|
62
|
-
validator: boost.validator.assertValidAddress(),
|
|
63
61
|
incentiveQuantity,
|
|
64
62
|
claimant,
|
|
65
63
|
boostId: boost.id,
|
|
@@ -105,11 +103,10 @@ describe('PointsIncentive', () => {
|
|
|
105
103
|
const claimant = trustedSigner.account;
|
|
106
104
|
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
107
105
|
const incentiveQuantity = 1;
|
|
108
|
-
const claimDataPayload = await
|
|
106
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
109
107
|
signer: trustedSigner,
|
|
110
108
|
incentiveData,
|
|
111
109
|
chainId: defaultOptions.config.chains[0].id,
|
|
112
|
-
validator: boost.validator.assertValidAddress(),
|
|
113
110
|
incentiveQuantity,
|
|
114
111
|
claimant,
|
|
115
112
|
boostId: boost.id,
|