This contract is designed to manage all assets owned by the VeBetter DAO
This contract handles the receiving and transferring of assets, leveraging upgradeable, pausable, and access control features.
bytes32 GOVERNANCE_ROLE
Role identifier for governance operations
bytes32 UPGRADER_ROLE
Role identifier for upgrading the contract
bytes32 PAUSER_ROLE
Role identifier for pausing the contract
address VTHO
Address of VTHO token (Built-in Contract on Vechain Thor)
Storage structure for Treasury
GalaxyMemberStorage structure holds all the state variables in a single location.
struct TreasuryStorage {
address B3TR;
address VOT3;
mapping(address => uint256) transferLimit;
uint256 transferLimitVET;
}
event TransferLimitUpdated(address token, uint256 limit)
Emitted when transfer limit for a token is updated
event TransferLimitVETUpdated(uint256 limit)
Emitted when transfer limit for VET is updated
function _getTreasuryStorage() internal pure returns (struct Treasury.TreasuryStorage $)
Retrieves the stored TreasuryStorage
from its
designated slot
modifier onlyGovernanceWhenNotPaused()
Ensures that only users with governance role can perform actions when the contract is not paused
modifier onlyAdminOrGovernance()
constructor() public
function initialize(address _b3tr, address _vot3, address _timeLock, address _admin, address _proxyAdmin, address _pauser, uint256 _transferLimitVET, uint256 _transferLimitB3TR, uint256 _transferLimitVOT3, uint256 _transferLimitVTHO) external
Initializes the contract with necessary roles and token addresses
Name | Type | Description |
---|---|---|
_b3tr | address | Address of the B3TR token |
_vot3 | address | Address of the VOT3 token |
_timeLock | address | Address of the timelock contract controlling governance actions |
_admin | address | Address of the admin responsible for initial setup |
_proxyAdmin | address | Address of the proxy administrator for upgrade purposes |
_pauser | address | Address of the pauser role |
_transferLimitVET | uint256 | Transfer limit for VET |
_transferLimitB3TR | uint256 | Transfer limit for B3TR |
_transferLimitVOT3 | uint256 | Transfer limit for VOT3 |
_transferLimitVTHO | uint256 | Transfer limit for VTHO |
receive() external payable
Allows the contract to receive VET directly
fallback() external payable
Fallback function to handle incoming VET when data is sent
function pause() external
Pauses the Treasury contract
Pausing the contract will prevent all transfers and staking operations Only admin with pauser role can pause the contract
function unpause() external
Unpauses the Treasury contract allowing normal operations
Only admin with pauser role can unpause the contract
function transferVTHO(address _to, uint256 _value) external
Transfers a specified amount of VTHO tokens to a specified address
Only governance can transfer VTHO when the contract is not paused
Name | Type | Description |
---|---|---|
_to | address | Recipient of the VTHO |
_value | uint256 | Amount of VTHO to transfer |
function transferB3TR(address _to, uint256 _value) external
Transfers a specified amount of B3TR tokens to a specified address
Only governance can transfer B3TR when the contract is not paused
Name | Type | Description |
---|---|---|
_to | address | Recipient of the B3TR |
_value | uint256 | Amount of B3TR to transfer |
function transferVOT3(address _to, uint256 _value) external
Transfers a specified amount of VOT3 tokens to a specified address
Only governance can transfer VOT3 when the contract is not paused
Name | Type | Description |
---|---|---|
_to | address | Recipient of the VOT3 |
_value | uint256 | Amount of VOT3 to transfer |
function transferVET(address _to, uint256 _value) external
Transfers a specified amount of VET to a specified address
Only governance can transfer VET when the contract is not paused
Name | Type | Description |
---|---|---|
_to | address | Recipient of the VET |
_value | uint256 | Amount of VET to transfer |
function transferTokens(address _token, address _to, uint256 _value) external
Transfers any ERC20 token to a given address
Only governance can transfer tokens when the contract is not paused
Name | Type | Description |
---|---|---|
_token | address | The ERC20 token to transfer |
_to | address | Recipient of the ERC20 token |
_value | uint256 | Amount of the ERC20 token to transfer |
function transferNFT(address _nft, address _to, uint256 _tokenId) external
Transfers an ERC721 token to a specified address
Only governance can transfer NFTs when the contract is not paused
Name | Type | Description |
---|---|---|
_nft | address | The ERC721 token to transfer |
_to | address | Recipient of the ERC721 token |
_tokenId | uint256 | The id of the ERC721 token to transfer |
function transferERC1155Tokens(address _tokenAddress, address _to, uint256 _id, uint256 _value, bytes _data) external
Transfers an ERC1155 token to a specified address
Only governance can transfer ERC1155 tokens when the contract is not paused
Name | Type | Description |
---|---|---|
_tokenAddress | address | The ERC1155 token to transfer |
_to | address | Recipient of the ERC1155 token |
_id | uint256 | The id of the ERC1155 token to transfer |
_value | uint256 | The amount of token ERC1155 token to transfer |
_data | bytes | Additional data with no specified format |
function convertB3TR(uint256 _b3trAmount) external
Converts a specified amount of B3TR to VOT3
Only governance can convert B3TR when the contract is not paused
Name | Type | Description |
---|---|---|
_b3trAmount | uint256 | Amount of B3TR to convert |
function convertVOT3(uint256 _vot3Amount) external
Converts a specified amount of VOT3 to B3TR
Only governance can convert VOT3 when the contract is not paused
Name | Type | Description |
---|---|---|
_vot3Amount | uint256 | Amount of VOT3 to convert |
function setTransferLimitVET(uint256 _transferLimitVET) external
Sets the transfer limit for VET
Name | Type | Description |
---|---|---|
_transferLimitVET | uint256 | The new transfer limit for VET |
function setTransferLimitToken(address _token, uint256 _transferLimit) external
Sets the transfer limit for any token
Name | Type | Description |
---|---|---|
_token | address | The token to set the transfer limit for |
_transferLimit | uint256 |
function getVTHOBalance() external view returns (uint256)
Retrieves the balance of VTHO held by the contract
function getB3TRBalance() external view returns (uint256)
Retrieves the balance of B3TR held by the contract
function getVOT3Balance() external view returns (uint256)
Retrieves the balance of VOT3 held by the contract
function getVETBalance() external view returns (uint256)
Retrieves the balance of VET held by the contract
function getTokenBalance(address _token) external view returns (uint256)
Retrieves the balance of any ERC20 token held by the contract
Name | Type | Description |
---|---|---|
_token | address | The ERC20 token to check balance for |
function getCollectionNFTBalance(address _nft) external view returns (uint256)
Retrieves the balance of any ERC721 token held by the contract
Name | Type | Description |
---|---|---|
_nft | address | The ERC721 token to check balance for |
function getERC1155TokenBalance(address _token, uint256 _id) external view returns (uint256)
Retrieves the balance of any ERC1155 token held by the contract
Name | Type | Description |
---|---|---|
_token | address | The ERC1155 token to check balance for |
_id | uint256 | The id of the ERC1155 token |
function version() external pure virtual returns (string)
Retrieves the current version of the contract
function b3trAddress() public view returns (address)
Retrieves the address of the B3TR token
function vot3Address() public view returns (address)
Retrieves the address of the VOT3 token
function getTransferLimitVET() external view returns (uint256)
function getTransferLimitToken(address _token) external view returns (uint256)
function _getERC20Contract(address token) internal pure returns (contract IERC20)
Internal function to get the ERC20 contract instance
function onERC721Received(address, address, uint256, bytes) external pure returns (bytes4)
See {IERC721Receiver-onERC721Received}.
function onERC1155Received(address, address, uint256, uint256, bytes) public virtual returns (bytes4)
See {IERC1155Receiver-onERC1155Received}.
Name | Type | Description |
---|---|---|
[0] | bytes4 | bytes4 The selector of the function |
function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) public virtual returns (bytes4)
See {IERC1155Receiver-onERC1155BatchReceived}.
Name | Type | Description |
---|---|---|
[0] | bytes4 | bytes4 The selector of the function |
function _authorizeUpgrade(address newImplementation) internal virtual
_Function that should revert when msg.sender
is not
authorized to upgrade the contract. Called by {upgradeToAndCall}.
Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
solidity function _authorizeUpgrade(address) internal onlyOwner {}
_