Contracts API

ContractRegistry

Inherits from Multicall, ContractMeta
⛽ 1.82M

Functions

constructor

function constructor(address _governance) public

addresses

function addresses() external returns (address[])
Addresses of the registered contracts

names

function names() external returns (string[] result)
Names of the registered contracts

versions

function versions(string name_) external returns (string[] result)
All versions of the contract
Parameters:
Name
Type
Description
name
string
Name of the contract

versionAddress

function versionAddress(string name_, string version) external returns (address)
Address of the contract at a given version
Parameters:
Name
Type
Description
name
string
Name of the contract
version
string
Version of the contract

latestVersion

function latestVersion(string name_) external returns (string, address)
Latest version of the contract
Parameters:
Name
Type
Description
name
string
Name of the contract

registerContract

⛽ 258K (254K - 260K)
function registerContract(address target) external
Register a new contract
Parameters:
Name
Type
Description
target
address
Address of the contract to be registered
Specs
  • ✅ registers IContractMeta compatible contract and updates respective view methods - #addresses - #versions - #names - #latestVersion - #versionAddress
Access control
  • ✅ allowed: operator (deployer)
  • ✅ denied with FRB: random address
  • ✅ allowed: protocol admin
Edge cases
  • ✅ when new contract major version differs more, than on one reverts with INVA
  • ✅ when new contract version lower or equal existing one reverts with INVA
  • ✅ when contract has invalid version reverts with INVA
  • ✅ when contract name is not alphanumeric reverts with INV
  • ✅ when address is already registered reverts with DUP

Events

ContractRegistered

event ContractRegistered(address origin, address sender, bytes32 name, bytes32 version, address target)

ProtocolGovernance

⛽ 4.68M
Governance that manages all params common for Mellow Permissionless Vaults protocol.

Functions

constructor

function constructor(address admin) public
Creates a new contract
Parameters:
Name
Type
Description
admin
address
Initial admin of the contract
Specs
  • ✅ deploys a new contract

stagedParams

function stagedParams() public returns (struct IProtocolGovernance.Params)
Staged pending protocol parameters.
Specs
  • ✅ imestamp timestamp equals #stageParams's block.timestamp + governanceDelay
  • ✅ imestamp clears by #commitParams
  • ✅ imestamp edge cases when nothing is set returns zero
  • ✅ imestamp access control allowed: any address
Access control
  • ✅ allowed: any address
Properties
  • ✅ updates by #stageParams
  • ✅ clears by #commitParams

params

function params() public returns (struct IProtocolGovernance.Params)
Current protocol parameters.

stagedValidatorsAddresses

function stagedValidatorsAddresses() external returns (address[])

validatorsAddresses

function validatorsAddresses() external returns (address[])
Addresses that has validators.

validatorsAddress

function validatorsAddress(uint256 i) external returns (address)
Address that has validators.
Parameters:
Name
Type
Description
i
uint256
The number of address
Return Values:
Name
Type
Description
Validator
address
address
Specs
  • ✅ returns correct value
  • ✅ s properties @property: updates when committed validator grant for a new address
  • ✅ s properties @property: doesn't update when committed validator grant for an existing address
  • ✅ s access control allowed: any address

permissionAddresses

function permissionAddresses() external returns (address[])
Addresses for which non-zero permissions are set.

stagedPermissionGrantsAddresses

function stagedPermissionGrantsAddresses() external returns (address[])
Permission addresses staged for commit.

addressesByPermission

function addressesByPermission(uint8 permissionId) external returns (address[] addresses)
Return all addresses where rawPermissionMask bit for permissionId is set to 1.
Parameters:
Name
Type
Description
permissionId
uint8
Id of the permission to check.
Return Values:
Name
Type
Description
A
address[]
list of dirty addresses.
Specs
  • ✅ returns addresses that has the given permission set to true
Access control
  • ✅ allowed: any address
Properties
  • ✅ updates by #stagePermissionGrants + #commitPermissionGrants or #revokePermissions
  • ✅ is not affected by forceAllowMask
  • ✅ returns empty array on unknown permissionId

hasPermission

function hasPermission(address target, uint8 permissionId) external returns (bool)
Checks if address has permission or given permission is force allowed for any address.
Parameters:
Name
Type
Description
addr
address
Address to check
permissionId
uint8
Permission to check

hasAllPermissions

function hasAllPermissions(address target, uint8[] permissionIds) external returns (bool)
Checks if address has all permissions.
Parameters:
Name
Type
Description
target
address
Address to check
permissionIds
uint8[]
A list of permissions to check
Specs
  • ✅ checks if an address has all permissions set to true
Access control
  • ✅ allowed: any address
Properties
  • ✅ returns false on random address
  • ✅ is not affected by staged permissions
  • ✅ is affected by committed permissions
  • ✅ returns true for any address when forceAllowMask is set to true
Edge cases
  • ✅ on unknown permission id returns false

maxTokensPerVault

function maxTokensPerVault() external returns (uint256)
Max different ERC20 token addresses that could be managed by the protocol.
Specs
  • ✅ returns correct value

governanceDelay

function governanceDelay() external returns (uint256)
The delay for committing any governance params.
Specs
  • ✅ returns correct value

protocolTreasury

function protocolTreasury() external returns (address)
The address of the protocol treasury.
Specs
  • ✅ returns correct value

forceAllowMask

function forceAllowMask() external returns (uint256)
Permissions mask which defines if ordinary permission should be reverted. This bitmask is xored with ordinary mask.
Specs
  • ✅ returns correct value

withdrawLimit

function withdrawLimit(address token) external returns (uint256)
Withdraw limit per token per block.
Parameters:
Name
Type
Description
token
address
Address of the token
Return Values:
Name
Type
Description
Withdraw
uint256
limit per token per block
Specs
  • ✅ returns correct value

supportsInterface

function supportsInterface(bytes4 interfaceId) public returns (bool)
Specs
  • ✅ returns true for IProtocolGovernance interface (0xca11fe03)
  • ✅ access control: allowed: any address
  • ✅ edge cases: when contract does not support the given interface returns false

stageValidator

⛽ 129K (43K - 142K)
function stageValidator(address target, address validator) external
Stages a new validator for the given address
Parameters:
Name
Type
Description
target
address
The given address
validator
address
The validator for the given address
Specs
  • ✅ emits ValidatorStaged event
Access control
  • ✅ allowed: admin
  • ✅ denied: deployer
  • ✅ denied: random address
Edge cases
  • ✅ when attempting to stage grant to zero address reverts with AZ when target has zero address
  • ✅ when attempting to stage grant to zero address reverts with AZ when validator has zero address

rollbackStagedValidators

⛽ 39K (28K - 42K)
function rollbackStagedValidators() external
Rollback all staged validators.
Specs
  • ✅ rolls back all staged validators
  • ✅ emits AllStagedValidatorsRolledBack event
Access control
  • ✅ allowed: admin
  • ✅ denied: deployer
  • ✅ denied: random address

commitValidator

⛽ 86K (47K - 117K)
function commitValidator(address stagedAddress) external
Commits validator for the given address.
📕 Reverts if governance delay has not passed yet.
Parameters:
Name
Type
Description
target
address
The given address.
Specs
  • ✅ commits staged validators
  • ✅ emits ValidatorCommitted event
Access control
  • ✅ allowed: admin
  • ✅ denied: deployer
  • ✅ denied: random address
Edge cases
  • ✅ when attempting to commit validator for zero address reverts with NULL
  • ✅ when nothing is staged for the given address reverts with NULL
  • ✅ when attempting to commit validator too early reverts with TS

commitAllValidatorsSurpassedDelay

⛽ 132K (27K - 463K)
function commitAllValidatorsSurpassedDelay() external returns (address[] addressesCommitted)
Commites all staged validators for which governance delay passed
Return Values:
Name
Type
Description
Addresses
address[]
for which validators were committed
Specs
  • ✅ emits ValidatorCommitted event
Access control
  • ✅ allowed: admin
  • ✅ denied: deployer
  • ✅ denied: random address
Properties
  • ✅ commits all staged validators
  • ✅ commits all staged validators after delay
Edge cases
  • ✅ when attempting to commit a single validator too early does not commit validator
  • ✅ when attempting to commit multiple validators too early does not commit these validators

revokeValidator

⛽ 38K
function revokeValidator(address target) external
Revoke validator instantly from the given address.
Parameters:
Name
Type
Description
target
address
The given address
Specs
  • ✅ emits ValidatorRevoked event
Edge cases
  • ✅ when attempting to revoke from zero address reverts with NULL

rollbackStagedPermissionGrants

⛽ 37K (28K - 42K)
function rollbackStagedPermissionGrants() external
Rollback all staged granted permission grant.
Specs
  • ✅ rolls back all staged permission grants
  • ✅ emits AllStagedPermissionGrantsRolledBack event
Access control
  • ✅ allowed: admin
  • ✅ denied: deployer
  • ✅ denied: random address

commitPermissionGrants

⛽ 71K (46K - 117K)
function commitPermissionGrants(address stagedAddress) external
Commits permission grants for the given address.
📕 Reverts if governance delay has not passed yet.
Parameters:
Name
Type
Description
target
address
The given address.
Specs
  • ✅ commits staged permission grants
  • ✅ emits PermissionGrantsCommitted event
Access control
  • ✅ allowed: admin
  • ✅ denied: deployer
  • ✅ denied: random address
Edge cases
  • ✅ when attempting to commit permissions for zero address reverts with NULL
  • ✅ when nothing is staged for the given address reverts with NULL
  • ✅ when attempting to commit permissions too early reverts with TS

commitAllPermissionGrantsSurpassedDelay

⛽ 154K (27K - 386K)
function commitAllPermissionGrantsSurpassedDelay() external returns (address[] addresses)
Commites all staged permission grants for which governance delay passed.
Return Values:
Name
Type
Description
An
address[]
array of addresses for which permission grants were committed.
Specs
  • ✅ emits PermissionGrantsCommitted event
Access control
  • ✅ allowed: admin
  • ✅ denied: deployer
  • ✅ denied: random address
Properties
  • ✅ commits all staged permission grants
  • ✅ commits all staged permission grants after delay
Edge cases
  • ✅ when attempting to commit a single permission too early does not commit permission
  • ✅ when attempting to commit multiple permissions too early does not commit these permissions

revokePermissions

⛽ 62K (32K - 273K)
function revokePermissions(address target, uint8[] permissionIds) external
Revoke permission instantly from the given address.
Parameters:
Name
Type
Description
target
address
The given address.
permissionIds
uint8[]
A list of permission ids to revoke.
Specs
  • ✅ emits PermissionRevoked event
Edge cases
  • ✅ when attempting to revoke from zero address reverts with NULL

commitParams

⛽ 66K (54K - 81K)
function commitParams() external
Commits staged protocol params. Reverts if governance delay has not passed yet.
Specs
  • ✅ emits ParamsCommitted event
Access control
  • ✅ allowed: protocol admin
  • ✅ denied: deployer
  • ✅ denied: random address
Edge cases
  • ✅ when attempting to commit params too early reverts with TS
  • ✅ when attempting to commit params without setting pending params reverts with NULL

stagePermissionGrants

⛽ 164K (44K - 382K)
function stagePermissionGrants(address target, uint8[] permissionIds) external
Stage granted permissions that could have been committed after governance delay expires. Resets commit delay and permissions if there are already staged permissions for this address.
Parameters:
Name
Type
Description
target
address
Target address
permissionIds
uint8[]
A list of permission ids to grant
Specs
  • ✅ emits PermissionGrantsStaged event
Access control
  • ✅ allowed: admin
  • ✅ denied: deployer
  • ✅ denied: random address
Edge cases
  • ✅ when attempting to stage grant to zero address reverts with NULL

stageParams

⛽ 140K (62K - 165K)
function stageParams(struct IProtocolGovernance.Params newParams) external
Sets new pending params that could have been committed after governance delay expires.
Parameters:
Name
Type
Description
newParams
struct IProtocolGovernance.Params
New protocol parameters to set.
Specs
  • ✅ emits ParamsStaged event
Access control
  • ✅ allowed: admin
  • ✅ denied: random address
Edge cases
  • ✅ when given invalid params when maxTokensPerVault is zero reverts with NULL
  • ✅ when given invalid params when governanceDelay is zero reverts with NULL
  • ✅ when given invalid params when governanceDelay exceeds MAX_GOVERNANCE_DELAY reverts with LIMO
  • ✅ when given invalid params when withdrawLimit less than MIN_WITHDRAW_LIMIT reverts with LIMO

Structs

struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
struct Params {
uint256 maxTokensPerVault;
uint256 governanceDelay;
address protocolTreasury;
uint256 forceAllowMask;
uint256 withdrawLimit;
}

Events

ValidatorStaged

event ValidatorStaged(address origin, address sender, address target, address validator, uint256 at)
Emitted when validators are staged to be granted for specific address.
Parameters:
Name
Type
Description
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
target
address
Target address
validator
address
Staged validator
at
uint256
Timestamp when the staged permissions could be committed

ValidatorRevoked

event ValidatorRevoked(address origin, address sender, address target)
Validator revoked
Parameters:
Name
Type
Description
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
target
address
Target address

AllStagedValidatorsRolledBack

event AllStagedValidatorsRolledBack(address origin, address sender)
Emitted when staged validators are rolled back
Parameters:
Name
Type
Description
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)

ValidatorCommitted

event ValidatorCommitted(address origin, address sender, address target)
Emitted when staged validators are comitted for specific address
Parameters:
Name
Type
Description
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
target
address
Target address

PermissionGrantsStaged

event PermissionGrantsStaged(address origin, address sender, address target, uint8[] permissionIds, uint256 at)
Emitted when new permissions are staged to be granted for specific address.
Parameters:
Name
Type
Description
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
target
address
Target address
permissionIds
uint8[]
Permission IDs to be granted
at
uint256
Timestamp when the staged permissions could be committed

PermissionsRevoked

event PermissionsRevoked(address origin, address sender, address target, uint8[] permissionIds)
Emitted when permissions are revoked
Parameters:
Name
Type
Description
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
target
address
Target address
permissionIds
uint8[]
Permission IDs to be revoked

AllStagedPermissionGrantsRolledBack

event AllStagedPermissionGrantsRolledBack(address origin, address sender)
Emitted when staged permissions are rolled back
Parameters:
Name
Type
Description
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)

PermissionGrantsCommitted

event PermissionGrantsCommitted(address origin, address sender, address target)
Emitted when staged permissions are comitted for specific address
Parameters:
Name
Type
Description
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
target
address
Target address

ParamsStaged

event ParamsStaged(address origin, address sender, uint256 at, struct IProtocolGovernance.Params params)
Emitted when pending parameters are set
Parameters:
Name
Type
Description
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
at
uint256
Timestamp when the pending parameters could be committed
params
struct IProtocolGovernance.Params
Pending parameters

ParamsCommitted

event ParamsCommitted(address origin, address sender, struct IProtocolGovernance.Params params)
Emitted when pending parameters are committed
Parameters:
Name
Type
Description
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IProtocolGovernance.Params
Committed parameters

UnitPricesGovernance

⛽ 1.82M

Functions

constructor

function constructor(address admin) public

supportsInterface

function supportsInterface(bytes4 interfaceId) public returns (bool)
📕 Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.

stageUnitPrice

⛽ 72K (54K - 74K)
function stageUnitPrice(address token, uint256 value) external
Stage estimated amount of token worth 1 USD staged for commit.
Parameters:
Name
Type
Description
token
address
Address of the token
value
uint256
The amount of token

rollbackUnitPrice

⛽ 31K (30K - 31K)
function rollbackUnitPrice(address token) external
Reset staged value
Parameters:
Name
Type
Description
token
address
Address of the token

commitUnitPrice

⛽ 50K
function commitUnitPrice(address token) external
Commit staged unit price
Parameters:
Name
Type
Description
token
address
Address of the token

Structs

struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}

Events

UnitPriceStaged

event UnitPriceStaged(address origin, address sender, address token, uint256 unitPrice)
UnitPrice staged for commit
Parameters:
Name
Type
Description
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
token
address
Token address
unitPrice