@boostxyz/sdk 8.0.0-canary.2 → 8.0.0-canary.3

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../generated-Cf82M-QP.cjs"),p=require("@wagmi/core"),n=require("viem"),A=require("../deployments-DimWVnA4.cjs"),r=require("../Actions/EventAction.cjs"),i=require("../errors.cjs"),T=require("../utils.cjs"),v=require("./ERC20VariableIncentive.cjs"),w="0x6080604052348015600e575f80fd5b5060156019565b607c565b63409feecd198054600181161560365763f92ee8a95f526004601cfd5b6001600160401b03808260011c146077578060011b8355806020527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602080a15b505050565b6121c8806100895f395ff3fe608060405260043610610277575f3560e01c8063715018a61161014b578063c884ef83116100c6578063ec87621c1161007c578063f2fde38b11610062578063f2fde38b14610729578063fe9fbb801461073c578063fee81cf41461075b575f80fd5b8063ec87621c14610702578063f04e283e14610716575f80fd5b8063db09da12116100ac578063db09da12146106af578063dcc21361146106ce578063dcc59b6f146106ed575f80fd5b8063c884ef831461066c578063d54ad2a11461069a575f80fd5b8063a4d66daf1161011b578063bb1757cf11610101578063bb1757cf1461061a578063be4994f814610639578063c213f3f914610658575f80fd5b8063a4d66daf146105e4578063a871ced2146105f9575f80fd5b8063715018a61461053857806375b238fc1461054057806377548687146105545780638da5cb5b146105cc575f80fd5b806330db555f116101f55780634a4ee7b1116101ab578063514e62fc11610191578063514e62fc146104e657806354d1f13d1461051b57806366a78e6c14610523575f80fd5b80634a4ee7b1146104a75780634e7165a2146104ba575f80fd5b80634359d28a116101db5780634359d28a14610420578063439fab911461043f578063474f5a441461045e575f80fd5b806330db555f146103b057806338d52e0f146103cf575f80fd5b80631cd64df41161024a5780632569296211610230578063256929621461033d57806328d6183b146103455780632de948071461037f575f80fd5b80631cd64df4146102f4578063228cb73314610329575f80fd5b806301ffc9a71461027b57806307621eca146102af578063183a4f6e146102cc5780631c10893f146102e1575b5f80fd5b348015610286575f80fd5b5061029a6102953660046118ed565b61078c565b60405190151581526020015b60405180910390f35b3480156102ba575f80fd5b505f545b6040519081526020016102a6565b6102df6102da366004611933565b6107e7565b005b6102df6102ef36600461196b565b6107f4565b3480156102ff575f80fd5b5061029a61030e36600461196b565b638b78c6d8600c9081525f9290925260209091205481161490565b348015610334575f80fd5b506102be5f5481565b6102df61080a565b348015610350575f80fd5b506040517f52b8e45c0000000000000000000000000000000000000000000000000000000081526020016102a6565b34801561038a575f80fd5b506102be610399366004611995565b638b78c6d8600c9081525f91909152602090205490565b3480156103bb575f80fd5b506102df6103ca366004611933565b610857565b3480156103da575f80fd5b506003546103fb9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016102a6565b34801561042b575f80fd5b506102df61043a3660046119f8565b610913565b34801561044a575f80fd5b506102df610459366004611aa2565b610a0d565b348015610469575f80fd5b5061047d610478366004611aa2565b610d5f565b6040805192835273ffffffffffffffffffffffffffffffffffffffff9091166020830152016102a6565b6102df6104b536600461196b565b610ec1565b3480156104c5575f80fd5b506104d96104d4366004611aa2565b610ed3565b6040516102a69190611b2d565b3480156104f1575f80fd5b5061029a61050036600461196b565b638b78c6d8600c9081525f9290925260209091205416151590565b6102df610fbc565b34801561052e575f80fd5b506102be60065481565b6102df610ff5565b34801561054b575f80fd5b506102be600281565b34801561055f575f80fd5b506007546008546009546105bb9260ff908116929163ffffffff81169173ffffffffffffffffffffffffffffffffffffffff64010000000083041691780100000000000000000000000000000000000000000000000090041685565b6040516102a6959493929190611b7c565b3480156105d7575f80fd5b50638b78c6d819546103fb565b3480156105ef575f80fd5b506102be60025481565b348015610604575f80fd5b5061060d611008565b6040516102a69190611c35565b348015610625575f80fd5b5061029a610634366004611c43565b6110f7565b348015610644575f80fd5b506102df6106533660046119f8565b611328565b348015610663575f80fd5b506006546102be565b348015610677575f80fd5b5061029a610686366004611995565b60016020525f908152604090205460ff1681565b3480156106a5575f80fd5b506102be60055481565b3480156106ba575f80fd5b5061029a6106c9366004611c43565b6113c6565b3480156106d9575f80fd5b506102df6106e83660046119f8565b6113dc565b3480156106f8575f80fd5b506102be60045481565b34801561070d575f80fd5b506102be600181565b6102df610724366004611995565b61147a565b6102df610737366004611995565b6114b4565b348015610747575f80fd5b5061029a610756366004611995565b6114da565b348015610766575f80fd5b506102be610775366004611995565b63389a75e1600c9081525f91909152602090205490565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f52b8e45c0000000000000000000000000000000000000000000000000000000014806107e157506107e182611539565b92915050565b6107f1338261158e565b50565b6107fc611599565b61080682826115b3565b5050565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a250565b6001610862816115bf565b815f0361089b576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6003546108c09073ffffffffffffffffffffffffffffffffffffffff163330856115f0565b8160025f8282546108d19190611cc1565b909155505060408051338152602081018490527fa64c2da41decbd538f8629e54c8fa0b7362c9102b691386a0fb6a1797454e9c6910160405180910390a15050565b600261091e816115bf565b838214610957576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b84811015610a05575f84848381811061097457610974611cd4565b90506020020160208101906109899190611d01565b90508015156001036109cb576109c68787848181106109aa576109aa611cd4565b90506020020160208101906109bf9190611995565b60016115b3565b6109fc565b6109fc8787848181106109e0576109e0611cd4565b90506020020160208101906109f59190611995565b600161158e565b50600101610959565b505050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf6011328054600382558015610a5e5760018160011c14303b10610a555763f92ee8a95f526004601cfd5b818160ff1b1b91505b505f610a6c83850185611db5565b805160208201516040830151606084015160808501519495509293919290915f839003610ac5576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f610ae673ffffffffffffffffffffffffffffffffffffffff871630611652565b905083811015610b4f5786516040517f5c54305e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018290526044810185905260640160405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff88161790555f8581556002859055600684905560055581516007805484929082907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660018381811115610be057610be0611b3f565b021790555060208201516001808301919091556040830151600283018054606086015173ffffffffffffffffffffffffffffffffffffffff16640100000000027fffffffffffffffff00000000000000000000000000000000000000000000000090911663ffffffff90931692909217919091178082556080850151927fffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffffffff909116907801000000000000000000000000000000000000000000000000908490811115610cae57610cae611b3f565b0217905550905050610cbf33611685565b610cca3360016116cd565b8573ffffffffffffffffffffffffffffffffffffffff167f742256c25dbd8c1cb315d87101bae0f6fc7656686d10d32d27fc2765ce9ccb9c86868686604051610d169493929190611ea0565b60405180910390a2505050505050508015610d5a576002815560016020527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602080a15b505050565b5f806001610d6c816115bf565b5f610d7985870187611f75565b90505f8160200151806020019051810190610d949190611ff4565b90508060025f828254610da7919061200b565b90915550508151600354610dd49173ffffffffffffffffffffffffffffffffffffffff909116908361170e565b81516003546040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606092831b811660208301529183901b90911660348201526048810183905273ffffffffffffffffffffffffffffffffffffffff909116907f9ad2e7a4af16dceda9cce4274b2f59c328d8c012eb0e15eb5e1e73b7d8f264d390606801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815290829052610e9291611b2d565b60405180910390a260035490945073ffffffffffffffffffffffffffffffffffffffff16925050509250929050565b610ec9611599565b610806828261158e565b60605f80610ee38486018661201e565b9250509150604051806080016040528060016002811115610f0657610f06611b3f565b81526020018373ffffffffffffffffffffffffffffffffffffffff1681526020013073ffffffffffffffffffffffffffffffffffffffff168152602001604051806020016040528084815250604051602001610f659151815260200190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152918152915251610fa39190602001612050565b6040516020818303038152906040529250505092915050565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2565b610ffd611599565b6110065f611761565b565b6040805160a0810182525f808252602082018190529181018290526060810182905260808101919091526040805160a0810190915260078054829060ff16600181111561105757611057611b3f565b600181111561106857611068611b3f565b81526001828101546020830152600283015463ffffffff81166040840152640100000000810473ffffffffffffffffffffffffffffffffffffffff1660608401526080909201917801000000000000000000000000000000000000000000000000900460ff16908111156110de576110de611b3f565b60018111156110ef576110ef611b3f565b905250919050565b5f611100611599565b5f61110d838501856120c6565b90505f81602001518060200190518101906111289190611ff4565b90505f6111386002546005541090565b61116e576040517f6247a84e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f545f0361117d5750806111a0565b670de0b6b3a7640000825f546111939190612143565b61119d919061215a565b90505b600654158015906111b2575060065481115b156111bc57506006545b600254816005546111cd9190611cc1565b1115611205576040517f360e42e100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060055f8282546112169190611cc1565b92505081905550600160045f82825461122f9190611cc1565b90915550506003546112589073ffffffffffffffffffffffffffffffffffffffff16888361170e565b6003546040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606092831b811660208301529189901b90911660348201526048810182905273ffffffffffffffffffffffffffffffffffffffff8816907f9ad2e7a4af16dceda9cce4274b2f59c328d8c012eb0e15eb5e1e73b7d8f264d390606801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905261131391611b2d565b60405180910390a25060019695505050505050565b6002611333816115bf565b83821461136c576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b84811015610a05576113be86868381811061138b5761138b611cd4565b90506020020160208101906113a09190611995565b8585848181106113b2576113b2611cd4565b905060200201356115b3565b60010161136e565b5f6113d46002546005541090565b949350505050565b60026113e7816115bf565b838214611420576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b84811015610a055761147286868381811061143f5761143f611cd4565b90506020020160208101906114549190611995565b85858481811061146657611466611cd4565b9050602002013561158e565b600101611422565b611482611599565b63389a75e1600c52805f526020600c2080544211156114a857636f5e88185f526004601cfd5b5f90556107f181611761565b6114bc611599565b8060601b6114d157637448fbae5f526004601cfd5b6107f181611761565b5f8173ffffffffffffffffffffffffffffffffffffffff166114ff638b78c6d8195490565b73ffffffffffffffffffffffffffffffffffffffff1614806107e15750638b78c6d8600c9081525f839052602090205460031615156107e1565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f903181110000000000000000000000000000000000000000000000000000000014806107e157506107e1826117ab565b61080682825f611800565b638b78c6d819543314611006576382b429005f526004601cfd5b61080682826001611800565b638b78c6d8195433146107f157638b78c6d8600c52335f52806020600c2054166107f1576382b429005f526004601cfd5b60405181606052826040528360601b602c526f23b872dd000000000000000000000000600c5260205f6064601c5f895af18060015f51141661164457803d873b15171061164457637939f4245f526004601cfd5b505f60605260405250505050565b5f816014526f70a082310000000000000000000000005f5260208060246010865afa601f3d111660205102905092915050565b73ffffffffffffffffffffffffffffffffffffffff16638b78c6d819819055805f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b638b78c6d8600c52815f52806020600c205580600c5160601c7f715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe265f80a35050565b81601452806034526fa9059cbb0000000000000000000000005f5260205f604460105f875af18060015f51141661175757803d853b151710611757576390b8ec185f526004601cfd5b505f603452505050565b638b78c6d819805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a355565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167fa92167050000000000000000000000000000000000000000000000000000000014806107e157506107e182611857565b638b78c6d8600c52825f526020600c20805483811783611821575080841681185b80835580600c5160601c7f715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe265f80a3505050505050565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f6ab67a0d0000000000000000000000000000000000000000000000000000000014806107e157507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107e1565b5f602082840312156118fd575f80fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461192c575f80fd5b9392505050565b5f60208284031215611943575f80fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff811681146107f1575f80fd5b5f806040838503121561197c575f80fd5b82356119878161194a565b946020939093013593505050565b5f602082840312156119a5575f80fd5b813561192c8161194a565b5f8083601f8401126119c0575f80fd5b50813567ffffffffffffffff8111156119d7575f80fd5b6020830191508360208260051b85010111156119f1575f80fd5b9250929050565b5f805f8060408587031215611a0b575f80fd5b843567ffffffffffffffff811115611a21575f80fd5b611a2d878288016119b0565b909550935050602085013567ffffffffffffffff811115611a4c575f80fd5b611a58878288016119b0565b95989497509550505050565b5f8083601f840112611a74575f80fd5b50813567ffffffffffffffff811115611a8b575f80fd5b6020830191508360208285010111156119f1575f80fd5b5f8060208385031215611ab3575f80fd5b823567ffffffffffffffff811115611ac9575f80fd5b611ad585828601611a64565b90969095509350505050565b5f81518084528060208401602086015e5f6020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b602081525f61192c6020830184611ae1565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b600281106107f1576107f1611b3f565b60a08101611b8987611b6c565b86825285602083015263ffffffff8516604083015273ffffffffffffffffffffffffffffffffffffffff84166060830152611bc383611b6c565b8260808301529695505050505050565b8051611bde81611b6c565b808352506020810151602083015263ffffffff604082015116604083015273ffffffffffffffffffffffffffffffffffffffff60608201511660608301526080810151611c2a81611b6c565b806080840152505050565b60a081016107e18284611bd3565b5f805f60408486031215611c55575f80fd5b8335611c608161194a565b9250602084013567ffffffffffffffff811115611c7b575f80fd5b611c8786828701611a64565b9497909650939450505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b808201808211156107e1576107e1611c94565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f60208284031215611d11575f80fd5b8135801515811461192c575f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b60405160a0810167ffffffffffffffff81118282101715611d7057611d70611d20565b60405290565b6040805190810167ffffffffffffffff81118282101715611d7057611d70611d20565b600281106107f1575f80fd5b8035611db081611d99565b919050565b5f81830361012081128015611dc8575f80fd5b50611dd1611d4d565b8335611ddc8161194a565b815260208481013590820152604080850135908201526060808501359082015260a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8083011215611e2b575f80fd5b611e33611d4d565b91506080840135611e4381611d99565b825260a0840135602083015260c084013563ffffffff81168114611e65575f80fd5b604083015260e0840135611e788161194a565b6060830152611e8a6101008501611da5565b6080830152816080820152809250505092915050565b84815260208101849052604081018390526101008101611ec36060830184611bd3565b95945050505050565b5f82601f830112611edb575f80fd5b813567ffffffffffffffff811115611ef557611ef5611d20565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810167ffffffffffffffff81118282101715611f4257611f42611d20565b604052818152838201602001851015611f59575f80fd5b816020850160208301375f918101602001919091529392505050565b5f60208284031215611f85575f80fd5b813567ffffffffffffffff811115611f9b575f80fd5b820160408185031215611fac575f80fd5b611fb4611d76565b8135611fbf8161194a565b8152602082013567ffffffffffffffff811115611fda575f80fd5b611fe686828501611ecc565b602083015250949350505050565b5f60208284031215612004575f80fd5b5051919050565b818103818111156107e1576107e1611c94565b5f805f60608486031215612030575f80fd5b833561203b8161194a565b95602085013595506040909401359392505050565b602081525f82516003811061206757612067611b3f565b8060208401525073ffffffffffffffffffffffffffffffffffffffff602084015116604083015273ffffffffffffffffffffffffffffffffffffffff604084015116606083015260608301516080808401526113d460a0840182611ae1565b5f602082840312156120d6575f80fd5b813567ffffffffffffffff8111156120ec575f80fd5b8201604081850312156120fd575f80fd5b612105611d76565b813567ffffffffffffffff81111561211b575f80fd5b61212786828501611ecc565b825250602082013567ffffffffffffffff811115611fda575f80fd5b80820281158282048414176107e1576107e1611c94565b5f8261218d577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b50049056fea264697066735822122069f0df25d1ca7c14d80738715391c4a4b217c6b7362908da91c6fbdcc629bf6364736f6c634300081a0033",y={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_BOOST_MAINNET_SIGNER_EOA:"0xCBD0C302040bC803B4B2EDaF21Be0e49Deff5480",VITE_BOOST_TESTNET_SIGNER_EOA:"0xd63167e9db11B108940b2E8236581F961f33f396"},m=class m extends v.ERC20VariableIncentive{constructor(){super(...arguments),this.abi=s.f}async getIncentiveCriteria(e){try{return await s.CH(this._config,{...e,address:this.assertValidAddress()})}catch(a){throw new i.IncentiveCriteriaNotFoundError(a)}}async decodeClaimData(e){const a=n.decodeAbiParameters([{type:"tuple",name:"BoostClaimData",components:[{type:"bytes",name:"validatorData"},{type:"bytes",name:"incentiveData"}]}],e),t=n.decodeAbiParameters([{type:"uint256"}],a[0].incentiveData)[0];let b=t;const[o,f]=await Promise.all([this.reward(),this.getMaxReward()]);return o===0n||(b=o*t/n.parseEther("1"),f!==0n&&b>f&&(b=f)),b}async getMaxReward(e){return await s.OH(this._config,{...e,address:this.assertValidAddress()})}async getIncentiveScalar({chainId:e,hash:a,knownSignatures:t,logs:b},o){var C;const f=await this.getIncentiveCriteria(o);if(f.criteriaType===r.SignatureType.EVENT){const g=t[f.signature];if(f.fieldIndex===T.CheatCodes.GAS_REBATE_INCENTIVE){const d=await p.getTransactionReceipt(this._config,{chainId:e,hash:a});return d.gasUsed*d.effectiveGasPrice+(d.blobGasUsed??0n)*(d.blobGasPrice??0n)}if(b&&b.length>0)try{const d=b.filter(c=>c.topics&&c.topics[0]===f.signature).map(c=>r.decodeAndReorderLogArgs(g,c));if(d.length>0)for(const c of d)try{return r.getScalarValue(c.args,f.fieldIndex)}catch{continue}}catch(d){throw new i.DecodedArgsError(`An error occurred while extracting scalar from logs: ${d.message}`)}const l=(await p.getTransactionReceipt(this._config,{chainId:e,hash:a})).logs;if(l.length===0)throw new i.NoMatchingLogsError(`No logs found for event signature ${f.signature}`);try{const d=t[f.signature],c=n.parseEventLogs({abi:[d],logs:l});if(c==null||c.length===0)throw new i.NoMatchingLogsError(`No logs found for event signature ${f.signature}`);return r.getScalarValue((C=c[0])==null?void 0:C.args,f.fieldIndex)}catch(d){throw new i.DecodedArgsError(`Failed to decode event log for signature ${f.signature}: ${d.message}`)}}else if(f.criteriaType===r.SignatureType.FUNC){const g=await p.getTransaction(this._config,{chainId:e,hash:a});try{const u=t[f.signature],l=n.decodeFunctionData({abi:[u],data:g.input});return r.getScalarValue(l.args,f.fieldIndex)}catch(u){throw new i.DecodedArgsError(`Failed to decode function data for signature ${f.signature}: ${u.message}`)}}else throw new i.InvalidCriteriaTypeError(`Invalid criteria type ${f.criteriaType}`)}buildParameters(e,a){const[t,b]=this.validateDeploymentConfig(e,a);return{abi:s.f,bytecode:w,args:[I(t)],...this.optionallyAttachAccount(b.account)}}};m.bases={...y!=null&&y.VITE_ERC20_VARIABLE_CRITERIA_INCENTIVE_V2_BASE?{31337:void 0}:{},...A.ERC20VariableCriteriaIncentiveV2};let E=m;function R(){return{criteriaType:r.SignatureType.EVENT,signature:n.zeroHash,fieldIndex:T.CheatCodes.GAS_REBATE_INCENTIVE,targetContract:n.zeroAddress,valueType:r.ValueType.WAD}}function I({asset:h,reward:e,limit:a,maxReward:t=0n,criteria:b}){return n.encodeAbiParameters([{type:"tuple",name:"initPayloadExtended",components:[{type:"address",name:"asset"},{type:"uint256",name:"reward"},{type:"uint256",name:"limit"},{type:"uint256",name:"maxReward"},{type:"tuple",name:"criteria",components:[{type:"uint8",name:"criteriaType"},{type:"bytes32",name:"signature"},{type:"uint8",name:"fieldIndex"},{type:"address",name:"targetContract"},{type:"uint8",name:"valueType"}]}]}],[{asset:h,reward:e,limit:a,maxReward:t,criteria:{criteriaType:b.criteriaType,signature:b.signature,fieldIndex:b.fieldIndex,targetContract:b.targetContract,valueType:b.valueType}}])}exports.erc20VariableCriteriaIncentiveV2Abi=s.f;exports.ERC20VariableCriteriaIncentiveV2=E;exports.gasRebateIncentiveCriteriaV2=R;exports.prepareERC20VariableCriteriaIncentiveV2Payload=I;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../generated-Cf82M-QP.cjs"),p=require("@wagmi/core"),n=require("viem"),A=require("../deployments-DimWVnA4.cjs"),r=require("../Actions/EventAction.cjs"),i=require("../errors.cjs"),T=require("../utils.cjs"),v=require("./ERC20VariableIncentive.cjs"),w="0x6080604052348015600e575f80fd5b5060156019565b607c565b63409feecd198054600181161560365763f92ee8a95f526004601cfd5b6001600160401b03808260011c146077578060011b8355806020527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602080a15b505050565b6121c8806100895f395ff3fe608060405260043610610277575f3560e01c8063715018a61161014b578063c884ef83116100c6578063ec87621c1161007c578063f2fde38b11610062578063f2fde38b14610729578063fe9fbb801461073c578063fee81cf41461075b575f80fd5b8063ec87621c14610702578063f04e283e14610716575f80fd5b8063db09da12116100ac578063db09da12146106af578063dcc21361146106ce578063dcc59b6f146106ed575f80fd5b8063c884ef831461066c578063d54ad2a11461069a575f80fd5b8063a4d66daf1161011b578063bb1757cf11610101578063bb1757cf1461061a578063be4994f814610639578063c213f3f914610658575f80fd5b8063a4d66daf146105e4578063a871ced2146105f9575f80fd5b8063715018a61461053857806375b238fc1461054057806377548687146105545780638da5cb5b146105cc575f80fd5b806330db555f116101f55780634a4ee7b1116101ab578063514e62fc11610191578063514e62fc146104e657806354d1f13d1461051b57806366a78e6c14610523575f80fd5b80634a4ee7b1146104a75780634e7165a2146104ba575f80fd5b80634359d28a116101db5780634359d28a14610420578063439fab911461043f578063474f5a441461045e575f80fd5b806330db555f146103b057806338d52e0f146103cf575f80fd5b80631cd64df41161024a5780632569296211610230578063256929621461033d57806328d6183b146103455780632de948071461037f575f80fd5b80631cd64df4146102f4578063228cb73314610329575f80fd5b806301ffc9a71461027b57806307621eca146102af578063183a4f6e146102cc5780631c10893f146102e1575b5f80fd5b348015610286575f80fd5b5061029a6102953660046118ed565b61078c565b60405190151581526020015b60405180910390f35b3480156102ba575f80fd5b505f545b6040519081526020016102a6565b6102df6102da366004611933565b6107e7565b005b6102df6102ef36600461196b565b6107f4565b3480156102ff575f80fd5b5061029a61030e36600461196b565b638b78c6d8600c9081525f9290925260209091205481161490565b348015610334575f80fd5b506102be5f5481565b6102df61080a565b348015610350575f80fd5b506040517f52b8e45c0000000000000000000000000000000000000000000000000000000081526020016102a6565b34801561038a575f80fd5b506102be610399366004611995565b638b78c6d8600c9081525f91909152602090205490565b3480156103bb575f80fd5b506102df6103ca366004611933565b610857565b3480156103da575f80fd5b506003546103fb9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016102a6565b34801561042b575f80fd5b506102df61043a3660046119f8565b610913565b34801561044a575f80fd5b506102df610459366004611aa2565b610a0d565b348015610469575f80fd5b5061047d610478366004611aa2565b610d5f565b6040805192835273ffffffffffffffffffffffffffffffffffffffff9091166020830152016102a6565b6102df6104b536600461196b565b610ec1565b3480156104c5575f80fd5b506104d96104d4366004611aa2565b610ed3565b6040516102a69190611b2d565b3480156104f1575f80fd5b5061029a61050036600461196b565b638b78c6d8600c9081525f9290925260209091205416151590565b6102df610fbc565b34801561052e575f80fd5b506102be60065481565b6102df610ff5565b34801561054b575f80fd5b506102be600281565b34801561055f575f80fd5b506007546008546009546105bb9260ff908116929163ffffffff81169173ffffffffffffffffffffffffffffffffffffffff64010000000083041691780100000000000000000000000000000000000000000000000090041685565b6040516102a6959493929190611b7c565b3480156105d7575f80fd5b50638b78c6d819546103fb565b3480156105ef575f80fd5b506102be60025481565b348015610604575f80fd5b5061060d611008565b6040516102a69190611c35565b348015610625575f80fd5b5061029a610634366004611c43565b6110f7565b348015610644575f80fd5b506102df6106533660046119f8565b611328565b348015610663575f80fd5b506006546102be565b348015610677575f80fd5b5061029a610686366004611995565b60016020525f908152604090205460ff1681565b3480156106a5575f80fd5b506102be60055481565b3480156106ba575f80fd5b5061029a6106c9366004611c43565b6113c6565b3480156106d9575f80fd5b506102df6106e83660046119f8565b6113dc565b3480156106f8575f80fd5b506102be60045481565b34801561070d575f80fd5b506102be600181565b6102df610724366004611995565b61147a565b6102df610737366004611995565b6114b4565b348015610747575f80fd5b5061029a610756366004611995565b6114da565b348015610766575f80fd5b506102be610775366004611995565b63389a75e1600c9081525f91909152602090205490565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f52b8e45c0000000000000000000000000000000000000000000000000000000014806107e157506107e182611539565b92915050565b6107f1338261158e565b50565b6107fc611599565b61080682826115b3565b5050565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a250565b6001610862816115bf565b815f0361089b576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6003546108c09073ffffffffffffffffffffffffffffffffffffffff163330856115f0565b8160025f8282546108d19190611cc1565b909155505060408051338152602081018490527fa64c2da41decbd538f8629e54c8fa0b7362c9102b691386a0fb6a1797454e9c6910160405180910390a15050565b600261091e816115bf565b838214610957576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b84811015610a05575f84848381811061097457610974611cd4565b90506020020160208101906109899190611d01565b90508015156001036109cb576109c68787848181106109aa576109aa611cd4565b90506020020160208101906109bf9190611995565b60016115b3565b6109fc565b6109fc8787848181106109e0576109e0611cd4565b90506020020160208101906109f59190611995565b600161158e565b50600101610959565b505050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf6011328054600382558015610a5e5760018160011c14303b10610a555763f92ee8a95f526004601cfd5b818160ff1b1b91505b505f610a6c83850185611db5565b805160208201516040830151606084015160808501519495509293919290915f839003610ac5576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f610ae673ffffffffffffffffffffffffffffffffffffffff871630611652565b905083811015610b4f5786516040517f5c54305e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602481018290526044810185905260640160405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff88161790555f8581556002859055600684905560055581516007805484929082907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660018381811115610be057610be0611b3f565b021790555060208201516001808301919091556040830151600283018054606086015173ffffffffffffffffffffffffffffffffffffffff16640100000000027fffffffffffffffff00000000000000000000000000000000000000000000000090911663ffffffff90931692909217919091178082556080850151927fffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffffffff909116907801000000000000000000000000000000000000000000000000908490811115610cae57610cae611b3f565b0217905550905050610cbf33611685565b610cca3360016116cd565b8573ffffffffffffffffffffffffffffffffffffffff167f742256c25dbd8c1cb315d87101bae0f6fc7656686d10d32d27fc2765ce9ccb9c86868686604051610d169493929190611ea0565b60405180910390a2505050505050508015610d5a576002815560016020527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602080a15b505050565b5f806001610d6c816115bf565b5f610d7985870187611f75565b90505f8160200151806020019051810190610d949190611ff4565b90508060025f828254610da7919061200b565b90915550508151600354610dd49173ffffffffffffffffffffffffffffffffffffffff909116908361170e565b81516003546040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606092831b811660208301529183901b90911660348201526048810183905273ffffffffffffffffffffffffffffffffffffffff909116907f9ad2e7a4af16dceda9cce4274b2f59c328d8c012eb0e15eb5e1e73b7d8f264d390606801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815290829052610e9291611b2d565b60405180910390a260035490945073ffffffffffffffffffffffffffffffffffffffff16925050509250929050565b610ec9611599565b610806828261158e565b60605f80610ee38486018661201e565b9250509150604051806080016040528060016002811115610f0657610f06611b3f565b81526020018373ffffffffffffffffffffffffffffffffffffffff1681526020013073ffffffffffffffffffffffffffffffffffffffff168152602001604051806020016040528084815250604051602001610f659151815260200190565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152918152915251610fa39190602001612050565b6040516020818303038152906040529250505092915050565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2565b610ffd611599565b6110065f611761565b565b6040805160a0810182525f808252602082018190529181018290526060810182905260808101919091526040805160a0810190915260078054829060ff16600181111561105757611057611b3f565b600181111561106857611068611b3f565b81526001828101546020830152600283015463ffffffff81166040840152640100000000810473ffffffffffffffffffffffffffffffffffffffff1660608401526080909201917801000000000000000000000000000000000000000000000000900460ff16908111156110de576110de611b3f565b60018111156110ef576110ef611b3f565b905250919050565b5f611100611599565b5f61110d838501856120c6565b90505f81602001518060200190518101906111289190611ff4565b90505f6111386002546005541090565b61116e576040517f6247a84e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f545f0361117d5750806111a0565b670de0b6b3a7640000825f546111939190612143565b61119d919061215a565b90505b600654158015906111b2575060065481115b156111bc57506006545b600254816005546111cd9190611cc1565b1115611205576040517f360e42e100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060055f8282546112169190611cc1565b92505081905550600160045f82825461122f9190611cc1565b90915550506003546112589073ffffffffffffffffffffffffffffffffffffffff16888361170e565b6003546040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606092831b811660208301529189901b90911660348201526048810182905273ffffffffffffffffffffffffffffffffffffffff8816907f9ad2e7a4af16dceda9cce4274b2f59c328d8c012eb0e15eb5e1e73b7d8f264d390606801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905261131391611b2d565b60405180910390a25060019695505050505050565b6002611333816115bf565b83821461136c576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b84811015610a05576113be86868381811061138b5761138b611cd4565b90506020020160208101906113a09190611995565b8585848181106113b2576113b2611cd4565b905060200201356115b3565b60010161136e565b5f6113d46002546005541090565b949350505050565b60026113e7816115bf565b838214611420576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b84811015610a055761147286868381811061143f5761143f611cd4565b90506020020160208101906114549190611995565b85858481811061146657611466611cd4565b9050602002013561158e565b600101611422565b611482611599565b63389a75e1600c52805f526020600c2080544211156114a857636f5e88185f526004601cfd5b5f90556107f181611761565b6114bc611599565b8060601b6114d157637448fbae5f526004601cfd5b6107f181611761565b5f8173ffffffffffffffffffffffffffffffffffffffff166114ff638b78c6d8195490565b73ffffffffffffffffffffffffffffffffffffffff1614806107e15750638b78c6d8600c9081525f839052602090205460031615156107e1565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f903181110000000000000000000000000000000000000000000000000000000014806107e157506107e1826117ab565b61080682825f611800565b638b78c6d819543314611006576382b429005f526004601cfd5b61080682826001611800565b638b78c6d8195433146107f157638b78c6d8600c52335f52806020600c2054166107f1576382b429005f526004601cfd5b60405181606052826040528360601b602c526f23b872dd000000000000000000000000600c5260205f6064601c5f895af18060015f51141661164457803d873b15171061164457637939f4245f526004601cfd5b505f60605260405250505050565b5f816014526f70a082310000000000000000000000005f5260208060246010865afa601f3d111660205102905092915050565b73ffffffffffffffffffffffffffffffffffffffff16638b78c6d819819055805f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b638b78c6d8600c52815f52806020600c205580600c5160601c7f715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe265f80a35050565b81601452806034526fa9059cbb0000000000000000000000005f5260205f604460105f875af18060015f51141661175757803d853b151710611757576390b8ec185f526004601cfd5b505f603452505050565b638b78c6d819805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a355565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167fa92167050000000000000000000000000000000000000000000000000000000014806107e157506107e182611857565b638b78c6d8600c52825f526020600c20805483811783611821575080841681185b80835580600c5160601c7f715ad5ce61fc9595c7b415289d59cf203f23a94fa06f04af7e489a0a76e1fe265f80a3505050505050565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f6ab67a0d0000000000000000000000000000000000000000000000000000000014806107e157507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107e1565b5f602082840312156118fd575f80fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461192c575f80fd5b9392505050565b5f60208284031215611943575f80fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff811681146107f1575f80fd5b5f806040838503121561197c575f80fd5b82356119878161194a565b946020939093013593505050565b5f602082840312156119a5575f80fd5b813561192c8161194a565b5f8083601f8401126119c0575f80fd5b50813567ffffffffffffffff8111156119d7575f80fd5b6020830191508360208260051b85010111156119f1575f80fd5b9250929050565b5f805f8060408587031215611a0b575f80fd5b843567ffffffffffffffff811115611a21575f80fd5b611a2d878288016119b0565b909550935050602085013567ffffffffffffffff811115611a4c575f80fd5b611a58878288016119b0565b95989497509550505050565b5f8083601f840112611a74575f80fd5b50813567ffffffffffffffff811115611a8b575f80fd5b6020830191508360208285010111156119f1575f80fd5b5f8060208385031215611ab3575f80fd5b823567ffffffffffffffff811115611ac9575f80fd5b611ad585828601611a64565b90969095509350505050565b5f81518084528060208401602086015e5f6020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b602081525f61192c6020830184611ae1565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b600281106107f1576107f1611b3f565b60a08101611b8987611b6c565b86825285602083015263ffffffff8516604083015273ffffffffffffffffffffffffffffffffffffffff84166060830152611bc383611b6c565b8260808301529695505050505050565b8051611bde81611b6c565b808352506020810151602083015263ffffffff604082015116604083015273ffffffffffffffffffffffffffffffffffffffff60608201511660608301526080810151611c2a81611b6c565b806080840152505050565b60a081016107e18284611bd3565b5f805f60408486031215611c55575f80fd5b8335611c608161194a565b9250602084013567ffffffffffffffff811115611c7b575f80fd5b611c8786828701611a64565b9497909650939450505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b808201808211156107e1576107e1611c94565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f60208284031215611d11575f80fd5b8135801515811461192c575f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b60405160a0810167ffffffffffffffff81118282101715611d7057611d70611d20565b60405290565b6040805190810167ffffffffffffffff81118282101715611d7057611d70611d20565b600281106107f1575f80fd5b8035611db081611d99565b919050565b5f81830361012081128015611dc8575f80fd5b50611dd1611d4d565b8335611ddc8161194a565b815260208481013590820152604080850135908201526060808501359082015260a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8083011215611e2b575f80fd5b611e33611d4d565b91506080840135611e4381611d99565b825260a0840135602083015260c084013563ffffffff81168114611e65575f80fd5b604083015260e0840135611e788161194a565b6060830152611e8a6101008501611da5565b6080830152816080820152809250505092915050565b84815260208101849052604081018390526101008101611ec36060830184611bd3565b95945050505050565b5f82601f830112611edb575f80fd5b813567ffffffffffffffff811115611ef557611ef5611d20565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810167ffffffffffffffff81118282101715611f4257611f42611d20565b604052818152838201602001851015611f59575f80fd5b816020850160208301375f918101602001919091529392505050565b5f60208284031215611f85575f80fd5b813567ffffffffffffffff811115611f9b575f80fd5b820160408185031215611fac575f80fd5b611fb4611d76565b8135611fbf8161194a565b8152602082013567ffffffffffffffff811115611fda575f80fd5b611fe686828501611ecc565b602083015250949350505050565b5f60208284031215612004575f80fd5b5051919050565b818103818111156107e1576107e1611c94565b5f805f60608486031215612030575f80fd5b833561203b8161194a565b95602085013595506040909401359392505050565b602081525f82516003811061206757612067611b3f565b8060208401525073ffffffffffffffffffffffffffffffffffffffff602084015116604083015273ffffffffffffffffffffffffffffffffffffffff604084015116606083015260608301516080808401526113d460a0840182611ae1565b5f602082840312156120d6575f80fd5b813567ffffffffffffffff8111156120ec575f80fd5b8201604081850312156120fd575f80fd5b612105611d76565b813567ffffffffffffffff81111561211b575f80fd5b61212786828501611ecc565b825250602082013567ffffffffffffffff811115611fda575f80fd5b80820281158282048414176107e1576107e1611c94565b5f8261218d577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b50049056fea264697066735822122069f0df25d1ca7c14d80738715391c4a4b217c6b7362908da91c6fbdcc629bf6364736f6c634300081a0033",y={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_BOOST_MAINNET_SIGNER_EOA:"0xCBD0C302040bC803B4B2EDaF21Be0e49Deff5480",VITE_BOOST_TESTNET_SIGNER_EOA:"0xd63167e9db11B108940b2E8236581F961f33f396"},m=class m extends v.ERC20VariableIncentive{constructor(){super(...arguments),this.abi=s.f}async getIncentiveCriteria(e){try{return await s.CH(this._config,{...e,address:this.assertValidAddress()})}catch(a){throw new i.IncentiveCriteriaNotFoundError(a)}}async decodeClaimData(e){const a=n.decodeAbiParameters([{type:"tuple",name:"BoostClaimData",components:[{type:"bytes",name:"validatorData"},{type:"bytes",name:"incentiveData"}]}],e),t=n.decodeAbiParameters([{type:"uint256"}],a[0].incentiveData)[0];let b=t;const[o,f]=await Promise.all([this.reward(),this.getMaxReward()]);return o===0n||(b=o*t/n.parseEther("1"),f!==0n&&b>f&&(b=f)),b}async getMaxReward(e){return await s.OH(this._config,{...e,address:this.assertValidAddress()})}async getIncentiveScalar({chainId:e,hash:a,knownSignatures:t,logs:b},o){var C;const f=await this.getIncentiveCriteria(o);if(f.criteriaType===r.SignatureType.EVENT){const g=t[f.signature];if(f.fieldIndex===T.CheatCodes.GAS_REBATE_INCENTIVE){const d=await p.getTransactionReceipt(this._config,{chainId:e,hash:a});return d.gasUsed*d.effectiveGasPrice+(d.blobGasUsed??0n)*(d.blobGasPrice??0n)}if(b&&b.length>0)try{const d=b.filter(c=>c.topics&&c.topics[0]===f.signature).map(c=>r.decodeAndReorderLogArgs(g,c));if(d.length>0)for(const c of d)try{return r.getScalarValue(c.args,f.fieldIndex)}catch{continue}}catch(d){throw new i.DecodedArgsError(`An error occurred while extracting scalar from logs: ${d.message}`)}const l=(await p.getTransactionReceipt(this._config,{chainId:e,hash:a})).logs;if(l.length===0)throw new i.NoMatchingLogsError(`No logs found for event signature ${f.signature}`);try{const d=t[f.signature],c=n.parseEventLogs({abi:[d],logs:l});if(c==null||c.length===0)throw new i.NoMatchingLogsError(`No logs found for event signature ${f.signature}`);return r.getScalarValue((C=c[0])==null?void 0:C.args,f.fieldIndex)}catch(d){throw new i.DecodedArgsError(`Failed to decode event log for signature ${f.signature}: ${d.message}`)}}else if(f.criteriaType===r.SignatureType.FUNC){const g=await p.getTransaction(this._config,{chainId:e,hash:a});try{const u=t[f.signature],l=n.decodeFunctionData({abi:[u],data:g.input});return r.getScalarValue(l.args,f.fieldIndex)}catch(u){throw new i.DecodedArgsError(`Failed to decode function data for signature ${f.signature}: ${u.message}`)}}else throw new i.InvalidCriteriaTypeError(`Invalid criteria type ${f.criteriaType}`)}buildParameters(e,a){const[t,b]=this.validateDeploymentConfig(e,a);return{abi:s.f,bytecode:w,args:[I(t)],...this.optionallyAttachAccount(b.account)}}};m.bases={...y!=null&&y.VITE_ERC20_VARIABLE_CRITERIA_INCENTIVE_V2_BASE?{31337:void 0}:{},...A.ERC20VariableCriteriaIncentiveV2};let E=m;function R(){return{criteriaType:r.SignatureType.EVENT,signature:n.zeroHash,fieldIndex:T.CheatCodes.GAS_REBATE_INCENTIVE,targetContract:n.zeroAddress,valueType:r.ValueType.WAD}}function I({asset:h,reward:e,limit:a,maxReward:t=0n,criteria:b}){return n.encodeAbiParameters([{type:"tuple",name:"initPayloadExtended",components:[{type:"address",name:"asset"},{type:"uint256",name:"reward"},{type:"uint256",name:"limit"},{type:"uint256",name:"maxReward"},{type:"tuple",name:"criteria",components:[{type:"uint8",name:"criteriaType"},{type:"bytes32",name:"signature"},{type:"uint32",name:"fieldIndex"},{type:"address",name:"targetContract"},{type:"uint8",name:"valueType"}]}]}],[{asset:h,reward:e,limit:a,maxReward:t,criteria:{criteriaType:b.criteriaType,signature:b.signature,fieldIndex:b.fieldIndex,targetContract:b.targetContract,valueType:b.valueType}}])}exports.erc20VariableCriteriaIncentiveV2Abi=s.f;exports.ERC20VariableCriteriaIncentiveV2=E;exports.gasRebateIncentiveCriteriaV2=R;exports.prepareERC20VariableCriteriaIncentiveV2Payload=I;
2
2
  //# sourceMappingURL=ERC20VariableCriteriaIncentiveV2.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ERC20VariableCriteriaIncentiveV2.cjs","sources":["../../src/Incentives/ERC20VariableCriteriaIncentiveV2.ts"],"sourcesContent":["import {\n erc20VariableCriteriaIncentiveV2Abi,\n readErc20VariableCriteriaIncentiveV2GetIncentiveCriteria,\n readErc20VariableCriteriaIncentiveV2GetMaxReward,\n} from '@boostxyz/evm';\nimport { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20VariableCriteriaIncentiveV2.sol/ERC20VariableCriteriaIncentiveV2.json';\nimport { getTransaction, getTransactionReceipt } from '@wagmi/core';\nimport {\n type AbiEvent,\n type AbiFunction,\n type Address,\n type GetLogsReturnType,\n type Hex,\n decodeAbiParameters,\n decodeFunctionData,\n encodeAbiParameters,\n parseEther,\n parseEventLogs,\n zeroAddress,\n zeroHash,\n} from 'viem';\nimport { ERC20VariableCriteriaIncentiveV2 as ERC20VariableCriteriaIncentiveV2Bases } from '../../dist/deployments.json';\nimport {\n SignatureType,\n ValueType,\n decodeAndReorderLogArgs,\n getScalarValue,\n} from '../Actions/EventAction';\nimport type {\n DeployableOptions,\n GenericDeployableParams,\n} from '../Deployable/Deployable';\nimport {\n DecodedArgsError,\n IncentiveCriteriaNotFoundError,\n InvalidCriteriaTypeError,\n NoMatchingLogsError,\n} from '../errors';\nimport { CheatCodes, type ReadParams } from '../utils';\nimport { ERC20VariableIncentive } from './ERC20VariableIncentive';\n\nexport { erc20VariableCriteriaIncentiveV2Abi };\n\nexport interface ERC20VariableCriteriaIncentiveV2Payload {\n /**\n * The address of the incentivized asset.\n *\n * @type {Address}\n */\n asset: Address;\n /**\n * The amount of the asset to distribute as reward.\n *\n * @type {bigint}\n */\n reward: bigint;\n /**\n * The total spending limit of the asset that will be distributed.\n *\n * @type {bigint}\n */\n limit: bigint;\n /**\n * The total amount claimable in a single claim or maximum per-action reward.\n *\n * @type {bigint}\n * @optional\n */\n maxReward?: bigint;\n /**\n * The criteria for the incentive that determines how the reward is distributed.\n *\n * @type {IncentiveCriteria}\n */\n criteria: IncentiveCriteriaV2;\n}\n\nexport interface IncentiveCriteriaV2 {\n /**\n * The type of criteria used, either function signature or event signature.\n *\n * @type {SignatureType}\n */\n criteriaType: SignatureType;\n /**\n * The function or event signature used for criteria matching.\n *\n * @type {Hex}\n */\n signature: Hex;\n /**\n * The index of the field from where the scalar value is extracted.\n *\n * @type {number}\n */\n fieldIndex: number;\n /**\n * The address of the contract where the event/function is called/emitted.\n *\n * @type {Address}\n */\n targetContract: Address;\n /**\n * The type of value used for the scalar value (RAW or WAD).\n * - RAW: Raw integer value (e.g., NFT quantity)\n * - WAD: Value with 18 decimals (e.g., token amount)\n *\n * @type {ValueType}\n */\n valueType: ValueType;\n}\n\nexport interface ReadIncentiveCriteriaV2Params extends ReadParams {}\n\nexport interface GetIncentiveScalarV2Params {\n chainId: number;\n hash: Hex;\n knownSignatures: Record<Hex, AbiFunction | AbiEvent>;\n logs?: GetLogsReturnType<AbiEvent, AbiEvent[], true>;\n}\n\n/**\n * Extended ERC20 Variable Criteria Incentive class that fetches incentive criteria and scalar\n *\n * @export\n * @class ERC20VariableCriteriaIncentive\n * @typedef {ERC20VariableCriteriaIncentiveV2}\n * @extends {ERC20VariableIncentive<ERC20VariableCriteriaIncentiveV2Payload, typeof erc20VariableCriteriaIncentiveV2Abi>}\n */\nexport class ERC20VariableCriteriaIncentiveV2 extends ERC20VariableIncentive<\n ERC20VariableCriteriaIncentiveV2Payload,\n typeof erc20VariableCriteriaIncentiveV2Abi,\n Promise<bigint>\n> {\n //@ts-expect-error instantiated correctly\n public override readonly abi = erc20VariableCriteriaIncentiveV2Abi;\n /**\n * @inheritdoc\n *\n * @public\n * @static\n * @type {Record<number, Address>}\n */\n public static override bases: Record<number, Address> = {\n ...(import.meta.env?.VITE_ERC20_VARIABLE_CRITERIA_INCENTIVE_V2_BASE\n ? {\n 31337: import.meta.env.VITE_ERC20_VARIABLE_CRITERIA_INCENTIVE_V2_BASE,\n }\n : {}),\n ...(ERC20VariableCriteriaIncentiveV2Bases as Record<number, Address>),\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<IncentiveCriteriaV2> {\n try {\n const criteria =\n await readErc20VariableCriteriaIncentiveV2GetIncentiveCriteria(\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 * Decodes claim data for the ERC20VariableCriteriaIncentiveV2, returning the claim amount.\n * Useful when deriving amount claimed from logs.\n *\n * @public\n * @param {Hex} claimData\n * @returns {Promise<bigint>} Returns the reward amount from a claim data payload\n */\n public override async decodeClaimData(claimData: Hex) {\n const boostClaimData = decodeAbiParameters(\n [\n {\n type: 'tuple',\n name: 'BoostClaimData',\n components: [\n { type: 'bytes', name: 'validatorData' },\n { type: 'bytes', name: 'incentiveData' },\n ],\n },\n ],\n claimData,\n );\n const signedAmount = decodeAbiParameters(\n [{ type: 'uint256' }],\n boostClaimData[0].incentiveData,\n )[0];\n let claimAmount = signedAmount;\n const [reward, maxReward] = await Promise.all([\n this.reward(),\n this.getMaxReward(),\n ]);\n\n if (reward === 0n) {\n return claimAmount;\n } else {\n claimAmount = (reward * signedAmount) / parseEther('1');\n }\n\n if (maxReward !== 0n && claimAmount > maxReward) {\n claimAmount = maxReward;\n }\n\n return claimAmount;\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 getMaxReward(params?: ReadParams): Promise<bigint> {\n const maxReward = await readErc20VariableCriteriaIncentiveV2GetMaxReward(\n this._config,\n {\n ...params,\n address: this.assertValidAddress(),\n },\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, logs }: GetIncentiveScalarV2Params,\n params?: ReadParams,\n ): Promise<bigint> {\n const criteria = await this.getIncentiveCriteria(params);\n if (criteria.criteriaType === SignatureType.EVENT) {\n const eventAbi = knownSignatures[criteria.signature] as AbiEvent;\n\n if (criteria.fieldIndex === CheatCodes.GAS_REBATE_INCENTIVE) {\n const transactionReceipt = await getTransactionReceipt(this._config, {\n chainId,\n hash,\n });\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\n // if logs are provided, use them to extract the scalar\n if (logs && logs.length > 0) {\n try {\n // only check logs that match the criteria signature\n const signatureMatchingLogs = logs\n .filter((log) => log.topics && log.topics[0] === criteria.signature)\n .map((log) => decodeAndReorderLogArgs(eventAbi, log));\n\n if (signatureMatchingLogs.length > 0) {\n for (const log of signatureMatchingLogs) {\n try {\n return getScalarValue(\n log.args as unknown[],\n criteria.fieldIndex,\n );\n } catch {\n continue;\n }\n }\n }\n } catch (e) {\n throw new DecodedArgsError(\n `An error occurred while extracting scalar from logs: ${(e as Error).message}`,\n );\n }\n }\n\n const transactionReceipt = await getTransactionReceipt(this._config, {\n chainId,\n hash,\n });\n const receiptLogs = transactionReceipt.logs;\n\n if (receiptLogs.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 const eventAbi = knownSignatures[criteria.signature] as AbiEvent;\n const decodedEvents = parseEventLogs({\n abi: [eventAbi],\n logs: receiptLogs,\n });\n if (decodedEvents == undefined || decodedEvents.length === 0) {\n throw new NoMatchingLogsError(\n `No logs found for event signature ${criteria.signature}`,\n );\n }\n\n return getScalarValue(\n decodedEvents[0]?.args as unknown[],\n criteria.fieldIndex,\n );\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\n return getScalarValue(\n decodedFunction.args as unknown[],\n criteria.fieldIndex,\n );\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 * @inheritdoc\n *\n * @public\n * @param {?ERC20VariableCriteriaIncentiveV2Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public override buildParameters(\n _payload?: ERC20VariableCriteriaIncentiveV2Payload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n return {\n abi: erc20VariableCriteriaIncentiveV2Abi,\n bytecode: bytecode as Hex,\n args: [prepareERC20VariableCriteriaIncentiveV2Payload(payload)],\n ...this.optionallyAttachAccount(options.account),\n };\n }\n}\n\n/**\n * Creates an IncentiveCriteria object representing a gas rebate incentive.\n * This object defines a variable incentive criteria where the criteria will be the gas spent.\n *\n * The criteria uses a signatureType of EVENT, with a special `fieldIndex` of 255 (using CheatCodes enum), which indicates\n * that the entire gas cost of the transaction will be used as the scalar value. If you don't want to\n * rebate the entire gas cost, you can use a reward value on the incentive..\n *\n * - `criteriaType`: EVENT, indicating it's based on event logs.\n * - `signature`: A zeroed signature (0x0000...0000), matching any event.\n * - `fieldIndex`: 255, indicating the use of transaction gas cost using CheatCodes enum.\n * - `targetContract`: A zeroed address (0x0000...0000), applicable to any contract.\n *\n * @returns {IncentiveCriteria} Returns an IncentiveCriteria object for a gas rebate.\n *\n * @example\n * const incentive = gasRebateIncentiveCriteria();\n * const actionPayload = {\n * criteria: incentive,\n * asset: \"0xAssetAddress\",\n * reward: 0, // Set to zero to rebate the entire gas cost\n * limit: BigInt(1000) // This is the total spend limit for the incentive\n * };\n * deployIncentive(actionPayload);\n */\nexport function gasRebateIncentiveCriteriaV2(): IncentiveCriteriaV2 {\n return {\n criteriaType: SignatureType.EVENT,\n signature: zeroHash,\n fieldIndex: CheatCodes.GAS_REBATE_INCENTIVE,\n targetContract: zeroAddress,\n valueType: ValueType.WAD,\n };\n}\n\n/**\n *\n *\n * @param {InitPayloadExtended} param0\n * @param {Address} param0.asset - The address of the ERC20 asset to incentivize.\n * @param {bigint} param0.reward - The reward amount to distribute per action.\n * @param {bigint} param0.limit - The total limit of the asset distribution.\n * @param {bigint} param0.maxReward - The maximum value claimable from a single completion.\n * @param {IncentiveCriteria} param0.criteria - The incentive criteria for reward distribution.\n * @returns {Hex}\n */\nexport function prepareERC20VariableCriteriaIncentiveV2Payload({\n asset,\n reward,\n limit,\n maxReward = 0n,\n criteria,\n}: ERC20VariableCriteriaIncentiveV2Payload) {\n return encodeAbiParameters(\n [\n {\n type: 'tuple',\n name: 'initPayloadExtended',\n components: [\n { type: 'address', name: 'asset' },\n { type: 'uint256', name: 'reward' },\n { type: 'uint256', name: 'limit' },\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 { type: 'uint8', name: 'valueType' },\n ],\n },\n ],\n },\n ],\n [\n {\n asset: asset,\n reward: reward,\n limit: limit,\n maxReward: maxReward,\n criteria: {\n criteriaType: criteria.criteriaType,\n signature: criteria.signature,\n fieldIndex: criteria.fieldIndex,\n targetContract: criteria.targetContract,\n valueType: criteria.valueType,\n },\n },\n ],\n );\n}\n"],"names":["_ERC20VariableCriteriaIncentiveV2","ERC20VariableIncentive","erc20VariableCriteriaIncentiveV2Abi","params","readErc20VariableCriteriaIncentiveV2GetIncentiveCriteria","e","IncentiveCriteriaNotFoundError","claimData","boostClaimData","decodeAbiParameters","signedAmount","claimAmount","reward","maxReward","parseEther","readErc20VariableCriteriaIncentiveV2GetMaxReward","chainId","hash","knownSignatures","logs","criteria","SignatureType","eventAbi","CheatCodes","transactionReceipt","getTransactionReceipt","signatureMatchingLogs","log","decodeAndReorderLogArgs","getScalarValue","DecodedArgsError","receiptLogs","NoMatchingLogsError","decodedEvents","parseEventLogs","_a","transaction","getTransaction","func","decodedFunction","decodeFunctionData","InvalidCriteriaTypeError","_payload","_options","payload","options","bytecode","prepareERC20VariableCriteriaIncentiveV2Payload","__vite_import_meta_env__","ERC20VariableCriteriaIncentiveV2Bases","ERC20VariableCriteriaIncentiveV2","gasRebateIncentiveCriteriaV2","zeroHash","zeroAddress","ValueType","asset","limit","encodeAbiParameters"],"mappings":"gtjBAiIaA,EAAN,MAAMA,UAAyCC,EAAAA,sBAIpD,CAJK,aAAA,CAAA,MAAA,GAAA,SAAA,EAML,KAAyB,IAAMC,GAAA,CA4B/B,MAAa,qBACXC,EAC8B,CAC1B,GAAA,CAUK,OARL,MAAMC,EAAA,GACJ,KAAK,QACL,CACE,GAAGD,EACH,QAAS,KAAK,mBAAmB,CACnC,CAAA,QAIGE,EAAG,CACJ,MAAA,IAAIC,EAAAA,+BAA+BD,CAAU,CACrD,CACF,CAUA,MAAsB,gBAAgBE,EAAgB,CACpD,MAAMC,EAAiBC,EAAA,oBACrB,CACE,CACE,KAAM,QACN,KAAM,iBACN,WAAY,CACV,CAAE,KAAM,QAAS,KAAM,eAAgB,EACvC,CAAE,KAAM,QAAS,KAAM,eAAgB,CACzC,CACF,CACF,EACAF,CAAA,EAEIG,EAAeD,EAAA,oBACnB,CAAC,CAAE,KAAM,UAAW,EACpBD,EAAe,CAAC,EAAE,eAClB,CAAC,EACH,IAAIG,EAAcD,EAClB,KAAM,CAACE,EAAQC,CAAS,EAAI,MAAM,QAAQ,IAAI,CAC5C,KAAK,OAAO,EACZ,KAAK,aAAa,CAAA,CACnB,EAED,OAAID,IAAW,KAGED,EAAAC,EAASF,EAAgBI,EAAA,WAAW,GAAG,EAGpDD,IAAc,IAAMF,EAAcE,IACtBF,EAAAE,IAGTF,CACT,CASA,MAAa,aAAaR,EAAsC,CASvD,OARW,MAAMY,EAAA,GACtB,KAAK,QACL,CACE,GAAGZ,EACH,QAAS,KAAK,mBAAmB,CACnC,CAAA,CAIJ,CAUA,MAAa,mBACX,CAAE,QAAAa,EAAS,KAAAC,EAAM,gBAAAC,EAAiB,KAAAC,GAClChB,E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AAA3C,EAAY,GACZ,SAAAO,CACF,EAA4C,CACnC,OAAAqC,EAAA,oBACL,CACE,CACE,KAAM,QACN,KAAM,sBACN,WAAY,CACV,CAAE,KAAM,UAAW,KAAM,OAAQ,EACjC,CAAE,KAAM,UAAW,KAAM,QAAS,EAClC,CAAE,KAAM,UAAW,KAAM,OAAQ,EACjC,CAAE,KAAM,UAAW,KAAM,WAAY,EACrC,CACE,KAAM,QACN,KAAM,WACN,WAAY,CACV,CAAE,KAAM,QAAS,KAAM,cAAe,EACtC,CAAE,KAAM,UAAW,KAAM,WAAY,EACrC,CAAE,KAAM,QAAS,KAAM,YAAa,EACpC,CAAE,KAAM,UAAW,KAAM,gBAAiB,EAC1C,CAAE,KAAM,QAAS,KAAM,WAAY,CACrC,CACF,CACF,CACF,CACF,EACA,CACE,CACE,MAAAF,EACA,OAAA3C,EACA,MAAA4C,EACA,UAAA3C,EACA,SAAU,CACR,aAAcO,EAAS,aACvB,UAAWA,EAAS,UACpB,WAAYA,EAAS,WACrB,eAAgBA,EAAS,eACzB,UAAWA,EAAS,SACtB,CACF,CACF,CAAA,CAEJ"}
1
+ {"version":3,"file":"ERC20VariableCriteriaIncentiveV2.cjs","sources":["../../src/Incentives/ERC20VariableCriteriaIncentiveV2.ts"],"sourcesContent":["import {\n erc20VariableCriteriaIncentiveV2Abi,\n readErc20VariableCriteriaIncentiveV2GetIncentiveCriteria,\n readErc20VariableCriteriaIncentiveV2GetMaxReward,\n} from '@boostxyz/evm';\nimport { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20VariableCriteriaIncentiveV2.sol/ERC20VariableCriteriaIncentiveV2.json';\nimport { getTransaction, getTransactionReceipt } from '@wagmi/core';\nimport {\n type AbiEvent,\n type AbiFunction,\n type Address,\n type GetLogsReturnType,\n type Hex,\n decodeAbiParameters,\n decodeFunctionData,\n encodeAbiParameters,\n parseEther,\n parseEventLogs,\n zeroAddress,\n zeroHash,\n} from 'viem';\nimport { ERC20VariableCriteriaIncentiveV2 as ERC20VariableCriteriaIncentiveV2Bases } from '../../dist/deployments.json';\nimport {\n SignatureType,\n ValueType,\n decodeAndReorderLogArgs,\n getScalarValue,\n} from '../Actions/EventAction';\nimport type {\n DeployableOptions,\n GenericDeployableParams,\n} from '../Deployable/Deployable';\nimport {\n DecodedArgsError,\n IncentiveCriteriaNotFoundError,\n InvalidCriteriaTypeError,\n NoMatchingLogsError,\n} from '../errors';\nimport { CheatCodes, type ReadParams } from '../utils';\nimport { ERC20VariableIncentive } from './ERC20VariableIncentive';\n\nexport { erc20VariableCriteriaIncentiveV2Abi };\n\nexport interface ERC20VariableCriteriaIncentiveV2Payload {\n /**\n * The address of the incentivized asset.\n *\n * @type {Address}\n */\n asset: Address;\n /**\n * The amount of the asset to distribute as reward.\n *\n * @type {bigint}\n */\n reward: bigint;\n /**\n * The total spending limit of the asset that will be distributed.\n *\n * @type {bigint}\n */\n limit: bigint;\n /**\n * The total amount claimable in a single claim or maximum per-action reward.\n *\n * @type {bigint}\n * @optional\n */\n maxReward?: bigint;\n /**\n * The criteria for the incentive that determines how the reward is distributed.\n *\n * @type {IncentiveCriteria}\n */\n criteria: IncentiveCriteriaV2;\n}\n\nexport interface IncentiveCriteriaV2 {\n /**\n * The type of criteria used, either function signature or event signature.\n *\n * @type {SignatureType}\n */\n criteriaType: SignatureType;\n /**\n * The function or event signature used for criteria matching.\n *\n * @type {Hex}\n */\n signature: Hex;\n /**\n * The index of the field from where the scalar value is extracted.\n *\n * @type {number}\n */\n fieldIndex: number;\n /**\n * The address of the contract where the event/function is called/emitted.\n *\n * @type {Address}\n */\n targetContract: Address;\n /**\n * The type of value used for the scalar value (RAW or WAD).\n * - RAW: Raw integer value (e.g., NFT quantity)\n * - WAD: Value with 18 decimals (e.g., token amount)\n *\n * @type {ValueType}\n */\n valueType: ValueType;\n}\n\nexport interface ReadIncentiveCriteriaV2Params extends ReadParams {}\n\nexport interface GetIncentiveScalarV2Params {\n chainId: number;\n hash: Hex;\n knownSignatures: Record<Hex, AbiFunction | AbiEvent>;\n logs?: GetLogsReturnType<AbiEvent, AbiEvent[], true>;\n}\n\n/**\n * Extended ERC20 Variable Criteria Incentive class that fetches incentive criteria and scalar\n *\n * @export\n * @class ERC20VariableCriteriaIncentive\n * @typedef {ERC20VariableCriteriaIncentiveV2}\n * @extends {ERC20VariableIncentive<ERC20VariableCriteriaIncentiveV2Payload, typeof erc20VariableCriteriaIncentiveV2Abi>}\n */\nexport class ERC20VariableCriteriaIncentiveV2 extends ERC20VariableIncentive<\n ERC20VariableCriteriaIncentiveV2Payload,\n typeof erc20VariableCriteriaIncentiveV2Abi,\n Promise<bigint>\n> {\n //@ts-expect-error instantiated correctly\n public override readonly abi = erc20VariableCriteriaIncentiveV2Abi;\n /**\n * @inheritdoc\n *\n * @public\n * @static\n * @type {Record<number, Address>}\n */\n public static override bases: Record<number, Address> = {\n ...(import.meta.env?.VITE_ERC20_VARIABLE_CRITERIA_INCENTIVE_V2_BASE\n ? {\n 31337: import.meta.env.VITE_ERC20_VARIABLE_CRITERIA_INCENTIVE_V2_BASE,\n }\n : {}),\n ...(ERC20VariableCriteriaIncentiveV2Bases as Record<number, Address>),\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<IncentiveCriteriaV2> {\n try {\n const criteria =\n await readErc20VariableCriteriaIncentiveV2GetIncentiveCriteria(\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 * Decodes claim data for the ERC20VariableCriteriaIncentiveV2, returning the claim amount.\n * Useful when deriving amount claimed from logs.\n *\n * @public\n * @param {Hex} claimData\n * @returns {Promise<bigint>} Returns the reward amount from a claim data payload\n */\n public override async decodeClaimData(claimData: Hex) {\n const boostClaimData = decodeAbiParameters(\n [\n {\n type: 'tuple',\n name: 'BoostClaimData',\n components: [\n { type: 'bytes', name: 'validatorData' },\n { type: 'bytes', name: 'incentiveData' },\n ],\n },\n ],\n claimData,\n );\n const signedAmount = decodeAbiParameters(\n [{ type: 'uint256' }],\n boostClaimData[0].incentiveData,\n )[0];\n let claimAmount = signedAmount;\n const [reward, maxReward] = await Promise.all([\n this.reward(),\n this.getMaxReward(),\n ]);\n\n if (reward === 0n) {\n return claimAmount;\n } else {\n claimAmount = (reward * signedAmount) / parseEther('1');\n }\n\n if (maxReward !== 0n && claimAmount > maxReward) {\n claimAmount = maxReward;\n }\n\n return claimAmount;\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 getMaxReward(params?: ReadParams): Promise<bigint> {\n const maxReward = await readErc20VariableCriteriaIncentiveV2GetMaxReward(\n this._config,\n {\n ...params,\n address: this.assertValidAddress(),\n },\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, logs }: GetIncentiveScalarV2Params,\n params?: ReadParams,\n ): Promise<bigint> {\n const criteria = await this.getIncentiveCriteria(params);\n if (criteria.criteriaType === SignatureType.EVENT) {\n const eventAbi = knownSignatures[criteria.signature] as AbiEvent;\n\n if (criteria.fieldIndex === CheatCodes.GAS_REBATE_INCENTIVE) {\n const transactionReceipt = await getTransactionReceipt(this._config, {\n chainId,\n hash,\n });\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\n // if logs are provided, use them to extract the scalar\n if (logs && logs.length > 0) {\n try {\n // only check logs that match the criteria signature\n const signatureMatchingLogs = logs\n .filter((log) => log.topics && log.topics[0] === criteria.signature)\n .map((log) => decodeAndReorderLogArgs(eventAbi, log));\n\n if (signatureMatchingLogs.length > 0) {\n for (const log of signatureMatchingLogs) {\n try {\n return getScalarValue(\n log.args as unknown[],\n criteria.fieldIndex,\n );\n } catch {\n continue;\n }\n }\n }\n } catch (e) {\n throw new DecodedArgsError(\n `An error occurred while extracting scalar from logs: ${(e as Error).message}`,\n );\n }\n }\n\n const transactionReceipt = await getTransactionReceipt(this._config, {\n chainId,\n hash,\n });\n const receiptLogs = transactionReceipt.logs;\n\n if (receiptLogs.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 const eventAbi = knownSignatures[criteria.signature] as AbiEvent;\n const decodedEvents = parseEventLogs({\n abi: [eventAbi],\n logs: receiptLogs,\n });\n if (decodedEvents == undefined || decodedEvents.length === 0) {\n throw new NoMatchingLogsError(\n `No logs found for event signature ${criteria.signature}`,\n );\n }\n\n return getScalarValue(\n decodedEvents[0]?.args as unknown[],\n criteria.fieldIndex,\n );\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\n return getScalarValue(\n decodedFunction.args as unknown[],\n criteria.fieldIndex,\n );\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 * @inheritdoc\n *\n * @public\n * @param {?ERC20VariableCriteriaIncentiveV2Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public override buildParameters(\n _payload?: ERC20VariableCriteriaIncentiveV2Payload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n return {\n abi: erc20VariableCriteriaIncentiveV2Abi,\n bytecode: bytecode as Hex,\n args: [prepareERC20VariableCriteriaIncentiveV2Payload(payload)],\n ...this.optionallyAttachAccount(options.account),\n };\n }\n}\n\n/**\n * Creates an IncentiveCriteria object representing a gas rebate incentive.\n * This object defines a variable incentive criteria where the criteria will be the gas spent.\n *\n * The criteria uses a signatureType of EVENT, with a special `fieldIndex` of 255 (using CheatCodes enum), which indicates\n * that the entire gas cost of the transaction will be used as the scalar value. If you don't want to\n * rebate the entire gas cost, you can use a reward value on the incentive..\n *\n * - `criteriaType`: EVENT, indicating it's based on event logs.\n * - `signature`: A zeroed signature (0x0000...0000), matching any event.\n * - `fieldIndex`: 255, indicating the use of transaction gas cost using CheatCodes enum.\n * - `targetContract`: A zeroed address (0x0000...0000), applicable to any contract.\n *\n * @returns {IncentiveCriteria} Returns an IncentiveCriteria object for a gas rebate.\n *\n * @example\n * const incentive = gasRebateIncentiveCriteria();\n * const actionPayload = {\n * criteria: incentive,\n * asset: \"0xAssetAddress\",\n * reward: 0, // Set to zero to rebate the entire gas cost\n * limit: BigInt(1000) // This is the total spend limit for the incentive\n * };\n * deployIncentive(actionPayload);\n */\nexport function gasRebateIncentiveCriteriaV2(): IncentiveCriteriaV2 {\n return {\n criteriaType: SignatureType.EVENT,\n signature: zeroHash,\n fieldIndex: CheatCodes.GAS_REBATE_INCENTIVE,\n targetContract: zeroAddress,\n valueType: ValueType.WAD,\n };\n}\n\n/**\n *\n *\n * @param {InitPayloadExtended} param0\n * @param {Address} param0.asset - The address of the ERC20 asset to incentivize.\n * @param {bigint} param0.reward - The reward amount to distribute per action.\n * @param {bigint} param0.limit - The total limit of the asset distribution.\n * @param {bigint} param0.maxReward - The maximum value claimable from a single completion.\n * @param {IncentiveCriteria} param0.criteria - The incentive criteria for reward distribution.\n * @returns {Hex}\n */\nexport function prepareERC20VariableCriteriaIncentiveV2Payload({\n asset,\n reward,\n limit,\n maxReward = 0n,\n criteria,\n}: ERC20VariableCriteriaIncentiveV2Payload) {\n return encodeAbiParameters(\n [\n {\n type: 'tuple',\n name: 'initPayloadExtended',\n components: [\n { type: 'address', name: 'asset' },\n { type: 'uint256', name: 'reward' },\n { type: 'uint256', name: 'limit' },\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: 'uint32', name: 'fieldIndex' },\n { type: 'address', name: 'targetContract' },\n { type: 'uint8', name: 'valueType' },\n ],\n },\n ],\n },\n ],\n [\n {\n asset: asset,\n reward: reward,\n limit: limit,\n maxReward: maxReward,\n criteria: {\n criteriaType: criteria.criteriaType,\n signature: criteria.signature,\n fieldIndex: criteria.fieldIndex,\n targetContract: criteria.targetContract,\n valueType: criteria.valueType,\n },\n },\n ],\n );\n}\n"],"names":["_ERC20VariableCriteriaIncentiveV2","ERC20VariableIncentive","erc20VariableCriteriaIncentiveV2Abi","params","readErc20VariableCriteriaIncentiveV2GetIncentiveCriteria","e","IncentiveCriteriaNotFoundError","claimData","boostClaimData","decodeAbiParameters","signedAmount","claimAmount","reward","maxReward","parseEther","readErc20VariableCriteriaIncentiveV2GetMaxReward","chainId","hash","knownSignatures","logs","criteria","SignatureType","eventAbi","CheatCodes","transactionReceipt","getTransactionReceipt","signatureMatchingLogs","log","decodeAndReorderLogArgs","getScalarValue","DecodedArgsError","receiptLogs","NoMatchingLogsError","decodedEvents","parseEventLogs","_a","transaction","getTransaction","func","decodedFunction","decodeFunctionData","InvalidCriteriaTypeError","_payload","_options","payload","options","bytecode","prepareERC20VariableCriteriaIncentiveV2Payload","__vite_import_meta_env__","ERC20VariableCriteriaIncentiveV2Bases","ERC20VariableCriteriaIncentiveV2","gasRebateIncentiveCriteriaV2","zeroHash","zeroAddress","ValueType","asset","limit","encodeAbiParameters"],"mappings":"gtjBAiIaA,EAAN,MAAMA,UAAyCC,EAAAA,sBAIpD,CAJK,aAAA,CAAA,MAAA,GAAA,SAAA,EAML,KAAyB,IAAMC,GAAA,CA4B/B,MAAa,qBACXC,EAC8B,CAC1B,GAAA,CAUK,OARL,MAAMC,EAAA,GACJ,KAAK,QACL,CACE,GAAGD,EACH,QAAS,KAAK,mBAAmB,CACnC,CAAA,QAIGE,EAAG,CACJ,MAAA,IAAIC,EAAAA,+BAA+BD,CAAU,CACrD,CACF,CAUA,MAAsB,gBAAgBE,EAAgB,CACpD,MAAMC,EAAiBC,EAAA,oBACrB,CACE,CACE,KAAM,QACN,KAAM,iBACN,WAAY,CACV,CAAE,KAAM,QAAS,KAAM,eAAgB,EACvC,CAAE,KAAM,QAAS,KAAM,eAAgB,CACzC,CACF,CACF,EACAF,CAAA,EAEIG,EAAeD,EAAA,oBACnB,CAAC,CAAE,KAAM,UAAW,EACpBD,EAAe,CAAC,EAAE,eAClB,CAAC,EACH,IAAIG,EAAcD,EAClB,KAAM,CAACE,EAAQC,CAAS,EAAI,MAAM,QAAQ,IAAI,CAC5C,KAAK,OAAO,EACZ,KAAK,aAAa,CAAA,CACnB,EAED,OAAID,IAAW,KAGED,EAAAC,EAASF,EAAgBI,EAAA,WAAW,GAAG,EAGpDD,IAAc,IAAMF,EAAcE,IACtBF,EAAAE,IAGTF,CACT,CASA,MAAa,aAAaR,EAAsC,CASvD,OARW,MAAMY,EAAA,GACtB,KAAK,QACL,CACE,GAAGZ,EACH,QAAS,KAAK,mBAAmB,CACnC,CAAA,CAIJ,CAUA,MAA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EzB,CAaO,SAASP,EAA+C,CAC7D,MAAAQ,EACA,OAAA3C,EACA,MAAA4C,EACA,UAAA3C,EAAY,GACZ,SAAAO,CACF,EAA4C,CACnC,OAAAqC,EAAA,oBACL,CACE,CACE,KAAM,QACN,KAAM,sBACN,WAAY,CACV,CAAE,KAAM,UAAW,KAAM,OAAQ,EACjC,CAAE,KAAM,UAAW,KAAM,QAAS,EAClC,CAAE,KAAM,UAAW,KAAM,OAAQ,EACjC,CAAE,KAAM,UAAW,KAAM,WAAY,EACrC,CACE,KAAM,QACN,KAAM,WACN,WAAY,CACV,CAAE,KAAM,QAAS,KAAM,cAAe,EACtC,CAAE,KAAM,UAAW,KAAM,WAAY,EACrC,CAAE,KAAM,SAAU,KAAM,YAAa,EACrC,CAAE,KAAM,UAAW,KAAM,gBAAiB,EAC1C,CAAE,KAAM,QAAS,KAAM,WAAY,CACrC,CACF,CACF,CACF,CACF,EACA,CACE,CACE,MAAAF,EACA,OAAA3C,EACA,MAAA4C,EACA,UAAA3C,EACA,SAAU,CACR,aAAcO,EAAS,aACvB,UAAWA,EAAS,UACpB,WAAYA,EAAS,WACrB,eAAgBA,EAAS,eACzB,UAAWA,EAAS,SACtB,CACF,CACF,CAAA,CAEJ"}
@@ -230,7 +230,7 @@ function M({
230
230
  components: [
231
231
  { type: "uint8", name: "criteriaType" },
232
232
  { type: "bytes32", name: "signature" },
233
- { type: "uint8", name: "fieldIndex" },
233
+ { type: "uint32", name: "fieldIndex" },
234
234
  { type: "address", name: "targetContract" },
235
235
  { type: "uint8", name: "valueType" }
236
236
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"ERC20VariableCriteriaIncentiveV2.js","sources":["../../src/Incentives/ERC20VariableCriteriaIncentiveV2.ts"],"sourcesContent":["import {\n erc20VariableCriteriaIncentiveV2Abi,\n readErc20VariableCriteriaIncentiveV2GetIncentiveCriteria,\n readErc20VariableCriteriaIncentiveV2GetMaxReward,\n} from '@boostxyz/evm';\nimport { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20VariableCriteriaIncentiveV2.sol/ERC20VariableCriteriaIncentiveV2.json';\nimport { getTransaction, getTransactionReceipt } from '@wagmi/core';\nimport {\n type AbiEvent,\n type AbiFunction,\n type Address,\n type GetLogsReturnType,\n type Hex,\n decodeAbiParameters,\n decodeFunctionData,\n encodeAbiParameters,\n parseEther,\n parseEventLogs,\n zeroAddress,\n zeroHash,\n} from 'viem';\nimport { ERC20VariableCriteriaIncentiveV2 as ERC20VariableCriteriaIncentiveV2Bases } from '../../dist/deployments.json';\nimport {\n SignatureType,\n ValueType,\n decodeAndReorderLogArgs,\n getScalarValue,\n} from '../Actions/EventAction';\nimport type {\n DeployableOptions,\n GenericDeployableParams,\n} from '../Deployable/Deployable';\nimport {\n DecodedArgsError,\n IncentiveCriteriaNotFoundError,\n InvalidCriteriaTypeError,\n NoMatchingLogsError,\n} from '../errors';\nimport { CheatCodes, type ReadParams } from '../utils';\nimport { ERC20VariableIncentive } from './ERC20VariableIncentive';\n\nexport { erc20VariableCriteriaIncentiveV2Abi };\n\nexport interface ERC20VariableCriteriaIncentiveV2Payload {\n /**\n * The address of the incentivized asset.\n *\n * @type {Address}\n */\n asset: Address;\n /**\n * The amount of the asset to distribute as reward.\n *\n * @type {bigint}\n */\n reward: bigint;\n /**\n * The total spending limit of the asset that will be distributed.\n *\n * @type {bigint}\n */\n limit: bigint;\n /**\n * The total amount claimable in a single claim or maximum per-action reward.\n *\n * @type {bigint}\n * @optional\n */\n maxReward?: bigint;\n /**\n * The criteria for the incentive that determines how the reward is distributed.\n *\n * @type {IncentiveCriteria}\n */\n criteria: IncentiveCriteriaV2;\n}\n\nexport interface IncentiveCriteriaV2 {\n /**\n * The type of criteria used, either function signature or event signature.\n *\n * @type {SignatureType}\n */\n criteriaType: SignatureType;\n /**\n * The function or event signature used for criteria matching.\n *\n * @type {Hex}\n */\n signature: Hex;\n /**\n * The index of the field from where the scalar value is extracted.\n *\n * @type {number}\n */\n fieldIndex: number;\n /**\n * The address of the contract where the event/function is called/emitted.\n *\n * @type {Address}\n */\n targetContract: Address;\n /**\n * The type of value used for the scalar value (RAW or WAD).\n * - RAW: Raw integer value (e.g., NFT quantity)\n * - WAD: Value with 18 decimals (e.g., token amount)\n *\n * @type {ValueType}\n */\n valueType: ValueType;\n}\n\nexport interface ReadIncentiveCriteriaV2Params extends ReadParams {}\n\nexport interface GetIncentiveScalarV2Params {\n chainId: number;\n hash: Hex;\n knownSignatures: Record<Hex, AbiFunction | AbiEvent>;\n logs?: GetLogsReturnType<AbiEvent, AbiEvent[], true>;\n}\n\n/**\n * Extended ERC20 Variable Criteria Incentive class that fetches incentive criteria and scalar\n *\n * @export\n * @class ERC20VariableCriteriaIncentive\n * @typedef {ERC20VariableCriteriaIncentiveV2}\n * @extends {ERC20VariableIncentive<ERC20VariableCriteriaIncentiveV2Payload, typeof erc20VariableCriteriaIncentiveV2Abi>}\n */\nexport class ERC20VariableCriteriaIncentiveV2 extends ERC20VariableIncentive<\n ERC20VariableCriteriaIncentiveV2Payload,\n typeof erc20VariableCriteriaIncentiveV2Abi,\n Promise<bigint>\n> {\n //@ts-expect-error instantiated correctly\n public override readonly abi = erc20VariableCriteriaIncentiveV2Abi;\n /**\n * @inheritdoc\n *\n * @public\n * @static\n * @type {Record<number, Address>}\n */\n public static override bases: Record<number, Address> = {\n ...(import.meta.env?.VITE_ERC20_VARIABLE_CRITERIA_INCENTIVE_V2_BASE\n ? {\n 31337: import.meta.env.VITE_ERC20_VARIABLE_CRITERIA_INCENTIVE_V2_BASE,\n }\n : {}),\n ...(ERC20VariableCriteriaIncentiveV2Bases as Record<number, Address>),\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<IncentiveCriteriaV2> {\n try {\n const criteria =\n await readErc20VariableCriteriaIncentiveV2GetIncentiveCriteria(\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 * Decodes claim data for the ERC20VariableCriteriaIncentiveV2, returning the claim amount.\n * Useful when deriving amount claimed from logs.\n *\n * @public\n * @param {Hex} claimData\n * @returns {Promise<bigint>} Returns the reward amount from a claim data payload\n */\n public override async decodeClaimData(claimData: Hex) {\n const boostClaimData = decodeAbiParameters(\n [\n {\n type: 'tuple',\n name: 'BoostClaimData',\n components: [\n { type: 'bytes', name: 'validatorData' },\n { type: 'bytes', name: 'incentiveData' },\n ],\n },\n ],\n claimData,\n );\n const signedAmount = decodeAbiParameters(\n [{ type: 'uint256' }],\n boostClaimData[0].incentiveData,\n )[0];\n let claimAmount = signedAmount;\n const [reward, maxReward] = await Promise.all([\n this.reward(),\n this.getMaxReward(),\n ]);\n\n if (reward === 0n) {\n return claimAmount;\n } else {\n claimAmount = (reward * signedAmount) / parseEther('1');\n }\n\n if (maxReward !== 0n && claimAmount > maxReward) {\n claimAmount = maxReward;\n }\n\n return claimAmount;\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 getMaxReward(params?: ReadParams): Promise<bigint> {\n const maxReward = await readErc20VariableCriteriaIncentiveV2GetMaxReward(\n this._config,\n {\n ...params,\n address: this.assertValidAddress(),\n },\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, logs }: GetIncentiveScalarV2Params,\n params?: ReadParams,\n ): Promise<bigint> {\n const criteria = await this.getIncentiveCriteria(params);\n if (criteria.criteriaType === SignatureType.EVENT) {\n const eventAbi = knownSignatures[criteria.signature] as AbiEvent;\n\n if (criteria.fieldIndex === CheatCodes.GAS_REBATE_INCENTIVE) {\n const transactionReceipt = await getTransactionReceipt(this._config, {\n chainId,\n hash,\n });\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\n // if logs are provided, use them to extract the scalar\n if (logs && logs.length > 0) {\n try {\n // only check logs that match the criteria signature\n const signatureMatchingLogs = logs\n .filter((log) => log.topics && log.topics[0] === criteria.signature)\n .map((log) => decodeAndReorderLogArgs(eventAbi, log));\n\n if (signatureMatchingLogs.length > 0) {\n for (const log of signatureMatchingLogs) {\n try {\n return getScalarValue(\n log.args as unknown[],\n criteria.fieldIndex,\n );\n } catch {\n continue;\n }\n }\n }\n } catch (e) {\n throw new DecodedArgsError(\n `An error occurred while extracting scalar from logs: ${(e as Error).message}`,\n );\n }\n }\n\n const transactionReceipt = await getTransactionReceipt(this._config, {\n chainId,\n hash,\n });\n const receiptLogs = transactionReceipt.logs;\n\n if (receiptLogs.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 const eventAbi = knownSignatures[criteria.signature] as AbiEvent;\n const decodedEvents = parseEventLogs({\n abi: [eventAbi],\n logs: receiptLogs,\n });\n if (decodedEvents == undefined || decodedEvents.length === 0) {\n throw new NoMatchingLogsError(\n `No logs found for event signature ${criteria.signature}`,\n );\n }\n\n return getScalarValue(\n decodedEvents[0]?.args as unknown[],\n criteria.fieldIndex,\n );\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\n return getScalarValue(\n decodedFunction.args as unknown[],\n criteria.fieldIndex,\n );\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 * @inheritdoc\n *\n * @public\n * @param {?ERC20VariableCriteriaIncentiveV2Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public override buildParameters(\n _payload?: ERC20VariableCriteriaIncentiveV2Payload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n return {\n abi: erc20VariableCriteriaIncentiveV2Abi,\n bytecode: bytecode as Hex,\n args: [prepareERC20VariableCriteriaIncentiveV2Payload(payload)],\n ...this.optionallyAttachAccount(options.account),\n };\n }\n}\n\n/**\n * Creates an IncentiveCriteria object representing a gas rebate incentive.\n * This object defines a variable incentive criteria where the criteria will be the gas spent.\n *\n * The criteria uses a signatureType of EVENT, with a special `fieldIndex` of 255 (using CheatCodes enum), which indicates\n * that the entire gas cost of the transaction will be used as the scalar value. If you don't want to\n * rebate the entire gas cost, you can use a reward value on the incentive..\n *\n * - `criteriaType`: EVENT, indicating it's based on event logs.\n * - `signature`: A zeroed signature (0x0000...0000), matching any event.\n * - `fieldIndex`: 255, indicating the use of transaction gas cost using CheatCodes enum.\n * - `targetContract`: A zeroed address (0x0000...0000), applicable to any contract.\n *\n * @returns {IncentiveCriteria} Returns an IncentiveCriteria object for a gas rebate.\n *\n * @example\n * const incentive = gasRebateIncentiveCriteria();\n * const actionPayload = {\n * criteria: incentive,\n * asset: \"0xAssetAddress\",\n * reward: 0, // Set to zero to rebate the entire gas cost\n * limit: BigInt(1000) // This is the total spend limit for the incentive\n * };\n * deployIncentive(actionPayload);\n */\nexport function gasRebateIncentiveCriteriaV2(): IncentiveCriteriaV2 {\n return {\n criteriaType: SignatureType.EVENT,\n signature: zeroHash,\n fieldIndex: CheatCodes.GAS_REBATE_INCENTIVE,\n targetContract: zeroAddress,\n valueType: ValueType.WAD,\n };\n}\n\n/**\n *\n *\n * @param {InitPayloadExtended} param0\n * @param {Address} param0.asset - The address of the ERC20 asset to incentivize.\n * @param {bigint} param0.reward - The reward amount to distribute per action.\n * @param {bigint} param0.limit - The total limit of the asset distribution.\n * @param {bigint} param0.maxReward - The maximum value claimable from a single completion.\n * @param {IncentiveCriteria} param0.criteria - The incentive criteria for reward distribution.\n * @returns {Hex}\n */\nexport function prepareERC20VariableCriteriaIncentiveV2Payload({\n asset,\n reward,\n limit,\n maxReward = 0n,\n criteria,\n}: ERC20VariableCriteriaIncentiveV2Payload) {\n return encodeAbiParameters(\n [\n {\n type: 'tuple',\n name: 'initPayloadExtended',\n components: [\n { type: 'address', name: 'asset' },\n { type: 'uint256', name: 'reward' },\n { type: 'uint256', name: 'limit' },\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 { type: 'uint8', name: 'valueType' },\n ],\n },\n ],\n },\n ],\n [\n {\n asset: asset,\n reward: reward,\n limit: limit,\n maxReward: maxReward,\n criteria: {\n criteriaType: criteria.criteriaType,\n signature: criteria.signature,\n fieldIndex: criteria.fieldIndex,\n targetContract: criteria.targetContract,\n valueType: criteria.valueType,\n },\n },\n ],\n );\n}\n"],"names":["_ERC20VariableCriteriaIncentiveV2","ERC20VariableIncentive","erc20VariableCriteriaIncentiveV2Abi","params","readErc20VariableCriteriaIncentiveV2GetIncentiveCriteria","e","IncentiveCriteriaNotFoundError","claimData","boostClaimData","decodeAbiParameters","signedAmount","claimAmount","reward","maxReward","parseEther","readErc20VariableCriteriaIncentiveV2GetMaxReward","chainId","hash","knownSignatures","logs","criteria","SignatureType","eventAbi","CheatCodes","transactionReceipt","getTransactionReceipt","signatureMatchingLogs","log","decodeAndReorderLogArgs","getScalarValue","DecodedArgsError","receiptLogs","NoMatchingLogsError","decodedEvents","parseEventLogs","_a","transaction","getTransaction","func","decodedFunction","decodeFunctionData","InvalidCriteriaTypeError","_payload","_options","payload","options","bytecode","prepareERC20VariableCriteriaIncentiveV2Payload","__vite_import_meta_env__","ERC20VariableCriteriaIncentiveV2Bases","ERC20VariableCriteriaIncentiveV2","gasRebateIncentiveCriteriaV2","zeroHash","zeroAddress","ValueType","asset","limit","encodeAbiParameters"],"mappings":";;;;;;;;m5iBAiIaA,IAAN,MAAMA,UAAyCC,EAIpD;AAAA,EAJK,cAAA;AAAA,UAAA,GAAA,SAAA,GAML,KAAyB,MAAMC;AAAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4B/B,MAAa,qBACXC,GAC8B;AAC1B,QAAA;AAUK,aARL,MAAMC;AAAAA,QACJ,KAAK;AAAA,QACL;AAAA,UACE,GAAGD;AAAA,UACH,SAAS,KAAK,mBAAmB;AAAA,QACnC;AAAA,MAAA;AAAA,aAIGE,GAAG;AACJ,YAAA,IAAIC,EAA+BD,CAAU;AAAA,IACrD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAsB,gBAAgBE,GAAgB;AACpD,UAAMC,IAAiBC;AAAA,MACrB;AAAA,QACE;AAAA,UACE,MAAM;AAAA,UACN,MAAM;AAAA,UACN,YAAY;AAAA,YACV,EAAE,MAAM,SAAS,MAAM,gBAAgB;AAAA,YACvC,EAAE,MAAM,SAAS,MAAM,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MAAM;AAAA,QACN,MAAM;AAAA,QACN,YAAY;AAAA,UACV,EAAE,MAAM,WAAW,MAAM,QAAQ;AAAA,UACjC,EAAE,MAAM,WAAW,MAAM,SAAS;AAAA,UAClC,EAAE,MAAM,WAAW,MAAM,QAAQ;AAAA,UACjC,EAAE,MAAM,WAAW,MAAM,YAAY;AAAA,UACrC;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,YAAY;AAAA,cACV,EAAE,MAAM,SAAS,MAAM,eAAe;AAAA,cACtC,EAAE,MAAM,WAAW,MAAM,YAAY;AAAA,cACrC,EAAE,MAAM,SAAS,MAAM,aAAa;AAAA,cACpC,EAAE,MAAM,WAAW,MAAM,iBAAiB;AAAA,cAC1C,EAAE,MAAM,SAAS,MAAM,YAAY;AAAA,YACrC;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,QACE,OAAAF;AAAA,QACA,QAAA3C;AAAA,QACA,OAAA4C;AAAA,QACA,WAAA3C;AAAA,QACA,UAAU;AAAA,UACR,cAAcO,EAAS;AAAA,UACvB,WAAWA,EAAS;AAAA,UACpB,YAAYA,EAAS;AAAA,UACrB,gBAAgBA,EAAS;AAAA,UACzB,WAAWA,EAAS;AAAA,QACtB;AAAA,MACF;AAAA,IACF;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"ERC20VariableCriteriaIncentiveV2.js","sources":["../../src/Incentives/ERC20VariableCriteriaIncentiveV2.ts"],"sourcesContent":["import {\n erc20VariableCriteriaIncentiveV2Abi,\n readErc20VariableCriteriaIncentiveV2GetIncentiveCriteria,\n readErc20VariableCriteriaIncentiveV2GetMaxReward,\n} from '@boostxyz/evm';\nimport { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC20VariableCriteriaIncentiveV2.sol/ERC20VariableCriteriaIncentiveV2.json';\nimport { getTransaction, getTransactionReceipt } from '@wagmi/core';\nimport {\n type AbiEvent,\n type AbiFunction,\n type Address,\n type GetLogsReturnType,\n type Hex,\n decodeAbiParameters,\n decodeFunctionData,\n encodeAbiParameters,\n parseEther,\n parseEventLogs,\n zeroAddress,\n zeroHash,\n} from 'viem';\nimport { ERC20VariableCriteriaIncentiveV2 as ERC20VariableCriteriaIncentiveV2Bases } from '../../dist/deployments.json';\nimport {\n SignatureType,\n ValueType,\n decodeAndReorderLogArgs,\n getScalarValue,\n} from '../Actions/EventAction';\nimport type {\n DeployableOptions,\n GenericDeployableParams,\n} from '../Deployable/Deployable';\nimport {\n DecodedArgsError,\n IncentiveCriteriaNotFoundError,\n InvalidCriteriaTypeError,\n NoMatchingLogsError,\n} from '../errors';\nimport { CheatCodes, type ReadParams } from '../utils';\nimport { ERC20VariableIncentive } from './ERC20VariableIncentive';\n\nexport { erc20VariableCriteriaIncentiveV2Abi };\n\nexport interface ERC20VariableCriteriaIncentiveV2Payload {\n /**\n * The address of the incentivized asset.\n *\n * @type {Address}\n */\n asset: Address;\n /**\n * The amount of the asset to distribute as reward.\n *\n * @type {bigint}\n */\n reward: bigint;\n /**\n * The total spending limit of the asset that will be distributed.\n *\n * @type {bigint}\n */\n limit: bigint;\n /**\n * The total amount claimable in a single claim or maximum per-action reward.\n *\n * @type {bigint}\n * @optional\n */\n maxReward?: bigint;\n /**\n * The criteria for the incentive that determines how the reward is distributed.\n *\n * @type {IncentiveCriteria}\n */\n criteria: IncentiveCriteriaV2;\n}\n\nexport interface IncentiveCriteriaV2 {\n /**\n * The type of criteria used, either function signature or event signature.\n *\n * @type {SignatureType}\n */\n criteriaType: SignatureType;\n /**\n * The function or event signature used for criteria matching.\n *\n * @type {Hex}\n */\n signature: Hex;\n /**\n * The index of the field from where the scalar value is extracted.\n *\n * @type {number}\n */\n fieldIndex: number;\n /**\n * The address of the contract where the event/function is called/emitted.\n *\n * @type {Address}\n */\n targetContract: Address;\n /**\n * The type of value used for the scalar value (RAW or WAD).\n * - RAW: Raw integer value (e.g., NFT quantity)\n * - WAD: Value with 18 decimals (e.g., token amount)\n *\n * @type {ValueType}\n */\n valueType: ValueType;\n}\n\nexport interface ReadIncentiveCriteriaV2Params extends ReadParams {}\n\nexport interface GetIncentiveScalarV2Params {\n chainId: number;\n hash: Hex;\n knownSignatures: Record<Hex, AbiFunction | AbiEvent>;\n logs?: GetLogsReturnType<AbiEvent, AbiEvent[], true>;\n}\n\n/**\n * Extended ERC20 Variable Criteria Incentive class that fetches incentive criteria and scalar\n *\n * @export\n * @class ERC20VariableCriteriaIncentive\n * @typedef {ERC20VariableCriteriaIncentiveV2}\n * @extends {ERC20VariableIncentive<ERC20VariableCriteriaIncentiveV2Payload, typeof erc20VariableCriteriaIncentiveV2Abi>}\n */\nexport class ERC20VariableCriteriaIncentiveV2 extends ERC20VariableIncentive<\n ERC20VariableCriteriaIncentiveV2Payload,\n typeof erc20VariableCriteriaIncentiveV2Abi,\n Promise<bigint>\n> {\n //@ts-expect-error instantiated correctly\n public override readonly abi = erc20VariableCriteriaIncentiveV2Abi;\n /**\n * @inheritdoc\n *\n * @public\n * @static\n * @type {Record<number, Address>}\n */\n public static override bases: Record<number, Address> = {\n ...(import.meta.env?.VITE_ERC20_VARIABLE_CRITERIA_INCENTIVE_V2_BASE\n ? {\n 31337: import.meta.env.VITE_ERC20_VARIABLE_CRITERIA_INCENTIVE_V2_BASE,\n }\n : {}),\n ...(ERC20VariableCriteriaIncentiveV2Bases as Record<number, Address>),\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<IncentiveCriteriaV2> {\n try {\n const criteria =\n await readErc20VariableCriteriaIncentiveV2GetIncentiveCriteria(\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 * Decodes claim data for the ERC20VariableCriteriaIncentiveV2, returning the claim amount.\n * Useful when deriving amount claimed from logs.\n *\n * @public\n * @param {Hex} claimData\n * @returns {Promise<bigint>} Returns the reward amount from a claim data payload\n */\n public override async decodeClaimData(claimData: Hex) {\n const boostClaimData = decodeAbiParameters(\n [\n {\n type: 'tuple',\n name: 'BoostClaimData',\n components: [\n { type: 'bytes', name: 'validatorData' },\n { type: 'bytes', name: 'incentiveData' },\n ],\n },\n ],\n claimData,\n );\n const signedAmount = decodeAbiParameters(\n [{ type: 'uint256' }],\n boostClaimData[0].incentiveData,\n )[0];\n let claimAmount = signedAmount;\n const [reward, maxReward] = await Promise.all([\n this.reward(),\n this.getMaxReward(),\n ]);\n\n if (reward === 0n) {\n return claimAmount;\n } else {\n claimAmount = (reward * signedAmount) / parseEther('1');\n }\n\n if (maxReward !== 0n && claimAmount > maxReward) {\n claimAmount = maxReward;\n }\n\n return claimAmount;\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 getMaxReward(params?: ReadParams): Promise<bigint> {\n const maxReward = await readErc20VariableCriteriaIncentiveV2GetMaxReward(\n this._config,\n {\n ...params,\n address: this.assertValidAddress(),\n },\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, logs }: GetIncentiveScalarV2Params,\n params?: ReadParams,\n ): Promise<bigint> {\n const criteria = await this.getIncentiveCriteria(params);\n if (criteria.criteriaType === SignatureType.EVENT) {\n const eventAbi = knownSignatures[criteria.signature] as AbiEvent;\n\n if (criteria.fieldIndex === CheatCodes.GAS_REBATE_INCENTIVE) {\n const transactionReceipt = await getTransactionReceipt(this._config, {\n chainId,\n hash,\n });\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\n // if logs are provided, use them to extract the scalar\n if (logs && logs.length > 0) {\n try {\n // only check logs that match the criteria signature\n const signatureMatchingLogs = logs\n .filter((log) => log.topics && log.topics[0] === criteria.signature)\n .map((log) => decodeAndReorderLogArgs(eventAbi, log));\n\n if (signatureMatchingLogs.length > 0) {\n for (const log of signatureMatchingLogs) {\n try {\n return getScalarValue(\n log.args as unknown[],\n criteria.fieldIndex,\n );\n } catch {\n continue;\n }\n }\n }\n } catch (e) {\n throw new DecodedArgsError(\n `An error occurred while extracting scalar from logs: ${(e as Error).message}`,\n );\n }\n }\n\n const transactionReceipt = await getTransactionReceipt(this._config, {\n chainId,\n hash,\n });\n const receiptLogs = transactionReceipt.logs;\n\n if (receiptLogs.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 const eventAbi = knownSignatures[criteria.signature] as AbiEvent;\n const decodedEvents = parseEventLogs({\n abi: [eventAbi],\n logs: receiptLogs,\n });\n if (decodedEvents == undefined || decodedEvents.length === 0) {\n throw new NoMatchingLogsError(\n `No logs found for event signature ${criteria.signature}`,\n );\n }\n\n return getScalarValue(\n decodedEvents[0]?.args as unknown[],\n criteria.fieldIndex,\n );\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\n return getScalarValue(\n decodedFunction.args as unknown[],\n criteria.fieldIndex,\n );\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 * @inheritdoc\n *\n * @public\n * @param {?ERC20VariableCriteriaIncentiveV2Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public override buildParameters(\n _payload?: ERC20VariableCriteriaIncentiveV2Payload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n return {\n abi: erc20VariableCriteriaIncentiveV2Abi,\n bytecode: bytecode as Hex,\n args: [prepareERC20VariableCriteriaIncentiveV2Payload(payload)],\n ...this.optionallyAttachAccount(options.account),\n };\n }\n}\n\n/**\n * Creates an IncentiveCriteria object representing a gas rebate incentive.\n * This object defines a variable incentive criteria where the criteria will be the gas spent.\n *\n * The criteria uses a signatureType of EVENT, with a special `fieldIndex` of 255 (using CheatCodes enum), which indicates\n * that the entire gas cost of the transaction will be used as the scalar value. If you don't want to\n * rebate the entire gas cost, you can use a reward value on the incentive..\n *\n * - `criteriaType`: EVENT, indicating it's based on event logs.\n * - `signature`: A zeroed signature (0x0000...0000), matching any event.\n * - `fieldIndex`: 255, indicating the use of transaction gas cost using CheatCodes enum.\n * - `targetContract`: A zeroed address (0x0000...0000), applicable to any contract.\n *\n * @returns {IncentiveCriteria} Returns an IncentiveCriteria object for a gas rebate.\n *\n * @example\n * const incentive = gasRebateIncentiveCriteria();\n * const actionPayload = {\n * criteria: incentive,\n * asset: \"0xAssetAddress\",\n * reward: 0, // Set to zero to rebate the entire gas cost\n * limit: BigInt(1000) // This is the total spend limit for the incentive\n * };\n * deployIncentive(actionPayload);\n */\nexport function gasRebateIncentiveCriteriaV2(): IncentiveCriteriaV2 {\n return {\n criteriaType: SignatureType.EVENT,\n signature: zeroHash,\n fieldIndex: CheatCodes.GAS_REBATE_INCENTIVE,\n targetContract: zeroAddress,\n valueType: ValueType.WAD,\n };\n}\n\n/**\n *\n *\n * @param {InitPayloadExtended} param0\n * @param {Address} param0.asset - The address of the ERC20 asset to incentivize.\n * @param {bigint} param0.reward - The reward amount to distribute per action.\n * @param {bigint} param0.limit - The total limit of the asset distribution.\n * @param {bigint} param0.maxReward - The maximum value claimable from a single completion.\n * @param {IncentiveCriteria} param0.criteria - The incentive criteria for reward distribution.\n * @returns {Hex}\n */\nexport function prepareERC20VariableCriteriaIncentiveV2Payload({\n asset,\n reward,\n limit,\n maxReward = 0n,\n criteria,\n}: ERC20VariableCriteriaIncentiveV2Payload) {\n return encodeAbiParameters(\n [\n {\n type: 'tuple',\n name: 'initPayloadExtended',\n components: [\n { type: 'address', name: 'asset' },\n { type: 'uint256', name: 'reward' },\n { type: 'uint256', name: 'limit' },\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: 'uint32', name: 'fieldIndex' },\n { type: 'address', name: 'targetContract' },\n { type: 'uint8', name: 'valueType' },\n ],\n },\n ],\n },\n ],\n [\n {\n asset: asset,\n reward: reward,\n limit: limit,\n maxReward: maxReward,\n criteria: {\n criteriaType: criteria.criteriaType,\n signature: criteria.signature,\n fieldIndex: criteria.fieldIndex,\n targetContract: criteria.targetContract,\n valueType: criteria.valueType,\n },\n },\n ],\n );\n}\n"],"names":["_ERC20VariableCriteriaIncentiveV2","ERC20VariableIncentive","erc20VariableCriteriaIncentiveV2Abi","params","readErc20VariableCriteriaIncentiveV2GetIncentiveCriteria","e","IncentiveCriteriaNotFoundError","claimData","boostClaimData","decodeAbiParameters","signedAmount","claimAmount","reward","maxReward","parseEther","readErc20VariableCriteriaIncentiveV2GetMaxReward","chainId","hash","knownSignatures","logs","criteria","SignatureType","eventAbi","CheatCodes","transactionReceipt","getTransactionReceipt","signatureMatchingLogs","log","decodeAndReorderLogArgs","getScalarValue","DecodedArgsError","receiptLogs","NoMatchingLogsError","decodedEvents","parseEventLogs","_a","transaction","getTransaction","func","decodedFunction","decodeFunctionData","InvalidCriteriaTypeError","_payload","_options","payload","options","bytecode","prepareERC20VariableCriteriaIncentiveV2Payload","__vite_import_meta_env__","ERC20VariableCriteriaIncentiveV2Bases","ERC20VariableCriteriaIncentiveV2","gasRebateIncentiveCriteriaV2","zeroHash","zeroAddress","ValueType","asset","limit","encodeAbiParameters"],"mappings":";;;;;;;;m5iBAiIaA,IAAN,MAAMA,UAAyCC,EAIpD;AAAA,EAJK,cAAA;AAAA,UAAA,GAAA,SAAA,GAML,KAAyB,MAAMC;AAAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4B/B,MAAa,qBACXC,GAC8B;AAC1B,QAAA;AAUK,aARL,MAAMC;AAAAA,QACJ,KAAK;AAAA,QACL;AAAA,UACE,GAAGD;AAAA,UACH,SAAS,KAAK,mBAAmB;AAAA,QACnC;AAAA,MAAA;AAAA,aAIGE,GAAG;AACJ,YAAA,IAAIC,EAA+BD,CAAU;AAAA,IACrD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAsB,gBAAgBE,GAAgB;AACpD,UAAMC,IAAiBC;AAAA,MACrB;AAAA,QACE;AAAA,UACE,MAAM;AAAA,UACN,MAAM;AAAA,UACN,YAAY;AAAA,YACV,EAAE,MAAM,SAAS,MAAM,gBAAgB;AAAA,YACvC,EAAE,MAAM,SAAS,MAAM,gBAAgB;AAAA,UACzC;AAAA,QACF;AAAA,MACF;AAAA,MACAF;AAAA,IAAA,GAEIG,IAAeD;AAAA,MACnB,CAAC,EAAE,MAAM,WAAW;AAAA,MACpBD,EAAe,CAAC,EAAE;AA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AW,MAAM,QAAQ;AAAA,UACjC,EAAE,MAAM,WAAW,MAAM,YAAY;AAAA,UACrC;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,YAAY;AAAA,cACV,EAAE,MAAM,SAAS,MAAM,eAAe;AAAA,cACtC,EAAE,MAAM,WAAW,MAAM,YAAY;AAAA,cACrC,EAAE,MAAM,UAAU,MAAM,aAAa;AAAA,cACrC,EAAE,MAAM,WAAW,MAAM,iBAAiB;AAAA,cAC1C,EAAE,MAAM,SAAS,MAAM,YAAY;AAAA,YACrC;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,QACE,OAAAF;AAAA,QACA,QAAA3C;AAAA,QACA,OAAA4C;AAAA,QACA,WAAA3C;AAAA,QACA,UAAU;AAAA,UACR,cAAcO,EAAS;AAAA,UACvB,WAAWA,EAAS;AAAA,UACpB,YAAYA,EAAS;AAAA,UACrB,gBAAgBA,EAAS;AAAA,UACzB,WAAWA,EAAS;AAAA,QACtB;AAAA,MACF;AAAA,IACF;AAAA,EAAA;AAEJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boostxyz/sdk",
3
- "version": "8.0.0-canary.2",
3
+ "version": "8.0.0-canary.3",
4
4
  "license": "GPL-3.0-or-later",
5
5
  "type": "module",
6
6
  "files": [
@@ -1668,7 +1668,7 @@ export function prepareEventActionPayload({
1668
1668
  components: [
1669
1669
  { type: 'uint8', name: 'signatureType' },
1670
1670
  { type: 'bytes32', name: 'signature' },
1671
- { type: 'uint8', name: 'fieldIndex' },
1671
+ { type: 'uint32', name: 'fieldIndex' },
1672
1672
  { type: 'address', name: 'targetContract' },
1673
1673
  { type: 'uint256', name: 'chainid' },
1674
1674
  ],
@@ -877,7 +877,7 @@ export function prepareERC20PeggedVariableCriteriaIncentiveV2Payload({
877
877
  components: [
878
878
  { type: 'uint8', name: 'criteriaType' },
879
879
  { type: 'bytes32', name: 'signature' },
880
- { type: 'uint8', name: 'fieldIndex' },
880
+ { type: 'uint32', name: 'fieldIndex' },
881
881
  { type: 'address', name: 'targetContract' },
882
882
  { type: 'uint8', name: 'valueType' },
883
883
  ],
@@ -457,7 +457,7 @@ export function prepareERC20VariableCriteriaIncentiveV2Payload({
457
457
  components: [
458
458
  { type: 'uint8', name: 'criteriaType' },
459
459
  { type: 'bytes32', name: 'signature' },
460
- { type: 'uint8', name: 'fieldIndex' },
460
+ { type: 'uint32', name: 'fieldIndex' },
461
461
  { type: 'address', name: 'targetContract' },
462
462
  { type: 'uint8', name: 'valueType' },
463
463
  ],