@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,428 @@
1
+ import {
2
+ erc20VariableIncentiveAbi,
3
+ readErc20VariableIncentiveAsset,
4
+ readErc20VariableIncentiveClaimed,
5
+ readErc20VariableIncentiveClaims,
6
+ readErc20VariableIncentiveCurrentReward,
7
+ readErc20VariableIncentiveIsClaimable,
8
+ readErc20VariableIncentiveLimit,
9
+ readErc20VariableIncentiveOwner,
10
+ readErc20VariableIncentiveReward,
11
+ readErc20VariableIncentiveTotalClaimed,
12
+ simulateErc20VariableIncentiveClaim,
13
+ simulateErc20VariableIncentiveClawback,
14
+ writeErc20VariableIncentiveClaim,
15
+ writeErc20VariableIncentiveClawback,
16
+ } from '@boostxyz/evm';
17
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20VariableIncentive.sol/ERC20VariableIncentive.json';
18
+ import {
19
+ type Address,
20
+ type ContractEventName,
21
+ type Hex,
22
+ encodeAbiParameters,
23
+ } from 'viem';
24
+ import { ERC20VariableIncentive as ERC20VariableIncentiveBases } 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 { erc20VariableIncentiveAbi };
39
+ /**
40
+ * The object representation of a `ERC20VariableIncentivePayload.InitPayload`
41
+ *
42
+ * @export
43
+ * @interface ERC20VariableIncentivePayload
44
+ * @typedef {ERC20VariableIncentivePayload}
45
+ */
46
+ export interface ERC20VariableIncentivePayload {
47
+ /**
48
+ * The address of the incentivized asset.
49
+ *
50
+ * @type {Address}
51
+ */
52
+ asset: Address;
53
+ /**
54
+ * The amount of the asset to distribute.
55
+ *
56
+ * @type {bigint}
57
+ */
58
+ reward: bigint;
59
+ /**
60
+ * The total spending limit of the asset that will be distributed.
61
+ *
62
+ * @type {bigint}
63
+ */
64
+ limit: bigint;
65
+ /**
66
+ * The entity that can `clawback` funds
67
+ *
68
+ * @type {Address}
69
+ */
70
+ manager: Address;
71
+ }
72
+
73
+ /**
74
+ * A generic `viem.Log` event with support for `ERC20VariableIncentive` event types.
75
+ *
76
+ * @export
77
+ * @typedef {ERC20VariableIncentiveLog}
78
+ * @template {ContractEventName<typeof erc20VariableIncentiveAbi>} [event=ContractEventName<
79
+ * typeof erc20VariableIncentiveAbi
80
+ * >]
81
+ */
82
+ export type ERC20VariableIncentiveLog<
83
+ event extends ContractEventName<
84
+ typeof erc20VariableIncentiveAbi
85
+ > = ContractEventName<typeof erc20VariableIncentiveAbi>,
86
+ > = GenericLog<typeof erc20VariableIncentiveAbi, event>;
87
+
88
+ /**
89
+ * A modified ERC20 incentive implementation that allows claiming of variable token amounts with a spending limit
90
+ *
91
+ * @export
92
+ * @class ERC20VariableIncentive
93
+ * @typedef {ERC20VariableIncentive}
94
+ * @extends {DeployableTarget<ERC20VariableIncentivePayload>}
95
+ */
96
+ export class ERC20VariableIncentive extends DeployableTarget<
97
+ ERC20VariableIncentivePayload,
98
+ typeof erc20VariableIncentiveAbi
99
+ > {
100
+ public override readonly abi = erc20VariableIncentiveAbi;
101
+ /**
102
+ * @inheritdoc
103
+ *
104
+ * @public
105
+ * @static
106
+ * @type {Record<number, Address>}
107
+ */
108
+ public static override bases: Record<number, Address> = {
109
+ ...(ERC20VariableIncentiveBases as Record<number, Address>),
110
+ };
111
+ /**
112
+ * @inheritdoc
113
+ *
114
+ * @public
115
+ * @static
116
+ * @type {RegistryType}
117
+ */
118
+ public static override registryType: RegistryType = RegistryType.INCENTIVE;
119
+
120
+ /**
121
+ * The owner of the incentive
122
+ *
123
+ * @public
124
+ * @async
125
+ * @param {?ReadParams} [params]
126
+ * @returns {Promise<Address>}
127
+ */
128
+ public async owner(
129
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'owner'>,
130
+ ) {
131
+ return await readErc20VariableIncentiveOwner(this._config, {
132
+ address: this.assertValidAddress(),
133
+ args: [],
134
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
135
+ ...(params as any),
136
+ });
137
+ }
138
+
139
+ /**
140
+ * The total amount of rewards claimed
141
+ *
142
+ * @public
143
+ * @async
144
+ * @param {?ReadParams} [params]
145
+ * @returns {Promise<bigint>}
146
+ */
147
+ public async totalClaimed(
148
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'totalClaimed'>,
149
+ ) {
150
+ return await readErc20VariableIncentiveTotalClaimed(this._config, {
151
+ address: this.assertValidAddress(),
152
+ args: [],
153
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
154
+ ...(params as any),
155
+ });
156
+ }
157
+
158
+ /**
159
+ * The current reward
160
+ *
161
+ * @public
162
+ * @async
163
+ * @param {?ReadParams} [params]
164
+ * @returns {Promise<bigint>} - The current reward
165
+ */
166
+ public async currentReward(
167
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'currentReward'>,
168
+ ) {
169
+ return await readErc20VariableIncentiveCurrentReward(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} [params]
183
+ * @returns {Promise<bigint>}
184
+ */
185
+ public async claims(
186
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'claims'>,
187
+ ) {
188
+ return await readErc20VariableIncentiveClaims(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
+ * A mapping of address to claim status
198
+ *
199
+ * @public
200
+ * @async
201
+ * @param {Address} address
202
+ * @param {?ReadParams} [params]
203
+ * @returns {Promise<boolean>}
204
+ */
205
+ public async claimed(
206
+ address: Address,
207
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'claimed'>,
208
+ ) {
209
+ return await readErc20VariableIncentiveClaimed(this._config, {
210
+ address: this.assertValidAddress(),
211
+ args: [address],
212
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
213
+ ...(params as any),
214
+ });
215
+ }
216
+
217
+ /**
218
+ * The address of the ERC20-like token
219
+ *
220
+ * @public
221
+ * @async
222
+ * @param {?ReadParams} [params]
223
+ * @returns {Promise<Address>}
224
+ */
225
+ public async asset(
226
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'asset'>,
227
+ ) {
228
+ return await readErc20VariableIncentiveAsset(this._config, {
229
+ address: this.assertValidAddress(),
230
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
231
+ ...(params as any),
232
+ });
233
+ }
234
+
235
+ /**
236
+ * The reward amount issued for each claim
237
+ *
238
+ * @public
239
+ * @async
240
+ * @param {?ReadParams} [params]
241
+ * @returns {Promise<bigint>}
242
+ */
243
+ public async reward(
244
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'reward'>,
245
+ ) {
246
+ return await readErc20VariableIncentiveReward(this._config, {
247
+ address: this.assertValidAddress(),
248
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
249
+ ...(params as any),
250
+ });
251
+ }
252
+
253
+ /**
254
+ * The limit (max claims, or max entries for raffles)
255
+ *
256
+ * @public
257
+ * @async
258
+ * @param {?ReadParams} [params]
259
+ * @returns {Promise<bigint>}
260
+ */
261
+ public async limit(
262
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'limit'>,
263
+ ) {
264
+ return await readErc20VariableIncentiveLimit(this._config, {
265
+ address: this.assertValidAddress(),
266
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
267
+ ...(params as any),
268
+ });
269
+ }
270
+
271
+ /**
272
+ * Claim the incentive
273
+ *
274
+ * @public
275
+ * @async
276
+ * @param {ClaimPayload} payload
277
+ * @param {?WriteParams} [params]
278
+ * @returns {Promise<boolean>} - Returns true if successfully claimed
279
+ */
280
+ protected async claim(
281
+ payload: ClaimPayload,
282
+ params?: WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>,
283
+ ) {
284
+ return await this.awaitResult(this.claimRaw(payload, params));
285
+ }
286
+
287
+ /**
288
+ * Claim the incentive
289
+ *
290
+ * @public
291
+ * @async
292
+ * @param {ClaimPayload} payload
293
+ * @param {?WriteParams} [params]
294
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - Returns true if successfully claimed
295
+ */
296
+ protected async claimRaw(
297
+ payload: ClaimPayload,
298
+ params?: WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>,
299
+ ) {
300
+ const { request, result } = await simulateErc20VariableIncentiveClaim(
301
+ this._config,
302
+ {
303
+ address: this.assertValidAddress(),
304
+ args: [prepareClaimPayload(payload)],
305
+ ...this.optionallyAttachAccount(),
306
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
307
+ ...(params as any),
308
+ },
309
+ );
310
+ const hash = await writeErc20VariableIncentiveClaim(this._config, request);
311
+ return { hash, result };
312
+ }
313
+
314
+ /**
315
+ * Clawback assets from the incentive
316
+ *
317
+ * @public
318
+ * @async
319
+ * @param {ClaimPayload} payload
320
+ * @param {?WriteParams} [params]
321
+ * @returns {Promise<boolean>} - True if the assets were successfully clawbacked
322
+ */
323
+ public async clawback(
324
+ payload: ClaimPayload,
325
+ params?: WriteParams<typeof erc20VariableIncentiveAbi, 'clawback'>,
326
+ ) {
327
+ return await this.awaitResult(this.clawbackRaw(payload, params));
328
+ }
329
+
330
+ /**
331
+ * Clawback assets from the incentive
332
+ *
333
+ * @public
334
+ * @async
335
+ * @param {ClaimPayload} payload
336
+ * @param {?WriteParams} [params]
337
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the assets were successfully clawbacked
338
+ */
339
+ public async clawbackRaw(
340
+ payload: ClaimPayload,
341
+ params?: WriteParams<typeof erc20VariableIncentiveAbi, 'clawback'>,
342
+ ) {
343
+ const { request, result } = await simulateErc20VariableIncentiveClawback(
344
+ this._config,
345
+ {
346
+ address: this.assertValidAddress(),
347
+ args: [prepareClaimPayload(payload)],
348
+ ...this.optionallyAttachAccount(),
349
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
350
+ ...(params as any),
351
+ },
352
+ );
353
+ const hash = await writeErc20VariableIncentiveClawback(
354
+ this._config,
355
+ request,
356
+ );
357
+ return { hash, result };
358
+ }
359
+
360
+ /**
361
+ * Check if an incentive is claimable. For the POOL strategy, the `bytes data` portion of the payload ignored. The recipient must not have already claimed the incentive.
362
+ *
363
+ * @public
364
+ * @async
365
+ * @param {ClaimPayload} payload
366
+ * @param {?ReadParams} [params]
367
+ * @returns {Promise<boolean>} = True if the incentive is claimable based on the data payload
368
+ */
369
+ public async isClaimable(
370
+ payload: ClaimPayload,
371
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'isClaimable'>,
372
+ ) {
373
+ return await readErc20VariableIncentiveIsClaimable(this._config, {
374
+ address: this.assertValidAddress(),
375
+ args: [prepareClaimPayload(payload)],
376
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
377
+ ...(params as any),
378
+ });
379
+ }
380
+
381
+ /**
382
+ * @inheritdoc
383
+ *
384
+ * @public
385
+ * @param {?ERC20VariableIncentivePayload} [_payload]
386
+ * @param {?DeployableOptions} [_options]
387
+ * @returns {GenericDeployableParams}
388
+ */
389
+ public override buildParameters(
390
+ _payload?: ERC20VariableIncentivePayload,
391
+ _options?: DeployableOptions,
392
+ ): GenericDeployableParams {
393
+ const [payload, options] = this.validateDeploymentConfig(
394
+ _payload,
395
+ _options,
396
+ );
397
+ return {
398
+ abi: erc20VariableIncentiveAbi,
399
+ bytecode: bytecode as Hex,
400
+ args: [prepareERC20VariableIncentivePayload(payload)],
401
+ ...this.optionallyAttachAccount(options.account),
402
+ };
403
+ }
404
+ }
405
+
406
+ /**
407
+ * Given a {@link ERC20VariableIncentivePayload}, properly encode a ` ERC20VariableIncentive.InitPayload` for use with {@link ERC20VariableIncentive} initialization.
408
+ *
409
+ * @param {ERC20VariableIncentivePayload} param0
410
+ * @param {Address} param0.asset - The address of the incentivized asset.
411
+ * @param {bigint} param0.reward - The amount of the asset to distribute.
412
+ * @param {bigint} param0.limit - How many times can this incentive be claimed.
413
+ * @returns {Hex}
414
+ */
415
+ export function prepareERC20VariableIncentivePayload({
416
+ asset,
417
+ reward,
418
+ limit,
419
+ }: ERC20VariableIncentivePayload) {
420
+ return encodeAbiParameters(
421
+ [
422
+ { type: 'address', name: 'asset' },
423
+ { type: 'uint256', name: 'reward' },
424
+ { type: 'uint256', name: 'limit' },
425
+ ],
426
+ [asset, reward, limit],
427
+ );
428
+ }
@@ -0,0 +1,95 @@
1
+ import { zeroAddress } from 'viem';
2
+ import { describe, expect, test } from 'vitest';
3
+ import { defaultOptions } from '@boostxyz/test/helpers';
4
+ import { StrategyType } from '../claiming';
5
+ import {
6
+ AllowListIncentive,
7
+ CGDAIncentive,
8
+ ERC20Incentive,
9
+ ERC20VariableIncentive,
10
+ incentiveFromAddress,
11
+ } from './Incentive';
12
+ import { PointsIncentive } from './PointsIncentive';
13
+
14
+ describe('Incentive', () => {
15
+ test('can automatically instantiate PointsIncentive given an address', async () => {
16
+ const incentive = new PointsIncentive(defaultOptions, {
17
+ venue: zeroAddress,
18
+ selector: '0xdeadb33f',
19
+ reward: 1n,
20
+ limit: 1n,
21
+ });
22
+ await incentive.deploy();
23
+ expect(
24
+ await incentiveFromAddress(
25
+ defaultOptions,
26
+ incentive.assertValidAddress(),
27
+ ),
28
+ ).toBeInstanceOf(PointsIncentive);
29
+ });
30
+
31
+ test('can automatically instantiate AllowListIncentive given an address', async () => {
32
+ const incentive = new AllowListIncentive(defaultOptions, {
33
+ allowList: zeroAddress,
34
+ limit: 3n,
35
+ });
36
+ await incentive.deploy();
37
+ expect(
38
+ await incentiveFromAddress(
39
+ defaultOptions,
40
+ incentive.assertValidAddress(),
41
+ ),
42
+ ).toBeInstanceOf(AllowListIncentive);
43
+ });
44
+
45
+ test('can automatically instantiate CGDAIncentive given an address', async () => {
46
+ const incentive = new CGDAIncentive(defaultOptions, {
47
+ asset: zeroAddress,
48
+ initialReward: 1n,
49
+ totalBudget: 10n,
50
+ rewardBoost: 1n,
51
+ rewardDecay: 1n,
52
+ manager: zeroAddress,
53
+ });
54
+ await incentive.deploy();
55
+ expect(
56
+ await incentiveFromAddress(
57
+ defaultOptions,
58
+ incentive.assertValidAddress(),
59
+ ),
60
+ ).toBeInstanceOf(CGDAIncentive);
61
+ });
62
+
63
+ test('can automatically instantiate ERC20Incentive given an address', async () => {
64
+ const incentive = new ERC20Incentive(defaultOptions, {
65
+ asset: zeroAddress,
66
+ strategy: StrategyType.POOL,
67
+ reward: 1n,
68
+ limit: 10n,
69
+ manager: zeroAddress,
70
+ });
71
+ await incentive.deploy();
72
+ expect(
73
+ await incentiveFromAddress(
74
+ defaultOptions,
75
+ incentive.assertValidAddress(),
76
+ ),
77
+ ).toBeInstanceOf(ERC20Incentive);
78
+ });
79
+
80
+ test('can automatically instantiate ERC20VariableIncentive given an address', async () => {
81
+ const incentive = new ERC20VariableIncentive(defaultOptions, {
82
+ asset: zeroAddress,
83
+ reward: 1n,
84
+ limit: 10n,
85
+ manager: zeroAddress,
86
+ });
87
+ await incentive.deploy();
88
+ expect(
89
+ await incentiveFromAddress(
90
+ defaultOptions,
91
+ incentive.assertValidAddress(),
92
+ ),
93
+ ).toBeInstanceOf(ERC20VariableIncentive);
94
+ });
95
+ });
@@ -0,0 +1,86 @@
1
+ import { aIncentiveAbi } from '@boostxyz/evm';
2
+ import {
3
+ AAllowListIncentive,
4
+ ACGDAIncentive,
5
+ AERC20Incentive,
6
+ AERC20VariableIncentive,
7
+ APointsIncentive,
8
+ } from '@boostxyz/evm/deploys/componentInterfaces.json';
9
+ import { readContract } from '@wagmi/core';
10
+ import type { Address, Hex } from 'viem';
11
+ import type { DeployableOptions } from '../Deployable/Deployable';
12
+ import { InvalidComponentInterfaceError } from '../errors';
13
+ import { AllowListIncentive } from './AllowListIncentive';
14
+ import { CGDAIncentive } from './CGDAIncentive';
15
+ import { ERC20Incentive } from './ERC20Incentive';
16
+ import type { ERC20VariableCriteriaIncentive } from './ERC20VariableCriteriaIncentive';
17
+ import { ERC20VariableIncentive } from './ERC20VariableIncentive';
18
+ // import { ERC1155Incentive } from './ERC1155Incentive';
19
+ import { PointsIncentive } from './PointsIncentive';
20
+
21
+ export {
22
+ AllowListIncentive,
23
+ CGDAIncentive,
24
+ // ERC1155Incentive,
25
+ ERC20Incentive,
26
+ PointsIncentive,
27
+ ERC20VariableIncentive,
28
+ };
29
+
30
+ /**
31
+ * A union type representing all valid protocol Incentive implementations
32
+ *
33
+ * @export
34
+ * @typedef {Incentive}
35
+ */
36
+ export type Incentive =
37
+ | AllowListIncentive
38
+ | CGDAIncentive
39
+ | ERC20Incentive
40
+ // | ERC1155Incentive
41
+ | PointsIncentive
42
+ | ERC20VariableIncentive
43
+ | ERC20VariableCriteriaIncentive;
44
+
45
+ /**
46
+ * A map of Incentive component interfaces to their constructors.
47
+ *
48
+ * @type {{ "0xc5b24b8e": typeof PointsIncentive; "0x8c901437": typeof ERC20Incentive; "0x4414fbb4": typeof AllowListIncentive; "0xa39e44d9": typeof CGDAIncentive; "0xa8e4af1e": typeof ERC20VariableIncentive }}
49
+ */
50
+ export const IncentiveByComponentInterface = {
51
+ [APointsIncentive as Hex]: PointsIncentive,
52
+ [AERC20Incentive as Hex]: ERC20Incentive,
53
+ [AAllowListIncentive]: AllowListIncentive,
54
+ // [AERC1155Incentive as Hex]: ERC1155Incentive,
55
+ [ACGDAIncentive as Hex]: CGDAIncentive,
56
+ [AERC20VariableIncentive as Hex]: ERC20VariableIncentive,
57
+ };
58
+
59
+ /**
60
+ * A function that will read a contract's component interface using `getComponentInterface` and return the correct instantiated instance.
61
+ *
62
+ * @export
63
+ * @async
64
+ * @param {DeployableOptions} options
65
+ * @param {Address} address
66
+ * @returns {Incentive}
67
+ * @throws {@link InvalidComponentInterfaceError}
68
+ */
69
+ export async function incentiveFromAddress(
70
+ options: DeployableOptions,
71
+ address: Address,
72
+ ) {
73
+ const interfaceId = (await readContract(options.config, {
74
+ abi: aIncentiveAbi,
75
+ functionName: 'getComponentInterface',
76
+ address,
77
+ })) as keyof typeof IncentiveByComponentInterface;
78
+ const Ctor = IncentiveByComponentInterface[interfaceId];
79
+ if (!Ctor) {
80
+ throw new InvalidComponentInterfaceError(
81
+ Object.keys(IncentiveByComponentInterface) as Hex[],
82
+ interfaceId as Hex,
83
+ );
84
+ }
85
+ return new Ctor(options, address);
86
+ }