@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,364 @@
1
+ import {
2
+ cgdaIncentiveAbi,
3
+ readCgdaIncentiveAsset,
4
+ readCgdaIncentiveCgdaParams,
5
+ readCgdaIncentiveClaimed,
6
+ readCgdaIncentiveClaims,
7
+ readCgdaIncentiveCurrentReward,
8
+ readCgdaIncentiveIsClaimable,
9
+ readCgdaIncentiveOwner,
10
+ readCgdaIncentiveReward,
11
+ readCgdaIncentiveTotalBudget,
12
+ simulateCgdaIncentiveClaim,
13
+ simulateCgdaIncentiveClawback,
14
+ writeCgdaIncentiveClaim,
15
+ writeCgdaIncentiveClawback,
16
+ } from '@boostxyz/evm';
17
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/CGDAIncentive.sol/CGDAIncentive.json';
18
+ import type { Address, ContractEventName, Hex } from 'viem';
19
+ import type {
20
+ DeployableOptions,
21
+ GenericDeployableParams,
22
+ } from '../Deployable/Deployable';
23
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
24
+ import {
25
+ type CGDAIncentivePayload,
26
+ type CGDAParameters,
27
+ type ClaimPayload,
28
+ type GenericLog,
29
+ type ReadParams,
30
+ RegistryType,
31
+ type WriteParams,
32
+ prepareCGDAIncentivePayload,
33
+ prepareClaimPayload,
34
+ } from '../utils';
35
+
36
+ export { cgdaIncentiveAbi };
37
+ export type { CGDAIncentivePayload };
38
+
39
+ /**
40
+ * A generic `viem.Log` event with support for `CGDAIncentive` event types.
41
+ *
42
+ * @export
43
+ * @typedef {CGDAIncentiveLog}
44
+ * @template {ContractEventName<typeof cgdaIncentiveAbi>} [event=ContractEventName<
45
+ * typeof cgdaIncentiveAbi
46
+ * >]
47
+ */
48
+ export type CGDAIncentiveLog<
49
+ event extends ContractEventName<typeof cgdaIncentiveAbi> = ContractEventName<
50
+ typeof cgdaIncentiveAbi
51
+ >,
52
+ > = GenericLog<typeof cgdaIncentiveAbi, event>;
53
+
54
+ /**
55
+ * Continuous Gradual Dutch Auction Incentive.
56
+ * An CGDA incentive implementation with reward amounts adjusting dynamically based on claim volume.
57
+ *
58
+ * @export
59
+ * @class CGDAIncentive
60
+ * @typedef {CGDAIncentive}
61
+ * @extends {DeployableTarget<CGDAIncentivePayload>}
62
+ */
63
+ export class CGDAIncentive extends DeployableTarget<
64
+ CGDAIncentivePayload,
65
+ typeof cgdaIncentiveAbi
66
+ > {
67
+ public override readonly abi = cgdaIncentiveAbi;
68
+ /**
69
+ * @inheritdoc
70
+ *
71
+ * @public
72
+ * @static
73
+ * @type {Address}
74
+ */
75
+ public static override base: Address = import.meta.env
76
+ .VITE_CGDA_INCENTIVE_BASE;
77
+ /**
78
+ * @inheritdoc
79
+ *
80
+ * @public
81
+ * @static
82
+ * @type {RegistryType}
83
+ */
84
+ public static override registryType: RegistryType = RegistryType.INCENTIVE;
85
+
86
+ /**
87
+ * The incentive's owner.
88
+ *
89
+ * @public
90
+ * @async
91
+ * @param {?ReadParams<typeof cgdaIncentiveAbi, 'owner'>} [params]
92
+ * @returns {unknown}
93
+ */
94
+ public async owner(params?: ReadParams<typeof cgdaIncentiveAbi, 'owner'>) {
95
+ return readCgdaIncentiveOwner(this._config, {
96
+ address: this.assertValidAddress(),
97
+ args: [],
98
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
99
+ ...(params as any),
100
+ });
101
+ }
102
+
103
+ /**
104
+ * The number of claims that have been made
105
+ *
106
+ * @public
107
+ * @async
108
+ * @param {?ReadParams<typeof cgdaIncentiveAbi, 'claims'>} [params]
109
+ * @returns {Promise<bigint>}
110
+ */
111
+ public async claims(params?: ReadParams<typeof cgdaIncentiveAbi, 'claims'>) {
112
+ return readCgdaIncentiveClaims(this._config, {
113
+ address: this.assertValidAddress(),
114
+ args: [],
115
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
116
+ ...(params as any),
117
+ });
118
+ }
119
+
120
+ /**
121
+ * The reward amount issued for each claim
122
+ *
123
+ * @public
124
+ * @async
125
+ * @param {?ReadParams<typeof allowListIncentiveAbi, 'reward'>} [params]
126
+ * @returns {Promise<bigint>}
127
+ */
128
+ public async reward(params?: ReadParams<typeof cgdaIncentiveAbi, 'reward'>) {
129
+ return readCgdaIncentiveReward(this._config, {
130
+ address: this.assertValidAddress(),
131
+ args: [],
132
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
133
+ ...(params as any),
134
+ });
135
+ }
136
+
137
+ /**
138
+ * Get the claim status for a user
139
+ *
140
+ * @public
141
+ * @async
142
+ * @param {Address} address
143
+ * @param {?ReadParams<typeof cgdaIncentiveAbi, 'claimed'>} [params]
144
+ * @returns {Promise<boolean>}
145
+ */
146
+ public async claimed(
147
+ address: Address,
148
+ params?: ReadParams<typeof cgdaIncentiveAbi, 'claimed'>,
149
+ ) {
150
+ return readCgdaIncentiveClaimed(this._config, {
151
+ address: this.assertValidAddress(),
152
+ args: [address],
153
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
154
+ ...(params as any),
155
+ });
156
+ }
157
+
158
+ /**
159
+ * The CGDA-like token used for the incentive
160
+ *
161
+ * @public
162
+ * @async
163
+ * @param {?ReadParams<typeof cgdaIncentiveAbi, 'asset'>} [params]
164
+ * @returns {unknown}
165
+ */
166
+ public async asset(params?: ReadParams<typeof cgdaIncentiveAbi, 'asset'>) {
167
+ return readCgdaIncentiveAsset(this._config, {
168
+ address: this.assertValidAddress(),
169
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
170
+ ...(params as any),
171
+ });
172
+ }
173
+
174
+ /**
175
+ * The configuration parameters for the CGDAIncentive
176
+ *
177
+ * @public
178
+ * @async
179
+ * @param {?ReadParams<typeof cgdaIncentiveAbi, 'cgdaParams'>} [params]
180
+ * @returns {Promise<CGDAParameters>}
181
+ */
182
+ public async cgdaParams(
183
+ params?: ReadParams<typeof cgdaIncentiveAbi, 'cgdaParams'>,
184
+ ): Promise<CGDAParameters> {
185
+ const [rewardDecay, rewardBoost, lastClaimTime, currentReward] =
186
+ await readCgdaIncentiveCgdaParams(this._config, {
187
+ address: this.assertValidAddress(),
188
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
189
+ ...(params as any),
190
+ });
191
+ return {
192
+ rewardDecay,
193
+ rewardBoost,
194
+ lastClaimTime,
195
+ currentReward,
196
+ };
197
+ }
198
+
199
+ /**
200
+ * The total budget of the incentive
201
+ *
202
+ * @public
203
+ * @async
204
+ * @param {?ReadParams<typeof cgdaIncentiveAbi, 'totalBudget'>} [params]
205
+ * @returns {Promise<bigint>}
206
+ */
207
+ public async totalBudget(
208
+ params?: ReadParams<typeof cgdaIncentiveAbi, 'totalBudget'>,
209
+ ) {
210
+ return readCgdaIncentiveTotalBudget(this._config, {
211
+ address: this.assertValidAddress(),
212
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
213
+ ...(params as any),
214
+ });
215
+ }
216
+
217
+ /**
218
+ * Claim the incentive
219
+ *
220
+ * @public
221
+ * @async
222
+ * @param {ClaimPayload} payload
223
+ * @param {?WriteParams<typeof cgdaIncentiveAbi, 'claim'>} [params]
224
+ * @returns {Promise<boolean>} - Returns true if successfully claimed
225
+ */
226
+ public async claim(
227
+ payload: ClaimPayload,
228
+ params?: WriteParams<typeof cgdaIncentiveAbi, 'claim'>,
229
+ ) {
230
+ return this.awaitResult(this.claimRaw(payload, params));
231
+ }
232
+
233
+ /**
234
+ * Claim the incentive
235
+ *
236
+ * @public
237
+ * @async
238
+ * @param {ClaimPayload} payload
239
+ * @param {?WriteParams<typeof cgdaIncentiveAbi, 'claim'>} [params]
240
+ * @returns {Promise<boolean>} - Returns true if successfully claimed
241
+ */
242
+ public async claimRaw(
243
+ payload: ClaimPayload,
244
+ params?: WriteParams<typeof cgdaIncentiveAbi, 'claim'>,
245
+ ) {
246
+ const { request, result } = await simulateCgdaIncentiveClaim(this._config, {
247
+ address: this.assertValidAddress(),
248
+ args: [prepareClaimPayload(payload)],
249
+ ...this.optionallyAttachAccount(),
250
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
251
+ ...(params as any),
252
+ });
253
+ const hash = await writeCgdaIncentiveClaim(this._config, request);
254
+ return { hash, result };
255
+ }
256
+
257
+ /**
258
+ * Clawback assets from the incentive
259
+ *
260
+ * @public
261
+ * @async
262
+ * @param {ClaimPayload} payload
263
+ * @param {?WriteParams<typeof cgdaIncentiveAbi, 'clawback'>} [params]
264
+ * @returns {Promise<boolean>} - True if the assets were successfully clawbacked
265
+ */
266
+ public async clawback(
267
+ payload: ClaimPayload,
268
+ params?: WriteParams<typeof cgdaIncentiveAbi, 'clawback'>,
269
+ ) {
270
+ return this.awaitResult(this.clawbackRaw(payload, params));
271
+ }
272
+
273
+ /**
274
+ * Clawback assets from the incentive
275
+ *
276
+ * @public
277
+ * @async
278
+ * @param {ClaimPayload} payload
279
+ * @param {?WriteParams<typeof cgdaIncentiveAbi, 'clawback'>} [params]
280
+ * @returns {Promise<boolean>} - True if the assets were successfully clawbacked
281
+ */
282
+ public async clawbackRaw(
283
+ payload: ClaimPayload,
284
+ params?: WriteParams<typeof cgdaIncentiveAbi, 'clawback'>,
285
+ ) {
286
+ const { request, result } = await simulateCgdaIncentiveClawback(
287
+ this._config,
288
+ {
289
+ address: this.assertValidAddress(),
290
+ args: [prepareClaimPayload(payload)],
291
+ ...this.optionallyAttachAccount(),
292
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
293
+ ...(params as any),
294
+ },
295
+ );
296
+ const hash = await writeCgdaIncentiveClawback(this._config, request);
297
+ return { hash, result };
298
+ }
299
+
300
+ /**
301
+ * Check if an incentive is claimable
302
+ *
303
+ * @public
304
+ * @async
305
+ * @param {ClaimPayload} payload
306
+ * @param {?ReadParams<typeof cgdaIncentiveAbi, 'isClaimable'>} [params]
307
+ * @returns {Promise<boolean>} - True if the incentive is claimable based on the data payload
308
+ */
309
+ public async isClaimable(
310
+ payload: ClaimPayload,
311
+ params?: ReadParams<typeof cgdaIncentiveAbi, 'isClaimable'>,
312
+ ) {
313
+ return readCgdaIncentiveIsClaimable(this._config, {
314
+ address: this.assertValidAddress(),
315
+ args: [prepareClaimPayload(payload)],
316
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
317
+ ...(params as any),
318
+ });
319
+ }
320
+
321
+ /**
322
+ * Calculates the current reward based on the time since the last claim.
323
+ * The reward is calculated based on the time since the last claim, the available budget, and the reward parameters. It increases linearly over time in the absence of claims, with each hour adding `rewardBoost` to the current reward, up to the available budget.
324
+ * For example, if there is one claim in the first hour, then no claims for three hours, the claimable reward would be `initialReward - rewardDecay + (rewardBoost * 3)`
325
+ *
326
+ * @public
327
+ * @async
328
+ * @param {?ReadParams<typeof cgdaIncentiveAbi, 'currentReward'>} [params]
329
+ * @returns {Promise<bigint>} - The current reward
330
+ */
331
+ public async currentReward(
332
+ params?: ReadParams<typeof cgdaIncentiveAbi, 'currentReward'>,
333
+ ) {
334
+ return readCgdaIncentiveCurrentReward(this._config, {
335
+ address: this.assertValidAddress(),
336
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
337
+ ...(params as any),
338
+ });
339
+ }
340
+
341
+ /**
342
+ * @inheritdoc
343
+ *
344
+ * @public
345
+ * @param {?CGDAIncentivePayload} [_payload]
346
+ * @param {?DeployableOptions} [_options]
347
+ * @returns {GenericDeployableParams}
348
+ */
349
+ public override buildParameters(
350
+ _payload?: CGDAIncentivePayload,
351
+ _options?: DeployableOptions,
352
+ ): GenericDeployableParams {
353
+ const [payload, options] = this.validateDeploymentConfig(
354
+ _payload,
355
+ _options,
356
+ );
357
+ return {
358
+ abi: cgdaIncentiveAbi,
359
+ bytecode: bytecode as Hex,
360
+ args: [prepareCGDAIncentivePayload(payload)],
361
+ ...this.optionallyAttachAccount(options.account),
362
+ };
363
+ }
364
+ }
@@ -0,0 +1,98 @@
1
+ import { readMockErc1155BalanceOf } from '@boostxyz/evm';
2
+ import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
3
+ import { signMessage } from '@wagmi/core';
4
+ import {
5
+ encodePacked,
6
+ isAddress,
7
+ keccak256,
8
+ pad,
9
+ parseEther,
10
+ zeroAddress,
11
+ zeroHash,
12
+ } from 'viem';
13
+ import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
14
+ import { accounts } from '../../test/accounts';
15
+ import {
16
+ type BudgetFixtures,
17
+ type Fixtures,
18
+ defaultOptions,
19
+ deployFixtures,
20
+ freshBoost,
21
+ fundBudget,
22
+ } from '../../test/helpers';
23
+ import { prepareSignerValidatorClaimDataPayload } from '../utils';
24
+ import { ERC1155Incentive, ERC1155StrategyType } from './ERC1155Incentive';
25
+
26
+ const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
27
+
28
+ let fixtures: Fixtures, budgets: BudgetFixtures;
29
+
30
+ describe.skip('ERC1155Incentive', () => {
31
+ beforeAll(async () => {
32
+ fixtures = await loadFixture(deployFixtures);
33
+ });
34
+
35
+ beforeEach(async () => {
36
+ budgets = await loadFixture(fundBudget(defaultOptions, fixtures));
37
+ });
38
+
39
+ test('can successfully be deployed', async () => {
40
+ const action = new ERC1155Incentive(defaultOptions, {
41
+ asset: zeroAddress,
42
+ strategy: ERC1155StrategyType.MINT,
43
+ tokenId: 0n,
44
+ limit: 10n,
45
+ extraData: '0x',
46
+ });
47
+ await action.deploy();
48
+ expect(isAddress(action.assertValidAddress())).toBe(true);
49
+ });
50
+
51
+ test('can claim', async () => {
52
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
53
+ const referrer = accounts.at(1)!.account!,
54
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
55
+ trustedSigner = accounts.at(0)!;
56
+ const erc1155Incentive = new fixtures.bases.ERC1155Incentive(
57
+ defaultOptions,
58
+ {
59
+ asset: budgets.erc1155.assertValidAddress(),
60
+ strategy: ERC1155StrategyType.POOL,
61
+ tokenId: 1n,
62
+ limit: 1n,
63
+ extraData: zeroHash,
64
+ },
65
+ );
66
+ const boost = await freshBoost(fixtures, {
67
+ budget: budgets.budget,
68
+ incentives: [erc1155Incentive],
69
+ });
70
+
71
+ const claimant = trustedSigner.account;
72
+ const incentiveData = pad('0xdef456232173821931823712381232131391321934');
73
+ const incentiveQuantity = 1;
74
+ const claimDataPayload = await prepareSignerValidatorClaimDataPayload({
75
+ signer: trustedSigner,
76
+ incentiveData,
77
+ chainId: defaultOptions.config.chains[0].id,
78
+ validator: boost.validator.assertValidAddress(),
79
+ incentiveQuantity,
80
+ claimant,
81
+ boostId: boost.id,
82
+ });
83
+
84
+ await fixtures.core.claimIncentive(
85
+ boost.id,
86
+ 0n,
87
+ referrer,
88
+ claimDataPayload,
89
+ { value: BOOST_CORE_CLAIM_FEE },
90
+ );
91
+ expect(
92
+ await readMockErc1155BalanceOf(defaultOptions.config, {
93
+ address: budgets.erc1155.assertValidAddress(),
94
+ args: [defaultOptions.account.address, 1n],
95
+ }),
96
+ ).toBe(1n);
97
+ });
98
+ });