@boostxyz/sdk 6.1.2 → 7.0.0-canary.0
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/README.md +1 -1
- package/dist/Actions/Action.cjs +1 -1
- package/dist/Actions/Action.js +4 -4
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +10 -0
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +84 -83
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.js +3 -3
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +14 -14
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.js +3 -3
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/BoostCore.cjs +2 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +1894 -267
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +808 -497
- package/dist/BoostCore.js.map +1 -1
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.js +47 -47
- package/dist/Budget-B_kgJGDu.cjs +2 -0
- package/dist/Budget-B_kgJGDu.cjs.map +1 -0
- package/dist/Budget-Bvi5Qjqp.js +1124 -0
- package/dist/Budget-Bvi5Qjqp.js.map +1 -0
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.d.ts +5 -4
- package/dist/Budgets/Budget.d.ts.map +1 -1
- package/dist/Budgets/Budget.js +9 -6
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +4 -0
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +25 -25
- package/dist/Budgets/ManagedBudgetWithFees.d.ts +4 -0
- package/dist/Budgets/ManagedBudgetWithFees.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudgetWithFeesV2.d.ts +4 -0
- package/dist/Budgets/ManagedBudgetWithFeesV2.d.ts.map +1 -1
- package/dist/Budgets/TransparentBudget.d.ts +944 -0
- package/dist/Budgets/TransparentBudget.d.ts.map +1 -0
- package/dist/Budgets/VestingBudget.d.ts +4 -0
- package/dist/Budgets/VestingBudget.d.ts.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.map +1 -1
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.js +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.js +19 -19
- package/dist/Incentive-CLKutfnD.js +445 -0
- package/dist/Incentive-CLKutfnD.js.map +1 -0
- package/dist/Incentive-CLSVNxDz.cjs +2 -0
- package/dist/Incentive-CLSVNxDz.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +9 -9
- 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.js +5 -5
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +17 -17
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/Incentives/ERC20PeggedIncentive.d.ts +1 -1
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.cjs +2 -0
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.cjs.map +1 -0
- package/dist/Incentives/{ERC20PeggedVariableCriteriaIncentive.d.ts → ERC20PeggedVariableCriteriaIncentiveV2.d.ts} +39 -27
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.d.ts.map +1 -0
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.js +625 -0
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.js.map +1 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.cjs +2 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.cjs.map +1 -0
- package/dist/Incentives/{ERC20VariableCriteriaIncentive.d.ts → ERC20VariableCriteriaIncentiveV2.d.ts} +42 -13
- package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.js +242 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.js.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.cjs +1 -1
- package/dist/Incentives/ERC20VariableIncentive.cjs.map +1 -1
- package/dist/Incentives/ERC20VariableIncentive.d.ts +3 -3
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20VariableIncentive.js +22 -22
- package/dist/Incentives/ERC20VariableIncentive.js.map +1 -1
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.d.ts +8 -8
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +13 -12
- 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.js +13 -13
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/SimpleDenyList-C1C_BHkY.js +133 -0
- package/dist/{SimpleDenyList-BKfPoTo1.js.map → SimpleDenyList-C1C_BHkY.js.map} +1 -1
- package/dist/SimpleDenyList-CWthbyj7.cjs +2 -0
- package/dist/{SimpleDenyList-DgjVf7FK.cjs.map → SimpleDenyList-CWthbyj7.cjs.map} +1 -1
- package/dist/Validators/LimitedSignerValidator.cjs +1 -1
- package/dist/Validators/LimitedSignerValidator.cjs.map +1 -1
- package/dist/Validators/LimitedSignerValidator.d.ts.map +1 -1
- package/dist/Validators/LimitedSignerValidator.js +48 -52
- package/dist/Validators/LimitedSignerValidator.js.map +1 -1
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.js +54 -54
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.js +2 -2
- package/dist/componentInterfaces-BVHB4Fjw.js +21 -0
- package/dist/componentInterfaces-BVHB4Fjw.js.map +1 -0
- package/dist/componentInterfaces-BqhL-meV.cjs +2 -0
- package/dist/componentInterfaces-BqhL-meV.cjs.map +1 -0
- package/dist/deployments-D9QxJGrC.cjs +2 -0
- package/dist/deployments-D9QxJGrC.cjs.map +1 -0
- package/dist/deployments-De8_J7SS.js +120 -0
- package/dist/{deployments-W_LUj833.js.map → deployments-De8_J7SS.js.map} +1 -1
- package/dist/deployments.json +63 -48
- package/dist/{generated-CElkFqkY.js → generated-BJfQ-EBO.js} +1268 -737
- package/dist/generated-BJfQ-EBO.js.map +1 -0
- package/dist/generated-mJJNq-xb.cjs +3 -0
- package/dist/generated-mJJNq-xb.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +162 -158
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +13 -7
- package/src/Actions/EventAction.ts +11 -0
- package/src/BoostCore.test.ts +14 -9
- package/src/BoostCore.ts +428 -26
- package/src/Budgets/Budget.ts +8 -1
- package/src/Budgets/TransparentBudget.test.ts +70 -0
- package/src/Budgets/TransparentBudget.ts +334 -0
- package/src/Deployable/Deployable.ts +1 -1
- package/src/Incentives/ERC20PeggedIncentive.ts +1 -1
- package/src/Incentives/{ERC20PeggedVariableCriteriaIncentive.test.ts → ERC20PeggedVariableCriteriaIncentiveV2.test.ts} +14 -10
- package/src/Incentives/{ERC20PeggedVariableCriteriaIncentive.ts → ERC20PeggedVariableCriteriaIncentiveV2.ts} +122 -100
- package/src/Incentives/{ERC20VariableCriteriaIncentive.test.ts → ERC20VariableCriteriaIncentiveV2.test.ts} +18 -13
- package/src/Incentives/{ERC20VariableCriteriaIncentive.ts → ERC20VariableCriteriaIncentiveV2.ts} +83 -24
- package/src/Incentives/ERC20VariableIncentive.ts +4 -2
- package/src/Incentives/Incentive.ts +12 -12
- package/src/Validators/LimitedSignerValidator.ts +1 -4
- package/src/index.test.ts +2 -2
- package/src/index.ts +3 -2
- package/src/utils.ts +1 -1
- package/dist/Budget-BjfL8dVX.cjs +0 -2
- package/dist/Budget-BjfL8dVX.cjs.map +0 -1
- package/dist/Budget-DD7IPuDx.js +0 -922
- package/dist/Budget-DD7IPuDx.js.map +0 -1
- package/dist/Incentive-V1RjH38L.js +0 -1036
- package/dist/Incentive-V1RjH38L.js.map +0 -1
- package/dist/Incentive-gVTfsnMB.cjs +0 -2
- package/dist/Incentive-gVTfsnMB.cjs.map +0 -1
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.d.ts.map +0 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs +0 -2
- package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs.map +0 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +0 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.js +0 -207
- package/dist/Incentives/ERC20VariableCriteriaIncentive.js.map +0 -1
- package/dist/SimpleDenyList-BKfPoTo1.js +0 -133
- package/dist/SimpleDenyList-DgjVf7FK.cjs +0 -2
- package/dist/componentInterfaces-CA1UIqWL.js +0 -20
- package/dist/componentInterfaces-CA1UIqWL.js.map +0 -1
- package/dist/componentInterfaces-aBgBbB7r.cjs +0 -2
- package/dist/componentInterfaces-aBgBbB7r.cjs.map +0 -1
- package/dist/deployments-CwTZr-cK.cjs +0 -2
- package/dist/deployments-CwTZr-cK.cjs.map +0 -1
- package/dist/deployments-W_LUj833.js +0 -117
- package/dist/generated-BPiHi7W2.cjs +0 -3
- package/dist/generated-BPiHi7W2.cjs.map +0 -1
- package/dist/generated-CElkFqkY.js.map +0 -1
package/src/BoostCore.ts
CHANGED
|
@@ -14,6 +14,9 @@ import {
|
|
|
14
14
|
simulateBoostCoreSetProtocolFeeReceiver,
|
|
15
15
|
simulateBoostCoreTopupIncentiveFromBudget,
|
|
16
16
|
simulateBoostCoreTopupIncentiveFromSender,
|
|
17
|
+
simulateTransparentBudgetCreateBoost,
|
|
18
|
+
simulateTransparentBudgetCreateBoostWithPermit2,
|
|
19
|
+
transparentBudgetAbi,
|
|
17
20
|
writeBoostCoreClaimIncentive,
|
|
18
21
|
writeBoostCoreClaimIncentiveFor,
|
|
19
22
|
writeBoostCoreCreateBoost,
|
|
@@ -21,6 +24,8 @@ import {
|
|
|
21
24
|
writeBoostCoreSetProtocolFeeReceiver,
|
|
22
25
|
writeBoostCoreTopupIncentiveFromBudget,
|
|
23
26
|
writeBoostCoreTopupIncentiveFromSender,
|
|
27
|
+
writeTransparentBudgetCreateBoost,
|
|
28
|
+
writeTransparentBudgetCreateBoostWithPermit2,
|
|
24
29
|
} from '@boostxyz/evm';
|
|
25
30
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/BoostCore.sol/BoostCore.json';
|
|
26
31
|
import {
|
|
@@ -28,7 +33,6 @@ import {
|
|
|
28
33
|
getAccount,
|
|
29
34
|
getChains,
|
|
30
35
|
getTransactionReceipt,
|
|
31
|
-
readContract,
|
|
32
36
|
waitForTransactionReceipt,
|
|
33
37
|
} from '@wagmi/core';
|
|
34
38
|
import { createWriteContract } from '@wagmi/core/codegen';
|
|
@@ -36,8 +40,6 @@ import {
|
|
|
36
40
|
type Address,
|
|
37
41
|
type ContractEventName,
|
|
38
42
|
type Hex,
|
|
39
|
-
decodeAbiParameters,
|
|
40
|
-
encodeAbiParameters,
|
|
41
43
|
encodePacked,
|
|
42
44
|
keccak256,
|
|
43
45
|
parseEventLogs,
|
|
@@ -69,6 +71,7 @@ import { type Budget, budgetFromAddress } from './Budgets/Budget';
|
|
|
69
71
|
import {
|
|
70
72
|
ManagedBudget,
|
|
71
73
|
type ManagedBudgetPayload,
|
|
74
|
+
prepareTransfer,
|
|
72
75
|
} from './Budgets/ManagedBudget';
|
|
73
76
|
import {
|
|
74
77
|
ManagedBudgetWithFees,
|
|
@@ -78,6 +81,7 @@ import {
|
|
|
78
81
|
ManagedBudgetWithFeesV2,
|
|
79
82
|
type ManagedBudgetWithFeesV2Payload,
|
|
80
83
|
} from './Budgets/ManagedBudgetWithFeesV2';
|
|
84
|
+
import { TransparentBudget } from './Budgets/TransparentBudget';
|
|
81
85
|
import {
|
|
82
86
|
Deployable,
|
|
83
87
|
type DeployableOptions,
|
|
@@ -102,13 +106,13 @@ import {
|
|
|
102
106
|
type ERC20PeggedIncentivePayload,
|
|
103
107
|
} from './Incentives/ERC20PeggedIncentive';
|
|
104
108
|
import {
|
|
105
|
-
|
|
106
|
-
type
|
|
107
|
-
} from './Incentives/
|
|
109
|
+
ERC20PeggedVariableCriteriaIncentiveV2,
|
|
110
|
+
type ERC20PeggedVariableCriteriaIncentiveV2Payload,
|
|
111
|
+
} from './Incentives/ERC20PeggedVariableCriteriaIncentiveV2';
|
|
108
112
|
import {
|
|
109
|
-
|
|
110
|
-
type
|
|
111
|
-
} from './Incentives/
|
|
113
|
+
ERC20VariableCriteriaIncentiveV2,
|
|
114
|
+
type ERC20VariableCriteriaIncentiveV2Payload,
|
|
115
|
+
} from './Incentives/ERC20VariableCriteriaIncentiveV2';
|
|
112
116
|
import type { ERC20VariableIncentivePayload } from './Incentives/ERC20VariableIncentive';
|
|
113
117
|
import {
|
|
114
118
|
ERC20VariableIncentive,
|
|
@@ -141,7 +145,11 @@ import {
|
|
|
141
145
|
InvalidProtocolChainIdError,
|
|
142
146
|
MustInitializeBudgetError,
|
|
143
147
|
} from './errors';
|
|
144
|
-
import type {
|
|
148
|
+
import type {
|
|
149
|
+
AssetType,
|
|
150
|
+
ERC1155TransferPayload,
|
|
151
|
+
FungibleTransferPayload,
|
|
152
|
+
} from './transfers';
|
|
145
153
|
import {
|
|
146
154
|
type GenericLog,
|
|
147
155
|
type HashAndSimulatedResult,
|
|
@@ -370,7 +378,6 @@ export class BoostCore extends Deployable<
|
|
|
370
378
|
/**
|
|
371
379
|
* Create a new Boost.
|
|
372
380
|
*
|
|
373
|
-
*
|
|
374
381
|
* @public
|
|
375
382
|
* @async
|
|
376
383
|
* @param {CreateBoostPayload} _boostPayload
|
|
@@ -498,6 +505,365 @@ export class BoostCore extends Deployable<
|
|
|
498
505
|
});
|
|
499
506
|
}
|
|
500
507
|
|
|
508
|
+
/**
|
|
509
|
+
* Creates a new Boost with a given TransparentBudget, which transfers assets to the budget on Boost creation.
|
|
510
|
+
*
|
|
511
|
+
* @public
|
|
512
|
+
* @async
|
|
513
|
+
* @param {TransparentBudget | Address} budget - Either an instance of a transparent budget, or the address of a transparent budget
|
|
514
|
+
* @param {(FungibleTransferPayload | ERC1155TransferPayload)[]} allocations - An array of transfers to be allocated to the budget prior to Boost creation
|
|
515
|
+
* @param {Omit<CreateBoostPayload, 'budget'>} _boostPayload - The core Boost configuration sans budget
|
|
516
|
+
* @param {?WriteParams} [params]
|
|
517
|
+
* @returns {Promise<Boost>}
|
|
518
|
+
*/
|
|
519
|
+
public async createBoostWithTransparentBudget(
|
|
520
|
+
budget: TransparentBudget | Address,
|
|
521
|
+
allocations: (FungibleTransferPayload | ERC1155TransferPayload)[],
|
|
522
|
+
_boostPayload: Omit<CreateBoostPayload, 'budget'>,
|
|
523
|
+
_params?: WriteParams,
|
|
524
|
+
) {
|
|
525
|
+
const [payload, options] =
|
|
526
|
+
this.validateDeploymentConfig<CreateBoostPayload>({
|
|
527
|
+
..._boostPayload,
|
|
528
|
+
budget: this.TransparentBudget(
|
|
529
|
+
typeof budget === 'string' ? budget : budget.assertValidAddress(),
|
|
530
|
+
),
|
|
531
|
+
});
|
|
532
|
+
const desiredChainId = _params?.chainId;
|
|
533
|
+
const { chainId, address: coreAddress } = assertValidAddressByChainId(
|
|
534
|
+
options.config,
|
|
535
|
+
this.addresses,
|
|
536
|
+
desiredChainId,
|
|
537
|
+
);
|
|
538
|
+
|
|
539
|
+
const boostFactory = createWriteContract({
|
|
540
|
+
abi: transparentBudgetAbi,
|
|
541
|
+
functionName: 'createBoost',
|
|
542
|
+
address:
|
|
543
|
+
typeof budget === 'string' ? budget : budget.assertValidAddress(),
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
const onChainPayload = await this.prepareCreateBoostPayload(
|
|
547
|
+
coreAddress,
|
|
548
|
+
chainId,
|
|
549
|
+
payload,
|
|
550
|
+
options,
|
|
551
|
+
);
|
|
552
|
+
|
|
553
|
+
const boostHash = await boostFactory(options.config, {
|
|
554
|
+
...this.optionallyAttachAccount(options.account),
|
|
555
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
556
|
+
...(_params as any),
|
|
557
|
+
chainId,
|
|
558
|
+
args: [
|
|
559
|
+
allocations.map(prepareTransfer),
|
|
560
|
+
coreAddress,
|
|
561
|
+
prepareBoostPayload(onChainPayload),
|
|
562
|
+
],
|
|
563
|
+
});
|
|
564
|
+
const receipt = await waitForTransactionReceipt(options.config, {
|
|
565
|
+
hash: boostHash,
|
|
566
|
+
});
|
|
567
|
+
const boostCreatedLog = parseEventLogs({
|
|
568
|
+
abi: boostCoreAbi,
|
|
569
|
+
eventName: 'BoostCreated',
|
|
570
|
+
logs: receipt.logs,
|
|
571
|
+
}).at(0);
|
|
572
|
+
let boostId = 0n;
|
|
573
|
+
if (!boostCreatedLog) throw new BoostCoreNoIdentifierEmitted();
|
|
574
|
+
boostId = boostCreatedLog?.args.boostId;
|
|
575
|
+
const boost = await this.readBoost(boostId);
|
|
576
|
+
return new Boost({
|
|
577
|
+
id: boostId,
|
|
578
|
+
budget: payload.budget.at(boost.budget),
|
|
579
|
+
action: payload.action.at(boost.action),
|
|
580
|
+
validator: payload.validator!.at(boost.validator),
|
|
581
|
+
allowList: payload.allowList!.at(boost.allowList),
|
|
582
|
+
incentives: payload.incentives.map((incentive, i) =>
|
|
583
|
+
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
584
|
+
incentive.at(boost.incentives.at(i)!),
|
|
585
|
+
),
|
|
586
|
+
protocolFee: boost.protocolFee,
|
|
587
|
+
maxParticipants: boost.maxParticipants,
|
|
588
|
+
owner: boost.owner,
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Returns a transaction hash and simulated Boost creation using a transparent budget
|
|
594
|
+
*
|
|
595
|
+
* @public
|
|
596
|
+
* @async
|
|
597
|
+
* @param {TransparentBudget | Address} budget - Either an instance of a transparent budget, or the address of a transparent budget
|
|
598
|
+
* @param {(FungibleTransferPayload | ERC1155TransferPayload)[]} allocations - An array of transfers to be allocated to the budget prior to Boost creation
|
|
599
|
+
* @param {Omit<CreateBoostPayload, 'budget'>} _boostPayload - The core Boost configuration sans budget
|
|
600
|
+
* @param {?WriteParams} [params]
|
|
601
|
+
* @returns {Promise<HashAndSimulatedResult>}
|
|
602
|
+
*/
|
|
603
|
+
public async createBoostWithTransparentBudgetRaw(
|
|
604
|
+
budget: TransparentBudget | Address,
|
|
605
|
+
allocations: (FungibleTransferPayload | ERC1155TransferPayload)[],
|
|
606
|
+
_boostPayload: Omit<CreateBoostPayload, 'budget'>,
|
|
607
|
+
_params?: WriteParams,
|
|
608
|
+
): Promise<HashAndSimulatedResult> {
|
|
609
|
+
const { request, result } =
|
|
610
|
+
await this.simulateCreateBoostWithTransparentBudget(
|
|
611
|
+
budget,
|
|
612
|
+
allocations,
|
|
613
|
+
_boostPayload,
|
|
614
|
+
_params,
|
|
615
|
+
);
|
|
616
|
+
const hash = await writeTransparentBudgetCreateBoost(this._config, request);
|
|
617
|
+
return { hash, result };
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Returns a simulated Boost creation using a transparent budget
|
|
622
|
+
*
|
|
623
|
+
* @public
|
|
624
|
+
* @async
|
|
625
|
+
* @param {TransparentBudget | Address} budget - Either an instance of a transparent budget, or the address of a transparent budget
|
|
626
|
+
* @param {(FungibleTransferPayload | ERC1155TransferPayload)[]} allocations - An array of transfers to be allocated to the budget prior to Boost creation
|
|
627
|
+
* @param {Omit<CreateBoostPayload, 'budget'>} _boostPayload - The core Boost configuration sans budget
|
|
628
|
+
* @param {?WriteParams} [params]
|
|
629
|
+
* @returns {Promise<SimulateContractReturnType>}
|
|
630
|
+
*/
|
|
631
|
+
public async simulateCreateBoostWithTransparentBudget(
|
|
632
|
+
budget: TransparentBudget | Address,
|
|
633
|
+
allocations: (FungibleTransferPayload | ERC1155TransferPayload)[],
|
|
634
|
+
_boostPayload: Omit<CreateBoostPayload, 'budget'>,
|
|
635
|
+
_params?: WriteParams,
|
|
636
|
+
) {
|
|
637
|
+
const [payload, options] =
|
|
638
|
+
this.validateDeploymentConfig<CreateBoostPayload>({
|
|
639
|
+
..._boostPayload,
|
|
640
|
+
budget: this.TransparentBudget(
|
|
641
|
+
typeof budget === 'string' ? budget : budget.assertValidAddress(),
|
|
642
|
+
),
|
|
643
|
+
});
|
|
644
|
+
const desiredChainId = _params?.chainId;
|
|
645
|
+
const { chainId, address: coreAddress } = assertValidAddressByChainId(
|
|
646
|
+
options.config,
|
|
647
|
+
this.addresses,
|
|
648
|
+
desiredChainId,
|
|
649
|
+
);
|
|
650
|
+
|
|
651
|
+
const onChainPayload = await this.prepareCreateBoostPayload(
|
|
652
|
+
coreAddress,
|
|
653
|
+
chainId,
|
|
654
|
+
payload,
|
|
655
|
+
options,
|
|
656
|
+
);
|
|
657
|
+
|
|
658
|
+
return await simulateTransparentBudgetCreateBoost(this._config, {
|
|
659
|
+
...this.optionallyAttachAccount(),
|
|
660
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
661
|
+
...(_params as any),
|
|
662
|
+
address:
|
|
663
|
+
typeof budget === 'string' ? budget : budget.assertValidAddress(),
|
|
664
|
+
chainId,
|
|
665
|
+
args: [
|
|
666
|
+
allocations.map(prepareTransfer),
|
|
667
|
+
coreAddress,
|
|
668
|
+
prepareBoostPayload(onChainPayload),
|
|
669
|
+
],
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Creates a new Boost with a given a TransparentBudget and Permit2, which transfers assets to the budget on Boost creation.
|
|
675
|
+
*
|
|
676
|
+
* @public
|
|
677
|
+
* @async
|
|
678
|
+
* @param {TransparentBudget | Address} budget - Either an instance of a transparent budget, or the address of a transparent budget
|
|
679
|
+
* @param {(FungibleTransferPayload | ERC1155TransferPayload)[]} allocations - An array of transfers to be allocated to the budget prior to Boost creation
|
|
680
|
+
* @param {Omit<CreateBoostPayload, 'budget'>} _boostPayload - The core Boost configuration sans budget
|
|
681
|
+
* @param {Hex} permit2Signature - The packed signature that was the result of signing the EIP712 hash of `permit`.
|
|
682
|
+
* @param {bigint} nonce - The nonce for the permit2 batch transfer
|
|
683
|
+
* @param {bigint} deadline - The deadline for the permit2 batch transfer
|
|
684
|
+
* @param {?WriteParams} [params]
|
|
685
|
+
* @returns {Promise<Boost>}
|
|
686
|
+
*/
|
|
687
|
+
public async createBoostWithPermit2(
|
|
688
|
+
budget: TransparentBudget | Address,
|
|
689
|
+
allocations: (FungibleTransferPayload | ERC1155TransferPayload)[],
|
|
690
|
+
_boostPayload: Omit<CreateBoostPayload, 'budget'>,
|
|
691
|
+
permit2Signature: Hex,
|
|
692
|
+
nonce: bigint,
|
|
693
|
+
deadline: bigint,
|
|
694
|
+
_params?: WriteParams,
|
|
695
|
+
) {
|
|
696
|
+
const [payload, options] =
|
|
697
|
+
this.validateDeploymentConfig<CreateBoostPayload>({
|
|
698
|
+
..._boostPayload,
|
|
699
|
+
budget: this.TransparentBudget(
|
|
700
|
+
typeof budget === 'string' ? budget : budget.assertValidAddress(),
|
|
701
|
+
),
|
|
702
|
+
});
|
|
703
|
+
const desiredChainId = _params?.chainId;
|
|
704
|
+
const { chainId, address: coreAddress } = assertValidAddressByChainId(
|
|
705
|
+
options.config,
|
|
706
|
+
this.addresses,
|
|
707
|
+
desiredChainId,
|
|
708
|
+
);
|
|
709
|
+
|
|
710
|
+
const boostFactory = createWriteContract({
|
|
711
|
+
abi: transparentBudgetAbi,
|
|
712
|
+
functionName: 'createBoostWithPermit2',
|
|
713
|
+
address:
|
|
714
|
+
typeof budget === 'string' ? budget : budget.assertValidAddress(),
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
const onChainPayload = await this.prepareCreateBoostPayload(
|
|
718
|
+
coreAddress,
|
|
719
|
+
chainId,
|
|
720
|
+
payload,
|
|
721
|
+
options,
|
|
722
|
+
);
|
|
723
|
+
|
|
724
|
+
const boostHash = await boostFactory(options.config, {
|
|
725
|
+
...this.optionallyAttachAccount(options.account),
|
|
726
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
727
|
+
...(_params as any),
|
|
728
|
+
chainId,
|
|
729
|
+
args: [
|
|
730
|
+
allocations.map(prepareTransfer),
|
|
731
|
+
coreAddress,
|
|
732
|
+
prepareBoostPayload(onChainPayload),
|
|
733
|
+
permit2Signature,
|
|
734
|
+
nonce,
|
|
735
|
+
deadline,
|
|
736
|
+
],
|
|
737
|
+
});
|
|
738
|
+
const receipt = await waitForTransactionReceipt(options.config, {
|
|
739
|
+
hash: boostHash,
|
|
740
|
+
});
|
|
741
|
+
const boostCreatedLog = parseEventLogs({
|
|
742
|
+
abi: boostCoreAbi,
|
|
743
|
+
eventName: 'BoostCreated',
|
|
744
|
+
logs: receipt.logs,
|
|
745
|
+
}).at(0);
|
|
746
|
+
let boostId = 0n;
|
|
747
|
+
if (!boostCreatedLog) throw new BoostCoreNoIdentifierEmitted();
|
|
748
|
+
boostId = boostCreatedLog?.args.boostId;
|
|
749
|
+
const boost = await this.readBoost(boostId);
|
|
750
|
+
return new Boost({
|
|
751
|
+
id: boostId,
|
|
752
|
+
budget: payload.budget.at(boost.budget),
|
|
753
|
+
action: payload.action.at(boost.action),
|
|
754
|
+
validator: payload.validator!.at(boost.validator),
|
|
755
|
+
allowList: payload.allowList!.at(boost.allowList),
|
|
756
|
+
incentives: payload.incentives.map((incentive, i) =>
|
|
757
|
+
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
758
|
+
incentive.at(boost.incentives.at(i)!),
|
|
759
|
+
),
|
|
760
|
+
protocolFee: boost.protocolFee,
|
|
761
|
+
maxParticipants: boost.maxParticipants,
|
|
762
|
+
owner: boost.owner,
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Returns a transaction hash and simulated Boost creation using a TransparentBudget and Permit2
|
|
768
|
+
*
|
|
769
|
+
* @public
|
|
770
|
+
* @async
|
|
771
|
+
* @param {TransparentBudget | Address} budget - Either an instance of a transparent budget, or the address of a transparent budget
|
|
772
|
+
* @param {(FungibleTransferPayload | ERC1155TransferPayload)[]} allocations - An array of transfers to be allocated to the budget prior to Boost creation
|
|
773
|
+
* @param {Omit<CreateBoostPayload, 'budget'>} _boostPayload - The core Boost configuration sans budget
|
|
774
|
+
* @param {Hex} permit2Signature - The packed signature that was the result of signing the EIP712 hash of `permit`.
|
|
775
|
+
* @param {bigint} nonce - The nonce for the permit2 batch transfer
|
|
776
|
+
* @param {bigint} deadline - The deadline for the permit2 batch transfer
|
|
777
|
+
* @param {?WriteParams} [params]
|
|
778
|
+
* @returns {Promise<HashAndSimulatedResult>}
|
|
779
|
+
*/
|
|
780
|
+
public async createBoostWithPermit2Raw(
|
|
781
|
+
budget: TransparentBudget | Address,
|
|
782
|
+
allocations: (FungibleTransferPayload | ERC1155TransferPayload)[],
|
|
783
|
+
_boostPayload: Omit<CreateBoostPayload, 'budget'>,
|
|
784
|
+
permit2Signature: Hex,
|
|
785
|
+
nonce: bigint,
|
|
786
|
+
deadline: bigint,
|
|
787
|
+
_params?: WriteParams,
|
|
788
|
+
): Promise<HashAndSimulatedResult> {
|
|
789
|
+
const { request, result } = await this.simulateCreateBoostWithPermit2(
|
|
790
|
+
budget,
|
|
791
|
+
allocations,
|
|
792
|
+
_boostPayload,
|
|
793
|
+
permit2Signature,
|
|
794
|
+
nonce,
|
|
795
|
+
deadline,
|
|
796
|
+
_params,
|
|
797
|
+
);
|
|
798
|
+
const hash = await writeTransparentBudgetCreateBoostWithPermit2(
|
|
799
|
+
this._config,
|
|
800
|
+
request,
|
|
801
|
+
);
|
|
802
|
+
return { hash, result };
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Returns a simulated Boost creation using a TransparentBudget and Permit2
|
|
807
|
+
*
|
|
808
|
+
* @public
|
|
809
|
+
* @async
|
|
810
|
+
* @param {TransparentBudget | Address} budget - Either an instance of a transparent budget, or the address of a transparent budget
|
|
811
|
+
* @param {(FungibleTransferPayload | ERC1155TransferPayload)[]} allocations - An array of transfers to be allocated to the budget prior to Boost creation
|
|
812
|
+
* @param {Omit<CreateBoostPayload, 'budget'>} _boostPayload - The core Boost configuration sans budget
|
|
813
|
+
* @param {Hex} permit2Signature - The packed signature that was the result of signing the EIP712 hash of `permit`.
|
|
814
|
+
* @param {bigint} nonce - The nonce for the permit2 batch transfer
|
|
815
|
+
* @param {bigint} deadline - The deadline for the permit2 batch transfer
|
|
816
|
+
* @param {?WriteParams} [params]
|
|
817
|
+
* @returns {Promise<SimulateContractReturnType>}
|
|
818
|
+
*/
|
|
819
|
+
public async simulateCreateBoostWithPermit2(
|
|
820
|
+
budget: TransparentBudget | Address,
|
|
821
|
+
allocations: (FungibleTransferPayload | ERC1155TransferPayload)[],
|
|
822
|
+
_boostPayload: Omit<CreateBoostPayload, 'budget'>,
|
|
823
|
+
permit2Signature: Hex,
|
|
824
|
+
nonce: bigint,
|
|
825
|
+
deadline: bigint,
|
|
826
|
+
_params?: WriteParams,
|
|
827
|
+
) {
|
|
828
|
+
const [payload, options] =
|
|
829
|
+
this.validateDeploymentConfig<CreateBoostPayload>({
|
|
830
|
+
..._boostPayload,
|
|
831
|
+
budget: this.TransparentBudget(
|
|
832
|
+
typeof budget === 'string' ? budget : budget.assertValidAddress(),
|
|
833
|
+
),
|
|
834
|
+
});
|
|
835
|
+
const desiredChainId = _params?.chainId;
|
|
836
|
+
const { chainId, address: coreAddress } = assertValidAddressByChainId(
|
|
837
|
+
options.config,
|
|
838
|
+
this.addresses,
|
|
839
|
+
desiredChainId,
|
|
840
|
+
);
|
|
841
|
+
|
|
842
|
+
const onChainPayload = await this.prepareCreateBoostPayload(
|
|
843
|
+
coreAddress,
|
|
844
|
+
chainId,
|
|
845
|
+
payload,
|
|
846
|
+
options,
|
|
847
|
+
);
|
|
848
|
+
|
|
849
|
+
return await simulateTransparentBudgetCreateBoostWithPermit2(this._config, {
|
|
850
|
+
...this.optionallyAttachAccount(),
|
|
851
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
852
|
+
...(_params as any),
|
|
853
|
+
address:
|
|
854
|
+
typeof budget === 'string' ? budget : budget.assertValidAddress(),
|
|
855
|
+
chainId,
|
|
856
|
+
args: [
|
|
857
|
+
allocations.map(prepareTransfer),
|
|
858
|
+
coreAddress,
|
|
859
|
+
prepareBoostPayload(onChainPayload),
|
|
860
|
+
permit2Signature,
|
|
861
|
+
nonce,
|
|
862
|
+
deadline,
|
|
863
|
+
],
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
|
|
501
867
|
// This function mutates payload, which isn't awesome but it's fine
|
|
502
868
|
private async prepareCreateBoostPayload(
|
|
503
869
|
coreAddress: Address,
|
|
@@ -549,8 +915,10 @@ export class BoostCore extends Deployable<
|
|
|
549
915
|
let budgetPayload: BoostPayload['budget'] = zeroAddress;
|
|
550
916
|
if (payload.budget.address) {
|
|
551
917
|
budgetPayload = payload.budget.address;
|
|
552
|
-
if (!(
|
|
553
|
-
|
|
918
|
+
if (!(payload.budget instanceof TransparentBudget)) {
|
|
919
|
+
if (!(await payload.budget.isAuthorized(coreAddress))) {
|
|
920
|
+
throw new BudgetMustAuthorizeBoostCore(coreAddress);
|
|
921
|
+
}
|
|
554
922
|
}
|
|
555
923
|
} else {
|
|
556
924
|
throw new MustInitializeBudgetError();
|
|
@@ -1443,6 +1811,40 @@ export class BoostCore extends Deployable<
|
|
|
1443
1811
|
);
|
|
1444
1812
|
}
|
|
1445
1813
|
// /**
|
|
1814
|
+
// * Bound {@link TransparentBudget} constructor that reuses the same configuration as the Boost Core instance.
|
|
1815
|
+
// *
|
|
1816
|
+
// * @example
|
|
1817
|
+
// * ```ts
|
|
1818
|
+
// * const budget = core.TransparentBudget('0x') // is roughly equivalent to
|
|
1819
|
+
// * const budget = new TransparentBudget({ config: core._config, account: core._account }, '0x')
|
|
1820
|
+
// * ```
|
|
1821
|
+
// * @param {DeployablePayloadOrAddress<never>} options
|
|
1822
|
+
// * @returns {TransparentBudget}
|
|
1823
|
+
// */
|
|
1824
|
+
// TransparentBudget(options: DeployablePayloadOrAddress<never>) {
|
|
1825
|
+
// return new TransparentBudget(
|
|
1826
|
+
// { config: this._config, account: this._account },
|
|
1827
|
+
// options,
|
|
1828
|
+
// );
|
|
1829
|
+
// }
|
|
1830
|
+
/**
|
|
1831
|
+
* Bound {@link TransparentBudget} constructor that reuses the same configuration as the Boost Core instance.
|
|
1832
|
+
*
|
|
1833
|
+
* @example
|
|
1834
|
+
* ```ts
|
|
1835
|
+
* const budget = core.TransparentBudget('0x') // is roughly equivalent to
|
|
1836
|
+
* const budget = new TransparentBudget({ config: core._config, account: core._account }, '0x')
|
|
1837
|
+
* ```
|
|
1838
|
+
* @param {DeployablePayloadOrAddress<ManagedBudgetPayload>} options
|
|
1839
|
+
* @returns {TransparentBudget}
|
|
1840
|
+
*/
|
|
1841
|
+
TransparentBudget(options: DeployablePayloadOrAddress<never>) {
|
|
1842
|
+
return new TransparentBudget(
|
|
1843
|
+
{ config: this._config, account: this._account },
|
|
1844
|
+
options,
|
|
1845
|
+
);
|
|
1846
|
+
}
|
|
1847
|
+
// /**
|
|
1446
1848
|
// * Bound {@link VestingBudget} constructor that reuses the same configuration as the Boost Core instance.
|
|
1447
1849
|
// *
|
|
1448
1850
|
// * @example
|
|
@@ -1611,7 +2013,7 @@ export class BoostCore extends Deployable<
|
|
|
1611
2013
|
}
|
|
1612
2014
|
|
|
1613
2015
|
/**
|
|
1614
|
-
* Bound {@link
|
|
2016
|
+
* Bound {@link ERC20VariableCriteriaIncentiveV2} constructor that reuses the same configuration as the Boost Core instance.
|
|
1615
2017
|
*
|
|
1616
2018
|
* @example
|
|
1617
2019
|
* ```ts
|
|
@@ -1620,13 +2022,13 @@ export class BoostCore extends Deployable<
|
|
|
1620
2022
|
* ```
|
|
1621
2023
|
* @param {DeployablePayloadOrAddress<ERC20VariableCrtieriaIncentivePayload>} options
|
|
1622
2024
|
* @param {?boolean} [isBase]
|
|
1623
|
-
* @returns {
|
|
2025
|
+
* @returns {ERC20VariableCrtieriaIncentiveV2}
|
|
1624
2026
|
* */
|
|
1625
|
-
|
|
1626
|
-
options: DeployablePayloadOrAddress<
|
|
2027
|
+
ERC20VariableCriteriaIncentiveV2(
|
|
2028
|
+
options: DeployablePayloadOrAddress<ERC20VariableCriteriaIncentiveV2Payload>,
|
|
1627
2029
|
isBase?: boolean,
|
|
1628
2030
|
) {
|
|
1629
|
-
return new
|
|
2031
|
+
return new ERC20VariableCriteriaIncentiveV2(
|
|
1630
2032
|
{ config: this._config, account: this._account },
|
|
1631
2033
|
options,
|
|
1632
2034
|
isBase,
|
|
@@ -1634,22 +2036,22 @@ export class BoostCore extends Deployable<
|
|
|
1634
2036
|
}
|
|
1635
2037
|
|
|
1636
2038
|
/**
|
|
1637
|
-
* Bound {@link
|
|
2039
|
+
* Bound {@link ERC20PeggedVariableCriteriaIncentiveV2} constructor that reuses the same configuration as the Boost Core instance.
|
|
1638
2040
|
*
|
|
1639
2041
|
* @example
|
|
1640
2042
|
* ```ts
|
|
1641
|
-
* const validator = core.
|
|
1642
|
-
* const validator = new
|
|
2043
|
+
* const validator = core.ERC20PeggedVariableCriteriaIncentiveV2({ ... }) // is roughly equivalent to
|
|
2044
|
+
* const validator = new ERC20PeggedVariableCriteriaIncentiveV2({ config: core._config, account: core._account }, { ... })
|
|
1643
2045
|
* ```
|
|
1644
|
-
* @param {DeployablePayloadOrAddress<
|
|
2046
|
+
* @param {DeployablePayloadOrAddress<ERC20PeggedVariableCriteriaIncentiveV2>} options
|
|
1645
2047
|
* @param {?boolean} [isBase]
|
|
1646
|
-
* @returns {
|
|
2048
|
+
* @returns {ERC20PeggedVariableCriteriaIncentiveV2}
|
|
1647
2049
|
* */
|
|
1648
|
-
|
|
1649
|
-
options: DeployablePayloadOrAddress<
|
|
2050
|
+
ERC20PeggedVariableCriteriaIncentiveV2(
|
|
2051
|
+
options: DeployablePayloadOrAddress<ERC20PeggedVariableCriteriaIncentiveV2Payload>,
|
|
1650
2052
|
isBase?: boolean,
|
|
1651
2053
|
) {
|
|
1652
|
-
return new
|
|
2054
|
+
return new ERC20PeggedVariableCriteriaIncentiveV2(
|
|
1653
2055
|
{ config: this._config, account: this._account },
|
|
1654
2056
|
options,
|
|
1655
2057
|
isBase,
|
package/src/Budgets/Budget.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
AManagedBudget,
|
|
4
4
|
AManagedBudgetWithFees,
|
|
5
5
|
AManagedBudgetWithFeesV2,
|
|
6
|
+
ATransparentBudget,
|
|
6
7
|
} from '@boostxyz/evm/deploys/componentInterfaces.json';
|
|
7
8
|
import { readContract } from '@wagmi/core';
|
|
8
9
|
import type { Address, Hex } from 'viem';
|
|
@@ -12,10 +13,14 @@ import type { ReadParams } from '../utils';
|
|
|
12
13
|
import { ManagedBudget } from './ManagedBudget';
|
|
13
14
|
import { ManagedBudgetWithFees } from './ManagedBudgetWithFees';
|
|
14
15
|
import { ManagedBudgetWithFeesV2 } from './ManagedBudgetWithFeesV2';
|
|
16
|
+
import { TransparentBudget } from './TransparentBudget';
|
|
15
17
|
|
|
16
18
|
export {
|
|
17
19
|
// VestingBudget,
|
|
18
20
|
ManagedBudget,
|
|
21
|
+
ManagedBudgetWithFees,
|
|
22
|
+
ManagedBudgetWithFeesV2,
|
|
23
|
+
TransparentBudget,
|
|
19
24
|
};
|
|
20
25
|
|
|
21
26
|
/**
|
|
@@ -27,7 +32,8 @@ export {
|
|
|
27
32
|
export type Budget =
|
|
28
33
|
| ManagedBudget
|
|
29
34
|
| ManagedBudgetWithFees
|
|
30
|
-
| ManagedBudgetWithFeesV2
|
|
35
|
+
| ManagedBudgetWithFeesV2
|
|
36
|
+
| TransparentBudget; // | VestingBudget
|
|
31
37
|
|
|
32
38
|
/**
|
|
33
39
|
* A map of Budget component interfaces to their constructors.
|
|
@@ -40,6 +46,7 @@ export const BudgetByComponentInterface = {
|
|
|
40
46
|
[AManagedBudget as Hex]: ManagedBudget,
|
|
41
47
|
[AManagedBudgetWithFees as Hex]: ManagedBudgetWithFees,
|
|
42
48
|
[AManagedBudgetWithFeesV2 as Hex]: ManagedBudgetWithFeesV2,
|
|
49
|
+
[ATransparentBudget as Hex]: TransparentBudget,
|
|
43
50
|
};
|
|
44
51
|
|
|
45
52
|
/**
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
|
|
2
|
+
import { isAddress, parseEther } from "viem";
|
|
3
|
+
import { beforeAll, describe, expect, test } from "vitest";
|
|
4
|
+
import type { MockERC20 } from "@boostxyz/test/MockERC20";
|
|
5
|
+
import type { MockERC1155 } from "@boostxyz/test/MockERC1155";
|
|
6
|
+
import {
|
|
7
|
+
type Fixtures,
|
|
8
|
+
defaultOptions,
|
|
9
|
+
deployFixtures,
|
|
10
|
+
fundTransparentBudget,
|
|
11
|
+
makeMockEventActionPayload
|
|
12
|
+
} from "@boostxyz/test/helpers";
|
|
13
|
+
import { TransparentBudget } from "./TransparentBudget";
|
|
14
|
+
import { StrategyType } from "../claiming";
|
|
15
|
+
|
|
16
|
+
let fixtures: Fixtures,
|
|
17
|
+
budget: TransparentBudget,
|
|
18
|
+
erc20: MockERC20,
|
|
19
|
+
erc1155: MockERC1155;
|
|
20
|
+
|
|
21
|
+
beforeAll(async () => {
|
|
22
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe("TransparentBudget", () => {
|
|
26
|
+
test("can successfully be deployed", async () => {
|
|
27
|
+
const budget = new TransparentBudget(defaultOptions);
|
|
28
|
+
//@ts-expect-error internal but need to testing
|
|
29
|
+
await budget.deploy();
|
|
30
|
+
expect(isAddress(budget.assertValidAddress())).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('can deploy a basic boost', async () => {
|
|
34
|
+
const { core } = fixtures
|
|
35
|
+
const { budget, erc20 } = await loadFixture(
|
|
36
|
+
fundTransparentBudget(defaultOptions, fixtures),
|
|
37
|
+
);
|
|
38
|
+
await fixtures.core.createBoostWithTransparentBudget(budget,
|
|
39
|
+
[
|
|
40
|
+
{
|
|
41
|
+
target: defaultOptions.account.address,
|
|
42
|
+
asset: erc20.assertValidAddress(),
|
|
43
|
+
amount: parseEther("110")
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
{
|
|
47
|
+
owner: defaultOptions.account.address,
|
|
48
|
+
protocolFee: 0n,
|
|
49
|
+
maxParticipants: 10000n,
|
|
50
|
+
validator: core.SignerValidator({
|
|
51
|
+
signers: [defaultOptions.account.address],
|
|
52
|
+
validatorCaller: defaultOptions.account.address,
|
|
53
|
+
}),
|
|
54
|
+
action: core.EventAction(
|
|
55
|
+
makeMockEventActionPayload(
|
|
56
|
+
core.assertValidAddress(),
|
|
57
|
+
erc20.assertValidAddress(),
|
|
58
|
+
),
|
|
59
|
+
),
|
|
60
|
+
incentives: [
|
|
61
|
+
core.ERC20Incentive({
|
|
62
|
+
asset: erc20.assertValidAddress(),
|
|
63
|
+
reward: parseEther("10"),
|
|
64
|
+
limit: 10n,
|
|
65
|
+
strategy: StrategyType.POOL,
|
|
66
|
+
}),
|
|
67
|
+
],
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
});
|