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.
struct Royalty {
uint256 royaltyPoolSize;
uint256 percentage;
uint256 royaltyPoolBalance;
address royaltyCPToken;
address tokenRoyaltyFactory;
address creator;
address[] royaltyPoolMembers;
string creatorsName;
string name;
}
function initilize(uint256 _royaltyPoolSize, uint256 _percentage, address _tokenRoyaltyFactory, address _creator, string _creatorsName, string _name, address _owner) external
function start() external
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
Name | Type | Description |
---|---|---|
_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 |
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
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
Name | Type | Description |
---|---|---|
_holder | address | address of the royalty token holder |
function _buyRoyalty(uint256 _amount, address _holder) internal
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
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.
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
Name | Type | Description |
---|---|---|
amount | uint256 | amount of ERC20 tokens to be paid back to royalty holders |
tokenAddress | address | address of the ERC20 token |
function withdraw() external
This function is used to withdraw the funds from the royalty sale contract and should only be called by the owner
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
Name | Type | Description |
---|---|---|
_amount | uint256 | amount of royalty token to be withdrawn |
_holder | address | address of the royalty token holder |
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
Name | Type | Description |
---|---|---|
_amount | uint256 | amount of royalty token to be withdrawn |
_holder | address | address of the royalty token holder |
_tokenAddress | address | |
function changeRoyaltyState() external
This function changes the state of the royalty sale and should only be called by the owner
function changeUpdateInterval(uint256 _updateInterval) external
This function is uded to change the update interval of the royalty automation
Parameters
Name | Type | Description |
---|---|---|
_updateInterval | uint256 | new update interval |
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
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
Name | Type | Description |
---|---|---|
_oracle | address | new oracle address |
_jobId | string | new jobId |
function getPoolMembers() external view returns (address[])
GETTERS
function getPoolMemberCount() external view returns (uint256)
function getPoolSize() external view returns (uint256)
function getPoolBalance() external view returns (uint256)
function getMemberPoolSize(address addr) external view returns (uint256)
function getRoyatyTokenAddress() external view returns (address)
function getRoyaltyBalance(address addr) external view returns (uint256)
function getERC20RoyaltyBalance(address addr, address tokenAddress) external view returns (uint256)
function getCreator() external view returns (address)
function getOwner() external view returns (address)
function getRoyaltyPercentage() external view returns (uint256)
function getRoyaltyState() external view returns (uint256)
function getTokenDetails() external view returns (string, string)
function getTimeLeft() external view returns (uint256)
function checkAutomation() external view returns (bool)
Last modified 1mo ago