Skip to main content

Mate2MarketSettlement.sol

Mate2MarketSettlement

DEFAULT_UPKEEP_GAS_LIMIT

uint32 DEFAULT_UPKEEP_GAS_LIMIT

factory

contract IChromaticMarketFactory factory

automate

contract IMate2AutomationRegistry1_1 automate

upkeepGasLimit

uint32 upkeepGasLimit

marketSettlementUpkeepIds

mapping(address => uint256) marketSettlementUpkeepIds

UpkeepGasLimitUpdated

event UpkeepGasLimitUpdated(uint32 gasLimitOld, uint32 gasLimitNew)

OnlyAccessableByDao

error OnlyAccessableByDao()

Throws an error indicating that the caller is not the DAO.

OnlyAccessableByFactoryOrDao

error OnlyAccessableByFactoryOrDao()

Throws an error indicating that the caller is neither the chromatic factory contract nor the DAO.

ExistMarketSettlementTask

error ExistMarketSettlementTask()

Throws an error indicating that a market settlement task already exists.

InsufficientKeeperFee

error InsufficientKeeperFee()

Throws an error indicating that the keeper fee is insufficient

PayKeeperFeeFailed

error PayKeeperFeeFailed()

Throws an error indicating that the payment of the keeper fee has failed.

EthTransferFailed

error EthTransferFailed()

Throws an error indicating that the transfer of Ether has failed.

onlyDao

modifier onlyDao()

Modifier to restrict access to only the DAO. Throws an OnlyAccessableByDao error if the caller is not the DAO.

onlyFactoryOrDao

modifier onlyFactoryOrDao()

Modifier to restrict access to only the factory or the DAO. Throws an OnlyAccessableByFactoryOrDao error if the caller is neither the chromatic factory contract nor the DAO.

constructor

constructor(contract IChromaticMarketFactory _factory, address _automate) public

checkUpkeep

function checkUpkeep(bytes checkData, bytes extraData) external view returns (bool upkeepNeeded, bytes performData)

method that is simulated by the keepers to see if any work actually needs to be performed. This method does does not actually need to be executable, and since it is only ever simulated it can consume lots of gas.

To ensure that it is never called, you may want to add the cannotExecute modifier from KeeperBase to your implementation of this method.

  • Parameters:

    NameTypeDescription
    checkDatabytesspecified in the upkeep registration so it is always the same for a registered upkeep. This can easily be broken down into specific arguments using abi.decode, so multiple upkeeps can be registered on the same contract and easily differentiated by the contract.
    extraDatabytespassed by keeper for passing offchain data
  • Return Values:

    NameTypeDescription
    upkeepNeededboolboolean to indicate whether the keeper should call performUpkeep or not.
    performDatabytesbytes that the keeper should call performUpkeep with, if upkeep is needed. If you would like to encode data to decode later, try abi.encode.

performUpkeep

function performUpkeep(bytes performData) external

method that is actually executed by the keepers, via the registry. The data returned by the checkUpkeep simulation will be passed into this method to actually be executed.

The input to this method should not be trusted, and the caller of the method should not even be restricted to any single registry. Anyone should be able call it, and the input should be validated, there is no guarantee that the data passed in is the performData returned from checkUpkeep. This could happen due to malicious keepers, racing keepers, or simply a state change while the performUpkeep transaction is waiting for confirmation. Always validate the data passed in.

  • Parameters:

    NameTypeDescription
    performDatabytesis the data which was passed back from the checkData simulation. If it is encoded, it can easily be decoded into other types by calling abi.decode. This data should not be trusted, and should be validated against the contract's current state.

createSettlementTask

function createSettlementTask(address market) external

Creates a settlement task for a given market.

This function can only be called by the Chromatic factory contract or the DAO. Throws an ExistMarketSettlementTask error if a market earning distribution task already exists for the market.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the chromatic market contract to be settled.

cancelSettlementTask

function cancelSettlementTask(address market) external

Cancels a settlement task for a given market.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the chromatic market contract for which to cancel the settlement task.

resolveSettlement

function resolveSettlement(address market, bytes extraData) public view returns (bool canExec, bytes execPayload)

Resolves the settlement of a market.

This function is called by the automation system.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the market contract.
    extraDatabytespassed by keeper for passing offchain data
  • Return Values:

    NameTypeDescription
    canExecboolWhether the settlement can be executed.
    execPayloadbytesThe encoded function call to execute the settlement.

settle

function settle(address market) public

Settles a market.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the market contract.

balanceOfUpkeepTreasury

function balanceOfUpkeepTreasury() external view returns (uint256)

withdrawUpkeepTreasuryFunds

function withdrawUpkeepTreasuryFunds(address payable _receiver, uint256 _amount) external

cancelUpkeep

function cancelUpkeep(uint256 upkeepId) external

updateUpkeepGasLimit

function updateUpkeepGasLimit(uint32 gasLimit) external

updatePrice

function updatePrice(address market, bytes extraData) public

Updates the price using off-chain data.

  • Parameters:

    NameTypeDescription
    marketaddressThe address of the market contract.
    extraDatabytespassed by keeper for passing offchain data

receive

receive() external payable

Fallback function to receive ETH payments.

fallback

fallback() external payable

Fallback function to receive ETH payments.

withdraw

function withdraw(address recipient, uint256 amount) external

Withdraws a specified amount of funds from the contract to a recipient address.

  • Parameters:

    NameTypeDescription
    recipientaddressThe address that will receive the withdrawn funds.
    amountuint256The amount of funds to be withdrawn.