@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,422 @@
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
+
67
+ /**
68
+ * A generic `viem.Log` event with support for `ERC20VariableIncentive` event types.
69
+ *
70
+ * @export
71
+ * @typedef {ERC20VariableIncentiveLog}
72
+ * @template {ContractEventName<typeof erc20VariableIncentiveAbi>} [event=ContractEventName<
73
+ * typeof erc20VariableIncentiveAbi
74
+ * >]
75
+ */
76
+ export type ERC20VariableIncentiveLog<
77
+ event extends ContractEventName<
78
+ typeof erc20VariableIncentiveAbi
79
+ > = ContractEventName<typeof erc20VariableIncentiveAbi>,
80
+ > = GenericLog<typeof erc20VariableIncentiveAbi, event>;
81
+
82
+ /**
83
+ * A modified ERC20 incentive implementation that allows claiming of variable token amounts with a spending limit
84
+ *
85
+ * @export
86
+ * @class ERC20VariableIncentive
87
+ * @typedef {ERC20VariableIncentive}
88
+ * @extends {DeployableTarget<ERC20VariableIncentivePayload>}
89
+ */
90
+ export class ERC20VariableIncentive extends DeployableTarget<
91
+ ERC20VariableIncentivePayload,
92
+ typeof erc20VariableIncentiveAbi
93
+ > {
94
+ public override readonly abi = erc20VariableIncentiveAbi;
95
+ /**
96
+ * @inheritdoc
97
+ *
98
+ * @public
99
+ * @static
100
+ * @type {Record<number, Address>}
101
+ */
102
+ public static override bases: Record<number, Address> = {
103
+ ...(ERC20VariableIncentiveBases as Record<number, Address>),
104
+ };
105
+ /**
106
+ * @inheritdoc
107
+ *
108
+ * @public
109
+ * @static
110
+ * @type {RegistryType}
111
+ */
112
+ public static override registryType: RegistryType = RegistryType.INCENTIVE;
113
+
114
+ /**
115
+ * The owner of the incentive
116
+ *
117
+ * @public
118
+ * @async
119
+ * @param {?ReadParams} [params]
120
+ * @returns {Promise<Address>}
121
+ */
122
+ public async owner(
123
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'owner'>,
124
+ ) {
125
+ return await readErc20VariableIncentiveOwner(this._config, {
126
+ address: this.assertValidAddress(),
127
+ args: [],
128
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
129
+ ...(params as any),
130
+ });
131
+ }
132
+
133
+ /**
134
+ * The total amount of rewards claimed
135
+ *
136
+ * @public
137
+ * @async
138
+ * @param {?ReadParams} [params]
139
+ * @returns {Promise<bigint>}
140
+ */
141
+ public async totalClaimed(
142
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'totalClaimed'>,
143
+ ) {
144
+ return await readErc20VariableIncentiveTotalClaimed(this._config, {
145
+ address: this.assertValidAddress(),
146
+ args: [],
147
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
148
+ ...(params as any),
149
+ });
150
+ }
151
+
152
+ /**
153
+ * The current reward
154
+ *
155
+ * @public
156
+ * @async
157
+ * @param {?ReadParams} [params]
158
+ * @returns {Promise<bigint>} - The current reward
159
+ */
160
+ public async currentReward(
161
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'currentReward'>,
162
+ ) {
163
+ return await readErc20VariableIncentiveCurrentReward(this._config, {
164
+ address: this.assertValidAddress(),
165
+ args: [],
166
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
167
+ ...(params as any),
168
+ });
169
+ }
170
+
171
+ /**
172
+ * The number of claims that have been made
173
+ *
174
+ * @public
175
+ * @async
176
+ * @param {?ReadParams} [params]
177
+ * @returns {Promise<bigint>}
178
+ */
179
+ public async claims(
180
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'claims'>,
181
+ ) {
182
+ return await readErc20VariableIncentiveClaims(this._config, {
183
+ address: this.assertValidAddress(),
184
+ args: [],
185
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
186
+ ...(params as any),
187
+ });
188
+ }
189
+
190
+ /**
191
+ * A mapping of address to claim status
192
+ *
193
+ * @public
194
+ * @async
195
+ * @param {Address} address
196
+ * @param {?ReadParams} [params]
197
+ * @returns {Promise<boolean>}
198
+ */
199
+ public async claimed(
200
+ address: Address,
201
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'claimed'>,
202
+ ) {
203
+ return await readErc20VariableIncentiveClaimed(this._config, {
204
+ address: this.assertValidAddress(),
205
+ args: [address],
206
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
207
+ ...(params as any),
208
+ });
209
+ }
210
+
211
+ /**
212
+ * The address of the ERC20-like token
213
+ *
214
+ * @public
215
+ * @async
216
+ * @param {?ReadParams} [params]
217
+ * @returns {Promise<Address>}
218
+ */
219
+ public async asset(
220
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'asset'>,
221
+ ) {
222
+ return await readErc20VariableIncentiveAsset(this._config, {
223
+ address: this.assertValidAddress(),
224
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
225
+ ...(params as any),
226
+ });
227
+ }
228
+
229
+ /**
230
+ * The reward amount issued for each claim
231
+ *
232
+ * @public
233
+ * @async
234
+ * @param {?ReadParams} [params]
235
+ * @returns {Promise<bigint>}
236
+ */
237
+ public async reward(
238
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'reward'>,
239
+ ) {
240
+ return await readErc20VariableIncentiveReward(this._config, {
241
+ address: this.assertValidAddress(),
242
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
243
+ ...(params as any),
244
+ });
245
+ }
246
+
247
+ /**
248
+ * The limit (max claims, or max entries for raffles)
249
+ *
250
+ * @public
251
+ * @async
252
+ * @param {?ReadParams} [params]
253
+ * @returns {Promise<bigint>}
254
+ */
255
+ public async limit(
256
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'limit'>,
257
+ ) {
258
+ return await readErc20VariableIncentiveLimit(this._config, {
259
+ address: this.assertValidAddress(),
260
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
261
+ ...(params as any),
262
+ });
263
+ }
264
+
265
+ /**
266
+ * Claim the incentive
267
+ *
268
+ * @public
269
+ * @async
270
+ * @param {ClaimPayload} payload
271
+ * @param {?WriteParams} [params]
272
+ * @returns {Promise<boolean>} - Returns true if successfully claimed
273
+ */
274
+ protected async claim(
275
+ payload: ClaimPayload,
276
+ params?: WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>,
277
+ ) {
278
+ return await this.awaitResult(this.claimRaw(payload, params));
279
+ }
280
+
281
+ /**
282
+ * Claim the incentive
283
+ *
284
+ * @public
285
+ * @async
286
+ * @param {ClaimPayload} payload
287
+ * @param {?WriteParams} [params]
288
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - Returns true if successfully claimed
289
+ */
290
+ protected async claimRaw(
291
+ payload: ClaimPayload,
292
+ params?: WriteParams<typeof erc20VariableIncentiveAbi, 'claim'>,
293
+ ) {
294
+ const { request, result } = await simulateErc20VariableIncentiveClaim(
295
+ this._config,
296
+ {
297
+ address: this.assertValidAddress(),
298
+ args: [prepareClaimPayload(payload)],
299
+ ...this.optionallyAttachAccount(),
300
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
301
+ ...(params as any),
302
+ },
303
+ );
304
+ const hash = await writeErc20VariableIncentiveClaim(this._config, request);
305
+ return { hash, result };
306
+ }
307
+
308
+ /**
309
+ * Clawback assets from the incentive
310
+ *
311
+ * @public
312
+ * @async
313
+ * @param {ClaimPayload} payload
314
+ * @param {?WriteParams} [params]
315
+ * @returns {Promise<boolean>} - True if the assets were successfully clawbacked
316
+ */
317
+ public async clawback(
318
+ payload: ClaimPayload,
319
+ params?: WriteParams<typeof erc20VariableIncentiveAbi, 'clawback'>,
320
+ ) {
321
+ return await this.awaitResult(this.clawbackRaw(payload, params));
322
+ }
323
+
324
+ /**
325
+ * Clawback assets from the incentive
326
+ *
327
+ * @public
328
+ * @async
329
+ * @param {ClaimPayload} payload
330
+ * @param {?WriteParams} [params]
331
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the assets were successfully clawbacked
332
+ */
333
+ public async clawbackRaw(
334
+ payload: ClaimPayload,
335
+ params?: WriteParams<typeof erc20VariableIncentiveAbi, 'clawback'>,
336
+ ) {
337
+ const { request, result } = await simulateErc20VariableIncentiveClawback(
338
+ this._config,
339
+ {
340
+ address: this.assertValidAddress(),
341
+ args: [prepareClaimPayload(payload)],
342
+ ...this.optionallyAttachAccount(),
343
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
344
+ ...(params as any),
345
+ },
346
+ );
347
+ const hash = await writeErc20VariableIncentiveClawback(
348
+ this._config,
349
+ request,
350
+ );
351
+ return { hash, result };
352
+ }
353
+
354
+ /**
355
+ * 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.
356
+ *
357
+ * @public
358
+ * @async
359
+ * @param {ClaimPayload} payload
360
+ * @param {?ReadParams} [params]
361
+ * @returns {Promise<boolean>} = True if the incentive is claimable based on the data payload
362
+ */
363
+ public async isClaimable(
364
+ payload: ClaimPayload,
365
+ params?: ReadParams<typeof erc20VariableIncentiveAbi, 'isClaimable'>,
366
+ ) {
367
+ return await readErc20VariableIncentiveIsClaimable(this._config, {
368
+ address: this.assertValidAddress(),
369
+ args: [prepareClaimPayload(payload)],
370
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
371
+ ...(params as any),
372
+ });
373
+ }
374
+
375
+ /**
376
+ * @inheritdoc
377
+ *
378
+ * @public
379
+ * @param {?ERC20VariableIncentivePayload} [_payload]
380
+ * @param {?DeployableOptions} [_options]
381
+ * @returns {GenericDeployableParams}
382
+ */
383
+ public override buildParameters(
384
+ _payload?: ERC20VariableIncentivePayload,
385
+ _options?: DeployableOptions,
386
+ ): GenericDeployableParams {
387
+ const [payload, options] = this.validateDeploymentConfig(
388
+ _payload,
389
+ _options,
390
+ );
391
+ return {
392
+ abi: erc20VariableIncentiveAbi,
393
+ bytecode: bytecode as Hex,
394
+ args: [prepareERC20VariableIncentivePayload(payload)],
395
+ ...this.optionallyAttachAccount(options.account),
396
+ };
397
+ }
398
+ }
399
+
400
+ /**
401
+ * Given a {@link ERC20VariableIncentivePayload}, properly encode a ` ERC20VariableIncentive.InitPayload` for use with {@link ERC20VariableIncentive} initialization.
402
+ *
403
+ * @param {ERC20VariableIncentivePayload} param0
404
+ * @param {Address} param0.asset - The address of the incentivized asset.
405
+ * @param {bigint} param0.reward - The amount of the asset to distribute.
406
+ * @param {bigint} param0.limit - How many times can this incentive be claimed.
407
+ * @returns {Hex}
408
+ */
409
+ export function prepareERC20VariableIncentivePayload({
410
+ asset,
411
+ reward,
412
+ limit,
413
+ }: ERC20VariableIncentivePayload) {
414
+ return encodeAbiParameters(
415
+ [
416
+ { type: 'address', name: 'asset' },
417
+ { type: 'uint256', name: 'reward' },
418
+ { type: 'uint256', name: 'limit' },
419
+ ],
420
+ [asset, reward, limit],
421
+ );
422
+ }
@@ -0,0 +1,92 @@
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
+ });
53
+ await incentive.deploy();
54
+ expect(
55
+ await incentiveFromAddress(
56
+ defaultOptions,
57
+ incentive.assertValidAddress(),
58
+ ),
59
+ ).toBeInstanceOf(CGDAIncentive);
60
+ });
61
+
62
+ test('can automatically instantiate ERC20Incentive given an address', async () => {
63
+ const incentive = new ERC20Incentive(defaultOptions, {
64
+ asset: zeroAddress,
65
+ strategy: StrategyType.POOL,
66
+ reward: 1n,
67
+ limit: 10n,
68
+ });
69
+ await incentive.deploy();
70
+ expect(
71
+ await incentiveFromAddress(
72
+ defaultOptions,
73
+ incentive.assertValidAddress(),
74
+ ),
75
+ ).toBeInstanceOf(ERC20Incentive);
76
+ });
77
+
78
+ test('can automatically instantiate ERC20VariableIncentive given an address', async () => {
79
+ const incentive = new ERC20VariableIncentive(defaultOptions, {
80
+ asset: zeroAddress,
81
+ reward: 1n,
82
+ limit: 10n,
83
+ });
84
+ await incentive.deploy();
85
+ expect(
86
+ await incentiveFromAddress(
87
+ defaultOptions,
88
+ incentive.assertValidAddress(),
89
+ ),
90
+ ).toBeInstanceOf(ERC20VariableIncentive);
91
+ });
92
+ });
@@ -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; "0x0a466e6f": typeof AllowListIncentive; "0xa39e44d9": typeof CGDAIncentive; "0x6060409d": 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
+ }