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

NameTypeDescription

initAddr

address[2]

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

NameTypeDescription

protocolId

bytes32

protocol id

chainId

uint256

target chain id

consensusTargetRate

uint256

consensus target rate

transmitters

address[]

protocol transmitters

proposeAddAllowedProtocolAddress

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

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

Parameters

NameTypeDescription

protocolId

bytes32

protocol id

chainId

uint256

target chain id

protocolAddress

bytes

protocol contract address on specified chain for adding

proposeRemoveAllowedProtocolAddress

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

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

Parameters

NameTypeDescription

protocolId

bytes32

protocol id

chainId

uint256

target chain id

protocolAddress

bytes

protocol contract address on specified chain for removing

proposeAddAllowedProposerAddress

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

Make proposal to adding allowed proposer on specified chain

Parameters

NameTypeDescription

protocolId

bytes32

protocol id

chainId

uint256

target chain id

proposerAddress

bytes

proposer address on specified chain for adding

proposeRemoveAllowedProposerAddress

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

Make proposal to removing allowed proposer on specified chain

Parameters

NameTypeDescription

protocolId

bytes32

protocol id

chainId

uint256

target chain id

proposerAddress

bytes

proposer address on specified chain for removing

proposeAddExecutor

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

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

Parameters

NameTypeDescription

protocolId

bytes32

protocol id

chainId

uint256

target chain id

executor

bytes

executor address or pubkey

proposeRemoveExecutor

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

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

Parameters

NameTypeDescription

protocolId

bytes32

protocol id

chainId

uint256

target chain id

executor

bytes

executor address or pubkey

proposeAddTransmitters

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

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

Parameters

NameTypeDescription

protocolId

bytes32

protocol id

chainId

uint256

target chain id

transmitters

address[]

transmitters array of evm address to add

proposeRemoveTransmitters

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

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

Parameters

NameTypeDescription

protocolId

bytes32

protocol id

chainId

uint256

target chain id

transmitters

address[]

transmitter array of evm address to remove

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

NameTypeDescription

protocolId

bytes32

protocol id

chainId

uint256

target chain id

toAdd

address[]

transmitter array of evm addresses to add

toRemove

address[]

transmitter array of evm addresses to remove

proposeSetConsensusTargetRate

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

Make proposal to set consensus target rate

Parameters

NameTypeDescription

protocolId

bytes32

protocol id

chainId

uint256

target chain id

consensusTargetRate

uint256

consensus target rate

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

NameTypeDescription

_params

bytes

encoded params

initGovProtocol

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

Adding info about GOV protocol

Parameters

NameTypeDescription

_consensusTargetRate

uint256

rate with 10000 decimals

_transmitters

address[]

array of initial gov transmitters

addGovProtocolAddress

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

add gov contract address and executors on specified chain

Parameters

NameTypeDescription

_chainId

uint256

chain id

_govAddress

bytes

address of gov contract on specified chain

_executors

bytes[]

address of executors which will be execute operations on specified chain

addProtocol

function addProtocol(bytes32 _protocolId, uint256 _consensusTargetRate) external

Adding new protocol by id

Parameters

NameTypeDescription

_protocolId

bytes32

protocol Id (may be proto short name or number)

_consensusTargetRate

uint256

rate with 10000 decimals

setProtocolPause

function setProtocolPause(bytes32 _protocolId, bool _state) external

Pause/unpause protocol

Parameters

NameTypeDescription

_protocolId

bytes32

protocol id

_state

bool

true - pause, false - unpause

addWatcher

function addWatcher(address _watcher) internal

Adding watcher to whitelist

Parameters

NameTypeDescription

_watcher

address

address of watcher to add

removeWatcher

function removeWatcher(address _watcher) internal

Removing watcher from whitelist

Parameters

NameTypeDescription

_watcher

address

address of watcher to remove

setWatchersConsensusTargetRate

function setWatchersConsensusTargetRate(uint256 _rate) external

Removing watcher from whitelist

Parameters

NameTypeDescription

_rate

uint256

rate

addAllowedProtocolAddress

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

Adding chainId and protocol address to whitelist

Parameters

NameTypeDescription

_protocolId

bytes32

protocol id

_chainId

uint256

chainId of this address of protocol contract

_protocolAddress

bytes

protocol address of contract

removeAllowedProtocolAddress

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

Removing protocol address from whitelist for specified protocol on specified chain

Parameters

NameTypeDescription

_protocolId

bytes32

protocol id

_chainId

uint256

chain id

_protocolAddress

bytes

protocol address to remove

addAllowedProposerAddress

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

Adding proposer to whitelist for specified protocol on specified chain

Parameters

NameTypeDescription

_protocolId

bytes32

protocol id

_chainId

uint256

chain id

_proposerAddress

bytes

proposer address to add

removeAllowedProposerAddress

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

Removing proposer from whitelist for specified protocol on specified chain

Parameters

NameTypeDescription

_protocolId

bytes32

protocol id

_chainId

uint256

chain id

_proposerAddress

bytes

proposer address to remove

addExecutor

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

Adding executor to specified protocol on specified chain id

Parameters

NameTypeDescription

_protocolId

bytes32

protocol id

_chainId

uint256

target chain id

_executor

bytes

executor address or pubkey

removeExecutor

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

Removing executor to specified protocol on specified chain id

Parameters

NameTypeDescription

_protocolId

bytes32

protocol id

_chainId

uint256

target chain id

_executor

bytes

executor address or pubkey

updateTransmitters

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

Update transmitters to specified protocol

called by RoundManager and AgentManager

Parameters

NameTypeDescription

_protocolId

bytes32

protocol id

_newTransmitters

address[]

new selected transmitter's array

removeTransmitter

function removeTransmitter(bytes32 _protocolId, address _transmitter) external

Removing transmitters from whitelist called when transmitters was banned or slashed

Parameters

NameTypeDescription

_protocolId

bytes32

protocol id

_transmitter

address

address of transmitter to remove

setConsensusTargetRate

function setConsensusTargetRate(bytes32 _protocolId, uint256 _rate) external

Setting of target rate

Parameters

NameTypeDescription

_protocolId

bytes32

protocol id

_rate

uint256

target rate with 10000 decimals

getOpData

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

getter of operation data

Parameters

NameTypeDescription

opHash

uint256

operation hash id

Return Values

NameTypeDescription

[0]

struct OperationLib.OperationData

Operation Data struct

getOpSigs

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

getter of operation proofs

Parameters

NameTypeDescription

opHash

uint256

operation hash id

Return Values

NameTypeDescription

[0]

struct OperationLib.Signature[]

current array of transmitter's signatures

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

NameTypeDescription

opHashArray

uint256[]

array of operation hashes

Return Values

NameTypeDescription

resultArray

bool[]

array of bool values indicates that operation was approved or not

checkOperationsExecuteStatus

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

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

Parameters

NameTypeDescription

opHashArray

uint256[]

array of operation hashes

Return Values

NameTypeDescription

resultArray

bool[]

array of bool values indicates that operation was executed or not

checkOperationSignature

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

recover and check transmitter's signature

Parameters

NameTypeDescription

transmitter

address

transmitter's address

opHash

bytes32

hash of signer data

sig

struct OperationLib.Signature

transmitter's signature

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

NameTypeDescription

opData

struct OperationLib.OperationData

operation data

sig

struct OperationLib.Signature

transmitter's signature

approveOperationExecuting

function approveOperationExecuting(uint256 opHash) external

approve operation was executed

Parameters

NameTypeDescription

opHash

uint256

1

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