@boostxyz/sdk 0.0.0-alpha.10

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 (242) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +7 -0
  3. package/dist/Actions/Action.cjs +2 -0
  4. package/dist/Actions/Action.cjs.map +1 -0
  5. package/dist/Actions/Action.d.ts +31 -0
  6. package/dist/Actions/Action.d.ts.map +1 -0
  7. package/dist/Actions/Action.js +29 -0
  8. package/dist/Actions/Action.js.map +1 -0
  9. package/dist/Actions/ContractAction.d.ts +370 -0
  10. package/dist/Actions/ContractAction.d.ts.map +1 -0
  11. package/dist/Actions/ERC721MintAction.d.ts +513 -0
  12. package/dist/Actions/ERC721MintAction.d.ts.map +1 -0
  13. package/dist/Actions/EventAction.cjs +2 -0
  14. package/dist/Actions/EventAction.cjs.map +1 -0
  15. package/dist/Actions/EventAction.d.ts +694 -0
  16. package/dist/Actions/EventAction.d.ts.map +1 -0
  17. package/dist/Actions/EventAction.js +491 -0
  18. package/dist/Actions/EventAction.js.map +1 -0
  19. package/dist/AllowLists/AllowList.cjs +2 -0
  20. package/dist/AllowLists/AllowList.cjs.map +1 -0
  21. package/dist/AllowLists/AllowList.d.ts +32 -0
  22. package/dist/AllowLists/AllowList.d.ts.map +1 -0
  23. package/dist/AllowLists/AllowList.js +30 -0
  24. package/dist/AllowLists/AllowList.js.map +1 -0
  25. package/dist/AllowLists/SimpleAllowList.cjs +2 -0
  26. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
  27. package/dist/AllowLists/SimpleAllowList.d.ts +481 -0
  28. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -0
  29. package/dist/AllowLists/SimpleAllowList.js +154 -0
  30. package/dist/AllowLists/SimpleAllowList.js.map +1 -0
  31. package/dist/AllowLists/SimpleDenyList.cjs +2 -0
  32. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
  33. package/dist/AllowLists/SimpleDenyList.d.ts +335 -0
  34. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -0
  35. package/dist/AllowLists/SimpleDenyList.js +115 -0
  36. package/dist/AllowLists/SimpleDenyList.js.map +1 -0
  37. package/dist/Auth/Auth.cjs +2 -0
  38. package/dist/Auth/Auth.cjs.map +1 -0
  39. package/dist/Auth/Auth.d.ts +10 -0
  40. package/dist/Auth/Auth.d.ts.map +1 -0
  41. package/dist/Auth/Auth.js +5 -0
  42. package/dist/Auth/Auth.js.map +1 -0
  43. package/dist/Auth/PassthroughAuth.cjs +2 -0
  44. package/dist/Auth/PassthroughAuth.cjs.map +1 -0
  45. package/dist/Auth/PassthroughAuth.d.ts +51 -0
  46. package/dist/Auth/PassthroughAuth.d.ts.map +1 -0
  47. package/dist/Auth/PassthroughAuth.js +39 -0
  48. package/dist/Auth/PassthroughAuth.js.map +1 -0
  49. package/dist/Boost.cjs +2 -0
  50. package/dist/Boost.cjs.map +1 -0
  51. package/dist/Boost.d.ts +234 -0
  52. package/dist/Boost.d.ts.map +1 -0
  53. package/dist/Boost.js +162 -0
  54. package/dist/Boost.js.map +1 -0
  55. package/dist/BoostCore.cjs +3 -0
  56. package/dist/BoostCore.cjs.map +1 -0
  57. package/dist/BoostCore.d.ts +498 -0
  58. package/dist/BoostCore.d.ts.map +1 -0
  59. package/dist/BoostCore.js +1153 -0
  60. package/dist/BoostCore.js.map +1 -0
  61. package/dist/BoostRegistry.cjs +2 -0
  62. package/dist/BoostRegistry.cjs.map +1 -0
  63. package/dist/BoostRegistry.d.ts +243 -0
  64. package/dist/BoostRegistry.d.ts.map +1 -0
  65. package/dist/BoostRegistry.js +262 -0
  66. package/dist/BoostRegistry.js.map +1 -0
  67. package/dist/Budgets/Budget.cjs +2 -0
  68. package/dist/Budgets/Budget.cjs.map +1 -0
  69. package/dist/Budgets/Budget.d.ts +31 -0
  70. package/dist/Budgets/Budget.d.ts.map +1 -0
  71. package/dist/Budgets/Budget.js +29 -0
  72. package/dist/Budgets/Budget.js.map +1 -0
  73. package/dist/Budgets/ManagedBudget.cjs +2 -0
  74. package/dist/Budgets/ManagedBudget.cjs.map +1 -0
  75. package/dist/Budgets/ManagedBudget.d.ts +1103 -0
  76. package/dist/Budgets/ManagedBudget.d.ts.map +1 -0
  77. package/dist/Budgets/ManagedBudget.js +516 -0
  78. package/dist/Budgets/ManagedBudget.js.map +1 -0
  79. package/dist/Budgets/SimpleBudget.d.ts +824 -0
  80. package/dist/Budgets/SimpleBudget.d.ts.map +1 -0
  81. package/dist/Budgets/VestingBudget.d.ts +778 -0
  82. package/dist/Budgets/VestingBudget.d.ts.map +1 -0
  83. package/dist/Deployable/Contract.cjs +2 -0
  84. package/dist/Deployable/Contract.cjs.map +1 -0
  85. package/dist/Deployable/Contract.d.ts +125 -0
  86. package/dist/Deployable/Contract.d.ts.map +1 -0
  87. package/dist/Deployable/Contract.js +150 -0
  88. package/dist/Deployable/Contract.js.map +1 -0
  89. package/dist/Deployable/Deployable.cjs +2 -0
  90. package/dist/Deployable/Deployable.cjs.map +1 -0
  91. package/dist/Deployable/Deployable.d.ts +161 -0
  92. package/dist/Deployable/Deployable.d.ts.map +1 -0
  93. package/dist/Deployable/Deployable.js +131 -0
  94. package/dist/Deployable/Deployable.js.map +1 -0
  95. package/dist/Deployable/DeployableTarget.cjs +2 -0
  96. package/dist/Deployable/DeployableTarget.cjs.map +1 -0
  97. package/dist/Deployable/DeployableTarget.d.ts +116 -0
  98. package/dist/Deployable/DeployableTarget.d.ts.map +1 -0
  99. package/dist/Deployable/DeployableTarget.js +132 -0
  100. package/dist/Deployable/DeployableTarget.js.map +1 -0
  101. package/dist/Incentives/AllowListIncentive.cjs +2 -0
  102. package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
  103. package/dist/Incentives/AllowListIncentive.d.ts +513 -0
  104. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -0
  105. package/dist/Incentives/AllowListIncentive.js +201 -0
  106. package/dist/Incentives/AllowListIncentive.js.map +1 -0
  107. package/dist/Incentives/CGDAIncentive.cjs +2 -0
  108. package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
  109. package/dist/Incentives/CGDAIncentive.d.ts +644 -0
  110. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -0
  111. package/dist/Incentives/CGDAIncentive.js +271 -0
  112. package/dist/Incentives/CGDAIncentive.js.map +1 -0
  113. package/dist/Incentives/ERC1155Incentive.d.ts +713 -0
  114. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -0
  115. package/dist/Incentives/ERC20Incentive.cjs +2 -0
  116. package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
  117. package/dist/Incentives/ERC20Incentive.d.ts +666 -0
  118. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -0
  119. package/dist/Incentives/ERC20Incentive.js +312 -0
  120. package/dist/Incentives/ERC20Incentive.js.map +1 -0
  121. package/dist/Incentives/ERC20VariableIncentive.d.ts +582 -0
  122. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -0
  123. package/dist/Incentives/Incentive.cjs +2 -0
  124. package/dist/Incentives/Incentive.cjs.map +1 -0
  125. package/dist/Incentives/Incentive.d.ts +36 -0
  126. package/dist/Incentives/Incentive.d.ts.map +1 -0
  127. package/dist/Incentives/Incentive.js +299 -0
  128. package/dist/Incentives/Incentive.js.map +1 -0
  129. package/dist/Incentives/PointsIncentive.cjs +2 -0
  130. package/dist/Incentives/PointsIncentive.cjs.map +1 -0
  131. package/dist/Incentives/PointsIncentive.d.ts +659 -0
  132. package/dist/Incentives/PointsIncentive.d.ts.map +1 -0
  133. package/dist/Incentives/PointsIncentive.js +215 -0
  134. package/dist/Incentives/PointsIncentive.js.map +1 -0
  135. package/dist/Validators/SignerValidator.cjs +2 -0
  136. package/dist/Validators/SignerValidator.cjs.map +1 -0
  137. package/dist/Validators/SignerValidator.d.ts +745 -0
  138. package/dist/Validators/SignerValidator.d.ts.map +1 -0
  139. package/dist/Validators/SignerValidator.js +293 -0
  140. package/dist/Validators/SignerValidator.js.map +1 -0
  141. package/dist/Validators/Validator.cjs +2 -0
  142. package/dist/Validators/Validator.cjs.map +1 -0
  143. package/dist/Validators/Validator.d.ts +31 -0
  144. package/dist/Validators/Validator.d.ts.map +1 -0
  145. package/dist/Validators/Validator.js +27 -0
  146. package/dist/Validators/Validator.js.map +1 -0
  147. package/dist/claiming.cjs +2 -0
  148. package/dist/claiming.cjs.map +1 -0
  149. package/dist/claiming.d.ts +43 -0
  150. package/dist/claiming.d.ts.map +1 -0
  151. package/dist/claiming.js +17 -0
  152. package/dist/claiming.js.map +1 -0
  153. package/dist/componentInterfaces-CKCBwG16.cjs +2 -0
  154. package/dist/componentInterfaces-CKCBwG16.cjs.map +1 -0
  155. package/dist/componentInterfaces-DYkaxBda.js +13 -0
  156. package/dist/componentInterfaces-DYkaxBda.js.map +1 -0
  157. package/dist/errors.cjs +2 -0
  158. package/dist/errors.cjs.map +1 -0
  159. package/dist/errors.d.ts +441 -0
  160. package/dist/errors.d.ts.map +1 -0
  161. package/dist/errors.js +262 -0
  162. package/dist/errors.js.map +1 -0
  163. package/dist/generated-BDeDiaCK.js +4625 -0
  164. package/dist/generated-BDeDiaCK.js.map +1 -0
  165. package/dist/generated-wKBNvm48.cjs +3 -0
  166. package/dist/generated-wKBNvm48.cjs.map +1 -0
  167. package/dist/index.cjs +2 -0
  168. package/dist/index.cjs.map +1 -0
  169. package/dist/index.d.ts +25 -0
  170. package/dist/index.d.ts.map +1 -0
  171. package/dist/index.js +113 -0
  172. package/dist/index.js.map +1 -0
  173. package/dist/transfers.cjs +2 -0
  174. package/dist/transfers.cjs.map +1 -0
  175. package/dist/transfers.d.ts +198 -0
  176. package/dist/transfers.d.ts.map +1 -0
  177. package/dist/transfers.js +84 -0
  178. package/dist/transfers.js.map +1 -0
  179. package/dist/utils.cjs +2 -0
  180. package/dist/utils.cjs.map +1 -0
  181. package/dist/utils.d.ts +116 -0
  182. package/dist/utils.d.ts.map +1 -0
  183. package/dist/utils.js +30 -0
  184. package/dist/utils.js.map +1 -0
  185. package/package.json +211 -0
  186. package/src/Actions/Action.test.ts +75 -0
  187. package/src/Actions/Action.ts +61 -0
  188. package/src/Actions/ContractAction.test.ts +197 -0
  189. package/src/Actions/ContractAction.ts +301 -0
  190. package/src/Actions/ERC721MintAction.test.ts +112 -0
  191. package/src/Actions/ERC721MintAction.ts +292 -0
  192. package/src/Actions/EventAction.test.ts +205 -0
  193. package/src/Actions/EventAction.ts +811 -0
  194. package/src/AllowLists/AllowList.test.ts +64 -0
  195. package/src/AllowLists/AllowList.ts +60 -0
  196. package/src/AllowLists/SimpleAllowList.test.ts +52 -0
  197. package/src/AllowLists/SimpleAllowList.ts +284 -0
  198. package/src/AllowLists/SimpleDenyList.test.ts +52 -0
  199. package/src/AllowLists/SimpleDenyList.ts +227 -0
  200. package/src/Auth/Auth.ts +11 -0
  201. package/src/Auth/PassthroughAuth.test.ts +12 -0
  202. package/src/Auth/PassthroughAuth.ts +80 -0
  203. package/src/Boost.ts +290 -0
  204. package/src/BoostCore.test.ts +773 -0
  205. package/src/BoostCore.ts +1261 -0
  206. package/src/BoostRegistry.ts +467 -0
  207. package/src/Budgets/Budget.test.ts +27 -0
  208. package/src/Budgets/Budget.ts +61 -0
  209. package/src/Budgets/ManagedBudget.test.ts +154 -0
  210. package/src/Budgets/ManagedBudget.ts +796 -0
  211. package/src/Budgets/SimpleBudget.test.ts +152 -0
  212. package/src/Budgets/SimpleBudget.ts +564 -0
  213. package/src/Budgets/VestingBudget.test.ts +123 -0
  214. package/src/Budgets/VestingBudget.ts +602 -0
  215. package/src/Deployable/Contract.ts +229 -0
  216. package/src/Deployable/Deployable.ts +250 -0
  217. package/src/Deployable/DeployableTarget.ts +223 -0
  218. package/src/Incentives/AllowListIncentive.test.ts +143 -0
  219. package/src/Incentives/AllowListIncentive.ts +334 -0
  220. package/src/Incentives/CGDAIncentive.test.ts +132 -0
  221. package/src/Incentives/CGDAIncentive.ts +468 -0
  222. package/src/Incentives/ERC1155Incentive.test.ts +87 -0
  223. package/src/Incentives/ERC1155Incentive.ts +466 -0
  224. package/src/Incentives/ERC20Incentive.test.ts +130 -0
  225. package/src/Incentives/ERC20Incentive.ts +482 -0
  226. package/src/Incentives/ERC20VariableIncentive.test.ts +136 -0
  227. package/src/Incentives/ERC20VariableIncentive.ts +420 -0
  228. package/src/Incentives/Incentive.test.ts +92 -0
  229. package/src/Incentives/Incentive.ts +85 -0
  230. package/src/Incentives/PointsIncentive.test.ts +139 -0
  231. package/src/Incentives/PointsIncentive.ts +365 -0
  232. package/src/Validators/SignerValidator.test.ts +159 -0
  233. package/src/Validators/SignerValidator.ts +681 -0
  234. package/src/Validators/Validator.test.ts +21 -0
  235. package/src/Validators/Validator.ts +55 -0
  236. package/src/claiming.ts +56 -0
  237. package/src/errors.ts +542 -0
  238. package/src/index.test.ts +40 -0
  239. package/src/index.ts +53 -0
  240. package/src/transfers.ts +284 -0
  241. package/src/utils.test.ts +44 -0
  242. package/src/utils.ts +198 -0
@@ -0,0 +1,602 @@
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
+ encodeAbiParameters,
30
+ parseAbiParameters,
31
+ zeroAddress,
32
+ } from 'viem';
33
+ import type {
34
+ DeployableOptions,
35
+ GenericDeployableParams,
36
+ } from '../Deployable/Deployable';
37
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
38
+ import { DeployableUnknownOwnerProvidedError } from '../errors';
39
+ import {
40
+ type FungibleTransferPayload,
41
+ prepareFungibleTransfer,
42
+ } from '../transfers';
43
+ import {
44
+ type GenericLog,
45
+ type ReadParams,
46
+ RegistryType,
47
+ type WriteParams,
48
+ } from '../utils';
49
+
50
+ export { vestingBudgetAbi };
51
+ export type { FungibleTransferPayload };
52
+ /**
53
+ * The object representation of a `VestingBudget.InitPayload`
54
+ *
55
+ * @export
56
+ * @interface VestingBudgetPayload
57
+ * @typedef {VestingBudgetPayload}
58
+ */
59
+ export interface VestingBudgetPayload {
60
+ /**
61
+ * The budget's owner.
62
+ *
63
+ * @type {Address}
64
+ */
65
+ owner: Address;
66
+ /**
67
+ * List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
68
+ *
69
+ * @type {Address[]}
70
+ */
71
+ authorized: Address[];
72
+ /**
73
+ * The timestamp at which the vesting schedule begins
74
+ *
75
+ * @type {bigint}
76
+ */
77
+ start: bigint;
78
+ /**
79
+ * The duration of the vesting schedule (in seconds)
80
+ *
81
+ * @type {bigint}
82
+ */
83
+ duration: bigint;
84
+ /**
85
+ * The duration of the cliff period (in seconds)
86
+ *
87
+ * @type {bigint}
88
+ */
89
+ cliff: bigint;
90
+ }
91
+
92
+ /**
93
+ * A generic `viem.Log` event with support for `VestingBudget` event types.
94
+ *
95
+ * @export
96
+ * @typedef {VestingBudgetLog}
97
+ * @template {ContractEventName<typeof vestingBudgetAbi>} [event=ContractEventName<
98
+ * typeof vestingBudgetAbi
99
+ * >]
100
+ */
101
+ export type VestingBudgetLog<
102
+ event extends ContractEventName<typeof vestingBudgetAbi> = ContractEventName<
103
+ typeof vestingBudgetAbi
104
+ >,
105
+ > = GenericLog<typeof vestingBudgetAbi, event>;
106
+
107
+ /**
108
+ * A vesting-based budget implementation that allows for the distribution of assets over time
109
+ * Take note of the following when making use of this budget type:
110
+ * - 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.
111
+ * - 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.
112
+ * - 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.
113
+ * - 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.
114
+ *
115
+ * @export
116
+ * @class VestingBudget
117
+ * @typedef {VestingBudget}
118
+ * @extends {DeployableTarget<VestingBudgetPayload>}
119
+ */
120
+ export class VestingBudget extends DeployableTarget<
121
+ VestingBudgetPayload,
122
+ typeof vestingBudgetAbi
123
+ > {
124
+ public override readonly abi = vestingBudgetAbi;
125
+ /**
126
+ * @inheritdoc
127
+ *
128
+ * @public
129
+ * @static
130
+ * @type {Address}
131
+ */
132
+ public static override base: Address = import.meta.env
133
+ .VITE_VESTING_BUDGET_BASE;
134
+ /**
135
+ * @inheritdoc
136
+ *
137
+ * @public
138
+ * @static
139
+ * @type {RegistryType}
140
+ */
141
+ public static override registryType: RegistryType = RegistryType.BUDGET;
142
+
143
+ /**
144
+ * Get the owner of the budget
145
+ *
146
+ * @public
147
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'owner'>} [params]
148
+ * @returns {Promise<Address>}
149
+ */
150
+ public owner(params?: ReadParams<typeof vestingBudgetAbi, 'owner'>) {
151
+ return readVestingBudgetOwner(this._config, {
152
+ address: this.assertValidAddress(),
153
+ args: [],
154
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
155
+ ...(params as any),
156
+ });
157
+ }
158
+
159
+ /**
160
+ * The timestamp at which the vesting schedule begins
161
+ *
162
+ * @public
163
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'start'>} [params]
164
+ * @returns {*}
165
+ */
166
+ public start(params?: ReadParams<typeof vestingBudgetAbi, 'start'>) {
167
+ return readVestingBudgetStart(this._config, {
168
+ address: this.assertValidAddress(),
169
+ args: [],
170
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
171
+ ...(params as any),
172
+ });
173
+ }
174
+
175
+ /**
176
+ * The duration of the vesting schedule (in seconds)
177
+ *
178
+ * @public
179
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'duration'>} [params]
180
+ * @returns {*}
181
+ */
182
+ public duration(params?: ReadParams<typeof vestingBudgetAbi, 'duration'>) {
183
+ return readVestingBudgetDuration(this._config, {
184
+ address: this.assertValidAddress(),
185
+ args: [],
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
+
191
+ /**
192
+ * The duration of the cliff period (in seconds)
193
+ *
194
+ * @public
195
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'cliff'>} [params]
196
+ * @returns {*}
197
+ */
198
+ public cliff(params?: ReadParams<typeof vestingBudgetAbi, 'cliff'>) {
199
+ return readVestingBudgetCliff(this._config, {
200
+ address: this.assertValidAddress(),
201
+ args: [],
202
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
203
+ ...(params as any),
204
+ });
205
+ }
206
+
207
+ /**
208
+ * Allocates assets to the budget.
209
+ * The caller must have already approved the contract to transfer the asset
210
+ * If the asset transfer fails, the allocation will revert
211
+ *
212
+ * @public
213
+ * @async
214
+ * @param {(FungibleTransferPayload)} transfer
215
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'allocate'>} [params]
216
+ * @returns {Promise<boolean>} - True if the allocation was successful
217
+ */
218
+ public async allocate(
219
+ transfer: FungibleTransferPayload,
220
+ params?: WriteParams<typeof vestingBudgetAbi, 'allocate'>,
221
+ ) {
222
+ return await this.awaitResult(this.allocateRaw(transfer, params));
223
+ }
224
+
225
+ /**
226
+ * Allocates assets to the budget.
227
+ * The caller must have already approved the contract to transfer the asset
228
+ * If the asset transfer fails, the allocation will revert
229
+ *
230
+ * @public
231
+ * @async
232
+ * @param {(FungibleTransferPayload)} transfer
233
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'allocate'>} [params]
234
+ * @returns {Promise<boolean>} - True if the allocation was successful
235
+ */
236
+ public async allocateRaw(
237
+ transfer: FungibleTransferPayload,
238
+ params?: WriteParams<typeof vestingBudgetAbi, 'allocate'>,
239
+ ) {
240
+ const { request, result } = await simulateVestingBudgetAllocate(
241
+ this._config,
242
+ {
243
+ address: this.assertValidAddress(),
244
+ args: [prepareFungibleTransfer(transfer)],
245
+ ...this.optionallyAttachAccount(),
246
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
247
+ ...(params as any),
248
+ },
249
+ );
250
+ const hash = await writeVestingBudgetAllocate(this._config, request);
251
+ return { hash, result };
252
+ }
253
+
254
+ /**
255
+ * Clawbacks assets from the budget.
256
+ * Only the owner can directly clawback assets from the budget
257
+ * If the amount is zero, the entire balance of the asset will be transferred to the receiver
258
+ * If the asset transfer fails, the reclamation will revert
259
+ *
260
+ * @public
261
+ * @async
262
+ * @param {(FungibleTransferPayload)} transfer
263
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'clawback'>} [params]
264
+ * @returns {Promise<boolean>} - True if the request was successful
265
+ */
266
+ public async clawback(
267
+ transfer: FungibleTransferPayload,
268
+ params?: WriteParams<typeof vestingBudgetAbi, 'clawback'>,
269
+ ) {
270
+ return await this.awaitResult(this.clawbackRaw(transfer, params));
271
+ }
272
+
273
+ /**
274
+ * Clawbacks assets from the budget.
275
+ * Only the owner can directly clawback assets from the budget
276
+ * If the amount is zero, the entire balance of the asset will be transferred to the receiver
277
+ * If the asset transfer fails, the reclamation will revert
278
+ *
279
+ * @public
280
+ * @async
281
+ * @param {(FungibleTransferPayload)} transfer
282
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'clawback'>} [params]
283
+ * @returns {Promise<boolean>} - True if the request was successful
284
+ */
285
+ public async clawbackRaw(
286
+ transfer: FungibleTransferPayload,
287
+ params?: WriteParams<typeof vestingBudgetAbi, 'clawback'>,
288
+ ) {
289
+ const { request, result } = await simulateVestingBudgetClawback(
290
+ this._config,
291
+ {
292
+ address: this.assertValidAddress(),
293
+ args: [prepareFungibleTransfer(transfer)],
294
+ ...this.optionallyAttachAccount(),
295
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
296
+ ...(params as any),
297
+ },
298
+ );
299
+ const hash = await writeVestingBudgetClawback(this._config, request);
300
+ return { hash, result };
301
+ }
302
+
303
+ /**
304
+ * Disburses assets from the budget to a single recipient
305
+ * If the asset transfer fails, the disbursement will revert
306
+ *
307
+ * @public
308
+ * @async
309
+ * @param {(FungibleTransferPayload)} transfer
310
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'disburse'>} [params]
311
+ * @returns {Promise<boolean>} - True if the disbursement was successful
312
+ */
313
+ public async disburse(
314
+ transfer: FungibleTransferPayload,
315
+ params?: WriteParams<typeof vestingBudgetAbi, 'disburse'>,
316
+ ) {
317
+ return await this.awaitResult(this.disburseRaw(transfer, params));
318
+ }
319
+
320
+ /**
321
+ * Disburses assets from the budget to a single recipient
322
+ * If the asset transfer fails, the disbursement will revert
323
+ *
324
+ * @public
325
+ * @async
326
+ * @param {(FungibleTransferPayload)} transfer
327
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'disburse'>} [params]
328
+ * @returns {Promise<boolean>} - True if the disbursement was successful
329
+ */
330
+ public async disburseRaw(
331
+ transfer: FungibleTransferPayload,
332
+ params?: WriteParams<typeof vestingBudgetAbi, 'disburse'>,
333
+ ) {
334
+ const { request, result } = await simulateVestingBudgetDisburse(
335
+ this._config,
336
+ {
337
+ address: this.assertValidAddress(),
338
+ args: [prepareFungibleTransfer(transfer)],
339
+ ...this.optionallyAttachAccount(),
340
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
341
+ ...(params as any),
342
+ },
343
+ );
344
+ const hash = await writeVestingBudgetDisburse(this._config, request);
345
+ return { hash, result };
346
+ }
347
+
348
+ /**
349
+ * Disburses assets from the budget to multiple recipients
350
+ *
351
+ * @public
352
+ * @async
353
+ * @param {Array<FungibleTransferPayload>} transfers
354
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>} [params]
355
+ * @returns {Promise<boolean>} - True if all disbursements were successful
356
+ */
357
+ public async disburseBatch(
358
+ transfers: FungibleTransferPayload[],
359
+ params?: WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>,
360
+ ) {
361
+ return await this.awaitResult(this.disburseBatchRaw(transfers, params));
362
+ }
363
+
364
+ /**
365
+ * Disburses assets from the budget to multiple recipients
366
+ *
367
+ * @public
368
+ * @async
369
+ * @param {Array<FungibleTransferPayload>} transfers
370
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>} [params]
371
+ * @returns {Promise<boolean>} - True if all disbursements were successful
372
+ */
373
+ public async disburseBatchRaw(
374
+ transfers: FungibleTransferPayload[],
375
+ params?: WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>,
376
+ ) {
377
+ const { request, result } = await simulateVestingBudgetDisburseBatch(
378
+ this._config,
379
+ {
380
+ address: this.assertValidAddress(),
381
+ args: [transfers.map(prepareFungibleTransfer)],
382
+ ...this.optionallyAttachAccount(),
383
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
384
+ ...(params as any),
385
+ },
386
+ );
387
+ const hash = await writeVestingBudgetDisburseBatch(this._config, request);
388
+ return { hash, result };
389
+ }
390
+
391
+ /**
392
+ * Set the authorized status of the given accounts
393
+ * The mechanism for managing authorization is left to the implementing contract
394
+ *
395
+ * @public
396
+ * @async
397
+ * @param {Address[]} addresses - The accounts to authorize or deauthorize
398
+ * @param {boolean[]} allowed - The authorization status for the given accounts
399
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'setAuthorized'>} [params]
400
+ * @returns {Promise<void>}
401
+ */
402
+ public async setAuthorized(
403
+ addresses: Address[],
404
+ allowed: boolean[],
405
+ params?: WriteParams<typeof vestingBudgetAbi, 'setAuthorized'>,
406
+ ) {
407
+ return await this.awaitResult(
408
+ this.setAuthorizedRaw(addresses, allowed, params),
409
+ );
410
+ }
411
+
412
+ /**
413
+ * Set the authorized status of the given accounts
414
+ * The mechanism for managing authorization is left to the implementing contract
415
+ *
416
+ * @public
417
+ * @async
418
+ * @param {Address[]} addresses - The accounts to authorize or deauthorize
419
+ * @param {boolean[]} allowed - The authorization status for the given accounts
420
+ * @param {?WriteParams<typeof vestingBudgetAbi, 'setAuthorized'>} [params]
421
+ * @returns {Promise<void>}
422
+ */
423
+ public async setAuthorizedRaw(
424
+ addresses: Address[],
425
+ allowed: boolean[],
426
+ params?: WriteParams<typeof vestingBudgetAbi, 'setAuthorized'>,
427
+ ) {
428
+ const { request, result } = await simulateVestingBudgetSetAuthorized(
429
+ this._config,
430
+ {
431
+ address: this.assertValidAddress(),
432
+ args: [addresses, allowed],
433
+ ...this.optionallyAttachAccount(),
434
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
435
+ ...(params as any),
436
+ },
437
+ );
438
+ const hash = await writeVestingBudgetSetAuthorized(this._config, request);
439
+ return { hash, result };
440
+ }
441
+
442
+ /**
443
+ * Check if the given account is authorized to use the budget
444
+ *
445
+ * @public
446
+ * @param {Address} account
447
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'isAuthorized'>} [params]
448
+ * @returns {Promise<boolean>} - True if the account is authorized
449
+ */
450
+ public isAuthorized(
451
+ account: Address,
452
+ params?: ReadParams<typeof vestingBudgetAbi, 'isAuthorized'>,
453
+ ) {
454
+ return readVestingBudgetIsAuthorized(this._config, {
455
+ address: this.assertValidAddress(),
456
+ args: [account],
457
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
458
+ ...(params as any),
459
+ });
460
+ }
461
+
462
+ /**
463
+ * Get the end time of the vesting schedule
464
+ *
465
+ * @public
466
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'end'>} [params]
467
+ * @returns {Promise<bigint>}
468
+ */
469
+ public end(params?: ReadParams<typeof vestingBudgetAbi, 'end'>) {
470
+ return readVestingBudgetEnd(this._config, {
471
+ address: this.assertValidAddress(),
472
+ args: [],
473
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
474
+ ...(params as any),
475
+ });
476
+ }
477
+
478
+ /**
479
+ * Get the total amount of assets allocated to the budget, including any that have been distributed
480
+ * This is equal to the sum of the total current balance and the total distributed amount
481
+ *
482
+ * @public
483
+ * @param {Address} asset - The address of the asset (or the zero address for native assets)
484
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'total'>} [params]
485
+ * @returns {Promise<bigint>}
486
+ */
487
+ public total(
488
+ asset: Address,
489
+ params?: ReadParams<typeof vestingBudgetAbi, 'total'>,
490
+ ) {
491
+ return readVestingBudgetTotal(this._config, {
492
+ address: this.assertValidAddress(),
493
+ args: [asset],
494
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
495
+ ...(params as any),
496
+ });
497
+ }
498
+
499
+ /**
500
+ * Get the amount of assets available for distribution from the budget as of the current block timestamp
501
+ * This is equal to the total vested amount minus any already distributed
502
+ *
503
+ * @public
504
+ * @param {Address} asset - The address of the asset (or the zero address for native assets)
505
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'available'>} [params]
506
+ * @returns {Promise<bigint>} - The amount of assets currently available for distribution
507
+ */
508
+ public available(
509
+ asset: Address,
510
+ params?: ReadParams<typeof vestingBudgetAbi, 'available'>,
511
+ ) {
512
+ return readVestingBudgetAvailable(this._config, {
513
+ address: this.assertValidAddress(),
514
+ args: [asset],
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 amount of assets that have been distributed from the budget
522
+ *
523
+ * @public
524
+ * @param {Address} asset
525
+ * @param {?ReadParams<typeof vestingBudgetAbi, 'distributed'>} [params]
526
+ * @returns {Promise<bigint>} - The amount of assets distributed
527
+ */
528
+ public distributed(
529
+ asset: Address,
530
+ params?: ReadParams<typeof vestingBudgetAbi, 'distributed'>,
531
+ ) {
532
+ return readVestingBudgetDistributed(this._config, {
533
+ address: this.assertValidAddress(),
534
+ args: [asset],
535
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
536
+ ...(params as any),
537
+ });
538
+ }
539
+
540
+ /**
541
+ * @inheritdoc
542
+ *
543
+ * @public
544
+ * @param {?VestingBudgetPayload} [_payload]
545
+ * @param {?DeployableOptions} [_options]
546
+ * @returns {GenericDeployableParams}
547
+ */
548
+ public override buildParameters(
549
+ _payload?: VestingBudgetPayload,
550
+ _options?: DeployableOptions,
551
+ ): GenericDeployableParams {
552
+ const [payload, options] = this.validateDeploymentConfig(
553
+ _payload,
554
+ _options,
555
+ );
556
+ if (!payload.owner || payload.owner === zeroAddress) {
557
+ const owner = options.account
558
+ ? options.account.address
559
+ : options.config
560
+ ? getAccount(options.config).address
561
+ : this._account?.address;
562
+ if (owner) {
563
+ payload.owner = owner;
564
+ } else {
565
+ throw new DeployableUnknownOwnerProvidedError();
566
+ }
567
+ }
568
+ return {
569
+ abi: vestingBudgetAbi,
570
+ bytecode: bytecode as Hex,
571
+ args: [prepareVestingBudgetPayload(payload)],
572
+ ...this.optionallyAttachAccount(options.account),
573
+ };
574
+ }
575
+ }
576
+
577
+ /**
578
+ * Given a {@link VestingBudgetPayload}, properly encode a `VestingBudget.InitPayload` for use with {@link VestingBudget} initialization.
579
+ *
580
+ * @param {VestingBudgetPayload} param0
581
+ * @param {Address} param0.owner - The budget's owner.
582
+ * @param {{}} param0.authorized - List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
583
+ * @param {bigint} param0.start - The timestamp at which the vesting schedule begins
584
+ * @param {bigint} param0.duration - The duration of the vesting schedule (in seconds)
585
+ * @param {bigint} param0.cliff - The duration of the cliff period (in seconds)
586
+ * @returns {Hex}
587
+ */
588
+ export function prepareVestingBudgetPayload({
589
+ owner,
590
+ authorized,
591
+ start,
592
+ duration,
593
+ cliff,
594
+ }: VestingBudgetPayload) {
595
+ return encodeAbiParameters(
596
+ parseAbiParameters([
597
+ 'VestingBudgetPayload payload',
598
+ 'struct VestingBudgetPayload { address owner; address[] authorized; uint64 start; uint64 duration; uint64 cliff; }',
599
+ ]),
600
+ [{ owner, authorized, start, duration, cliff }],
601
+ );
602
+ }