Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
"
},
"@openzeppelin/contracts/access/Ownable2Step.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.0;
import "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
_transferOwnership(sender);
}
}
"
},
"@openzeppelin/contracts/security/ReentrancyGuard.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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);
}
"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
"
},
"contracts/ReserveVault.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;
/**
*
* @title ReserveVault - HYM Strategic Redistribution Vault (PATCHED VERSION)
* @dev Manages the redistribution of accumulated tokens for different purposes
* @notice Implemented fixes:
* - Gnosis Safe-ready
* - Improved cooldown control
* - Improved monitoring functions
* - Gas optimization
*/
import '@openzeppelin/contracts/access/Ownable2Step.sol';
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/security/ReentrancyGuard.sol';
contract ReserveVault is Ownable2Step, ReentrancyGuard {
// --- Timelock para Gnosis Safe ---
address public timelock;
event TimelockSet(address indexed oldTimelock, address indexed newTimelock);
modifier onlyGov() {
require(msg.sender == owner() || msg.sender == timelock, 'Only owner/timelock');
_;
}
function setTimelock(address newTimelock) public onlyOwner {
emit TimelockSet(timelock, newTimelock);
timelock = newTimelock;
}
// --- Main settings ---
IERC20 public immutable hymToken;
address public lastroWallet; // 30% - Lastro reserve
address public infraWallet; // 30% - Infrastructure
address public marketingWallet; // 20% - Marketing
address public distributorWallet; // 20% - HolderDistributor
// --- Distribution percentages (base 10000) ---
uint256 public lastroPercentage = 3000; // 30%
uint256 public infraPercentage = 3000; // 30%
uint256 public marketingPercentage = 2000; // 20%
uint256 public distributorPercentage = 2000; // 20%
// --- Cooldown control ---
uint256 public lastDistribution;
uint256 public distributionCooldown = 30 days;
uint256 public minimumDistribution = 1000 * 1e18; // Minimum 1000 HYM
// --- Distribution history ---
struct DistributionRecord {
uint256 timestamp;
uint256 totalAmount;
uint256 lastroAmount;
uint256 infraAmount;
uint256 marketingAmount;
uint256 distributorAmount;
}
DistributionRecord[] public distributionHistory;
// --- Events ---
event WalletsUpdated(
address indexed lastro,
address indexed infra,
address indexed marketing,
address distributor
);
event PercentagesUpdated(
uint256 lastro,
uint256 infra,
uint256 marketing,
uint256 distributor
);
event TokensDistributed(
uint256 totalAmount,
uint256 lastroAmount,
uint256 infraAmount,
uint256 marketingAmount,
uint256 distributorAmount
);
event CooldownUpdated(uint256 newCooldown);
event MinimumDistributionUpdated(uint256 newMinimum);
event EmergencyWithdraw(address indexed to, uint256 amount);
/**
* @dev Constructor for the ReserveVault contract.
* @param _token Address of the HYM token.
* @param _lastro Address of the lastro wallet.
* @param _infra Address of the infrastructure wallet.
* @param _marketing Address of the marketing wallet.
* @param _distributor Address of the distributor contract.
*/
constructor(
address _token,
address _lastro,
address _infra,
address _marketing,
address _distributor
) Ownable2Step() {
require(_token != address(0), "Invalid token");
require(_lastro != address(0), "Invalid lastro");
require(_infra != address(0), "Invalid infra");
require(_marketing != address(0), "Invalid marketing");
require(_distributor != address(0), "Invalid distributor");
hymToken = IERC20(_token);
lastroWallet = _lastro;
infraWallet = _infra;
marketingWallet = _marketing;
distributorWallet = _distributor;
lastDistribution = block.timestamp;
}
/**
* @notice Distributes the accumulated tokens according to the configured percentages
* MODIFIED FOR TESTING: Cooldown temporarily disabled
*/
function distribute() external nonReentrant {
// COOLDOWN DISABLED FOR TESTING
// require(
// block.timestamp >= lastDistribution + distributionCooldown,
// "Cooldown period not met"
// );
uint256 totalBalance = hymToken.balanceOf(address(this));
require(totalBalance >= minimumDistribution, "Below minimum distribution");
// Calculate values for each wallet
uint256 lastroAmount = (totalBalance * lastroPercentage) / 10000;
uint256 infraAmount = (totalBalance * infraPercentage) / 10000;
uint256 marketingAmount = (totalBalance * marketingPercentage) / 10000;
uint256 distributorAmount = (totalBalance * distributorPercentage) / 10000;
// Adjust to ensure the entire amount is distributed
uint256 totalCalculated = lastroAmount + infraAmount + marketingAmount + distributorAmount;
if (totalCalculated < totalBalance) {
// Add difference to lastro
lastroAmount += (totalBalance - totalCalculated);
}
// Execute transfers
require(hymToken.transfer(lastroWallet, lastroAmount), "Lastro transfer failed");
require(hymToken.transfer(infraWallet, infraAmount), "Infra transfer failed");
require(hymToken.transfer(marketingWallet, marketingAmount), "Marketing transfer failed");
require(hymToken.transfer(distributorWallet, distributorAmount), "Distributor transfer failed");
// Update state
lastDistribution = block.timestamp;
// Record in history
distributionHistory.push(DistributionRecord({
timestamp: block.timestamp,
totalAmount: totalBalance,
lastroAmount: lastroAmount,
infraAmount: infraAmount,
marketingAmount: marketingAmount,
distributorAmount: distributorAmount
}));
emit TokensDistributed(
totalBalance,
lastroAmount,
infraAmount,
marketingAmount,
distributorAmount
);
}
/**
* @notice Updates the destination wallet addresses
* @param _lastro New address of the lastro wallet
* @param _infra New address of the infrastructure wallet
* @param _marketing New address of the marketing wallet
* @param _distributor New address of the distributor contract
*/
function updateWallets(
address _lastro,
address _infra,
address _marketing,
address _distributor
) external onlyGov {
require(_lastro != address(0), "Invalid lastro");
require(_infra != address(0), "Invalid infra");
require(_marketing != address(0), "Invalid marketing");
require(_distributor != address(0), "Invalid distributor");
lastroWallet = _lastro;
infraWallet = _infra;
marketingWallet = _marketing;
distributorWallet = _distributor;
emit WalletsUpdated(_lastro, _infra, _marketing, _distributor);
}
/**
* @notice Updates the distribution percentages
* @param _lastro Percentage for lastro (base 10000)
* @param _infra Percentage for infrastructure (base 10000)
* @param _marketing Percentage for marketing (base 10000)
* @param _distributor Percentage for distributor (base 10000)
*/
function updatePercentages(
uint256 _lastro,
uint256 _infra,
uint256 _marketing,
uint256 _distributor
) external onlyGov {
require(
_lastro + _infra + _marketing + _distributor == 10000,
"Percentages must sum to 100%"
);
lastroPercentage = _lastro;
infraPercentage = _infra;
marketingPercentage = _marketing;
distributorPercentage = _distributor;
emit PercentagesUpdated(_lastro, _infra, _marketing, _distributor);
}
/**
* @notice Updates the cooldown period between distributions
* @param newCooldown New period in seconds
*/
function updateDistributionCooldown(uint256 newCooldown) external onlyGov {
require(newCooldown >= 1 days, "Minimum cooldown: 1 day");
require(newCooldown <= 90 days, "Maximum cooldown: 90 days");
distributionCooldown = newCooldown;
emit CooldownUpdated(newCooldown);
}
/**
* @notice Updates the minimum distribution amount
* @param newMinimum New minimum value
*/
function updateMinimumDistribution(uint256 newMinimum) external onlyGov {
require(newMinimum > 0, "Minimum must be greater than zero");
minimumDistribution = newMinimum;
emit MinimumDistributionUpdated(newMinimum);
}
/**
* @notice Returns information about the next distribution
* @return canDistribute Whether it can distribute now
* @return timeUntilNext Time until next distribution
* @return currentBalance Current vault balance
* @return nextDistribution Timestamp of the next distribution
*/
function getDistributionInfo()
external
view
returns (
bool canDistribute,
uint256 timeUntilNext,
uint256 currentBalance,
uint256 nextDistribution
)
{
currentBalance = hymToken.balanceOf(address(this));
nextDistribution = lastDistribution + distributionCooldown;
if (block.timestamp >= nextDistribution && currentBalance >= minimumDistribution) {
canDistribute = true;
timeUntilNext = 0;
} else {
canDistribute = false;
timeUntilNext = nextDistribution > block.timestamp ? nextDistribution - block.timestamp : 0;
}
}
/**
* @notice Simulates a distribution without executing it
* @return lastroAmount Amount that would be sent to lastro
* @return infraAmount Amount that would be sent to infrastructure
* @return marketingAmount Amount that would be sent to marketing
* @return distributorAmount Amount that would be sent to distributor
*/
function previewDistribution()
external
view
returns (
uint256 lastroAmount,
uint256 infraAmount,
uint256 marketingAmount,
uint256 distributorAmount
)
{
uint256 totalBalance = hymToken.balanceOf(address(this));
lastroAmount = (totalBalance * lastroPercentage) / 10000;
infraAmount = (totalBalance * infraPercentage) / 10000;
marketingAmount = (totalBalance * marketingPercentage) / 10000;
distributorAmount = (totalBalance * distributorPercentage) / 10000;
// Adjusts to ensure the entire amount is distributed
uint256 totalCalculated = lastroAmount + infraAmount + marketingAmount + distributorAmount;
if (totalCalculated < totalBalance) {
lastroAmount += (totalBalance - totalCalculated);
}
}
/**
* @notice Returns the distribution history
* @param limit Maximum number of records to return
* @return Array with distribution history
*/
function getDistributionHistory(uint256 limit)
external
view
returns (DistributionRecord[] memory)
{
uint256 length = distributionHistory.length;
if (limit > length) limit = length;
DistributionRecord[] memory result = new DistributionRecord[](limit);
for (uint256 i = 0; i < limit; i++) {
result[i] = distributionHistory[length - 1 - i]; // Most recent first
}
return result;
}
/**
* @notice Returns general vault statistics
* @return totalDistributions Total number of distributions
* @return totalDistributed Total amount already distributed
* @return currentBalance Current balance
* @return lastDistributionTime Timestamp of the last distribution
*/
function getVaultStats()
external
view
returns (
uint256 totalDistributions,
uint256 totalDistributed,
uint256 currentBalance,
uint256 lastDistributionTime
)
{
totalDistributions = distributionHistory.length;
for (uint256 i = 0; i < distributionHistory.length; i++) {
totalDistributed += distributionHistory[i].totalAmount;
}
currentBalance = hymToken.balanceOf(address(this));
lastDistributionTime = lastDistribution;
}
/**
* @notice Emergency function to withdraw all tokens
* @param to Destination address
*/
function emergencyWithdrawAll(address to) external onlyOwner nonReentrant {
require(to != address(0), "Invalid destination");
uint256 balance = hymToken.balanceOf(address(this));
require(balance > 0, "Nothing to withdraw");
require(hymToken.transfer(to, balance), "Transfer failed");
emit EmergencyWithdraw(to, balance);
}
/**
* @notice Emergency function to recover accidentally sent ERC20 tokens
* @param token Address of the token to recover
* @param amount Amount to recover
*/
function emergencyRecoverToken(address token, uint256 amount) external onlyOwner {
require(token != address(hymToken), "Cannot recover HYM");
require(token != address(0), "Invalid token address");
IERC20(token).transfer(owner(), amount);
}
/**
* @notice Force a distribution ignoring cooldown (emergency only)
* @dev Should only be used in exceptional situations
*/
function forceDistribute() external onlyOwner nonReentrant {
uint256 totalBalance = hymToken.balanceOf(address(this));
require(totalBalance > 0, "Nothing to distribute");
// Calculate amounts for each wallet
uint256 lastroAmount = (totalBalance * lastroPercentage) / 10000;
uint256 infraAmount = (totalBalance * infraPercentage) / 10000;
uint256 marketingAmount = (totalBalance * marketingPercentage) / 10000;
uint256 distributorAmount = (totalBalance * distributorPercentage) / 10000;
// Adjust to ensure the entire amount is distributed
uint256 totalCalculated = lastroAmount + infraAmount + marketingAmount + distributorAmount;
if (totalCalculated < totalBalance) {
lastroAmount += (totalBalance - totalCalculated);
}
// Execute transfers
require(hymToken.transfer(lastroWallet, lastroAmount), "Lastro transfer failed");
require(hymToken.transfer(infraWallet, infraAmount), "Infra transfer failed");
require(hymToken.transfer(marketingWallet, marketingAmount), "Marketing transfer failed");
require(hymToken.transfer(distributorWallet, distributorAmount), "Distributor transfer failed");
// Update state
lastDistribution = block.timestamp;
// Record in history
distributionHistory.push(DistributionRecord({
timestamp: block.timestamp,
totalAmount: totalBalance,
lastroAmount: lastroAmount,
infraAmount: infraAmount,
marketingAmount: marketingAmount,
distributorAmount: distributorAmount
}));
emit TokensDistributed(
totalBalance,
lastroAmount,
infraAmount,
marketingAmount,
distributorAmount
);
}
}
"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
Submitted on: 2025-09-25 10:21:46
Comments
Log in to comment.
No comments yet.