Token Royalty Sale
The Token Royalty Sale contract manages a token royalty sale. It allows users to deposit tokens into a royalty pool, and then distributes royalties to the members of the pool based on the percentage of the pool that they hold. The contract also has automation functionality, which can be used to automatically update the royalty balances and perform other maintenance tasks on a regular basis.
Below are some of the contract definitions and their parameters.
TokenRoyaltySaleV2
Royalty
struct Royalty {
uint256 royaltyPoolSize;
uint256 percentage;
uint256 royaltyPoolBalance;
address royaltyCPToken;
address tokenRoyaltyFactory;
address creator;
address[] royaltyPoolMembers;
string creatorsName;
string name;
}
initilize
function initilize(uint256 _royaltyPoolSize, uint256 _percentage, address _tokenRoyaltyFactory, address _creator, string _creatorsName, string _name, address _owner) external
start
function start() external
setupAutomationV2
function setupAutomationV2(uint256 _updateInterval, address _royaltyAdapter, address _oracle, string _jobId) external
this function is called by Picardy Royalty Registrar when registering automation and sets up the automation
This function is called by picardy royalty registrar, PS: royalty adapter contract needs LINK for automation to work
Parameters
_updateInterval
uint256
update interval for the automation
_royaltyAdapter
address
address of Picardy Royalty Adapter
_oracle
address
address of the oracle
_jobId
string
job id for the oracle
toggleAutomation
function toggleAutomation() external
this function is called by the contract owner to pause automation
this function can only be called by the contract owner and picardy royalty registrar
buyRoyalty
function buyRoyalty(address _holder) external payable
This function can be called by anyone and is a payable function to buy royalty token in ETH
Parameters
_holder
address
address of the royalty token holder
_buyRoyalty
function _buyRoyalty(uint256 _amount, address _holder) internal
checkUpkeep
function checkUpkeep(bytes) external view returns (bool upkeepNeeded, bytes performData)
This function is used by chainlink keepers to check if the requirements for upkeep are met
this function can only be called by chainlink keepers
performUpkeep
function performUpkeep(bytes) external
This function is used by chainlink keepers to perform upkeep if checkUpkeep() returns true
this function can be called by anyone. checkUpkeep() parameters again to avoid unautorized call.
updateRoyalty
function updateRoyalty(uint256 amount, address tokenAddress) external
This function can only be called by the royaltySale owner or payMaster contract to pay royalty in ERC20. this function can only be called by the contract owner or payMaster contract
Parameters
amount
uint256
amount of ERC20 tokens to be paid back to royalty holders
tokenAddress
address
address of the ERC20 token
withdraw
function withdraw() external
This function is used to withdraw the funds from the royalty sale contract and should only be called by the owner
withdrawRoyalty
function withdrawRoyalty(uint256 _amount, address _holder) external
This function is used to withdraw the royalty. It can only be called by the royalty token holder
Parameters
_amount
uint256
amount of royalty token to be withdrawn
_holder
address
address of the royalty token holder
withdrawERC20Royalty
function withdrawERC20Royalty(uint256 _amount, address _holder, address _tokenAddress) external
This function is used to withdraw the royalty in ERC20. It can only be called by the royalty token holder
Parameters
_amount
uint256
amount of royalty token to be withdrawn
_holder
address
address of the royalty token holder
_tokenAddress
address
changeRoyaltyState
function changeRoyaltyState() external
This function changes the state of the royalty sale and should only be called by the owner
changeUpdateInterval
function changeUpdateInterval(uint256 _updateInterval) external
This function is uded to change the update interval of the royalty automation
Parameters
_updateInterval
uint256
new update interval
transferOwnership
function transferOwnership(address newOwner) public
this function is used to transfer ownership of the sale contract to a new owner and should only be called by the owner
updateNodeDetails
function updateNodeDetails(address _oracle, string _jobId) external
This function is used to change the oracle address and jobId of the chainlink node for custom job id
this function can only be called by the contract owner. (See docs for custom automation)
Parameters
_oracle
address
new oracle address
_jobId
string
new jobId
getPoolMembers
function getPoolMembers() external view returns (address[])
GETTERS
getPoolMemberCount
function getPoolMemberCount() external view returns (uint256)
getPoolSize
function getPoolSize() external view returns (uint256)
getPoolBalance
function getPoolBalance() external view returns (uint256)
getMemberPoolSize
function getMemberPoolSize(address addr) external view returns (uint256)
getRoyatyTokenAddress
function getRoyatyTokenAddress() external view returns (address)
getRoyaltyBalance
function getRoyaltyBalance(address addr) external view returns (uint256)
getERC20RoyaltyBalance
function getERC20RoyaltyBalance(address addr, address tokenAddress) external view returns (uint256)
getCreator
function getCreator() external view returns (address)
getOwner
function getOwner() external view returns (address)
getRoyaltyPercentage
function getRoyaltyPercentage() external view returns (uint256)
getRoyaltyState
function getRoyaltyState() external view returns (uint256)
getTokenDetails
function getTokenDetails() external view returns (string, string)
getTimeLeft
function getTimeLeft() external view returns (uint256)
checkAutomation
function checkAutomation() external view returns (bool)
Last updated