RoyaltyPayoutHelper

Git Source

Inherits: TransferHelper, SanctionsCompliance

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

weth

address public weth;

royaltyEngine

IRoyaltyEngineV1 public royaltyEngine;

Functions

constructor

constructor(address sanctionsOracle, address wethAddress, address royaltyEngineAddress)
    SanctionsCompliance(sanctionsOracle);

Parameters

NameTypeDescription
sanctionsOracleaddress- the init sanctions oracle
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