@boostxyz/sdk 5.1.1 → 5.2.1

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.
@@ -33,6 +33,7 @@ import {
33
33
  gasRebateIncentiveCriteria,
34
34
  } from "./ERC20VariableCriteriaIncentive";
35
35
  import { allKnownSignatures } from "@boostxyz/test/allKnownSignatures";
36
+ import { readMockErc20BalanceOf } from "@boostxyz/evm";
36
37
 
37
38
  /**
38
39
  * A basic ERC721 mint scalar criteria for testing
@@ -73,11 +74,11 @@ export function basicErc721MintScalarCriteria(
73
74
  let fixtures: Fixtures,
74
75
  erc20: MockERC20,
75
76
  erc721: MockERC721,
76
- erc20Incentive: ERC20PeggedVariableCriteriaIncentive,
77
+ erc20PeggedVariableCriteriaIncentive: ERC20PeggedVariableCriteriaIncentive,
77
78
  budgets: BudgetFixtures,
78
79
  boost: Boost;
79
80
 
80
- describe("ERC20VariableCriteriaIncentive", () => {
81
+ describe("ERC20PeggedVariableCriteriaIncentive", () => {
81
82
  beforeAll(async () => {
82
83
  fixtures = await loadFixture(deployFixtures(defaultOptions));
83
84
  });
@@ -86,7 +87,7 @@ describe("ERC20VariableCriteriaIncentive", () => {
86
87
  budgets = await loadFixture(fundBudget(defaultOptions, fixtures));
87
88
  erc20 = await loadFixture(fundErc20(defaultOptions));
88
89
  erc721 = await loadFixture(fundErc721(defaultOptions));
89
- erc20Incentive = fixtures.core.ERC20PeggedVariableCriteriaIncentive({
90
+ erc20PeggedVariableCriteriaIncentive = fixtures.core.ERC20PeggedVariableCriteriaIncentive({
90
91
  asset: budgets.erc20.assertValidAddress(),
91
92
  reward: parseEther("1"),
92
93
  limit: parseEther("10"),
@@ -97,48 +98,48 @@ describe("ERC20VariableCriteriaIncentive", () => {
97
98
 
98
99
  boost = await freshBoost(fixtures, {
99
100
  budget: budgets.budget,
100
- incentives: [erc20Incentive],
101
+ incentives: [erc20PeggedVariableCriteriaIncentive],
101
102
  });
102
103
  expect(isAddress(boost.incentives[0]!.assertValidAddress())).toBe(true);
103
104
  });
104
105
 
105
106
  describe("Basic Parameters", () => {
106
107
  test("should return correct asset address", async () => {
107
- const asset = await erc20Incentive.asset();
108
+ const asset = await erc20PeggedVariableCriteriaIncentive.asset();
108
109
  expect(isAddressEqual(asset, budgets.erc20.assertValidAddress())).toBe(true);
109
110
  });
110
111
 
111
112
  test("should return correct peg token address", async () => {
112
- const peg = await erc20Incentive.peg();
113
+ const peg = await erc20PeggedVariableCriteriaIncentive.peg();
113
114
  expect(isAddressEqual(peg, erc20.assertValidAddress())).toBe(true);
114
115
  });
115
116
 
116
117
  test("should return correct reward amount", async () => {
117
- const reward = await erc20Incentive.reward();
118
+ const reward = await erc20PeggedVariableCriteriaIncentive.reward();
118
119
  expect(reward).toBe(parseEther("1"));
119
120
  });
120
121
 
121
122
  test("should return correct limit", async () => {
122
- const limit = await erc20Incentive.limit();
123
+ const limit = await erc20PeggedVariableCriteriaIncentive.limit();
123
124
  expect(limit).toBe(parseEther("10"));
124
125
  });
125
126
 
126
127
  test("should return correct max reward", async () => {
127
- const maxReward = await erc20Incentive.getMaxReward();
128
+ const maxReward = await erc20PeggedVariableCriteriaIncentive.getMaxReward();
128
129
  expect(maxReward).toBe(parseEther("20"));
129
130
  });
130
131
  });
131
132
 
132
133
  describe("Remaining Claims", () => {
133
134
  test("should calculate remaining claim potential correctly", async () => {
134
- const remaining = await erc20Incentive.getRemainingClaimPotential();
135
- const limit = await erc20Incentive.limit();
136
- const totalClaimed = await erc20Incentive.totalClaimed();
135
+ const remaining = await erc20PeggedVariableCriteriaIncentive.getRemainingClaimPotential();
136
+ const limit = await erc20PeggedVariableCriteriaIncentive.limit();
137
+ const totalClaimed = await erc20PeggedVariableCriteriaIncentive.totalClaimed();
137
138
  expect(remaining).toBe(limit - totalClaimed);
138
139
  });
139
140
 
140
141
  test("should return true for canBeClaimed when claims remain", async () => {
141
- const canBeClaimed = await erc20Incentive.canBeClaimed();
142
+ const canBeClaimed = await erc20PeggedVariableCriteriaIncentive.canBeClaimed();
142
143
  expect(canBeClaimed).toBe(true);
143
144
  });
144
145
  });
@@ -159,7 +160,7 @@ describe("ERC20VariableCriteriaIncentive", () => {
159
160
  describe("Claim Data", () => {
160
161
  test("should properly encode claim data", () => {
161
162
  const rewardAmount = parseEther("1");
162
- const encodedData = erc20Incentive.buildClaimData(rewardAmount);
163
+ const encodedData = erc20PeggedVariableCriteriaIncentive.buildClaimData(rewardAmount);
163
164
  expect(encodedData).toBe(
164
165
  "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"
165
166
  );
@@ -168,14 +169,14 @@ describe("ERC20VariableCriteriaIncentive", () => {
168
169
 
169
170
  describe("Owner", () => {
170
171
  test("should return correct owner", async () => {
171
- const owner = await erc20Incentive.owner();
172
+ const owner = await erc20PeggedVariableCriteriaIncentive.owner();
172
173
  expect(isAddressEqual(owner, fixtures.core.assertValidAddress())).toBe(true);
173
174
  });
174
175
  });
175
176
 
176
177
  describe("Current Reward", () => {
177
178
  test("should return valid current reward", async () => {
178
- const currentReward = await erc20Incentive.currentReward();
179
+ const currentReward = await erc20PeggedVariableCriteriaIncentive.currentReward();
179
180
  expect(currentReward).toBeDefined();
180
181
  expect(currentReward).toBeTypeOf("bigint");
181
182
  });
@@ -190,7 +191,7 @@ describe("ERC20VariableCriteriaIncentive", () => {
190
191
  recipient,
191
192
  1n,
192
193
  );
193
- const scalar = await erc20Incentive.getIncentiveScalar({
194
+ const scalar = await erc20PeggedVariableCriteriaIncentive.getIncentiveScalar({
194
195
  hash,
195
196
  chainId: 31337,
196
197
  knownSignatures: allKnownSignatures,
@@ -202,7 +203,7 @@ describe("ERC20VariableCriteriaIncentive", () => {
202
203
  test("should return a valid scalar for event-based criteria", async () => {
203
204
  boost = await freshBoost(fixtures, {
204
205
  budget: budgets.budget,
205
- incentives: [erc20Incentive],
206
+ incentives: [erc20PeggedVariableCriteriaIncentive],
206
207
  });
207
208
  const recipient = accounts[1].account;
208
209
  const { hash } = await erc721.transferFromRaw(
@@ -210,7 +211,7 @@ describe("ERC20VariableCriteriaIncentive", () => {
210
211
  recipient,
211
212
  1n,
212
213
  );
213
- const scalar = await erc20Incentive.getIncentiveScalar({
214
+ const scalar = await erc20PeggedVariableCriteriaIncentive.getIncentiveScalar({
214
215
  hash,
215
216
  chainId: 31337,
216
217
  knownSignatures: allKnownSignatures,
@@ -223,7 +224,7 @@ describe("ERC20VariableCriteriaIncentive", () => {
223
224
  // Ensure that the gasRebateIncentiveCriteria returns the correct structure
224
225
  const gasRebateCriteria = gasRebateIncentiveCriteria();
225
226
 
226
- erc20Incentive = fixtures.core.ERC20PeggedVariableCriteriaIncentive({
227
+ erc20PeggedVariableCriteriaIncentive = fixtures.core.ERC20PeggedVariableCriteriaIncentive({
227
228
  asset: budgets.erc20.assertValidAddress(),
228
229
  reward: 1n,
229
230
  limit: 1n,
@@ -242,7 +243,7 @@ describe("ERC20VariableCriteriaIncentive", () => {
242
243
 
243
244
  boost = await freshBoost(fixtures, {
244
245
  budget: budgets.budget,
245
- incentives: [erc20Incentive],
246
+ incentives: [erc20PeggedVariableCriteriaIncentive],
246
247
  });
247
248
 
248
249
  // Validate that the deployed incentive has the correct criteria set up
@@ -261,7 +262,7 @@ describe("ERC20VariableCriteriaIncentive", () => {
261
262
  const { hash } = await erc20.mintRaw(recipient, parseEther("100"));
262
263
 
263
264
  try {
264
- await erc20Incentive.getIncentiveScalar({
265
+ await erc20PeggedVariableCriteriaIncentive.getIncentiveScalar({
265
266
  hash,
266
267
  chainId: 31337,
267
268
  knownSignatures: allKnownSignatures,
@@ -276,7 +277,7 @@ describe("ERC20VariableCriteriaIncentive", () => {
276
277
  const { hash } = await erc20.mintRaw(recipient, parseEther("100"));
277
278
 
278
279
  try {
279
- await erc20Incentive.getIncentiveScalar({
280
+ await erc20PeggedVariableCriteriaIncentive.getIncentiveScalar({
280
281
  hash,
281
282
  chainId: 31337,
282
283
  knownSignatures: allKnownSignatures,
@@ -299,11 +300,11 @@ describe("ERC20VariableCriteriaIncentive", () => {
299
300
  // rebase this
300
301
  const boost = await freshBoost(fixtures, {
301
302
  budget: budgets.budget,
302
- incentives: [erc20Incentive],
303
+ incentives: [erc20PeggedVariableCriteriaIncentive],
303
304
  });
304
305
  const [amount, address] = await budgets.budget.clawbackFromTarget(
305
306
  fixtures.core.assertValidAddress(),
306
- erc20Incentive.buildClawbackData(1n),
307
+ erc20PeggedVariableCriteriaIncentive.buildClawbackData(1n),
307
308
  boost.id,
308
309
  0,
309
310
  );
@@ -312,4 +313,45 @@ describe("ERC20VariableCriteriaIncentive", () => {
312
313
  true,
313
314
  );
314
315
  });
316
+
317
+ test('can claim', async () => {
318
+ const referrer = accounts.at(1)?.account!
319
+ const trustedSigner = accounts.at(0)!
320
+ const claimant = trustedSigner.account!;
321
+ const asset = await erc20PeggedVariableCriteriaIncentive.asset()
322
+ const signedAmount = 2n
323
+ const incentiveData = erc20PeggedVariableCriteriaIncentive.buildClaimData(signedAmount)
324
+ const claimDataPayload = await boost.validator.encodeClaimData({
325
+ signer: trustedSigner,
326
+ incentiveData,
327
+ chainId: defaultOptions.config.chains[0].id,
328
+ incentiveQuantity: boost.incentives.length,
329
+ claimant,
330
+ boostId: boost.id
331
+ })
332
+
333
+ // verify reward amount
334
+ const incentiveClaimAmount = await erc20PeggedVariableCriteriaIncentive.decodeClaimData(claimDataPayload)
335
+ expect(incentiveClaimAmount).toBe(signedAmount)
336
+
337
+ const balanceBeforeClaim = await readMockErc20BalanceOf(defaultOptions.config, {
338
+ address: asset,
339
+ args: [claimant],
340
+ })
341
+
342
+ await fixtures.core.claimIncentiveFor(
343
+ boost.id,
344
+ 0n,
345
+ referrer,
346
+ claimDataPayload,
347
+ claimant,
348
+ );
349
+
350
+ const balanceAfterClaim = await readMockErc20BalanceOf(defaultOptions.config, {
351
+ address: asset,
352
+ args: [claimant],
353
+ })
354
+
355
+ expect(balanceAfterClaim - balanceBeforeClaim).toBe(signedAmount);
356
+ })
315
357
  });
@@ -26,8 +26,10 @@ import {
26
26
  type Address,
27
27
  type ContractEventName,
28
28
  type Hex,
29
+ decodeAbiParameters,
29
30
  decodeFunctionData,
30
31
  encodeAbiParameters,
32
+ parseEther,
31
33
  parseEventLogs,
32
34
  zeroAddress,
33
35
  } from 'viem';
@@ -650,16 +652,109 @@ export class ERC20PeggedVariableCriteriaIncentive extends DeployableTarget<
650
652
  * Builds the claim data for the ERC20PeggedVariableCriteriaIncentivePayload.
651
653
  *
652
654
  * @public
653
- * @param {bigint} rewardAmount
655
+ * @param {bigint} signedAmount
654
656
  * @returns {Hash} Returns the encoded claim data
655
657
  * @description This function returns the encoded claim data for the ERC20PeggedVariableCriteriaIncentivePayload.
656
658
  */
657
- public buildClaimData(rewardAmount: bigint) {
659
+ public buildClaimData(signedAmount: bigint) {
658
660
  return encodeAbiParameters(
659
- [{ type: 'uint256', name: 'rewardAmount' }],
660
- [rewardAmount],
661
+ [{ type: 'uint256', name: 'signedAmount' }],
662
+ [signedAmount],
661
663
  );
662
664
  }
665
+
666
+ /**
667
+ * Decodes claim data for the ERC20PeggedVariableCriteriaIncentive, returning the claim amount.
668
+ * Useful when deriving amount claimed from logs.
669
+ *
670
+ * @public
671
+ * @param {Hex} claimData
672
+ * @returns {BigInt} Returns the reward amount from a claim data payload
673
+ */
674
+ public async decodeClaimData(claimData: Hex) {
675
+ const boostClaimData = decodeAbiParameters(
676
+ [
677
+ {
678
+ type: 'tuple',
679
+ name: 'BoostClaimData',
680
+ components: [
681
+ { type: 'bytes', name: 'validatorData' },
682
+ { type: 'bytes', name: 'incentiveData' },
683
+ ],
684
+ },
685
+ ],
686
+ claimData,
687
+ );
688
+ const signedAmount = decodeAbiParameters(
689
+ [{ type: 'uint256' }],
690
+ boostClaimData[0].incentiveData,
691
+ )[0];
692
+ let claimAmount = signedAmount;
693
+ const [reward, maxReward] = await Promise.all([
694
+ this.reward(),
695
+ this.getMaxReward(),
696
+ ]);
697
+
698
+ if (reward === 0n) {
699
+ return claimAmount;
700
+ } else {
701
+ claimAmount = (reward * signedAmount) / parseEther('1');
702
+ }
703
+
704
+ if (maxReward !== 0n && claimAmount > maxReward) {
705
+ claimAmount = maxReward;
706
+ }
707
+
708
+ return claimAmount;
709
+ }
710
+
711
+ /**
712
+ * Decodes claim data for the ERC20PeggedVariableCriteriaIncentive, returning the claim amount.
713
+ * Useful when deriving amount claimed from logs.
714
+ * Use this function instead of `decodeClaimData` if you have reward details.
715
+ *
716
+ * @public
717
+ * @param {Hex} claimData
718
+ * @param {bigint} [reward]
719
+ * @param {bigint} [maxReward]
720
+ * @returns {BigInt} Returns the reward amount from a claim data payload
721
+ */
722
+ public decodeClaimDataWithRewardDetails(
723
+ claimData: Hex,
724
+ reward: bigint,
725
+ maxReward: bigint,
726
+ ) {
727
+ const boostClaimData = decodeAbiParameters(
728
+ [
729
+ {
730
+ type: 'tuple',
731
+ name: 'BoostClaimData',
732
+ components: [
733
+ { type: 'bytes', name: 'validatorData' },
734
+ { type: 'bytes', name: 'incentiveData' },
735
+ ],
736
+ },
737
+ ],
738
+ claimData,
739
+ );
740
+ const signedAmount = decodeAbiParameters(
741
+ [{ type: 'uint256' }],
742
+ boostClaimData[0].incentiveData,
743
+ )[0];
744
+ let claimAmount = signedAmount;
745
+
746
+ if (reward === 0n) {
747
+ return claimAmount;
748
+ } else {
749
+ claimAmount = (reward * signedAmount) / parseEther('1');
750
+ }
751
+
752
+ if (maxReward !== 0n && claimAmount > maxReward) {
753
+ claimAmount = maxReward;
754
+ }
755
+
756
+ return claimAmount;
757
+ }
663
758
  }
664
759
 
665
760
  /**
@@ -1 +0,0 @@
1
- {"version":3,"file":"Incentive-DSsxOFKY.js","sources":["../src/Incentives/ERC20PeggedIncentive.ts","../src/Incentives/ERC20PeggedVariableCriteriaIncentive.ts","../src/Incentives/Incentive.ts"],"sourcesContent":["import {\n erc20PeggedIncentiveAbi,\n readErc20PeggedIncentiveAsset,\n readErc20PeggedIncentiveClaimed,\n readErc20PeggedIncentiveClaims,\n readErc20PeggedIncentiveCurrentReward,\n readErc20PeggedIncentiveGetPeg,\n readErc20PeggedIncentiveIsClaimable,\n readErc20PeggedIncentiveLimit,\n readErc20PeggedIncentiveOwner,\n readErc20PeggedIncentivePeg,\n readErc20PeggedIncentiveReward,\n readErc20PeggedIncentiveTotalClaimed,\n simulateErc20PeggedIncentiveClaim,\n simulateErc20PeggedIncentiveClawback,\n writeErc20PeggedIncentiveClaim,\n writeErc20PeggedIncentiveClawback,\n} from '@boostxyz/evm';\nimport { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20PeggedIncentive.sol/ERC20PeggedIncentive.json';\nimport {\n type Address,\n type ContractEventName,\n type Hex,\n encodeAbiParameters,\n zeroAddress,\n zeroHash,\n} from 'viem';\nimport { ERC20PeggedIncentive as ERC20PeggedIncentiveBases } from '../../dist/deployments.json';\nimport type {\n DeployableOptions,\n GenericDeployableParams,\n} from '../Deployable/Deployable';\nimport { DeployableTarget } from '../Deployable/DeployableTarget';\nimport { type ClaimPayload, prepareClaimPayload } from '../claiming';\nimport {\n type GenericLog,\n type ReadParams,\n RegistryType,\n type WriteParams,\n} from '../utils';\n\nexport { erc20PeggedIncentiveAbi };\n\n/**\n * The object representation of a `ERC20PeggedIncentive.InitPayload`\n *\n * @export\n * @interface ERC20PeggedIncentivePayload\n * @typedef {ERC20PeggedIncentivePayload}\n */\nexport interface ERC20PeggedIncentivePayload {\n /**\n * The address of the incentivized asset.\n *\n * @type {Address}\n */\n asset: Address;\n /**\n * The peg to normalize to.\n *\n * @type {Address}\n */\n peg: Address;\n /**\n * The amount of the asset to distribute.\n *\n * @type {bigint}\n */\n reward: bigint;\n /**\n * Total spend for the incentive.\n *\n * @type {bigint}\n */\n limit: bigint;\n /**\n * (Optional) The address of the entity that can managed the incentive.\n *\n * @type {Address}\n * @optional\n */\n manager?: Address;\n}\n\n/**\n * A generic `viem.Log` event with support for `ERC20PeggedIncentive` event types.\n *\n * @export\n * @typedef {ERC20PeggedIncentiveLog}\n * @template {ContractEventName<typeof erc20PeggedIncentiveAbi>} [event=ContractEventName<\n * typeof erc20PeggedIncentiveAbi\n * >]\n */\nexport type ERC20PeggedIncentiveLog<\n event extends ContractEventName<\n typeof erc20PeggedIncentiveAbi\n > = ContractEventName<typeof erc20PeggedIncentiveAbi>,\n> = GenericLog<typeof erc20PeggedIncentiveAbi, event>;\n\n/**\n * A simple ERC20 incentive implementation that allows claiming of tokens\n *\n * @export\n * @class ERC20PeggedIncentive\n * @typedef {ERC20PeggedIncentive}\n * @extends {DeployableTarget<ERC20PeggedIncentivePayload>}\n */\nexport class ERC20PeggedIncentive extends DeployableTarget<\n ERC20PeggedIncentivePayload,\n typeof erc20PeggedIncentiveAbi\n> {\n public override readonly abi = erc20PeggedIncentiveAbi;\n /**\n * @inheritdoc\n *\n * @public\n * @static\n * @type {Record<number, Address>}\n */\n public static override bases: Record<number, Address> = {\n 31337: import.meta.env.VITE_ERC20_INCENTIVE_BASE,\n ...(ERC20PeggedIncentiveBases as Record<number, Address>),\n };\n /**\n * @inheritdoc\n *\n * @public\n * @static\n * @type {RegistryType}\n */\n public static override registryType: RegistryType = RegistryType.INCENTIVE;\n\n /**\n * The owner of the incentive\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<Address>}\n */\n public async owner(params?: ReadParams) {\n return await readErc20PeggedIncentiveOwner(this._config, {\n address: this.assertValidAddress(),\n args: [],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Calculates the current reward based on the time since the last claim. The reward is calculated based on the time since the last claim, the available budget, and the reward parameters. It increases linearly over time in the absence of claims, with each hour adding `rewardBoost` to the current reward, up to the available budget. For example, if there is one claim in the first hour, then no claims for three hours, the claimable reward would be `initialReward - rewardDecay + (rewardBoost * 3)`\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>} - The current reward\n */\n public async currentReward(params?: ReadParams) {\n return await readErc20PeggedIncentiveCurrentReward(this._config, {\n address: this.assertValidAddress(),\n args: [],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * The number of claims that have been made\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>}\n */\n public async claims(params?: ReadParams) {\n return await readErc20PeggedIncentiveClaims(this._config, {\n address: this.assertValidAddress(),\n args: [],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * The total amount of rewards claimed\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>}\n */\n public async totalClaimed(params?: ReadParams) {\n return await readErc20PeggedIncentiveTotalClaimed(this._config, {\n address: this.assertValidAddress(),\n args: [],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * A mapping of address to claim status\n *\n * @public\n * @async\n * @param {Address} address\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>}\n */\n public async claimed(address: Address, params?: ReadParams) {\n return await readErc20PeggedIncentiveClaimed(this._config, {\n address: this.assertValidAddress(),\n args: [address],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * The address of the ERC20-like token\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<Address>}\n */\n public async asset(params?: ReadParams) {\n return await readErc20PeggedIncentiveAsset(this._config, {\n address: this.assertValidAddress(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * The address of the pegged ERC20-like token\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<Address>}\n */\n public async peg(params?: ReadParams) {\n return await readErc20PeggedIncentivePeg(this._config, {\n address: this.assertValidAddress(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * The reward amount issued for each claim\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>}\n */\n public async reward(params?: ReadParams) {\n return await readErc20PeggedIncentiveReward(this._config, {\n address: this.assertValidAddress(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * The limit (max possible rewards payout in reward token)\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>}\n */\n public async limit(params?: ReadParams) {\n return await readErc20PeggedIncentiveLimit(this._config, {\n address: this.assertValidAddress(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Claim the incentive\n *\n * @public\n * @async\n * @param {ClaimPayload} payload\n * @param {?WriteParams} [params]\n * @returns {Promise<boolean>} - Returns true if successfully claimed\n */\n protected async claim(payload: ClaimPayload, params?: WriteParams) {\n return await this.awaitResult(this.claimRaw(payload, params));\n }\n\n /**\n * Claim the incentive\n *\n * @public\n * @async\n * @param {ClaimPayload} payload\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - Returns true if successfully claimed\n */\n protected async claimRaw(payload: ClaimPayload, params?: WriteParams) {\n const { request, result } = await simulateErc20PeggedIncentiveClaim(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [prepareClaimPayload(payload)],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n const hash = await writeErc20PeggedIncentiveClaim(this._config, request);\n return { hash, result };\n }\n\n /**\n * Clawback assets from the incentive\n *\n * @public\n * @async\n * @param {ClaimPayload} payload\n * @param {?WriteParams} [params]\n * @returns {Promise<boolean>} - True if the assets were successfully clawbacked\n */\n public async clawback(payload: ClaimPayload, params?: WriteParams) {\n return await this.awaitResult(this.clawbackRaw(payload, params));\n }\n\n /**\n * Clawback assets from the incentive\n *\n * @public\n * @async\n * @param {ClaimPayload} payload\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the assets were successfully clawbacked\n */\n public async clawbackRaw(payload: ClaimPayload, params?: WriteParams) {\n const { request, result } = await simulateErc20PeggedIncentiveClawback(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [prepareClaimPayload(payload)],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n const hash = await writeErc20PeggedIncentiveClawback(this._config, request);\n return { hash, result };\n }\n\n /**\n * Check if an incentive is claimable.\n *\n * @public\n * @async\n * @param {ClaimPayload} payload\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>} = True if the incentive is claimable based on the data payload\n */\n public async isClaimable(payload: ClaimPayload, params?: ReadParams) {\n return await readErc20PeggedIncentiveIsClaimable(this._config, {\n address: this.assertValidAddress(),\n args: [payload.target, payload.data],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * read the peg token for the incentive.\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<Address>} = The address of the token the reward is pegged to\n */\n public async getPeg(params?: ReadParams) {\n return await readErc20PeggedIncentiveGetPeg(this._config, {\n address: this.assertValidAddress(),\n args: [],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Get the maximum amount that can be claimed by this incentive. Useful when used in conjunction with `BoostCore.calculateProtocolFee`\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>} = Return a bigint representing that maximum amount that can be distributed by this incentive.\n */\n public async getTotalBudget(params?: ReadParams) {\n return await this.limit(params);\n }\n\n /**\n * Check if any claims remain by comparing the incentive's total claims against its limit. Does not take requesting user's elligibility into account.\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>} - True if total claims is less than limit\n */\n public async canBeClaimed(params?: ReadParams) {\n return (await this.getRemainingClaimPotential(params)) > 0n;\n }\n\n /**\n * Check how many claims remain by comparing the incentive's total claims against its limit. Does not take requesting user's elligibility into account.\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>} - True if total claims is less than limit\n */\n public async getRemainingClaimPotential(params?: ReadParams) {\n const [claims, limit] = await Promise.all([\n this.claims(params),\n this.limit(params),\n ]);\n return limit - claims;\n }\n\n /**\n * @inheritdoc\n *\n * @public\n * @param {?ERC20PeggedIncentivePayload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public override buildParameters(\n _payload?: ERC20PeggedIncentivePayload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n return {\n abi: erc20PeggedIncentiveAbi,\n bytecode: bytecode as Hex,\n args: [prepareERC20PeggedIncentivePayload(payload)],\n ...this.optionallyAttachAccount(options.account),\n };\n }\n\n /**\n * Encodes an amount to clawback from the incentive\n *\n * @public\n * @param {bigint} amount - How much of the asset to clawback\n * @returns {Hex} - Returns an encoded uint256\n */\n public buildClawbackData(amount: bigint) {\n return encodeAbiParameters([{ type: 'uint256' }], [amount]);\n }\n\n /**\n * Builds the claim data for the ERC20PeggedIncentive.\n *\n * @public\n * @param {bigint} rewardAmount\n * @returns {Hash} Returns the encoded claim data\n * @description This function returns the encoded claim data for the ERC20PeggedIncentive.\n */\n public buildClaimData(rewardAmount: bigint) {\n return encodeAbiParameters(\n [{ type: 'uint256', name: 'rewardAmount' }],\n [rewardAmount],\n );\n }\n}\n\n/**\n * Given a {@link ERC20PeggedIncentivePayload}, properly encode a `ERC20PeggedIncentive.InitPayload` for use with {@link ERC20PeggedIncentive} initialization.\n *\n * @param {ERC20PeggedIncentivePayload} param0\n * @param {Address} param0.asset - The address of the incentivized asset.\n * @param {Address} param0.peg - The peg to normalize to.\n * @param {bigint} param0.reward - The amount of the asset to distribute.\n * @param {bigint} param0.limit - How many times can this incentive be claimed.\n * @param {Address} [param0.manager=zeroAddress] - The entity that can manage the incentive.\n * @returns {Hex}\n */\nexport function prepareERC20PeggedIncentivePayload({\n asset,\n peg,\n reward,\n limit,\n manager = zeroAddress,\n}: ERC20PeggedIncentivePayload) {\n return encodeAbiParameters(\n [\n { type: 'address', name: 'asset' },\n { type: 'address', name: 'peg' },\n { type: 'uint256', name: 'reward' },\n { type: 'uint256', name: 'limit' },\n { type: 'address', name: 'manager' },\n ],\n [asset, peg, reward, limit, manager],\n );\n}\n","import {\n erc20PeggedVariableCriteriaIncentiveAbi,\n readErc20PeggedVariableCriteriaIncentiveAsset,\n readErc20PeggedVariableCriteriaIncentiveClaimed,\n readErc20PeggedVariableCriteriaIncentiveClaims,\n readErc20PeggedVariableCriteriaIncentiveCurrentReward,\n readErc20PeggedVariableCriteriaIncentiveGetIncentiveCriteria,\n readErc20PeggedVariableCriteriaIncentiveGetMaxReward,\n readErc20PeggedVariableCriteriaIncentiveGetPeg,\n readErc20PeggedVariableCriteriaIncentiveIsClaimable,\n readErc20PeggedVariableCriteriaIncentiveLimit,\n readErc20PeggedVariableCriteriaIncentiveOwner,\n readErc20PeggedVariableCriteriaIncentivePeg,\n readErc20PeggedVariableCriteriaIncentiveReward,\n readErc20PeggedVariableCriteriaIncentiveTotalClaimed,\n simulateErc20PeggedVariableCriteriaIncentiveClaim,\n simulateErc20PeggedVariableCriteriaIncentiveClawback,\n writeErc20PeggedVariableCriteriaIncentiveClaim,\n writeErc20PeggedVariableCriteriaIncentiveClawback,\n} from '@boostxyz/evm';\nimport { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20PeggedVariableCriteriaIncentive.sol/ERC20PeggedVariableCriteriaIncentive.json';\nimport { getTransaction, getTransactionReceipt } from '@wagmi/core';\nimport type { AbiEvent } from 'abitype';\nimport {\n type AbiFunction,\n type Address,\n type ContractEventName,\n type Hex,\n decodeFunctionData,\n encodeAbiParameters,\n parseEventLogs,\n zeroAddress,\n} from 'viem';\nimport { ERC20PeggedVariableCriteriaIncentive as ERC20PeggedVariableCriteriaIncentiveBases } from '../../dist/deployments.json';\nimport { SignatureType } from '../Actions/EventAction';\nimport type {\n DeployableOptions,\n GenericDeployableParams,\n} from '../Deployable/Deployable';\nimport { DeployableTarget } from '../Deployable/DeployableTarget';\nimport { type ClaimPayload, prepareClaimPayload } from '../claiming';\nimport {\n DecodedArgsError,\n IncentiveCriteriaNotFoundError,\n InvalidCriteriaTypeError,\n NoMatchingLogsError,\n} from '../errors';\nimport {\n CheatCodes,\n type GenericLog,\n type ReadParams,\n RegistryType,\n type WriteParams,\n} from '../utils';\nimport type {\n GetIncentiveScalarParams,\n IncentiveCriteria,\n} from './ERC20VariableCriteriaIncentive';\n\nexport { erc20PeggedVariableCriteriaIncentiveAbi };\n\n/**\n * The object representation of a `Erc20PeggedVariableCriteriaIncentive.InitPayload`\n *\n * @export\n * @interface Erc20PeggedVariableCriteriaIncentive\n * @typedef {Erc20PeggedVariableCriteriaIncentive}\n */\nexport interface ERC20PeggedVariableCriteriaIncentivePayload {\n /**\n * The address of the incentivized asset.\n *\n * @type {Address}\n */\n asset: Address;\n /**\n * The peg to normalize to.\n *\n * @type {Address}\n */\n peg: Address;\n /**\n * The amount of the asset to distribute.\n *\n * @type {bigint}\n */\n reward: bigint;\n /**\n * Total spend for the incentive.\n *\n * @type {bigint}\n */\n limit: bigint;\n /**\n * Maximum reward each claim is elligible for.\n *\n * @type {bigint}\n */\n maxReward: bigint;\n /**\n * (Optional) The address of the entity that can managed the incentive.\n *\n * @type {Address}\n * @optional\n */\n manager?: Address;\n /**\n * The criteria for the incentive that determines how the reward is distributed.\n *\n * @type {IncentiveCriteria}\n */\n criteria: IncentiveCriteria;\n}\n\n/**\n * A generic `viem.Log` event with support for `Erc20PeggedVariableCriteriaIncentive` event types.\n *\n * @export\n * @typedef {Erc20PeggedVariableCriteriaIncentiveLog}\n * @template {ContractEventName<typeof erc20PeggedVariableCriteriaIncentiveAbi>} [event=ContractEventName<\n * typeof erc20PeggedVariableCriteriaIncentiveAbi\n * >]\n */\nexport type Erc20PeggedVariableCriteriaIncentiveLog<\n event extends ContractEventName<\n typeof erc20PeggedVariableCriteriaIncentiveAbi\n > = ContractEventName<typeof erc20PeggedVariableCriteriaIncentiveAbi>,\n> = GenericLog<typeof erc20PeggedVariableCriteriaIncentiveAbi, event>;\n\n/**\n * A simple ERC20 incentive implementation that allows claiming of tokens\n *\n * @export\n * @class Erc20PeggedVariableCriteriaIncentive\n * @typedef {ERC20PeggedVariableCriteriaIncentive}\n * @extends {DeployableTarget<ERC20PeggedVariableCriteriaIncentive>}\n */\nexport class ERC20PeggedVariableCriteriaIncentive extends DeployableTarget<\n ERC20PeggedVariableCriteriaIncentivePayload,\n typeof erc20PeggedVariableCriteriaIncentiveAbi\n> {\n public override readonly abi = erc20PeggedVariableCriteriaIncentiveAbi;\n /**\n * @inheritdoc\n *\n * @public\n * @static\n * @type {Record<number, Address>}\n */\n public static override bases: Record<number, Address> = {\n 31337: import.meta.env.VITE_ERC20_INCENTIVE_BASE,\n ...(ERC20PeggedVariableCriteriaIncentiveBases as Record<number, Address>),\n };\n /**\n * @inheritdoc\n *\n * @public\n * @static\n * @type {RegistryType}\n */\n public static override registryType: RegistryType = RegistryType.INCENTIVE;\n\n /**\n * The owner of the incentive\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<Address>}\n */\n public async owner(params?: ReadParams) {\n return await readErc20PeggedVariableCriteriaIncentiveOwner(this._config, {\n address: this.assertValidAddress(),\n args: [],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Calculates the current reward based on the time since the last claim. The reward is calculated based on the time since the last claim, the available budget, and the reward parameters. It increases linearly over time in the absence of claims, with each hour adding `rewardBoost` to the current reward, up to the available budget. For example, if there is one claim in the first hour, then no claims for three hours, the claimable reward would be `initialReward - rewardDecay + (rewardBoost * 3)`\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>} - The current reward\n */\n public async currentReward(params?: ReadParams) {\n return await readErc20PeggedVariableCriteriaIncentiveCurrentReward(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n }\n\n /**\n * Retrieves the maximum reward amount per claim.\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>} The maximum reward amount per claim\n */\n public async getMaxReward(params?: ReadParams): Promise<bigint> {\n const maxReward =\n await readErc20PeggedVariableCriteriaIncentiveGetMaxReward(this._config, {\n ...params,\n address: this.assertValidAddress(),\n });\n\n return maxReward;\n }\n\n /**\n * Fetches the incentive scalar from a transaction hash\n *\n * @param {GetIncentiveScalarParams} params\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>}\n * @throws {InvalidCriteriaTypeError | NoMatchingLogsError | DecodedArgsError}\n */\n public async getIncentiveScalar(\n { chainId, hash, knownSignatures }: GetIncentiveScalarParams,\n params?: ReadParams,\n ): Promise<bigint> {\n const criteria = await this.getIncentiveCriteria(params);\n if (criteria.criteriaType === SignatureType.EVENT) {\n const transactionReceipt = await getTransactionReceipt(this._config, {\n chainId,\n hash,\n });\n if (criteria.fieldIndex === CheatCodes.GAS_REBATE_INCENTIVE) {\n const totalCost =\n transactionReceipt.gasUsed * transactionReceipt.effectiveGasPrice + // Normal gas cost\n (transactionReceipt.blobGasUsed ?? 0n) *\n (transactionReceipt.blobGasPrice ?? 0n); // Blob gas cost - account for potential undefined values\n return totalCost;\n }\n const logs = transactionReceipt.logs;\n\n if (logs.length === 0) {\n throw new NoMatchingLogsError(\n `No logs found for event signature ${criteria.signature}`,\n );\n }\n\n // Decode the event log\n try {\n // Decode function data\n const eventAbi = knownSignatures[criteria.signature] as AbiEvent;\n const decodedEvents = parseEventLogs({\n abi: [eventAbi],\n logs,\n });\n if (decodedEvents == undefined || decodedEvents.length === 0) {\n throw new NoMatchingLogsError(\n `No logs found for event signature ${criteria.signature}`,\n );\n }\n const scalarValue = (decodedEvents[0]?.args as string[])[\n criteria.fieldIndex\n ];\n\n if (scalarValue === undefined) {\n throw new DecodedArgsError(\n `Decoded argument at index ${criteria.fieldIndex} is undefined`,\n );\n }\n return BigInt(scalarValue);\n } catch (e) {\n throw new DecodedArgsError(\n `Failed to decode event log for signature ${criteria.signature}: ${(e as Error).message}`,\n );\n }\n } else if (criteria.criteriaType === SignatureType.FUNC) {\n // Fetch the transaction data\n const transaction = await getTransaction(this._config, {\n chainId,\n hash,\n });\n try {\n // Decode function data\n const func = knownSignatures[criteria.signature] as AbiFunction;\n const decodedFunction = decodeFunctionData({\n abi: [func],\n data: transaction.input,\n });\n const scalarValue = decodedFunction.args[criteria.fieldIndex] as string;\n if (scalarValue === undefined || scalarValue === null) {\n throw new DecodedArgsError(\n `Decoded argument at index ${criteria.fieldIndex} is undefined`,\n );\n }\n return BigInt(scalarValue);\n } catch (e) {\n throw new DecodedArgsError(\n `Failed to decode function data for signature ${criteria.signature}: ${(e as Error).message}`,\n );\n }\n } else {\n throw new InvalidCriteriaTypeError(\n `Invalid criteria type ${criteria.criteriaType}`,\n );\n }\n }\n\n /**\n * The number of claims that have been made\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>}\n */\n public async claims(params?: ReadParams) {\n return await readErc20PeggedVariableCriteriaIncentiveClaims(this._config, {\n address: this.assertValidAddress(),\n args: [],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * The total amount of rewards claimed\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>}\n */\n public async totalClaimed(params?: ReadParams) {\n return await readErc20PeggedVariableCriteriaIncentiveTotalClaimed(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n }\n\n /**\n * A mapping of address to claim status\n *\n * @public\n * @async\n * @param {Address} address\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>}\n */\n public async claimed(address: Address, params?: ReadParams) {\n return await readErc20PeggedVariableCriteriaIncentiveClaimed(this._config, {\n address: this.assertValidAddress(),\n args: [address],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * The address of the ERC20-like token\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<Address>}\n */\n public async asset(params?: ReadParams) {\n return await readErc20PeggedVariableCriteriaIncentiveAsset(this._config, {\n address: this.assertValidAddress(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * The address of the pegged ERC20-like token\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<Address>}\n */\n public async peg(params?: ReadParams) {\n return await readErc20PeggedVariableCriteriaIncentivePeg(this._config, {\n address: this.assertValidAddress(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * The reward amount issued for each claim\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>}\n */\n public async reward(params?: ReadParams) {\n return await readErc20PeggedVariableCriteriaIncentiveReward(this._config, {\n address: this.assertValidAddress(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * The limit (max possible rewards payout in reward token)\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>}\n */\n public async limit(params?: ReadParams) {\n return await readErc20PeggedVariableCriteriaIncentiveLimit(this._config, {\n address: this.assertValidAddress(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Claim the incentive\n *\n * @public\n * @async\n * @param {ClaimPayload} payload\n * @param {?WriteParams} [params]\n * @returns {Promise<boolean>} - Returns true if successfully claimed\n */\n protected async claim(payload: ClaimPayload, params?: WriteParams) {\n return await this.awaitResult(this.claimRaw(payload, params));\n }\n\n /**\n * Claim the incentive\n *\n * @public\n * @async\n * @param {ClaimPayload} payload\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - Returns true if successfully claimed\n */\n protected async claimRaw(payload: ClaimPayload, params?: WriteParams) {\n const { request, result } =\n await simulateErc20PeggedVariableCriteriaIncentiveClaim(this._config, {\n address: this.assertValidAddress(),\n args: [prepareClaimPayload(payload)],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n const hash = await writeErc20PeggedVariableCriteriaIncentiveClaim(\n this._config,\n request,\n );\n return { hash, result };\n }\n\n /**\n * Clawback assets from the incentive\n *\n * @public\n * @async\n * @param {ClaimPayload} payload\n * @param {?WriteParams} [params]\n * @returns {Promise<boolean>} - True if the assets were successfully clawbacked\n */\n public async clawback(payload: ClaimPayload, params?: WriteParams) {\n return await this.awaitResult(this.clawbackRaw(payload, params));\n }\n\n /**\n * Clawback assets from the incentive\n *\n * @public\n * @async\n * @param {ClaimPayload} payload\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the assets were successfully clawbacked\n */\n public async clawbackRaw(payload: ClaimPayload, params?: WriteParams) {\n const { request, result } =\n await simulateErc20PeggedVariableCriteriaIncentiveClawback(this._config, {\n address: this.assertValidAddress(),\n args: [prepareClaimPayload(payload)],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n const hash = await writeErc20PeggedVariableCriteriaIncentiveClawback(\n this._config,\n request,\n );\n return { hash, result };\n }\n\n /**\n * Check if an incentive is claimable.\n *\n * @public\n * @async\n * @param {ClaimPayload} payload\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>} = True if the incentive is claimable based on the data payload\n */\n public async isClaimable(payload: ClaimPayload, params?: ReadParams) {\n return await readErc20PeggedVariableCriteriaIncentiveIsClaimable(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [payload.target, payload.data],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n }\n\n /**\n * read the peg token for the incentive.\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<Address>} = The address of the token the reward is pegged to\n */\n public async getPeg(params?: ReadParams) {\n return await readErc20PeggedVariableCriteriaIncentiveGetPeg(this._config, {\n address: this.assertValidAddress(),\n args: [],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Get the maximum amount that can be claimed by this incentive. Useful when used in conjunction with `BoostCore.calculateProtocolFee`\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>} = Return a bigint representing that maximum amount that can be distributed by this incentive.\n */\n public async getTotalBudget(params?: ReadParams) {\n return await this.limit(params);\n }\n\n /**\n * Check if any claims remain by comparing the incentive's total claims against its limit. Does not take requesting user's elligibility into account.\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>} - True if total claims is less than limit\n */\n public async canBeClaimed(params?: ReadParams) {\n return (await this.getRemainingClaimPotential(params)) > 0n;\n }\n\n /**\n * Check how many claims remain by comparing the incentive's total claims against its limit. Does not take requesting user's elligibility into account.\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>} - True if total claims is less than limit\n */\n public async getRemainingClaimPotential(params?: ReadParams) {\n const [totalClaimed, limit] = await Promise.all([\n this.totalClaimed(params),\n this.limit(params),\n ]);\n return limit - totalClaimed;\n }\n\n /**\n *Functions from the ERC20VariableIncentive contract\n */\n\n /**\n * Fetches the IncentiveCriteria struct from the contract\n *\n * @param {?ReadParams} [params]\n * @returns {Promise<IncentiveCriteria>} Incentive criteria structure\n * @throws {IncentiveCriteriaNotFoundError}\n */\n public async getIncentiveCriteria(\n params?: ReadParams,\n ): Promise<IncentiveCriteria> {\n try {\n const criteria =\n await readErc20PeggedVariableCriteriaIncentiveGetIncentiveCriteria(\n this._config,\n {\n ...params,\n address: this.assertValidAddress(),\n },\n );\n\n return criteria;\n } catch (e) {\n throw new IncentiveCriteriaNotFoundError(e as Error);\n }\n }\n\n /**\n * @inheritdoc\n *\n * @public\n * @param {?ERC20PeggedVariableCriteriaIncentivePayload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public override buildParameters(\n _payload?: ERC20PeggedVariableCriteriaIncentivePayload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n return {\n abi: erc20PeggedVariableCriteriaIncentiveAbi,\n bytecode: bytecode as Hex,\n args: [prepareERC20PeggedVariableCriteriaIncentivePayload(payload)],\n ...this.optionallyAttachAccount(options.account),\n };\n }\n\n /**\n * Encodes an amount to clawback from the incentive\n *\n * @public\n * @param {bigint} amount - How much of the asset to clawback\n * @returns {Hex} - Returns an encoded uint256\n */\n public buildClawbackData(amount: bigint) {\n return encodeAbiParameters([{ type: 'uint256' }], [amount]);\n }\n\n /**\n * Builds the claim data for the ERC20PeggedVariableCriteriaIncentivePayload.\n *\n * @public\n * @param {bigint} rewardAmount\n * @returns {Hash} Returns the encoded claim data\n * @description This function returns the encoded claim data for the ERC20PeggedVariableCriteriaIncentivePayload.\n */\n public buildClaimData(rewardAmount: bigint) {\n return encodeAbiParameters(\n [{ type: 'uint256', name: 'rewardAmount' }],\n [rewardAmount],\n );\n }\n}\n\n/**\n * Given a {@link ERC20PeggedVariableCriteriaIncentivePayload}, properly encode a `ERC20PeggedVariableCriteriaIncentivePayload.InitPayload` for use with {@link ERC20PeggedVariableCriteriaIncentivePayload} initialization.\n *\n * @param {ERC20PeggedVariableCriteriaIncentivePayload} param0\n * @param {Address} param0.asset - The address of the incentivized asset.\n * @param {Address} param0.peg - The peg to normalize to.\n * @param {bigint} param0.reward - The amount of the asset to distribute.\n * @param {bigint} param0.limit - How many times can this incentive be claimed.\n * @param {Address} [param0.manager=zeroAddress] - The entity that can manage the incentive.\n * @param {IncentiveCriteria} param0.criteria - The incentive criteria for reward distribution.\n * @returns {Hex}\n */\nexport function prepareERC20PeggedVariableCriteriaIncentivePayload({\n asset,\n peg,\n reward,\n limit,\n maxReward = 0n,\n manager = zeroAddress,\n criteria,\n}: ERC20PeggedVariableCriteriaIncentivePayload) {\n return encodeAbiParameters(\n [\n {\n type: 'tuple',\n name: 'initPayloadExtended',\n components: [\n { type: 'address', name: 'asset' },\n { type: 'address', name: 'peg' },\n { type: 'uint256', name: 'reward' },\n { type: 'uint256', name: 'limit' },\n { type: 'address', name: 'manager' },\n { type: 'uint256', name: 'maxReward' },\n {\n type: 'tuple',\n name: 'criteria',\n components: [\n { type: 'uint8', name: 'criteriaType' },\n { type: 'bytes32', name: 'signature' },\n { type: 'uint8', name: 'fieldIndex' },\n { type: 'address', name: 'targetContract' },\n ],\n },\n ],\n },\n ],\n [\n {\n asset,\n peg,\n reward,\n limit,\n manager,\n maxReward,\n criteria: {\n criteriaType: criteria.criteriaType,\n signature: criteria.signature,\n fieldIndex: criteria.fieldIndex,\n targetContract: criteria.targetContract,\n },\n },\n ],\n );\n}\n","import { aIncentiveAbi } from '@boostxyz/evm';\nimport {\n AAllowListIncentive,\n ACGDAIncentive,\n AERC20Incentive,\n AERC20PeggedIncentive,\n AERC20PeggedVariableCriteriaIncentive,\n AERC20VariableCriteriaIncentive,\n AERC20VariableIncentive,\n // AERC20VariableCriteriaIncentive\n APointsIncentive,\n} from '@boostxyz/evm/deploys/componentInterfaces.json';\nimport { readContract } from '@wagmi/core';\nimport type { Address, Hex } from 'viem';\nimport type { DeployableOptions } from '../Deployable/Deployable';\nimport { InvalidComponentInterfaceError } from '../errors';\nimport type { ReadParams } from '../utils';\nimport { AllowListIncentive } from './AllowListIncentive';\nimport { CGDAIncentive } from './CGDAIncentive';\nimport { ERC20Incentive } from './ERC20Incentive';\nimport { ERC20PeggedIncentive } from './ERC20PeggedIncentive';\nimport { ERC20PeggedVariableCriteriaIncentive } from './ERC20PeggedVariableCriteriaIncentive';\nimport { ERC20VariableCriteriaIncentive } from './ERC20VariableCriteriaIncentive';\nimport { ERC20VariableIncentive } from './ERC20VariableIncentive';\n// import { ERC1155Incentive } from './ERC1155Incentive';\nimport { PointsIncentive } from './PointsIncentive';\n\nexport {\n AllowListIncentive,\n CGDAIncentive,\n // ERC1155Incentive,\n ERC20Incentive,\n ERC20PeggedIncentive,\n ERC20PeggedVariableCriteriaIncentive,\n PointsIncentive,\n ERC20VariableIncentive,\n ERC20VariableCriteriaIncentive,\n};\n\n/**\n * A union type representing all valid protocol Incentive implementations\n *\n * @export\n * @typedef {Incentive}\n */\nexport type Incentive =\n | AllowListIncentive\n | CGDAIncentive\n | ERC20Incentive\n // | ERC1155Incentive\n | ERC20PeggedIncentive\n | ERC20PeggedVariableCriteriaIncentive\n | PointsIncentive\n | ERC20VariableIncentive\n | ERC20VariableCriteriaIncentive;\n\n/**\n * A map of Incentive component interfaces to their constructors.\n *\n * @type {{ \"0xc5b24b8e\": typeof PointsIncentive; \"0x8c901437\": typeof ERC20Incentive; \"0x4414fbb4\": typeof ERC20PeggedIncentive; \"0xf60c99c9\": typeof ERC20PeggedVariableCriteriaIncentive; \"0x56586338\": typeof AllowListIncentive; \"0xa39e44d9\": typeof CGDAIncentive; \"0xa8e4af1e\": typeof ERC20VariableIncentive; \"0x90318111\": typeof ERC20VariableCriteriaIncentive }}\n */\nexport const IncentiveByComponentInterface = {\n [APointsIncentive as Hex]: PointsIncentive,\n [AERC20Incentive as Hex]: ERC20Incentive,\n [AERC20PeggedVariableCriteriaIncentive as Hex]:\n ERC20PeggedVariableCriteriaIncentive,\n [AERC20PeggedIncentive as Hex]: ERC20PeggedIncentive,\n [AAllowListIncentive]: AllowListIncentive,\n // [AERC1155Incentive as Hex]: ERC1155Incentive,\n [ACGDAIncentive as Hex]: CGDAIncentive,\n [AERC20VariableIncentive as Hex]: ERC20VariableIncentive,\n [AERC20VariableCriteriaIncentive as Hex]: ERC20VariableCriteriaIncentive,\n};\n\n/**\n * A function that will read a contract's component interface using `getComponentInterface` and return the correct instantiated instance.\n *\n * @export\n * @async\n * @param {DeployableOptions} options\n * @param {Address} address\n * @returns {Incentive}\n * @throws {@link InvalidComponentInterfaceError}\n */\nexport async function incentiveFromAddress(\n options: DeployableOptions,\n address: Address,\n params?: ReadParams,\n) {\n const interfaceId = (await readContract(options.config, {\n abi: aIncentiveAbi,\n functionName: 'getComponentInterface',\n address,\n ...params,\n })) as keyof typeof IncentiveByComponentInterface;\n const Ctor = IncentiveByComponentInterface[interfaceId];\n if (!Ctor) {\n throw new InvalidComponentInterfaceError(\n Object.keys(IncentiveByComponentInterface) as Hex[],\n interfaceId as Hex,\n );\n }\n return new Ctor(options, address);\n}\n"],"names":["_ERC20PeggedIncentive","DeployableTarget","erc20PeggedIncentiveAbi","params","readErc20PeggedIncentiveOwner","readErc20PeggedIncentiveCurrentReward","readErc20PeggedIncentiveClaims","readErc20PeggedIncentiveTotalClaimed","address","readErc20PeggedIncentiveClaimed","readErc20PeggedIncentiveAsset","readErc20PeggedIncentivePeg","readErc20PeggedIncentiveReward","readErc20PeggedIncentiveLimit","payload","request","result","simulateErc20PeggedIncentiveClaim","prepareClaimPayload","writeErc20PeggedIncentiveClaim","simulateErc20PeggedIncentiveClawback","writeErc20PeggedIncentiveClawback","readErc20PeggedIncentiveIsClaimable","readErc20PeggedIncentiveGetPeg","claims","limit","_payload","_options","options","bytecode","prepareERC20PeggedIncentivePayload","amount","encodeAbiParameters","rewardAmount","ERC20PeggedIncentiveBases","RegistryType","ERC20PeggedIncentive","asset","peg","reward","manager","zeroAddress","_ERC20PeggedVariableCriteriaIncentive","erc20PeggedVariableCriteriaIncentiveAbi","readErc20PeggedVariableCriteriaIncentiveOwner","readErc20PeggedVariableCriteriaIncentiveCurrentReward","readErc20PeggedVariableCriteriaIncentiveGetMaxReward","chainId","hash","knownSignatures","criteria","SignatureType","transactionReceipt","getTransactionReceipt","CheatCodes","logs","NoMatchingLogsError","eventAbi","decodedEvents","parseEventLogs","scalarValue","_a","DecodedArgsError","e","transaction","getTransaction","func","decodeFunctionData","InvalidCriteriaTypeError","readErc20PeggedVariableCriteriaIncentiveClaims","readErc20PeggedVariableCriteriaIncentiveTotalClaimed","readErc20PeggedVariableCriteriaIncentiveClaimed","readErc20PeggedVariableCriteriaIncentiveAsset","readErc20PeggedVariableCriteriaIncentivePeg","readErc20PeggedVariableCriteriaIncentiveReward","readErc20PeggedVariableCriteriaIncentiveLimit","simulateErc20PeggedVariableCriteriaIncentiveClaim","writeErc20PeggedVariableCriteriaIncentiveClaim","simulateErc20PeggedVariableCriteriaIncentiveClawback","writeErc20PeggedVariableCriteriaIncentiveClawback","readErc20PeggedVariableCriteriaIncentiveIsClaimable","readErc20PeggedVariableCriteriaIncentiveGetPeg","totalClaimed","readErc20PeggedVariableCriteriaIncentiveGetIncentiveCriteria","IncentiveCriteriaNotFoundError","prepareERC20PeggedVariableCriteriaIncentivePayload","ERC20PeggedVariableCriteriaIncentiveBases","ERC20PeggedVariableCriteriaIncentive","maxReward","IncentiveByComponentInterface","APointsIncentive","PointsIncentive","AERC20Incentive","ERC20Incentive","AERC20PeggedVariableCriteriaIncentive","AERC20PeggedIncentive","AAllowListIncentive","AllowListIncentive","ACGDAIncentive","CGDAIncentive","AERC20VariableIncentive","ERC20VariableIncentive","AERC20VariableCriteriaIncentive","ERC20VariableCriteriaIncentive","incentiveFromAddress","interfaceId","readContract","aIncentiveAbi","Ctor","InvalidComponentInterfaceError"],"mappings":";;;;;;;;;;;;;;;;ywoBA2GaA,IAAN,MAAMA,UAA6BC,EAGxC;AAAA,EAHK,cAAA;AAAA,UAAA,GAAA,SAAA,GAIL,KAAyB,MAAMC;AAAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6B/B,MAAa,MAAMC,GAAqB;AAC/B,WAAA,MAAMC,EAA8B,KAAK,SAAS;AAAA,MACvD,SAAS,KAAK,mBAAmB;AAAA,MACjC,MAAM,CAAC;AAAA;AAAA,MAEP,GAAID;AAAA,IAAA,CACL;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAa,cAAcA,GAAqB;AACvC,WAAA,MAAME,EAAsC,KAAK,SAAS;AAAA,MAC/D,SAAS,KAAK,mBAAmB;AAAA,MACjC,MAAM,CAAC;AAAA;AAAA,MAEP,GAAIF;AAAA,IAAA,CACL;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAa,OAAOA,GAAqB;AAChC,WAAA,MAAMG,EAA+B,KAAK,SAAS;AAAA,MACxD,SAAS,KAAK,mBAAmB;AAAA,MACjC,MAAM,CAAC;AAAA;AAA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