Master Smart Contract

Master Smart Contract is a contract which should collect operations from transmitters with those signatures. Also it has gov functions which can administrate protocols:

  • allow new protocol

  • add/remove protocol address to interact on specified chain

  • add/remove proposer address on specified chain wich can proposing new operations due EndPoint.propose() function.

  • update transmitters on protocol

  • add/remove executors on specified chain

  • set consensus target rate

MasterSmartContract__GovProtocolAlreadyInited

error MasterSmartContract__GovProtocolAlreadyInited()

MasterSmartContract__GovProtocolIsNotInited

error MasterSmartContract__GovProtocolIsNotInited()

MasterSmartContract__InvalidProtocolId

error MasterSmartContract__InvalidProtocolId(bytes32)

MasterSmartContract__ForbiddenOperationWithGovProtocol

error MasterSmartContract__ForbiddenOperationWithGovProtocol()

MasterSmartContract__DaoIsNotAllowedOnSpecifiedChain

error MasterSmartContract__DaoIsNotAllowedOnSpecifiedChain(uint256)

MasterSmartContract__ProtocolIsNotInited

error MasterSmartContract__ProtocolIsNotInited(bytes32)

MasterSmartContract__ProtocolIsNotInitedOnChain

error MasterSmartContract__ProtocolIsNotInitedOnChain(bytes32, uint256)

MasterSmartContract__ProtocolAlreadyAdded

error MasterSmartContract__ProtocolAlreadyAdded(bytes32)

MasterSmartContract__ProtocolIsNotAllowed

error MasterSmartContract__ProtocolIsNotAllowed(bytes32)

MasterSmartContract__ProtocolAddressAlreadyExist

error MasterSmartContract__ProtocolAddressAlreadyExist(bytes32, bytes)

MasterSmartContract__TransmitterIsAlreadyAdded

error MasterSmartContract__TransmitterIsAlreadyAdded(bytes32, address)

MasterSmartContract__TransmitterIsNotAllowed

error MasterSmartContract__TransmitterIsNotAllowed(bytes32, address)

MasterSmartContract__WatcherIsNotAllowed

error MasterSmartContract__WatcherIsNotAllowed(address)

MasterSmartContract__OperationIsAlreadyApproved

error MasterSmartContract__OperationIsAlreadyApproved(uint256)

MasterSmartContract__TransmitterIsAlreadyApproved

error MasterSmartContract__TransmitterIsAlreadyApproved(address, uint256)

MasterSmartContract__WatcherIsAlreadyApproved

error MasterSmartContract__WatcherIsAlreadyApproved(address, uint256)

MasterSmartContract__OperationDoesNotExist

error MasterSmartContract__OperationDoesNotExist(uint256)

MasterSmartContract__OpIsNotApproved

error MasterSmartContract__OpIsNotApproved(uint256)

MasterSmartContract__OpExecutionAlreadyApproved

error MasterSmartContract__OpExecutionAlreadyApproved(uint256)

MasterSmartContract__SignatureCheckFailed

error MasterSmartContract__SignatureCheckFailed(uint256, address)

MasterSmartContract__ProtocolIsPaused

error MasterSmartContract__ProtocolIsPaused(bytes32)

MasterSmartContract__AddrTooBig

error MasterSmartContract__AddrTooBig(bytes32)

MasterSmartContract__SelectorTooBig

error MasterSmartContract__SelectorTooBig(bytes32)

MasterSmartContract__ParamsTooBig

error MasterSmartContract__ParamsTooBig(bytes32)

AddAllowedProtocol

event AddAllowedProtocol(bytes32 protocolId, uint256 consensusTargetRate)

SetProtocolPause

event SetProtocolPause(bytes32 protocolId, bool state)

AddAllowedProtocolAddress

event AddAllowedProtocolAddress(bytes32 protocolId, uint256 chainId, bytes protocolAddress)

RemoveAllowedProtocolAddress

event RemoveAllowedProtocolAddress(bytes32 protocolId, uint256 chainId, bytes protocolAddress)

AddAllowedProposerAddress

event AddAllowedProposerAddress(bytes32 protocolId, uint256 chainId, bytes proposerAddress)

RemoveAllowedProposerAddress

event RemoveAllowedProposerAddress(bytes32 protocolId, uint256 chainId, bytes proposerAddress)

UpdateTransmitters

event UpdateTransmitters(bytes32 protocolId, address[] toAdd, address[] toRemove)

RemoveTransmitter

event RemoveTransmitter(bytes32 protocolId, address transmitter)

AddExecutor

event AddExecutor(bytes32 protocolId, uint256 chainId, bytes executor)

RemoveExecutor

event RemoveExecutor(bytes32 protocolId, uint256 chainId, bytes executor)

SetConsensusTargetRate

event SetConsensusTargetRate(bytes32 protocolId, uint256 rate)

NewOperation

event NewOperation(uint256 opHash, bytes protocol, bytes functionSelector)

NewProof

event NewProof(uint256 opHash, address transmitter)

ProposalApproved

event ProposalApproved(uint256 opHash)

ProposalExecuted

event ProposalExecuted(uint256 opHash)

ADMIN

bytes32 ADMIN

SPOTTER

bytes32 SPOTTER

STAKING_CONTRACTS

bytes32 STAKING_CONTRACTS

govProtocolId

bytes32 govProtocolId

InitOnChainStages

enum InitOnChainStages {
  NotInited,
  OnInition,
  Inited
}

InitOnChainInfo

struct InitOnChainInfo {
  enum MasterSmartContract.InitOnChainStages stage;
  bytes[] queuedProtocolAddresses;
  bytes[] queuedProposerAddresses;
  address[] queuedTransmitters;
}

AllowedProtocolInfo

struct AllowedProtocolInfo {
  bool isInit;
  bool isPaused;
  uint256 numberOfAllowedTransmitters;
  uint256 consensusTargetRate;
  uint256[] chainIds;
  address[] transmittersArr;
  mapping(uint256 => struct MasterSmartContract.InitOnChainInfo) initOnChainInfo;
}

isInit

bool isInit

allowedTransmitters

mapping(bytes32 => mapping(address => bool)) allowedTransmitters

allowedTransmitters map of allowed transmitters which can work with this protocol

allowedExecutors

mapping(bytes32 => mapping(uint256 => mapping(bytes => bool))) allowedExecutors

allowedExecutors map of allowed executors addresses which can execute operations on specified protocol on specified chain

allowedProposers

mapping(bytes32 => mapping(uint256 => mapping(bytes => bool))) allowedProposers

allowedProposers map of allowed proposers addresses which can propose operations on specified protocol on specified chain

operations

mapping(uint256 => struct OperationLib.Operation) operations

map with operations, key: opHash is a uint256(keccak256(OperationData operationData)), value - Operation which need to validate and execute

allowedProtocolInfo

mapping(bytes32 => struct MasterSmartContract.AllowedProtocolInfo) allowedProtocolInfo

map with allowed protocols info

protocolAddressToProtocolId

mapping(uint256 => mapping(bytes => bytes32)) protocolAddressToProtocolId

map to associate specified protocol contract on specified chain id with protocol id

govContractAddresses

mapping(uint256 => bytes) govContractAddresses

map of gov contract addresses on other chains

rateDecimals

uint256 rateDecimals

10000 = 100%

allowedWatchers

mapping(address => bool) allowedWatchers

watcher wich should approve operation execution

numberOfAllowedWatchers

uint256 numberOfAllowedWatchers

number of allowed watchers

watchersConsensusTargetRate

uint256 watchersConsensusTargetRate

watchers consensus target rate

endPoint

contract IProposer endPoint

proposer contract

betManager

contract BetManager betManager

transmitters bet manager

externalDeveloperHub

contract ExternalDeveloperHub externalDeveloperHub

externalDeveloper manager

lastExecutedOpNonceInOrder

mapping(bytes32 => mapping(uint256 => uint256)) lastExecutedOpNonceInOrder

last executed ordered operation nonce for specified protocol on specified chain

used for ordered operations to notify executors about last executed operation nonce

_isAllowedTransmitterInternal

function _isAllowedTransmitterInternal(uint256 _chainId, bytes _protocolAddr) internal view

END of VARS *

isAllowedTransmitter

modifier isAllowedTransmitter(uint256 _chainId, bytes _protocolAddr)

_isAllowedWatcherInternal

function _isAllowedWatcherInternal(address _watcher) internal view

isAllowedWatcher

modifier isAllowedWatcher(address _watcher)

_isAllowedProtocolInternal

function _isAllowedProtocolInternal(uint256 _chainId, bytes _protocolAddr) internal view

isAllowedProtocol

modifier isAllowedProtocol(uint256 _chainId, bytes _protocolAddr)

__chainId

function __chainId() internal view returns (uint256 id)

initialize

function initialize(address[2] initAddr) external

Initialize

Parameters

setContracts

function setContracts(address[4] initAddr) external

Set contracts addresses

_authorizeUpgrade

function _authorizeUpgrade(address) internal

getSelector

function getSelector(bytes _func) internal pure returns (bytes4)

proposeAddAllowedProtocol

function proposeAddAllowedProtocol(bytes32 protocolId, uint256 chainId, uint256 consensusTargetRate, address[] transmitters) internal

Make proposal to adding allowed protocol to endPoint on specified chain

Parameters

proposeAddAllowedProtocolAddress

function proposeAddAllowedProtocolAddress(bytes32 protocolId, uint256 chainId, bytes protocolAddress) internal

Make proposal to adding allowed protocol contract address to endPoint on specified chain

Parameters

proposeRemoveAllowedProtocolAddress

function proposeRemoveAllowedProtocolAddress(bytes32 protocolId, uint256 chainId, bytes protocolAddress) internal

Make proposal to removing allowed protocol contract address from endPoint on specified chain

Parameters

proposeAddAllowedProposerAddress

function proposeAddAllowedProposerAddress(bytes32 protocolId, uint256 chainId, bytes proposerAddress) internal

Make proposal to adding allowed proposer on specified chain

Parameters

proposeRemoveAllowedProposerAddress

function proposeRemoveAllowedProposerAddress(bytes32 protocolId, uint256 chainId, bytes proposerAddress) internal

Make proposal to removing allowed proposer on specified chain

Parameters

proposeAddExecutor

function proposeAddExecutor(bytes32 protocolId, uint256 chainId, bytes executor) internal

Make proposal to adding allowed executor to specified protocol on specified chain

Parameters

proposeRemoveExecutor

function proposeRemoveExecutor(bytes32 protocolId, uint256 chainId, bytes executor) internal

Make proposal to removing allowed executor to specified protocol on specified chain

Parameters

proposeAddTransmitters

function proposeAddTransmitters(bytes32 protocolId, uint256 chainId, address[] transmitters) internal

Make proposal to adding allowed transmitter to specified protocol on specified chain

Parameters

proposeRemoveTransmitters

function proposeRemoveTransmitters(bytes32 protocolId, uint256 chainId, address[] transmitters) internal

Make proposal to removing allowed transmitter to specified protocol on specified chain

Parameters

proposeUpdateTransmitters

function proposeUpdateTransmitters(bytes32 protocolId, uint256 chainId, address[] toAdd, address[] toRemove) internal

Make proposal to update allowed transmitter to specified protocol on specified chain

Parameters

proposeSetConsensusTargetRate

function proposeSetConsensusTargetRate(bytes32 protocolId, uint256 chainId, uint256 consensusTargetRate) internal

Make proposal to set consensus target rate

Parameters

handleAddAllowedProtocol

function handleAddAllowedProtocol(bytes _params) external

Callback function for handle 2nd step of protocol inition on specified chain.

called by EndPoint from specified chain, after addAllowedProtocol processing

Parameters

initGovProtocol

function initGovProtocol(uint256 _consensusTargetRate, address[] _transmitters) external

Adding info about GOV protocol

Parameters

addGovProtocolAddress

function addGovProtocolAddress(uint256 _chainId, bytes _govAddress, bytes[] _executors) external

add gov contract address and executors on specified chain

Parameters

addProtocol

function addProtocol(bytes32 _protocolId, uint256 _consensusTargetRate) external

Adding new protocol by id

Parameters

setProtocolPause

function setProtocolPause(bytes32 _protocolId, bool _state) external

Pause/unpause protocol

Parameters

addWatcher

function addWatcher(address _watcher) internal

Adding watcher to whitelist

Parameters

removeWatcher

function removeWatcher(address _watcher) internal

Removing watcher from whitelist

Parameters

setWatchersConsensusTargetRate

function setWatchersConsensusTargetRate(uint256 _rate) external

Removing watcher from whitelist

Parameters

addAllowedProtocolAddress

function addAllowedProtocolAddress(bytes32 _protocolId, uint256 _chainId, bytes _protocolAddress) external

Adding chainId and protocol address to whitelist

Parameters

removeAllowedProtocolAddress

function removeAllowedProtocolAddress(bytes32 _protocolId, uint256 _chainId, bytes _protocolAddress) external

Removing protocol address from whitelist for specified protocol on specified chain

Parameters

addAllowedProposerAddress

function addAllowedProposerAddress(bytes32 _protocolId, uint256 _chainId, bytes _proposerAddress) external

Adding proposer to whitelist for specified protocol on specified chain

Parameters

removeAllowedProposerAddress

function removeAllowedProposerAddress(bytes32 _protocolId, uint256 _chainId, bytes _proposerAddress) external

Removing proposer from whitelist for specified protocol on specified chain

Parameters

addExecutor

function addExecutor(bytes32 _protocolId, uint256 _chainId, bytes _executor) external

Adding executor to specified protocol on specified chain id

Parameters

removeExecutor

function removeExecutor(bytes32 _protocolId, uint256 _chainId, bytes _executor) external

Removing executor to specified protocol on specified chain id

Parameters

updateTransmitters

function updateTransmitters(bytes32 _protocolId, address[] _newTransmitters) external

Update transmitters to specified protocol

called by RoundManager and AgentManager

Parameters

removeTransmitter

function removeTransmitter(bytes32 _protocolId, address _transmitter) external

Removing transmitters from whitelist called when transmitters was banned or slashed

Parameters

setConsensusTargetRate

function setConsensusTargetRate(bytes32 _protocolId, uint256 _rate) external

Setting of target rate

Parameters

getOpData

function getOpData(uint256 opHash) public view returns (struct OperationLib.OperationData)

getter of operation data

Parameters

Return Values

getOpSigs

function getOpSigs(uint256 opHash) public view returns (struct OperationLib.Signature[])

getter of operation proofs

Parameters

Return Values

getProtocolInitStateOnChain

function getProtocolInitStateOnChain(bytes32 protocolId, uint256 chainId) external view returns (enum MasterSmartContract.InitOnChainStages)

checkOperationsApproveStatus

function checkOperationsApproveStatus(uint256[] opHashArray) external view returns (bool[] resultArray)

Get array of opHashes, check it was approved and returns array of result

Parameters

Return Values

checkOperationsExecuteStatus

function checkOperationsExecuteStatus(uint256[] opHashArray) external view returns (bool[] resultArray)

Get array of opHashes, check it was executed and returns array of result

Parameters

Return Values

checkOperationSignature

function checkOperationSignature(address transmitter, bytes32 opHash, struct OperationLib.Signature sig) internal pure returns (bool)

recover and check transmitter's signature

Parameters

proposeOperation

function proposeOperation(struct OperationLib.OperationData opData, struct OperationLib.Signature sig) external

proposing an operation/approve an operation/give an operation of status approved

0xe1b3d28a

Parameters

approveOperationExecuting

function approveOperationExecuting(uint256 opHash) external

approve operation was executed

Parameters

isPaused

function isPaused(bytes32 protocolId) external view returns (bool)

isInited

function isInited(bytes32 protocolId, uint256 chainId) external view returns (bool)

getTransmitters

function getTransmitters(bytes32 protocolId) external view returns (address[])

Last updated