@boostxyz/sdk 6.1.3 → 7.0.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Actions/Action.cjs +1 -1
- package/dist/Actions/Action.js +7 -7
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +10 -0
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +77 -76
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.js +5 -5
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +17 -17
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.js +3 -3
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/BoostCore.cjs +2 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +1894 -267
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +831 -520
- package/dist/BoostCore.js.map +1 -1
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.js +48 -48
- package/dist/Budget-BgGihcwx.js +1124 -0
- package/dist/Budget-BgGihcwx.js.map +1 -0
- package/dist/Budget-DYlTLLwg.cjs +2 -0
- package/dist/Budget-DYlTLLwg.cjs.map +1 -0
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.d.ts +5 -4
- package/dist/Budgets/Budget.d.ts.map +1 -1
- package/dist/Budgets/Budget.js +9 -6
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +4 -0
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +22 -22
- package/dist/Budgets/ManagedBudgetWithFees.d.ts +4 -0
- package/dist/Budgets/ManagedBudgetWithFees.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudgetWithFeesV2.d.ts +4 -0
- package/dist/Budgets/ManagedBudgetWithFeesV2.d.ts.map +1 -1
- package/dist/Budgets/TransparentBudget.d.ts +944 -0
- package/dist/Budgets/TransparentBudget.d.ts.map +1 -0
- package/dist/Budgets/VestingBudget.d.ts +4 -0
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/Deployable.cjs.map +1 -1
- package/dist/Deployable/Deployable.d.ts +1 -1
- package/dist/Deployable/Deployable.d.ts.map +1 -1
- package/dist/Deployable/Deployable.js.map +1 -1
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.js +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.js +20 -20
- package/dist/Incentive-BDqkFt0J.cjs +2 -0
- package/dist/Incentive-BDqkFt0J.cjs.map +1 -0
- package/dist/Incentive-DPOADY1f.js +449 -0
- package/dist/Incentive-DPOADY1f.js.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +14 -14
- package/dist/Incentives/AllowListIncentive.js.map +1 -1
- package/dist/Incentives/CGDAIncentive.cjs +1 -1
- package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +11 -11
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +14 -14
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/Incentives/ERC20PeggedIncentive.d.ts +1 -1
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.cjs +2 -0
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.cjs.map +1 -0
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.d.ts +3 -1
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.js +604 -0
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.js.map +1 -0
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.cjs +2 -0
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.cjs.map +1 -0
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.d.ts +1103 -0
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.d.ts.map +1 -0
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.js +625 -0
- package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.js.map +1 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs +1 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs.map +1 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +11 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.js +112 -80
- package/dist/Incentives/ERC20VariableCriteriaIncentive.js.map +1 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.cjs +2 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.cjs.map +1 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.d.ts +903 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.js +242 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.js.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.cjs +1 -1
- package/dist/Incentives/ERC20VariableIncentive.cjs.map +1 -1
- package/dist/Incentives/ERC20VariableIncentive.d.ts +3 -3
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20VariableIncentive.js +22 -22
- package/dist/Incentives/ERC20VariableIncentive.js.map +1 -1
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.d.ts +8 -6
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +19 -14
- package/dist/Incentives/Incentive.js.map +1 -1
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -1
- package/dist/Incentives/PointsIncentive.js +9 -9
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/SimpleDenyList-B_AcmgYq.cjs +2 -0
- package/dist/{SimpleDenyList-DgjVf7FK.cjs.map → SimpleDenyList-B_AcmgYq.cjs.map} +1 -1
- package/dist/SimpleDenyList-BbDLzRw7.js +133 -0
- package/dist/{SimpleDenyList-BKfPoTo1.js.map → SimpleDenyList-BbDLzRw7.js.map} +1 -1
- package/dist/Validators/LimitedSignerValidator.cjs +1 -1
- package/dist/Validators/LimitedSignerValidator.cjs.map +1 -1
- package/dist/Validators/LimitedSignerValidator.js +13 -13
- package/dist/Validators/LimitedSignerValidator.js.map +1 -1
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.js +52 -52
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.js +2 -2
- package/dist/componentInterfaces-C5ig8mCK.cjs +2 -0
- package/dist/componentInterfaces-C5ig8mCK.cjs.map +1 -0
- package/dist/componentInterfaces-Ddus5rIA.js +23 -0
- package/dist/componentInterfaces-Ddus5rIA.js.map +1 -0
- package/dist/deployments-C17nvui-.cjs +2 -0
- package/dist/deployments-C17nvui-.cjs.map +1 -0
- package/dist/deployments-CH4Xmkbv.js +132 -0
- package/dist/{deployments-W_LUj833.js.map → deployments-CH4Xmkbv.js.map} +1 -1
- package/dist/deployments.json +63 -48
- package/dist/{generated-CElkFqkY.js → generated-CINzoGbl.js} +2611 -955
- package/dist/generated-CINzoGbl.js.map +1 -0
- package/dist/generated-C_JEoLDO.cjs +3 -0
- package/dist/generated-C_JEoLDO.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +167 -154
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +20 -2
- package/src/Actions/EventAction.ts +11 -0
- package/src/BoostCore.test.ts +14 -9
- package/src/BoostCore.ts +428 -26
- package/src/Budgets/Budget.ts +8 -1
- package/src/Budgets/TransparentBudget.test.ts +70 -0
- package/src/Budgets/TransparentBudget.ts +334 -0
- package/src/Deployable/Deployable.ts +1 -1
- package/src/Incentives/ERC20PeggedIncentive.ts +1 -1
- package/src/Incentives/ERC20PeggedVariableCriteriaIncentive.ts +3 -1
- package/src/Incentives/{ERC20PeggedVariableCriteriaIncentive.test.ts → ERC20PeggedVariableCriteriaIncentiveV2.test.ts} +20 -16
- package/src/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.ts +872 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +50 -1
- package/src/Incentives/{ERC20VariableCriteriaIncentive.test.ts → ERC20VariableCriteriaIncentiveV2.test.ts} +24 -19
- package/src/Incentives/ERC20VariableCriteriaIncentiveV2.ts +447 -0
- package/src/Incentives/ERC20VariableIncentive.ts +4 -2
- package/src/Incentives/Incentive.ts +13 -2
- package/src/index.test.ts +2 -2
- package/src/index.ts +3 -0
- package/src/utils.ts +1 -1
- package/dist/Budget-BjfL8dVX.cjs +0 -2
- package/dist/Budget-BjfL8dVX.cjs.map +0 -1
- package/dist/Budget-DD7IPuDx.js +0 -922
- package/dist/Budget-DD7IPuDx.js.map +0 -1
- package/dist/Incentive-V1RjH38L.js +0 -1036
- package/dist/Incentive-V1RjH38L.js.map +0 -1
- package/dist/Incentive-gVTfsnMB.cjs +0 -2
- package/dist/Incentive-gVTfsnMB.cjs.map +0 -1
- package/dist/SimpleDenyList-BKfPoTo1.js +0 -133
- package/dist/SimpleDenyList-DgjVf7FK.cjs +0 -2
- package/dist/componentInterfaces-CA1UIqWL.js +0 -20
- package/dist/componentInterfaces-CA1UIqWL.js.map +0 -1
- package/dist/componentInterfaces-aBgBbB7r.cjs +0 -2
- package/dist/componentInterfaces-aBgBbB7r.cjs.map +0 -1
- package/dist/deployments-CwTZr-cK.cjs +0 -2
- package/dist/deployments-CwTZr-cK.cjs.map +0 -1
- package/dist/deployments-W_LUj833.js +0 -117
- package/dist/generated-BPiHi7W2.cjs +0 -3
- package/dist/generated-BPiHi7W2.cjs.map +0 -1
- package/dist/generated-CElkFqkY.js.map +0 -1
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readTransparentBudgetDistributed,
|
|
3
|
+
readTransparentBudgetOwner,
|
|
4
|
+
readTransparentBudgetTotal,
|
|
5
|
+
simulateTransparentBudgetClawbackFromTarget,
|
|
6
|
+
simulateTransparentBudgetDisburse,
|
|
7
|
+
simulateTransparentBudgetDisburseBatch,
|
|
8
|
+
transparentBudgetAbi,
|
|
9
|
+
writeTransparentBudgetClawbackFromTarget,
|
|
10
|
+
writeTransparentBudgetDisburse,
|
|
11
|
+
writeTransparentBudgetDisburseBatch,
|
|
12
|
+
} from '@boostxyz/evm';
|
|
13
|
+
import { bytecode } from '@boostxyz/evm/artifacts/contracts/budgets/TransparentBudget.sol/TransparentBudget.json';
|
|
14
|
+
import {
|
|
15
|
+
type Address,
|
|
16
|
+
type ContractEventName,
|
|
17
|
+
type Hex,
|
|
18
|
+
zeroAddress,
|
|
19
|
+
zeroHash,
|
|
20
|
+
} from 'viem';
|
|
21
|
+
import { TransparentBudget as TransparentBudgetBases } from '../../dist/deployments.json';
|
|
22
|
+
import type {
|
|
23
|
+
DeployableOptions,
|
|
24
|
+
GenericDeployableParams,
|
|
25
|
+
} from '../Deployable/Deployable';
|
|
26
|
+
import { DeployableTargetWithRBAC } from '../Deployable/DeployableTargetWithRBAC';
|
|
27
|
+
import type {
|
|
28
|
+
ERC1155TransferPayload,
|
|
29
|
+
FungibleTransferPayload,
|
|
30
|
+
} from '../transfers';
|
|
31
|
+
import {
|
|
32
|
+
type GenericLog,
|
|
33
|
+
type ReadParams,
|
|
34
|
+
RegistryType,
|
|
35
|
+
type WriteParams,
|
|
36
|
+
} from '../utils';
|
|
37
|
+
import { prepareTransfer } from './ManagedBudget';
|
|
38
|
+
export { transparentBudgetAbi };
|
|
39
|
+
export type { ERC1155TransferPayload, FungibleTransferPayload };
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A generic `viem.Log` event with support for `TransparentBudget` event types.
|
|
43
|
+
*
|
|
44
|
+
* @export
|
|
45
|
+
* @typedef {TransparentBudgetLog}
|
|
46
|
+
* @template {ContractEventName<typeof transparentBudgetAbi>} [event=ContractEventName<
|
|
47
|
+
* typeof transparentBudgetAbi
|
|
48
|
+
* >]
|
|
49
|
+
*/
|
|
50
|
+
export type TransparentBudgetLog<
|
|
51
|
+
event extends ContractEventName<
|
|
52
|
+
typeof transparentBudgetAbi
|
|
53
|
+
> = ContractEventName<typeof transparentBudgetAbi>,
|
|
54
|
+
> = GenericLog<typeof transparentBudgetAbi, event>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A budget implementation that transfers assets to the budget on Boost creation.
|
|
58
|
+
* Can be used with or without [Permit2](https://github.com/Uniswap/permit2) for token approval
|
|
59
|
+
*
|
|
60
|
+
* @export
|
|
61
|
+
* @class TransparentBudget
|
|
62
|
+
* @typedef {TransparentBudget}
|
|
63
|
+
* @extends {DeployableTargetWithRBAC<TransparentBudgetPayload>}
|
|
64
|
+
*/
|
|
65
|
+
export class TransparentBudget extends DeployableTargetWithRBAC<
|
|
66
|
+
never,
|
|
67
|
+
typeof transparentBudgetAbi
|
|
68
|
+
> {
|
|
69
|
+
/**
|
|
70
|
+
* @inheritdoc
|
|
71
|
+
*
|
|
72
|
+
* @public
|
|
73
|
+
* @readonly
|
|
74
|
+
* @type {*}
|
|
75
|
+
*/
|
|
76
|
+
public override readonly abi = transparentBudgetAbi;
|
|
77
|
+
/**
|
|
78
|
+
* @inheritdoc
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
* @static
|
|
82
|
+
* @type {Record<number, Address>}
|
|
83
|
+
*/
|
|
84
|
+
public static override bases: Record<number, Address> = {
|
|
85
|
+
31337: import.meta.env.VITE_TRANSPARENT_BUDGET_BASE,
|
|
86
|
+
...(TransparentBudgetBases as Record<number, Address>),
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* @inheritdoc
|
|
90
|
+
*
|
|
91
|
+
* @public
|
|
92
|
+
* @static
|
|
93
|
+
* @type {RegistryType}
|
|
94
|
+
*/
|
|
95
|
+
public static override registryType: RegistryType = RegistryType.BUDGET;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Clawbacks assets from an incentive associated with the budget via Boost Core.
|
|
99
|
+
* Only the authorized users can clawback assets from an incentive.
|
|
100
|
+
* If the asset transfer fails, the reclamation will revert.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* const [amount, address] = await budgets.budget.clawbackFromTarget(
|
|
105
|
+
* core.assertValidAddress(),
|
|
106
|
+
* erc20Incentive.buildClawbackData(1n),
|
|
107
|
+
* boost.id,
|
|
108
|
+
* incentiveId,
|
|
109
|
+
* );
|
|
110
|
+
* ```
|
|
111
|
+
* @public
|
|
112
|
+
* @async
|
|
113
|
+
* @param {Address} target - The address of a contract implementing clawback, typically `BoostCore`
|
|
114
|
+
* @param {Hex} data - The encoded data payload for the clawback, can be acquired with `incentive.buildClawbackData`
|
|
115
|
+
* @param {bigint | number} boostId - The ID of the boost
|
|
116
|
+
* @param {bigint | number} incentiveId - The ID of the incentive
|
|
117
|
+
* @param {?WriteParams} [params] - Optional write parameters
|
|
118
|
+
* @returns {Promise<[bigint, Address]>} - Returns a tuple of amount reclaimed and the address reclaimed from
|
|
119
|
+
*/
|
|
120
|
+
public async clawbackFromTarget(
|
|
121
|
+
target: Address,
|
|
122
|
+
data: Hex,
|
|
123
|
+
boostId: bigint | number,
|
|
124
|
+
incentiveId: bigint | number,
|
|
125
|
+
params?: WriteParams,
|
|
126
|
+
) {
|
|
127
|
+
return await this.awaitResult(
|
|
128
|
+
this.clawbackFromTargetRaw(target, data, boostId, incentiveId, params),
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Clawbacks assets from an incentive associated with the budget via Boost Core.
|
|
134
|
+
* Only the authorized users can clawback assets from an incentive.
|
|
135
|
+
* If the asset transfer fails, the reclamation will revert.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* const { hash, result: [ amount, address ] } = await budgets.budget.clawbackFromTargetRaw(
|
|
140
|
+
* core.assertValidAddress(),
|
|
141
|
+
* erc20Incentive.buildClawbackData(1n),
|
|
142
|
+
* boost.id,
|
|
143
|
+
* incentiveId,
|
|
144
|
+
* );
|
|
145
|
+
* ```
|
|
146
|
+
* @public
|
|
147
|
+
* @async
|
|
148
|
+
* @param {Address} target - The address of a contract implementing clawback, typically `BoostCore`
|
|
149
|
+
* @param {Hex} data - The encoded data payload for the clawback, can be acquired with `incentive.buildClawbackData`
|
|
150
|
+
* @param {bigint | number} boostId - The ID of the boost
|
|
151
|
+
* @param {bigint | number} incentiveId - The ID of the incentive
|
|
152
|
+
* @param {?WriteParams} [params] - Optional write parameters
|
|
153
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - Returns transaction hash and simulated result
|
|
154
|
+
*/
|
|
155
|
+
public async clawbackFromTargetRaw(
|
|
156
|
+
target: Address,
|
|
157
|
+
data: Hex,
|
|
158
|
+
boostId: bigint | number,
|
|
159
|
+
incentiveId: bigint | number,
|
|
160
|
+
params?: WriteParams,
|
|
161
|
+
) {
|
|
162
|
+
const { request, result } =
|
|
163
|
+
await simulateTransparentBudgetClawbackFromTarget(this._config, {
|
|
164
|
+
address: this.assertValidAddress(),
|
|
165
|
+
args: [target, data, BigInt(boostId), BigInt(incentiveId)],
|
|
166
|
+
...this.optionallyAttachAccount(),
|
|
167
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
168
|
+
...(params as any),
|
|
169
|
+
});
|
|
170
|
+
const hash = await writeTransparentBudgetClawbackFromTarget(
|
|
171
|
+
this._config,
|
|
172
|
+
request,
|
|
173
|
+
);
|
|
174
|
+
return { hash, result };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Disburses assets from the budget to a single recipient
|
|
179
|
+
* If the asset transfer fails, the disbursement will revert
|
|
180
|
+
*
|
|
181
|
+
* @public
|
|
182
|
+
* @async
|
|
183
|
+
* @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
|
|
184
|
+
* @param {?WriteParams} [params]
|
|
185
|
+
* @returns {Promise<boolean>} - True if the disbursement was successful
|
|
186
|
+
*/
|
|
187
|
+
public async disburse(
|
|
188
|
+
transfer: FungibleTransferPayload | ERC1155TransferPayload,
|
|
189
|
+
params?: WriteParams,
|
|
190
|
+
) {
|
|
191
|
+
return await this.awaitResult(this.disburseRaw(transfer, params));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Disburses assets from the budget to a single recipient
|
|
196
|
+
* If the asset transfer fails, the disbursement will revert
|
|
197
|
+
*
|
|
198
|
+
* @public
|
|
199
|
+
* @async
|
|
200
|
+
* @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer
|
|
201
|
+
* @param {?WriteParams} [params]
|
|
202
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the disbursement was successful
|
|
203
|
+
*/
|
|
204
|
+
public async disburseRaw(
|
|
205
|
+
transfer: FungibleTransferPayload | ERC1155TransferPayload,
|
|
206
|
+
params?: WriteParams,
|
|
207
|
+
) {
|
|
208
|
+
const { request, result } = await simulateTransparentBudgetDisburse(
|
|
209
|
+
this._config,
|
|
210
|
+
{
|
|
211
|
+
address: this.assertValidAddress(),
|
|
212
|
+
args: [prepareTransfer(transfer)],
|
|
213
|
+
...this.optionallyAttachAccount(),
|
|
214
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
215
|
+
...(params as any),
|
|
216
|
+
},
|
|
217
|
+
);
|
|
218
|
+
const hash = await writeTransparentBudgetDisburse(this._config, request);
|
|
219
|
+
return { hash, result };
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Disburses assets from the budget to multiple recipients
|
|
224
|
+
*
|
|
225
|
+
* @public
|
|
226
|
+
* @async
|
|
227
|
+
* @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers
|
|
228
|
+
* @param {?WriteParams} [params]
|
|
229
|
+
* @returns {Promise<boolean>} - True if all disbursements were successful
|
|
230
|
+
*/
|
|
231
|
+
public async disburseBatch(
|
|
232
|
+
transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,
|
|
233
|
+
params?: WriteParams,
|
|
234
|
+
) {
|
|
235
|
+
return await this.awaitResult(this.disburseBatchRaw(transfers, params));
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Disburses assets from the budget to multiple recipients
|
|
240
|
+
*
|
|
241
|
+
* @public
|
|
242
|
+
* @async
|
|
243
|
+
* @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers
|
|
244
|
+
* @param {?WriteParams} [params]
|
|
245
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if all disbursements were successful
|
|
246
|
+
*/
|
|
247
|
+
public async disburseBatchRaw(
|
|
248
|
+
transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,
|
|
249
|
+
params?: WriteParams,
|
|
250
|
+
) {
|
|
251
|
+
const { request, result } = await simulateTransparentBudgetDisburseBatch(
|
|
252
|
+
this._config,
|
|
253
|
+
{
|
|
254
|
+
address: this.assertValidAddress(),
|
|
255
|
+
args: [transfers.map(prepareTransfer)],
|
|
256
|
+
...this.optionallyAttachAccount(),
|
|
257
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
258
|
+
...(params as any),
|
|
259
|
+
},
|
|
260
|
+
);
|
|
261
|
+
const hash = await writeTransparentBudgetDisburseBatch(
|
|
262
|
+
this._config,
|
|
263
|
+
request,
|
|
264
|
+
);
|
|
265
|
+
return { hash, result };
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Get the total amount of assets allocated to the budget, including any that have been distributed
|
|
270
|
+
* If a tokenId is provided, get the total amount of ERC1155 assets allocated to the budget, including any that have been distributed
|
|
271
|
+
*
|
|
272
|
+
* @public
|
|
273
|
+
* @param {Address} [asset="0x0000000000000000000000000000000000000000"] - The address of the asset
|
|
274
|
+
* @param {?(bigint | undefined)} [tokenId] - The ID of the token
|
|
275
|
+
* @param {?ReadParams} [params]
|
|
276
|
+
* @returns {Promise<bigint>} - The total amount of assets
|
|
277
|
+
*/
|
|
278
|
+
public total(
|
|
279
|
+
asset: Address = zeroAddress,
|
|
280
|
+
tokenId?: bigint | undefined,
|
|
281
|
+
params?: ReadParams,
|
|
282
|
+
) {
|
|
283
|
+
return readTransparentBudgetTotal(this._config, {
|
|
284
|
+
address: this.assertValidAddress(),
|
|
285
|
+
args: tokenId ? [asset, tokenId] : [asset],
|
|
286
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
287
|
+
...(params as any),
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Get the amount of assets that have been distributed from the budget.
|
|
293
|
+
* If a tokenId is provided, get the amount of ERC1155 assets that have been distributed from the budget
|
|
294
|
+
*
|
|
295
|
+
* @public
|
|
296
|
+
* @param {Address} [asset="0x0000000000000000000000000000000000000000"]
|
|
297
|
+
* @param {?(bigint | undefined)} [tokenId]
|
|
298
|
+
* @param {?ReadParams} [params]
|
|
299
|
+
* @returns {Promise<bigint>} - The amount of assets distributed
|
|
300
|
+
*/
|
|
301
|
+
public distributed(
|
|
302
|
+
asset: Address = zeroAddress,
|
|
303
|
+
tokenId?: bigint | undefined,
|
|
304
|
+
params?: ReadParams,
|
|
305
|
+
) {
|
|
306
|
+
return readTransparentBudgetDistributed(this._config, {
|
|
307
|
+
address: this.assertValidAddress(),
|
|
308
|
+
args: tokenId ? [asset, tokenId] : [asset],
|
|
309
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
310
|
+
...(params as any),
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* @inheritdoc
|
|
316
|
+
*
|
|
317
|
+
* @public
|
|
318
|
+
* @param {?TransparentBudgetPayload} [_payload]
|
|
319
|
+
* @param {?DeployableOptions} [_options]
|
|
320
|
+
* @returns {GenericDeployableParams}
|
|
321
|
+
*/
|
|
322
|
+
public override buildParameters(
|
|
323
|
+
_payload?: never,
|
|
324
|
+
_options?: DeployableOptions,
|
|
325
|
+
): GenericDeployableParams {
|
|
326
|
+
const [_, options] = this.validateDeploymentConfig({}, _options);
|
|
327
|
+
return {
|
|
328
|
+
abi: transparentBudgetAbi,
|
|
329
|
+
bytecode: bytecode as Hex,
|
|
330
|
+
args: [zeroHash],
|
|
331
|
+
...this.optionallyAttachAccount(options.account),
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}
|
|
@@ -503,7 +503,7 @@ export class ERC20PeggedIncentive extends DeployableTarget<
|
|
|
503
503
|
*
|
|
504
504
|
* @public
|
|
505
505
|
* @param {Hex} claimData
|
|
506
|
-
* @returns {
|
|
506
|
+
* @returns {bigint} Returns the reward amount from a claim data payload
|
|
507
507
|
*/
|
|
508
508
|
public decodeClaimData(claimData: Hex) {
|
|
509
509
|
const boostClaimData = decodeAbiParameters(
|
|
@@ -66,6 +66,7 @@ export { erc20PeggedVariableCriteriaIncentiveAbi };
|
|
|
66
66
|
* The object representation of a `Erc20PeggedVariableCriteriaIncentive.InitPayload`
|
|
67
67
|
*
|
|
68
68
|
* @export
|
|
69
|
+
* @deprecated Please use only v2 implementations
|
|
69
70
|
* @interface Erc20PeggedVariableCriteriaIncentive
|
|
70
71
|
* @typedef {Erc20PeggedVariableCriteriaIncentive}
|
|
71
72
|
*/
|
|
@@ -134,6 +135,7 @@ export type Erc20PeggedVariableCriteriaIncentiveLog<
|
|
|
134
135
|
* A simple ERC20 incentive implementation that allows claiming of tokens
|
|
135
136
|
*
|
|
136
137
|
* @export
|
|
138
|
+
* @deprecated Please use only v2 implementations
|
|
137
139
|
* @class Erc20PeggedVariableCriteriaIncentive
|
|
138
140
|
* @typedef {ERC20PeggedVariableCriteriaIncentive}
|
|
139
141
|
* @extends {DeployableTarget<ERC20PeggedVariableCriteriaIncentive>}
|
|
@@ -696,7 +698,7 @@ export class ERC20PeggedVariableCriteriaIncentive extends DeployableTarget<
|
|
|
696
698
|
*
|
|
697
699
|
* @public
|
|
698
700
|
* @param {Hex} claimData
|
|
699
|
-
* @returns {
|
|
701
|
+
* @returns {Promise<bigint>} Returns the reward amount from a claim data payload
|
|
700
702
|
*/
|
|
701
703
|
public async decodeClaimData(claimData: Hex) {
|
|
702
704
|
const boostClaimData = decodeAbiParameters(
|
|
@@ -23,15 +23,15 @@ import {
|
|
|
23
23
|
zeroHash,
|
|
24
24
|
} from "viem";
|
|
25
25
|
import { beforeAll, beforeEach, describe, expect, test } from "vitest";
|
|
26
|
-
import { SignatureType } from "../Actions/EventAction";
|
|
26
|
+
import { SignatureType, ValueType } from "../Actions/EventAction";
|
|
27
27
|
import type { Boost } from "../Boost";
|
|
28
28
|
import {
|
|
29
|
-
type
|
|
30
|
-
} from "./
|
|
29
|
+
type ERC20PeggedVariableCriteriaIncentiveV2,
|
|
30
|
+
} from "./ERC20PeggedVariableCriteriaIncentiveV2";
|
|
31
31
|
import {
|
|
32
|
-
type
|
|
33
|
-
|
|
34
|
-
} from "./
|
|
32
|
+
type IncentiveCriteriaV2,
|
|
33
|
+
gasRebateIncentiveCriteriaV2,
|
|
34
|
+
} from "./ERC20VariableCriteriaIncentiveV2";
|
|
35
35
|
import { allKnownSignatures } from "@boostxyz/test/allKnownSignatures";
|
|
36
36
|
import { readMockErc20BalanceOf } from "@boostxyz/evm";
|
|
37
37
|
|
|
@@ -43,12 +43,13 @@ import { readMockErc20BalanceOf } from "@boostxyz/evm";
|
|
|
43
43
|
*/
|
|
44
44
|
export function basicErc721TransferScalarCriteria(
|
|
45
45
|
erc721: MockERC721,
|
|
46
|
-
):
|
|
46
|
+
): IncentiveCriteriaV2 {
|
|
47
47
|
return {
|
|
48
48
|
criteriaType: SignatureType.FUNC,
|
|
49
49
|
signature: funcSelectors["transferFrom(address,address,uint256)"] as Hex, // Function selector for mint
|
|
50
50
|
fieldIndex: 2, // Field where the scalar value resides
|
|
51
51
|
targetContract: erc721.assertValidAddress(),
|
|
52
|
+
valueType: ValueType.WAD,
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
55
|
|
|
@@ -60,7 +61,7 @@ export function basicErc721TransferScalarCriteria(
|
|
|
60
61
|
*/
|
|
61
62
|
export function basicErc721MintScalarCriteria(
|
|
62
63
|
erc721: MockERC721,
|
|
63
|
-
):
|
|
64
|
+
): IncentiveCriteriaV2 {
|
|
64
65
|
return {
|
|
65
66
|
criteriaType: SignatureType.EVENT,
|
|
66
67
|
signature: eventSelectors[
|
|
@@ -68,13 +69,14 @@ export function basicErc721MintScalarCriteria(
|
|
|
68
69
|
] as Hex, // Function selector for mint
|
|
69
70
|
fieldIndex: 2, // Field where the scalar value resides
|
|
70
71
|
targetContract: erc721.assertValidAddress(),
|
|
72
|
+
valueType: ValueType.WAD,
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
let fixtures: Fixtures,
|
|
75
77
|
erc20: MockERC20,
|
|
76
78
|
erc721: MockERC721,
|
|
77
|
-
erc20PeggedVariableCriteriaIncentive:
|
|
79
|
+
erc20PeggedVariableCriteriaIncentive: ERC20PeggedVariableCriteriaIncentiveV2,
|
|
78
80
|
budgets: BudgetFixtures,
|
|
79
81
|
boost: Boost;
|
|
80
82
|
|
|
@@ -87,7 +89,7 @@ describe("ERC20PeggedVariableCriteriaIncentive", () => {
|
|
|
87
89
|
budgets = await loadFixture(fundBudget(defaultOptions, fixtures));
|
|
88
90
|
erc20 = await loadFixture(fundErc20(defaultOptions));
|
|
89
91
|
erc721 = await loadFixture(fundErc721(defaultOptions));
|
|
90
|
-
erc20PeggedVariableCriteriaIncentive = fixtures.core.
|
|
92
|
+
erc20PeggedVariableCriteriaIncentive = fixtures.core.ERC20PeggedVariableCriteriaIncentiveV2({
|
|
91
93
|
asset: budgets.erc20.assertValidAddress(),
|
|
92
94
|
reward: parseEther("1"),
|
|
93
95
|
limit: parseEther("10"),
|
|
@@ -146,7 +148,7 @@ describe("ERC20PeggedVariableCriteriaIncentive", () => {
|
|
|
146
148
|
|
|
147
149
|
describe("getIncentiveCriteria", () => {
|
|
148
150
|
test("should fetch incentive criteria successfully", async () => {
|
|
149
|
-
const incentive = boost.incentives[0] as
|
|
151
|
+
const incentive = boost.incentives[0] as ERC20PeggedVariableCriteriaIncentiveV2;
|
|
150
152
|
const criteria = await incentive.getIncentiveCriteria();
|
|
151
153
|
expect(criteria).toMatchObject({
|
|
152
154
|
criteriaType: SignatureType.FUNC,
|
|
@@ -220,11 +222,11 @@ describe("ERC20PeggedVariableCriteriaIncentive", () => {
|
|
|
220
222
|
expect(scalar).toBe(1n);
|
|
221
223
|
});
|
|
222
224
|
|
|
223
|
-
test("
|
|
225
|
+
test("gasRebateIncentiveCriteriaV2 generates correct incentive criteria", async () => {
|
|
224
226
|
// Ensure that the gasRebateIncentiveCriteria returns the correct structure
|
|
225
|
-
const gasRebateCriteria =
|
|
227
|
+
const gasRebateCriteria = gasRebateIncentiveCriteriaV2();
|
|
226
228
|
|
|
227
|
-
erc20PeggedVariableCriteriaIncentive = fixtures.core.
|
|
229
|
+
erc20PeggedVariableCriteriaIncentive = fixtures.core.ERC20PeggedVariableCriteriaIncentiveV2({
|
|
228
230
|
asset: budgets.erc20.assertValidAddress(),
|
|
229
231
|
reward: 1n,
|
|
230
232
|
limit: 1n,
|
|
@@ -239,6 +241,7 @@ describe("ERC20PeggedVariableCriteriaIncentive", () => {
|
|
|
239
241
|
signature: zeroHash,
|
|
240
242
|
fieldIndex: 255,
|
|
241
243
|
targetContract: zeroAddress,
|
|
244
|
+
valueType: ValueType.WAD,
|
|
242
245
|
});
|
|
243
246
|
|
|
244
247
|
boost = await freshBoost(fixtures, {
|
|
@@ -248,12 +251,13 @@ describe("ERC20PeggedVariableCriteriaIncentive", () => {
|
|
|
248
251
|
|
|
249
252
|
// Validate that the deployed incentive has the correct criteria set up
|
|
250
253
|
const deployedIncentive = (await boost
|
|
251
|
-
.incentives[0]) as
|
|
254
|
+
.incentives[0]) as ERC20PeggedVariableCriteriaIncentiveV2;
|
|
252
255
|
const deployedCriteria = await deployedIncentive.getIncentiveCriteria();
|
|
253
256
|
expect(deployedCriteria.criteriaType).toBe(SignatureType.EVENT);
|
|
254
257
|
expect(deployedCriteria.signature).toBe(zeroHash);
|
|
255
258
|
expect(deployedCriteria.fieldIndex).toBe(255);
|
|
256
259
|
expect(deployedCriteria.targetContract).toBe(zeroAddress);
|
|
260
|
+
expect(deployedCriteria.valueType).toBe(ValueType.WAD);
|
|
257
261
|
});
|
|
258
262
|
|
|
259
263
|
test("should throw NoMatchingLogsError for event criteria with no matching logs", async () => {
|
|
@@ -290,7 +294,7 @@ describe("ERC20PeggedVariableCriteriaIncentive", () => {
|
|
|
290
294
|
|
|
291
295
|
test("can properly encode a uint256", () => {
|
|
292
296
|
//@ts-ignore
|
|
293
|
-
const incentive = fixtures.core.
|
|
297
|
+
const incentive = fixtures.core.ERC20VariableCriteriaIncentiveV2();
|
|
294
298
|
expect(incentive.buildClawbackData(1n)).toBe(
|
|
295
299
|
"0x0000000000000000000000000000000000000000000000000000000000000001",
|
|
296
300
|
);
|