@boostxyz/sdk 2.0.0 → 2.1.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.
Files changed (109) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.js +4 -4
  3. package/dist/Actions/EventAction.cjs +1 -1
  4. package/dist/Actions/EventAction.js +17 -17
  5. package/dist/Actions/EventAction.js.map +1 -1
  6. package/dist/AllowLists/AllowList.cjs +1 -1
  7. package/dist/AllowLists/AllowList.js +5 -5
  8. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  9. package/dist/AllowLists/SimpleAllowList.js +19 -19
  10. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  11. package/dist/AllowLists/SimpleDenyList.js +3 -3
  12. package/dist/Auth/PassthroughAuth.cjs +1 -1
  13. package/dist/Auth/PassthroughAuth.js +1 -1
  14. package/dist/BoostCore.cjs +2 -2
  15. package/dist/BoostCore.cjs.map +1 -1
  16. package/dist/BoostCore.d.ts +14 -0
  17. package/dist/BoostCore.d.ts.map +1 -1
  18. package/dist/BoostCore.js +100 -81
  19. package/dist/BoostCore.js.map +1 -1
  20. package/dist/BoostRegistry.cjs +1 -1
  21. package/dist/BoostRegistry.js +31 -31
  22. package/dist/Budget-B0kJsZtZ.cjs +2 -0
  23. package/dist/Budget-B0kJsZtZ.cjs.map +1 -0
  24. package/dist/Budget-NtzY9H7G.js +462 -0
  25. package/dist/Budget-NtzY9H7G.js.map +1 -0
  26. package/dist/Budgets/Budget.cjs +1 -1
  27. package/dist/Budgets/Budget.cjs.map +1 -1
  28. package/dist/Budgets/Budget.d.ts +5 -4
  29. package/dist/Budgets/Budget.d.ts.map +1 -1
  30. package/dist/Budgets/Budget.js +9 -26
  31. package/dist/Budgets/Budget.js.map +1 -1
  32. package/dist/Budgets/ManagedBudget.cjs +1 -1
  33. package/dist/Budgets/ManagedBudget.js +34 -34
  34. package/dist/Budgets/ManagedBudgetWithFees.d.ts +1203 -0
  35. package/dist/Budgets/ManagedBudgetWithFees.d.ts.map +1 -0
  36. package/dist/Deployable/DeployableTarget.cjs +1 -1
  37. package/dist/Deployable/DeployableTarget.js +1 -1
  38. package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
  39. package/dist/Deployable/DeployableTargetWithRBAC.js +23 -23
  40. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  41. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  42. package/dist/Incentives/AllowListIncentive.js +16 -16
  43. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  44. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  45. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  46. package/dist/Incentives/CGDAIncentive.js +28 -28
  47. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  48. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  49. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  50. package/dist/Incentives/ERC20Incentive.js +25 -25
  51. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  52. package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs +1 -1
  53. package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs.map +1 -1
  54. package/dist/Incentives/ERC20VariableCriteriaIncentive.js +29 -29
  55. package/dist/Incentives/ERC20VariableCriteriaIncentive.js.map +1 -1
  56. package/dist/Incentives/ERC20VariableIncentive.cjs +1 -1
  57. package/dist/Incentives/ERC20VariableIncentive.cjs.map +1 -1
  58. package/dist/Incentives/ERC20VariableIncentive.js +6 -6
  59. package/dist/Incentives/ERC20VariableIncentive.js.map +1 -1
  60. package/dist/Incentives/Incentive.cjs +1 -1
  61. package/dist/Incentives/Incentive.js +4 -4
  62. package/dist/Incentives/PointsIncentive.cjs +1 -1
  63. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  64. package/dist/Incentives/PointsIncentive.js +12 -12
  65. package/dist/Incentives/PointsIncentive.js.map +1 -1
  66. package/dist/{SimpleDenyList-wDvsNIuY.cjs → SimpleDenyList-B65fnca2.cjs} +2 -2
  67. package/dist/{SimpleDenyList-wDvsNIuY.cjs.map → SimpleDenyList-B65fnca2.cjs.map} +1 -1
  68. package/dist/{SimpleDenyList-D-rGBaay.js → SimpleDenyList-UvXQl2vm.js} +20 -20
  69. package/dist/{SimpleDenyList-D-rGBaay.js.map → SimpleDenyList-UvXQl2vm.js.map} +1 -1
  70. package/dist/Validators/LimitedSignerValidator.cjs +1 -1
  71. package/dist/Validators/LimitedSignerValidator.js +9 -9
  72. package/dist/Validators/SignerValidator.cjs +1 -1
  73. package/dist/Validators/SignerValidator.js +8 -8
  74. package/dist/Validators/Validator.cjs +1 -1
  75. package/dist/Validators/Validator.cjs.map +1 -1
  76. package/dist/Validators/Validator.js +20 -20
  77. package/dist/componentInterfaces-Bt-4sNB5.cjs +2 -0
  78. package/dist/componentInterfaces-Bt-4sNB5.cjs.map +1 -0
  79. package/dist/componentInterfaces-dakxtQHf.js +16 -0
  80. package/dist/componentInterfaces-dakxtQHf.js.map +1 -0
  81. package/dist/deployments-DxkwtCyu.cjs +2 -0
  82. package/dist/deployments-DxkwtCyu.cjs.map +1 -0
  83. package/dist/{deployments-BdPDIh-i.js → deployments-ZLVwJGZD.js} +33 -30
  84. package/dist/deployments-ZLVwJGZD.js.map +1 -0
  85. package/dist/deployments.json +17 -14
  86. package/dist/{generated-CDEDSOGZ.js → generated-B0XfMfoq.js} +1037 -470
  87. package/dist/generated-B0XfMfoq.js.map +1 -0
  88. package/dist/generated-pNKCp_Ez.cjs +3 -0
  89. package/dist/generated-pNKCp_Ez.cjs.map +1 -0
  90. package/dist/index.cjs +1 -1
  91. package/dist/index.d.ts +1 -0
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +148 -145
  94. package/package.json +1 -1
  95. package/src/BoostCore.ts +30 -0
  96. package/src/Budgets/Budget.ts +8 -3
  97. package/src/Budgets/ManagedBudgetWithFees.test.ts +286 -0
  98. package/src/Budgets/ManagedBudgetWithFees.ts +671 -0
  99. package/src/index.ts +1 -0
  100. package/dist/componentInterfaces-BQw7DH-m.cjs +0 -2
  101. package/dist/componentInterfaces-BQw7DH-m.cjs.map +0 -1
  102. package/dist/componentInterfaces-C0vuWQlh.js +0 -15
  103. package/dist/componentInterfaces-C0vuWQlh.js.map +0 -1
  104. package/dist/deployments--f75Pthq.cjs +0 -2
  105. package/dist/deployments--f75Pthq.cjs.map +0 -1
  106. package/dist/deployments-BdPDIh-i.js.map +0 -1
  107. package/dist/generated-CDEDSOGZ.js.map +0 -1
  108. package/dist/generated-D3DE5TfH.cjs +0 -3
  109. package/dist/generated-D3DE5TfH.cjs.map +0 -1
@@ -0,0 +1,671 @@
1
+ import {
2
+ managedBudgetWithFeesAbi,
3
+ readManagedBudgetAvailable,
4
+ readManagedBudgetDistributed,
5
+ readManagedBudgetOwner,
6
+ readManagedBudgetTotal,
7
+ readManagedBudgetWithFeesManagementFee,
8
+ simulateManagedBudgetAllocate,
9
+ simulateManagedBudgetClawback,
10
+ simulateManagedBudgetClawbackFromTarget,
11
+ simulateManagedBudgetDisburse,
12
+ simulateManagedBudgetDisburseBatch,
13
+ simulateManagedBudgetWithFeesPayManagementFee,
14
+ simulateManagedBudgetWithFeesSetManagementFee,
15
+ writeManagedBudgetAllocate,
16
+ writeManagedBudgetClawback,
17
+ writeManagedBudgetClawbackFromTarget,
18
+ writeManagedBudgetDisburse,
19
+ writeManagedBudgetDisburseBatch,
20
+ writeManagedBudgetWithFeesPayManagementFee,
21
+ writeManagedBudgetWithFeesSetManagementFee,
22
+ } from '@boostxyz/evm';
23
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/budgets/ManagedBudgetWithFees.sol/ManagedBudgetWithFees.json';
24
+ import { getAccount } from '@wagmi/core';
25
+ import {
26
+ type Address,
27
+ type ContractEventName,
28
+ type Hex,
29
+ encodeAbiParameters,
30
+ parseAbiParameters,
31
+ zeroAddress,
32
+ } from 'viem';
33
+ import { ManagedBudgetWithFees as ManagedBudgetWithFeesBases } from '../../dist/deployments.json';
34
+ import type {
35
+ DeployableOptions,
36
+ GenericDeployableParams,
37
+ } from '../Deployable/Deployable';
38
+ import {
39
+ DeployableTargetWithRBAC,
40
+ type Roles,
41
+ } from '../Deployable/DeployableTargetWithRBAC';
42
+ import { DeployableUnknownOwnerProvidedError } from '../errors';
43
+ import type {
44
+ ERC1155TransferPayload,
45
+ FungibleTransferPayload,
46
+ } from '../transfers';
47
+ import {
48
+ type GenericLog,
49
+ type ReadParams,
50
+ RegistryType,
51
+ type WriteParams,
52
+ } from '../utils';
53
+ import { prepareTransfer } from './ManagedBudget';
54
+ export { managedBudgetWithFeesAbi };
55
+ export type { ERC1155TransferPayload, FungibleTransferPayload };
56
+
57
+ /**
58
+ * The object representation of a `ManagedBudgetWithFeesPayload.InitPayload`
59
+ *
60
+ * @export
61
+ * @interface ManagedBudgetWithFeesPayload
62
+ * @typedef {ManagedBudgetWithFeesPayload}
63
+ */
64
+ export interface ManagedBudgetWithFeesPayload {
65
+ /**
66
+ * The budget's owner
67
+ *
68
+ * @type {Address}
69
+ */
70
+ owner: Address;
71
+ /**
72
+ * List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
73
+ *
74
+ * @type {Address[]}
75
+ */
76
+ authorized: Address[];
77
+ /**
78
+ * List of roles to assign to the corresponding account by index.
79
+ *
80
+ * @type {Roles[]}
81
+ */
82
+ roles: Roles[];
83
+ /**
84
+ * Management Fee rate for incentive payouts
85
+ *
86
+ * @type {bigint}
87
+ */
88
+ managementFee: bigint;
89
+ }
90
+
91
+ /**
92
+ * A generic `viem.Log` event with support for `ManagedBudgetWithFees` event types.
93
+ *
94
+ * @export
95
+ * @typedef {ManagedBudgetWithFeesLog}
96
+ * @template {ContractEventName<typeof managedBudgetWithFeesAbi>} [event=ContractEventName<
97
+ * typeof managedBudgetWithFeesAbi
98
+ * >]
99
+ */
100
+ export type ManagedBudgetWithFeesLog<
101
+ event extends ContractEventName<
102
+ typeof managedBudgetWithFeesAbi
103
+ > = ContractEventName<typeof managedBudgetWithFeesAbi>,
104
+ > = GenericLog<typeof managedBudgetWithFeesAbi, event>;
105
+
106
+ /**
107
+ * A minimal budget implementation that simply holds and distributes tokens (ERC20-like and native)
108
+ * This type of budget supports ETH, ERC20, and ERC1155 assets only
109
+ *
110
+ * @export
111
+ * @class ManagedBudgetWithFees
112
+ * @typedef {ManagedBudgetWithFees}
113
+ * @extends {DeployableTargetWithRBAC<ManagedBudgetWithFeesPayload>}
114
+ */
115
+ export class ManagedBudgetWithFees extends DeployableTargetWithRBAC<
116
+ ManagedBudgetWithFeesPayload,
117
+ typeof managedBudgetWithFeesAbi
118
+ > {
119
+ /**
120
+ * @inheritdoc
121
+ *
122
+ * @public
123
+ * @readonly
124
+ * @type {*}
125
+ */
126
+ public override readonly abi = managedBudgetWithFeesAbi;
127
+ /**
128
+ * @inheritdoc
129
+ *
130
+ * @public
131
+ * @static
132
+ * @type {Record<number, Address>}
133
+ */
134
+ public static override bases: Record<number, Address> = {
135
+ 31337: import.meta.env.VITE_MANAGED_BUDGET_WITH_FEES_BASE,
136
+ ...(ManagedBudgetWithFeesBases as Record<number, Address>),
137
+ };
138
+ /**
139
+ * @inheritdoc
140
+ *
141
+ * @public
142
+ * @static
143
+ * @type {RegistryType}
144
+ */
145
+ public static override registryType: RegistryType = RegistryType.BUDGET;
146
+
147
+ /**
148
+ * Allocates assets to the budget.
149
+ * The caller must have already approved the contract to transfer the asset
150
+ * If the asset transfer fails, the allocation will revert
151
+ *
152
+ * @public
153
+ * @async
154
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
155
+ * @param {?WriteParams} [params]
156
+ * @returns {Promise<boolean>} - True if the allocation was successful
157
+ */
158
+ public async allocate(
159
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
160
+ params?: WriteParams,
161
+ ) {
162
+ return await this.awaitResult(this.allocateRaw(transfer, params));
163
+ }
164
+
165
+ /**
166
+ * Allocates assets to the budget.
167
+ * The caller must have already approved the contract to transfer the asset
168
+ * If the asset transfer fails, the allocation will revert
169
+ *
170
+ * @public
171
+ * @async
172
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
173
+ * @param {?WriteParams} [params]
174
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the allocation was successful
175
+ */
176
+ public async allocateRaw(
177
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
178
+ params?: WriteParams,
179
+ ) {
180
+ const { request, result } = await simulateManagedBudgetAllocate(
181
+ this._config,
182
+ {
183
+ address: this.assertValidAddress(),
184
+ args: [prepareTransfer(transfer)],
185
+ ...this.optionallyAttachAccount(),
186
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
187
+ ...(params as any),
188
+ },
189
+ );
190
+ const hash = await writeManagedBudgetAllocate(this._config, request);
191
+ return { hash, result };
192
+ }
193
+
194
+ /**
195
+ * Clawbacks assets from the budget.
196
+ * Only the owner can directly clawback assets from the budget
197
+ * If the amount is zero, the entire balance of the asset will be transferred to the receiver
198
+ * If the asset transfer fails, the reclamation will revert
199
+ *
200
+ * @public
201
+ * @async
202
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
203
+ * @param {?WriteParams} [params]
204
+ * @returns {Promise<boolean>} - True if the request was successful
205
+ */
206
+ public async clawback(
207
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
208
+ params?: WriteParams,
209
+ ) {
210
+ return await this.awaitResult(this.clawbackRaw(transfer, params));
211
+ }
212
+
213
+ /**
214
+ * Clawbacks assets from the budget.
215
+ * Only the owner or admin can directly clawback assets from the budget
216
+ * If the amount is zero, the entire balance of the asset will be transferred to the receiver
217
+ * If the asset transfer fails, the reclamation will revert
218
+ *
219
+ * @public
220
+ * @async
221
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
222
+ * @param {?WriteParams} [params]
223
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the request was successful
224
+ */
225
+ public async clawbackRaw(
226
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
227
+ params?: WriteParams,
228
+ ) {
229
+ const { request, result } = await simulateManagedBudgetClawback(
230
+ this._config,
231
+ {
232
+ address: this.assertValidAddress(),
233
+ args: [prepareTransfer(transfer)],
234
+ ...this.optionallyAttachAccount(),
235
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
236
+ ...(params as any),
237
+ },
238
+ );
239
+ const hash = await writeManagedBudgetClawback(this._config, request);
240
+ return { hash, result };
241
+ }
242
+
243
+ /**
244
+ * Clawbacks assets from an incentive associated with the budget via Boost Core.
245
+ * Only the authorized users can clawback assets from an incentive.
246
+ * If the asset transfer fails, the reclamation will revert.
247
+ *
248
+ * @example
249
+ * ```ts
250
+ * const [amount, address] = await budgets.budget.clawbackFromTarget(
251
+ * core.assertValidAddress(),
252
+ * erc20Incentive.buildClawbackData(1n),
253
+ * boost.id,
254
+ * incentiveId,
255
+ * );
256
+ * ```
257
+ * @public
258
+ * @async
259
+ * @param {Address} target - The address of a contract implementing clawback, typically `BoostCore`
260
+ * @param {Hex} data - The encoded data payload for the clawback, can be acquired with `incentive.buildClawbackData`
261
+ * @param {bigint | number} boostId - The ID of the boost
262
+ * @param {bigint | number} incentiveId - The ID of the incentive
263
+ * @param {?WriteParams} [params] - Optional write parameters
264
+ * @returns {Promise<[bigint, Address]>} - Returns a tuple of amount reclaimed and the address reclaimed from
265
+ */
266
+ public async clawbackFromTarget(
267
+ target: Address,
268
+ data: Hex,
269
+ boostId: bigint | number,
270
+ incentiveId: bigint | number,
271
+ params?: WriteParams,
272
+ ) {
273
+ return await this.awaitResult(
274
+ this.clawbackFromTargetRaw(target, data, boostId, incentiveId, params),
275
+ );
276
+ }
277
+
278
+ /**
279
+ * Clawbacks assets from an incentive associated with the budget via Boost Core.
280
+ * Only the authorized users can clawback assets from an incentive.
281
+ * If the asset transfer fails, the reclamation will revert.
282
+ *
283
+ * @example
284
+ * ```ts
285
+ * const { hash, result: [ amount, address ] } = await budgets.budget.clawbackFromTargetRaw(
286
+ * core.assertValidAddress(),
287
+ * erc20Incentive.buildClawbackData(1n),
288
+ * boost.id,
289
+ * incentiveId,
290
+ * );
291
+ * ```
292
+ * @public
293
+ * @async
294
+ * @param {Address} target - The address of a contract implementing clawback, typically `BoostCore`
295
+ * @param {Hex} data - The encoded data payload for the clawback, can be acquired with `incentive.buildClawbackData`
296
+ * @param {bigint | number} boostId - The ID of the boost
297
+ * @param {bigint | number} incentiveId - The ID of the incentive
298
+ * @param {?WriteParams} [params] - Optional write parameters
299
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - Returns transaction hash and simulated result
300
+ */
301
+ public async clawbackFromTargetRaw(
302
+ target: Address,
303
+ data: Hex,
304
+ boostId: bigint | number,
305
+ incentiveId: bigint | number,
306
+ params?: WriteParams,
307
+ ) {
308
+ const { request, result } = await simulateManagedBudgetClawbackFromTarget(
309
+ this._config,
310
+ {
311
+ address: this.assertValidAddress(),
312
+ args: [target, data, BigInt(boostId), BigInt(incentiveId)],
313
+ ...this.optionallyAttachAccount(),
314
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
315
+ ...(params as any),
316
+ },
317
+ );
318
+ const hash = await writeManagedBudgetClawbackFromTarget(
319
+ this._config,
320
+ request,
321
+ );
322
+ return { hash, result };
323
+ }
324
+
325
+ /**
326
+ * Disburses assets from the budget to a single recipient
327
+ * If the asset transfer fails, the disbursement will revert
328
+ *
329
+ * @public
330
+ * @async
331
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
332
+ * @param {?WriteParams} [params]
333
+ * @returns {Promise<boolean>} - True if the disbursement was successful
334
+ */
335
+ public async disburse(
336
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
337
+ params?: WriteParams,
338
+ ) {
339
+ return await this.awaitResult(this.disburseRaw(transfer, params));
340
+ }
341
+
342
+ /**
343
+ * Disburses assets from the budget to a single recipient
344
+ * If the asset transfer fails, the disbursement will revert
345
+ *
346
+ * @public
347
+ * @async
348
+ * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
349
+ * @param {?WriteParams} [params]
350
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the disbursement was successful
351
+ */
352
+ public async disburseRaw(
353
+ transfer: FungibleTransferPayload | ERC1155TransferPayload,
354
+ params?: WriteParams,
355
+ ) {
356
+ const { request, result } = await simulateManagedBudgetDisburse(
357
+ this._config,
358
+ {
359
+ address: this.assertValidAddress(),
360
+ args: [prepareTransfer(transfer)],
361
+ ...this.optionallyAttachAccount(),
362
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
363
+ ...(params as any),
364
+ },
365
+ );
366
+ const hash = await writeManagedBudgetDisburse(this._config, request);
367
+ return { hash, result };
368
+ }
369
+
370
+ /**
371
+ * Disburses assets from the budget to multiple recipients
372
+ *
373
+ * @public
374
+ * @async
375
+ * @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers
376
+ * @param {?WriteParams} [params]
377
+ * @returns {Promise<boolean>} - True if all disbursements were successful
378
+ */
379
+ public async disburseBatch(
380
+ transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,
381
+ params?: WriteParams,
382
+ ) {
383
+ return await this.awaitResult(this.disburseBatchRaw(transfers, params));
384
+ }
385
+
386
+ /**
387
+ * Disburses assets from the budget to multiple recipients
388
+ *
389
+ * @public
390
+ * @async
391
+ * @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers
392
+ * @param {?WriteParams} [params]
393
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if all disbursements were successful
394
+ */
395
+ public async disburseBatchRaw(
396
+ transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,
397
+ params?: WriteParams,
398
+ ) {
399
+ const { request, result } = await simulateManagedBudgetDisburseBatch(
400
+ this._config,
401
+ {
402
+ address: this.assertValidAddress(),
403
+ args: [transfers.map(prepareTransfer)],
404
+ ...this.optionallyAttachAccount(),
405
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
406
+ ...(params as any),
407
+ },
408
+ );
409
+ const hash = await writeManagedBudgetDisburseBatch(this._config, request);
410
+ return { hash, result };
411
+ }
412
+
413
+ /**
414
+ * Pays out reserved management fees to the boost owner
415
+ * for a given incentive
416
+ *
417
+ * @public
418
+ * @async
419
+ * @param {bigint | string} boostId
420
+ * @param {bigint | string} incentiveId
421
+ * @param {?WriteParams} [params]
422
+ * @returns {Promise<boolean>} - True if the payout was successful
423
+ */
424
+ public async payManagementFee(
425
+ boostId: bigint | string,
426
+ incentiveId: bigint | string,
427
+ params?: WriteParams,
428
+ ) {
429
+ return await this.awaitResult(
430
+ this.payManagementFeeRaw(boostId, incentiveId, params),
431
+ );
432
+ }
433
+
434
+ /**
435
+ * Pays out reserved management fees to the boost owner
436
+ *
437
+ * @public
438
+ * @async
439
+ * @param bigint boostId
440
+ * @param bigint incentiveId
441
+ * @param {?WriteParams} [params]
442
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the payout was successful
443
+ */
444
+ public async payManagementFeeRaw(
445
+ boostId: bigint | string,
446
+ incentiveId: bigint | string,
447
+ params?: WriteParams,
448
+ ) {
449
+ const { request, result } =
450
+ await simulateManagedBudgetWithFeesPayManagementFee(this._config, {
451
+ address: this.assertValidAddress(),
452
+ args: [boostId, incentiveId],
453
+ ...this.optionallyAttachAccount(),
454
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
455
+ ...(params as any),
456
+ });
457
+ const hash = await writeManagedBudgetWithFeesPayManagementFee(
458
+ this._config,
459
+ request,
460
+ );
461
+ return { hash, result };
462
+ }
463
+
464
+ /**
465
+ * Sets the management fee for the budget
466
+ * @public
467
+ * @async
468
+ * @param {bigint} managementFee
469
+ * @param {?WriteParams} [params]
470
+ * @returns {Promise<void>} - will throw if the transaction fails
471
+ */
472
+ public async setManagementFee(managementFee: bigint, params?: WriteParams) {
473
+ return await this.awaitResult(
474
+ this.setManagementFeeRaw(managementFee, params),
475
+ );
476
+ }
477
+
478
+ /**
479
+ * Sets the management fee for the budget
480
+ * @public
481
+ * @async
482
+ * @param {bigint} managementFee
483
+ * @param {?WriteParams} [params]
484
+ * @returns {Promise<{ hash: `0x${string}`; result: void; }>}
485
+ */
486
+ public async setManagementFeeRaw(
487
+ managementFee: bigint,
488
+ params?: WriteParams,
489
+ ) {
490
+ const { request, result } =
491
+ await simulateManagedBudgetWithFeesSetManagementFee(this._config, {
492
+ address: this.assertValidAddress(),
493
+ args: [managementFee],
494
+ ...this.optionallyAttachAccount(),
495
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
496
+ ...(params as any),
497
+ });
498
+ const hash = await writeManagedBudgetWithFeesSetManagementFee(
499
+ this._config,
500
+ request,
501
+ );
502
+ return { hash, result };
503
+ }
504
+
505
+ /**
506
+ * Get the configured management fee for the budget
507
+ * @public
508
+ * @param {?ReadParams} [params]
509
+ * @returns {Promise<bigint>} - The management fee
510
+ */
511
+ public async managementFee(params?: ReadParams) {
512
+ return await readManagedBudgetWithFeesManagementFee(this._config, {
513
+ address: this.assertValidAddress(),
514
+ args: [],
515
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
516
+ ...(params as any),
517
+ });
518
+ }
519
+
520
+ /**
521
+ * Get the owner of the budget
522
+ *
523
+ * @public
524
+ * @param {?ReadParams} [params]
525
+ * @returns {Promise<Address>}
526
+ */
527
+ public owner(params?: ReadParams) {
528
+ return readManagedBudgetOwner(this._config, {
529
+ address: this.assertValidAddress(),
530
+ args: [],
531
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
532
+ ...(params as any),
533
+ });
534
+ }
535
+
536
+ /**
537
+ * Get the total amount of assets allocated to the budget, including any that have been distributed
538
+ * If a tokenId is provided, get the total amount of ERC1155 assets allocated to the budget, including any that have been distributed
539
+ *
540
+ * @public
541
+ * @param {Address} [asset="0x0000000000000000000000000000000000000000"] - The address of the asset
542
+ * @param {?(bigint | undefined)} [tokenId] - The ID of the token
543
+ * @param {?ReadParams} [params]
544
+ * @returns {Promise<bigint>} - The total amount of assets
545
+ */
546
+ public total(
547
+ asset: Address = zeroAddress,
548
+ tokenId?: bigint | undefined,
549
+ params?: ReadParams,
550
+ ) {
551
+ return readManagedBudgetTotal(this._config, {
552
+ address: this.assertValidAddress(),
553
+ args: tokenId ? [asset, tokenId] : [asset],
554
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
555
+ ...(params as any),
556
+ });
557
+ }
558
+
559
+ /**
560
+ * Get the amount of assets available for distribution from the budget.
561
+ * If a tokenId is provided, get the amount of ERC1155 assets available for distribution from the budget
562
+ *
563
+ * @public
564
+ * @param {Address} [asset="0x0000000000000000000000000000000000000000"]
565
+ * @param {?(bigint | undefined)} [tokenId]
566
+ * @param {?ReadParams} [params]
567
+ * @returns {Promise<bigint>} - The amount of assets available
568
+ */
569
+ public available(
570
+ asset: Address = zeroAddress,
571
+ tokenId?: bigint | undefined,
572
+ params?: ReadParams,
573
+ ) {
574
+ return readManagedBudgetAvailable(this._config, {
575
+ address: this.assertValidAddress(),
576
+ args: tokenId ? [asset, tokenId] : [asset],
577
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
578
+ ...(params as any),
579
+ });
580
+ }
581
+
582
+ /**
583
+ * Get the amount of assets that have been distributed from the budget.
584
+ * If a tokenId is provided, get the amount of ERC1155 assets that have been distributed from the budget
585
+ *
586
+ * @public
587
+ * @param {Address} [asset="0x0000000000000000000000000000000000000000"]
588
+ * @param {?(bigint | undefined)} [tokenId]
589
+ * @param {?ReadParams} [params]
590
+ * @returns {Promise<bigint>} - The amount of assets distributed
591
+ */
592
+ public distributed(
593
+ asset: Address = zeroAddress,
594
+ tokenId?: bigint | undefined,
595
+ params?: ReadParams,
596
+ ) {
597
+ return readManagedBudgetDistributed(this._config, {
598
+ address: this.assertValidAddress(),
599
+ args: tokenId ? [asset, tokenId] : [asset],
600
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
601
+ ...(params as any),
602
+ });
603
+ }
604
+
605
+ /**
606
+ * @inheritdoc
607
+ *
608
+ * @public
609
+ * @param {?ManagedBudgetWithFeesPayload} [_payload]
610
+ * @param {?DeployableOptions} [_options]
611
+ * @returns {GenericDeployableParams}
612
+ */
613
+ public override buildParameters(
614
+ _payload?: ManagedBudgetWithFeesPayload,
615
+ _options?: DeployableOptions,
616
+ ): GenericDeployableParams {
617
+ const [payload, options] = this.validateDeploymentConfig(
618
+ _payload,
619
+ _options,
620
+ );
621
+ if (!payload.owner || payload.owner === zeroAddress) {
622
+ const owner = options.account
623
+ ? options.account.address
624
+ : options.config
625
+ ? getAccount(options.config).address
626
+ : this._account?.address;
627
+ if (owner) {
628
+ payload.owner = owner;
629
+ } else {
630
+ throw new DeployableUnknownOwnerProvidedError();
631
+ }
632
+ }
633
+ return {
634
+ abi: managedBudgetWithFeesAbi,
635
+ bytecode: bytecode as Hex,
636
+ args: [prepareManagedBudgetWithFeesPayload(payload)],
637
+ ...this.optionallyAttachAccount(options.account),
638
+ };
639
+ }
640
+ }
641
+
642
+ /**
643
+ * Given a {@link ManagedBudgetWithFeesPayload}, properly encode a `ManagedBudgetWithFees.InitPayload` for use with {@link ManagedBudgetWithFees} initialization.
644
+ *
645
+ * @param {ManagedBudgetWithFeesPayload} param0
646
+ * @param {Address} param0.owner - The budget's owner
647
+ * @param {{}} param0.authorized - List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
648
+ * @param {{}} param0.roles - List of roles to assign to the corresponding account by index.
649
+ * @returns {Hex}
650
+ */
651
+ export const prepareManagedBudgetWithFeesPayload = ({
652
+ owner,
653
+ authorized,
654
+ roles,
655
+ managementFee,
656
+ }: ManagedBudgetWithFeesPayload) => {
657
+ return encodeAbiParameters(
658
+ parseAbiParameters([
659
+ 'ManagedBudgetWithFeesPayload payload',
660
+ 'struct ManagedBudgetWithFeesPayload { address owner; address[] authorized; uint256[] roles; uint256 managementFee; }',
661
+ ]),
662
+ [
663
+ {
664
+ owner,
665
+ authorized,
666
+ roles: roles as unknown as Array<bigint>,
667
+ managementFee,
668
+ },
669
+ ],
670
+ );
671
+ };
package/src/index.ts CHANGED
@@ -21,6 +21,7 @@ export * from './Budgets/Budget';
21
21
  // export * from './Budgets/SimpleBudget';
22
22
  // export * from './Budgets/VestingBudget';
23
23
  export * from './Budgets/ManagedBudget';
24
+ export * from './Budgets/ManagedBudgetWithFees';
24
25
 
25
26
  // Deployable
26
27
 
@@ -1,2 +0,0 @@
1
- "use strict";const e="0xc2c281ec",n="0x53cf8555",t="0x7cc1d5bb",i="0x52b8e45c",c="0x90318111",A="0x7687b0ed",a="0x5fbfaa4e",o="0x0d36a40d",s="0xb8ce7b22",l="0x1392d798",v="0x3d30a22c";exports.AAllowListIncentive=e;exports.ACGDAIncentive=n;exports.AERC20Incentive=t;exports.AERC20VariableCriteriaIncentive=i;exports.AERC20VariableIncentive=c;exports.AEventAction=A;exports.AManagedBudget=a;exports.APointsIncentive=o;exports.ASignerValidator=s;exports.ASimpleAllowList=l;exports.ASimpleDenyList=v;
2
- //# sourceMappingURL=componentInterfaces-BQw7DH-m.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"componentInterfaces-BQw7DH-m.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,15 +0,0 @@
1
- const e = "0xc2c281ec", n = "0x53cf8555", c = "0x7cc1d5bb", t = "0x52b8e45c", s = "0x90318111", a = "0x7687b0ed", i = "0x5fbfaa4e", o = "0x0d36a40d", A = "0xb8ce7b22", x = "0x1392d798", b = "0x3d30a22c";
2
- export {
3
- a as A,
4
- i as a,
5
- o as b,
6
- c,
7
- e as d,
8
- n as e,
9
- s as f,
10
- t as g,
11
- A as h,
12
- x as i,
13
- b as j
14
- };
15
- //# sourceMappingURL=componentInterfaces-C0vuWQlh.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"componentInterfaces-C0vuWQlh.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}