@boostxyz/sdk 0.0.0-alpha.2 → 0.0.0-alpha.21

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