@boostxyz/sdk 5.0.0 → 5.1.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.
Files changed (127) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.js +5 -5
  3. package/dist/Actions/EventAction.cjs +1 -1
  4. package/dist/Actions/EventAction.cjs.map +1 -1
  5. package/dist/Actions/EventAction.d.ts +18 -0
  6. package/dist/Actions/EventAction.d.ts.map +1 -1
  7. package/dist/Actions/EventAction.js +201 -132
  8. package/dist/Actions/EventAction.js.map +1 -1
  9. package/dist/AllowLists/AllowList.cjs +1 -1
  10. package/dist/AllowLists/AllowList.js +3 -3
  11. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  12. package/dist/AllowLists/SimpleAllowList.js +8 -8
  13. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  14. package/dist/AllowLists/SimpleDenyList.js +3 -3
  15. package/dist/Auth/PassthroughAuth.cjs +1 -1
  16. package/dist/Auth/PassthroughAuth.js +1 -1
  17. package/dist/BoostCore.cjs +2 -2
  18. package/dist/BoostCore.cjs.map +1 -1
  19. package/dist/BoostCore.d.ts +14 -0
  20. package/dist/BoostCore.d.ts.map +1 -1
  21. package/dist/BoostCore.js +130 -111
  22. package/dist/BoostCore.js.map +1 -1
  23. package/dist/BoostRegistry.cjs +1 -1
  24. package/dist/BoostRegistry.js +6 -6
  25. package/dist/{Budget-fHCvlPfB.js → Budget-C0SMvfEl.js} +53 -53
  26. package/dist/{Budget-fHCvlPfB.js.map → Budget-C0SMvfEl.js.map} +1 -1
  27. package/dist/{Budget-Cnyh81n5.cjs → Budget-N0YEfSt2.cjs} +2 -2
  28. package/dist/{Budget-Cnyh81n5.cjs.map → Budget-N0YEfSt2.cjs.map} +1 -1
  29. package/dist/Budgets/Budget.cjs +1 -1
  30. package/dist/Budgets/Budget.js +3 -3
  31. package/dist/Budgets/ManagedBudget.cjs +1 -1
  32. package/dist/Budgets/ManagedBudget.js +29 -29
  33. package/dist/Deployable/DeployableTarget.cjs +1 -1
  34. package/dist/Deployable/DeployableTarget.js +1 -1
  35. package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
  36. package/dist/Deployable/DeployableTargetWithRBAC.js +15 -15
  37. package/dist/Incentive-DSsxOFKY.js +901 -0
  38. package/dist/Incentive-DSsxOFKY.js.map +1 -0
  39. package/dist/Incentive-lNp-ZudZ.cjs +2 -0
  40. package/dist/Incentive-lNp-ZudZ.cjs.map +1 -0
  41. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  42. package/dist/Incentives/AllowListIncentive.js +11 -11
  43. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  44. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  45. package/dist/Incentives/CGDAIncentive.d.ts +1 -1
  46. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  47. package/dist/Incentives/CGDAIncentive.js +24 -22
  48. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  49. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  50. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  51. package/dist/Incentives/ERC20Incentive.js +19 -19
  52. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  53. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.d.ts +1035 -0
  54. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.d.ts.map +1 -0
  55. package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs +1 -1
  56. package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs.map +1 -1
  57. package/dist/Incentives/ERC20VariableCriteriaIncentive.js +19 -19
  58. package/dist/Incentives/ERC20VariableCriteriaIncentive.js.map +1 -1
  59. package/dist/Incentives/ERC20VariableIncentive.cjs +1 -1
  60. package/dist/Incentives/ERC20VariableIncentive.cjs.map +1 -1
  61. package/dist/Incentives/ERC20VariableIncentive.d.ts +1 -1
  62. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  63. package/dist/Incentives/ERC20VariableIncentive.js +25 -23
  64. package/dist/Incentives/ERC20VariableIncentive.js.map +1 -1
  65. package/dist/Incentives/Incentive.cjs +1 -1
  66. package/dist/Incentives/Incentive.d.ts +6 -5
  67. package/dist/Incentives/Incentive.d.ts.map +1 -1
  68. package/dist/Incentives/Incentive.js +17 -16
  69. package/dist/Incentives/PointsIncentive.cjs +1 -1
  70. package/dist/Incentives/PointsIncentive.js +8 -8
  71. package/dist/{SimpleDenyList-GZlSeh2G.js → SimpleDenyList-B8QeJthf.js} +12 -12
  72. package/dist/{SimpleDenyList-GZlSeh2G.js.map → SimpleDenyList-B8QeJthf.js.map} +1 -1
  73. package/dist/{SimpleDenyList-CgQvS1ek.cjs → SimpleDenyList-DIb4xX3j.cjs} +2 -2
  74. package/dist/{SimpleDenyList-CgQvS1ek.cjs.map → SimpleDenyList-DIb4xX3j.cjs.map} +1 -1
  75. package/dist/Validators/LimitedSignerValidator.cjs +1 -1
  76. package/dist/Validators/LimitedSignerValidator.js +18 -18
  77. package/dist/Validators/SignerValidator.cjs +1 -1
  78. package/dist/Validators/SignerValidator.js +16 -16
  79. package/dist/Validators/Validator.cjs +1 -1
  80. package/dist/Validators/Validator.js +4 -4
  81. package/dist/componentInterfaces-D7r9xJmt.cjs +2 -0
  82. package/dist/componentInterfaces-D7r9xJmt.cjs.map +1 -0
  83. package/dist/componentInterfaces-PR3ijhgZ.js +18 -0
  84. package/dist/componentInterfaces-PR3ijhgZ.js.map +1 -0
  85. package/dist/{deployments-CMdsItcq.cjs → deployments-BGpr4ppG.cjs} +2 -2
  86. package/dist/deployments-BGpr4ppG.cjs.map +1 -0
  87. package/dist/{deployments-DzhmI-zL.js → deployments-COxshLqt.js} +42 -32
  88. package/dist/deployments-COxshLqt.js.map +1 -0
  89. package/dist/deployments.json +20 -15
  90. package/dist/generated-CRD9XfOT.cjs +3 -0
  91. package/dist/generated-CRD9XfOT.cjs.map +1 -0
  92. package/dist/{generated-Hbd0NIf9.js → generated-ClbO_ULI.js} +1274 -709
  93. package/dist/generated-ClbO_ULI.js.map +1 -0
  94. package/dist/index.cjs +1 -1
  95. package/dist/index.d.ts +1 -0
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js +133 -129
  98. package/dist/utils.cjs +1 -1
  99. package/dist/utils.cjs.map +1 -1
  100. package/dist/utils.d.ts +7 -1
  101. package/dist/utils.d.ts.map +1 -1
  102. package/dist/utils.js +1121 -41
  103. package/dist/utils.js.map +1 -1
  104. package/package.json +1 -1
  105. package/src/Actions/EventAction.ts +85 -1
  106. package/src/BoostCore.ts +27 -0
  107. package/src/Incentives/CGDAIncentive.ts +3 -1
  108. package/src/Incentives/ERC20PeggedIncentive.ts +2 -2
  109. package/src/Incentives/ERC20PeggedVariableCriteriaIncentive.test.ts +315 -0
  110. package/src/Incentives/ERC20PeggedVariableCriteriaIncentive.ts +728 -0
  111. package/src/Incentives/ERC20VariableIncentive.ts +3 -1
  112. package/src/Incentives/Incentive.ts +8 -2
  113. package/src/index.ts +1 -0
  114. package/src/utils.ts +10 -0
  115. package/dist/Incentive-M45PaQsT.js +0 -397
  116. package/dist/Incentive-M45PaQsT.js.map +0 -1
  117. package/dist/Incentive-axLU7ndr.cjs +0 -2
  118. package/dist/Incentive-axLU7ndr.cjs.map +0 -1
  119. package/dist/componentInterfaces-Bt-4sNB5.cjs +0 -2
  120. package/dist/componentInterfaces-Bt-4sNB5.cjs.map +0 -1
  121. package/dist/componentInterfaces-C4uAYjSo.js +0 -16
  122. package/dist/componentInterfaces-C4uAYjSo.js.map +0 -1
  123. package/dist/deployments-CMdsItcq.cjs.map +0 -1
  124. package/dist/deployments-DzhmI-zL.js.map +0 -1
  125. package/dist/generated-CNkDfjzI.cjs +0 -3
  126. package/dist/generated-CNkDfjzI.cjs.map +0 -1
  127. package/dist/generated-Hbd0NIf9.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ERC20Incentive.js","sources":["../../src/Incentives/ERC20Incentive.ts"],"sourcesContent":["import {\n erc20IncentiveAbi,\n readErc20IncentiveAsset,\n readErc20IncentiveClaimed,\n readErc20IncentiveClaims,\n readErc20IncentiveCurrentReward,\n readErc20IncentiveEntries,\n readErc20IncentiveIsClaimable,\n readErc20IncentiveLimit,\n readErc20IncentiveOwner,\n readErc20IncentiveReward,\n readErc20IncentiveStrategy,\n simulateErc20IncentiveClaim,\n simulateErc20IncentiveClawback,\n simulateErc20IncentiveDrawRaffle,\n writeErc20IncentiveClaim,\n writeErc20IncentiveClawback,\n writeErc20IncentiveDrawRaffle,\n} from '@boostxyz/evm';\nimport { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20Incentive.sol/ERC20Incentive.json';\nimport {\n type Address,\n type ContractEventName,\n type Hex,\n encodeAbiParameters,\n zeroAddress,\n zeroHash,\n} from 'viem';\nimport { ERC20Incentive as ERC20IncentiveBases } from '../../dist/deployments.json';\nimport type {\n DeployableOptions,\n GenericDeployableParams,\n} from '../Deployable/Deployable';\nimport { DeployableTarget } from '../Deployable/DeployableTarget';\nimport {\n type ClaimPayload,\n StrategyType,\n prepareClaimPayload,\n} from '../claiming';\nimport {\n type GenericLog,\n type ReadParams,\n RegistryType,\n type WriteParams,\n} from '../utils';\n\nexport { erc20IncentiveAbi };\n\n/**\n * The object representation of a `ERC20Incentive.InitPayload`\n *\n * @export\n * @interface ERC20IncentivePayload\n * @typedef {ERC20IncentivePayload}\n */\nexport interface ERC20IncentivePayload {\n /**\n * The address of the incentivized asset.\n *\n * @type {Address}\n */\n asset: Address;\n /**\n * The type of disbursement strategy for the incentive.\n *\n * @type {StrategyType}\n */\n strategy: StrategyType;\n /**\n * The amount of the asset to distribute.\n *\n * @type {bigint}\n */\n reward: bigint;\n /**\n * How many times can this incentive be claimed. This should ideally be 1n for `RAFFLE` strategy types.\n *\n * @type {bigint}\n */\n limit: bigint;\n /**\n * (Optional) The address of the entity that can trigger a raffle.\n * If omitted, the incentive will have no manager with permissions to draw the raffle.\n *\n * @type {Address}\n * @optional\n */\n manager?: Address;\n}\n\n/**\n * A generic `viem.Log` event with support for `ERC20Incentive` event types.\n *\n * @export\n * @typedef {ERC20IncentiveLog}\n * @template {ContractEventName<typeof erc20IncentiveAbi>} [event=ContractEventName<\n * typeof erc20IncentiveAbi\n * >]\n */\nexport type ERC20IncentiveLog<\n event extends ContractEventName<typeof erc20IncentiveAbi> = ContractEventName<\n typeof erc20IncentiveAbi\n >,\n> = GenericLog<typeof erc20IncentiveAbi, event>;\n\n/**\n * A simple ERC20 incentive implementation that allows claiming of tokens\n *\n * @export\n * @class ERC20Incentive\n * @typedef {ERC20Incentive}\n * @extends {DeployableTarget<ERC20IncentivePayload>}\n */\nexport class ERC20Incentive extends DeployableTarget<\n ERC20IncentivePayload,\n typeof erc20IncentiveAbi\n> {\n public override readonly abi = erc20IncentiveAbi;\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 ...(ERC20IncentiveBases 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 readErc20IncentiveOwner(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 readErc20IncentiveCurrentReward(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 readErc20IncentiveClaims(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 readErc20IncentiveClaimed(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 readErc20IncentiveAsset(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 strategy for the incentive (MINT or POOL)\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<StrategyType>}\n */\n public strategy(params?: ReadParams): Promise<StrategyType> {\n return readErc20IncentiveStrategy(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 }) as Promise<StrategyType>;\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 readErc20IncentiveReward(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 claims, or max entries for raffles)\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>}\n */\n public async limit(params?: ReadParams) {\n return await readErc20IncentiveLimit(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 set of addresses that have claimed a slot in the incentive raffle, accessed by bigint index.\n *\n * @public\n * @async\n * @param {bigint} i - Index of address\n * @param {?ReadParams} [params]\n * @returns {Promise<Address>}\n */\n public async entries(i: bigint, params?: ReadParams) {\n return await readErc20IncentiveEntries(this._config, {\n address: this.assertValidAddress(),\n args: [i],\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 simulateErc20IncentiveClaim(\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 writeErc20IncentiveClaim(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 simulateErc20IncentiveClawback(\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 writeErc20IncentiveClawback(this._config, request);\n return { hash, result };\n }\n\n /**\n * 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.\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 readErc20IncentiveIsClaimable(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 * Draw a winner from the raffle. Only callable by owner. Only valid when the strategy is set to `Strategy.RAFFLE`\n *\n * @public\n * @async\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async drawRaffle(params?: WriteParams) {\n return await this.awaitResult(this.drawRaffleRaw(params));\n }\n\n /**\n * Draw a winner from the raffle. Only callable by owner. Only valid when the strategy is set to `Strategy.RAFFLE`\n *\n * @public\n * @async\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: void; }>}\n */\n public async drawRaffleRaw(params?: WriteParams) {\n const { request, result } = await simulateErc20IncentiveDrawRaffle(\n this._config,\n {\n address: this.assertValidAddress(),\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 writeErc20IncentiveDrawRaffle(this._config, request);\n return { hash, result };\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 if (\n this.payload?.strategy !== undefined &&\n this.payload?.limit !== undefined &&\n this.payload?.reward !== undefined\n ) {\n return (this.payload.strategy as StrategyType) === StrategyType.POOL\n ? this.payload.limit * this.payload.reward\n : this.payload.reward;\n }\n const [strategy, limit, reward] = await Promise.all([\n this.strategy(params),\n this.limit(params),\n this.reward(params),\n ]);\n return strategy === StrategyType.POOL ? limit * reward : reward;\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 {?ERC20IncentivePayload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public override buildParameters(\n _payload?: ERC20IncentivePayload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n return {\n abi: erc20IncentiveAbi,\n bytecode: bytecode as Hex,\n args: [prepareERC20IncentivePayload(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 ERC20Incentive.\n *\n * @public\n * @returns {Hash} A `zeroHash`, as ERC20Incentive doesn't require specific claim data.\n * @description This function returns `zeroHash` because ERC20Incentive doesn't use any specific claim data.\n */\n public buildClaimData() {\n return zeroHash;\n }\n}\n\n/**\n * Given a {@link ERC20IncentivePayload}, properly encode a `ERC20Incentive.InitPayload` for use with {@link ERC20Incentive} initialization.\n *\n * @param {ERC20IncentivePayload} param0\n * @param {Address} param0.asset - The address of the incentivized asset.\n * @param {StrategyType} param0.strategy - The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`\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 draw raffles - defaults to unset\n * @returns {Hex}\n */\nexport function prepareERC20IncentivePayload({\n asset,\n strategy,\n reward,\n limit,\n manager = zeroAddress,\n}: ERC20IncentivePayload) {\n return encodeAbiParameters(\n [\n { type: 'address', name: 'asset' },\n { type: 'uint8', name: 'strategy' },\n { type: 'uint256', name: 'reward' },\n { type: 'uint256', name: 'limit' },\n { type: 'address', name: 'manager' },\n ],\n [\n asset,\n strategy,\n reward,\n // unclear how user set limit should work for raffle, so in order to avoid passing 0's let's correct it\n limit === 0n && strategy === StrategyType.RAFFLE ? 1n : limit,\n manager,\n ],\n );\n}\n"],"names":["_ERC20Incentive","DeployableTarget","erc20IncentiveAbi","params","readErc20IncentiveOwner","readErc20IncentiveCurrentReward","readErc20IncentiveClaims","address","readErc20IncentiveClaimed","readErc20IncentiveAsset","readErc20IncentiveStrategy","readErc20IncentiveReward","readErc20IncentiveLimit","i","readErc20IncentiveEntries","payload","request","result","simulateErc20IncentiveClaim","prepareClaimPayload","writeErc20IncentiveClaim","simulateErc20IncentiveClawback","writeErc20IncentiveClawback","readErc20IncentiveIsClaimable","simulateErc20IncentiveDrawRaffle","writeErc20IncentiveDrawRaffle","_a","_b","_c","StrategyType","strategy","limit","reward","claims","_payload","_options","options","bytecode","prepareERC20IncentivePayload","amount","encodeAbiParameters","zeroHash","ERC20IncentiveBases","RegistryType","ERC20Incentive","asset","manager","zeroAddress"],"mappings":";;;;;;4iuBAiHaA,IAAN,MAAMA,UAAuBC,EAGlC;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,EAAwB,KAAK,SAAS;AAAA,MACjD,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,EAAgC,KAAK,SAAS;AAAA,MACzD,SAAS,KAAK,mBAAmB;AAAA,MACjC,MAAM,CAAC;AAAA;AAAA,MAEP,GAAIF;AAAA,IAAA,CACL;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,iBAAiB;AACf,WAAAE;AAAA,EACT;AACF;AArYEzC,EAAuB,QAAiC;AAAA,EACtD,OAAO;AAAA,EACP,GAAI0C;AAAA,GASN1C,EAAuB,eAA6B2C,EAAa;AAvB5D,IAAMC,IAAN5C;AA8ZA,SAASsC,EAA6B;AAAA,EAC3C,OAAAO;AAAA,EACA,UAAAf;AAAA,EACA,QAAAE;AAAA,EACA,OAAAD;AAAA,EACA,SAAAe,IAAUC;AACZ,GAA0B;AACjB,SAAAP;AAAA,IACL;AAAA,MACE,EAAE,MAAM,WAAW,MAAM,QAAQ;AAAA,MACjC,EAAE,MAAM,SAAS,MAAM,WAAW;AAAA,MAClC,EAAE,MAAM,WAAW,MAAM,SAAS;AAAA,MAClC,EAAE,MAAM,WAAW,MAAM,QAAQ;AAAA,MACjC,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,IACrC;AAAA,IACA;AAAA,MACEK;AAAA,MACAf;AAAA,MACAE;AAAA;AAAA,MAEAD,MAAU,MAAMD,MAAaD,EAAa,SAAS,KAAKE;AAAA,MACxDe;AAAA,IACF;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"ERC20Incentive.js","sources":["../../src/Incentives/ERC20Incentive.ts"],"sourcesContent":["import {\n erc20IncentiveAbi,\n readErc20IncentiveAsset,\n readErc20IncentiveClaimed,\n readErc20IncentiveClaims,\n readErc20IncentiveCurrentReward,\n readErc20IncentiveEntries,\n readErc20IncentiveIsClaimable,\n readErc20IncentiveLimit,\n readErc20IncentiveOwner,\n readErc20IncentiveReward,\n readErc20IncentiveStrategy,\n simulateErc20IncentiveClaim,\n simulateErc20IncentiveClawback,\n simulateErc20IncentiveDrawRaffle,\n writeErc20IncentiveClaim,\n writeErc20IncentiveClawback,\n writeErc20IncentiveDrawRaffle,\n} from '@boostxyz/evm';\nimport { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20Incentive.sol/ERC20Incentive.json';\nimport {\n type Address,\n type ContractEventName,\n type Hex,\n encodeAbiParameters,\n zeroAddress,\n zeroHash,\n} from 'viem';\nimport { ERC20Incentive as ERC20IncentiveBases } from '../../dist/deployments.json';\nimport type {\n DeployableOptions,\n GenericDeployableParams,\n} from '../Deployable/Deployable';\nimport { DeployableTarget } from '../Deployable/DeployableTarget';\nimport {\n type ClaimPayload,\n StrategyType,\n prepareClaimPayload,\n} from '../claiming';\nimport {\n type GenericLog,\n type ReadParams,\n RegistryType,\n type WriteParams,\n} from '../utils';\n\nexport { erc20IncentiveAbi };\n\n/**\n * The object representation of a `ERC20Incentive.InitPayload`\n *\n * @export\n * @interface ERC20IncentivePayload\n * @typedef {ERC20IncentivePayload}\n */\nexport interface ERC20IncentivePayload {\n /**\n * The address of the incentivized asset.\n *\n * @type {Address}\n */\n asset: Address;\n /**\n * The type of disbursement strategy for the incentive.\n *\n * @type {StrategyType}\n */\n strategy: StrategyType;\n /**\n * The amount of the asset to distribute.\n *\n * @type {bigint}\n */\n reward: bigint;\n /**\n * How many times can this incentive be claimed. This should ideally be 1n for `RAFFLE` strategy types.\n *\n * @type {bigint}\n */\n limit: bigint;\n /**\n * (Optional) The address of the entity that can trigger a raffle.\n * If omitted, the incentive will have no manager with permissions to draw the raffle.\n *\n * @type {Address}\n * @optional\n */\n manager?: Address;\n}\n\n/**\n * A generic `viem.Log` event with support for `ERC20Incentive` event types.\n *\n * @export\n * @typedef {ERC20IncentiveLog}\n * @template {ContractEventName<typeof erc20IncentiveAbi>} [event=ContractEventName<\n * typeof erc20IncentiveAbi\n * >]\n */\nexport type ERC20IncentiveLog<\n event extends ContractEventName<typeof erc20IncentiveAbi> = ContractEventName<\n typeof erc20IncentiveAbi\n >,\n> = GenericLog<typeof erc20IncentiveAbi, event>;\n\n/**\n * A simple ERC20 incentive implementation that allows claiming of tokens\n *\n * @export\n * @class ERC20Incentive\n * @typedef {ERC20Incentive}\n * @extends {DeployableTarget<ERC20IncentivePayload>}\n */\nexport class ERC20Incentive extends DeployableTarget<\n ERC20IncentivePayload,\n typeof erc20IncentiveAbi\n> {\n public override readonly abi = erc20IncentiveAbi;\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 ...(ERC20IncentiveBases 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 readErc20IncentiveOwner(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 readErc20IncentiveCurrentReward(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 readErc20IncentiveClaims(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 readErc20IncentiveClaimed(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 readErc20IncentiveAsset(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 strategy for the incentive (MINT or POOL)\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<StrategyType>}\n */\n public strategy(params?: ReadParams): Promise<StrategyType> {\n return readErc20IncentiveStrategy(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 }) as Promise<StrategyType>;\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 readErc20IncentiveReward(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 claims, or max entries for raffles)\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>}\n */\n public async limit(params?: ReadParams) {\n return await readErc20IncentiveLimit(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 set of addresses that have claimed a slot in the incentive raffle, accessed by bigint index.\n *\n * @public\n * @async\n * @param {bigint} i - Index of address\n * @param {?ReadParams} [params]\n * @returns {Promise<Address>}\n */\n public async entries(i: bigint, params?: ReadParams) {\n return await readErc20IncentiveEntries(this._config, {\n address: this.assertValidAddress(),\n args: [i],\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 simulateErc20IncentiveClaim(\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 writeErc20IncentiveClaim(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 simulateErc20IncentiveClawback(\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 writeErc20IncentiveClawback(this._config, request);\n return { hash, result };\n }\n\n /**\n * 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.\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 readErc20IncentiveIsClaimable(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 * Draw a winner from the raffle. Only callable by owner. Only valid when the strategy is set to `Strategy.RAFFLE`\n *\n * @public\n * @async\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async drawRaffle(params?: WriteParams) {\n return await this.awaitResult(this.drawRaffleRaw(params));\n }\n\n /**\n * Draw a winner from the raffle. Only callable by owner. Only valid when the strategy is set to `Strategy.RAFFLE`\n *\n * @public\n * @async\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: void; }>}\n */\n public async drawRaffleRaw(params?: WriteParams) {\n const { request, result } = await simulateErc20IncentiveDrawRaffle(\n this._config,\n {\n address: this.assertValidAddress(),\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 writeErc20IncentiveDrawRaffle(this._config, request);\n return { hash, result };\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 if (\n this.payload?.strategy !== undefined &&\n this.payload?.limit !== undefined &&\n this.payload?.reward !== undefined\n ) {\n return (this.payload.strategy as StrategyType) === StrategyType.POOL\n ? this.payload.limit * this.payload.reward\n : this.payload.reward;\n }\n const [strategy, limit, reward] = await Promise.all([\n this.strategy(params),\n this.limit(params),\n this.reward(params),\n ]);\n return strategy === StrategyType.POOL ? limit * reward : reward;\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 {?ERC20IncentivePayload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public override buildParameters(\n _payload?: ERC20IncentivePayload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n return {\n abi: erc20IncentiveAbi,\n bytecode: bytecode as Hex,\n args: [prepareERC20IncentivePayload(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 ERC20Incentive.\n *\n * @public\n * @returns {Hash} A `zeroHash`, as ERC20Incentive doesn't require specific claim data.\n * @description This function returns `zeroHash` because ERC20Incentive doesn't use any specific claim data.\n */\n public buildClaimData() {\n return zeroHash;\n }\n}\n\n/**\n * Given a {@link ERC20IncentivePayload}, properly encode a `ERC20Incentive.InitPayload` for use with {@link ERC20Incentive} initialization.\n *\n * @param {ERC20IncentivePayload} param0\n * @param {Address} param0.asset - The address of the incentivized asset.\n * @param {StrategyType} param0.strategy - The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`\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 draw raffles - defaults to unset\n * @returns {Hex}\n */\nexport function prepareERC20IncentivePayload({\n asset,\n strategy,\n reward,\n limit,\n manager = zeroAddress,\n}: ERC20IncentivePayload) {\n return encodeAbiParameters(\n [\n { type: 'address', name: 'asset' },\n { type: 'uint8', name: 'strategy' },\n { type: 'uint256', name: 'reward' },\n { type: 'uint256', name: 'limit' },\n { type: 'address', name: 'manager' },\n ],\n [\n asset,\n strategy,\n reward,\n // unclear how user set limit should work for raffle, so in order to avoid passing 0's let's correct it\n limit === 0n && strategy === StrategyType.RAFFLE ? 1n : limit,\n manager,\n ],\n );\n}\n"],"names":["_ERC20Incentive","DeployableTarget","erc20IncentiveAbi","params","readErc20IncentiveOwner","readErc20IncentiveCurrentReward","readErc20IncentiveClaims","address","readErc20IncentiveClaimed","readErc20IncentiveAsset","readErc20IncentiveStrategy","readErc20IncentiveReward","readErc20IncentiveLimit","i","readErc20IncentiveEntries","payload","request","result","simulateErc20IncentiveClaim","prepareClaimPayload","writeErc20IncentiveClaim","simulateErc20IncentiveClawback","writeErc20IncentiveClawback","readErc20IncentiveIsClaimable","simulateErc20IncentiveDrawRaffle","writeErc20IncentiveDrawRaffle","_a","_b","_c","StrategyType","strategy","limit","reward","claims","_payload","_options","options","bytecode","prepareERC20IncentivePayload","amount","encodeAbiParameters","zeroHash","ERC20IncentiveBases","RegistryType","ERC20Incentive","asset","manager","zeroAddress"],"mappings":";;;;;;ojuBAiHaA,IAAN,MAAMA,UAAuBC,EAGlC;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,EAAwB,KAAK,SAAS;AAAA,MACjD,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,EAAgC,KAAK,SAAS;AAAA,MACzD,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,EAAyB,KAAK,SAAS;AAAA,MAClD,SAAS,KAAK,mBAAmB;AAAA,MACjC,MAAM,CAAC;AAAA;AAAA,MAEP,GAAIH;AAAA,IAAA,CACL;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAa,QAAQI,GAAkBJ,GAAqB;AACnD,WAAA,MAAMK,EAA0B,KAAK,SAAS;AAAA,MACnD,SAAS,KAAK,mBAAmB;AAAA,MACjC,MAAM,CAACD,CAAO;AAAA;AAAA,MAEd,GAAIJ;AAAA,IAAA,CACL;AAAA,EACH;AAAA;AA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