@boostxyz/sdk 0.0.0-alpha.2 → 0.0.0-alpha.21
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 +2 -1
- package/dist/Actions/Action.cjs.map +1 -0
- package/dist/Actions/Action.d.ts +1 -1
- package/dist/Actions/Action.d.ts.map +1 -1
- package/dist/Actions/Action.js +14 -12
- package/dist/Actions/Action.js.map +1 -0
- 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 +2 -1
- package/dist/Actions/EventAction.cjs.map +1 -0
- package/dist/Actions/EventAction.d.ts +405 -36
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +15 -209
- package/dist/Actions/EventAction.js.map +1 -0
- package/dist/AllowLists/AllowList.cjs +2 -1
- package/dist/AllowLists/AllowList.cjs.map +1 -0
- package/dist/AllowLists/AllowList.d.ts +6 -5
- package/dist/AllowLists/AllowList.d.ts.map +1 -1
- package/dist/AllowLists/AllowList.js +46 -22
- package/dist/AllowLists/AllowList.js.map +1 -0
- package/dist/AllowLists/OpenAllowList.d.ts +423 -0
- package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleAllowList.cjs +2 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
- package/dist/AllowLists/SimpleAllowList.d.ts +124 -40
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +76 -76
- package/dist/AllowLists/SimpleAllowList.js.map +1 -0
- package/dist/AllowLists/SimpleDenyList.cjs +2 -1
- package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
- package/dist/AllowLists/SimpleDenyList.d.ts +234 -13
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +12 -200
- package/dist/AllowLists/SimpleDenyList.js.map +1 -0
- package/dist/Auth/Auth.cjs +1 -0
- package/dist/Auth/Auth.cjs.map +1 -0
- package/dist/Auth/Auth.js +1 -0
- package/dist/Auth/Auth.js.map +1 -0
- package/dist/Auth/PassthroughAuth.cjs +2 -1
- package/dist/Auth/PassthroughAuth.cjs.map +1 -0
- package/dist/Auth/PassthroughAuth.js +5 -4
- package/dist/Auth/PassthroughAuth.js.map +1 -0
- package/dist/Boost.cjs +2 -1
- package/dist/Boost.cjs.map +1 -0
- package/dist/Boost.d.ts +105 -14
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +138 -5
- package/dist/Boost.js.map +1 -0
- package/dist/BoostCore-DolmDuXW.cjs +3 -0
- package/dist/BoostCore-DolmDuXW.cjs.map +1 -0
- package/dist/BoostCore-Z97KVu4V.js +1448 -0
- package/dist/BoostCore-Z97KVu4V.js.map +1 -0
- package/dist/BoostCore.cjs +2 -2
- package/dist/BoostCore.cjs.map +1 -0
- package/dist/BoostCore.d.ts +788 -79
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +30 -1103
- package/dist/BoostCore.js.map +1 -0
- package/dist/BoostRegistry.cjs +2 -1
- package/dist/BoostRegistry.cjs.map +1 -0
- package/dist/BoostRegistry.d.ts +95 -26
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +183 -89
- package/dist/BoostRegistry.js.map +1 -0
- package/dist/Budgets/Budget.cjs +2 -1
- package/dist/Budgets/Budget.cjs.map +1 -0
- package/dist/Budgets/Budget.d.ts +1 -1
- package/dist/Budgets/Budget.d.ts.map +1 -1
- package/dist/Budgets/Budget.js +15 -13
- package/dist/Budgets/Budget.js.map +1 -0
- package/dist/Budgets/ManagedBudget.cjs +2 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -0
- package/dist/Budgets/ManagedBudget.d.ts +112 -192
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +91 -291
- package/dist/Budgets/ManagedBudget.js.map +1 -0
- package/dist/Budgets/VestingBudget.d.ts +277 -91
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/Contract.cjs +2 -1
- package/dist/Deployable/Contract.cjs.map +1 -0
- package/dist/Deployable/Contract.d.ts +4 -5
- package/dist/Deployable/Contract.d.ts.map +1 -1
- package/dist/Deployable/Contract.js +7 -8
- package/dist/Deployable/Contract.js.map +1 -0
- package/dist/Deployable/Deployable.cjs +1 -0
- package/dist/Deployable/Deployable.cjs.map +1 -0
- package/dist/Deployable/Deployable.d.ts +9 -3
- package/dist/Deployable/Deployable.d.ts.map +1 -1
- package/dist/Deployable/Deployable.js +10 -5
- package/dist/Deployable/Deployable.js.map +1 -0
- package/dist/Deployable/DeployableTarget.cjs +2 -1
- package/dist/Deployable/DeployableTarget.cjs.map +1 -0
- package/dist/Deployable/DeployableTarget.d.ts +16 -15
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.js +49 -42
- package/dist/Deployable/DeployableTarget.js.map +1 -0
- 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-CBKzuNoN.cjs +2 -0
- package/dist/EventAction-CBKzuNoN.cjs.map +1 -0
- package/dist/EventAction-DWuuc_Qy.js +1528 -0
- package/dist/EventAction-DWuuc_Qy.js.map +1 -0
- package/dist/Incentive-BxzEtN26.js +298 -0
- package/dist/Incentive-BxzEtN26.js.map +1 -0
- package/dist/Incentive-CrF3-ayL.cjs +2 -0
- package/dist/Incentive-CrF3-ayL.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +2 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.d.ts +65 -21
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +52 -36
- package/dist/Incentives/AllowListIncentive.js.map +1 -0
- package/dist/Incentives/CGDAIncentive.cjs +2 -1
- package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
- package/dist/Incentives/CGDAIncentive.d.ts +315 -26
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +64 -39
- package/dist/Incentives/CGDAIncentive.js.map +1 -0
- package/dist/Incentives/ERC1155Incentive.d.ts +291 -43
- package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.cjs +2 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
- package/dist/Incentives/ERC20Incentive.d.ts +270 -33
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +69 -46
- package/dist/Incentives/ERC20Incentive.js.map +1 -0
- package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +338 -421
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +262 -32
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +2 -1
- package/dist/Incentives/Incentive.cjs.map +1 -0
- package/dist/Incentives/Incentive.d.ts +5 -8
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +17 -278
- package/dist/Incentives/Incentive.js.map +1 -0
- package/dist/Incentives/PointsIncentive.cjs +2 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -0
- package/dist/Incentives/PointsIncentive.d.ts +81 -23
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +57 -36
- package/dist/Incentives/PointsIncentive.js.map +1 -0
- 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 +2 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -0
- package/dist/Validators/SignerValidator.d.ts +310 -17
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +165 -36
- package/dist/Validators/SignerValidator.js.map +1 -0
- package/dist/Validators/Validator.cjs +2 -1
- package/dist/Validators/Validator.cjs.map +1 -0
- package/dist/Validators/Validator.d.ts +2 -2
- package/dist/Validators/Validator.d.ts.map +1 -1
- package/dist/Validators/Validator.js +10 -8
- package/dist/Validators/Validator.js.map +1 -0
- 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 +2 -1
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.ts +421 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +297 -39
- package/dist/errors.js.map +1 -0
- package/dist/{generated-x_abr3Yv.js → generated-CKt2yCQd.js} +3143 -3002
- 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 +2 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +144 -1353
- package/dist/index.js.map +1 -0
- 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 +2 -1
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +26 -1350
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +38 -636
- package/dist/utils.js.map +1 -0
- package/package.json +37 -11
- package/src/Actions/Action.test.ts +79 -0
- package/src/Actions/Action.ts +61 -0
- package/src/Actions/ContractAction.test.ts +197 -0
- package/src/Actions/ContractAction.ts +300 -0
- package/src/Actions/ERC721MintAction.test.ts +112 -0
- package/src/Actions/ERC721MintAction.ts +291 -0
- package/src/Actions/EventAction.test.ts +787 -0
- package/src/Actions/EventAction.ts +1218 -0
- package/src/AllowLists/AllowList.test.ts +64 -0
- package/src/AllowLists/AllowList.ts +62 -0
- package/src/AllowLists/OpenAllowList.test.ts +40 -0
- package/src/AllowLists/OpenAllowList.ts +45 -0
- package/src/AllowLists/SimpleAllowList.test.ts +52 -0
- package/src/AllowLists/SimpleAllowList.ts +262 -0
- package/src/AllowLists/SimpleDenyList.test.ts +52 -0
- package/src/AllowLists/SimpleDenyList.ts +250 -0
- package/src/Auth/Auth.ts +11 -0
- package/src/Auth/PassthroughAuth.test.ts +12 -0
- package/src/Auth/PassthroughAuth.ts +80 -0
- package/src/Boost.ts +287 -0
- package/src/BoostCore.test.ts +894 -0
- package/src/BoostCore.ts +1438 -0
- package/src/BoostRegistry.test.ts +53 -0
- package/src/BoostRegistry.ts +588 -0
- package/src/Budgets/Budget.test.ts +27 -0
- package/src/Budgets/Budget.ts +60 -0
- package/src/Budgets/ManagedBudget.test.ts +217 -0
- package/src/Budgets/ManagedBudget.ts +534 -0
- package/src/Budgets/VestingBudget.test.ts +123 -0
- package/src/Budgets/VestingBudget.ts +530 -0
- package/src/Deployable/Contract.ts +228 -0
- package/src/Deployable/Deployable.ts +250 -0
- package/src/Deployable/DeployableTarget.ts +234 -0
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.test.ts +143 -0
- package/src/Incentives/AllowListIncentive.ts +336 -0
- package/src/Incentives/CGDAIncentive.test.ts +135 -0
- package/src/Incentives/CGDAIncentive.ts +476 -0
- package/src/Incentives/ERC1155Incentive.test.ts +87 -0
- package/src/Incentives/ERC1155Incentive.ts +465 -0
- package/src/Incentives/ERC20Incentive.test.ts +133 -0
- package/src/Incentives/ERC20Incentive.ts +490 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +139 -0
- package/src/Incentives/ERC20VariableIncentive.ts +428 -0
- package/src/Incentives/Incentive.test.ts +95 -0
- package/src/Incentives/Incentive.ts +86 -0
- package/src/Incentives/PointsIncentive.test.ts +138 -0
- package/src/Incentives/PointsIncentive.ts +367 -0
- package/src/Validators/SignerValidator.test.ts +159 -0
- package/src/Validators/SignerValidator.ts +683 -0
- package/src/Validators/Validator.test.ts +21 -0
- package/src/Validators/Validator.ts +55 -0
- package/src/claiming.ts +56 -0
- package/src/errors.ts +866 -0
- package/src/index.test.ts +122 -0
- package/src/index.ts +58 -0
- package/src/transfers.ts +284 -0
- package/src/utils.test.ts +44 -0
- package/src/utils.ts +247 -0
- package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
- package/dist/generated-BaaleHW-.cjs +0 -2
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import {
|
|
2
|
+
erc20IncentiveAbi,
|
|
3
|
+
readErc20IncentiveAsset,
|
|
4
|
+
readErc20IncentiveClaimed,
|
|
5
|
+
readErc20IncentiveClaims,
|
|
6
|
+
readErc20IncentiveCurrentReward,
|
|
7
|
+
readErc20IncentiveEntries,
|
|
8
|
+
readErc20IncentiveIsClaimable,
|
|
9
|
+
readErc20IncentiveLimit,
|
|
10
|
+
readErc20IncentiveOwner,
|
|
11
|
+
readErc20IncentiveReward,
|
|
12
|
+
readErc20IncentiveStrategy,
|
|
13
|
+
simulateErc20IncentiveClaim,
|
|
14
|
+
simulateErc20IncentiveClawback,
|
|
15
|
+
simulateErc20IncentiveDrawRaffle,
|
|
16
|
+
writeErc20IncentiveClaim,
|
|
17
|
+
writeErc20IncentiveClawback,
|
|
18
|
+
writeErc20IncentiveDrawRaffle,
|
|
19
|
+
} from '@boostxyz/evm';
|
|
20
|
+
import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20Incentive.sol/ERC20Incentive.json';
|
|
21
|
+
import {
|
|
22
|
+
type Address,
|
|
23
|
+
type ContractEventName,
|
|
24
|
+
type Hex,
|
|
25
|
+
encodeAbiParameters,
|
|
26
|
+
} from 'viem';
|
|
27
|
+
import { ERC20Incentive as ERC20IncentiveBases } from '../../dist/deployments.json';
|
|
28
|
+
import type {
|
|
29
|
+
DeployableOptions,
|
|
30
|
+
GenericDeployableParams,
|
|
31
|
+
} from '../Deployable/Deployable';
|
|
32
|
+
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
33
|
+
import {
|
|
34
|
+
type ClaimPayload,
|
|
35
|
+
type StrategyType,
|
|
36
|
+
prepareClaimPayload,
|
|
37
|
+
} from '../claiming';
|
|
38
|
+
import {
|
|
39
|
+
type GenericLog,
|
|
40
|
+
type ReadParams,
|
|
41
|
+
RegistryType,
|
|
42
|
+
type WriteParams,
|
|
43
|
+
} from '../utils';
|
|
44
|
+
|
|
45
|
+
export { erc20IncentiveAbi };
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The object representation of a `ERC20Incentive.InitPayload`
|
|
49
|
+
*
|
|
50
|
+
* @export
|
|
51
|
+
* @interface ERC20IncentivePayload
|
|
52
|
+
* @typedef {ERC20IncentivePayload}
|
|
53
|
+
*/
|
|
54
|
+
export interface ERC20IncentivePayload {
|
|
55
|
+
/**
|
|
56
|
+
* The address of the incentivized asset.
|
|
57
|
+
*
|
|
58
|
+
* @type {Address}
|
|
59
|
+
*/
|
|
60
|
+
asset: Address;
|
|
61
|
+
/**
|
|
62
|
+
* The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
|
|
63
|
+
*
|
|
64
|
+
* @type {StrategyType}
|
|
65
|
+
*/
|
|
66
|
+
strategy: StrategyType;
|
|
67
|
+
/**
|
|
68
|
+
* The amount of the asset to distribute.
|
|
69
|
+
*
|
|
70
|
+
* @type {bigint}
|
|
71
|
+
*/
|
|
72
|
+
reward: bigint;
|
|
73
|
+
/**
|
|
74
|
+
* How many times can this incentive be claimed.
|
|
75
|
+
*
|
|
76
|
+
* @type {bigint}
|
|
77
|
+
*/
|
|
78
|
+
limit: bigint;
|
|
79
|
+
/**
|
|
80
|
+
* The entity that can `clawback` funds
|
|
81
|
+
*
|
|
82
|
+
* @type {Address}
|
|
83
|
+
*/
|
|
84
|
+
manager: Address;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* A generic `viem.Log` event with support for `ERC20Incentive` event types.
|
|
89
|
+
*
|
|
90
|
+
* @export
|
|
91
|
+
* @typedef {ERC20IncentiveLog}
|
|
92
|
+
* @template {ContractEventName<typeof erc20IncentiveAbi>} [event=ContractEventName<
|
|
93
|
+
* typeof erc20IncentiveAbi
|
|
94
|
+
* >]
|
|
95
|
+
*/
|
|
96
|
+
export type ERC20IncentiveLog<
|
|
97
|
+
event extends ContractEventName<typeof erc20IncentiveAbi> = ContractEventName<
|
|
98
|
+
typeof erc20IncentiveAbi
|
|
99
|
+
>,
|
|
100
|
+
> = GenericLog<typeof erc20IncentiveAbi, event>;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* A simple ERC20 incentive implementation that allows claiming of tokens
|
|
104
|
+
*
|
|
105
|
+
* @export
|
|
106
|
+
* @class ERC20Incentive
|
|
107
|
+
* @typedef {ERC20Incentive}
|
|
108
|
+
* @extends {DeployableTarget<ERC20IncentivePayload>}
|
|
109
|
+
*/
|
|
110
|
+
export class ERC20Incentive extends DeployableTarget<
|
|
111
|
+
ERC20IncentivePayload,
|
|
112
|
+
typeof erc20IncentiveAbi
|
|
113
|
+
> {
|
|
114
|
+
public override readonly abi = erc20IncentiveAbi;
|
|
115
|
+
/**
|
|
116
|
+
* @inheritdoc
|
|
117
|
+
*
|
|
118
|
+
* @public
|
|
119
|
+
* @static
|
|
120
|
+
* @type {Record<number, Address>}
|
|
121
|
+
*/
|
|
122
|
+
public static override bases: Record<number, Address> = {
|
|
123
|
+
...(ERC20IncentiveBases as Record<number, Address>),
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* @inheritdoc
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
* @static
|
|
130
|
+
* @type {RegistryType}
|
|
131
|
+
*/
|
|
132
|
+
public static override registryType: RegistryType = RegistryType.INCENTIVE;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The owner of the incentive
|
|
136
|
+
*
|
|
137
|
+
* @public
|
|
138
|
+
* @async
|
|
139
|
+
* @param {?ReadParams} [params]
|
|
140
|
+
* @returns {Promise<Address>}
|
|
141
|
+
*/
|
|
142
|
+
public async owner(params?: ReadParams<typeof erc20IncentiveAbi, 'owner'>) {
|
|
143
|
+
return await readErc20IncentiveOwner(this._config, {
|
|
144
|
+
address: this.assertValidAddress(),
|
|
145
|
+
args: [],
|
|
146
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
147
|
+
...(params as any),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Calculates the current reward based on the time since the last claim. The reward is calculated based on the time since the last claim, the available budget, and the reward parameters. It increases linearly over time in the absence of claims, with each hour adding `rewardBoost` to the current reward, up to the available budget. For example, if there is one claim in the first hour, then no claims for three hours, the claimable reward would be `initialReward - rewardDecay + (rewardBoost * 3)`
|
|
153
|
+
*
|
|
154
|
+
* @public
|
|
155
|
+
* @async
|
|
156
|
+
* @param {?ReadParams} [params]
|
|
157
|
+
* @returns {Promise<bigint>} - The current reward
|
|
158
|
+
*/
|
|
159
|
+
public async currentReward(
|
|
160
|
+
params?: ReadParams<typeof erc20IncentiveAbi, 'currentReward'>,
|
|
161
|
+
) {
|
|
162
|
+
return await readErc20IncentiveCurrentReward(this._config, {
|
|
163
|
+
address: this.assertValidAddress(),
|
|
164
|
+
args: [],
|
|
165
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
166
|
+
...(params as any),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The number of claims that have been made
|
|
172
|
+
*
|
|
173
|
+
* @public
|
|
174
|
+
* @async
|
|
175
|
+
* @param {?ReadParams} [params]
|
|
176
|
+
* @returns {Promise<bigint>}
|
|
177
|
+
*/
|
|
178
|
+
public async claims(params?: ReadParams<typeof erc20IncentiveAbi, 'claims'>) {
|
|
179
|
+
return await readErc20IncentiveClaims(this._config, {
|
|
180
|
+
address: this.assertValidAddress(),
|
|
181
|
+
args: [],
|
|
182
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
183
|
+
...(params as any),
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* A mapping of address to claim status
|
|
189
|
+
*
|
|
190
|
+
* @public
|
|
191
|
+
* @async
|
|
192
|
+
* @param {Address} address
|
|
193
|
+
* @param {?ReadParams} [params]
|
|
194
|
+
* @returns {Promise<boolean>}
|
|
195
|
+
*/
|
|
196
|
+
public async claimed(
|
|
197
|
+
address: Address,
|
|
198
|
+
params?: ReadParams<typeof erc20IncentiveAbi, 'claimed'>,
|
|
199
|
+
) {
|
|
200
|
+
return await readErc20IncentiveClaimed(this._config, {
|
|
201
|
+
address: this.assertValidAddress(),
|
|
202
|
+
args: [address],
|
|
203
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
204
|
+
...(params as any),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The address of the ERC20-like token
|
|
210
|
+
*
|
|
211
|
+
* @public
|
|
212
|
+
* @async
|
|
213
|
+
* @param {?ReadParams} [params]
|
|
214
|
+
* @returns {Promise<Address>}
|
|
215
|
+
*/
|
|
216
|
+
public async asset(params?: ReadParams<typeof erc20IncentiveAbi, 'asset'>) {
|
|
217
|
+
return await readErc20IncentiveAsset(this._config, {
|
|
218
|
+
address: this.assertValidAddress(),
|
|
219
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
220
|
+
...(params as any),
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* The strategy for the incentive (MINT or POOL)
|
|
226
|
+
*
|
|
227
|
+
* @public
|
|
228
|
+
* @async
|
|
229
|
+
* @param {?ReadParams} [params]
|
|
230
|
+
* @returns {Promise<StrategyType>}
|
|
231
|
+
*/
|
|
232
|
+
public strategy(
|
|
233
|
+
params?: ReadParams<typeof erc20IncentiveAbi, 'strategy'>,
|
|
234
|
+
): Promise<StrategyType> {
|
|
235
|
+
return readErc20IncentiveStrategy(this._config, {
|
|
236
|
+
address: this.assertValidAddress(),
|
|
237
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
238
|
+
...(params as any),
|
|
239
|
+
}) as Promise<StrategyType>;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* The reward amount issued for each claim
|
|
244
|
+
*
|
|
245
|
+
* @public
|
|
246
|
+
* @async
|
|
247
|
+
* @param {?ReadParams} [params]
|
|
248
|
+
* @returns {Promise<bigint>}
|
|
249
|
+
*/
|
|
250
|
+
public async reward(params?: ReadParams<typeof erc20IncentiveAbi, 'reward'>) {
|
|
251
|
+
return await readErc20IncentiveReward(this._config, {
|
|
252
|
+
address: this.assertValidAddress(),
|
|
253
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
254
|
+
...(params as any),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* The limit (max claims, or max entries for raffles)
|
|
260
|
+
*
|
|
261
|
+
* @public
|
|
262
|
+
* @async
|
|
263
|
+
* @param {?ReadParams} [params]
|
|
264
|
+
* @returns {Promise<bigint>}
|
|
265
|
+
*/
|
|
266
|
+
public async limit(params?: ReadParams<typeof erc20IncentiveAbi, 'limit'>) {
|
|
267
|
+
return await readErc20IncentiveLimit(this._config, {
|
|
268
|
+
address: this.assertValidAddress(),
|
|
269
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
270
|
+
...(params as any),
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* The set of addresses that have claimed a slot in the incentive raffle, accessed by bigint index.
|
|
276
|
+
*
|
|
277
|
+
* @public
|
|
278
|
+
* @async
|
|
279
|
+
* @param {bigint} i - Index of address
|
|
280
|
+
* @param {?ReadParams} [params]
|
|
281
|
+
* @returns {Promise<Address>}
|
|
282
|
+
*/
|
|
283
|
+
public async entries(
|
|
284
|
+
i: bigint,
|
|
285
|
+
params?: ReadParams<typeof erc20IncentiveAbi, 'entries'>,
|
|
286
|
+
) {
|
|
287
|
+
return await readErc20IncentiveEntries(this._config, {
|
|
288
|
+
address: this.assertValidAddress(),
|
|
289
|
+
args: [i],
|
|
290
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
291
|
+
...(params as any),
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Claim the incentive
|
|
297
|
+
*
|
|
298
|
+
* @public
|
|
299
|
+
* @async
|
|
300
|
+
* @param {ClaimPayload} payload
|
|
301
|
+
* @param {?WriteParams} [params]
|
|
302
|
+
* @returns {Promise<boolean>} - Returns true if successfully claimed
|
|
303
|
+
*/
|
|
304
|
+
protected async claim(
|
|
305
|
+
payload: ClaimPayload,
|
|
306
|
+
params?: WriteParams<typeof erc20IncentiveAbi, 'claim'>,
|
|
307
|
+
) {
|
|
308
|
+
return await this.awaitResult(this.claimRaw(payload, params));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Claim the incentive
|
|
313
|
+
*
|
|
314
|
+
* @public
|
|
315
|
+
* @async
|
|
316
|
+
* @param {ClaimPayload} payload
|
|
317
|
+
* @param {?WriteParams} [params]
|
|
318
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - Returns true if successfully claimed
|
|
319
|
+
*/
|
|
320
|
+
protected async claimRaw(
|
|
321
|
+
payload: ClaimPayload,
|
|
322
|
+
params?: WriteParams<typeof erc20IncentiveAbi, 'claim'>,
|
|
323
|
+
) {
|
|
324
|
+
const { request, result } = await simulateErc20IncentiveClaim(
|
|
325
|
+
this._config,
|
|
326
|
+
{
|
|
327
|
+
address: this.assertValidAddress(),
|
|
328
|
+
args: [prepareClaimPayload(payload)],
|
|
329
|
+
...this.optionallyAttachAccount(),
|
|
330
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
331
|
+
...(params as any),
|
|
332
|
+
},
|
|
333
|
+
);
|
|
334
|
+
const hash = await writeErc20IncentiveClaim(this._config, request);
|
|
335
|
+
return { hash, result };
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Clawback assets from the incentive
|
|
340
|
+
*
|
|
341
|
+
* @public
|
|
342
|
+
* @async
|
|
343
|
+
* @param {ClaimPayload} payload
|
|
344
|
+
* @param {?WriteParams} [params]
|
|
345
|
+
* @returns {Promise<boolean>} - True if the assets were successfully clawbacked
|
|
346
|
+
*/
|
|
347
|
+
public async clawback(
|
|
348
|
+
payload: ClaimPayload,
|
|
349
|
+
params?: WriteParams<typeof erc20IncentiveAbi, 'clawback'>,
|
|
350
|
+
) {
|
|
351
|
+
return await this.awaitResult(this.clawbackRaw(payload, params));
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Clawback assets from the incentive
|
|
356
|
+
*
|
|
357
|
+
* @public
|
|
358
|
+
* @async
|
|
359
|
+
* @param {ClaimPayload} payload
|
|
360
|
+
* @param {?WriteParams} [params]
|
|
361
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the assets were successfully clawbacked
|
|
362
|
+
*/
|
|
363
|
+
public async clawbackRaw(
|
|
364
|
+
payload: ClaimPayload,
|
|
365
|
+
params?: WriteParams<typeof erc20IncentiveAbi, 'clawback'>,
|
|
366
|
+
) {
|
|
367
|
+
const { request, result } = await simulateErc20IncentiveClawback(
|
|
368
|
+
this._config,
|
|
369
|
+
{
|
|
370
|
+
address: this.assertValidAddress(),
|
|
371
|
+
args: [prepareClaimPayload(payload)],
|
|
372
|
+
...this.optionallyAttachAccount(),
|
|
373
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
374
|
+
...(params as any),
|
|
375
|
+
},
|
|
376
|
+
);
|
|
377
|
+
const hash = await writeErc20IncentiveClawback(this._config, request);
|
|
378
|
+
return { hash, result };
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Check if an incentive is claimable. For the POOL strategy, the `bytes data` portion of the payload ignored. The recipient must not have already claimed the incentive.
|
|
383
|
+
*
|
|
384
|
+
* @public
|
|
385
|
+
* @async
|
|
386
|
+
* @param {ClaimPayload} payload
|
|
387
|
+
* @param {?ReadParams} [params]
|
|
388
|
+
* @returns {Promise<boolean>} = True if the incentive is claimable based on the data payload
|
|
389
|
+
*/
|
|
390
|
+
public async isClaimable(
|
|
391
|
+
payload: ClaimPayload,
|
|
392
|
+
params?: ReadParams<typeof erc20IncentiveAbi, 'isClaimable'>,
|
|
393
|
+
) {
|
|
394
|
+
return await readErc20IncentiveIsClaimable(this._config, {
|
|
395
|
+
address: this.assertValidAddress(),
|
|
396
|
+
args: [prepareClaimPayload(payload)],
|
|
397
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
398
|
+
...(params as any),
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Draw a winner from the raffle. Only callable by owner. Only valid when the strategy is set to `Strategy.RAFFLE`
|
|
404
|
+
*
|
|
405
|
+
* @public
|
|
406
|
+
* @async
|
|
407
|
+
* @param {?WriteParams} [params]
|
|
408
|
+
* @returns {Promise<void>}
|
|
409
|
+
*/
|
|
410
|
+
public async drawRaffle(
|
|
411
|
+
params?: WriteParams<typeof erc20IncentiveAbi, 'drawRaffle'>,
|
|
412
|
+
) {
|
|
413
|
+
return await this.awaitResult(this.drawRaffleRaw(params));
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Draw a winner from the raffle. Only callable by owner. Only valid when the strategy is set to `Strategy.RAFFLE`
|
|
418
|
+
*
|
|
419
|
+
* @public
|
|
420
|
+
* @async
|
|
421
|
+
* @param {?WriteParams} [params]
|
|
422
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
423
|
+
*/
|
|
424
|
+
public async drawRaffleRaw(
|
|
425
|
+
params?: WriteParams<typeof erc20IncentiveAbi, 'drawRaffle'>,
|
|
426
|
+
) {
|
|
427
|
+
const { request, result } = await simulateErc20IncentiveDrawRaffle(
|
|
428
|
+
this._config,
|
|
429
|
+
{
|
|
430
|
+
address: this.assertValidAddress(),
|
|
431
|
+
...this.optionallyAttachAccount(),
|
|
432
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
433
|
+
...(params as any),
|
|
434
|
+
},
|
|
435
|
+
);
|
|
436
|
+
const hash = await writeErc20IncentiveDrawRaffle(this._config, request);
|
|
437
|
+
return { hash, result };
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* @inheritdoc
|
|
442
|
+
*
|
|
443
|
+
* @public
|
|
444
|
+
* @param {?ERC20IncentivePayload} [_payload]
|
|
445
|
+
* @param {?DeployableOptions} [_options]
|
|
446
|
+
* @returns {GenericDeployableParams}
|
|
447
|
+
*/
|
|
448
|
+
public override buildParameters(
|
|
449
|
+
_payload?: ERC20IncentivePayload,
|
|
450
|
+
_options?: DeployableOptions,
|
|
451
|
+
): GenericDeployableParams {
|
|
452
|
+
const [payload, options] = this.validateDeploymentConfig(
|
|
453
|
+
_payload,
|
|
454
|
+
_options,
|
|
455
|
+
);
|
|
456
|
+
return {
|
|
457
|
+
abi: erc20IncentiveAbi,
|
|
458
|
+
bytecode: bytecode as Hex,
|
|
459
|
+
args: [prepareERC20IncentivePayload(payload)],
|
|
460
|
+
...this.optionallyAttachAccount(options.account),
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Given a {@link ERC20IncentivePayload}, properly encode a `ERC20Incentive.InitPayload` for use with {@link ERC20Incentive} initialization.
|
|
467
|
+
*
|
|
468
|
+
* @param {ERC20IncentivePayload} param0
|
|
469
|
+
* @param {Address} param0.asset - The address of the incentivized asset.
|
|
470
|
+
* @param {StrategyType} param0.strategy - The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
|
|
471
|
+
* @param {bigint} param0.reward - The amount of the asset to distribute.
|
|
472
|
+
* @param {bigint} param0.limit - How many times can this incentive be claimed.
|
|
473
|
+
* @returns {Hex}
|
|
474
|
+
*/
|
|
475
|
+
export function prepareERC20IncentivePayload({
|
|
476
|
+
asset,
|
|
477
|
+
strategy,
|
|
478
|
+
reward,
|
|
479
|
+
limit,
|
|
480
|
+
}: ERC20IncentivePayload) {
|
|
481
|
+
return encodeAbiParameters(
|
|
482
|
+
[
|
|
483
|
+
{ type: 'address', name: 'asset' },
|
|
484
|
+
{ type: 'uint8', name: 'strategy' },
|
|
485
|
+
{ type: 'uint256', name: 'reward' },
|
|
486
|
+
{ type: 'uint256', name: 'limit' },
|
|
487
|
+
],
|
|
488
|
+
[asset, strategy, reward, limit],
|
|
489
|
+
);
|
|
490
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { Mock } from 'node:test';
|
|
2
|
+
import { selectors as eventSelectors } from '@boostxyz/signatures/events';
|
|
3
|
+
import { selectors as funcSelectors } from '@boostxyz/signatures/functions';
|
|
4
|
+
import type { MockERC20 } from '@boostxyz/test/MockERC20';
|
|
5
|
+
import type { MockERC721 } from '@boostxyz/test/MockERC721';
|
|
6
|
+
import { accounts } from '@boostxyz/test/accounts';
|
|
7
|
+
import {
|
|
8
|
+
type BudgetFixtures,
|
|
9
|
+
type Fixtures,
|
|
10
|
+
defaultOptions,
|
|
11
|
+
deployFixtures,
|
|
12
|
+
freshBoost,
|
|
13
|
+
fundBudget,
|
|
14
|
+
fundErc20,
|
|
15
|
+
fundErc721,
|
|
16
|
+
} from '@boostxyz/test/helpers';
|
|
17
|
+
import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
|
|
18
|
+
import { type Hex, isAddress, parseEther } from 'viem';
|
|
19
|
+
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
20
|
+
import { SignatureType } from '../Actions/EventAction';
|
|
21
|
+
import type { Boost } from '../Boost';
|
|
22
|
+
import type {
|
|
23
|
+
ERC20VariableCriteriaIncentive,
|
|
24
|
+
ERC20VariableCriteriaIncentivePayload,
|
|
25
|
+
IncentiveCriteria,
|
|
26
|
+
} from './ERC20VariableCriteriaIncentive';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A basic ERC721 mint scalar criteria for testing
|
|
30
|
+
*
|
|
31
|
+
* @param {MockERC721} erc721 - The ERC721 contract
|
|
32
|
+
* @returns {IncentiveCriteria} - Returns a basic incentive criteria
|
|
33
|
+
*/
|
|
34
|
+
export function basicErc721TransferScalarCriteria(
|
|
35
|
+
erc721: MockERC721,
|
|
36
|
+
): IncentiveCriteria {
|
|
37
|
+
return {
|
|
38
|
+
criteriaType: SignatureType.FUNC,
|
|
39
|
+
signature: funcSelectors['transferFrom(address,address,uint256)'] as Hex, // Function selector for mint
|
|
40
|
+
fieldIndex: 2, // Field where the scalar value resides
|
|
41
|
+
targetContract: erc721.assertValidAddress(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A basic ERC721 mint scalar criteria for testing
|
|
47
|
+
*
|
|
48
|
+
* @param {MockERC721} erc721 - The ERC721 contract
|
|
49
|
+
* @returns {IncentiveCriteria} - Returns a basic incentive criteria
|
|
50
|
+
*/
|
|
51
|
+
export function basicErc721MintScalarCriteria(
|
|
52
|
+
erc721: MockERC721,
|
|
53
|
+
): IncentiveCriteria {
|
|
54
|
+
return {
|
|
55
|
+
criteriaType: SignatureType.EVENT,
|
|
56
|
+
signature: eventSelectors[
|
|
57
|
+
'Transfer(address indexed,address indexed,uint256 indexed)'
|
|
58
|
+
] as Hex, // Function selector for mint
|
|
59
|
+
fieldIndex: 2, // Field where the scalar value resides
|
|
60
|
+
targetContract: erc721.assertValidAddress(),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A basic ERC721 mint scalar payload for testing
|
|
66
|
+
*
|
|
67
|
+
* @param {MockERC721} erc721 - The ERC721 contract
|
|
68
|
+
* @returns {ERC20VariableCriteriaIncentivePayload} - Returns a full variable criteria incentive payload
|
|
69
|
+
*/
|
|
70
|
+
export function basicErc721TransferScalarPayload(
|
|
71
|
+
erc721: MockERC721,
|
|
72
|
+
): ERC20VariableCriteriaIncentivePayload {
|
|
73
|
+
return {
|
|
74
|
+
asset: erc721.assertValidAddress(),
|
|
75
|
+
reward: 1n,
|
|
76
|
+
limit: 1n,
|
|
77
|
+
criteria: basicErc721TransferScalarCriteria(erc721),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let fixtures: Fixtures,
|
|
82
|
+
erc20: MockERC20,
|
|
83
|
+
erc721: MockERC721,
|
|
84
|
+
erc20Incentive: ERC20VariableCriteriaIncentive,
|
|
85
|
+
budgets: BudgetFixtures,
|
|
86
|
+
boost: Boost;
|
|
87
|
+
|
|
88
|
+
describe('ERC20VariableCriteriaIncentive', () => {
|
|
89
|
+
beforeAll(async () => {
|
|
90
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
beforeEach(async () => {
|
|
94
|
+
budgets = await loadFixture(fundBudget(defaultOptions, fixtures));
|
|
95
|
+
erc20 = await loadFixture(fundErc20(defaultOptions));
|
|
96
|
+
erc721 = await loadFixture(fundErc721(defaultOptions));
|
|
97
|
+
erc20Incentive = fixtures.core.ERC20VariableCriteriaIncentive({
|
|
98
|
+
asset: budgets.erc20.assertValidAddress(),
|
|
99
|
+
reward: 1n,
|
|
100
|
+
limit: 1n,
|
|
101
|
+
criteria: basicErc721TransferScalarCriteria(erc721),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
boost = await freshBoost(fixtures, {
|
|
105
|
+
budget: budgets.budget,
|
|
106
|
+
incentives: [erc20Incentive],
|
|
107
|
+
});
|
|
108
|
+
expect(isAddress(boost.incentives[0]!.assertValidAddress())).toBe(true);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('getIncentiveCriteria', () => {
|
|
112
|
+
test('should fetch incentive criteria successfully', async () => {
|
|
113
|
+
const incentive = boost.incentives[0] as ERC20VariableCriteriaIncentive;
|
|
114
|
+
const criteria = await incentive.getIncentiveCriteria();
|
|
115
|
+
expect(criteria).toMatchObject({
|
|
116
|
+
criteriaType: SignatureType.FUNC,
|
|
117
|
+
signature: expect.any(String),
|
|
118
|
+
fieldIndex: expect.any(Number),
|
|
119
|
+
targetContract: expect.any(String),
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('getIncentiveScalar', () => {
|
|
125
|
+
test('should return a valid scalar for function-based criteria', async () => {
|
|
126
|
+
const recipient = accounts[1].account;
|
|
127
|
+
|
|
128
|
+
const { hash } = await erc721.transferFromRaw(
|
|
129
|
+
accounts[0].account,
|
|
130
|
+
recipient,
|
|
131
|
+
1n,
|
|
132
|
+
);
|
|
133
|
+
const scalar = await erc20Incentive.getIncentiveScalar({ hash });
|
|
134
|
+
|
|
135
|
+
expect(scalar).toBe(1n);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('should return a valid scalar for event-based criteria', async () => {
|
|
139
|
+
erc20Incentive = fixtures.core.ERC20VariableCriteriaIncentive({
|
|
140
|
+
asset: budgets.erc20.assertValidAddress(),
|
|
141
|
+
reward: 1n,
|
|
142
|
+
limit: 1n,
|
|
143
|
+
criteria: basicErc721MintScalarCriteria(erc721),
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
boost = await freshBoost(fixtures, {
|
|
147
|
+
budget: budgets.budget,
|
|
148
|
+
incentives: [erc20Incentive],
|
|
149
|
+
});
|
|
150
|
+
const recipient = accounts[1].account;
|
|
151
|
+
const { hash } = await erc721.transferFromRaw(
|
|
152
|
+
accounts[0].account,
|
|
153
|
+
recipient,
|
|
154
|
+
1n,
|
|
155
|
+
);
|
|
156
|
+
const scalar = await erc20Incentive.getIncentiveScalar({ hash });
|
|
157
|
+
|
|
158
|
+
expect(scalar).toBe(1n);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test('should throw NoMatchingLogsError for event criteria with no matching logs', async () => {
|
|
162
|
+
const recipient = accounts[1].account;
|
|
163
|
+
|
|
164
|
+
const { hash } = await erc20.mintRaw(recipient, parseEther('100'));
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
await erc20Incentive.getIncentiveScalar({ hash });
|
|
168
|
+
} catch (e) {
|
|
169
|
+
expect((e as Error).name).toBe('DecodedArgsError');
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('should throw DecodedArgsError for invalid function-based data', async () => {
|
|
174
|
+
const recipient = accounts[1].account;
|
|
175
|
+
const { hash } = await erc20.mintRaw(recipient, parseEther('100'));
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
await erc20Incentive.getIncentiveScalar({ hash });
|
|
179
|
+
} catch (e) {
|
|
180
|
+
expect((e as Error).name).toBe('DecodedArgsError');
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|