@boostxyz/sdk 0.0.0-alpha.8 → 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 -12
- 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.js +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +31 -2
- 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 +12 -6
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +168 -166
- 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 +4 -4
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +19 -24
- 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/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.cjs.map +1 -1
- package/dist/Deployable/DeployableTarget.js +3 -3
- 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.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/{generated-Cbv8zFkf.js → generated-57_Kffpz.js} +8 -5
- package/dist/generated-57_Kffpz.js.map +1 -0
- package/dist/{generated-BzszviNp.cjs → generated-wKBNvm48.cjs} +2 -2
- 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 -125
- 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 +452 -35
- package/src/AllowLists/SimpleAllowList.ts +48 -5
- 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 +39 -33
- package/src/BoostRegistry.ts +19 -22
- 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/DeployableTarget.ts +2 -2
- 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 +1 -1
- package/src/index.ts +10 -7
- package/src/transfers.ts +284 -0
- package/src/utils.ts +3 -2052
- package/dist/generated-BzszviNp.cjs.map +0 -1
- package/dist/generated-Cbv8zFkf.js.map +0 -1
|
@@ -11,26 +11,49 @@ import {
|
|
|
11
11
|
writeAllowListIncentiveClaim,
|
|
12
12
|
} from '@boostxyz/evm';
|
|
13
13
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/AllowListIncentive.sol/AllowListIncentive.json';
|
|
14
|
-
import
|
|
14
|
+
import {
|
|
15
|
+
type Address,
|
|
16
|
+
type ContractEventName,
|
|
17
|
+
type Hex,
|
|
18
|
+
encodeAbiParameters,
|
|
19
|
+
} from 'viem';
|
|
15
20
|
import { SimpleAllowList } from '../AllowLists/AllowList';
|
|
16
21
|
import type {
|
|
17
22
|
DeployableOptions,
|
|
18
23
|
GenericDeployableParams,
|
|
19
24
|
} from '../Deployable/Deployable';
|
|
20
25
|
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
26
|
+
import { type ClaimPayload, prepareClaimPayload } from '../claiming';
|
|
21
27
|
import {
|
|
22
|
-
type AllowListIncentivePayload,
|
|
23
|
-
type ClaimPayload,
|
|
24
28
|
type GenericLog,
|
|
25
29
|
type ReadParams,
|
|
26
30
|
RegistryType,
|
|
27
31
|
type WriteParams,
|
|
28
|
-
prepareAllowListIncentivePayload,
|
|
29
|
-
prepareClaimPayload,
|
|
30
32
|
} from '../utils';
|
|
31
33
|
|
|
32
34
|
export { allowListIncentiveAbi };
|
|
33
|
-
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The object representation of a `AllowListIncentive.InitPayload`
|
|
38
|
+
*
|
|
39
|
+
* @export
|
|
40
|
+
* @interface AllowListIncentivePayload
|
|
41
|
+
* @typedef {AllowListIncentivePayload}
|
|
42
|
+
*/
|
|
43
|
+
export interface AllowListIncentivePayload {
|
|
44
|
+
/**
|
|
45
|
+
* The address to the allowlist to add claimers to.
|
|
46
|
+
*
|
|
47
|
+
* @type {Address}
|
|
48
|
+
*/
|
|
49
|
+
allowList: Address;
|
|
50
|
+
/**
|
|
51
|
+
* The maximum number of claims that can be made (one per address)
|
|
52
|
+
*
|
|
53
|
+
* @type {bigint}
|
|
54
|
+
*/
|
|
55
|
+
limit: bigint;
|
|
56
|
+
}
|
|
34
57
|
|
|
35
58
|
/**
|
|
36
59
|
* A generic `viem.Log` event with support for `AllowListIncentive` event types.
|
|
@@ -93,7 +116,7 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
93
116
|
public async owner(
|
|
94
117
|
params?: ReadParams<typeof allowListIncentiveAbi, 'owner'>,
|
|
95
118
|
) {
|
|
96
|
-
return readAllowListIncentiveOwner(this._config, {
|
|
119
|
+
return await readAllowListIncentiveOwner(this._config, {
|
|
97
120
|
address: this.assertValidAddress(),
|
|
98
121
|
args: [],
|
|
99
122
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -112,7 +135,7 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
112
135
|
public async claims(
|
|
113
136
|
params?: ReadParams<typeof allowListIncentiveAbi, 'claims'>,
|
|
114
137
|
) {
|
|
115
|
-
return readAllowListIncentiveClaims(this._config, {
|
|
138
|
+
return await readAllowListIncentiveClaims(this._config, {
|
|
116
139
|
address: this.assertValidAddress(),
|
|
117
140
|
args: [],
|
|
118
141
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -131,7 +154,7 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
131
154
|
public async reward(
|
|
132
155
|
params?: ReadParams<typeof allowListIncentiveAbi, 'reward'>,
|
|
133
156
|
) {
|
|
134
|
-
return readAllowListIncentiveReward(this._config, {
|
|
157
|
+
return await readAllowListIncentiveReward(this._config, {
|
|
135
158
|
address: this.assertValidAddress(),
|
|
136
159
|
args: [],
|
|
137
160
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -152,7 +175,7 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
152
175
|
address: Address,
|
|
153
176
|
params?: ReadParams<typeof allowListIncentiveAbi, 'claimed'>,
|
|
154
177
|
) {
|
|
155
|
-
return readAllowListIncentiveClaimed(this._config, {
|
|
178
|
+
return await readAllowListIncentiveClaimed(this._config, {
|
|
156
179
|
address: this.assertValidAddress(),
|
|
157
180
|
args: [address],
|
|
158
181
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -193,7 +216,7 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
193
216
|
public async limit(
|
|
194
217
|
params?: ReadParams<typeof allowListIncentiveAbi, 'limit'>,
|
|
195
218
|
) {
|
|
196
|
-
return readAllowListIncentiveLimit(this._config, {
|
|
219
|
+
return await readAllowListIncentiveLimit(this._config, {
|
|
197
220
|
address: this.assertValidAddress(),
|
|
198
221
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
199
222
|
...(params as any),
|
|
@@ -209,11 +232,11 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
209
232
|
* @param {?WriteParams<typeof allowListIncentiveAbi, 'claim'>} [params]
|
|
210
233
|
* @returns {Promise<true>} - return true if successful, otherwise revert
|
|
211
234
|
*/
|
|
212
|
-
|
|
235
|
+
protected async claim(
|
|
213
236
|
payload: Pick<ClaimPayload, 'target'>,
|
|
214
237
|
params?: WriteParams<typeof allowListIncentiveAbi, 'claim'>,
|
|
215
238
|
) {
|
|
216
|
-
return this.awaitResult(this.claimRaw(payload, params));
|
|
239
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
217
240
|
}
|
|
218
241
|
|
|
219
242
|
/**
|
|
@@ -225,7 +248,7 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
225
248
|
* @param {?WriteParams<typeof allowListIncentiveAbi, 'claim'>} [params]
|
|
226
249
|
* @returns {Promise<true>} - return true if successful, otherwise revert
|
|
227
250
|
*/
|
|
228
|
-
|
|
251
|
+
protected async claimRaw(
|
|
229
252
|
payload: Pick<ClaimPayload, 'target'>,
|
|
230
253
|
params?: WriteParams<typeof allowListIncentiveAbi, 'claim'>,
|
|
231
254
|
) {
|
|
@@ -256,7 +279,7 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
256
279
|
payload: Pick<ClaimPayload, 'target'>,
|
|
257
280
|
params?: ReadParams<typeof allowListIncentiveAbi, 'isClaimable'>,
|
|
258
281
|
) {
|
|
259
|
-
return readAllowListIncentiveIsClaimable(this._config, {
|
|
282
|
+
return await readAllowListIncentiveIsClaimable(this._config, {
|
|
260
283
|
address: this.assertValidAddress(),
|
|
261
284
|
args: [prepareClaimPayload(payload)],
|
|
262
285
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -288,3 +311,24 @@ export class AllowListIncentive extends DeployableTarget<
|
|
|
288
311
|
};
|
|
289
312
|
}
|
|
290
313
|
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Given a {@link AllowListIncentivePayload}, properly encode a `AllowListIncentive.InitPayload` for use with {@link AllowListIncentive} initialization.
|
|
317
|
+
*
|
|
318
|
+
* @param {AllowListIncentivePayload} param0
|
|
319
|
+
* @param {Address} param0.allowList - The address to the allowlist to add claimers to.
|
|
320
|
+
* @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
|
|
321
|
+
* @returns {Hex}
|
|
322
|
+
*/
|
|
323
|
+
export const prepareAllowListIncentivePayload = ({
|
|
324
|
+
allowList,
|
|
325
|
+
limit,
|
|
326
|
+
}: AllowListIncentivePayload) => {
|
|
327
|
+
return encodeAbiParameters(
|
|
328
|
+
[
|
|
329
|
+
{ type: 'address', name: 'allowList' },
|
|
330
|
+
{ type: 'uint256', name: 'limit' },
|
|
331
|
+
],
|
|
332
|
+
[allowList, limit],
|
|
333
|
+
);
|
|
334
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { readMockErc20BalanceOf } from '@boostxyz/evm';
|
|
2
2
|
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
3
|
-
import {
|
|
4
|
-
import { encodePacked, isAddress, keccak256, pad, parseEther } from 'viem';
|
|
3
|
+
import { isAddress, pad, parseEther } from 'viem';
|
|
5
4
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
6
5
|
import { accounts } from '../../test/accounts';
|
|
7
6
|
import {
|
|
@@ -12,7 +11,6 @@ import {
|
|
|
12
11
|
freshBoost,
|
|
13
12
|
fundBudget,
|
|
14
13
|
} from '../../test/helpers';
|
|
15
|
-
import { prepareSignerValidatorClaimDataPayload } from '../utils';
|
|
16
14
|
import { CGDAIncentive } from './CGDAIncentive';
|
|
17
15
|
|
|
18
16
|
let fixtures: Fixtures, budgets: BudgetFixtures;
|
|
@@ -59,11 +57,10 @@ describe('CGDAIncentive', () => {
|
|
|
59
57
|
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
60
58
|
|
|
61
59
|
const incentiveQuantity = 1;
|
|
62
|
-
const claimDataPayload = await
|
|
60
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
63
61
|
signer: trustedSigner,
|
|
64
62
|
incentiveData,
|
|
65
63
|
chainId: defaultOptions.config.chains[0].id,
|
|
66
|
-
validator: boost.validator.assertValidAddress(),
|
|
67
64
|
incentiveQuantity,
|
|
68
65
|
claimant,
|
|
69
66
|
boostId: boost.id,
|
|
@@ -104,11 +101,10 @@ describe('CGDAIncentive', () => {
|
|
|
104
101
|
const claimant = trustedSigner.account;
|
|
105
102
|
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
106
103
|
const incentiveQuantity = 1;
|
|
107
|
-
const claimDataPayload = await
|
|
104
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
108
105
|
signer: trustedSigner,
|
|
109
106
|
incentiveData,
|
|
110
107
|
chainId: defaultOptions.config.chains[0].id,
|
|
111
|
-
validator: boost.validator.assertValidAddress(),
|
|
112
108
|
incentiveQuantity,
|
|
113
109
|
claimant,
|
|
114
110
|
boostId: boost.id,
|
|
@@ -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,
|