Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TokenTimelock, PaymentSplitter, ERC20Snapshot, ERC20VotesComp, GovernorVotesComp #4276

Merged
merged 14 commits into from
May 26, 2023
Merged
5 changes: 5 additions & 0 deletions .changeset/clever-eagles-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': major
---

`PaymentSplitter`: removed.
frangio marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions .changeset/ninety-ghosts-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': major
---

`ERC20Snapshot`: removed.
5 changes: 5 additions & 0 deletions .changeset/stupid-sheep-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': major
---

`TokenTimelock`: removed in favor of `VestingWallet`.
214 changes: 0 additions & 214 deletions contracts/finance/PaymentSplitter.sol

This file was deleted.

6 changes: 0 additions & 6 deletions contracts/finance/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@ NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/

This directory includes primitives for financial systems:

- {PaymentSplitter} allows to split Ether and ERC20 payments among a group of accounts. The sender does not need to be
aware that the assets will be split in this way, since it is handled transparently by the contract. The split can be
in equal parts or in any other arbitrary proportion.

- {VestingWallet} handles the vesting of Ether and ERC20 tokens for a given beneficiary. Custody of multiple tokens can
be given to this contract, which will release the token to the beneficiary following a given, customizable, vesting
schedule.

== Contracts

{{PaymentSplitter}}

{{VestingWallet}}
12 changes: 11 additions & 1 deletion contracts/finance/VestingWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import "../utils/Context.sol";
* Any token transferred to this contract will follow the vesting schedule as if they were locked from the beginning.
* Consequently, if the vesting has already started, any amount of tokens sent to this contract will (at least partly)
* be immediately releasable.
*
* By setting the duration to 0, one can configure this contract to behave like an asset timelock that hold tokens for
* a beneficiary until a specified time.
*/
contract VestingWallet is Context {
event EtherReleased(uint256 amount);
Expand Down Expand Up @@ -62,6 +65,13 @@ contract VestingWallet is Context {
return _duration;
}

/**
* @dev Getter for the end timestamp.
*/
function end() public view virtual returns (uint256) {
return _start + _duration;
}

/**
* @dev Amount of eth already released
*/
Expand Down Expand Up @@ -136,7 +146,7 @@ contract VestingWallet is Context {
function _vestingSchedule(uint256 totalAllocation, uint64 timestamp) internal view virtual returns (uint256) {
if (timestamp < start()) {
return 0;
} else if (timestamp > start() + duration()) {
} else if (timestamp > end()) {
frangio marked this conversation as resolved.
Show resolved Hide resolved
return totalAllocation;
} else {
return (totalAllocation * (timestamp - start())) / duration();
Expand Down
12 changes: 5 additions & 7 deletions contracts/token/ERC20/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ Additionally there are multiple custom extensions, including:
* {ERC20Burnable}: destruction of own tokens.
* {ERC20Capped}: enforcement of a cap to the total supply when minting tokens.
* {ERC20Pausable}: ability to pause token transfers.
* {ERC20Snapshot}: efficient storage of past token balances to be later queried at any point in time.
* {ERC20Permit}: gasless approval of tokens (standardized as ERC2612).
* {ERC20FlashMint}: token level support for flash loans through the minting and burning of ephemeral tokens (standardized as ERC3156).
* {ERC20Votes}: support for voting and vote delegation.
* {ERC20VotesComp}: support for voting and vote delegation (compatible with Compound's token, with uint96 restrictions).
* {ERC20Wrapper}: wrapper to create an ERC20 backed by another ERC20, with deposit and withdraw methods. Useful in conjunction with {ERC20Votes}.
* {ERC4626}: tokenized vault that manages shares (represented as ERC20) that are backed by assets (another ERC20).

Finally, there are some utilities to interact with ERC20 contracts in various ways.
Finally, there are some utilities to interact with ERC20 contracts in various ways:

* {SafeERC20}: a wrapper around the interface that eliminates the need to handle boolean return values.
* {TokenTimelock}: hold tokens for a beneficiary until a specified time.

Other utilities that support ERC20 assets can be found in codebase:

* ERC20 tokens can be timelocked (held tokens for a beneficiary until a specified time) or vested (released following a given schedule) using a {VestingWallet}.

NOTE: This core set of contracts is designed to be unopinionated, allowing developers to access the internal functions in ERC20 (such as <<ERC20-_mint-address-uint256-,`_mint`>>) and expose them as external functions in the way they prefer.

Expand All @@ -51,8 +53,6 @@ NOTE: This core set of contracts is designed to be unopinionated, allowing devel

{{ERC20Permit}}

{{ERC20Snapshot}}

{{ERC20Votes}}

{{ERC20VotesComp}}
Expand All @@ -66,5 +66,3 @@ NOTE: This core set of contracts is designed to be unopinionated, allowing devel
== Utilities

{{SafeERC20}}

{{TokenTimelock}}