Contracts API
ContractRegistry
Inherits from Multicall, ContractMeta
⛽ 1.82M
Functions
constructor
addresses
Addresses of the registered contracts
names
Names of the registered contracts
versions
All versions of the contract
Parameters:
versionAddress
Address of the contract at a given version
Parameters:
latestVersion
Latest version of the contract
Parameters:
registerContract
⛽ 256K (254K - 259K)
Register a new contract
Parameters:
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
ProtocolGovernance
Inherits from Multicall, UnitPricesGovernance, DefaultAccessControl, AccessControlEnumerable, AccessControl, ERC165, Context, ContractMeta
⛽ 4.68M
Governance that manages all params common for Euclidean Protocol Permissionless Vaults protocol.
Functions
constructor
Creates a new contract
Parameters:
Specs
✅ deploys a new contract
stagedParams
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
Current protocol parameters.
stagedValidatorsAddresses
validatorsAddresses
Addresses that has validators.
validatorsAddress
Address that has validators.
Parameters:
Return Values:
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
Addresses for which non-zero permissions are set.
stagedPermissionGrantsAddresses
Permission addresses staged for commit.
addressesByPermission
Return all addresses where rawPermissionMask bit for permissionId is set to 1.
Parameters:
Return Values:
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
Checks if address has permission or given permission is force allowed for any address.
Parameters:
hasAllPermissions
Checks if address has all permissions.
Parameters:
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
Max different ERC20 token addresses that could be managed by the protocol.
Specs
✅ returns correct value
governanceDelay
The delay for committing any governance params.
Specs
✅ returns correct value
protocolTreasury
The address of the protocol treasury.
Specs
✅ returns correct value
forceAllowMask
Permissions mask which defines if ordinary permission should be reverted. This bitmask is xored with ordinary mask.
Specs
✅ returns correct value
withdrawLimit
Withdraw limit per token per block.
Parameters:
Return Values:
Specs
✅ returns correct value
supportsInterface
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)
Stages a new validator for the given address
Parameters:
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)
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)
Commits validator for the given address.
📕 Reverts if governance delay has not passed yet.
Parameters:
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)
Commites all staged validators for which governance delay passed
Return Values:
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
Revoke validator instantly from the given address.
Parameters:
Specs
✅ emits ValidatorRevoked event
Edge cases
✅ when attempting to revoke from zero address reverts with NULL
rollbackStagedPermissionGrants
⛽ 37K (28K - 42K)
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)
Commits permission grants for the given address.
📕 Reverts if governance delay has not passed yet.
Parameters:
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
⛽ 145K (27K - 248K)
Commites all staged permission grants for which governance delay passed.
Return Values:
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 - 275K)
Revoke permission instantly from the given address.
Parameters:
Specs
✅ emits PermissionRevoked event
Edge cases
✅ when attempting to revoke from zero address reverts with NULL
commitParams
⛽ 66K (54K - 81K)
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
⛽ 166K (44K - 383K)
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:
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)
Sets new pending params that could have been committed after governance delay expires.
Parameters:
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
Events
ValidatorStaged
Emitted when validators are staged to be granted for specific address.
Parameters:
ValidatorRevoked
Validator revoked
Parameters:
AllStagedValidatorsRolledBack
Emitted when staged validators are rolled back
Parameters:
ValidatorCommitted
Emitted when staged validators are comitted for specific address
Parameters:
PermissionGrantsStaged
Emitted when new permissions are staged to be granted for specific address.
Parameters:
PermissionsRevoked
Emitted when permissions are revoked
Parameters:
AllStagedPermissionGrantsRolledBack
Emitted when staged permissions are rolled back
Parameters:
PermissionGrantsCommitted
Emitted when staged permissions are comitted for specific address
Parameters:
ParamsStaged
Emitted when pending parameters are set
Parameters:
ParamsCommitted
Emitted when pending parameters are committed
Parameters:
UnitPricesGovernance
Inherits from DefaultAccessControl, AccessControlEnumerable, AccessControl, ERC165, Context
⛽ 1.82M
Functions
constructor
supportsInterface
📕 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)
Stage estimated amount of token worth 1 USD staged for commit.
Parameters:
rollbackUnitPrice
⛽ 31K (30K - 31K)
Reset staged value
Parameters:
commitUnitPrice
⛽ 50K
Commit staged unit price
Parameters:
Structs
Events
UnitPriceStaged
UnitPrice staged for commit
Parameters:
UnitPriceRolledBack
UnitPrice rolled back
Parameters:
UnitPriceCommitted
UnitPrice committed
Parameters:
VaultRegistry
Inherits from ERC721, ERC165, Context, ContractMeta
⛽ 3.07M
This contract is used to manage ERC721 NFT for all Vaults.
Functions
constructor
Creates a new contract.
Parameters:
Specs
✅ creates VaultRegistry
✅ initializes ProtocolGovernance address
✅ initializes ERC721 token name
✅ initializes ERC721 token symbol
vaults3
Specs
✅ returns all registered vaults
✅ access control: allowed: any address
✅ ount returns the number of registered vaults
✅ ount access control: allowed: any address
✅ ount properties @property: when N new vaults have been registered, vaults count will be increased by N
vaultForNft
Get Vault for the giver NFT ID.
Parameters:
Return Values:
Specs
✅ resolves Vault address by VaultRegistry NFT
✅ access control: allowed: any address
Edge cases
✅ when Vault NFT is not registered in VaultRegistry returns zero address
nftForVault
Get NFT ID for given Vault contract address.
Parameters:
Return Values:
Specs
✅ resolves VaultRegistry NFT by Vault address
✅ access control: allowed: any address
Edge cases
✅ when Vault is not registered in VaultRegistry returns zero
isLocked
Checks if the nft is locked for all transfers
Parameters:
Return Values:
Specs
✅ checks if token is locked (not transferable)
✅ access control: allowed: any address
Edge cases
✅ when VaultRegistry NFT is not registered in VaultRegistry returns false
protocolGovernance
Address of the ProtocolGovernance.
Specs
✅ returns ProtocolGovernance address
✅ access control: allowed: any address
stagedProtocolGovernance
Address of the staged ProtocolGovernance.
Specs
✅ returns ProtocolGovernance address staged for commit
✅ access control: allowed: any address
✅ imestamp returns timestamp after which #commitStagedProtocolGovernance can be called
✅ imestamp access control: allowed: any address
✅ imestamp edge cases when nothing is staged returns 0
✅ imestamp edge cases right after #commitStagedProtocolGovernance was called returns 0
Edge cases
✅ when nothing is staged returns zero address
✅ right after #commitStagedProtocolGovernance was called returns zero address
stagedProtocolGovernanceTimestamp
Minimal timestamp when staged ProtocolGovernance can be applied.
Specs
✅ returns timestamp after which #commitStagedProtocolGovernance can be called
✅ access control: allowed: any address
Edge cases
✅ when nothing is staged returns 0
✅ right after #commitStagedProtocolGovernance was called returns 0
vaultsCount
Number of Vaults registered.
Specs
✅ returns the number of registered vaults
✅ access control: allowed: any address
Properties
✅ when N new vaults have been registered, vaults count will be increased by N
supportsInterface
Specs
✅ returns true if this contract supports a certain interface
✅ access control: allowed: any address
✅ edge cases: when contract does not support the given interface returns false
registerVault
⛽ 167K (154K - 188K)
Register new Vault and mint NFT.
Parameters:
Return Values:
Specs
✅ binds minted ERC721 NFT to Vault address and transfers minted NFT to owner specified in args
✅ emits VaultRegistered event
✅ access control: allowed: any account with Register Vault permissions
✅ access control: denied: any other address
✅ access control: denied: protocol governance admin
Properties
✅ minted NFT equals to vaultRegistry#vaultsCount
Edge cases
✅ when address doesn't conform to IVault interface (IERC165) reverts with INVI
✅ when vault has already been registered reverts with DUP
✅ when owner address is zero reverts with AZ
stageProtocolGovernance
⛽ 75K (43K - 80K)
Stage new ProtocolGovernance.
Parameters:
Specs
✅ stages new ProtocolGovernance for commit
✅ sets the stagedProtocolGovernanceTimestamp after which #commitStagedProtocolGovernance can be called
✅ access control: allowed: ProtocolGovernance Admin
✅ access control: denied: any other address
✅ access control: denied: deployer
Edge cases
✅ when new ProtocolGovernance is a zero address reverts with AZ
commitStagedProtocolGovernance
⛽ 34K
Commit new ProtocolGovernance.
Specs
✅ commits staged ProtocolGovernance
✅ resets staged ProtocolGovernanceTimestamp
✅ resets staged ProtocolGovernance
✅ access control: allowed: ProtocolGovernance Admin
✅ access control: denied: any other address
Edge cases
✅ when nothing is staged reverts with INIT
✅ when called before stagedProtocolGovernanceTimestamp reverts with TS
✅ when called before stagedProtocolGovernanceTimestamp reverts with TS
lockNft
⛽ 46K (29K - 49K)
Specs
✅ locks NFT (disables any transfer)
✅ emits TokenLocked event
✅ access control: allowed: NFT owner
✅ access control: denied: any other address
✅ access control: denied: protocol admin
Edge cases
✅ when NFT has already been locked succeeds
Events
TokenLocked
Emitted when token is locked for transfers
Parameters:
VaultRegistered
Emitted when new Vault is registered in VaultRegistry
Parameters:
StagedProtocolGovernance
Parameters:
CommitedProtocolGovernance
Parameters:
CommonLibrary
CommonLibrary shared utilities
ExceptionsLibrary
Exceptions stores project`s smart-contracts exceptions
PermissionIdsLibrary
Stores permission ids for addresses
SemverLibrary
ChainlinkOracle
Inherits from DefaultAccessControl, AccessControlEnumerable, AccessControl, ERC165, Context, ContractMeta
⛽ 2.77M
Contract for getting chainlink data
Functions
constructor
hasOracle
Checks if token has chainlink oracle
Parameters:
Return Values:
Specs
✅ returns true if oracle is supported
✅ edge cases: when oracle is not supported returns false
supportedTokens
A list of supported tokens
Specs
✅ returns list of supported tokens
priceX96
Oracle price for tokens as a Q64.96 value. Returns pricing information based on the indexes of non-zero bits in safetyIndicesSet. It is possible that not all indices will have their respective prices returned.
📕 The price is token1 / token0 i.e. how many weis of token1 required for 1 wei of token0. The safety indexes are:
1 - unsafe, this is typically a spot price that can be easily manipulated,
2 - 4 - more or less safe, this is typically a uniV3 oracle, where the safety is defined by the timespan of the average price
5 - safe - this is typically a chailink oracle
Parameters:
Return Values:
supportsInterface
📕 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.
Specs
✅ returns true for ChainlinkOracle interface (0x8e3bd5d7)
✅ edge cases: when contract does not support the given interface returns false
addChainlinkOracles
⛽ 82K (81K - 83K)
Add a Chainlink price feed for a token
Parameters:
Specs
✅ emits OraclesAdded event
✅ when oracles have set by addChainLinkOracles function returns prices
✅ edge cases: when arrays have different lengths reverts with INV
✅ edge cases: when sender has no admin righs reverts with FRB
Structs
Events
OraclesAdded
Emitted when new Chainlink oracle is added
Parameters:
Euclidean Oracle
Inherits from ERC165, ContractMeta
⛽ 783K
constructor
priceX96
supportsInterface
📕 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.
Specs
✅ returns true for IUniV3Oracle interface (0x6d80125b)
✅ edge cases: when contract does not support the given interface returns false
UniV2Oracle
Inherits from ERC165, ContractMeta
⛽ 671K
constructor
priceX96
Oracle price for tokens as a Q64.96 value. Returns pricing information based on the indexes of non-zero bits in safetyIndicesSet. It is possible that not all indices will have their respective prices returned.
📕 The price is token1 / token0 i.e. how many weis of token1 required for 1 wei of token0. The safety indexes are:
1 - unsafe, this is typically a spot price that can be easily manipulated,
2 - 4 - more or less safe, this is typically a uniV3 oracle, where the safety is defined by the timespan of the average price
5 - safe - this is typically a chailink oracle
Parameters:
Return Values:
supportsInterface
📕 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.
Specs
✅ returns true for IUniV2Oracle interface (0x2748645e)
✅ edge cases: when contract does not support the given interface returns false
UniV3Oracle
Inherits from DefaultAccessControl, AccessControlEnumerable, AccessControl, ERC165, Context, ContractMeta
⛽ 3.44M
Functions
constructor
priceX96
Oracle price for tokens as a Q64.96 value. Returns pricing information based on the indexes of non-zero bits in safetyIndicesSet. It is possible that not all indices will have their respective prices returned.
📕 Logic of this function is next: If there is no initialized pool for the passed tokens, empty arrays will be returned. Depending on safetyIndicesSet if the 1st bit in safetyIndicesSet is non-zero, then the response will contain the spot price. If there is a non-zero 2nd bit in the safetyIndicesSet and the corresponding position in the pool was created no later than LOW_OBS_DELTA seconds ago, then the average price for the last LOW_OBS_DELTA seconds will be returned. The same logic exists for the 3rd and MID_OBS_DELTA, and 4th index and HIGH_OBS_DELTA.
Parameters:
Return Values:
supportsInterface
📕 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.
Specs
✅ returns true for IUniV3Oracle interface (0x2a3602d6)
✅ when contract does not support the given interface returns false
addUniV3Pools
⛽ 73K (39K - 89K)
Add UniV3 pools for prices.
Parameters:
Specs
✅ when adding [weth, usdc] pools with fee = 500 adds pools
✅ when adding [weth, usdc] pools with fee = 3000 adds pools
✅ when adding [weth, usdc] pools with fee = 10000 does not return prices
Structs
Events
PoolsUpdated
Emitted when new pool is added or updated and become available for oracle prices
Parameters:
HStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
⛽ 7.59M
Functions
constructor
constructs a strategy
Parameters:
Specs
✅ deploys a new contract
initialize
initializes the strategy
Parameters:
createStrategy
⛽ 536K (536K - 539K)
creates the clone of the strategy
Parameters:
Return Values:
Specs
✅ creates a new strategy and initializes it
updateStrategyParams
⛽ 48K (44K - 51K)
updates parameters of the strategy. Can be called only by admin
Parameters:
updateMintingParams
updates parameters for minting position. Can be called only by admin
Parameters:
updateOracleParams
updates oracle parameters. Can be called only by admin
Parameters:
updateRatioParams
⛽ 39K (38K - 40K)
updates parameters of the capital ratios and deviation. Can be called only by admin
Parameters:
updateSwapFees
updates swap fees for uniswapV3Pool swaps
Parameters:
manualPull
⛽ 468K (256K - 517K)
manual pulling tokens from vault. Can be called only by admin
Parameters:
Specs
✅ pulls token amounts from fromVault to toVault
rebalance
⛽ 1.44M (352K - 1.75M)
rebalance method. Need to be called if the new position is needed
Parameters:
Return Values:
Specs
✅ performs a rebalance according to strategy params
Structs
Events
MintUniV3Position
Emitted when new position in UniV3Pool has been minted.
Parameters:
BurnUniV3Position
Emitted when position in UniV3Pool has been burnt.
Parameters:
SwapTokensOnERC20Vault
Emitted when swap is initiated.
Parameters:
UpdateStrategyParams
Emitted when Strategy strategyParams are set.
Parameters:
UpdateMintingParams
Emitted when Strategy mintingParams are set.
Parameters:
UpdateOracleParams
Emitted when Strategy oracleParams are set.
Parameters:
UpdateRatioParams
Emitted when Strategy ratioParams are set.
Parameters:
UpdateSwapFees
Emitted when new swap fees for UniV3Pool swaps are set.
Parameters:
LStrategy
Inherits from DefaultAccessControl, AccessControlEnumerable, AccessControl, ERC165, Context
⛽ 7.65M
Functions
constructor
getTargetPriceX96
Target price based on mutable params, as a Q64.96 value
targetUniV3LiquidityRatio
Target liquidity ratio for UniV3 vaults
rebalanceERC20UniV3Vaults
⛽ 505K (326K - 1.69M)
Make a rebalance between ERC20 and UniV3 Vaults
Parameters:
Return Values:
rebalanceUniV3Vaults
⛽ 432K (138K - 900K)
Make a rebalance of UniV3 vaults
Parameters:
Return Values:
postPreOrder
⛽ 144K (140K - 180K)
Post preorder for ERC20 vault rebalance.
Parameters:
Return Values:
signOrder
⛽ 210K (103K - 233K)
Sign offchain cowswap order onchain
Parameters:
resetCowswapAllowance
⛽ 117K (116K - 118K)
Reset cowswap allowance to 0
Parameters:
collectUniFees
⛽ 279K (239K - 320K)
Collect Uniswap pool fees to erc20 vault
Return Values:
manualPull
⛽ 345K (297K - 487K)
Manually pull tokens from fromVault to toVault
Parameters:
updateTradingParams
⛽ 68K (42K - 119K)
Sets new trading params
Parameters:
updateRatioParams
⛽ 37K (36K - 53K)
Sets new ratio params
Parameters:
updateOtherParams
⛽ 41K (33K - 94K)
Sets new other params
Parameters: