Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/contracts/vault/VaultTokenized.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ contract VaultTokenized is Vault, ERC20Upgradeable, IVaultTokenized {
/**
* @inheritdoc ERC20Upgradeable
*/
function _update(address from, address to, uint256 value) internal override {
function _update(address from, address to, uint256 value) internal virtual override {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_activeShares.push(Time.timestamp(), totalSupply() + value);
Expand Down
48 changes: 48 additions & 0 deletions src/contracts/vault/VaultTokenizedVotes.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {VotesUpgradeable} from "lib/openzeppelin-contracts-upgradeable/contracts/governance/utils/VotesUpgradeable.sol";
import {Time} from "@openzeppelin/contracts/utils/types/Time.sol";
import {VaultTokenized} from "./VaultTokenized.sol";

contract VaultTokenizedVotes is VaultTokenized, VotesUpgradeable {
constructor(
address delegatorFactory,
address slasherFactory,
address vaultFactory
) VaultTokenized(delegatorFactory, slasherFactory, vaultFactory) {}

function clock() public view override returns (uint48) {
return Time.timestamp();
}

function CLOCK_MODE() public pure override returns (string memory) {
return "mode=timestamp";
}

function _getVotingUnits(
address account
) internal view virtual override returns (uint256) {
return balanceOf(account);
}

error ERC20ExceededSafeSupply(uint256 increasedSupply, uint256 cap);

function _maxSupply() internal view virtual returns (uint256) {
return type(uint208).max;
}

function _update(address from, address to, uint256 value) internal virtual override {
VaultTokenized._update(from, to, value);

// copied from ERC20Votes._update
if (from == address(0)) {
uint256 supply = totalSupply();
uint256 cap = _maxSupply();
if (supply > cap) {
revert ERC20ExceededSafeSupply(supply, cap);
}
}
_transferVotingUnits(from, to, value);
}
}