Solidity API

Treasury

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.

GOVERNANCE_ROLE

bytes32 GOVERNANCE_ROLE

Role identifier for governance operations

UPGRADER_ROLE

bytes32 UPGRADER_ROLE

Role identifier for upgrading the contract

PAUSER_ROLE

bytes32 PAUSER_ROLE

Role identifier for pausing the contract

VTHO

address VTHO

Address of VTHO token (Built-in Contract on Vechain Thor)

TreasuryStorage

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;
}

TransferLimitUpdated

event TransferLimitUpdated(address token, uint256 limit)

Emitted when transfer limit for a token is updated

TransferLimitVETUpdated

event TransferLimitVETUpdated(uint256 limit)

Emitted when transfer limit for VET is updated

_getTreasuryStorage

function _getTreasuryStorage() internal pure returns (struct Treasury.TreasuryStorage $)

Retrieves the stored TreasuryStorage from its designated slot

onlyGovernanceWhenNotPaused

modifier onlyGovernanceWhenNotPaused()

Ensures that only users with governance role can perform actions when the contract is not paused

onlyAdminOrGovernance

modifier onlyAdminOrGovernance()

constructor

constructor() public

initialize

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

Parameters

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

receive() external payable

Allows the contract to receive VET directly

fallback

fallback() external payable

Fallback function to handle incoming VET when data is sent

pause

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

unpause

function unpause() external

Unpauses the Treasury contract allowing normal operations

Only admin with pauser role can unpause the contract

transferVTHO

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

Parameters

Name Type Description
_to address Recipient of the VTHO
_value uint256 Amount of VTHO to transfer

transferB3TR

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

Parameters

Name Type Description
_to address Recipient of the B3TR
_value uint256 Amount of B3TR to transfer

transferVOT3

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

Parameters

Name Type Description
_to address Recipient of the VOT3
_value uint256 Amount of VOT3 to transfer

transferVET

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

Parameters

Name Type Description
_to address Recipient of the VET
_value uint256 Amount of VET to transfer

transferTokens

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

Parameters

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

transferNFT

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

Parameters

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

transferERC1155Tokens

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

Parameters

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

convertB3TR

function convertB3TR(uint256 _b3trAmount) external

Converts a specified amount of B3TR to VOT3

Only governance can convert B3TR when the contract is not paused

Parameters

Name Type Description
_b3trAmount uint256 Amount of B3TR to convert

convertVOT3

function convertVOT3(uint256 _vot3Amount) external

Converts a specified amount of VOT3 to B3TR

Only governance can convert VOT3 when the contract is not paused

Parameters

Name Type Description
_vot3Amount uint256 Amount of VOT3 to convert

setTransferLimitVET

function setTransferLimitVET(uint256 _transferLimitVET) external

Sets the transfer limit for VET

Parameters

Name Type Description
_transferLimitVET uint256 The new transfer limit for VET

setTransferLimitToken

function setTransferLimitToken(address _token, uint256 _transferLimit) external

Sets the transfer limit for any token

Parameters

Name Type Description
_token address The token to set the transfer limit for
_transferLimit uint256

getVTHOBalance

function getVTHOBalance() external view returns (uint256)

Retrieves the balance of VTHO held by the contract

getB3TRBalance

function getB3TRBalance() external view returns (uint256)

Retrieves the balance of B3TR held by the contract

getVOT3Balance

function getVOT3Balance() external view returns (uint256)

Retrieves the balance of VOT3 held by the contract

getVETBalance

function getVETBalance() external view returns (uint256)

Retrieves the balance of VET held by the contract

getTokenBalance

function getTokenBalance(address _token) external view returns (uint256)

Retrieves the balance of any ERC20 token held by the contract

Parameters

Name Type Description
_token address The ERC20 token to check balance for

getCollectionNFTBalance

function getCollectionNFTBalance(address _nft) external view returns (uint256)

Retrieves the balance of any ERC721 token held by the contract

Parameters

Name Type Description
_nft address The ERC721 token to check balance for

getERC1155TokenBalance

function getERC1155TokenBalance(address _token, uint256 _id) external view returns (uint256)

Retrieves the balance of any ERC1155 token held by the contract

Parameters

Name Type Description
_token address The ERC1155 token to check balance for
_id uint256 The id of the ERC1155 token

version

function version() external pure virtual returns (string)

Retrieves the current version of the contract

b3trAddress

function b3trAddress() public view returns (address)

Retrieves the address of the B3TR token

vot3Address

function vot3Address() public view returns (address)

Retrieves the address of the VOT3 token

getTransferLimitVET

function getTransferLimitVET() external view returns (uint256)

getTransferLimitToken

function getTransferLimitToken(address _token) external view returns (uint256)

_getERC20Contract

function _getERC20Contract(address token) internal pure returns (contract IERC20)

Internal function to get the ERC20 contract instance

onERC721Received

function onERC721Received(address, address, uint256, bytes) external pure returns (bytes4)

See {IERC721Receiver-onERC721Received}.

onERC1155Received

function onERC1155Received(address, address, uint256, uint256, bytes) public virtual returns (bytes4)

See {IERC1155Receiver-onERC1155Received}.

Return Values

Name Type Description
[0] bytes4 bytes4 The selector of the function

onERC1155BatchReceived

function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) public virtual returns (bytes4)

See {IERC1155Receiver-onERC1155BatchReceived}.

Return Values

Name Type Description
[0] bytes4 bytes4 The selector of the function

_authorizeUpgrade

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 {}_