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