GovernedVault
Inherits: IGovernedVault
Title: GovernedVault
Author: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80)
The RECONCILIATION facet of the self-governed ERC-4626 vault. The vault is ONE diamond that composes
the strategy-aware vault (VaultCore → ERC4626 → ERC20), vote-weighted shares (ERC20Votes),
an on-chain Governor, and a TimelockController — all cut as their normal facets — but a handful
of selectors either CLASH across those facets or must be MODIFIED for the single-diamond topology.
This small facet owns exactly those selectors; DeployGovernedVault cuts it for them and excludes
them from the base facets.
Deliberately a THIN library-delegating facet (NOT inheriting the four heavy facets — that would exceed EIP-170 by ~2x). It resolves:
- SELECTOR CLASHES:
name(ERC-20 vs Governor → the share name),clock/CLOCK_MODE(Votes vs Governor → the Votes clock),transfer/transferFrom(base ERC-20 vs the checkpoint-updating ERC20Votes variants → the checkpoint variants). - VAULT MINT/BURN → VOTE CHECKPOINT SEAM: the audited ERC4626Lib mutators move shares via ERC20Lib's
plain
_update(no checkpoint); each is wrapped here to post the matching VotesLib voting-unit delta, so governance weight tracks deposits/withdrawals. (transfer/transferFromalready checkpoint via ERC20Votes.) - BALLOT-NONCE NAMESPACE:
castVoteBySigdraws from GovernedVaultLib's dedicated nonce, leaving the ERC-20delegateBySignonce on NoncesLib — see GovernedVaultLib for why a shared counter would silently invalidate signatures.
Functions
ballotNonce
The next unused governor-ballot nonce for voter (consumed by castVoteBySig). Distinct from the
ERC-20 delegation nonce returned elsewhere.
function ballotNonce(address voter) external view returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| voter | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
name
The single share-token name (resolves the ERC-20 vs Governor name() clash).
function name() external view returns (string memory);Returns
| Name | Type | Description |
|---|---|---|
| <none> | string |
clock
The ERC-6372 clock (the Votes/shares clock serves both the token and the governor).
function clock() external view returns (uint48);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint48 |
CLOCK_MODE
The ERC-6372 clock mode.
function CLOCK_MODE() external view returns (string memory);Returns
| Name | Type | Description |
|---|---|---|
| <none> | string |
transfer
Checkpoint-updating share transfer (resolves the base ERC-20 vs ERC20Votes clash).
function transfer(address to, uint256 value) external returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| to | address | |
| value | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
transferFrom
Checkpoint-updating share transferFrom.
function transferFrom(address from, address to, uint256 value) external returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| from | address | |
| to | address | |
| value | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
deposit
Deposit assets for shares, then post the mint's voting-unit delta (strategy-rebalance guarded, closed while the strategy manager latches deposits).
function deposit(uint256 assets, address receiver) external returns (uint256 shares);Parameters
| Name | Type | Description |
|---|---|---|
| assets | uint256 | |
| receiver | address |
Returns
| Name | Type | Description |
|---|---|---|
| shares | uint256 |
mint
Mint exact shares for assets, then post the voting-unit delta (closed while deposits are latched).
function mint(uint256 shares, address receiver) external returns (uint256 assets);Parameters
| Name | Type | Description |
|---|---|---|
| shares | uint256 | |
| receiver | address |
Returns
| Name | Type | Description |
|---|---|---|
| assets | uint256 |
withdraw
Withdraw exact assets by burning shares, then post the burn's voting-unit delta.
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);Parameters
| Name | Type | Description |
|---|---|---|
| assets | uint256 | |
| receiver | address | |
| owner | address |
Returns
| Name | Type | Description |
|---|---|---|
| shares | uint256 |
redeem
Redeem exact shares for assets, then post the burn's voting-unit delta.
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);Parameters
| Name | Type | Description |
|---|---|---|
| shares | uint256 | |
| receiver | address | |
| owner | address |
Returns
| Name | Type | Description |
|---|---|---|
| assets | uint256 |
castVoteBySig
Cast a vote by EIP-712 signature, consuming the vault's DEDICATED ballot nonce (not the shared
NoncesLib counter the ERC-20 delegateBySig owns). Only the nonce source differs from
GovernorLib.castVoteBySig.
function castVoteBySig(uint256 proposalId, uint8 support, address voter, bytes memory signature)
external
returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| proposalId | uint256 | |
| support | uint8 | |
| voter | address | |
| signature | bytes |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
exportSelectors
ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).
Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches
forge inspect GovernedVault methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
CLOCK_MODE() 0x4bf5d7e9
ballotNonce(address) 0xd5cae628
castVoteBySig(uint256,uint8,address,bytes) 0x8ff262e3
clock() 0x91ddadf4
deposit(uint256,address) 0x6e553f65
mint(uint256,address) 0x94bf804d
name() 0x06fdde03
redeem(uint256,address,address) 0xba087652
transfer(address,uint256) 0xa9059cbb
transferFrom(address,address,uint256) 0x23b872dd
withdraw(uint256,address,address) 0xb460af94
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |