RoyaltyPayoutHelperUpgradeable

Git Source

Inherits: SanctionsComplianceUpgradeable, TransferHelper

Author: transientlabs.xyz

Abstract contract to help payout royalties using the Royalty Registry

Does not manage updating the sanctions oracle and expects the child contract to implement

State Variables

RoyaltyPayoutHelperStorageLocation

bytes32 private constant RoyaltyPayoutHelperStorageLocation =
    0x9ab1d1ca9bfa2c669468b724939724262b3f2887db3df18c90168701d6422700;

Functions

_getRoyaltyPayoutHelperStorage

function _getRoyaltyPayoutHelperStorage() private pure returns (RoyaltyPayoutHelperStorage storage $);

__RoyaltyPayoutHelper_init

Function to initialize the contract

function __RoyaltyPayoutHelper_init(address sanctionsOracle, address wethAddress, address royaltyEngineAddress)
    internal
    onlyInitializing;

Parameters

NameTypeDescription
sanctionsOracleaddress- the init sanctions oracle
wethAddressaddress- the init weth address
royaltyEngineAddressaddress- the init royalty engine address

__RoyaltyPayoutHelper_init_unchained

unchained function to initialize the contract

function __RoyaltyPayoutHelper_init_unchained(address wethAddress, address royaltyEngineAddress)
    internal
    onlyInitializing;

Parameters

NameTypeDescription
wethAddressaddress- the init weth address
royaltyEngineAddressaddress- the init royalty engine address

_setWethAddress

Function to update the WETH address

Care should be taken to ensure proper access control for this function

function _setWethAddress(address wethAddress) internal;

Parameters

NameTypeDescription
wethAddressaddressThe new WETH token address

_setRoyaltyEngineAddress

Function to update the royalty engine address

Care should be taken to ensure proper access control for this function

function _setRoyaltyEngineAddress(address royaltyEngineAddress) internal;

Parameters

NameTypeDescription
royaltyEngineAddressaddressThe new royalty engine address

_payoutRoyalties

Function to payout royalties from the contract balance based on sale price

if the call to the royalty engine reverts or if the return values are invalid, no payments are made

if the sum of the royalty payouts is greater than the salePrice, the loop exits early for gas savings (this shouldn't happen in reality)

if this is used in a call where tokens should be transferred from a sender, it is advisable to first transfer the required amount to the contract and then call this function, as it will save on gas

function _payoutRoyalties(address token, uint256 tokenId, address currency, uint256 salePrice)
    internal
    returns (uint256 remainingSale);

Parameters

NameTypeDescription
tokenaddressThe contract address for the token
tokenIduint256The token id
currencyaddressThe address of the currency to send to recipients (null address == ETH)
salePriceuint256The sale price for the token

Returns

NameTypeDescription
remainingSaleuint256The amount left over in the sale after paying out royalties

weth

Function to get the current WETH address

function weth() public view returns (address);

royaltyEngine

Function to get the royalty registry

function royaltyEngine() public view returns (IRoyaltyEngineV1);

Structs

RoyaltyPayoutHelperStorage

struct RoyaltyPayoutHelperStorage {
    address weth;
    IRoyaltyEngineV1 royaltyEngine;
}