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

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