Address Contract Verified
Address
0xc2d456b8dDf6ba5F38a09c252DAAe231C45200E9
Balance
0 ETH
Nonce
1
Code Size
4582 bytes
Creator
0x20797082...D27A at tx 0xb5e6c451...d19da1
Indexed Transactions
0
Contract Bytecode
4582 bytes
0x6080604052600436106101025760003560e01c80635121bdd011610095578063a3f8eace11610064578063a3f8eace146102f4578063a41498f114610314578063be9a655514610348578063c53949e41461035d578063d7c37a431461038e57600080fd5b80635121bdd0146102555780637c76aa0d14610289578063810ec23b1461029e5780639852595c146102be57600080fd5b806331db1bcc116100d157806331db1bcc146101c257806338af3eed146101d95780633b4700fa146102205780633d6279c51461023557600080fd5b806304646a491461010e5780630fb5a6b414610150578063180b26071461018d57806319165587146101a257600080fd5b3661010957005b600080fd5b34801561011a57600080fd5b507f0000000000000000000000000000000000000000000000000000000000278d005b6040519081526020015b60405180910390f35b34801561015c57600080fd5b507f0000000000000000000000000000000000000000000000000000000003c2670067ffffffffffffffff1661013d565b34801561019957600080fd5b5060005461013d565b3480156101ae57600080fd5b5061013d6101bd366004610fbc565b6103ac565b3480156101ce57600080fd5b506101d761059e565b005b3480156101e557600080fd5b507f0000000000000000000000001e89950e1aa76ae80af5e9013408bf417ce6cc535b6040516001600160a01b039091168152602001610147565b34801561022c57600080fd5b5061013d61067f565b34801561024157600080fd5b506101d7610250366004610fd7565b6106af565b34801561026157600080fd5b506102087f0000000000000000000000008a854288a5976036a725879164ca3e91d30c6a1b81565b34801561029557600080fd5b506101d761079d565b3480156102aa57600080fd5b5061013d6102b9366004611001565b610874565b3480156102ca57600080fd5b5061013d6102d9366004610fbc565b6001600160a01b031660009081526001602052604090205490565b34801561030057600080fd5b5061013d61030f366004610fbc565b610912565b34801561032057600080fd5b506102087f0000000000000000000000003e49e9c890cd5b015a18ed76e7a4093f569f1a0481565b34801561035457600080fd5b5061013d61095a565b34801561036957600080fd5b5060025461037e90600160a01b900460ff1681565b6040519015158152602001610147565b34801561039a57600080fd5b506002546001600160a01b0316610208565b6000806103b883610912565b905080156103c957426000556103fb565b6040517f969bf7288f744225521096ebffff657851af77dd4c63700d76b8d1cf6481d1f190600090a150600092915050565b6001600160a01b0383166000908152600160205260408120805483929061042390849061105b565b90915550506040518181526001600160a01b038416907fc0e523490dd523c33b1878c9eb14ff46991e3f5b2cd33710918618f2a39cba1b9060200160405180910390a2610491837f0000000000000000000000003e49e9c890cd5b015a18ed76e7a4093f569f1a0483610988565b60006001600160a01b037f0000000000000000000000003e49e9c890cd5b015a18ed76e7a4093f569f1a041663bc157ac1837f0000000000000000000000001e89950e1aa76ae80af5e9013408bf417ce6cc536040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152600060448201526064016020604051808303816000875af1158015610537573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061055b919061106e565b60408051848152602081018390529192507f3ff23663eb1549cf2496a13f81baea9aeb98dee9d6fc24516b0d6972f27e821b910160405180910390a19392505050565b6002546001600160a01b031633146105d15760405162461bcd60e51b81526004016105c890611087565b60405180910390fd5b600254600160a01b900460ff161561063e5760405162461bcd60e51b815260206004820152602a60248201527f56657374696e6757616c6c65743a2061646d696e2061636365737320616c726560448201526918591e48189d5c9b995960b21b60648201526084016105c8565b600280546001600160a81b031916600160a01b1790556040517f592ba3494456a6831f2c650c248a552effda881d7084da6fddc6905717bf3d1290600090a1565b60006106aa7f0000000000000000000000008a854288a5976036a725879164ca3e91d30c6a1b6103ac565b905090565b6002546001600160a01b031633146106d95760405162461bcd60e51b81526004016105c890611087565b600254600160a01b900460ff161561073e5760405162461bcd60e51b815260206004820152602260248201527f56657374696e6757616c6c65743a2061646d696e20616363657373206275726e604482015261195960f21b60648201526084016105c8565b6002546107569083906001600160a01b031683610ad5565b816001600160a01b03167fba443e8671971c36cdeb74f87321041daff421230cbc5e36cb835269ed1d8b7e8260405161079191815260200190565b60405180910390a25050565b336001600160a01b037f0000000000000000000000001e89950e1aa76ae80af5e9013408bf417ce6cc5316146108155760405162461bcd60e51b815260206004820152601e60248201527f56657374696e6757616c6c65743a206e6f742062656e6566696369617279000060448201526064016105c8565b6040514781527f4a056dde23b99279281149762230635e038169d8550d58aa98e060fbf80b23a19060200160405180910390a16108727f0000000000000000000000001e89950e1aa76ae80af5e9013408bf417ce6cc5347610b05565b565b6001600160a01b038216600090815260016020526040812054610909906040516370a0823160e01b81523060048201526001600160a01b038616906370a0823190602401602060405180830381865afa1580156108d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f9919061106e565b610903919061105b565b83610c1e565b90505b92915050565b60008061091f8342610874565b90508015610951576001600160a01b03831660009081526001602052604090205461094a90826110cf565b9392505050565b50600092915050565b67ffffffffffffffff7f0000000000000000000000000000000000000000000000000000000065e1c3401690565b801580610a025750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa1580156109dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a00919061106e565b155b610a6d5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016105c8565b6040516001600160a01b038316602482015260448101829052610ad090849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610d3e565b505050565b6040516001600160a01b038316602482015260448101829052610ad090849063a9059cbb60e01b90606401610a99565b80471015610b555760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016105c8565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610ba2576040519150601f19603f3d011682016040523d82523d6000602084013e610ba7565b606091505b5050905080610ad05760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016105c8565b6000610c2861095a565b8267ffffffffffffffff1611610c405750600061090c565b8167ffffffffffffffff167f0000000000000000000000000000000000000000000000000000000000278d00600054610c79919061105b565b1115610c875750600061090c565b7f0000000000000000000000000000000000000000000000000000000003c2670067ffffffffffffffff16610cba61095a565b610cc4919061105b565b8267ffffffffffffffff161115610cdc57508161090c565b7f0000000000000000000000000000000000000000000000000000000003c2670067ffffffffffffffff16610d0f61095a565b610d239067ffffffffffffffff85166110cf565b610d2d90856110e2565b610d3791906110f9565b905061090c565b6000610d93826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610e109092919063ffffffff16565b805190915015610ad05780806020019051810190610db1919061111b565b610ad05760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105c8565b6060610e1f8484600085610e27565b949350505050565b606082471015610e885760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105c8565b600080866001600160a01b03168587604051610ea49190611161565b60006040518083038185875af1925050503d8060008114610ee1576040519150601f19603f3d011682016040523d82523d6000602084013e610ee6565b606091505b5091509150610ef787838387610f02565b979650505050505050565b60608315610f71578251600003610f6a576001600160a01b0385163b610f6a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105c8565b5081610e1f565b610e1f8383815115610f865781518083602001fd5b8060405162461bcd60e51b81526004016105c8919061117d565b80356001600160a01b0381168114610fb757600080fd5b919050565b600060208284031215610fce57600080fd5b61090982610fa0565b60008060408385031215610fea57600080fd5b610ff383610fa0565b946020939093013593505050565b6000806040838503121561101457600080fd5b61101d83610fa0565b9150602083013567ffffffffffffffff8116811461103a57600080fd5b809150509250929050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561090c5761090c611045565b60006020828403121561108057600080fd5b5051919050565b60208082526028908201527f56657374696e6757616c6c65743a206e6f742061646d696e6973746572656420604082015267313c9030b236b4b760c11b606082015260800190565b8181038181111561090c5761090c611045565b808202811582820484141761090c5761090c611045565b60008261111657634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561112d57600080fd5b8151801515811461094a57600080fd5b60005b83811015611158578181015183820152602001611140565b50506000910152565b6000825161117381846020870161113d565b9190910192915050565b602081526000825180602084015261119c81604085016020870161113d565b601f01601f1916919091016040019291505056fea2646970667358221220e7ea7f10d404eba5a6fcb8e2602f1e0f4e4071018accb0c302850fb5959439b064736f6c63430008130033
Verified Source Code Full Match
Compiler: v0.8.19+commit.7dd6d404
EVM: paris
Optimization: Yes (200 runs)
VestingWalletGET.sol 221 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "openzeppelin-contracts/token/ERC20/utils/SafeERC20.sol";
import "openzeppelin-contracts/utils/Address.sol";
import "openzeppelin-contracts/utils/Context.sol";
import "openzeppelin-contracts/token/ERC20/IERC20.sol";
import "./interfaces/ILockedRevenueDistributionToken.sol";
/**
* @title VestingWalletGET
* @dev This contract handles the vesting of 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 vesting schedule.
* The vesting schedule is customizable through the {vestedAmount} function.
*
* 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.
*/
contract VestingWalletGET is Context {
// events
event AdminAccessBurned();
event EtherSaved(uint256 amount);
event ERC20Released(address indexed token, uint256 amount);
event AdminWithdraw(address indexed token, uint256 amount);
event NothingToClaim();
event UnlockedTokensStaked(uint256 amountUnlocked, uint256 amountStaked);
uint256 private immutable cooldownPeriod_;
uint256 private lastReleased_;
mapping(address => uint256) private _erc20Released;
address private immutable beneficiary_;
uint64 private immutable start_;
ILockedRevenueDistributionToken public immutable stakingContract_;
IERC20 public immutable lockToken_;
uint64 private immutable duration_;
address private administeredBy_;
bool public adminAccessBurned;
/**
* @dev Set the beneficiary, start timestamp and vesting duration of the vesting wallet.
*/
constructor(
address _beneficiaryAddress,
address _administeredBy,
address _lockToken,
address _stakingContract,
uint64 _startTimestamp,
uint64 _durationSeconds,
uint256 _cooldownPeriod
) payable {
require(
_beneficiaryAddress != address(0),
"VestingWallet: beneficiary is zero address"
);
lockToken_ = IERC20(_lockToken);
stakingContract_ = ILockedRevenueDistributionToken(_stakingContract);
beneficiary_ = _beneficiaryAddress;
start_ = _startTimestamp;
duration_ = _durationSeconds;
cooldownPeriod_ = _cooldownPeriod;
lastReleased_ = _startTimestamp;
administeredBy_ = _administeredBy;
adminAccessBurned = false;
}
/**
* @dev The contract should be able to receive Eth.
*/
receive() external payable virtual {}
/**
* @dev Getter for the beneficiary address.
*/
function beneficiary() public view virtual returns (address) {
return beneficiary_;
}
/**
* @dev Getter for the admin address.
*/
function administeredBy() public view virtual returns (address) {
return administeredBy_;
}
/**
* @dev Getter for the start timestamp.
*/
function start() public view virtual returns (uint256) {
return start_;
}
/**
* @dev Getter for the vesting duration.
*/
function duration() public view virtual returns (uint256) {
return duration_;
}
/**
* @dev Duration of the cooldown period
*/
function cooldownPeriod() public view virtual returns (uint256) {
return cooldownPeriod_;
}
/**
* @dev Timestamp of the last token release
*/
function lastRelease() public view virtual returns (uint256) {
return lastReleased_;
}
/**
* @dev Amount of token already released
*/
function released(address token) public view virtual returns (uint256) {
return _erc20Released[token];
}
/**
* @dev Release the native token (ether) that was sent to this wallt by accident
*/
function salvageEthereum() public virtual {
require(msg.sender == beneficiary(), "VestingWallet: not beneficiary");
emit EtherSaved(address(this).balance);
Address.sendValue(payable(beneficiary()), address(this).balance);
}
function burnAdminAccess() public virtual {
require(msg.sender == administeredBy_, "VestingWallet: not administered by admin");
require(!adminAccessBurned, "VestingWallet: admin access already burned");
administeredBy_ = address(0);
adminAccessBurned = true;
emit AdminAccessBurned();
}
/**
* @notice Withdraw vested tokens by admin
* @param _tokenAddress address of the token to withdraw
* @param _withdrawAmount amount of token to withdraw
*/
function withdrawTokensByAdmin(address _tokenAddress, uint256 _withdrawAmount) external {
require(msg.sender == administeredBy_, "VestingWallet: not administered by admin");
require(!adminAccessBurned, "VestingWallet: admin access burned");
SafeERC20.safeTransfer(IERC20(_tokenAddress), administeredBy_, _withdrawAmount);
emit AdminWithdraw(_tokenAddress, _withdrawAmount);
}
/**
* @dev Getter for the amount of releasable `token` tokens. `token` should be the address of an
* IERC20 contract.
*/
function releasable(address token) public view virtual returns (uint256) {
uint256 vested_ = vestedAmount(token, uint64(block.timestamp));
if(vested_ != 0) {
return vested_ - released(token);
} else {
return 0;
}
}
function releaseLockToken() public virtual returns(uint256 amountStakedTokensReleased_){
return release(address(lockToken_));
}
/**
* @dev Release the tokens that have already vested.
* Emits a {ERC20Released} event.
*/
function release(address token) public virtual returns(uint256 amountStakedTokensReleased_){
uint256 amount = releasable(token);
if (amount != 0) {
lastReleased_ = block.timestamp;
} else {
emit NothingToClaim();
return 0;
}
_erc20Released[token] += amount;
emit ERC20Released(token, amount);
SafeERC20.safeApprove(IERC20(token), address(stakingContract_), amount);
uint256 amountStakedTokens_ = stakingContract_.deposit(amount, beneficiary(), 0);
emit UnlockedTokensStaked(amount, amountStakedTokens_);
return amountStakedTokens_;
}
/**
* @dev Calculates the amount of tokens that has already vested. Default implementation is a linear vesting curve.
*/
function vestedAmount(
address token,
uint64 timestamp
) public view virtual returns (uint256) {
return
_vestingSchedule(
IERC20(token).balanceOf(address(this)) + released(token),
timestamp
);
}
/**
* @dev Virtual implementation of the vesting formula. This returns the amount vested, as a function of time, for
* an asset given its total historical allocation.
*/
function _vestingSchedule(
uint256 totalAllocation,
uint64 timestamp
) internal view virtual returns (uint256) {
if (timestamp <= start()) {
return 0;
} else if ((lastReleased_ + cooldownPeriod_) > timestamp) {
return 0;
} else if (timestamp > start() + duration()) {
return totalAllocation;
} else {
return (totalAllocation * (timestamp - start())) / duration();
}
}
}
ILockedRevenueDistributionToken.sol 301 lines
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.7;
interface ILockedRevenueDistributionToken {
/**
* @notice Represents a withdrawal request, packed into a single word.
* @custom:member unlockedAt Timestamp after which the withdrawal is unlocked.
* @custom:member shares Amount of shares to be burned upon withdrawal execution.
* @custom:member assets Amount of assets to be returned to user upon withdrawal execution.
*/
struct WithdrawalRequest {
uint32 unlockedAt;
uint32 lockTime;
uint96 shares;
uint96 assets;
}
/*░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░ Events ░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░*/
/**
* @notice Emitted when burning shares upon withdrawal request cancellation.
* @param assets_ Amount of assets returned to contract address.
* @param shares_ Share delta between withdrawal request creation and cancellation.
*/
event CancellationBurn(uint256 assets_, uint256 shares_);
/**
* @notice Emitted when the instant withdrawal fee is set.
* @param percentage_ A percentage value from 0 to 100.
*/
event InstantWithdrawalFeeChanged(uint256 percentage_);
/**
* @notice Emitted when time-to-unlock for a standard withdrawal set.
* @param lockTime_ Integer length of lock time, e.g. `26 weeks`.
*/
event LockTimeChanged(uint256 lockTime_);
/**
* @notice Emitted when redistributing rewards upon early execution or cancellation of a withdrawal request.
* @param assets_ Assets redistributed to remaining stakers.
*/
event Redistribute(uint256 assets_);
/**
* @notice Emitted when refunding shares upon withdrawal request cancellation.
* @param receiver_ Account to refund shares to at spot rate.
* @param assets_ Equivalent asset value for shares returned.
* @param shares_ Amount of shares returned to the receiver.
*/
event Refund(address indexed receiver_, uint256 assets_, uint256 shares_);
/**
* @notice Emitted when fee exemption status has been set for an address.
* @param account_ Address in which to apply the exemption.
* @param status_ True for exempt, false to remove exemption.
*/
event WithdrawalFeeExemptionStatusChanged(address indexed account_, bool status_);
/**
* @notice Emitted when an instant withdrawal fee is paid.
* @param caller_ The caller of the `redeem` or `withdraw` function.
* @param receiver_ The receiver of the assets.
* @param owner_ The owner of the shares or withdrawal request.
* @param fee_ The assets paid as fee.
*/
event WithdrawalFeePaid(address indexed caller_, address indexed receiver_, address indexed owner_, uint256 fee_);
/**
* @notice Emitted when a new withdrawal request has been created for an account.
* @param request_ Struct containing shares, assets, and maturity date of the created request.
* @param pos_ Index/position of the withdrawal request created.
*/
event WithdrawalRequestCreated(WithdrawalRequest request_, uint256 pos_);
/**
* @notice Emitted when an account cancels any existing withdrawal requests.
* @param pos_ Index/position of the withdrawal request cancelled.
*/
event WithdrawalRequestCancelled(uint256 pos_);
/**
* @notice Emitted when a withdrawal request has been executed with shares burned and assets withdrawn.
* @param pos_ Index/position of the withdrawal request executed.
*/
event WithdrawalRequestExecuted(uint256 pos_);
/*░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░ State Variables ░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░*/
/**
* @notice Constant maximum lock time able to be set using `setLockTime` to avoid permanent lockup.
* @return maximumLockTime_ Maxmimum lock time integer length, e.g. `104 weeks`.
*/
function MAXIMUM_LOCK_TIME() external view returns (uint256 maximumLockTime_);
/**
* @notice Constant vesting period, used in `updateVestingSchedule`.
* @return vestingPeriod_ Fixed vesting period, e.g. `2 weeks`.
*/
function VESTING_PERIOD() external view returns (uint256 vestingPeriod_);
/**
* @notice Constant time window in which unlocked withdrawal requests can be executed.
* @return withdrawalWindow_ Fixed withdrawal window, e.g. `4 weeks`.
*/
function WITHDRAWAL_WINDOW() external view returns (uint256 withdrawalWindow_);
/**
* @notice Percentage withdrawal fee to be applied to instant withdrawals.
* @return instantWithdrawalFee_ A percentage value from 0 to 100.
*/
function instantWithdrawalFee() external view returns (uint256 instantWithdrawalFee_);
/**
* @notice The lock time set for standard withdrawals to become unlocked.
* @return lockTime_ Length of lock of a standard withdrawal request, e.g. `26 weeks`.
*/
function lockTime() external view returns (uint256 lockTime_);
/**
* @notice Returns exemption status for a given account. When true then instant withdrawal fee will not apply.
* @param account_ Account to check for exemption.
* @return status_ Exemption status.
*/
function withdrawalFeeExemptions(address account_) external view returns (bool status_);
/*░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░ Administrative Functions ░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░*/
/**
* @notice Sets the intstant withdrawal fee, applied when making instant withdrawals or redemptions.
* @notice Can only be set by owner.
* @param percentage_ Fee percentage. Must be an integer between 0 and 100 inclusive.
*/
function setInstantWithdrawalFee(uint256 percentage_) external;
/**
* @notice Sets the lock time for standard withdrawals to become unlocked.
* @notice Can only be set by owner.
* @notice Must be lower than MAXIMUM_LOCK_TIME to prevent permanent lockup.
* @param lockTime_ Length of lock of a standard withdrawal request.
*/
function setLockTime(uint256 lockTime_) external;
/**
* @notice Sets or unsets an owner address to be exempt from the withdrawal fee.
* @notice Useful in case of future migrations where an approved contract may be given permission to migrate
* balances to a new token. Can also be used to exempt third-party vaults from facing withdrawal fee when
* managing balances, such as lending platform liquidations.
* @notice Can only be set by contract `owner`.
* @dev The zero address cannot be set as exmempt as this will always represent an address that pays fees.
* @param owner_ Owner address to exempt from instant withdrawal fees.
* @param status_ true to add exemption, false to remove exemption.
*/
function setWithdrawalFeeExemption(address owner_, bool status_) external;
/*░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░ Public Functions ░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░*/
/**
* @notice Creates a new withdrawal request for future execution using the shares conversion at the point of
* request. May only be executed after the unlock date.
* @notice Transfers shares to the vault contract to reserve them, reducing share balance.
* @param shares_ Amount of shares to redeem upon unlock.
*/
function createWithdrawalRequest(uint256 shares_) external;
/**
* @notice Removes an open withdrawal request for the sender.
* @param pos_ Index/position of the withdrawal request to be cancelled.
*/
function cancelWithdrawalRequest(uint256 pos_) external;
/**
* @notice Executes an existing withdrawal request for msg.sender. Before the request is unlocked, a percentage
* fee will be paid, equal to a percentage of the instantWithdrawalFee by time elapsed of the request.
* @param pos_ Index/position of the withdrawal request to be executed.
*/
function executeWithdrawalRequest(uint256 pos_) external;
/**
* @notice Executes an existing withdrawal request that has passed its unlock date.
* @dev Identical to parent implementation but made public by fixed vesting period and removal of owner check.
* @return issuanceRate_ Slope of release of newly added assets, scaled up by `precision`.
* @return freeAssets_ Amount of assets currently released to stakers.
*/
function updateVestingSchedule() external returns (uint256 issuanceRate_, uint256 freeAssets_);
/**
* @notice ERC5143 slippage-protected deposit method. The transaction will revert if the shares to be returned is
* less than minShares_.
* @param assets_ Amount of assets to deposit.
* @param receiver_ The receiver of the shares.
* @param minShares_ Minimum amount of shares to be returned.
* @return shares_ Amount of shares returned to receiver_.
*/
function deposit(uint256 assets_, address receiver_, uint256 minShares_) external returns (uint256 shares_);
/**
* @notice ERC5143 slippage-protected mint method. The transaction will revert if the assets to be deducted is
* greater than maxAssets_.
* @param shares_ Amount of shares to mint.
* @param receiver_ The receiver of the shares.
* @param maxAssets_ Maximum amount of assets to be deducted.
* @return assets_ Amount of deducted when minting shares.
*/
function mint(uint256 shares_, address receiver_, uint256 maxAssets_) external returns (uint256 assets_);
/**
* @notice ERC5143 slippage-protected redeem method. The transaction will revert if the assets to be returned is
* less than minAssets_.
* @param shares_ Amount of shares to redeem.
* @param receiver_ The receiver of the assets.
* @param owner_ Owner of shares making redemption.
* @param minAssets_ Minimum amount of assets to be returned.
* @return assets_ Amount of assets returned.
*/
function redeem(uint256 shares_, address receiver_, address owner_, uint256 minAssets_)
external
returns (uint256 assets_);
/**
* @notice ERC5143 slippage-protected withdraw method. The transaction will revert if the shares to be deducted is
* greater than maxShares_.
* @param assets_ Amount of assets to withdraw.
* @param receiver_ The receiver of the assets.
* @param owner_ Owner of shares making withdrawal.
* @param maxShares_ Minimum amount of shares to be deducted.
* @return shares_ Amount of shares deducted.
*/
function withdraw(uint256 assets_, address receiver_, address owner_, uint256 maxShares_)
external
returns (uint256 shares_);
/*░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░ View Functions ░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░*/
/**
* @notice Previews a redemption of shares for owner. Applies withdrawal fee if owner does not have an exemption.
* @param owner_ Owner of shares making redemption.
* @param shares_ Amount of shares to redeem.
* @return assets_ Assets redeemed for shares for owner.
* @param fee_ The assets paid as fee.
*/
function previewRedeem(uint256 shares_, address owner_) external view returns (uint256 assets_, uint256 fee_);
/**
* @notice Previews a withdrawal of assets for owner. Applies withdrawal fee if owner does not have an exemption.
* @param owner_ Owner of shares makeing withdrawal.
* @param assets_ Amount of assets to withdraw.
* @return shares_ Shares needed to be burned for owner.
* @param fee_ The assets paid as fee.
*/
function previewWithdraw(uint256 assets_, address owner_) external view returns (uint256 shares_, uint256 fee_);
/**
* @notice Previews a withdrawal request execution, calculating the assets returned to the receiver and fee paid.
* @notice Fee percentage reduces linearly from instantWithdrawalFee until 0 at the unlockedAt timestamp.
* @param pos_ Index/position of the withdrawal request to be previewed.
* @param owner_ Owner of the withdrawal request.
* @return request_ The WithdrawalRequest struct within storage.
* @return assets_ Amount of assets returned to owner if withdrawn.
* @return fee_ The assets paid as fee.
*/
function previewWithdrawalRequest(uint256 pos_, address owner_)
external
view
returns (WithdrawalRequest memory request_, uint256 assets_, uint256 fee_);
/**
* @notice Returns a count of the number of created withdrawal requests for an account, including cancelled.
* @param owner_ Account address of owner of withdrawal requests.
* @return count_ Number of withdrawal request created for owner account.
*/
function withdrawalRequestCount(address owner_) external view returns (uint256 count_);
/**
* @notice Returns an array of created withdrawal requests for an account, including cancelled.
* @param owner_ Account address of owner of withdrawal requests.
* @return requests_ Array of withdrawal request structs for an owner.
*/
function withdrawalRequests(address owner_) external view returns (WithdrawalRequest[] memory requests_);
/**
* @notice Returns existing withdrawal request for a given account.
* @param account_ Account address holding withdrawal request.
* @param pos_ Index/position of the withdrawal request in the array.
* @return request_ Withdrawal request struct found at position for owner.
*/
function withdrawalRequests(address account_, uint256 pos_)
external
view
returns (WithdrawalRequest memory request_);
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
SafeERC20.sol 116 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
draft-IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
Read Contract
adminAccessBurned 0xc53949e4 → bool
administeredBy 0xd7c37a43 → address
beneficiary 0x38af3eed → address
cooldownPeriod 0x04646a49 → uint256
duration 0x0fb5a6b4 → uint256
lastRelease 0x180b2607 → uint256
lockToken_ 0x5121bdd0 → address
releasable 0xa3f8eace → uint256
released 0x9852595c → uint256
stakingContract_ 0xa41498f1 → address
start 0xbe9a6555 → uint256
vestedAmount 0x810ec23b → uint256
Write Contract 5 functions
These functions modify contract state and require a wallet transaction to execute.
burnAdminAccess 0x31db1bcc
No parameters
release 0x19165587
address token
returns: uint256
releaseLockToken 0x3b4700fa
No parameters
returns: uint256
salvageEthereum 0x7c76aa0d
No parameters
withdrawTokensByAdmin 0x3d6279c5
address _tokenAddress
uint256 _withdrawAmount
Recent Transactions
No transactions found for this address