@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
|
@@ -15,26 +15,100 @@ import {
|
|
|
15
15
|
writeCgdaIncentiveClawback,
|
|
16
16
|
} from '@boostxyz/evm';
|
|
17
17
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/CGDAIncentive.sol/CGDAIncentive.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 CGDAIncentivePayload,
|
|
26
|
-
type CGDAParameters,
|
|
27
|
-
type ClaimPayload,
|
|
28
31
|
type GenericLog,
|
|
29
32
|
type ReadParams,
|
|
30
33
|
RegistryType,
|
|
31
34
|
type WriteParams,
|
|
32
|
-
prepareCGDAIncentivePayload,
|
|
33
|
-
prepareClaimPayload,
|
|
34
35
|
} from '../utils';
|
|
35
36
|
|
|
36
37
|
export { cgdaIncentiveAbi };
|
|
37
|
-
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The object representation of a `CGDAIncentive.InitPayload`
|
|
41
|
+
*
|
|
42
|
+
* @export
|
|
43
|
+
* @interface CGDAIncentivePayload
|
|
44
|
+
* @typedef {CGDAIncentivePayload}
|
|
45
|
+
*/
|
|
46
|
+
export interface CGDAIncentivePayload {
|
|
47
|
+
/**
|
|
48
|
+
* The address of the ERC20-like token
|
|
49
|
+
*
|
|
50
|
+
* @type {Address}
|
|
51
|
+
*/
|
|
52
|
+
asset: Address;
|
|
53
|
+
/**
|
|
54
|
+
* The initial reward amount
|
|
55
|
+
*
|
|
56
|
+
* @type {bigint}
|
|
57
|
+
*/
|
|
58
|
+
initialReward: bigint;
|
|
59
|
+
/**
|
|
60
|
+
* The amount to subtract from the current reward after each claim
|
|
61
|
+
*
|
|
62
|
+
* @type {bigint}
|
|
63
|
+
*/
|
|
64
|
+
rewardDecay: bigint;
|
|
65
|
+
/**
|
|
66
|
+
* The amount by which the reward increases for each hour without a claim (continuous linear increase)
|
|
67
|
+
*
|
|
68
|
+
* @type {bigint}
|
|
69
|
+
*/
|
|
70
|
+
rewardBoost: bigint;
|
|
71
|
+
/**
|
|
72
|
+
* The total budget for the incentive
|
|
73
|
+
*
|
|
74
|
+
* @type {bigint}
|
|
75
|
+
*/
|
|
76
|
+
totalBudget: bigint;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The configuration parameters for the CGDAIncentive
|
|
81
|
+
*
|
|
82
|
+
* @export
|
|
83
|
+
* @interface CGDAParameters
|
|
84
|
+
* @typedef {CGDAParameters}
|
|
85
|
+
*/
|
|
86
|
+
export interface CGDAParameters {
|
|
87
|
+
/**
|
|
88
|
+
* The amount to subtract from the current reward after each claim
|
|
89
|
+
*
|
|
90
|
+
* @type {bigint}
|
|
91
|
+
*/
|
|
92
|
+
rewardDecay: bigint;
|
|
93
|
+
/**
|
|
94
|
+
* The amount by which the reward increases for each hour without a claim (continuous linear increase)
|
|
95
|
+
*
|
|
96
|
+
* @type {bigint}
|
|
97
|
+
*/
|
|
98
|
+
rewardBoost: bigint;
|
|
99
|
+
/**
|
|
100
|
+
* The timestamp of the last claim
|
|
101
|
+
*
|
|
102
|
+
* @type {bigint}
|
|
103
|
+
*/
|
|
104
|
+
lastClaimTime: bigint;
|
|
105
|
+
/**
|
|
106
|
+
* The current reward amount
|
|
107
|
+
*
|
|
108
|
+
* @type {bigint}
|
|
109
|
+
*/
|
|
110
|
+
currentReward: bigint;
|
|
111
|
+
}
|
|
38
112
|
|
|
39
113
|
/**
|
|
40
114
|
* A generic `viem.Log` event with support for `CGDAIncentive` event types.
|
|
@@ -92,7 +166,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
92
166
|
* @returns {unknown}
|
|
93
167
|
*/
|
|
94
168
|
public async owner(params?: ReadParams<typeof cgdaIncentiveAbi, 'owner'>) {
|
|
95
|
-
return readCgdaIncentiveOwner(this._config, {
|
|
169
|
+
return await readCgdaIncentiveOwner(this._config, {
|
|
96
170
|
address: this.assertValidAddress(),
|
|
97
171
|
args: [],
|
|
98
172
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -109,7 +183,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
109
183
|
* @returns {Promise<bigint>}
|
|
110
184
|
*/
|
|
111
185
|
public async claims(params?: ReadParams<typeof cgdaIncentiveAbi, 'claims'>) {
|
|
112
|
-
return readCgdaIncentiveClaims(this._config, {
|
|
186
|
+
return await readCgdaIncentiveClaims(this._config, {
|
|
113
187
|
address: this.assertValidAddress(),
|
|
114
188
|
args: [],
|
|
115
189
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -126,7 +200,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
126
200
|
* @returns {Promise<bigint>}
|
|
127
201
|
*/
|
|
128
202
|
public async reward(params?: ReadParams<typeof cgdaIncentiveAbi, 'reward'>) {
|
|
129
|
-
return readCgdaIncentiveReward(this._config, {
|
|
203
|
+
return await readCgdaIncentiveReward(this._config, {
|
|
130
204
|
address: this.assertValidAddress(),
|
|
131
205
|
args: [],
|
|
132
206
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -147,7 +221,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
147
221
|
address: Address,
|
|
148
222
|
params?: ReadParams<typeof cgdaIncentiveAbi, 'claimed'>,
|
|
149
223
|
) {
|
|
150
|
-
return readCgdaIncentiveClaimed(this._config, {
|
|
224
|
+
return await readCgdaIncentiveClaimed(this._config, {
|
|
151
225
|
address: this.assertValidAddress(),
|
|
152
226
|
args: [address],
|
|
153
227
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -164,7 +238,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
164
238
|
* @returns {unknown}
|
|
165
239
|
*/
|
|
166
240
|
public async asset(params?: ReadParams<typeof cgdaIncentiveAbi, 'asset'>) {
|
|
167
|
-
return readCgdaIncentiveAsset(this._config, {
|
|
241
|
+
return await readCgdaIncentiveAsset(this._config, {
|
|
168
242
|
address: this.assertValidAddress(),
|
|
169
243
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
170
244
|
...(params as any),
|
|
@@ -207,7 +281,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
207
281
|
public async totalBudget(
|
|
208
282
|
params?: ReadParams<typeof cgdaIncentiveAbi, 'totalBudget'>,
|
|
209
283
|
) {
|
|
210
|
-
return readCgdaIncentiveTotalBudget(this._config, {
|
|
284
|
+
return await readCgdaIncentiveTotalBudget(this._config, {
|
|
211
285
|
address: this.assertValidAddress(),
|
|
212
286
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
213
287
|
...(params as any),
|
|
@@ -223,11 +297,11 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
223
297
|
* @param {?WriteParams<typeof cgdaIncentiveAbi, 'claim'>} [params]
|
|
224
298
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
225
299
|
*/
|
|
226
|
-
|
|
300
|
+
protected async claim(
|
|
227
301
|
payload: ClaimPayload,
|
|
228
302
|
params?: WriteParams<typeof cgdaIncentiveAbi, 'claim'>,
|
|
229
303
|
) {
|
|
230
|
-
return this.awaitResult(this.claimRaw(payload, params));
|
|
304
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
231
305
|
}
|
|
232
306
|
|
|
233
307
|
/**
|
|
@@ -239,7 +313,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
239
313
|
* @param {?WriteParams<typeof cgdaIncentiveAbi, 'claim'>} [params]
|
|
240
314
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
241
315
|
*/
|
|
242
|
-
|
|
316
|
+
protected async claimRaw(
|
|
243
317
|
payload: ClaimPayload,
|
|
244
318
|
params?: WriteParams<typeof cgdaIncentiveAbi, 'claim'>,
|
|
245
319
|
) {
|
|
@@ -267,7 +341,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
267
341
|
payload: ClaimPayload,
|
|
268
342
|
params?: WriteParams<typeof cgdaIncentiveAbi, 'clawback'>,
|
|
269
343
|
) {
|
|
270
|
-
return this.awaitResult(this.clawbackRaw(payload, params));
|
|
344
|
+
return await this.awaitResult(this.clawbackRaw(payload, params));
|
|
271
345
|
}
|
|
272
346
|
|
|
273
347
|
/**
|
|
@@ -310,7 +384,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
310
384
|
payload: ClaimPayload,
|
|
311
385
|
params?: ReadParams<typeof cgdaIncentiveAbi, 'isClaimable'>,
|
|
312
386
|
) {
|
|
313
|
-
return readCgdaIncentiveIsClaimable(this._config, {
|
|
387
|
+
return await readCgdaIncentiveIsClaimable(this._config, {
|
|
314
388
|
address: this.assertValidAddress(),
|
|
315
389
|
args: [prepareClaimPayload(payload)],
|
|
316
390
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -331,7 +405,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
331
405
|
public async currentReward(
|
|
332
406
|
params?: ReadParams<typeof cgdaIncentiveAbi, 'currentReward'>,
|
|
333
407
|
) {
|
|
334
|
-
return readCgdaIncentiveCurrentReward(this._config, {
|
|
408
|
+
return await readCgdaIncentiveCurrentReward(this._config, {
|
|
335
409
|
address: this.assertValidAddress(),
|
|
336
410
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
337
411
|
...(params as any),
|
|
@@ -362,3 +436,33 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
362
436
|
};
|
|
363
437
|
}
|
|
364
438
|
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Given a {@link CGDAIncentivePayload}, properly encode a `CGDAIncentive.InitPayload` for use with {@link CGDAIncentive} initialization.
|
|
442
|
+
*
|
|
443
|
+
* @param {CGDAIncentivePayload} param0
|
|
444
|
+
* @param {Address} param0.asset - The address of the ERC20-like token
|
|
445
|
+
* @param {bigint} param0.initialReward - The initial reward amount
|
|
446
|
+
* @param {bigint} param0.rewardDecay - The amount to subtract from the current reward after each claim
|
|
447
|
+
* @param {bigint} param0.rewardBoost - The amount by which the reward increases for each hour without a claim (continuous linear increase)
|
|
448
|
+
* @param {bigint} param0.totalBudget - The total budget for the incentive
|
|
449
|
+
* @returns {Hex}
|
|
450
|
+
*/
|
|
451
|
+
export function prepareCGDAIncentivePayload({
|
|
452
|
+
asset,
|
|
453
|
+
initialReward,
|
|
454
|
+
rewardDecay,
|
|
455
|
+
rewardBoost,
|
|
456
|
+
totalBudget,
|
|
457
|
+
}: CGDAIncentivePayload) {
|
|
458
|
+
return encodeAbiParameters(
|
|
459
|
+
[
|
|
460
|
+
{ type: 'address', name: 'asset' },
|
|
461
|
+
{ type: 'uint256', name: 'initialReward' },
|
|
462
|
+
{ type: 'uint256', name: 'rewardDecay' },
|
|
463
|
+
{ type: 'uint256', name: 'rewardBoost' },
|
|
464
|
+
{ type: 'uint256', name: 'totalBudget' },
|
|
465
|
+
],
|
|
466
|
+
[asset, initialReward, rewardDecay, rewardBoost, totalBudget],
|
|
467
|
+
);
|
|
468
|
+
}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { readMockErc1155BalanceOf } from '@boostxyz/evm';
|
|
2
2
|
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
encodePacked,
|
|
6
|
-
isAddress,
|
|
7
|
-
keccak256,
|
|
8
|
-
pad,
|
|
9
|
-
parseEther,
|
|
10
|
-
zeroAddress,
|
|
11
|
-
zeroHash,
|
|
12
|
-
} from 'viem';
|
|
3
|
+
import { isAddress, pad, parseEther, zeroAddress, zeroHash } from 'viem';
|
|
13
4
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
14
5
|
import { accounts } from '../../test/accounts';
|
|
15
6
|
import {
|
|
@@ -20,7 +11,6 @@ import {
|
|
|
20
11
|
freshBoost,
|
|
21
12
|
fundBudget,
|
|
22
13
|
} from '../../test/helpers';
|
|
23
|
-
import { prepareSignerValidatorClaimDataPayload } from '../utils';
|
|
24
14
|
import { ERC1155Incentive, ERC1155StrategyType } from './ERC1155Incentive';
|
|
25
15
|
|
|
26
16
|
const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
|
|
@@ -71,11 +61,10 @@ describe.skip('ERC1155Incentive', () => {
|
|
|
71
61
|
const claimant = trustedSigner.account;
|
|
72
62
|
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
73
63
|
const incentiveQuantity = 1;
|
|
74
|
-
const claimDataPayload = await
|
|
64
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
75
65
|
signer: trustedSigner,
|
|
76
66
|
incentiveData,
|
|
77
67
|
chainId: defaultOptions.config.chains[0].id,
|
|
78
|
-
validator: boost.validator.assertValidAddress(),
|
|
79
68
|
incentiveQuantity,
|
|
80
69
|
claimant,
|
|
81
70
|
boostId: boost.id,
|
|
@@ -16,7 +16,13 @@ import {
|
|
|
16
16
|
writeErc1155IncentiveClawback,
|
|
17
17
|
} from '@boostxyz/evm';
|
|
18
18
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC1155Incentive.sol/ERC1155Incentive.json';
|
|
19
|
-
import
|
|
19
|
+
import {
|
|
20
|
+
type Address,
|
|
21
|
+
type ContractEventName,
|
|
22
|
+
type Hex,
|
|
23
|
+
encodeAbiParameters,
|
|
24
|
+
parseAbiParameters,
|
|
25
|
+
} from 'viem';
|
|
20
26
|
import type {
|
|
21
27
|
DeployableOptions,
|
|
22
28
|
GenericDeployableParams,
|
|
@@ -24,19 +30,68 @@ import type {
|
|
|
24
30
|
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
25
31
|
import {
|
|
26
32
|
type ClaimPayload,
|
|
27
|
-
type
|
|
28
|
-
|
|
33
|
+
type StrategyType,
|
|
34
|
+
prepareClaimPayload,
|
|
35
|
+
} from '../claiming';
|
|
36
|
+
import {
|
|
29
37
|
type GenericLog,
|
|
30
38
|
type ReadParams,
|
|
31
39
|
RegistryType,
|
|
32
|
-
type StrategyType,
|
|
33
40
|
type WriteParams,
|
|
34
|
-
prepareClaimPayload,
|
|
35
|
-
prepareERC1155IncentivePayload,
|
|
36
41
|
} from '../utils';
|
|
37
42
|
|
|
38
|
-
export {
|
|
39
|
-
|
|
43
|
+
export { erc1155IncentiveAbi };
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Enum representing inventive disbursement strategies for {@link ERC1155Incentive}
|
|
47
|
+
*
|
|
48
|
+
* @export
|
|
49
|
+
* @enum {number}
|
|
50
|
+
*/
|
|
51
|
+
export enum ERC1155StrategyType {
|
|
52
|
+
POOL = 0,
|
|
53
|
+
MINT = 1,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The object representation of a `ERC1155Incentive.InitPayload`
|
|
58
|
+
*
|
|
59
|
+
* @export
|
|
60
|
+
* @interface ERC1155IncentivePayload
|
|
61
|
+
* @typedef {ERC1155IncentivePayload}
|
|
62
|
+
*/
|
|
63
|
+
export interface ERC1155IncentivePayload {
|
|
64
|
+
/**
|
|
65
|
+
* The address of the `ERC1155` asset
|
|
66
|
+
*
|
|
67
|
+
* @type {Address}
|
|
68
|
+
*/
|
|
69
|
+
asset: Address;
|
|
70
|
+
/**
|
|
71
|
+
* Should be `Strategy.POOL`
|
|
72
|
+
*
|
|
73
|
+
* @type {ERC1155StrategyType}
|
|
74
|
+
*/
|
|
75
|
+
strategy: ERC1155StrategyType;
|
|
76
|
+
/**
|
|
77
|
+
* The token ID to target
|
|
78
|
+
*
|
|
79
|
+
* @type {bigint}
|
|
80
|
+
*/
|
|
81
|
+
tokenId: bigint;
|
|
82
|
+
/**
|
|
83
|
+
* The maximum number of claims that can be made (one per address)
|
|
84
|
+
*
|
|
85
|
+
* @type {bigint}
|
|
86
|
+
*/
|
|
87
|
+
limit: bigint;
|
|
88
|
+
/**
|
|
89
|
+
* Any extra data to accompany the claim, if applicable.
|
|
90
|
+
*
|
|
91
|
+
* @type {Hex}
|
|
92
|
+
*/
|
|
93
|
+
extraData: Hex;
|
|
94
|
+
}
|
|
40
95
|
|
|
41
96
|
/**
|
|
42
97
|
* A generic `viem.Log` event with support for `ERC1155Incentive` event types.
|
|
@@ -96,7 +151,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
96
151
|
public async claims(
|
|
97
152
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'claims'>,
|
|
98
153
|
) {
|
|
99
|
-
return readErc1155IncentiveClaims(this._config, {
|
|
154
|
+
return await readErc1155IncentiveClaims(this._config, {
|
|
100
155
|
address: this.assertValidAddress(),
|
|
101
156
|
args: [],
|
|
102
157
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -115,7 +170,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
115
170
|
public async reward(
|
|
116
171
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'reward'>,
|
|
117
172
|
) {
|
|
118
|
-
return readErc1155IncentiveReward(this._config, {
|
|
173
|
+
return await readErc1155IncentiveReward(this._config, {
|
|
119
174
|
address: this.assertValidAddress(),
|
|
120
175
|
args: [],
|
|
121
176
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -136,7 +191,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
136
191
|
address: Address,
|
|
137
192
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'claimed'>,
|
|
138
193
|
) {
|
|
139
|
-
return readErc1155IncentiveClaimed(this._config, {
|
|
194
|
+
return await readErc1155IncentiveClaimed(this._config, {
|
|
140
195
|
address: this.assertValidAddress(),
|
|
141
196
|
args: [address],
|
|
142
197
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -153,7 +208,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
153
208
|
* @returns {unknown}
|
|
154
209
|
*/
|
|
155
210
|
public async asset(params?: ReadParams<typeof erc1155IncentiveAbi, 'asset'>) {
|
|
156
|
-
return readErc1155IncentiveAsset(this._config, {
|
|
211
|
+
return await readErc1155IncentiveAsset(this._config, {
|
|
157
212
|
address: this.assertValidAddress(),
|
|
158
213
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
159
214
|
...(params as any),
|
|
@@ -168,7 +223,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
168
223
|
* @param {?ReadParams<typeof erc1155IncentiveAbi, 'strategy'>} [params]
|
|
169
224
|
* @returns {Promise<StrategyType>}
|
|
170
225
|
*/
|
|
171
|
-
public
|
|
226
|
+
public strategy(
|
|
172
227
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'strategy'>,
|
|
173
228
|
): Promise<StrategyType> {
|
|
174
229
|
return readErc1155IncentiveStrategy(this._config, {
|
|
@@ -187,7 +242,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
187
242
|
* @returns {unknown}
|
|
188
243
|
*/
|
|
189
244
|
public async limit(params?: ReadParams<typeof erc1155IncentiveAbi, 'limit'>) {
|
|
190
|
-
return readErc1155IncentiveLimit(this._config, {
|
|
245
|
+
return await readErc1155IncentiveLimit(this._config, {
|
|
191
246
|
address: this.assertValidAddress(),
|
|
192
247
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
193
248
|
...(params as any),
|
|
@@ -205,7 +260,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
205
260
|
public async tokenId(
|
|
206
261
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'tokenId'>,
|
|
207
262
|
) {
|
|
208
|
-
return readErc1155IncentiveTokenId(this._config, {
|
|
263
|
+
return await readErc1155IncentiveTokenId(this._config, {
|
|
209
264
|
address: this.assertValidAddress(),
|
|
210
265
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
211
266
|
...(params as any),
|
|
@@ -223,7 +278,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
223
278
|
public async extraData(
|
|
224
279
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'extraData'>,
|
|
225
280
|
) {
|
|
226
|
-
return readErc1155IncentiveExtraData(this._config, {
|
|
281
|
+
return await readErc1155IncentiveExtraData(this._config, {
|
|
227
282
|
address: this.assertValidAddress(),
|
|
228
283
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
229
284
|
...(params as any),
|
|
@@ -239,11 +294,11 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
239
294
|
* @param {?WriteParams<typeof erc1155IncentiveAbi, 'claim'>} [params]
|
|
240
295
|
* @returns {unknown}
|
|
241
296
|
*/
|
|
242
|
-
|
|
297
|
+
protected async claim(
|
|
243
298
|
payload: ClaimPayload,
|
|
244
299
|
params?: WriteParams<typeof erc1155IncentiveAbi, 'claim'>,
|
|
245
300
|
) {
|
|
246
|
-
return this.awaitResult(this.claimRaw(payload, params));
|
|
301
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
247
302
|
}
|
|
248
303
|
|
|
249
304
|
/**
|
|
@@ -255,7 +310,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
255
310
|
* @param {?WriteParams<typeof erc1155IncentiveAbi, 'claim'>} [params]
|
|
256
311
|
* @returns {unknown}
|
|
257
312
|
*/
|
|
258
|
-
|
|
313
|
+
protected async claimRaw(
|
|
259
314
|
payload: ClaimPayload,
|
|
260
315
|
params?: WriteParams<typeof erc1155IncentiveAbi, 'claim'>,
|
|
261
316
|
) {
|
|
@@ -286,7 +341,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
286
341
|
payload: ClaimPayload,
|
|
287
342
|
params?: WriteParams<typeof erc1155IncentiveAbi, 'clawback'>,
|
|
288
343
|
) {
|
|
289
|
-
return this.awaitResult(this.clawbackRaw(payload, params));
|
|
344
|
+
return await this.awaitResult(this.clawbackRaw(payload, params));
|
|
290
345
|
}
|
|
291
346
|
|
|
292
347
|
/**
|
|
@@ -329,7 +384,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
329
384
|
payload: ClaimPayload,
|
|
330
385
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'isClaimable'>,
|
|
331
386
|
) {
|
|
332
|
-
return readErc1155IncentiveIsClaimable(this._config, {
|
|
387
|
+
return await readErc1155IncentiveIsClaimable(this._config, {
|
|
333
388
|
address: this.assertValidAddress(),
|
|
334
389
|
args: [prepareClaimPayload(payload)],
|
|
335
390
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -350,7 +405,7 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
350
405
|
data: ERC1155IncentivePayload,
|
|
351
406
|
params?: ReadParams<typeof erc1155IncentiveAbi, 'preflight'>,
|
|
352
407
|
) {
|
|
353
|
-
return readErc1155IncentivePreflight(this._config, {
|
|
408
|
+
return await readErc1155IncentivePreflight(this._config, {
|
|
354
409
|
address: this.assertValidAddress(),
|
|
355
410
|
args: [prepareERC1155IncentivePayload(data)],
|
|
356
411
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -382,3 +437,30 @@ export class ERC1155Incentive extends DeployableTarget<
|
|
|
382
437
|
};
|
|
383
438
|
}
|
|
384
439
|
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Given a {@link ERC1155IncentivePayload}, properly encode a `ERC1155Incentive.InitPayload` for use with {@link ERC1155Incentive} initialization.
|
|
443
|
+
*
|
|
444
|
+
* @param {ERC1155IncentivePayload} param0
|
|
445
|
+
* @param {Address} param0.asset - The address of the `ERC1155` asset
|
|
446
|
+
* @param {ERC1155StrategyType} param0.strategy - Should be `Strategy.POOL`
|
|
447
|
+
* @param {bigint} param0.tokenId - The token ID to target
|
|
448
|
+
* @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
|
|
449
|
+
* @param {Hex} param0.extraData - Any extra data to accompany the claim, if applicable.
|
|
450
|
+
* @returns {Hex}
|
|
451
|
+
*/
|
|
452
|
+
export const prepareERC1155IncentivePayload = ({
|
|
453
|
+
asset,
|
|
454
|
+
strategy,
|
|
455
|
+
tokenId,
|
|
456
|
+
limit,
|
|
457
|
+
extraData,
|
|
458
|
+
}: ERC1155IncentivePayload) => {
|
|
459
|
+
return encodeAbiParameters(
|
|
460
|
+
parseAbiParameters([
|
|
461
|
+
'InitPayload payload',
|
|
462
|
+
'struct InitPayload { address asset; uint8 strategy; uint256 tokenId; uint256 limit; bytes extraData; }',
|
|
463
|
+
]),
|
|
464
|
+
[{ asset, strategy, tokenId, limit, extraData }],
|
|
465
|
+
);
|
|
466
|
+
};
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { readMockErc20BalanceOf } from '@boostxyz/evm';
|
|
2
2
|
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
encodePacked,
|
|
6
|
-
isAddress,
|
|
7
|
-
keccak256,
|
|
8
|
-
pad,
|
|
9
|
-
parseEther,
|
|
10
|
-
zeroAddress,
|
|
11
|
-
} from 'viem';
|
|
3
|
+
import { isAddress, pad, parseEther, zeroAddress } from 'viem';
|
|
12
4
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
13
5
|
import { accounts } from '../../test/accounts';
|
|
14
6
|
import {
|
|
@@ -19,11 +11,10 @@ import {
|
|
|
19
11
|
freshBoost,
|
|
20
12
|
fundBudget,
|
|
21
13
|
} from '../../test/helpers';
|
|
22
|
-
import {
|
|
14
|
+
import { BOOST_CORE_CLAIM_FEE } from '../BoostCore';
|
|
15
|
+
import { StrategyType } from '../claiming';
|
|
23
16
|
import { ERC20Incentive } from './ERC20Incentive';
|
|
24
17
|
|
|
25
|
-
const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
|
|
26
|
-
|
|
27
18
|
let fixtures: Fixtures, budgets: BudgetFixtures;
|
|
28
19
|
|
|
29
20
|
describe('ERC20Incentive', () => {
|
|
@@ -65,11 +56,10 @@ describe('ERC20Incentive', () => {
|
|
|
65
56
|
const claimant = trustedSigner.account;
|
|
66
57
|
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
67
58
|
const incentiveQuantity = 1;
|
|
68
|
-
const claimDataPayload = await
|
|
59
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
69
60
|
signer: trustedSigner,
|
|
70
61
|
incentiveData,
|
|
71
62
|
chainId: defaultOptions.config.chains[0].id,
|
|
72
|
-
validator: boost.validator.assertValidAddress(),
|
|
73
63
|
incentiveQuantity,
|
|
74
64
|
claimant,
|
|
75
65
|
boostId: boost.id,
|
|
@@ -109,11 +99,10 @@ describe('ERC20Incentive', () => {
|
|
|
109
99
|
const claimant = trustedSigner.account;
|
|
110
100
|
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
111
101
|
const incentiveQuantity = 1;
|
|
112
|
-
const claimDataPayload = await
|
|
102
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
113
103
|
signer: trustedSigner,
|
|
114
104
|
incentiveData,
|
|
115
105
|
chainId: defaultOptions.config.chains[0].id,
|
|
116
|
-
validator: boost.validator.assertValidAddress(),
|
|
117
106
|
incentiveQuantity,
|
|
118
107
|
claimant,
|
|
119
108
|
boostId: boost.id,
|
|
@@ -124,7 +113,7 @@ describe('ERC20Incentive', () => {
|
|
|
124
113
|
0n,
|
|
125
114
|
referrer,
|
|
126
115
|
claimDataPayload,
|
|
127
|
-
{ value:
|
|
116
|
+
{ value: BOOST_CORE_CLAIM_FEE },
|
|
128
117
|
);
|
|
129
118
|
try {
|
|
130
119
|
await fixtures.core.claimIncentive(
|