@boostxyz/sdk 0.0.0-alpha.5 → 0.0.0-alpha.7

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 (165) hide show
  1. package/dist/Actions/Action.cjs +1 -0
  2. package/dist/Actions/Action.cjs.map +1 -0
  3. package/dist/Actions/Action.js +1 -0
  4. package/dist/Actions/Action.js.map +1 -0
  5. package/dist/Actions/EventAction.cjs +2 -1
  6. package/dist/Actions/EventAction.cjs.map +1 -0
  7. package/dist/Actions/EventAction.d.ts.map +1 -1
  8. package/dist/Actions/EventAction.js +39 -40
  9. package/dist/Actions/EventAction.js.map +1 -0
  10. package/dist/AllowLists/AllowList.cjs +1 -0
  11. package/dist/AllowLists/AllowList.cjs.map +1 -0
  12. package/dist/AllowLists/AllowList.js +1 -0
  13. package/dist/AllowLists/AllowList.js.map +1 -0
  14. package/dist/AllowLists/SimpleAllowList.cjs +1 -0
  15. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
  16. package/dist/AllowLists/SimpleAllowList.js +1 -0
  17. package/dist/AllowLists/SimpleAllowList.js.map +1 -0
  18. package/dist/AllowLists/SimpleDenyList.cjs +1 -0
  19. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
  20. package/dist/AllowLists/SimpleDenyList.js +1 -0
  21. package/dist/AllowLists/SimpleDenyList.js.map +1 -0
  22. package/dist/Auth/Auth.cjs +1 -0
  23. package/dist/Auth/Auth.cjs.map +1 -0
  24. package/dist/Auth/Auth.js +1 -0
  25. package/dist/Auth/Auth.js.map +1 -0
  26. package/dist/Auth/PassthroughAuth.cjs +1 -0
  27. package/dist/Auth/PassthroughAuth.cjs.map +1 -0
  28. package/dist/Auth/PassthroughAuth.js +1 -0
  29. package/dist/Auth/PassthroughAuth.js.map +1 -0
  30. package/dist/Boost.cjs +1 -0
  31. package/dist/Boost.cjs.map +1 -0
  32. package/dist/Boost.js +1 -0
  33. package/dist/Boost.js.map +1 -0
  34. package/dist/BoostCore.cjs +1 -0
  35. package/dist/BoostCore.cjs.map +1 -0
  36. package/dist/BoostCore.js +1 -0
  37. package/dist/BoostCore.js.map +1 -0
  38. package/dist/BoostRegistry.cjs +1 -0
  39. package/dist/BoostRegistry.cjs.map +1 -0
  40. package/dist/BoostRegistry.js +1 -0
  41. package/dist/BoostRegistry.js.map +1 -0
  42. package/dist/Budgets/Budget.cjs +1 -0
  43. package/dist/Budgets/Budget.cjs.map +1 -0
  44. package/dist/Budgets/Budget.js +1 -0
  45. package/dist/Budgets/Budget.js.map +1 -0
  46. package/dist/Budgets/ManagedBudget.cjs +1 -0
  47. package/dist/Budgets/ManagedBudget.cjs.map +1 -0
  48. package/dist/Budgets/ManagedBudget.js +1 -0
  49. package/dist/Budgets/ManagedBudget.js.map +1 -0
  50. package/dist/Deployable/Contract.cjs +1 -0
  51. package/dist/Deployable/Contract.cjs.map +1 -0
  52. package/dist/Deployable/Contract.js +1 -0
  53. package/dist/Deployable/Contract.js.map +1 -0
  54. package/dist/Deployable/Deployable.cjs +1 -0
  55. package/dist/Deployable/Deployable.cjs.map +1 -0
  56. package/dist/Deployable/Deployable.js +1 -0
  57. package/dist/Deployable/Deployable.js.map +1 -0
  58. package/dist/Deployable/DeployableTarget.cjs +1 -0
  59. package/dist/Deployable/DeployableTarget.cjs.map +1 -0
  60. package/dist/Deployable/DeployableTarget.js +1 -0
  61. package/dist/Deployable/DeployableTarget.js.map +1 -0
  62. package/dist/Incentives/AllowListIncentive.cjs +1 -0
  63. package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
  64. package/dist/Incentives/AllowListIncentive.js +1 -0
  65. package/dist/Incentives/AllowListIncentive.js.map +1 -0
  66. package/dist/Incentives/CGDAIncentive.cjs +1 -0
  67. package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
  68. package/dist/Incentives/CGDAIncentive.js +1 -0
  69. package/dist/Incentives/CGDAIncentive.js.map +1 -0
  70. package/dist/Incentives/ERC20Incentive.cjs +1 -0
  71. package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
  72. package/dist/Incentives/ERC20Incentive.js +1 -0
  73. package/dist/Incentives/ERC20Incentive.js.map +1 -0
  74. package/dist/Incentives/Incentive.cjs +1 -0
  75. package/dist/Incentives/Incentive.cjs.map +1 -0
  76. package/dist/Incentives/Incentive.js +1 -0
  77. package/dist/Incentives/Incentive.js.map +1 -0
  78. package/dist/Incentives/PointsIncentive.cjs +1 -0
  79. package/dist/Incentives/PointsIncentive.cjs.map +1 -0
  80. package/dist/Incentives/PointsIncentive.js +1 -0
  81. package/dist/Incentives/PointsIncentive.js.map +1 -0
  82. package/dist/Validators/SignerValidator.cjs +1 -0
  83. package/dist/Validators/SignerValidator.cjs.map +1 -0
  84. package/dist/Validators/SignerValidator.js +1 -0
  85. package/dist/Validators/SignerValidator.js.map +1 -0
  86. package/dist/Validators/Validator.cjs +1 -0
  87. package/dist/Validators/Validator.cjs.map +1 -0
  88. package/dist/Validators/Validator.js +1 -0
  89. package/dist/Validators/Validator.js.map +1 -0
  90. package/dist/componentInterfaces-CKCBwG16.cjs +1 -0
  91. package/dist/componentInterfaces-CKCBwG16.cjs.map +1 -0
  92. package/dist/componentInterfaces-DYkaxBda.js +1 -0
  93. package/dist/componentInterfaces-DYkaxBda.js.map +1 -0
  94. package/dist/errors.cjs +1 -0
  95. package/dist/errors.cjs.map +1 -0
  96. package/dist/errors.js +1 -0
  97. package/dist/errors.js.map +1 -0
  98. package/dist/generated-Cd-Fe7W7.cjs +1 -0
  99. package/dist/generated-Cd-Fe7W7.cjs.map +1 -0
  100. package/dist/generated-DGpIVcv5.js +1 -0
  101. package/dist/generated-DGpIVcv5.js.map +1 -0
  102. package/dist/index.cjs +1 -0
  103. package/dist/index.cjs.map +1 -0
  104. package/dist/index.js +1 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/utils.cjs +1 -0
  107. package/dist/utils.cjs.map +1 -0
  108. package/dist/utils.js +1 -0
  109. package/dist/utils.js.map +1 -0
  110. package/package.json +3 -2
  111. package/src/Actions/Action.test.ts +77 -0
  112. package/src/Actions/Action.ts +61 -0
  113. package/src/Actions/ContractAction.test.ts +199 -0
  114. package/src/Actions/ContractAction.ts +238 -0
  115. package/src/Actions/ERC721MintAction.test.ts +112 -0
  116. package/src/Actions/ERC721MintAction.ts +238 -0
  117. package/src/Actions/EventAction.test.ts +182 -0
  118. package/src/Actions/EventAction.ts +380 -0
  119. package/src/AllowLists/AllowList.test.ts +64 -0
  120. package/src/AllowLists/AllowList.ts +60 -0
  121. package/src/AllowLists/SimpleAllowList.test.ts +52 -0
  122. package/src/AllowLists/SimpleAllowList.ts +240 -0
  123. package/src/AllowLists/SimpleDenyList.test.ts +52 -0
  124. package/src/AllowLists/SimpleDenyList.ts +289 -0
  125. package/src/Auth/Auth.ts +11 -0
  126. package/src/Auth/PassthroughAuth.test.ts +12 -0
  127. package/src/Auth/PassthroughAuth.ts +80 -0
  128. package/src/Boost.ts +155 -0
  129. package/src/BoostCore.test.ts +846 -0
  130. package/src/BoostCore.ts +1192 -0
  131. package/src/BoostRegistry.ts +449 -0
  132. package/src/Budgets/Budget.test.ts +27 -0
  133. package/src/Budgets/Budget.ts +61 -0
  134. package/src/Budgets/ManagedBudget.test.ts +154 -0
  135. package/src/Budgets/ManagedBudget.ts +743 -0
  136. package/src/Budgets/SimpleBudget.test.ts +152 -0
  137. package/src/Budgets/SimpleBudget.ts +521 -0
  138. package/src/Budgets/VestingBudget.test.ts +123 -0
  139. package/src/Budgets/VestingBudget.ts +532 -0
  140. package/src/Deployable/Contract.ts +229 -0
  141. package/src/Deployable/Deployable.ts +244 -0
  142. package/src/Deployable/DeployableTarget.ts +210 -0
  143. package/src/Incentives/AllowListIncentive.test.ts +146 -0
  144. package/src/Incentives/AllowListIncentive.ts +290 -0
  145. package/src/Incentives/CGDAIncentive.test.ts +136 -0
  146. package/src/Incentives/CGDAIncentive.ts +364 -0
  147. package/src/Incentives/ERC1155Incentive.test.ts +98 -0
  148. package/src/Incentives/ERC1155Incentive.ts +384 -0
  149. package/src/Incentives/ERC20Incentive.test.ts +141 -0
  150. package/src/Incentives/ERC20Incentive.ts +417 -0
  151. package/src/Incentives/ERC20VariableIncentive.test.ts +156 -0
  152. package/src/Incentives/ERC20VariableIncentive.ts +368 -0
  153. package/src/Incentives/Incentive.test.ts +92 -0
  154. package/src/Incentives/Incentive.ts +85 -0
  155. package/src/Incentives/PointsIncentive.test.ts +142 -0
  156. package/src/Incentives/PointsIncentive.ts +303 -0
  157. package/src/Validators/SignerValidator.test.ts +163 -0
  158. package/src/Validators/SignerValidator.ts +272 -0
  159. package/src/Validators/Validator.test.ts +21 -0
  160. package/src/Validators/Validator.ts +55 -0
  161. package/src/errors.ts +524 -0
  162. package/src/index.test.ts +40 -0
  163. package/src/index.ts +50 -0
  164. package/src/utils.test.ts +44 -0
  165. package/src/utils.ts +2247 -0
@@ -0,0 +1,123 @@
1
+ import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
2
+ import { isAddress, parseEther, zeroAddress } from 'viem';
3
+ import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
4
+ import type { MockERC20 } from '../../test/MockERC20';
5
+ import {
6
+ type Fixtures,
7
+ defaultOptions,
8
+ deployFixtures,
9
+ freshVestingBudget,
10
+ fundErc20,
11
+ fundVestingBudget,
12
+ } from '../../test/helpers';
13
+ import { testAccount } from '../../test/viem';
14
+ import { VestingBudget } from './VestingBudget';
15
+
16
+ let fixtures: Fixtures, budget: VestingBudget, erc20: MockERC20;
17
+
18
+ beforeAll(async () => {
19
+ fixtures = await loadFixture(deployFixtures);
20
+ });
21
+
22
+ describe.skip('VestingBudget', () => {
23
+ test('can successfully be deployed', async () => {
24
+ const budget = new VestingBudget(defaultOptions, {
25
+ owner: testAccount.address,
26
+ authorized: [],
27
+ start: 0n,
28
+ duration: 100n,
29
+ cliff: 5n,
30
+ });
31
+ await budget.deploy();
32
+ expect(isAddress(budget.assertValidAddress())).toBe(true);
33
+ });
34
+
35
+ test('can be owned', async () => {
36
+ const budget = await loadFixture(
37
+ freshVestingBudget(defaultOptions, fixtures),
38
+ );
39
+ expect(await budget.owner()).toBe(defaultOptions.account.address);
40
+ });
41
+
42
+ test('can have authorized users', async () => {
43
+ const budget = await loadFixture(
44
+ freshVestingBudget(defaultOptions, fixtures),
45
+ );
46
+ expect(await budget.isAuthorized(defaultOptions.account.address)).toBe(
47
+ true,
48
+ );
49
+ expect(await budget.isAuthorized(zeroAddress)).toBe(false);
50
+ });
51
+
52
+ test('can have no initial balance', async () => {
53
+ const budget = await loadFixture(
54
+ freshVestingBudget(defaultOptions, fixtures),
55
+ );
56
+ expect(await budget.available(zeroAddress)).toBe(0n);
57
+ });
58
+
59
+ describe('can allocate', () => {
60
+ beforeEach(async () => {
61
+ budget = await loadFixture(freshVestingBudget(defaultOptions, fixtures));
62
+ erc20 = await loadFixture(fundErc20(defaultOptions));
63
+ });
64
+
65
+ test('native assets', async () => {
66
+ await budget.allocate(
67
+ {
68
+ amount: parseEther('1.0'),
69
+ asset: zeroAddress,
70
+ target: defaultOptions.account.address,
71
+ },
72
+ {
73
+ value: parseEther('1.0'),
74
+ },
75
+ );
76
+ expect(await budget.available(zeroAddress)).toBe(parseEther('1.0'));
77
+ });
78
+
79
+ test('erc20', async () => {
80
+ await erc20.approve(budget.assertValidAddress(), parseEther('100'));
81
+ await budget.allocate({
82
+ amount: parseEther('100'),
83
+ asset: erc20.assertValidAddress(),
84
+ target: defaultOptions.account.address,
85
+ });
86
+ expect(await budget.available(erc20.assertValidAddress())).toBe(
87
+ parseEther('100'),
88
+ );
89
+ });
90
+ });
91
+
92
+ describe('can disburse', () => {
93
+ beforeEach(async () => {
94
+ const budgetFixtures = await loadFixture(
95
+ fundVestingBudget(defaultOptions, fixtures),
96
+ );
97
+ budget = budgetFixtures.budget;
98
+ erc20 = budgetFixtures.erc20;
99
+ });
100
+
101
+ test('native assets', async () => {
102
+ await budget.disburse({
103
+ amount: parseEther('1.0'),
104
+ asset: zeroAddress,
105
+ target: defaultOptions.account.address,
106
+ });
107
+
108
+ expect(await budget.available(zeroAddress)).toBe(0n);
109
+ });
110
+
111
+ test('erc20 assets', async () => {
112
+ await budget.disburse({
113
+ amount: parseEther('10'),
114
+ asset: erc20.assertValidAddress(),
115
+ target: defaultOptions.account.address,
116
+ });
117
+
118
+ expect(await budget.available(erc20.assertValidAddress())).toBe(
119
+ parseEther('90'),
120
+ );
121
+ });
122
+ });
123
+ });
@@ -0,0 +1,532 @@
1
+ import {
2
+ readVestingBudgetAvailable,
3
+ readVestingBudgetCliff,
4
+ readVestingBudgetDistributed,
5
+ readVestingBudgetDuration,
6
+ readVestingBudgetEnd,
7
+ readVestingBudgetIsAuthorized,
8
+ readVestingBudgetOwner,
9
+ readVestingBudgetStart,
10
+ readVestingBudgetTotal,
11
+ simulateVestingBudgetAllocate,
12
+ simulateVestingBudgetClawback,
13
+ simulateVestingBudgetDisburse,
14
+ simulateVestingBudgetDisburseBatch,
15
+ simulateVestingBudgetSetAuthorized,
16
+ vestingBudgetAbi,
17
+ writeVestingBudgetAllocate,
18
+ writeVestingBudgetClawback,
19
+ writeVestingBudgetDisburse,
20
+ writeVestingBudgetDisburseBatch,
21
+ writeVestingBudgetSetAuthorized,
22
+ } from '@boostxyz/evm';
23
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/budgets/VestingBudget.sol/VestingBudget.json';
24
+ import { getAccount } from '@wagmi/core';
25
+ import {
26
+ type Address,
27
+ type ContractEventName,
28
+ type Hex,
29
+ zeroAddress,
30
+ } from 'viem';
31
+ import type {
32
+ DeployableOptions,
33
+ GenericDeployableParams,
34
+ } from '../Deployable/Deployable';
35
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
36
+ import { DeployableUnknownOwnerProvidedError } from '../errors';
37
+ import {
38
+ type FungibleTransferPayload,
39
+ type GenericLog,
40
+ type ReadParams,
41
+ RegistryType,
42
+ type VestingBudgetPayload,
43
+ type WriteParams,
44
+ prepareFungibleTransfer,
45
+ prepareVestingBudgetPayload,
46
+ } from '../utils';
47
+
48
+ export { vestingBudgetAbi };
49
+ export type { VestingBudgetPayload };
50
+
51
+ /**
52
+ * A generic `viem.Log` event with support for `VestingBudget` event types.
53
+ *
54
+ * @export
55
+ * @typedef {VestingBudgetLog}
56
+ * @template {ContractEventName<typeof vestingBudgetAbi>} [event=ContractEventName<
57
+ * typeof vestingBudgetAbi
58
+ * >]
59
+ */
60
+ export type VestingBudgetLog<
61
+ event extends ContractEventName<typeof vestingBudgetAbi> = ContractEventName<
62
+ typeof vestingBudgetAbi
63
+ >,
64
+ > = GenericLog<typeof vestingBudgetAbi, event>;
65
+
66
+ /**
67
+ * A vesting-based budget implementation that allows for the distribution of assets over time
68
+ * Take note of the following when making use of this budget type:
69
+ * - The budget is designed to manage native and ERC20 token balances only. Using rebasing tokens or other non-standard token types may result in unexpected behavior.
70
+ * - Any assets allocated to this type of budget will follow the vesting schedule as if they were locked from the beginning, which is to say that, if the vesting has already started, some portion of the assets will be immediately available for distribution.
71
+ * - A vesting budget can also act as a time-lock, unlocking all assets at a specified point in time. To release assets at a specific time rather than vesting them over time, set the `start` to the desired time and the `duration` to zero.
72
+ * - This contract is {Ownable} to enable the owner to allocate to the budget, clawback and disburse assets from the budget, and to set authorized addresses. Additionally, the owner can transfer ownership of the budget to another address. Doing so has no effect on the vesting schedule.
73
+ *
74
+ * @export
75
+ * @class VestingBudget
76
+ * @typedef {VestingBudget}
77
+ * @extends {DeployableTarget<VestingBudgetPayload>}
78
+ */
79
+ export class VestingBudget extends DeployableTarget<
80
+ VestingBudgetPayload,
81
+ typeof vestingBudgetAbi
82
+ > {
83
+ public override readonly abi = vestingBudgetAbi;
84
+ /**
85
+ * @inheritdoc
86
+ *
87
+ * @public
88
+ * @static
89
+ * @type {Address}
90
+ */
91
+ public static override base: Address = import.meta.env
92
+ .VITE_VESTING_BUDGET_BASE;
93
+ /**
94
+ * @inheritdoc
95
+ *
96
+ * @public
97
+ * @static
98
+ * @type {RegistryType}
99
+ */
100
+ public static override registryType: RegistryType = RegistryType.BUDGET;
101
+
102
+ /**
103
+ * Get the owner of the budget
104
+ *
105
+ * @public
106
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'owner'>} [params]
107
+ * @returns {Promise<Address>}
108
+ */
109
+ public owner(params?: ReadParams<typeof vestingBudgetAbi, 'owner'>) {
110
+ return readVestingBudgetOwner(this._config, {
111
+ address: this.assertValidAddress(),
112
+ args: [],
113
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
114
+ ...(params as any),
115
+ });
116
+ }
117
+
118
+ /**
119
+ * The timestamp at which the vesting schedule begins
120
+ *
121
+ * @public
122
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'start'>} [params]
123
+ * @returns {*}
124
+ */
125
+ public start(params?: ReadParams<typeof vestingBudgetAbi, 'start'>) {
126
+ return readVestingBudgetStart(this._config, {
127
+ address: this.assertValidAddress(),
128
+ args: [],
129
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
130
+ ...(params as any),
131
+ });
132
+ }
133
+
134
+ /**
135
+ * The duration of the vesting schedule (in seconds)
136
+ *
137
+ * @public
138
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'duration'>} [params]
139
+ * @returns {*}
140
+ */
141
+ public duration(params?: ReadParams<typeof vestingBudgetAbi, 'duration'>) {
142
+ return readVestingBudgetDuration(this._config, {
143
+ address: this.assertValidAddress(),
144
+ args: [],
145
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
146
+ ...(params as any),
147
+ });
148
+ }
149
+
150
+ /**
151
+ * The duration of the cliff period (in seconds)
152
+ *
153
+ * @public
154
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'cliff'>} [params]
155
+ * @returns {*}
156
+ */
157
+ public cliff(params?: ReadParams<typeof vestingBudgetAbi, 'cliff'>) {
158
+ return readVestingBudgetCliff(this._config, {
159
+ address: this.assertValidAddress(),
160
+ args: [],
161
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
162
+ ...(params as any),
163
+ });
164
+ }
165
+
166
+ /**
167
+ * Allocates assets to the budget.
168
+ * The caller must have already approved the contract to transfer the asset
169
+ * If the asset transfer fails, the allocation will revert
170
+ *
171
+ * @public
172
+ * @async
173
+ * @param {(FungibleTransferPayload)} transfer
174
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'allocate'>} [params]
175
+ * @returns {Promise<boolean>} - True if the allocation was successful
176
+ */
177
+ public async allocate(
178
+ transfer: FungibleTransferPayload,
179
+ params?: WriteParams<typeof vestingBudgetAbi, 'allocate'>,
180
+ ) {
181
+ return this.awaitResult(this.allocateRaw(transfer, params));
182
+ }
183
+
184
+ /**
185
+ * Allocates assets to the budget.
186
+ * The caller must have already approved the contract to transfer the asset
187
+ * If the asset transfer fails, the allocation will revert
188
+ *
189
+ * @public
190
+ * @async
191
+ * @param {(FungibleTransferPayload)} transfer
192
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'allocate'>} [params]
193
+ * @returns {Promise<boolean>} - True if the allocation was successful
194
+ */
195
+ public async allocateRaw(
196
+ transfer: FungibleTransferPayload,
197
+ params?: WriteParams<typeof vestingBudgetAbi, 'allocate'>,
198
+ ) {
199
+ const { request, result } = await simulateVestingBudgetAllocate(
200
+ this._config,
201
+ {
202
+ address: this.assertValidAddress(),
203
+ args: [prepareFungibleTransfer(transfer)],
204
+ ...this.optionallyAttachAccount(),
205
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
206
+ ...(params as any),
207
+ },
208
+ );
209
+ const hash = await writeVestingBudgetAllocate(this._config, request);
210
+ return { hash, result };
211
+ }
212
+
213
+ /**
214
+ * Clawbacks assets from the budget.
215
+ * Only the owner 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)} transfer
222
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'clawback'>} [params]
223
+ * @returns {Promise<boolean>} - True if the request was successful
224
+ */
225
+ public async clawback(
226
+ transfer: FungibleTransferPayload,
227
+ params?: WriteParams<typeof vestingBudgetAbi, 'clawback'>,
228
+ ) {
229
+ return this.awaitResult(this.clawbackRaw(transfer, params));
230
+ }
231
+
232
+ /**
233
+ * Clawbacks assets from the budget.
234
+ * Only the owner can directly clawback assets from the budget
235
+ * If the amount is zero, the entire balance of the asset will be transferred to the receiver
236
+ * If the asset transfer fails, the reclamation will revert
237
+ *
238
+ * @public
239
+ * @async
240
+ * @param {(FungibleTransferPayload)} transfer
241
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'clawback'>} [params]
242
+ * @returns {Promise<boolean>} - True if the request was successful
243
+ */
244
+ public async clawbackRaw(
245
+ transfer: FungibleTransferPayload,
246
+ params?: WriteParams<typeof vestingBudgetAbi, 'clawback'>,
247
+ ) {
248
+ const { request, result } = await simulateVestingBudgetClawback(
249
+ this._config,
250
+ {
251
+ address: this.assertValidAddress(),
252
+ args: [prepareFungibleTransfer(transfer)],
253
+ ...this.optionallyAttachAccount(),
254
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
255
+ ...(params as any),
256
+ },
257
+ );
258
+ const hash = await writeVestingBudgetClawback(this._config, request);
259
+ return { hash, result };
260
+ }
261
+
262
+ /**
263
+ * Disburses assets from the budget to a single recipient
264
+ * If the asset transfer fails, the disbursement will revert
265
+ *
266
+ * @public
267
+ * @async
268
+ * @param {(FungibleTransferPayload)} transfer
269
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'disburse'>} [params]
270
+ * @returns {Promise<boolean>} - True if the disbursement was successful
271
+ */
272
+ public async disburse(
273
+ transfer: FungibleTransferPayload,
274
+ params?: WriteParams<typeof vestingBudgetAbi, 'disburse'>,
275
+ ) {
276
+ return this.awaitResult(this.disburseRaw(transfer, params));
277
+ }
278
+
279
+ /**
280
+ * Disburses assets from the budget to a single recipient
281
+ * If the asset transfer fails, the disbursement will revert
282
+ *
283
+ * @public
284
+ * @async
285
+ * @param {(FungibleTransferPayload)} transfer
286
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'disburse'>} [params]
287
+ * @returns {Promise<boolean>} - True if the disbursement was successful
288
+ */
289
+ public async disburseRaw(
290
+ transfer: FungibleTransferPayload,
291
+ params?: WriteParams<typeof vestingBudgetAbi, 'disburse'>,
292
+ ) {
293
+ const { request, result } = await simulateVestingBudgetDisburse(
294
+ this._config,
295
+ {
296
+ address: this.assertValidAddress(),
297
+ args: [prepareFungibleTransfer(transfer)],
298
+ ...this.optionallyAttachAccount(),
299
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
300
+ ...(params as any),
301
+ },
302
+ );
303
+ const hash = await writeVestingBudgetDisburse(this._config, request);
304
+ return { hash, result };
305
+ }
306
+
307
+ /**
308
+ * Disburses assets from the budget to multiple recipients
309
+ *
310
+ * @public
311
+ * @async
312
+ * @param {Array<FungibleTransferPayload>} transfers
313
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>} [params]
314
+ * @returns {Promise<boolean>} - True if all disbursements were successful
315
+ */
316
+ public async disburseBatch(
317
+ transfers: FungibleTransferPayload[],
318
+ params?: WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>,
319
+ ) {
320
+ return this.awaitResult(this.disburseBatchRaw(transfers, params));
321
+ }
322
+
323
+ /**
324
+ * Disburses assets from the budget to multiple recipients
325
+ *
326
+ * @public
327
+ * @async
328
+ * @param {Array<FungibleTransferPayload>} transfers
329
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>} [params]
330
+ * @returns {Promise<boolean>} - True if all disbursements were successful
331
+ */
332
+ public async disburseBatchRaw(
333
+ transfers: FungibleTransferPayload[],
334
+ params?: WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>,
335
+ ) {
336
+ const { request, result } = await simulateVestingBudgetDisburseBatch(
337
+ this._config,
338
+ {
339
+ address: this.assertValidAddress(),
340
+ args: [transfers.map(prepareFungibleTransfer)],
341
+ ...this.optionallyAttachAccount(),
342
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
343
+ ...(params as any),
344
+ },
345
+ );
346
+ const hash = await writeVestingBudgetDisburseBatch(this._config, request);
347
+ return { hash, result };
348
+ }
349
+
350
+ /**
351
+ * Set the authorized status of the given accounts
352
+ * The mechanism for managing authorization is left to the implementing contract
353
+ *
354
+ * @public
355
+ * @async
356
+ * @param {Address[]} addresses - The accounts to authorize or deauthorize
357
+ * @param {boolean[]} allowed - The authorization status for the given accounts
358
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'setAuthorized'>} [params]
359
+ * @returns {Promise<void>}
360
+ */
361
+ public async setAuthorized(
362
+ addresses: Address[],
363
+ allowed: boolean[],
364
+ params?: WriteParams<typeof vestingBudgetAbi, 'setAuthorized'>,
365
+ ) {
366
+ return this.awaitResult(this.setAuthorizedRaw(addresses, allowed, params));
367
+ }
368
+
369
+ /**
370
+ * Set the authorized status of the given accounts
371
+ * The mechanism for managing authorization is left to the implementing contract
372
+ *
373
+ * @public
374
+ * @async
375
+ * @param {Address[]} addresses - The accounts to authorize or deauthorize
376
+ * @param {boolean[]} allowed - The authorization status for the given accounts
377
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'setAuthorized'>} [params]
378
+ * @returns {Promise<void>}
379
+ */
380
+ public async setAuthorizedRaw(
381
+ addresses: Address[],
382
+ allowed: boolean[],
383
+ params?: WriteParams<typeof vestingBudgetAbi, 'setAuthorized'>,
384
+ ) {
385
+ const { request, result } = await simulateVestingBudgetSetAuthorized(
386
+ this._config,
387
+ {
388
+ address: this.assertValidAddress(),
389
+ args: [addresses, allowed],
390
+ ...this.optionallyAttachAccount(),
391
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
392
+ ...(params as any),
393
+ },
394
+ );
395
+ const hash = await writeVestingBudgetSetAuthorized(this._config, request);
396
+ return { hash, result };
397
+ }
398
+
399
+ /**
400
+ * Check if the given account is authorized to use the budget
401
+ *
402
+ * @public
403
+ * @param {Address} account
404
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'isAuthorized'>} [params]
405
+ * @returns {Promise<boolean>} - True if the account is authorized
406
+ */
407
+ public isAuthorized(
408
+ account: Address,
409
+ params?: ReadParams<typeof vestingBudgetAbi, 'isAuthorized'>,
410
+ ) {
411
+ return readVestingBudgetIsAuthorized(this._config, {
412
+ address: this.assertValidAddress(),
413
+ args: [account],
414
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
415
+ ...(params as any),
416
+ });
417
+ }
418
+
419
+ /**
420
+ * Get the end time of the vesting schedule
421
+ *
422
+ * @public
423
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'end'>} [params]
424
+ * @returns {Promise<bigint>}
425
+ */
426
+ public end(params?: ReadParams<typeof vestingBudgetAbi, 'end'>) {
427
+ return readVestingBudgetEnd(this._config, {
428
+ address: this.assertValidAddress(),
429
+ args: [],
430
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
431
+ ...(params as any),
432
+ });
433
+ }
434
+
435
+ /**
436
+ * Get the total amount of assets allocated to the budget, including any that have been distributed
437
+ * This is equal to the sum of the total current balance and the total distributed amount
438
+ *
439
+ * @public
440
+ * @param {Address} asset - The address of the asset (or the zero address for native assets)
441
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'total'>} [params]
442
+ * @returns {Promise<bigint>}
443
+ */
444
+ public total(
445
+ asset: Address,
446
+ params?: ReadParams<typeof vestingBudgetAbi, 'total'>,
447
+ ) {
448
+ return readVestingBudgetTotal(this._config, {
449
+ address: this.assertValidAddress(),
450
+ args: [asset],
451
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
452
+ ...(params as any),
453
+ });
454
+ }
455
+
456
+ /**
457
+ * Get the amount of assets available for distribution from the budget as of the current block timestamp
458
+ * This is equal to the total vested amount minus any already distributed
459
+ *
460
+ * @public
461
+ * @param {Address} asset - The address of the asset (or the zero address for native assets)
462
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'available'>} [params]
463
+ * @returns {Promise<bigint>} - The amount of assets currently available for distribution
464
+ */
465
+ public available(
466
+ asset: Address,
467
+ params?: ReadParams<typeof vestingBudgetAbi, 'available'>,
468
+ ) {
469
+ return readVestingBudgetAvailable(this._config, {
470
+ address: this.assertValidAddress(),
471
+ args: [asset],
472
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
473
+ ...(params as any),
474
+ });
475
+ }
476
+
477
+ /**
478
+ * Get the amount of assets that have been distributed from the budget
479
+ *
480
+ * @public
481
+ * @param {Address} asset
482
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'distributed'>} [params]
483
+ * @returns {Promise<bigint>} - The amount of assets distributed
484
+ */
485
+ public distributed(
486
+ asset: Address,
487
+ params?: ReadParams<typeof vestingBudgetAbi, 'distributed'>,
488
+ ) {
489
+ return readVestingBudgetDistributed(this._config, {
490
+ address: this.assertValidAddress(),
491
+ args: [asset],
492
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
493
+ ...(params as any),
494
+ });
495
+ }
496
+
497
+ /**
498
+ * @inheritdoc
499
+ *
500
+ * @public
501
+ * @param {?VestingBudgetPayload} [_payload]
502
+ * @param {?DeployableOptions} [_options]
503
+ * @returns {GenericDeployableParams}
504
+ */
505
+ public override buildParameters(
506
+ _payload?: VestingBudgetPayload,
507
+ _options?: DeployableOptions,
508
+ ): GenericDeployableParams {
509
+ const [payload, options] = this.validateDeploymentConfig(
510
+ _payload,
511
+ _options,
512
+ );
513
+ if (!payload.owner || payload.owner === zeroAddress) {
514
+ const owner = options.account
515
+ ? options.account.address
516
+ : options.config
517
+ ? getAccount(options.config).address
518
+ : this._account?.address;
519
+ if (owner) {
520
+ payload.owner = owner;
521
+ } else {
522
+ throw new DeployableUnknownOwnerProvidedError();
523
+ }
524
+ }
525
+ return {
526
+ abi: vestingBudgetAbi,
527
+ bytecode: bytecode as Hex,
528
+ args: [prepareVestingBudgetPayload(payload)],
529
+ ...this.optionallyAttachAccount(options.account),
530
+ };
531
+ }
532
+ }