@boostxyz/sdk 0.0.0-alpha.2 → 0.0.0-alpha.21
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/dist/Actions/Action.cjs +2 -1
- package/dist/Actions/Action.cjs.map +1 -0
- package/dist/Actions/Action.d.ts +1 -1
- package/dist/Actions/Action.d.ts.map +1 -1
- package/dist/Actions/Action.js +14 -12
- package/dist/Actions/Action.js.map +1 -0
- package/dist/Actions/ContractAction.d.ts +57 -14
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +50 -23
- package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.cjs +2 -1
- package/dist/Actions/EventAction.cjs.map +1 -0
- package/dist/Actions/EventAction.d.ts +405 -36
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +15 -209
- package/dist/Actions/EventAction.js.map +1 -0
- package/dist/AllowLists/AllowList.cjs +2 -1
- package/dist/AllowLists/AllowList.cjs.map +1 -0
- package/dist/AllowLists/AllowList.d.ts +6 -5
- package/dist/AllowLists/AllowList.d.ts.map +1 -1
- package/dist/AllowLists/AllowList.js +46 -22
- package/dist/AllowLists/AllowList.js.map +1 -0
- package/dist/AllowLists/OpenAllowList.d.ts +423 -0
- package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleAllowList.cjs +2 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
- package/dist/AllowLists/SimpleAllowList.d.ts +124 -40
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +76 -76
- package/dist/AllowLists/SimpleAllowList.js.map +1 -0
- package/dist/AllowLists/SimpleDenyList.cjs +2 -1
- package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
- package/dist/AllowLists/SimpleDenyList.d.ts +234 -13
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +12 -200
- package/dist/AllowLists/SimpleDenyList.js.map +1 -0
- package/dist/Auth/Auth.cjs +1 -0
- package/dist/Auth/Auth.cjs.map +1 -0
- package/dist/Auth/Auth.js +1 -0
- package/dist/Auth/Auth.js.map +1 -0
- package/dist/Auth/PassthroughAuth.cjs +2 -1
- package/dist/Auth/PassthroughAuth.cjs.map +1 -0
- package/dist/Auth/PassthroughAuth.js +5 -4
- package/dist/Auth/PassthroughAuth.js.map +1 -0
- package/dist/Boost.cjs +2 -1
- package/dist/Boost.cjs.map +1 -0
- package/dist/Boost.d.ts +105 -14
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +138 -5
- package/dist/Boost.js.map +1 -0
- package/dist/BoostCore-DolmDuXW.cjs +3 -0
- package/dist/BoostCore-DolmDuXW.cjs.map +1 -0
- package/dist/BoostCore-Z97KVu4V.js +1448 -0
- package/dist/BoostCore-Z97KVu4V.js.map +1 -0
- package/dist/BoostCore.cjs +2 -2
- package/dist/BoostCore.cjs.map +1 -0
- package/dist/BoostCore.d.ts +788 -79
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +30 -1103
- package/dist/BoostCore.js.map +1 -0
- package/dist/BoostRegistry.cjs +2 -1
- package/dist/BoostRegistry.cjs.map +1 -0
- package/dist/BoostRegistry.d.ts +95 -26
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +183 -89
- package/dist/BoostRegistry.js.map +1 -0
- package/dist/Budgets/Budget.cjs +2 -1
- package/dist/Budgets/Budget.cjs.map +1 -0
- package/dist/Budgets/Budget.d.ts +1 -1
- package/dist/Budgets/Budget.d.ts.map +1 -1
- package/dist/Budgets/Budget.js +15 -13
- package/dist/Budgets/Budget.js.map +1 -0
- package/dist/Budgets/ManagedBudget.cjs +2 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -0
- package/dist/Budgets/ManagedBudget.d.ts +112 -192
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +91 -291
- package/dist/Budgets/ManagedBudget.js.map +1 -0
- package/dist/Budgets/VestingBudget.d.ts +277 -91
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/Contract.cjs +2 -1
- package/dist/Deployable/Contract.cjs.map +1 -0
- package/dist/Deployable/Contract.d.ts +4 -5
- package/dist/Deployable/Contract.d.ts.map +1 -1
- package/dist/Deployable/Contract.js +7 -8
- package/dist/Deployable/Contract.js.map +1 -0
- package/dist/Deployable/Deployable.cjs +1 -0
- package/dist/Deployable/Deployable.cjs.map +1 -0
- package/dist/Deployable/Deployable.d.ts +9 -3
- package/dist/Deployable/Deployable.d.ts.map +1 -1
- package/dist/Deployable/Deployable.js +10 -5
- package/dist/Deployable/Deployable.js.map +1 -0
- package/dist/Deployable/DeployableTarget.cjs +2 -1
- package/dist/Deployable/DeployableTarget.cjs.map +1 -0
- package/dist/Deployable/DeployableTarget.d.ts +16 -15
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.js +49 -42
- package/dist/Deployable/DeployableTarget.js.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
- package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
- package/dist/EventAction-CBKzuNoN.cjs +2 -0
- package/dist/EventAction-CBKzuNoN.cjs.map +1 -0
- package/dist/EventAction-DWuuc_Qy.js +1528 -0
- package/dist/EventAction-DWuuc_Qy.js.map +1 -0
- package/dist/Incentive-BxzEtN26.js +298 -0
- package/dist/Incentive-BxzEtN26.js.map +1 -0
- package/dist/Incentive-CrF3-ayL.cjs +2 -0
- package/dist/Incentive-CrF3-ayL.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +2 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.d.ts +65 -21
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +52 -36
- package/dist/Incentives/AllowListIncentive.js.map +1 -0
- package/dist/Incentives/CGDAIncentive.cjs +2 -1
- package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
- package/dist/Incentives/CGDAIncentive.d.ts +315 -26
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +64 -39
- package/dist/Incentives/CGDAIncentive.js.map +1 -0
- package/dist/Incentives/ERC1155Incentive.d.ts +291 -43
- package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.cjs +2 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
- package/dist/Incentives/ERC20Incentive.d.ts +270 -33
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +69 -46
- package/dist/Incentives/ERC20Incentive.js.map +1 -0
- package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +338 -421
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +262 -32
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +2 -1
- package/dist/Incentives/Incentive.cjs.map +1 -0
- package/dist/Incentives/Incentive.d.ts +5 -8
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +17 -278
- package/dist/Incentives/Incentive.js.map +1 -0
- package/dist/Incentives/PointsIncentive.cjs +2 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -0
- package/dist/Incentives/PointsIncentive.d.ts +81 -23
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +57 -36
- package/dist/Incentives/PointsIncentive.js.map +1 -0
- package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
- package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
- package/dist/SimpleDenyList-CGaWjuld.js +132 -0
- package/dist/SimpleDenyList-CGaWjuld.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +2 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -0
- package/dist/Validators/SignerValidator.d.ts +310 -17
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +165 -36
- package/dist/Validators/SignerValidator.js.map +1 -0
- package/dist/Validators/Validator.cjs +2 -1
- package/dist/Validators/Validator.cjs.map +1 -0
- package/dist/Validators/Validator.d.ts +2 -2
- package/dist/Validators/Validator.d.ts.map +1 -1
- package/dist/Validators/Validator.js +10 -8
- package/dist/Validators/Validator.js.map +1 -0
- package/dist/claiming.cjs +2 -0
- package/dist/claiming.cjs.map +1 -0
- package/dist/claiming.d.ts +43 -0
- package/dist/claiming.d.ts.map +1 -0
- package/dist/claiming.js +17 -0
- package/dist/claiming.js.map +1 -0
- package/dist/componentInterfaces-BBCFkrZv.js +14 -0
- package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
- package/dist/deployments-DVXioW2i.cjs +2 -0
- package/dist/deployments-DVXioW2i.cjs.map +1 -0
- package/dist/deployments-oykLv3_Z.js +43 -0
- package/dist/deployments-oykLv3_Z.js.map +1 -0
- package/dist/deployments.json +44 -0
- package/dist/errors.cjs +2 -1
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.ts +421 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +297 -39
- package/dist/errors.js.map +1 -0
- package/dist/{generated-x_abr3Yv.js → generated-CKt2yCQd.js} +3143 -3002
- package/dist/generated-CKt2yCQd.js.map +1 -0
- package/dist/generated-CyTNlOwM.cjs +3 -0
- package/dist/generated-CyTNlOwM.cjs.map +1 -0
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +144 -1353
- package/dist/index.js.map +1 -0
- package/dist/transfers.cjs +2 -0
- package/dist/transfers.cjs.map +1 -0
- package/dist/transfers.d.ts +198 -0
- package/dist/transfers.d.ts.map +1 -0
- package/dist/transfers.js +84 -0
- package/dist/transfers.js.map +1 -0
- package/dist/utils.cjs +2 -1
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +26 -1350
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +38 -636
- package/dist/utils.js.map +1 -0
- package/package.json +37 -11
- package/src/Actions/Action.test.ts +79 -0
- package/src/Actions/Action.ts +61 -0
- package/src/Actions/ContractAction.test.ts +197 -0
- package/src/Actions/ContractAction.ts +300 -0
- package/src/Actions/ERC721MintAction.test.ts +112 -0
- package/src/Actions/ERC721MintAction.ts +291 -0
- package/src/Actions/EventAction.test.ts +787 -0
- package/src/Actions/EventAction.ts +1218 -0
- package/src/AllowLists/AllowList.test.ts +64 -0
- package/src/AllowLists/AllowList.ts +62 -0
- package/src/AllowLists/OpenAllowList.test.ts +40 -0
- package/src/AllowLists/OpenAllowList.ts +45 -0
- package/src/AllowLists/SimpleAllowList.test.ts +52 -0
- package/src/AllowLists/SimpleAllowList.ts +262 -0
- package/src/AllowLists/SimpleDenyList.test.ts +52 -0
- package/src/AllowLists/SimpleDenyList.ts +250 -0
- package/src/Auth/Auth.ts +11 -0
- package/src/Auth/PassthroughAuth.test.ts +12 -0
- package/src/Auth/PassthroughAuth.ts +80 -0
- package/src/Boost.ts +287 -0
- package/src/BoostCore.test.ts +894 -0
- package/src/BoostCore.ts +1438 -0
- package/src/BoostRegistry.test.ts +53 -0
- package/src/BoostRegistry.ts +588 -0
- package/src/Budgets/Budget.test.ts +27 -0
- package/src/Budgets/Budget.ts +60 -0
- package/src/Budgets/ManagedBudget.test.ts +217 -0
- package/src/Budgets/ManagedBudget.ts +534 -0
- package/src/Budgets/VestingBudget.test.ts +123 -0
- package/src/Budgets/VestingBudget.ts +530 -0
- package/src/Deployable/Contract.ts +228 -0
- package/src/Deployable/Deployable.ts +250 -0
- package/src/Deployable/DeployableTarget.ts +234 -0
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.test.ts +143 -0
- package/src/Incentives/AllowListIncentive.ts +336 -0
- package/src/Incentives/CGDAIncentive.test.ts +135 -0
- package/src/Incentives/CGDAIncentive.ts +476 -0
- package/src/Incentives/ERC1155Incentive.test.ts +87 -0
- package/src/Incentives/ERC1155Incentive.ts +465 -0
- package/src/Incentives/ERC20Incentive.test.ts +133 -0
- package/src/Incentives/ERC20Incentive.ts +490 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +139 -0
- package/src/Incentives/ERC20VariableIncentive.ts +428 -0
- package/src/Incentives/Incentive.test.ts +95 -0
- package/src/Incentives/Incentive.ts +86 -0
- package/src/Incentives/PointsIncentive.test.ts +138 -0
- package/src/Incentives/PointsIncentive.ts +367 -0
- package/src/Validators/SignerValidator.test.ts +159 -0
- package/src/Validators/SignerValidator.ts +683 -0
- package/src/Validators/Validator.test.ts +21 -0
- package/src/Validators/Validator.ts +55 -0
- package/src/claiming.ts +56 -0
- package/src/errors.ts +866 -0
- package/src/index.test.ts +122 -0
- package/src/index.ts +58 -0
- package/src/transfers.ts +284 -0
- package/src/utils.test.ts +44 -0
- package/src/utils.ts +247 -0
- package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
- package/dist/generated-BaaleHW-.cjs +0 -2
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readVestingBudgetAvailable,
|
|
3
|
+
readVestingBudgetCliff,
|
|
4
|
+
readVestingBudgetDistributed,
|
|
5
|
+
readVestingBudgetDuration,
|
|
6
|
+
readVestingBudgetEnd,
|
|
7
|
+
readVestingBudgetIsAuthorized,
|
|
8
|
+
readVestingBudgetOwner,
|
|
9
|
+
readVestingBudgetStart,
|
|
10
|
+
readVestingBudgetTotal,
|
|
11
|
+
simulateVestingBudgetAllocate,
|
|
12
|
+
simulateVestingBudgetClawback,
|
|
13
|
+
simulateVestingBudgetDisburse,
|
|
14
|
+
simulateVestingBudgetDisburseBatch,
|
|
15
|
+
simulateVestingBudgetSetAuthorized,
|
|
16
|
+
vestingBudgetAbi,
|
|
17
|
+
writeVestingBudgetAllocate,
|
|
18
|
+
writeVestingBudgetClawback,
|
|
19
|
+
writeVestingBudgetDisburse,
|
|
20
|
+
writeVestingBudgetDisburseBatch,
|
|
21
|
+
writeVestingBudgetSetAuthorized,
|
|
22
|
+
} from '@boostxyz/evm';
|
|
23
|
+
import { bytecode } from '@boostxyz/evm/artifacts/contracts/budgets/VestingBudget.sol/VestingBudget.json';
|
|
24
|
+
import { getAccount } from '@wagmi/core';
|
|
25
|
+
import {
|
|
26
|
+
type Address,
|
|
27
|
+
type ContractEventName,
|
|
28
|
+
type Hex,
|
|
29
|
+
encodeAbiParameters,
|
|
30
|
+
parseAbiParameters,
|
|
31
|
+
zeroAddress,
|
|
32
|
+
} from 'viem';
|
|
33
|
+
import type {
|
|
34
|
+
DeployableOptions,
|
|
35
|
+
GenericDeployableParams,
|
|
36
|
+
} from '../Deployable/Deployable';
|
|
37
|
+
import { DeployableTargetWithRBAC } from '../Deployable/DeployableTargetWithRBAC';
|
|
38
|
+
import { DeployableUnknownOwnerProvidedError } from '../errors';
|
|
39
|
+
import {
|
|
40
|
+
type FungibleTransferPayload,
|
|
41
|
+
prepareFungibleTransfer,
|
|
42
|
+
} from '../transfers';
|
|
43
|
+
import {
|
|
44
|
+
type GenericLog,
|
|
45
|
+
type ReadParams,
|
|
46
|
+
RegistryType,
|
|
47
|
+
type WriteParams,
|
|
48
|
+
} from '../utils';
|
|
49
|
+
|
|
50
|
+
export { vestingBudgetAbi };
|
|
51
|
+
export type { FungibleTransferPayload };
|
|
52
|
+
/**
|
|
53
|
+
* The object representation of a `VestingBudget.InitPayload`
|
|
54
|
+
*
|
|
55
|
+
* @export
|
|
56
|
+
* @interface VestingBudgetPayload
|
|
57
|
+
* @typedef {VestingBudgetPayload}
|
|
58
|
+
*/
|
|
59
|
+
export interface VestingBudgetPayload {
|
|
60
|
+
/**
|
|
61
|
+
* The budget's owner.
|
|
62
|
+
*
|
|
63
|
+
* @type {Address}
|
|
64
|
+
*/
|
|
65
|
+
owner: Address;
|
|
66
|
+
/**
|
|
67
|
+
* List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
|
|
68
|
+
*
|
|
69
|
+
* @type {Address[]}
|
|
70
|
+
*/
|
|
71
|
+
authorized: Address[];
|
|
72
|
+
/**
|
|
73
|
+
* The timestamp at which the vesting schedule begins
|
|
74
|
+
*
|
|
75
|
+
* @type {bigint}
|
|
76
|
+
*/
|
|
77
|
+
start: bigint;
|
|
78
|
+
/**
|
|
79
|
+
* The duration of the vesting schedule (in seconds)
|
|
80
|
+
*
|
|
81
|
+
* @type {bigint}
|
|
82
|
+
*/
|
|
83
|
+
duration: bigint;
|
|
84
|
+
/**
|
|
85
|
+
* The duration of the cliff period (in seconds)
|
|
86
|
+
*
|
|
87
|
+
* @type {bigint}
|
|
88
|
+
*/
|
|
89
|
+
cliff: bigint;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A generic `viem.Log` event with support for `VestingBudget` event types.
|
|
94
|
+
*
|
|
95
|
+
* @export
|
|
96
|
+
* @typedef {VestingBudgetLog}
|
|
97
|
+
* @template {ContractEventName<typeof vestingBudgetAbi>} [event=ContractEventName<
|
|
98
|
+
* typeof vestingBudgetAbi
|
|
99
|
+
* >]
|
|
100
|
+
*/
|
|
101
|
+
export type VestingBudgetLog<
|
|
102
|
+
event extends ContractEventName<typeof vestingBudgetAbi> = ContractEventName<
|
|
103
|
+
typeof vestingBudgetAbi
|
|
104
|
+
>,
|
|
105
|
+
> = GenericLog<typeof vestingBudgetAbi, event>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A vesting-based budget implementation that allows for the distribution of assets over time
|
|
109
|
+
* Take note of the following when making use of this budget type:
|
|
110
|
+
* - The budget is designed to manage native and ERC20 token balances only. Using rebasing tokens or other non-standard token types may result in unexpected behavior.
|
|
111
|
+
* - Any assets allocated to this type of budget will follow the vesting schedule as if they were locked from the beginning, which is to say that, if the vesting has already started, some portion of the assets will be immediately available for distribution.
|
|
112
|
+
* - A vesting budget can also act as a time-lock, unlocking all assets at a specified point in time. To release assets at a specific time rather than vesting them over time, set the `start` to the desired time and the `duration` to zero.
|
|
113
|
+
* - This contract is {Ownable} to enable the owner to allocate to the budget, clawback and disburse assets from the budget, and to set authorized addresses. Additionally, the owner can transfer ownership of the budget to another address. Doing so has no effect on the vesting schedule.
|
|
114
|
+
*
|
|
115
|
+
* @export
|
|
116
|
+
* @class VestingBudget
|
|
117
|
+
* @typedef {VestingBudget}
|
|
118
|
+
* @extends {DeployableTargetWithRBAC<VestingBudgetPayload>}
|
|
119
|
+
*/
|
|
120
|
+
export class VestingBudget extends DeployableTargetWithRBAC<
|
|
121
|
+
VestingBudgetPayload,
|
|
122
|
+
typeof vestingBudgetAbi
|
|
123
|
+
> {
|
|
124
|
+
public override readonly abi = vestingBudgetAbi;
|
|
125
|
+
/**
|
|
126
|
+
* @inheritdoc
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
* @static
|
|
130
|
+
* @type {Record<number, Address>}
|
|
131
|
+
*/
|
|
132
|
+
public static override bases: Record<number, Address> = {};
|
|
133
|
+
/**
|
|
134
|
+
* @inheritdoc
|
|
135
|
+
*
|
|
136
|
+
* @public
|
|
137
|
+
* @static
|
|
138
|
+
* @type {RegistryType}
|
|
139
|
+
*/
|
|
140
|
+
public static override registryType: RegistryType = RegistryType.BUDGET;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Get the owner of the budget
|
|
144
|
+
*
|
|
145
|
+
* @public
|
|
146
|
+
* @param {?ReadParams} [params]
|
|
147
|
+
* @returns {Promise<Address>}
|
|
148
|
+
*/
|
|
149
|
+
public owner(params?: ReadParams<typeof vestingBudgetAbi, 'owner'>) {
|
|
150
|
+
return readVestingBudgetOwner(this._config, {
|
|
151
|
+
address: this.assertValidAddress(),
|
|
152
|
+
args: [],
|
|
153
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
154
|
+
...(params as any),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The timestamp at which the vesting schedule begins
|
|
160
|
+
*
|
|
161
|
+
* @public
|
|
162
|
+
* @param {?ReadParams} [params]
|
|
163
|
+
* @returns {Promise<bigint>}
|
|
164
|
+
*/
|
|
165
|
+
public start(params?: ReadParams<typeof vestingBudgetAbi, 'start'>) {
|
|
166
|
+
return readVestingBudgetStart(this._config, {
|
|
167
|
+
address: this.assertValidAddress(),
|
|
168
|
+
args: [],
|
|
169
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
170
|
+
...(params as any),
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The duration of the vesting schedule (in seconds)
|
|
176
|
+
*
|
|
177
|
+
* @public
|
|
178
|
+
* @param {?ReadParams} [params]
|
|
179
|
+
* @returns {Promise<bigint>}
|
|
180
|
+
*/
|
|
181
|
+
public duration(params?: ReadParams<typeof vestingBudgetAbi, 'duration'>) {
|
|
182
|
+
return readVestingBudgetDuration(this._config, {
|
|
183
|
+
address: this.assertValidAddress(),
|
|
184
|
+
args: [],
|
|
185
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
186
|
+
...(params as any),
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The duration of the cliff period (in seconds)
|
|
192
|
+
*
|
|
193
|
+
* @public
|
|
194
|
+
* @param {?ReadParams} [params]
|
|
195
|
+
* @returns {Promise<bigint>}
|
|
196
|
+
*/
|
|
197
|
+
public cliff(params?: ReadParams<typeof vestingBudgetAbi, 'cliff'>) {
|
|
198
|
+
return readVestingBudgetCliff(this._config, {
|
|
199
|
+
address: this.assertValidAddress(),
|
|
200
|
+
args: [],
|
|
201
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
202
|
+
...(params as any),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Allocates assets to the budget.
|
|
208
|
+
* The caller must have already approved the contract to transfer the asset
|
|
209
|
+
* If the asset transfer fails, the allocation will revert
|
|
210
|
+
*
|
|
211
|
+
* @public
|
|
212
|
+
* @async
|
|
213
|
+
* @param {(FungibleTransferPayload)} transfer
|
|
214
|
+
* @param {?WriteParams} [params]
|
|
215
|
+
* @returns {Promise<boolean>} - True if the allocation was successful
|
|
216
|
+
*/
|
|
217
|
+
public async allocate(
|
|
218
|
+
transfer: FungibleTransferPayload,
|
|
219
|
+
params?: WriteParams<typeof vestingBudgetAbi, 'allocate'>,
|
|
220
|
+
) {
|
|
221
|
+
return await this.awaitResult(this.allocateRaw(transfer, params));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Allocates assets to the budget.
|
|
226
|
+
* The caller must have already approved the contract to transfer the asset
|
|
227
|
+
* If the asset transfer fails, the allocation will revert
|
|
228
|
+
*
|
|
229
|
+
* @public
|
|
230
|
+
* @async
|
|
231
|
+
* @param {(FungibleTransferPayload)} transfer
|
|
232
|
+
* @param {?WriteParams} [params]
|
|
233
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the allocation was successful
|
|
234
|
+
*/
|
|
235
|
+
public async allocateRaw(
|
|
236
|
+
transfer: FungibleTransferPayload,
|
|
237
|
+
params?: WriteParams<typeof vestingBudgetAbi, 'allocate'>,
|
|
238
|
+
) {
|
|
239
|
+
const { request, result } = await simulateVestingBudgetAllocate(
|
|
240
|
+
this._config,
|
|
241
|
+
{
|
|
242
|
+
address: this.assertValidAddress(),
|
|
243
|
+
args: [prepareFungibleTransfer(transfer)],
|
|
244
|
+
...this.optionallyAttachAccount(),
|
|
245
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
246
|
+
...(params as any),
|
|
247
|
+
},
|
|
248
|
+
);
|
|
249
|
+
const hash = await writeVestingBudgetAllocate(this._config, request);
|
|
250
|
+
return { hash, result };
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Clawbacks assets from the budget.
|
|
255
|
+
* Only the owner can directly clawback assets from the budget
|
|
256
|
+
* If the amount is zero, the entire balance of the asset will be transferred to the receiver
|
|
257
|
+
* If the asset transfer fails, the reclamation will revert
|
|
258
|
+
*
|
|
259
|
+
* @public
|
|
260
|
+
* @async
|
|
261
|
+
* @param {(FungibleTransferPayload)} transfer
|
|
262
|
+
* @param {?WriteParams} [params]
|
|
263
|
+
* @returns {Promise<boolean>} - True if the request was successful
|
|
264
|
+
*/
|
|
265
|
+
public async clawback(
|
|
266
|
+
transfer: FungibleTransferPayload,
|
|
267
|
+
params?: WriteParams<typeof vestingBudgetAbi, 'clawback'>,
|
|
268
|
+
) {
|
|
269
|
+
return await this.awaitResult(this.clawbackRaw(transfer, params));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Clawbacks assets from the budget.
|
|
274
|
+
* Only the owner can directly clawback assets from the budget
|
|
275
|
+
* If the amount is zero, the entire balance of the asset will be transferred to the receiver
|
|
276
|
+
* If the asset transfer fails, the reclamation will revert
|
|
277
|
+
*
|
|
278
|
+
* @public
|
|
279
|
+
* @async
|
|
280
|
+
* @param {(FungibleTransferPayload)} transfer
|
|
281
|
+
* @param {?WriteParams} [params]
|
|
282
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the request was successful
|
|
283
|
+
*/
|
|
284
|
+
public async clawbackRaw(
|
|
285
|
+
transfer: FungibleTransferPayload,
|
|
286
|
+
params?: WriteParams<typeof vestingBudgetAbi, 'clawback'>,
|
|
287
|
+
) {
|
|
288
|
+
const { request, result } = await simulateVestingBudgetClawback(
|
|
289
|
+
this._config,
|
|
290
|
+
{
|
|
291
|
+
address: this.assertValidAddress(),
|
|
292
|
+
args: [prepareFungibleTransfer(transfer)],
|
|
293
|
+
...this.optionallyAttachAccount(),
|
|
294
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
295
|
+
...(params as any),
|
|
296
|
+
},
|
|
297
|
+
);
|
|
298
|
+
const hash = await writeVestingBudgetClawback(this._config, request);
|
|
299
|
+
return { hash, result };
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Disburses assets from the budget to a single recipient
|
|
304
|
+
* If the asset transfer fails, the disbursement will revert
|
|
305
|
+
*
|
|
306
|
+
* @public
|
|
307
|
+
* @async
|
|
308
|
+
* @param {(FungibleTransferPayload)} transfer
|
|
309
|
+
* @param {?WriteParams} [params]
|
|
310
|
+
* @returns {Promise<boolean>} - True if the disbursement was successful
|
|
311
|
+
*/
|
|
312
|
+
public async disburse(
|
|
313
|
+
transfer: FungibleTransferPayload,
|
|
314
|
+
params?: WriteParams<typeof vestingBudgetAbi, 'disburse'>,
|
|
315
|
+
) {
|
|
316
|
+
return await this.awaitResult(this.disburseRaw(transfer, params));
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Disburses assets from the budget to a single recipient
|
|
321
|
+
* If the asset transfer fails, the disbursement will revert
|
|
322
|
+
*
|
|
323
|
+
* @public
|
|
324
|
+
* @async
|
|
325
|
+
* @param {(FungibleTransferPayload)} transfer
|
|
326
|
+
* @param {?WriteParams} [params]
|
|
327
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the disbursement was successful
|
|
328
|
+
*/
|
|
329
|
+
public async disburseRaw(
|
|
330
|
+
transfer: FungibleTransferPayload,
|
|
331
|
+
params?: WriteParams<typeof vestingBudgetAbi, 'disburse'>,
|
|
332
|
+
) {
|
|
333
|
+
const { request, result } = await simulateVestingBudgetDisburse(
|
|
334
|
+
this._config,
|
|
335
|
+
{
|
|
336
|
+
address: this.assertValidAddress(),
|
|
337
|
+
args: [prepareFungibleTransfer(transfer)],
|
|
338
|
+
...this.optionallyAttachAccount(),
|
|
339
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
340
|
+
...(params as any),
|
|
341
|
+
},
|
|
342
|
+
);
|
|
343
|
+
const hash = await writeVestingBudgetDisburse(this._config, request);
|
|
344
|
+
return { hash, result };
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Disburses assets from the budget to multiple recipients
|
|
349
|
+
*
|
|
350
|
+
* @public
|
|
351
|
+
* @async
|
|
352
|
+
* @param {Array<FungibleTransferPayload>} transfers
|
|
353
|
+
* @param {?WriteParams} [params]
|
|
354
|
+
* @returns {Promise<boolean>} - True if all disbursements were successful
|
|
355
|
+
*/
|
|
356
|
+
public async disburseBatch(
|
|
357
|
+
transfers: FungibleTransferPayload[],
|
|
358
|
+
params?: WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>,
|
|
359
|
+
) {
|
|
360
|
+
return await this.awaitResult(this.disburseBatchRaw(transfers, params));
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Disburses assets from the budget to multiple recipients
|
|
365
|
+
*
|
|
366
|
+
* @public
|
|
367
|
+
* @async
|
|
368
|
+
* @param {Array<FungibleTransferPayload>} transfers
|
|
369
|
+
* @param {?WriteParams} [params]
|
|
370
|
+
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if all disbursements were successful
|
|
371
|
+
*/
|
|
372
|
+
public async disburseBatchRaw(
|
|
373
|
+
transfers: FungibleTransferPayload[],
|
|
374
|
+
params?: WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>,
|
|
375
|
+
) {
|
|
376
|
+
const { request, result } = await simulateVestingBudgetDisburseBatch(
|
|
377
|
+
this._config,
|
|
378
|
+
{
|
|
379
|
+
address: this.assertValidAddress(),
|
|
380
|
+
args: [transfers.map(prepareFungibleTransfer)],
|
|
381
|
+
...this.optionallyAttachAccount(),
|
|
382
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
383
|
+
...(params as any),
|
|
384
|
+
},
|
|
385
|
+
);
|
|
386
|
+
const hash = await writeVestingBudgetDisburseBatch(this._config, request);
|
|
387
|
+
return { hash, result };
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Get the end time of the vesting schedule
|
|
392
|
+
*
|
|
393
|
+
* @public
|
|
394
|
+
* @param {?ReadParams} [params]
|
|
395
|
+
* @returns {Promise<bigint>}
|
|
396
|
+
*/
|
|
397
|
+
public end(params?: ReadParams<typeof vestingBudgetAbi, 'end'>) {
|
|
398
|
+
return readVestingBudgetEnd(this._config, {
|
|
399
|
+
address: this.assertValidAddress(),
|
|
400
|
+
args: [],
|
|
401
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
402
|
+
...(params as any),
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Get the total amount of assets allocated to the budget, including any that have been distributed
|
|
408
|
+
* This is equal to the sum of the total current balance and the total distributed amount
|
|
409
|
+
*
|
|
410
|
+
* @public
|
|
411
|
+
* @param {Address} [asset="0x0000000000000000000000000000000000000000"] - The address of the asset (or the zero address for native assets)
|
|
412
|
+
* @param {?ReadParams} [params]
|
|
413
|
+
* @returns {Promise<bigint>}
|
|
414
|
+
*/
|
|
415
|
+
public total(
|
|
416
|
+
asset: Address = zeroAddress,
|
|
417
|
+
params?: ReadParams<typeof vestingBudgetAbi, 'total'>,
|
|
418
|
+
) {
|
|
419
|
+
return readVestingBudgetTotal(this._config, {
|
|
420
|
+
address: this.assertValidAddress(),
|
|
421
|
+
args: [asset],
|
|
422
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
423
|
+
...(params as any),
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Get the amount of assets available for distribution from the budget as of the current block timestamp
|
|
429
|
+
* This is equal to the total vested amount minus any already distributed
|
|
430
|
+
*
|
|
431
|
+
* @public
|
|
432
|
+
* @param {Address} [asset="0x0000000000000000000000000000000000000000"] - The address of the asset (or the zero address for native assets)
|
|
433
|
+
* @param {?ReadParams} [params]
|
|
434
|
+
* @returns {Promise<bigint>} - The amount of assets currently available for distribution
|
|
435
|
+
*/
|
|
436
|
+
public available(
|
|
437
|
+
asset: Address = zeroAddress,
|
|
438
|
+
params?: ReadParams<typeof vestingBudgetAbi, 'available'>,
|
|
439
|
+
) {
|
|
440
|
+
return readVestingBudgetAvailable(this._config, {
|
|
441
|
+
address: this.assertValidAddress(),
|
|
442
|
+
args: [asset],
|
|
443
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
444
|
+
...(params as any),
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Get the amount of assets that have been distributed from the budget
|
|
450
|
+
*
|
|
451
|
+
* @public
|
|
452
|
+
* @param {Address} [asset="0x0000000000000000000000000000000000000000"]
|
|
453
|
+
* @param {?ReadParams} [params]
|
|
454
|
+
* @returns {Promise<bigint>} - The amount of assets distributed
|
|
455
|
+
*/
|
|
456
|
+
public distributed(
|
|
457
|
+
asset: Address = zeroAddress,
|
|
458
|
+
params?: ReadParams<typeof vestingBudgetAbi, 'distributed'>,
|
|
459
|
+
) {
|
|
460
|
+
return readVestingBudgetDistributed(this._config, {
|
|
461
|
+
address: this.assertValidAddress(),
|
|
462
|
+
args: [asset],
|
|
463
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
464
|
+
...(params as any),
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* @inheritdoc
|
|
470
|
+
*
|
|
471
|
+
* @public
|
|
472
|
+
* @param {?VestingBudgetPayload} [_payload]
|
|
473
|
+
* @param {?DeployableOptions} [_options]
|
|
474
|
+
* @returns {GenericDeployableParams}
|
|
475
|
+
*/
|
|
476
|
+
public override buildParameters(
|
|
477
|
+
_payload?: VestingBudgetPayload,
|
|
478
|
+
_options?: DeployableOptions,
|
|
479
|
+
): GenericDeployableParams {
|
|
480
|
+
const [payload, options] = this.validateDeploymentConfig(
|
|
481
|
+
_payload,
|
|
482
|
+
_options,
|
|
483
|
+
);
|
|
484
|
+
if (!payload.owner || payload.owner === zeroAddress) {
|
|
485
|
+
const owner = options.account
|
|
486
|
+
? options.account.address
|
|
487
|
+
: options.config
|
|
488
|
+
? getAccount(options.config).address
|
|
489
|
+
: this._account?.address;
|
|
490
|
+
if (owner) {
|
|
491
|
+
payload.owner = owner;
|
|
492
|
+
} else {
|
|
493
|
+
throw new DeployableUnknownOwnerProvidedError();
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return {
|
|
497
|
+
abi: vestingBudgetAbi,
|
|
498
|
+
bytecode: bytecode as Hex,
|
|
499
|
+
args: [prepareVestingBudgetPayload(payload)],
|
|
500
|
+
...this.optionallyAttachAccount(options.account),
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Given a {@link VestingBudgetPayload}, properly encode a `VestingBudget.InitPayload` for use with {@link VestingBudget} initialization.
|
|
507
|
+
*
|
|
508
|
+
* @param {VestingBudgetPayload} param0
|
|
509
|
+
* @param {Address} param0.owner - The budget's owner.
|
|
510
|
+
* @param {{}} param0.authorized - List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
|
|
511
|
+
* @param {bigint} param0.start - The timestamp at which the vesting schedule begins
|
|
512
|
+
* @param {bigint} param0.duration - The duration of the vesting schedule (in seconds)
|
|
513
|
+
* @param {bigint} param0.cliff - The duration of the cliff period (in seconds)
|
|
514
|
+
* @returns {Hex}
|
|
515
|
+
*/
|
|
516
|
+
export function prepareVestingBudgetPayload({
|
|
517
|
+
owner,
|
|
518
|
+
authorized,
|
|
519
|
+
start,
|
|
520
|
+
duration,
|
|
521
|
+
cliff,
|
|
522
|
+
}: VestingBudgetPayload) {
|
|
523
|
+
return encodeAbiParameters(
|
|
524
|
+
parseAbiParameters([
|
|
525
|
+
'VestingBudgetPayload payload',
|
|
526
|
+
'struct VestingBudgetPayload { address owner; address[] authorized; uint64 start; uint64 duration; uint64 cliff; }',
|
|
527
|
+
]),
|
|
528
|
+
[{ owner, authorized, start, duration, cliff }],
|
|
529
|
+
);
|
|
530
|
+
}
|