@boostxyz/sdk 0.0.0-alpha.8 → 1.1.0-alpha.22
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.cjs.map +1 -1
- package/dist/Actions/Action.js +7 -7
- package/dist/Actions/ContractAction.d.ts +57 -14
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +50 -23
- 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 +420 -45
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +15 -225
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.cjs.map +1 -1
- package/dist/AllowLists/AllowList.d.ts +6 -4
- package/dist/AllowLists/AllowList.d.ts.map +1 -1
- package/dist/AllowLists/AllowList.js +45 -23
- package/dist/AllowLists/AllowList.js.map +1 -1
- package/dist/AllowLists/OpenAllowList.d.ts +423 -0
- package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +123 -39
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +75 -76
- 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 +234 -13
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +11 -200
- 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 +105 -14
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +137 -5
- package/dist/Boost.js.map +1 -1
- package/dist/BoostCore-BVZExPPu.js +1462 -0
- package/dist/BoostCore-BVZExPPu.js.map +1 -0
- package/dist/BoostCore-D-E-cnGI.cjs +3 -0
- package/dist/BoostCore-D-E-cnGI.cjs.map +1 -0
- package/dist/BoostCore.cjs +1 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +759 -82
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +29 -1148
- 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 +83 -28
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +170 -93
- package/dist/BoostRegistry.js.map +1 -1
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.cjs.map +1 -1
- package/dist/Budgets/Budget.d.ts.map +1 -1
- package/dist/Budgets/Budget.js +2 -2
- package/dist/Budgets/Budget.js.map +1 -1
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +112 -192
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +89 -290
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +277 -91
- 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.d.ts +4 -5
- package/dist/Deployable/Contract.d.ts.map +1 -1
- package/dist/Deployable/Contract.js +6 -8
- package/dist/Deployable/Contract.js.map +1 -1
- package/dist/Deployable/Deployable.cjs.map +1 -1
- package/dist/Deployable/Deployable.d.ts +1 -1
- package/dist/Deployable/Deployable.d.ts.map +1 -1
- package/dist/Deployable/Deployable.js +3 -5
- 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 +13 -13
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.js +30 -27
- package/dist/Deployable/DeployableTarget.js.map +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
- package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
- package/dist/EventAction-BZt5cjbe.cjs +2 -0
- package/dist/EventAction-BZt5cjbe.cjs.map +1 -0
- package/dist/EventAction-C_-hJXWm.js +1541 -0
- package/dist/EventAction-C_-hJXWm.js.map +1 -0
- package/dist/Incentive-BhHaK3PZ.cjs +2 -0
- package/dist/Incentive-BhHaK3PZ.cjs.map +1 -0
- package/dist/Incentive-Cqg1w6wD.js +312 -0
- package/dist/Incentive-Cqg1w6wD.js.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts +73 -21
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +61 -36
- 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 +323 -26
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +73 -39
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +291 -43
- 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 +278 -33
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +79 -47
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +346 -420
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +271 -32
- 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.d.ts +4 -4
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +16 -280
- 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 +89 -23
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +66 -36
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
- package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
- package/dist/SimpleDenyList-CGaWjuld.js +132 -0
- package/dist/SimpleDenyList-CGaWjuld.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts +310 -17
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +164 -36
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.cjs.map +1 -1
- package/dist/Validators/Validator.d.ts +1 -1
- package/dist/Validators/Validator.js +2 -2
- package/dist/Validators/Validator.js.map +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/componentInterfaces-BBCFkrZv.js +14 -0
- package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
- package/dist/deployments-DVXioW2i.cjs +2 -0
- package/dist/deployments-DVXioW2i.cjs.map +1 -0
- package/dist/deployments-oykLv3_Z.js +43 -0
- package/dist/deployments-oykLv3_Z.js.map +1 -0
- package/dist/deployments.json +44 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +257 -21
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +183 -26
- package/dist/errors.js.map +1 -1
- package/dist/{generated-Cbv8zFkf.js → generated-CKt2yCQd.js} +3615 -1868
- package/dist/generated-CKt2yCQd.js.map +1 -0
- package/dist/generated-CyTNlOwM.cjs +3 -0
- package/dist/generated-CyTNlOwM.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +143 -126
- package/dist/index.js.map +1 -1
- 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 +25 -1380
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +36 -648
- package/dist/utils.js.map +1 -1
- package/package.json +34 -10
- package/src/Actions/Action.test.ts +19 -17
- package/src/Actions/ContractAction.test.ts +14 -16
- package/src/Actions/ContractAction.ts +84 -22
- package/src/Actions/ERC721MintAction.test.ts +8 -8
- package/src/Actions/ERC721MintAction.ts +83 -30
- package/src/Actions/EventAction.test.ts +759 -113
- package/src/Actions/EventAction.ts +991 -116
- package/src/AllowLists/AllowList.test.ts +7 -7
- package/src/AllowLists/AllowList.ts +5 -3
- package/src/AllowLists/OpenAllowList.test.ts +40 -0
- package/src/AllowLists/OpenAllowList.ts +45 -0
- package/src/AllowLists/SimpleAllowList.test.ts +4 -4
- package/src/AllowLists/SimpleAllowList.ts +86 -65
- package/src/AllowLists/SimpleDenyList.test.ts +4 -4
- package/src/AllowLists/SimpleDenyList.ts +87 -126
- package/src/Auth/PassthroughAuth.test.ts +1 -1
- package/src/Auth/PassthroughAuth.ts +1 -1
- package/src/Boost.ts +147 -15
- package/src/BoostCore.test.ts +326 -278
- package/src/BoostCore.ts +425 -242
- package/src/BoostRegistry.test.ts +53 -0
- package/src/BoostRegistry.ts +168 -50
- package/src/Budgets/Budget.test.ts +2 -2
- package/src/Budgets/Budget.ts +1 -2
- package/src/Budgets/ManagedBudget.test.ts +82 -19
- package/src/Budgets/ManagedBudget.ts +106 -315
- package/src/Budgets/VestingBudget.test.ts +7 -7
- package/src/Budgets/VestingBudget.ts +110 -112
- package/src/Deployable/Contract.ts +5 -6
- package/src/Deployable/Deployable.ts +1 -1
- package/src/Deployable/DeployableTarget.ts +32 -21
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.test.ts +7 -10
- package/src/Incentives/AllowListIncentive.ts +88 -30
- package/src/Incentives/CGDAIncentive.test.ts +11 -12
- package/src/Incentives/CGDAIncentive.ts +161 -37
- package/src/Incentives/ERC1155Incentive.test.ts +5 -16
- package/src/Incentives/ERC1155Incentive.ts +132 -51
- package/src/Incentives/ERC20Incentive.test.ts +15 -23
- package/src/Incentives/ERC20Incentive.ts +131 -46
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +324 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +12 -35
- package/src/Incentives/ERC20VariableIncentive.ts +118 -43
- package/src/Incentives/Incentive.test.ts +5 -2
- package/src/Incentives/Incentive.ts +7 -6
- package/src/Incentives/PointsIncentive.test.ts +26 -30
- package/src/Incentives/PointsIncentive.ts +110 -34
- package/src/Validators/SignerValidator.test.ts +9 -13
- package/src/Validators/SignerValidator.ts +437 -26
- package/src/Validators/Validator.test.ts +2 -2
- package/src/Validators/Validator.ts +1 -1
- package/src/claiming.ts +56 -0
- package/src/errors.ts +346 -22
- package/src/index.test.ts +118 -36
- package/src/index.ts +15 -7
- package/src/transfers.ts +284 -0
- package/src/utils.test.ts +2 -2
- package/src/utils.ts +61 -2061
- package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
- package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
- package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
- package/dist/componentInterfaces-DYkaxBda.js +0 -13
- package/dist/componentInterfaces-DYkaxBda.js.map +0 -1
- package/dist/generated-BzszviNp.cjs +0 -3
- package/dist/generated-BzszviNp.cjs.map +0 -1
- package/dist/generated-Cbv8zFkf.js.map +0 -1
- package/src/Budgets/SimpleBudget.test.ts +0 -152
- package/src/Budgets/SimpleBudget.ts +0 -521
|
@@ -1,9 +1,8 @@
|
|
|
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, zeroAddress } from 'viem';
|
|
5
4
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
6
|
-
import { accounts } from '
|
|
5
|
+
import { accounts } from '@boostxyz/test/accounts';
|
|
7
6
|
import {
|
|
8
7
|
type BudgetFixtures,
|
|
9
8
|
type Fixtures,
|
|
@@ -11,15 +10,14 @@ import {
|
|
|
11
10
|
deployFixtures,
|
|
12
11
|
freshBoost,
|
|
13
12
|
fundBudget,
|
|
14
|
-
} from '
|
|
15
|
-
import { prepareSignerValidatorClaimDataPayload } from '../utils';
|
|
13
|
+
} from '@boostxyz/test/helpers';
|
|
16
14
|
import { CGDAIncentive } from './CGDAIncentive';
|
|
17
15
|
|
|
18
16
|
let fixtures: Fixtures, budgets: BudgetFixtures;
|
|
19
17
|
|
|
20
18
|
describe('CGDAIncentive', () => {
|
|
21
19
|
beforeAll(async () => {
|
|
22
|
-
fixtures = await loadFixture(deployFixtures);
|
|
20
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
23
21
|
});
|
|
24
22
|
|
|
25
23
|
beforeEach(async () => {
|
|
@@ -33,6 +31,7 @@ describe('CGDAIncentive', () => {
|
|
|
33
31
|
totalBudget: 10n,
|
|
34
32
|
rewardBoost: 1n,
|
|
35
33
|
rewardDecay: 1n,
|
|
34
|
+
manager: budgets.budget.address || zeroAddress
|
|
36
35
|
});
|
|
37
36
|
await action.deploy();
|
|
38
37
|
expect(isAddress(action.assertValidAddress())).toBe(true);
|
|
@@ -43,12 +42,13 @@ describe('CGDAIncentive', () => {
|
|
|
43
42
|
const referrer = accounts.at(1)!.account!;
|
|
44
43
|
// biome-ignore lint/style/noNonNullAssertion: we know this is defined
|
|
45
44
|
const trustedSigner = accounts.at(0)!;
|
|
46
|
-
const erc20Incentive =
|
|
45
|
+
const erc20Incentive = fixtures.core.CGDAIncentive({
|
|
47
46
|
asset: budgets.erc20.assertValidAddress(),
|
|
48
47
|
initialReward: 1n,
|
|
49
48
|
totalBudget: 10n,
|
|
50
49
|
rewardBoost: 1n,
|
|
51
50
|
rewardDecay: 1n,
|
|
51
|
+
manager: budgets.budget.assertValidAddress(),
|
|
52
52
|
});
|
|
53
53
|
const boost = await freshBoost(fixtures, {
|
|
54
54
|
budget: budgets.budget,
|
|
@@ -59,11 +59,10 @@ describe('CGDAIncentive', () => {
|
|
|
59
59
|
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
60
60
|
|
|
61
61
|
const incentiveQuantity = 1;
|
|
62
|
-
const claimDataPayload = await
|
|
62
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
63
63
|
signer: trustedSigner,
|
|
64
64
|
incentiveData,
|
|
65
65
|
chainId: defaultOptions.config.chains[0].id,
|
|
66
|
-
validator: boost.validator.assertValidAddress(),
|
|
67
66
|
incentiveQuantity,
|
|
68
67
|
claimant,
|
|
69
68
|
boostId: boost.id,
|
|
@@ -89,12 +88,13 @@ describe('CGDAIncentive', () => {
|
|
|
89
88
|
const referrer = accounts.at(1)!.account!;
|
|
90
89
|
// biome-ignore lint/style/noNonNullAssertion: we know this is defined
|
|
91
90
|
const trustedSigner = accounts.at(0)!;
|
|
92
|
-
const erc20Incentive =
|
|
91
|
+
const erc20Incentive = fixtures.core.CGDAIncentive({
|
|
93
92
|
asset: budgets.erc20.assertValidAddress(),
|
|
94
93
|
initialReward: 1n,
|
|
95
94
|
totalBudget: 10n,
|
|
96
95
|
rewardBoost: 1n,
|
|
97
96
|
rewardDecay: 1n,
|
|
97
|
+
manager: budgets.budget.address || zeroAddress
|
|
98
98
|
});
|
|
99
99
|
const boost = await freshBoost(fixtures, {
|
|
100
100
|
budget: budgets.budget,
|
|
@@ -104,11 +104,10 @@ describe('CGDAIncentive', () => {
|
|
|
104
104
|
const claimant = trustedSigner.account;
|
|
105
105
|
const incentiveData = pad('0xdef456232173821931823712381232131391321934');
|
|
106
106
|
const incentiveQuantity = 1;
|
|
107
|
-
const claimDataPayload = await
|
|
107
|
+
const claimDataPayload = await boost.validator.encodeClaimData({
|
|
108
108
|
signer: trustedSigner,
|
|
109
109
|
incentiveData,
|
|
110
110
|
chainId: defaultOptions.config.chains[0].id,
|
|
111
|
-
validator: boost.validator.assertValidAddress(),
|
|
112
111
|
incentiveQuantity,
|
|
113
112
|
claimant,
|
|
114
113
|
boostId: boost.id,
|
|
@@ -15,26 +15,108 @@ 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
|
+
zeroHash,
|
|
24
|
+
} from 'viem';
|
|
25
|
+
import { CGDAIncentive as CGDAIncentiveBases } from '../../dist/deployments.json';
|
|
19
26
|
import type {
|
|
20
27
|
DeployableOptions,
|
|
21
28
|
GenericDeployableParams,
|
|
22
29
|
} from '../Deployable/Deployable';
|
|
23
30
|
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
31
|
+
import { type ClaimPayload, prepareClaimPayload } from '../claiming';
|
|
24
32
|
import {
|
|
25
|
-
type CGDAIncentivePayload,
|
|
26
|
-
type CGDAParameters,
|
|
27
|
-
type ClaimPayload,
|
|
28
33
|
type GenericLog,
|
|
29
34
|
type ReadParams,
|
|
30
35
|
RegistryType,
|
|
31
36
|
type WriteParams,
|
|
32
|
-
prepareCGDAIncentivePayload,
|
|
33
|
-
prepareClaimPayload,
|
|
34
37
|
} from '../utils';
|
|
35
38
|
|
|
36
39
|
export { cgdaIncentiveAbi };
|
|
37
|
-
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The object representation of a `CGDAIncentive.InitPayload`
|
|
43
|
+
*
|
|
44
|
+
* @export
|
|
45
|
+
* @interface CGDAIncentivePayload
|
|
46
|
+
* @typedef {CGDAIncentivePayload}
|
|
47
|
+
*/
|
|
48
|
+
export interface CGDAIncentivePayload {
|
|
49
|
+
/**
|
|
50
|
+
* The address of the ERC20-like token
|
|
51
|
+
*
|
|
52
|
+
* @type {Address}
|
|
53
|
+
*/
|
|
54
|
+
asset: Address;
|
|
55
|
+
/**
|
|
56
|
+
* The initial reward amount
|
|
57
|
+
*
|
|
58
|
+
* @type {bigint}
|
|
59
|
+
*/
|
|
60
|
+
initialReward: bigint;
|
|
61
|
+
/**
|
|
62
|
+
* The amount to subtract from the current reward after each claim
|
|
63
|
+
*
|
|
64
|
+
* @type {bigint}
|
|
65
|
+
*/
|
|
66
|
+
rewardDecay: bigint;
|
|
67
|
+
/**
|
|
68
|
+
* The amount by which the reward increases for each hour without a claim (continuous linear increase)
|
|
69
|
+
*
|
|
70
|
+
* @type {bigint}
|
|
71
|
+
*/
|
|
72
|
+
rewardBoost: bigint;
|
|
73
|
+
/**
|
|
74
|
+
* The total budget for the incentive
|
|
75
|
+
*
|
|
76
|
+
* @type {bigint}
|
|
77
|
+
*/
|
|
78
|
+
totalBudget: bigint;
|
|
79
|
+
/**
|
|
80
|
+
* The entity that can `clawback` funds
|
|
81
|
+
*
|
|
82
|
+
* @type {Address}
|
|
83
|
+
*/
|
|
84
|
+
manager: Address;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The configuration parameters for the CGDAIncentive
|
|
89
|
+
*
|
|
90
|
+
* @export
|
|
91
|
+
* @interface CGDAParameters
|
|
92
|
+
* @typedef {CGDAParameters}
|
|
93
|
+
*/
|
|
94
|
+
export interface CGDAParameters {
|
|
95
|
+
/**
|
|
96
|
+
* The amount to subtract from the current reward after each claim
|
|
97
|
+
*
|
|
98
|
+
* @type {bigint}
|
|
99
|
+
*/
|
|
100
|
+
rewardDecay: bigint;
|
|
101
|
+
/**
|
|
102
|
+
* The amount by which the reward increases for each hour without a claim (continuous linear increase)
|
|
103
|
+
*
|
|
104
|
+
* @type {bigint}
|
|
105
|
+
*/
|
|
106
|
+
rewardBoost: bigint;
|
|
107
|
+
/**
|
|
108
|
+
* The timestamp of the last claim
|
|
109
|
+
*
|
|
110
|
+
* @type {bigint}
|
|
111
|
+
*/
|
|
112
|
+
lastClaimTime: bigint;
|
|
113
|
+
/**
|
|
114
|
+
* The current reward amount
|
|
115
|
+
*
|
|
116
|
+
* @type {bigint}
|
|
117
|
+
*/
|
|
118
|
+
currentReward: bigint;
|
|
119
|
+
}
|
|
38
120
|
|
|
39
121
|
/**
|
|
40
122
|
* A generic `viem.Log` event with support for `CGDAIncentive` event types.
|
|
@@ -70,10 +152,11 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
70
152
|
*
|
|
71
153
|
* @public
|
|
72
154
|
* @static
|
|
73
|
-
* @type {Address}
|
|
155
|
+
* @type {Record<number, Address>}
|
|
74
156
|
*/
|
|
75
|
-
public static override
|
|
76
|
-
|
|
157
|
+
public static override bases: Record<number, Address> = {
|
|
158
|
+
...(CGDAIncentiveBases as Record<number, Address>),
|
|
159
|
+
};
|
|
77
160
|
/**
|
|
78
161
|
* @inheritdoc
|
|
79
162
|
*
|
|
@@ -88,11 +171,11 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
88
171
|
*
|
|
89
172
|
* @public
|
|
90
173
|
* @async
|
|
91
|
-
* @param {?ReadParams
|
|
92
|
-
* @returns {
|
|
174
|
+
* @param {?ReadParams} [params]
|
|
175
|
+
* @returns {Promise<Address>}
|
|
93
176
|
*/
|
|
94
177
|
public async owner(params?: ReadParams<typeof cgdaIncentiveAbi, 'owner'>) {
|
|
95
|
-
return readCgdaIncentiveOwner(this._config, {
|
|
178
|
+
return await readCgdaIncentiveOwner(this._config, {
|
|
96
179
|
address: this.assertValidAddress(),
|
|
97
180
|
args: [],
|
|
98
181
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -105,11 +188,11 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
105
188
|
*
|
|
106
189
|
* @public
|
|
107
190
|
* @async
|
|
108
|
-
* @param {?ReadParams
|
|
191
|
+
* @param {?ReadParams} [params]
|
|
109
192
|
* @returns {Promise<bigint>}
|
|
110
193
|
*/
|
|
111
194
|
public async claims(params?: ReadParams<typeof cgdaIncentiveAbi, 'claims'>) {
|
|
112
|
-
return readCgdaIncentiveClaims(this._config, {
|
|
195
|
+
return await readCgdaIncentiveClaims(this._config, {
|
|
113
196
|
address: this.assertValidAddress(),
|
|
114
197
|
args: [],
|
|
115
198
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -122,11 +205,11 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
122
205
|
*
|
|
123
206
|
* @public
|
|
124
207
|
* @async
|
|
125
|
-
* @param {?ReadParams
|
|
208
|
+
* @param {?ReadParams} [params]
|
|
126
209
|
* @returns {Promise<bigint>}
|
|
127
210
|
*/
|
|
128
211
|
public async reward(params?: ReadParams<typeof cgdaIncentiveAbi, 'reward'>) {
|
|
129
|
-
return readCgdaIncentiveReward(this._config, {
|
|
212
|
+
return await readCgdaIncentiveReward(this._config, {
|
|
130
213
|
address: this.assertValidAddress(),
|
|
131
214
|
args: [],
|
|
132
215
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -140,14 +223,14 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
140
223
|
* @public
|
|
141
224
|
* @async
|
|
142
225
|
* @param {Address} address
|
|
143
|
-
* @param {?ReadParams
|
|
226
|
+
* @param {?ReadParams} [params]
|
|
144
227
|
* @returns {Promise<boolean>}
|
|
145
228
|
*/
|
|
146
229
|
public async claimed(
|
|
147
230
|
address: Address,
|
|
148
231
|
params?: ReadParams<typeof cgdaIncentiveAbi, 'claimed'>,
|
|
149
232
|
) {
|
|
150
|
-
return readCgdaIncentiveClaimed(this._config, {
|
|
233
|
+
return await readCgdaIncentiveClaimed(this._config, {
|
|
151
234
|
address: this.assertValidAddress(),
|
|
152
235
|
args: [address],
|
|
153
236
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -160,11 +243,11 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
160
243
|
*
|
|
161
244
|
* @public
|
|
162
245
|
* @async
|
|
163
|
-
* @param {?ReadParams
|
|
164
|
-
* @returns {
|
|
246
|
+
* @param {?ReadParams} [params]
|
|
247
|
+
* @returns {Promise<Address>}
|
|
165
248
|
*/
|
|
166
249
|
public async asset(params?: ReadParams<typeof cgdaIncentiveAbi, 'asset'>) {
|
|
167
|
-
return readCgdaIncentiveAsset(this._config, {
|
|
250
|
+
return await readCgdaIncentiveAsset(this._config, {
|
|
168
251
|
address: this.assertValidAddress(),
|
|
169
252
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
170
253
|
...(params as any),
|
|
@@ -176,7 +259,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
176
259
|
*
|
|
177
260
|
* @public
|
|
178
261
|
* @async
|
|
179
|
-
* @param {?ReadParams
|
|
262
|
+
* @param {?ReadParams} [params]
|
|
180
263
|
* @returns {Promise<CGDAParameters>}
|
|
181
264
|
*/
|
|
182
265
|
public async cgdaParams(
|
|
@@ -201,13 +284,13 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
201
284
|
*
|
|
202
285
|
* @public
|
|
203
286
|
* @async
|
|
204
|
-
* @param {?ReadParams
|
|
287
|
+
* @param {?ReadParams} [params]
|
|
205
288
|
* @returns {Promise<bigint>}
|
|
206
289
|
*/
|
|
207
290
|
public async totalBudget(
|
|
208
291
|
params?: ReadParams<typeof cgdaIncentiveAbi, 'totalBudget'>,
|
|
209
292
|
) {
|
|
210
|
-
return readCgdaIncentiveTotalBudget(this._config, {
|
|
293
|
+
return await readCgdaIncentiveTotalBudget(this._config, {
|
|
211
294
|
address: this.assertValidAddress(),
|
|
212
295
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
213
296
|
...(params as any),
|
|
@@ -220,14 +303,14 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
220
303
|
* @public
|
|
221
304
|
* @async
|
|
222
305
|
* @param {ClaimPayload} payload
|
|
223
|
-
* @param {?WriteParams
|
|
306
|
+
* @param {?WriteParams} [params]
|
|
224
307
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
225
308
|
*/
|
|
226
|
-
|
|
309
|
+
protected async claim(
|
|
227
310
|
payload: ClaimPayload,
|
|
228
311
|
params?: WriteParams<typeof cgdaIncentiveAbi, 'claim'>,
|
|
229
312
|
) {
|
|
230
|
-
return this.awaitResult(this.claimRaw(payload, params));
|
|
313
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
231
314
|
}
|
|
232
315
|
|
|
233
316
|
/**
|
|
@@ -236,10 +319,10 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
236
319
|
* @public
|
|
237
320
|
* @async
|
|
238
321
|
* @param {ClaimPayload} payload
|
|
239
|
-
* @param {?WriteParams
|
|
322
|
+
* @param {?WriteParams} [params]
|
|
240
323
|
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
241
324
|
*/
|
|
242
|
-
|
|
325
|
+
protected async claimRaw(
|
|
243
326
|
payload: ClaimPayload,
|
|
244
327
|
params?: WriteParams<typeof cgdaIncentiveAbi, 'claim'>,
|
|
245
328
|
) {
|
|
@@ -260,14 +343,14 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
260
343
|
* @public
|
|
261
344
|
* @async
|
|
262
345
|
* @param {ClaimPayload} payload
|
|
263
|
-
* @param {?WriteParams
|
|
346
|
+
* @param {?WriteParams} [params]
|
|
264
347
|
* @returns {Promise<boolean>} - True if the assets were successfully clawbacked
|
|
265
348
|
*/
|
|
266
349
|
public async clawback(
|
|
267
350
|
payload: ClaimPayload,
|
|
268
351
|
params?: WriteParams<typeof cgdaIncentiveAbi, 'clawback'>,
|
|
269
352
|
) {
|
|
270
|
-
return this.awaitResult(this.clawbackRaw(payload, params));
|
|
353
|
+
return await this.awaitResult(this.clawbackRaw(payload, params));
|
|
271
354
|
}
|
|
272
355
|
|
|
273
356
|
/**
|
|
@@ -276,7 +359,7 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
276
359
|
* @public
|
|
277
360
|
* @async
|
|
278
361
|
* @param {ClaimPayload} payload
|
|
279
|
-
* @param {?WriteParams
|
|
362
|
+
* @param {?WriteParams} [params]
|
|
280
363
|
* @returns {Promise<boolean>} - True if the assets were successfully clawbacked
|
|
281
364
|
*/
|
|
282
365
|
public async clawbackRaw(
|
|
@@ -303,14 +386,14 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
303
386
|
* @public
|
|
304
387
|
* @async
|
|
305
388
|
* @param {ClaimPayload} payload
|
|
306
|
-
* @param {?ReadParams
|
|
389
|
+
* @param {?ReadParams} [params]
|
|
307
390
|
* @returns {Promise<boolean>} - True if the incentive is claimable based on the data payload
|
|
308
391
|
*/
|
|
309
392
|
public async isClaimable(
|
|
310
393
|
payload: ClaimPayload,
|
|
311
394
|
params?: ReadParams<typeof cgdaIncentiveAbi, 'isClaimable'>,
|
|
312
395
|
) {
|
|
313
|
-
return readCgdaIncentiveIsClaimable(this._config, {
|
|
396
|
+
return await readCgdaIncentiveIsClaimable(this._config, {
|
|
314
397
|
address: this.assertValidAddress(),
|
|
315
398
|
args: [prepareClaimPayload(payload)],
|
|
316
399
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -325,13 +408,13 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
325
408
|
*
|
|
326
409
|
* @public
|
|
327
410
|
* @async
|
|
328
|
-
* @param {?ReadParams
|
|
411
|
+
* @param {?ReadParams} [params]
|
|
329
412
|
* @returns {Promise<bigint>} - The current reward
|
|
330
413
|
*/
|
|
331
414
|
public async currentReward(
|
|
332
415
|
params?: ReadParams<typeof cgdaIncentiveAbi, 'currentReward'>,
|
|
333
416
|
) {
|
|
334
|
-
return readCgdaIncentiveCurrentReward(this._config, {
|
|
417
|
+
return await readCgdaIncentiveCurrentReward(this._config, {
|
|
335
418
|
address: this.assertValidAddress(),
|
|
336
419
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
337
420
|
...(params as any),
|
|
@@ -361,4 +444,45 @@ export class CGDAIncentive extends DeployableTarget<
|
|
|
361
444
|
...this.optionallyAttachAccount(options.account),
|
|
362
445
|
};
|
|
363
446
|
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Builds the claim data for the CGDAIncentive.
|
|
450
|
+
*
|
|
451
|
+
* @public
|
|
452
|
+
* @returns {Hash} A `zeroHash`, as CGDAIncentive doesn't require specific claim data.
|
|
453
|
+
* @description This function returns `zeroHash` because CGDAIncentive doesn't use any specific claim data.
|
|
454
|
+
*/
|
|
455
|
+
public buildClaimData() {
|
|
456
|
+
return zeroHash;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Given a {@link CGDAIncentivePayload}, properly encode a `CGDAIncentive.InitPayload` for use with {@link CGDAIncentive} initialization.
|
|
462
|
+
*
|
|
463
|
+
* @param {CGDAIncentivePayload} param0
|
|
464
|
+
* @param {Address} param0.asset - The address of the ERC20-like token
|
|
465
|
+
* @param {bigint} param0.initialReward - The initial reward amount
|
|
466
|
+
* @param {bigint} param0.rewardDecay - The amount to subtract from the current reward after each claim
|
|
467
|
+
* @param {bigint} param0.rewardBoost - The amount by which the reward increases for each hour without a claim (continuous linear increase)
|
|
468
|
+
* @param {bigint} param0.totalBudget - The total budget for the incentive
|
|
469
|
+
* @returns {Hex}
|
|
470
|
+
*/
|
|
471
|
+
export function prepareCGDAIncentivePayload({
|
|
472
|
+
asset,
|
|
473
|
+
initialReward,
|
|
474
|
+
rewardDecay,
|
|
475
|
+
rewardBoost,
|
|
476
|
+
totalBudget,
|
|
477
|
+
}: CGDAIncentivePayload) {
|
|
478
|
+
return encodeAbiParameters(
|
|
479
|
+
[
|
|
480
|
+
{ type: 'address', name: 'asset' },
|
|
481
|
+
{ type: 'uint256', name: 'initialReward' },
|
|
482
|
+
{ type: 'uint256', name: 'rewardDecay' },
|
|
483
|
+
{ type: 'uint256', name: 'rewardBoost' },
|
|
484
|
+
{ type: 'uint256', name: 'totalBudget' },
|
|
485
|
+
],
|
|
486
|
+
[asset, initialReward, rewardDecay, rewardBoost, totalBudget],
|
|
487
|
+
);
|
|
364
488
|
}
|
|
@@ -1,17 +1,8 @@
|
|
|
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
|
-
import { accounts } from '
|
|
5
|
+
import { accounts } from '@boostxyz/test/accounts';
|
|
15
6
|
import {
|
|
16
7
|
type BudgetFixtures,
|
|
17
8
|
type Fixtures,
|
|
@@ -19,8 +10,7 @@ import {
|
|
|
19
10
|
deployFixtures,
|
|
20
11
|
freshBoost,
|
|
21
12
|
fundBudget,
|
|
22
|
-
} from '
|
|
23
|
-
import { prepareSignerValidatorClaimDataPayload } from '../utils';
|
|
13
|
+
} from '@boostxyz/test/helpers';
|
|
24
14
|
import { ERC1155Incentive, ERC1155StrategyType } from './ERC1155Incentive';
|
|
25
15
|
|
|
26
16
|
const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
|
|
@@ -29,7 +19,7 @@ let fixtures: Fixtures, budgets: BudgetFixtures;
|
|
|
29
19
|
|
|
30
20
|
describe.skip('ERC1155Incentive', () => {
|
|
31
21
|
beforeAll(async () => {
|
|
32
|
-
fixtures = await loadFixture(deployFixtures);
|
|
22
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
33
23
|
});
|
|
34
24
|
|
|
35
25
|
beforeEach(async () => {
|
|
@@ -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,
|