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

start

setupAutomationV2

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

toggleAutomation

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

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

_buyRoyalty

checkUpkeep

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

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

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

withdraw

This function is used to withdraw the funds from the royalty sale contract and should only be called by the owner

withdrawRoyalty

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

withdrawERC20Royalty

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

changeRoyaltyState

This function changes the state of the royalty sale and should only be called by the owner

changeUpdateInterval

This function is uded to change the update interval of the royalty automation

Parameters

Name
Type
Description

_updateInterval

uint256

new update interval

transferOwnership

this function is used to transfer ownership of the sale contract to a new owner and should only be called by the owner

updateNodeDetails

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

getPoolMembers

GETTERS

getPoolMemberCount

getPoolSize

getPoolBalance

getMemberPoolSize

getRoyatyTokenAddress

getRoyaltyBalance

getERC20RoyaltyBalance

getCreator

getOwner

getRoyaltyPercentage

getRoyaltyState

getTokenDetails

getTimeLeft

checkAutomation

Last updated