@boostxyz/sdk 6.1.3 → 7.0.0-canary.1

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.
Files changed (186) hide show
  1. package/README.md +1 -1
  2. package/dist/Actions/Action.cjs +1 -1
  3. package/dist/Actions/Action.js +7 -7
  4. package/dist/Actions/EventAction.cjs +1 -1
  5. package/dist/Actions/EventAction.cjs.map +1 -1
  6. package/dist/Actions/EventAction.d.ts +10 -0
  7. package/dist/Actions/EventAction.d.ts.map +1 -1
  8. package/dist/Actions/EventAction.js +77 -76
  9. package/dist/Actions/EventAction.js.map +1 -1
  10. package/dist/AllowLists/AllowList.cjs +1 -1
  11. package/dist/AllowLists/AllowList.js +5 -5
  12. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  13. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
  14. package/dist/AllowLists/SimpleAllowList.js +17 -17
  15. package/dist/AllowLists/SimpleAllowList.js.map +1 -1
  16. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  17. package/dist/AllowLists/SimpleDenyList.js +3 -3
  18. package/dist/Auth/PassthroughAuth.cjs +1 -1
  19. package/dist/Auth/PassthroughAuth.js +1 -1
  20. package/dist/BoostCore.cjs +2 -2
  21. package/dist/BoostCore.cjs.map +1 -1
  22. package/dist/BoostCore.d.ts +1894 -267
  23. package/dist/BoostCore.d.ts.map +1 -1
  24. package/dist/BoostCore.js +831 -520
  25. package/dist/BoostCore.js.map +1 -1
  26. package/dist/BoostRegistry.cjs +1 -1
  27. package/dist/BoostRegistry.js +48 -48
  28. package/dist/Budget-BgGihcwx.js +1124 -0
  29. package/dist/Budget-BgGihcwx.js.map +1 -0
  30. package/dist/Budget-DYlTLLwg.cjs +2 -0
  31. package/dist/Budget-DYlTLLwg.cjs.map +1 -0
  32. package/dist/Budgets/Budget.cjs +1 -1
  33. package/dist/Budgets/Budget.d.ts +5 -4
  34. package/dist/Budgets/Budget.d.ts.map +1 -1
  35. package/dist/Budgets/Budget.js +9 -6
  36. package/dist/Budgets/ManagedBudget.cjs +1 -1
  37. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  38. package/dist/Budgets/ManagedBudget.d.ts +4 -0
  39. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  40. package/dist/Budgets/ManagedBudget.js +22 -22
  41. package/dist/Budgets/ManagedBudgetWithFees.d.ts +4 -0
  42. package/dist/Budgets/ManagedBudgetWithFees.d.ts.map +1 -1
  43. package/dist/Budgets/ManagedBudgetWithFeesV2.d.ts +4 -0
  44. package/dist/Budgets/ManagedBudgetWithFeesV2.d.ts.map +1 -1
  45. package/dist/Budgets/TransparentBudget.d.ts +944 -0
  46. package/dist/Budgets/TransparentBudget.d.ts.map +1 -0
  47. package/dist/Budgets/VestingBudget.d.ts +4 -0
  48. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  49. package/dist/Deployable/Deployable.cjs.map +1 -1
  50. package/dist/Deployable/Deployable.d.ts +1 -1
  51. package/dist/Deployable/Deployable.d.ts.map +1 -1
  52. package/dist/Deployable/Deployable.js.map +1 -1
  53. package/dist/Deployable/DeployableTarget.cjs +1 -1
  54. package/dist/Deployable/DeployableTarget.js +1 -1
  55. package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
  56. package/dist/Deployable/DeployableTargetWithRBAC.js +20 -20
  57. package/dist/Incentive-BDqkFt0J.cjs +2 -0
  58. package/dist/Incentive-BDqkFt0J.cjs.map +1 -0
  59. package/dist/Incentive-DPOADY1f.js +449 -0
  60. package/dist/Incentive-DPOADY1f.js.map +1 -0
  61. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  62. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  63. package/dist/Incentives/AllowListIncentive.js +14 -14
  64. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  65. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  66. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  67. package/dist/Incentives/CGDAIncentive.js +11 -11
  68. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  69. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  70. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  71. package/dist/Incentives/ERC20Incentive.js +14 -14
  72. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  73. package/dist/Incentives/ERC20PeggedIncentive.d.ts +1 -1
  74. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.cjs +2 -0
  75. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.cjs.map +1 -0
  76. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.d.ts +3 -1
  77. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.d.ts.map +1 -1
  78. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.js +604 -0
  79. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.js.map +1 -0
  80. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.cjs +2 -0
  81. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.cjs.map +1 -0
  82. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.d.ts +1103 -0
  83. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.d.ts.map +1 -0
  84. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.js +625 -0
  85. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.js.map +1 -0
  86. package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs +1 -1
  87. package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs.map +1 -1
  88. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +11 -1
  89. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -1
  90. package/dist/Incentives/ERC20VariableCriteriaIncentive.js +112 -80
  91. package/dist/Incentives/ERC20VariableCriteriaIncentive.js.map +1 -1
  92. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.cjs +2 -0
  93. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.cjs.map +1 -0
  94. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.d.ts +903 -0
  95. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.d.ts.map +1 -0
  96. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.js +242 -0
  97. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.js.map +1 -0
  98. package/dist/Incentives/ERC20VariableIncentive.cjs +1 -1
  99. package/dist/Incentives/ERC20VariableIncentive.cjs.map +1 -1
  100. package/dist/Incentives/ERC20VariableIncentive.d.ts +3 -3
  101. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  102. package/dist/Incentives/ERC20VariableIncentive.js +22 -22
  103. package/dist/Incentives/ERC20VariableIncentive.js.map +1 -1
  104. package/dist/Incentives/Incentive.cjs +1 -1
  105. package/dist/Incentives/Incentive.d.ts +8 -6
  106. package/dist/Incentives/Incentive.d.ts.map +1 -1
  107. package/dist/Incentives/Incentive.js +19 -14
  108. package/dist/Incentives/Incentive.js.map +1 -1
  109. package/dist/Incentives/PointsIncentive.cjs +1 -1
  110. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  111. package/dist/Incentives/PointsIncentive.js +9 -9
  112. package/dist/Incentives/PointsIncentive.js.map +1 -1
  113. package/dist/SimpleDenyList-B_AcmgYq.cjs +2 -0
  114. package/dist/{SimpleDenyList-DgjVf7FK.cjs.map → SimpleDenyList-B_AcmgYq.cjs.map} +1 -1
  115. package/dist/SimpleDenyList-BbDLzRw7.js +133 -0
  116. package/dist/{SimpleDenyList-BKfPoTo1.js.map → SimpleDenyList-BbDLzRw7.js.map} +1 -1
  117. package/dist/Validators/LimitedSignerValidator.cjs +1 -1
  118. package/dist/Validators/LimitedSignerValidator.cjs.map +1 -1
  119. package/dist/Validators/LimitedSignerValidator.js +13 -13
  120. package/dist/Validators/LimitedSignerValidator.js.map +1 -1
  121. package/dist/Validators/SignerValidator.cjs +1 -1
  122. package/dist/Validators/SignerValidator.cjs.map +1 -1
  123. package/dist/Validators/SignerValidator.js +52 -52
  124. package/dist/Validators/SignerValidator.js.map +1 -1
  125. package/dist/Validators/Validator.cjs +1 -1
  126. package/dist/Validators/Validator.js +2 -2
  127. package/dist/componentInterfaces-C5ig8mCK.cjs +2 -0
  128. package/dist/componentInterfaces-C5ig8mCK.cjs.map +1 -0
  129. package/dist/componentInterfaces-Ddus5rIA.js +23 -0
  130. package/dist/componentInterfaces-Ddus5rIA.js.map +1 -0
  131. package/dist/deployments-C17nvui-.cjs +2 -0
  132. package/dist/deployments-C17nvui-.cjs.map +1 -0
  133. package/dist/deployments-CH4Xmkbv.js +132 -0
  134. package/dist/{deployments-W_LUj833.js.map → deployments-CH4Xmkbv.js.map} +1 -1
  135. package/dist/deployments.json +63 -48
  136. package/dist/{generated-CElkFqkY.js → generated-CINzoGbl.js} +2611 -955
  137. package/dist/generated-CINzoGbl.js.map +1 -0
  138. package/dist/generated-C_JEoLDO.cjs +3 -0
  139. package/dist/generated-C_JEoLDO.cjs.map +1 -0
  140. package/dist/index.cjs +1 -1
  141. package/dist/index.d.ts +3 -0
  142. package/dist/index.d.ts.map +1 -1
  143. package/dist/index.js +167 -154
  144. package/dist/index.js.map +1 -1
  145. package/dist/utils.cjs.map +1 -1
  146. package/dist/utils.js.map +1 -1
  147. package/package.json +20 -2
  148. package/src/Actions/EventAction.ts +11 -0
  149. package/src/BoostCore.test.ts +14 -9
  150. package/src/BoostCore.ts +428 -26
  151. package/src/Budgets/Budget.ts +8 -1
  152. package/src/Budgets/TransparentBudget.test.ts +70 -0
  153. package/src/Budgets/TransparentBudget.ts +334 -0
  154. package/src/Deployable/Deployable.ts +1 -1
  155. package/src/Incentives/ERC20PeggedIncentive.ts +1 -1
  156. package/src/Incentives/ERC20PeggedVariableCriteriaIncentive.ts +3 -1
  157. package/src/Incentives/{ERC20PeggedVariableCriteriaIncentive.test.ts → ERC20PeggedVariableCriteriaIncentiveV2.test.ts} +20 -16
  158. package/src/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.ts +872 -0
  159. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +50 -1
  160. package/src/Incentives/{ERC20VariableCriteriaIncentive.test.ts → ERC20VariableCriteriaIncentiveV2.test.ts} +24 -19
  161. package/src/Incentives/ERC20VariableCriteriaIncentiveV2.ts +447 -0
  162. package/src/Incentives/ERC20VariableIncentive.ts +4 -2
  163. package/src/Incentives/Incentive.ts +13 -2
  164. package/src/index.test.ts +2 -2
  165. package/src/index.ts +3 -0
  166. package/src/utils.ts +1 -1
  167. package/dist/Budget-BjfL8dVX.cjs +0 -2
  168. package/dist/Budget-BjfL8dVX.cjs.map +0 -1
  169. package/dist/Budget-DD7IPuDx.js +0 -922
  170. package/dist/Budget-DD7IPuDx.js.map +0 -1
  171. package/dist/Incentive-V1RjH38L.js +0 -1036
  172. package/dist/Incentive-V1RjH38L.js.map +0 -1
  173. package/dist/Incentive-gVTfsnMB.cjs +0 -2
  174. package/dist/Incentive-gVTfsnMB.cjs.map +0 -1
  175. package/dist/SimpleDenyList-BKfPoTo1.js +0 -133
  176. package/dist/SimpleDenyList-DgjVf7FK.cjs +0 -2
  177. package/dist/componentInterfaces-CA1UIqWL.js +0 -20
  178. package/dist/componentInterfaces-CA1UIqWL.js.map +0 -1
  179. package/dist/componentInterfaces-aBgBbB7r.cjs +0 -2
  180. package/dist/componentInterfaces-aBgBbB7r.cjs.map +0 -1
  181. package/dist/deployments-CwTZr-cK.cjs +0 -2
  182. package/dist/deployments-CwTZr-cK.cjs.map +0 -1
  183. package/dist/deployments-W_LUj833.js +0 -117
  184. package/dist/generated-BPiHi7W2.cjs +0 -3
  185. package/dist/generated-BPiHi7W2.cjs.map +0 -1
  186. 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
- ERC20PeggedVariableCriteriaIncentive,
106
- type ERC20PeggedVariableCriteriaIncentivePayload,
107
- } from './Incentives/ERC20PeggedVariableCriteriaIncentive';
109
+ ERC20PeggedVariableCriteriaIncentiveV2,
110
+ type ERC20PeggedVariableCriteriaIncentiveV2Payload,
111
+ } from './Incentives/ERC20PeggedVariableCriteriaIncentiveV2';
108
112
  import {
109
- ERC20VariableCriteriaIncentive,
110
- type ERC20VariableCriteriaIncentivePayload,
111
- } from './Incentives/ERC20VariableCriteriaIncentive';
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 { AssetType } from './transfers';
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 (!(await payload.budget.isAuthorized(coreAddress))) {
553
- throw new BudgetMustAuthorizeBoostCore(coreAddress);
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 ERC20VariableCriteriaIncentive} constructor that reuses the same configuration as the Boost Core instance.
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 {ERC20VariableCrtieriaIncentive}
2025
+ * @returns {ERC20VariableCrtieriaIncentiveV2}
1624
2026
  * */
1625
- ERC20VariableCriteriaIncentive(
1626
- options: DeployablePayloadOrAddress<ERC20VariableCriteriaIncentivePayload>,
2027
+ ERC20VariableCriteriaIncentiveV2(
2028
+ options: DeployablePayloadOrAddress<ERC20VariableCriteriaIncentiveV2Payload>,
1627
2029
  isBase?: boolean,
1628
2030
  ) {
1629
- return new ERC20VariableCriteriaIncentive(
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 ERC20PeggedVariableCriteriaIncentive} constructor that reuses the same configuration as the Boost Core instance.
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.ERC20PeggedVariableCriteriaIncentive({ ... }) // is roughly equivalent to
1642
- * const validator = new ERC20PeggedVariableCriteriaIncentive({ config: core._config, account: core._account }, { ... })
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<ERC20PeggedVariableCriteriaIncentive>} options
2046
+ * @param {DeployablePayloadOrAddress<ERC20PeggedVariableCriteriaIncentiveV2>} options
1645
2047
  * @param {?boolean} [isBase]
1646
- * @returns {ERC20PeggedVariableCriteriaIncentive}
2048
+ * @returns {ERC20PeggedVariableCriteriaIncentiveV2}
1647
2049
  * */
1648
- ERC20PeggedVariableCriteriaIncentive(
1649
- options: DeployablePayloadOrAddress<ERC20PeggedVariableCriteriaIncentivePayload>,
2050
+ ERC20PeggedVariableCriteriaIncentiveV2(
2051
+ options: DeployablePayloadOrAddress<ERC20PeggedVariableCriteriaIncentiveV2Payload>,
1650
2052
  isBase?: boolean,
1651
2053
  ) {
1652
- return new ERC20PeggedVariableCriteriaIncentive(
2054
+ return new ERC20PeggedVariableCriteriaIncentiveV2(
1653
2055
  { config: this._config, account: this._account },
1654
2056
  options,
1655
2057
  isBase,
@@ -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; // | VestingBudget
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
+ });