@boostxyz/sdk 7.0.0-canary.0 → 7.0.0-canary.2

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 (118) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.js +7 -7
  3. package/dist/Actions/EventAction.cjs +1 -1
  4. package/dist/Actions/EventAction.js +56 -56
  5. package/dist/AllowLists/AllowList.cjs +1 -1
  6. package/dist/AllowLists/AllowList.js +5 -5
  7. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  8. package/dist/AllowLists/SimpleAllowList.js +17 -17
  9. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  10. package/dist/AllowLists/SimpleDenyList.js +3 -3
  11. package/dist/Auth/PassthroughAuth.cjs +1 -1
  12. package/dist/Auth/PassthroughAuth.js +1 -1
  13. package/dist/BoostCore.cjs +2 -2
  14. package/dist/BoostCore.js +141 -141
  15. package/dist/BoostRegistry.cjs +1 -1
  16. package/dist/BoostRegistry.js +11 -11
  17. package/dist/{Budget-Bvi5Qjqp.js → Budget-D2aQ8V__.js} +54 -54
  18. package/dist/{Budget-Bvi5Qjqp.js.map → Budget-D2aQ8V__.js.map} +1 -1
  19. package/dist/{Budget-B_kgJGDu.cjs → Budget-lcBEy-fx.cjs} +2 -2
  20. package/dist/{Budget-B_kgJGDu.cjs.map → Budget-lcBEy-fx.cjs.map} +1 -1
  21. package/dist/Budgets/Budget.cjs +1 -1
  22. package/dist/Budgets/Budget.js +3 -3
  23. package/dist/Budgets/ManagedBudget.cjs +1 -1
  24. package/dist/Budgets/ManagedBudget.js +29 -29
  25. package/dist/Deployable/DeployableTarget.cjs +1 -1
  26. package/dist/Deployable/DeployableTarget.js +1 -1
  27. package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
  28. package/dist/Deployable/DeployableTargetWithRBAC.js +16 -16
  29. package/dist/Incentive-DJZmgtA9.js +449 -0
  30. package/dist/{Incentive-CLKutfnD.js.map → Incentive-DJZmgtA9.js.map} +1 -1
  31. package/dist/{Incentive-CLSVNxDz.cjs → Incentive-DfVj0SE5.cjs} +2 -2
  32. package/dist/{Incentive-CLSVNxDz.cjs.map → Incentive-DfVj0SE5.cjs.map} +1 -1
  33. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  34. package/dist/Incentives/AllowListIncentive.js +15 -15
  35. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  36. package/dist/Incentives/CGDAIncentive.js +9 -9
  37. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  38. package/dist/Incentives/ERC20Incentive.js +15 -15
  39. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.cjs +2 -0
  40. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.cjs.map +1 -0
  41. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.d.ts +1093 -0
  42. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.d.ts.map +1 -0
  43. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.js +604 -0
  44. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.js.map +1 -0
  45. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.cjs +1 -1
  46. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.cjs.map +1 -1
  47. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.d.ts +4 -4
  48. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.d.ts.map +1 -1
  49. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.js +33 -33
  50. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.js.map +1 -1
  51. package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs +2 -0
  52. package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs.map +1 -0
  53. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +884 -0
  54. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  55. package/dist/Incentives/ERC20VariableCriteriaIncentive.js +239 -0
  56. package/dist/Incentives/ERC20VariableCriteriaIncentive.js.map +1 -0
  57. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.cjs +1 -1
  58. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.cjs.map +1 -1
  59. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.d.ts +7 -7
  60. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.d.ts.map +1 -1
  61. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.js +11 -11
  62. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.js.map +1 -1
  63. package/dist/Incentives/ERC20VariableIncentive.cjs +1 -1
  64. package/dist/Incentives/ERC20VariableIncentive.js +12 -12
  65. package/dist/Incentives/Incentive.cjs +1 -1
  66. package/dist/Incentives/Incentive.d.ts +6 -4
  67. package/dist/Incentives/Incentive.d.ts.map +1 -1
  68. package/dist/Incentives/Incentive.js +23 -19
  69. package/dist/Incentives/Incentive.js.map +1 -1
  70. package/dist/Incentives/PointsIncentive.cjs +1 -1
  71. package/dist/Incentives/PointsIncentive.js +8 -8
  72. package/dist/{SimpleDenyList-C1C_BHkY.js → SimpleDenyList-C-T2RCgi.js} +14 -14
  73. package/dist/{SimpleDenyList-C1C_BHkY.js.map → SimpleDenyList-C-T2RCgi.js.map} +1 -1
  74. package/dist/{SimpleDenyList-CWthbyj7.cjs → SimpleDenyList-Dxle-6uU.cjs} +2 -2
  75. package/dist/{SimpleDenyList-CWthbyj7.cjs.map → SimpleDenyList-Dxle-6uU.cjs.map} +1 -1
  76. package/dist/Validators/LimitedSignerValidator.cjs +1 -1
  77. package/dist/Validators/LimitedSignerValidator.js +17 -17
  78. package/dist/Validators/SignerValidator.cjs +1 -1
  79. package/dist/Validators/SignerValidator.js +6 -6
  80. package/dist/Validators/Validator.cjs +1 -1
  81. package/dist/Validators/Validator.js +2 -2
  82. package/dist/componentInterfaces-C5ig8mCK.cjs +2 -0
  83. package/dist/componentInterfaces-C5ig8mCK.cjs.map +1 -0
  84. package/dist/componentInterfaces-Ddus5rIA.js +23 -0
  85. package/dist/componentInterfaces-Ddus5rIA.js.map +1 -0
  86. package/dist/{deployments-De8_J7SS.js → deployments-C-e2CGJJ.js} +47 -35
  87. package/dist/{deployments-De8_J7SS.js.map → deployments-C-e2CGJJ.js.map} +1 -1
  88. package/dist/deployments-YkNK95HE.cjs +2 -0
  89. package/dist/deployments-YkNK95HE.cjs.map +1 -0
  90. package/dist/deployments.json +12 -12
  91. package/dist/{generated-BJfQ-EBO.js → generated-CINzoGbl.js} +1890 -765
  92. package/dist/generated-CINzoGbl.js.map +1 -0
  93. package/dist/generated-C_JEoLDO.cjs +3 -0
  94. package/dist/generated-C_JEoLDO.cjs.map +1 -0
  95. package/dist/index.cjs +1 -1
  96. package/dist/index.d.ts +2 -0
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +150 -141
  99. package/dist/index.js.map +1 -1
  100. package/package.json +13 -1
  101. package/src/Incentives/ERC20PeggedVariableCriteriaIncentive.ts +852 -0
  102. package/src/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.test.ts +6 -6
  103. package/src/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.ts +5 -5
  104. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +437 -0
  105. package/src/Incentives/ERC20VariableCriteriaIncentiveV2.test.ts +6 -6
  106. package/src/Incentives/ERC20VariableCriteriaIncentiveV2.ts +7 -7
  107. package/src/Incentives/Incentive.ts +11 -0
  108. package/src/index.ts +2 -0
  109. package/dist/Incentive-CLKutfnD.js +0 -445
  110. package/dist/componentInterfaces-BVHB4Fjw.js +0 -21
  111. package/dist/componentInterfaces-BVHB4Fjw.js.map +0 -1
  112. package/dist/componentInterfaces-BqhL-meV.cjs +0 -2
  113. package/dist/componentInterfaces-BqhL-meV.cjs.map +0 -1
  114. package/dist/deployments-D9QxJGrC.cjs +0 -2
  115. package/dist/deployments-D9QxJGrC.cjs.map +0 -1
  116. package/dist/generated-BJfQ-EBO.js.map +0 -1
  117. package/dist/generated-mJJNq-xb.cjs +0 -3
  118. package/dist/generated-mJJNq-xb.cjs.map +0 -1
@@ -29,8 +29,8 @@ import {
29
29
  type ERC20PeggedVariableCriteriaIncentiveV2,
30
30
  } from "./ERC20PeggedVariableCriteriaIncentiveV2";
31
31
  import {
32
- type IncentiveCriteria,
33
- gasRebateIncentiveCriteria,
32
+ type IncentiveCriteriaV2,
33
+ gasRebateIncentiveCriteriaV2,
34
34
  } from "./ERC20VariableCriteriaIncentiveV2";
35
35
  import { allKnownSignatures } from "@boostxyz/test/allKnownSignatures";
36
36
  import { readMockErc20BalanceOf } from "@boostxyz/evm";
@@ -43,7 +43,7 @@ import { readMockErc20BalanceOf } from "@boostxyz/evm";
43
43
  */
44
44
  export function basicErc721TransferScalarCriteria(
45
45
  erc721: MockERC721,
46
- ): IncentiveCriteria {
46
+ ): IncentiveCriteriaV2 {
47
47
  return {
48
48
  criteriaType: SignatureType.FUNC,
49
49
  signature: funcSelectors["transferFrom(address,address,uint256)"] as Hex, // Function selector for mint
@@ -61,7 +61,7 @@ export function basicErc721TransferScalarCriteria(
61
61
  */
62
62
  export function basicErc721MintScalarCriteria(
63
63
  erc721: MockERC721,
64
- ): IncentiveCriteria {
64
+ ): IncentiveCriteriaV2 {
65
65
  return {
66
66
  criteriaType: SignatureType.EVENT,
67
67
  signature: eventSelectors[
@@ -222,9 +222,9 @@ describe("ERC20PeggedVariableCriteriaIncentive", () => {
222
222
  expect(scalar).toBe(1n);
223
223
  });
224
224
 
225
- test("gasRebateIncentiveCriteria generates correct incentive criteria", async () => {
225
+ test("gasRebateIncentiveCriteriaV2 generates correct incentive criteria", async () => {
226
226
  // Ensure that the gasRebateIncentiveCriteria returns the correct structure
227
- const gasRebateCriteria = gasRebateIncentiveCriteria();
227
+ const gasRebateCriteria = gasRebateIncentiveCriteriaV2();
228
228
 
229
229
  erc20PeggedVariableCriteriaIncentive = fixtures.core.ERC20PeggedVariableCriteriaIncentiveV2({
230
230
  asset: budgets.erc20.assertValidAddress(),
@@ -56,8 +56,8 @@ import {
56
56
  type WriteParams,
57
57
  } from '../utils';
58
58
  import type {
59
- GetIncentiveScalarParams,
60
- IncentiveCriteria,
59
+ GetIncentiveScalarV2Params,
60
+ IncentiveCriteriaV2,
61
61
  } from './ERC20VariableCriteriaIncentiveV2';
62
62
 
63
63
  export { erc20PeggedVariableCriteriaIncentiveV2Abi };
@@ -112,7 +112,7 @@ export interface ERC20PeggedVariableCriteriaIncentiveV2Payload {
112
112
  *
113
113
  * @type {IncentiveCriteria}
114
114
  */
115
- criteria: IncentiveCriteria;
115
+ criteria: IncentiveCriteriaV2;
116
116
  }
117
117
 
118
118
  /**
@@ -231,7 +231,7 @@ export class ERC20PeggedVariableCriteriaIncentiveV2 extends DeployableTarget<
231
231
  * @throws {InvalidCriteriaTypeError | NoMatchingLogsError | DecodedArgsError}
232
232
  */
233
233
  public async getIncentiveScalar(
234
- { chainId, hash, knownSignatures }: GetIncentiveScalarParams,
234
+ { chainId, hash, knownSignatures }: GetIncentiveScalarV2Params,
235
235
  params?: ReadParams,
236
236
  ): Promise<bigint> {
237
237
  const criteria = await this.getIncentiveCriteria(params);
@@ -616,7 +616,7 @@ export class ERC20PeggedVariableCriteriaIncentiveV2 extends DeployableTarget<
616
616
  */
617
617
  public async getIncentiveCriteria(
618
618
  params?: ReadParams,
619
- ): Promise<IncentiveCriteria> {
619
+ ): Promise<IncentiveCriteriaV2> {
620
620
  try {
621
621
  const criteria =
622
622
  await readErc20PeggedVariableCriteriaIncentiveV2GetIncentiveCriteria(
@@ -0,0 +1,437 @@
1
+ import {
2
+ erc20VariableCriteriaIncentiveAbi,
3
+ readErc20VariableCriteriaIncentiveGetIncentiveCriteria,
4
+ readErc20VariableCriteriaIncentiveGetMaxReward,
5
+ } from '@boostxyz/evm';
6
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20VariableCriteriaIncentive.sol/ERC20VariableCriteriaIncentive.json';
7
+ import { getTransaction, getTransactionReceipt } from '@wagmi/core';
8
+ import {
9
+ type AbiEvent,
10
+ type AbiFunction,
11
+ type Address,
12
+ type Hex,
13
+ decodeAbiParameters,
14
+ decodeFunctionData,
15
+ encodeAbiParameters,
16
+ parseEther,
17
+ parseEventLogs,
18
+ zeroAddress,
19
+ zeroHash,
20
+ } from 'viem';
21
+ import { ERC20VariableCriteriaIncentive as ERC20VariableCriteriaIncentiveBases } from '../../dist/deployments.json';
22
+ import { SignatureType } from '../Actions/EventAction';
23
+ import type {
24
+ DeployableOptions,
25
+ GenericDeployableParams,
26
+ } from '../Deployable/Deployable';
27
+ import {
28
+ DecodedArgsError,
29
+ IncentiveCriteriaNotFoundError,
30
+ InvalidCriteriaTypeError,
31
+ NoMatchingLogsError,
32
+ } from '../errors';
33
+ import { CheatCodes, type ReadParams } from '../utils';
34
+ import { ERC20VariableIncentive } from './ERC20VariableIncentive';
35
+
36
+ export { erc20VariableCriteriaIncentiveAbi };
37
+
38
+ export interface ERC20VariableCriteriaIncentivePayload {
39
+ /**
40
+ * The address of the incentivized asset.
41
+ *
42
+ * @type {Address}
43
+ */
44
+ asset: Address;
45
+ /**
46
+ * The amount of the asset to distribute as reward.
47
+ *
48
+ * @type {bigint}
49
+ */
50
+ reward: bigint;
51
+ /**
52
+ * The total spending limit of the asset that will be distributed.
53
+ *
54
+ * @type {bigint}
55
+ */
56
+ limit: bigint;
57
+ /**
58
+ * The total amount claimable in a single claim or maximum per-action reward.
59
+ *
60
+ * @type {bigint}
61
+ * @optional
62
+ */
63
+ maxReward?: bigint;
64
+ /**
65
+ * The criteria for the incentive that determines how the reward is distributed.
66
+ *
67
+ * @type {IncentiveCriteria}
68
+ */
69
+ criteria: IncentiveCriteria;
70
+ }
71
+
72
+ export interface IncentiveCriteria {
73
+ /**
74
+ * The type of criteria used, either function signature or event signature.
75
+ *
76
+ * @type {SignatureType}
77
+ */
78
+ criteriaType: SignatureType;
79
+ /**
80
+ * The function or event signature used for criteria matching.
81
+ *
82
+ * @type {Hex}
83
+ */
84
+ signature: Hex;
85
+ /**
86
+ * The index of the field from where the scalar value is extracted.
87
+ *
88
+ * @type {number}
89
+ */
90
+ fieldIndex: number;
91
+ /**
92
+ * The address of the contract where the event/function is called/emitted.
93
+ *
94
+ * @type {Address}
95
+ */
96
+ targetContract: Address;
97
+ }
98
+
99
+ export interface ReadIncentiveCriteriaParams extends ReadParams {}
100
+
101
+ export interface GetIncentiveScalarParams {
102
+ chainId: number;
103
+ hash: Hex;
104
+ knownSignatures: Record<Hex, AbiFunction | AbiEvent>;
105
+ }
106
+
107
+ /**
108
+ * Extended ERC20 Variable Criteria Incentive class that fetches incentive criteria and scalar
109
+ *
110
+ * @export
111
+ * @deprecated Please use only v2 implementations
112
+ * @class ERC20VariableCriteriaIncentive
113
+ * @typedef {ERC20VariableCriteriaIncentive}
114
+ * @extends {ERC20VariableIncentive<ERC20VariableCriteriaIncentivePayload, typeof erc20VariableCriteriaIncentiveAbi>}
115
+ */
116
+ export class ERC20VariableCriteriaIncentive extends ERC20VariableIncentive<
117
+ ERC20VariableCriteriaIncentivePayload,
118
+ typeof erc20VariableCriteriaIncentiveAbi,
119
+ Promise<bigint>
120
+ > {
121
+ //@ts-expect-error instantiated correctly
122
+ public override readonly abi = erc20VariableCriteriaIncentiveAbi;
123
+ /**
124
+ * @inheritdoc
125
+ *
126
+ * @public
127
+ * @static
128
+ * @type {Record<number, Address>}
129
+ */
130
+ public static override bases: Record<number, Address> = {
131
+ 31337: import.meta.env.VITE_ERC20_VARIABLE_CRITERIA_INCENTIVE_BASE,
132
+ ...(ERC20VariableCriteriaIncentiveBases as Record<number, Address>),
133
+ };
134
+
135
+ /**
136
+ *Functions from the ERC20VariableIncentive contract
137
+ */
138
+
139
+ /**
140
+ * Fetches the IncentiveCriteria struct from the contract
141
+ *
142
+ * @param {?ReadParams} [params]
143
+ * @returns {Promise<IncentiveCriteria>} Incentive criteria structure
144
+ * @throws {IncentiveCriteriaNotFoundError}
145
+ */
146
+ public async getIncentiveCriteria(
147
+ params?: ReadParams,
148
+ ): Promise<IncentiveCriteria> {
149
+ try {
150
+ const criteria =
151
+ await readErc20VariableCriteriaIncentiveGetIncentiveCriteria(
152
+ this._config,
153
+ {
154
+ ...params,
155
+ address: this.assertValidAddress(),
156
+ },
157
+ );
158
+
159
+ return criteria;
160
+ } catch (e) {
161
+ throw new IncentiveCriteriaNotFoundError(e as Error);
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Decodes claim data for the ERC20VariableCriteriaIncentive, returning the claim amount.
167
+ * Useful when deriving amount claimed from logs.
168
+ *
169
+ * @public
170
+ * @param {Hex} claimData
171
+ * @returns {Promise<bigint>} Returns the reward amount from a claim data payload
172
+ */
173
+ public override async decodeClaimData(claimData: Hex) {
174
+ const boostClaimData = decodeAbiParameters(
175
+ [
176
+ {
177
+ type: 'tuple',
178
+ name: 'BoostClaimData',
179
+ components: [
180
+ { type: 'bytes', name: 'validatorData' },
181
+ { type: 'bytes', name: 'incentiveData' },
182
+ ],
183
+ },
184
+ ],
185
+ claimData,
186
+ );
187
+ const signedAmount = decodeAbiParameters(
188
+ [{ type: 'uint256' }],
189
+ boostClaimData[0].incentiveData,
190
+ )[0];
191
+ let claimAmount = signedAmount;
192
+ const [reward, maxReward] = await Promise.all([
193
+ this.reward(),
194
+ this.getMaxReward(),
195
+ ]);
196
+
197
+ if (reward === 0n) {
198
+ return claimAmount;
199
+ } else {
200
+ claimAmount = (reward * signedAmount) / parseEther('1');
201
+ }
202
+
203
+ if (maxReward !== 0n && claimAmount > maxReward) {
204
+ claimAmount = maxReward;
205
+ }
206
+
207
+ return claimAmount;
208
+ }
209
+
210
+ /**
211
+ * Fetches the IncentiveCriteria struct from the contract
212
+ *
213
+ * @param {?ReadParams} [params]
214
+ * @returns {Promise<IncentiveCriteria>} Incentive criteria structure
215
+ * @throws {IncentiveCriteriaNotFoundError}
216
+ */
217
+ public async getMaxReward(params?: ReadParams): Promise<bigint> {
218
+ const maxReward = await readErc20VariableCriteriaIncentiveGetMaxReward(
219
+ this._config,
220
+ {
221
+ ...params,
222
+ address: this.assertValidAddress(),
223
+ },
224
+ );
225
+
226
+ return maxReward;
227
+ }
228
+
229
+ /**
230
+ * Fetches the incentive scalar from a transaction hash
231
+ *
232
+ * @param {GetIncentiveScalarParams} params
233
+ * @param {?ReadParams} [params]
234
+ * @returns {Promise<bigint>}
235
+ * @throws {InvalidCriteriaTypeError | NoMatchingLogsError | DecodedArgsError}
236
+ */
237
+ public async getIncentiveScalar(
238
+ { chainId, hash, knownSignatures }: GetIncentiveScalarParams,
239
+ params?: ReadParams,
240
+ ): Promise<bigint> {
241
+ const criteria = await this.getIncentiveCriteria(params);
242
+ if (criteria.criteriaType === SignatureType.EVENT) {
243
+ const transactionReceipt = await getTransactionReceipt(this._config, {
244
+ chainId,
245
+ hash,
246
+ });
247
+ if (criteria.fieldIndex === CheatCodes.GAS_REBATE_INCENTIVE) {
248
+ const totalCost =
249
+ transactionReceipt.gasUsed * transactionReceipt.effectiveGasPrice + // Normal gas cost
250
+ (transactionReceipt.blobGasUsed ?? 0n) *
251
+ (transactionReceipt.blobGasPrice ?? 0n); // Blob gas cost - account for potential undefined values
252
+ return totalCost;
253
+ }
254
+ const logs = transactionReceipt.logs;
255
+
256
+ if (logs.length === 0) {
257
+ throw new NoMatchingLogsError(
258
+ `No logs found for event signature ${criteria.signature}`,
259
+ );
260
+ }
261
+
262
+ // Decode the event log
263
+ try {
264
+ // Decode function data
265
+ const eventAbi = knownSignatures[criteria.signature] as AbiEvent;
266
+ const decodedEvents = parseEventLogs({
267
+ abi: [eventAbi],
268
+ logs,
269
+ });
270
+ if (decodedEvents == undefined || decodedEvents.length === 0) {
271
+ throw new NoMatchingLogsError(
272
+ `No logs found for event signature ${criteria.signature}`,
273
+ );
274
+ }
275
+ const scalarValue = (decodedEvents[0]?.args as string[])[
276
+ criteria.fieldIndex
277
+ ];
278
+
279
+ if (scalarValue === undefined) {
280
+ throw new DecodedArgsError(
281
+ `Decoded argument at index ${criteria.fieldIndex} is undefined`,
282
+ );
283
+ }
284
+ return BigInt(scalarValue);
285
+ } catch (e) {
286
+ throw new DecodedArgsError(
287
+ `Failed to decode event log for signature ${criteria.signature}: ${(e as Error).message}`,
288
+ );
289
+ }
290
+ } else if (criteria.criteriaType === SignatureType.FUNC) {
291
+ // Fetch the transaction data
292
+ const transaction = await getTransaction(this._config, {
293
+ chainId,
294
+ hash,
295
+ });
296
+ try {
297
+ // Decode function data
298
+ const func = knownSignatures[criteria.signature] as AbiFunction;
299
+ const decodedFunction = decodeFunctionData({
300
+ abi: [func],
301
+ data: transaction.input,
302
+ });
303
+ const scalarValue = decodedFunction.args[criteria.fieldIndex] as string;
304
+ if (scalarValue === undefined || scalarValue === null) {
305
+ throw new DecodedArgsError(
306
+ `Decoded argument at index ${criteria.fieldIndex} is undefined`,
307
+ );
308
+ }
309
+ return BigInt(scalarValue);
310
+ } catch (e) {
311
+ throw new DecodedArgsError(
312
+ `Failed to decode function data for signature ${criteria.signature}: ${(e as Error).message}`,
313
+ );
314
+ }
315
+ } else {
316
+ throw new InvalidCriteriaTypeError(
317
+ `Invalid criteria type ${criteria.criteriaType}`,
318
+ );
319
+ }
320
+ }
321
+
322
+ /**
323
+ * @inheritdoc
324
+ *
325
+ * @public
326
+ * @param {?ERC20VariableCriteriaIncentivePayload} [_payload]
327
+ * @param {?DeployableOptions} [_options]
328
+ * @returns {GenericDeployableParams}
329
+ */
330
+ public override buildParameters(
331
+ _payload?: ERC20VariableCriteriaIncentivePayload,
332
+ _options?: DeployableOptions,
333
+ ): GenericDeployableParams {
334
+ const [payload, options] = this.validateDeploymentConfig(
335
+ _payload,
336
+ _options,
337
+ );
338
+ return {
339
+ abi: erc20VariableCriteriaIncentiveAbi,
340
+ bytecode: bytecode as Hex,
341
+ args: [prepareERC20VariableCriteriaIncentivePayload(payload)],
342
+ ...this.optionallyAttachAccount(options.account),
343
+ };
344
+ }
345
+ }
346
+
347
+ /**
348
+ * Creates an IncentiveCriteria object representing a gas rebate incentive.
349
+ * This object defines a variable incentive criteria where the criteria will be the gas spent.
350
+ *
351
+ * The criteria uses a signatureType of EVENT, with a special `fieldIndex` of 255 (using CheatCodes enum), which indicates
352
+ * that the entire gas cost of the transaction will be used as the scalar value. If you don't want to
353
+ * rebate the entire gas cost, you can use a reward value on the incentive..
354
+ *
355
+ * - `criteriaType`: EVENT, indicating it's based on event logs.
356
+ * - `signature`: A zeroed signature (0x0000...0000), matching any event.
357
+ * - `fieldIndex`: 255, indicating the use of transaction gas cost using CheatCodes enum.
358
+ * - `targetContract`: A zeroed address (0x0000...0000), applicable to any contract.
359
+ *
360
+ * @returns {IncentiveCriteria} Returns an IncentiveCriteria object for a gas rebate.
361
+ *
362
+ * @example
363
+ * const incentive = gasRebateIncentiveCriteria();
364
+ * const actionPayload = {
365
+ * criteria: incentive,
366
+ * asset: "0xAssetAddress",
367
+ * reward: 0, // Set to zero to rebate the entire gas cost
368
+ * limit: BigInt(1000) // This is the total spend limit for the incentive
369
+ * };
370
+ * deployIncentive(actionPayload);
371
+ */
372
+ export function gasRebateIncentiveCriteria(): IncentiveCriteria {
373
+ return {
374
+ criteriaType: SignatureType.EVENT,
375
+ signature: zeroHash,
376
+ fieldIndex: CheatCodes.GAS_REBATE_INCENTIVE,
377
+ targetContract: zeroAddress,
378
+ };
379
+ }
380
+
381
+ /**
382
+ *
383
+ *
384
+ * @param {InitPayloadExtended} param0
385
+ * @param {Address} param0.asset - The address of the ERC20 asset to incentivize.
386
+ * @param {bigint} param0.reward - The reward amount to distribute per action.
387
+ * @param {bigint} param0.limit - The total limit of the asset distribution.
388
+ * @param {bigint} param0.maxReward - The maximum value claimable from a single completion.
389
+ * @param {IncentiveCriteria} param0.criteria - The incentive criteria for reward distribution.
390
+ * @returns {Hex}
391
+ */
392
+ export function prepareERC20VariableCriteriaIncentivePayload({
393
+ asset,
394
+ reward,
395
+ limit,
396
+ maxReward = 0n,
397
+ criteria,
398
+ }: ERC20VariableCriteriaIncentivePayload) {
399
+ return encodeAbiParameters(
400
+ [
401
+ {
402
+ type: 'tuple',
403
+ name: 'initPayloadExtended',
404
+ components: [
405
+ { type: 'address', name: 'asset' },
406
+ { type: 'uint256', name: 'reward' },
407
+ { type: 'uint256', name: 'limit' },
408
+ { type: 'uint256', name: 'maxReward' },
409
+ {
410
+ type: 'tuple',
411
+ name: 'criteria',
412
+ components: [
413
+ { type: 'uint8', name: 'criteriaType' },
414
+ { type: 'bytes32', name: 'signature' },
415
+ { type: 'uint8', name: 'fieldIndex' },
416
+ { type: 'address', name: 'targetContract' },
417
+ ],
418
+ },
419
+ ],
420
+ },
421
+ ],
422
+ [
423
+ {
424
+ asset: asset,
425
+ reward: reward,
426
+ limit: limit,
427
+ maxReward: maxReward,
428
+ criteria: {
429
+ criteriaType: criteria.criteriaType,
430
+ signature: criteria.signature,
431
+ fieldIndex: criteria.fieldIndex,
432
+ targetContract: criteria.targetContract,
433
+ },
434
+ },
435
+ ],
436
+ );
437
+ }
@@ -28,8 +28,8 @@ import type { Boost } from "../Boost";
28
28
  import {
29
29
  type ERC20VariableCriteriaIncentiveV2,
30
30
  type ERC20VariableCriteriaIncentiveV2Payload,
31
- type IncentiveCriteria,
32
- gasRebateIncentiveCriteria,
31
+ type IncentiveCriteriaV2,
32
+ gasRebateIncentiveCriteriaV2,
33
33
  } from "./ERC20VariableCriteriaIncentiveV2";
34
34
  import { allKnownSignatures } from "@boostxyz/test/allKnownSignatures";
35
35
 
@@ -41,7 +41,7 @@ import { allKnownSignatures } from "@boostxyz/test/allKnownSignatures";
41
41
  */
42
42
  export function basicErc721TransferScalarCriteria(
43
43
  erc721: MockERC721,
44
- ): IncentiveCriteria {
44
+ ): IncentiveCriteriaV2 {
45
45
  return {
46
46
  criteriaType: SignatureType.FUNC,
47
47
  signature: funcSelectors["transferFrom(address,address,uint256)"] as Hex, // Function selector for mint
@@ -59,7 +59,7 @@ export function basicErc721TransferScalarCriteria(
59
59
  */
60
60
  export function basicErc721MintScalarCriteria(
61
61
  erc721: MockERC721,
62
- ): IncentiveCriteria {
62
+ ): IncentiveCriteriaV2 {
63
63
  return {
64
64
  criteriaType: SignatureType.EVENT,
65
65
  signature: eventSelectors[
@@ -179,9 +179,9 @@ describe("ERC20VariableCriteriaIncentiveV2", () => {
179
179
  expect(scalar).toBe(1n);
180
180
  });
181
181
 
182
- test("gasRebateIncentiveCriteria generates correct incentive criteria", async () => {
182
+ test("gasRebateIncentiveCriteriaV2 generates correct incentive criteria", async () => {
183
183
  // Ensure that the gasRebateIncentiveCriteria returns the correct structure
184
- const gasRebateCriteria = gasRebateIncentiveCriteria();
184
+ const gasRebateCriteria = gasRebateIncentiveCriteriaV2();
185
185
 
186
186
  erc20Incentive = fixtures.core.ERC20VariableCriteriaIncentiveV2({
187
187
  asset: budgets.erc20.assertValidAddress(),
@@ -66,10 +66,10 @@ export interface ERC20VariableCriteriaIncentiveV2Payload {
66
66
  *
67
67
  * @type {IncentiveCriteria}
68
68
  */
69
- criteria: IncentiveCriteria;
69
+ criteria: IncentiveCriteriaV2;
70
70
  }
71
71
 
72
- export interface IncentiveCriteria {
72
+ export interface IncentiveCriteriaV2 {
73
73
  /**
74
74
  * The type of criteria used, either function signature or event signature.
75
75
  *
@@ -104,9 +104,9 @@ export interface IncentiveCriteria {
104
104
  valueType: ValueType;
105
105
  }
106
106
 
107
- export interface ReadIncentiveCriteriaParams extends ReadParams {}
107
+ export interface ReadIncentiveCriteriaV2Params extends ReadParams {}
108
108
 
109
- export interface GetIncentiveScalarParams {
109
+ export interface GetIncentiveScalarV2Params {
110
110
  chainId: number;
111
111
  hash: Hex;
112
112
  knownSignatures: Record<Hex, AbiFunction | AbiEvent>;
@@ -152,7 +152,7 @@ export class ERC20VariableCriteriaIncentiveV2 extends ERC20VariableIncentive<
152
152
  */
153
153
  public async getIncentiveCriteria(
154
154
  params?: ReadParams,
155
- ): Promise<IncentiveCriteria> {
155
+ ): Promise<IncentiveCriteriaV2> {
156
156
  try {
157
157
  const criteria =
158
158
  await readErc20VariableCriteriaIncentiveV2GetIncentiveCriteria(
@@ -242,7 +242,7 @@ export class ERC20VariableCriteriaIncentiveV2 extends ERC20VariableIncentive<
242
242
  * @throws {InvalidCriteriaTypeError | NoMatchingLogsError | DecodedArgsError}
243
243
  */
244
244
  public async getIncentiveScalar(
245
- { chainId, hash, knownSignatures }: GetIncentiveScalarParams,
245
+ { chainId, hash, knownSignatures }: GetIncentiveScalarV2Params,
246
246
  params?: ReadParams,
247
247
  ): Promise<bigint> {
248
248
  const criteria = await this.getIncentiveCriteria(params);
@@ -376,7 +376,7 @@ export class ERC20VariableCriteriaIncentiveV2 extends ERC20VariableIncentive<
376
376
  * };
377
377
  * deployIncentive(actionPayload);
378
378
  */
379
- export function gasRebateIncentiveCriteria(): IncentiveCriteria {
379
+ export function gasRebateIncentiveCriteriaV2(): IncentiveCriteriaV2 {
380
380
  return {
381
381
  criteriaType: SignatureType.EVENT,
382
382
  signature: zeroHash,
@@ -4,7 +4,9 @@ import {
4
4
  ACGDAIncentive,
5
5
  AERC20Incentive,
6
6
  AERC20PeggedIncentive,
7
+ AERC20PeggedVariableCriteriaIncentive,
7
8
  AERC20PeggedVariableCriteriaIncentiveV2,
9
+ AERC20VariableCriteriaIncentive,
8
10
  AERC20VariableCriteriaIncentiveV2,
9
11
  AERC20VariableIncentive,
10
12
  // AERC20VariableCriteriaIncentive
@@ -19,7 +21,9 @@ import { AllowListIncentive } from './AllowListIncentive';
19
21
  import { CGDAIncentive } from './CGDAIncentive';
20
22
  import { ERC20Incentive } from './ERC20Incentive';
21
23
  import { ERC20PeggedIncentive } from './ERC20PeggedIncentive';
24
+ import { ERC20PeggedVariableCriteriaIncentive } from './ERC20PeggedVariableCriteriaIncentive';
22
25
  import { ERC20PeggedVariableCriteriaIncentiveV2 } from './ERC20PeggedVariableCriteriaIncentiveV2';
26
+ import { ERC20VariableCriteriaIncentive } from './ERC20VariableCriteriaIncentive';
23
27
  import { ERC20VariableCriteriaIncentiveV2 } from './ERC20VariableCriteriaIncentiveV2';
24
28
  import { ERC20VariableIncentive } from './ERC20VariableIncentive';
25
29
  // import { ERC1155Incentive } from './ERC1155Incentive';
@@ -31,9 +35,11 @@ export {
31
35
  // ERC1155Incentive,
32
36
  ERC20Incentive,
33
37
  ERC20PeggedIncentive,
38
+ ERC20PeggedVariableCriteriaIncentive,
34
39
  ERC20PeggedVariableCriteriaIncentiveV2,
35
40
  PointsIncentive,
36
41
  ERC20VariableIncentive,
42
+ ERC20VariableCriteriaIncentive,
37
43
  ERC20VariableCriteriaIncentiveV2,
38
44
  };
39
45
 
@@ -49,9 +55,11 @@ export type Incentive =
49
55
  | ERC20Incentive
50
56
  // | ERC1155Incentive
51
57
  | ERC20PeggedIncentive
58
+ | ERC20PeggedVariableCriteriaIncentive
52
59
  | ERC20PeggedVariableCriteriaIncentiveV2
53
60
  | PointsIncentive
54
61
  | ERC20VariableIncentive
62
+ | ERC20VariableCriteriaIncentive
55
63
  | ERC20VariableCriteriaIncentiveV2;
56
64
 
57
65
  /**
@@ -62,6 +70,8 @@ export type Incentive =
62
70
  export const IncentiveByComponentInterface = {
63
71
  [APointsIncentive as Hex]: PointsIncentive,
64
72
  [AERC20Incentive as Hex]: ERC20Incentive,
73
+ [AERC20PeggedVariableCriteriaIncentive as Hex]:
74
+ ERC20PeggedVariableCriteriaIncentive,
65
75
  [AERC20PeggedVariableCriteriaIncentiveV2 as Hex]:
66
76
  ERC20PeggedVariableCriteriaIncentiveV2,
67
77
  [AERC20PeggedIncentive as Hex]: ERC20PeggedIncentive,
@@ -70,6 +80,7 @@ export const IncentiveByComponentInterface = {
70
80
  [ACGDAIncentive as Hex]: CGDAIncentive,
71
81
  [AERC20VariableIncentive as Hex]: ERC20VariableIncentive,
72
82
  [AERC20VariableCriteriaIncentiveV2 as Hex]: ERC20VariableCriteriaIncentiveV2,
83
+ [AERC20VariableCriteriaIncentive as Hex]: ERC20VariableCriteriaIncentive,
73
84
  };
74
85
 
75
86
  /**
package/src/index.ts CHANGED
@@ -39,6 +39,8 @@ export * from './Incentives/CGDAIncentive';
39
39
  export * from './Incentives/ERC20Incentive';
40
40
  export * from './Incentives/ERC20PeggedIncentive';
41
41
  export * from './Incentives/ERC20VariableIncentive';
42
+ export * from './Incentives/ERC20VariableCriteriaIncentive';
43
+ export * from './Incentives/ERC20PeggedVariableCriteriaIncentive';
42
44
  export * from './Incentives/ERC20VariableCriteriaIncentiveV2';
43
45
  export * from './Incentives/ERC20PeggedVariableCriteriaIncentiveV2';
44
46
  // export * from './Incentives/ERC1155Incentive';