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:
name
string
Name of the contract
versionAddress
Address of the contract at a given version
Parameters:
name
string
Name of the contract
version
string
Version of the contract
latestVersion
Latest version of the contract
Parameters:
name
string
Name of the contract
registerContract
⛽ 256K (254K - 259K)
Register a new contract
Parameters:
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
ProtocolGovernance
Inherits from Multicall, UnitPricesGovernance, DefaultAccessControl, AccessControlEnumerable, AccessControl, ERC165, Context, ContractMeta
⛽ 4.68M
Governance that manages all params common for Mellow Permissionless Vaults protocol.
Functions
constructor
Creates a new contract
Parameters:
admin
address
Initial admin of the contract
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:
i
uint256
The number of address
Return Values:
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
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:
permissionId
uint8
Id of the permission to check.
Return Values:
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
Checks if address has permission or given permission is force allowed for any address.
Parameters:
addr
address
Address to check
permissionId
uint8
Permission to check
hasAllPermissions
Checks if address has all permissions.
Parameters:
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
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:
token
address
Address of the token
Return Values:
Withdraw
uint256
limit per token per block
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:
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)
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:
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)
Commites all staged validators for which governance delay passed
Return Values:
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
Revoke validator instantly from the given address.
Parameters:
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)
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:
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
⛽ 145K (27K - 248K)
Commites all staged permission grants for which governance delay passed.
Return Values:
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 - 275K)
Revoke permission instantly from the given address.
Parameters:
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)
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:
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)
Sets new pending params that could have been committed after governance delay expires.
Parameters:
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
Events
ValidatorStaged
Emitted when validators are staged to be granted for specific address.
Parameters:
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
Validator revoked
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
target
address
Target address
AllStagedValidatorsRolledBack
Emitted when staged validators are rolled back
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
ValidatorCommitted
Emitted when staged validators are comitted for specific address
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
target
address
Target address
PermissionGrantsStaged
Emitted when new permissions are staged to be granted for specific address.
Parameters:
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
Emitted when permissions are revoked
Parameters:
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
Emitted when staged permissions are rolled back
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
PermissionGrantsCommitted
Emitted when staged permissions are comitted for specific address
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
target
address
Target address
ParamsStaged
Emitted when pending parameters are set
Parameters:
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
Emitted when pending parameters are committed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IProtocolGovernance.Params
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:
token
address
Address of the token
value
uint256
The amount of token
rollbackUnitPrice
⛽ 31K (30K - 31K)
Reset staged value
Parameters:
token
address
Address of the token
commitUnitPrice
⛽ 50K
Commit staged unit price
Parameters:
token
address
Address of the token
Structs
Events
UnitPriceStaged
UnitPrice staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
token
address
Token address
unitPrice
uint256
Unit price
UnitPriceRolledBack
UnitPrice rolled back
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
token
address
Token address
UnitPriceCommitted
UnitPrice committed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
token
address
Token address
unitPrice
uint256
Unit price
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:
name
string
ERC721 token name
symbol
string
ERC721 token symbol
protocolGovernance_
contract IProtocolGovernance
Reference to ProtocolGovernance
Specs
✅ creates VaultRegistry
✅ initializes ProtocolGovernance address
✅ initializes ERC721 token name
✅ initializes ERC721 token symbol
vaults
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:
nftId
uint256
NFT ID
Return Values:
vault
address
Address of the Vault contract
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:
vault
address
Address of the Vault contract
Return Values:
nftId
uint256
NFT ID
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:
nft
uint256
NFT to check for lock
Return Values:
if
bool
locked, false otherwise
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:
vault
address
address of the vault
owner
address
owner of the NFT
Return Values:
nft
uint256
Nft minted for the given Vault
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:
newProtocolGovernance
contract IProtocolGovernance
new ProtocolGovernance
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:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
nft
uint256
NFT to be locked
VaultRegistered
Emitted when new Vault is registered in VaultRegistry
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
nft
uint256
VaultRegistry NFT of the vault
vault
address
Address of the Vault contract
owner
address
Owner of the VaultRegistry NFT
StagedProtocolGovernance
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
newProtocolGovernance
contract IProtocolGovernance
Address of the new ProtocolGovernance
start
uint256
Timestamp of the start of the new ProtocolGovernance
CommitedProtocolGovernance
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
newProtocolGovernance
contract IProtocolGovernance
Address of the new ProtocolGovernance that has been committed
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:
token
address
token address
Return Values:
if
bool
token is allowed, false
o/w
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:
token0
address
Reference to token0
token1
address
Reference to token1
safetyIndicesSet
uint256
Bitmask of safety indices that are allowed for the return prices. For set of safety indexes = { 1 }, safetyIndicesSet = 0x2
Return Values:
pricesX96
uint256[]
Prices that satisfy safetyIndex and tokens
safetyIndices
uint256[]
Safety indices for those prices
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:
tokens
address[]
ERC20 tokens for the feed
oracles
address[]
Chainlink oracle price feeds (token / USD)
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:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
tokens
address[]
Tokens added
oracles
address[]
Orecles added for the tokens
MellowOracle
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:
token0
address
Reference to token0
token1
address
Reference to token1
safetyIndicesSet
uint256
Bitmask of safety indices that are allowed for the return prices. For set of safety indexes = { 1 }, safetyIndicesSet = 0x2
Return Values:
pricesX96
uint256[]
Prices that satisfy safetyIndex and tokens
safetyIndices
uint256[]
Safety indices for those prices
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:
token0
address
Reference to token0
token1
address
Reference to token1
safetyIndicesSet
uint256
Bitmask of safety indices that are allowed for the return prices. For set of safety indexes = { 1 }, safetyIndicesSet = 0x2
Return Values:
pricesX96
uint256[]
Prices that satisfy safetyIndex and tokens
safetyIndices
uint256[]
Safety indices for those prices
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:
pools
contract IUniswapV3Pool[]
Pools to add
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:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
pools
contract IUniswapV3Pool[]
UniV3 pools added
replacedPools
contract IUniswapV3Pool[]
UniV3 pools updated
HStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
⛽ 7.59M
Functions
constructor
constructs a strategy
Parameters:
positionManager_
contract INonfungiblePositionManager
the position manager for uniV3
router_
contract ISwapRouter
the uniV3 router for swapping tokens
uniV3Helper_
address
the address of the helper contract for uniV3
hStrategyHelper_
address
the address of the strategy helper contract
Specs
✅ deploys a new contract
initialize
initializes the strategy
Parameters:
tokens_
address[]
the addresses of the tokens managed by the strategy
erc20Vault_
contract IERC20Vault
the address of the erc20 vault
moneyVault_
contract IIntegrationVault
the address of the moneyVault. It is expected to be yEarn or AAVE
uniV3Vault_
contract IUniV3Vault
the address of uniV3Vault. It is expected to not hold the position
fee_
uint24
the fee of the uniV3 pool on which the vault operates
admin_
address
the addres of the admin of the strategy
createStrategy
⛽ 536K (536K - 539K)
creates the clone of the strategy
Parameters:
tokens_
address[]
the addresses of the tokens managed by the strategy
erc20Vault_
contract IERC20Vault
the address of the erc20 vault
moneyVault_
contract IIntegrationVault
the address of the moneyVault. It is expected to be yEarn or AAVE
uniV3Vault_
contract IUniV3Vault
the address of uniV3Vault. It is expected to not hold the position
fee_
uint24
the fee of the uniV3 pool on which the vault operates
admin_
address
the addres of the admin of the strategy
Return Values:
strategy
contract HStrategy
the address of new strategy
Specs
✅ creates a new strategy and initializes it
updateStrategyParams
⛽ 48K (44K - 51K)
updates parameters of the strategy. Can be called only by admin
Parameters:
newStrategyParams
struct HStrategy.StrategyParams
the new parameters
updateMintingParams
updates parameters for minting position. Can be called only by admin
Parameters:
newMintingParams
struct HStrategy.MintingParams
the new parameters
updateOracleParams
updates oracle parameters. Can be called only by admin
Parameters:
newOracleParams
struct HStrategy.OracleParams
the new parameters
updateRatioParams
⛽ 39K (38K - 40K)
updates parameters of the capital ratios and deviation. Can be called only by admin
Parameters:
newRatioParams
struct HStrategy.RatioParams
the new parameters
updateSwapFees
updates swap fees for uniswapV3Pool swaps
Parameters:
newSwapFees
uint24
the new parameters
manualPull
⛽ 468K (256K - 517K)
manual pulling tokens from vault. Can be called only by admin
Parameters:
fromVault
contract IIntegrationVault
the address of the vault to pull tokens from
toVault
contract IIntegrationVault
the address of the vault to pull tokens to
tokenAmounts
uint256[]
the amount of tokens to be pulled
vaultOptions
bytes
additional options for pull
method
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:
restrictions
struct HStrategy.RebalanceTokenAmounts
the restrictions of the amount of tokens to be transferred
moneyVaultOptions
bytes
additional parameters for pulling for pull
method for money vault
Return Values:
actualPulledAmounts
struct HStrategy.RebalanceTokenAmounts
actual transferred amounts
burnedAmounts
uint256[]
actual burned amounts from uniV3 position
Specs
✅ performs a rebalance according to strategy params