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
Structs
Events
MintUniV3Position
Emitted when new position in UniV3Pool has been minted.
Parameters:
uniV3Nft
uint256
nft of new minted position
lowerTick
int24
lowerTick of that position
upperTick
int24
upperTick of that position
BurnUniV3Position
Emitted when position in UniV3Pool has been burnt.
Parameters:
uniV3Nft
uint256
nft of new minted position
SwapTokensOnERC20Vault
Emitted when swap is initiated.
Parameters:
origin
address
Origin of the transaction (tx.origin)
swapParams
struct ISwapRouter.ExactInputSingleParams
Swap domainPositionParams
UpdateStrategyParams
Emitted when Strategy strategyParams are set.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
strategyParams
struct HStrategy.StrategyParams
Updated strategyParams
UpdateMintingParams
Emitted when Strategy mintingParams are set.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
mintingParams
struct HStrategy.MintingParams
Updated mintingParams
UpdateOracleParams
Emitted when Strategy oracleParams are set.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
oracleParams
struct HStrategy.OracleParams
Updated oracleParams
UpdateRatioParams
Emitted when Strategy ratioParams are set.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
ratioParams
struct HStrategy.RatioParams
Updated ratioParams
UpdateSwapFees
Emitted when new swap fees for UniV3Pool swaps are set.
Parameters:
newSwapFees
address
new swap fee
origin
address
Origin of the transaction (tx.origin)
sender
uint24
Sender of the call (msg.sender)
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:
minLowerVaultTokens
uint256[]
Min accepted tokenAmounts for lower vault
minUpperVaultTokens
uint256[]
Min accepted tokenAmounts for upper vault
deadline
uint256
Timestamp after which the transaction reverts
Return Values:
totalPulledAmounts
uint256[]
total amounts pulled from erc20 vault or Uni vaults
isNegativeCapitalDelta
bool
true
if rebalance if from UniVaults, false otherwise
percentageIncreaseD
uint256
the percentage of capital change of UniV3 vaults
rebalanceUniV3Vaults
⛽ 432K (138K - 900K)
Make a rebalance of UniV3 vaults
Parameters:
minWithdrawTokens
uint256[]
Min accepted tokenAmounts for withdrawal
minDepositTokens
uint256[]
Min accepted tokenAmounts for deposit
deadline
uint256
Timestamp after which the transaction reverts
Return Values:
pulledAmounts
uint256[]
Amounts pulled from one vault
pushedAmounts
uint256[]
Amounts pushed to the other vault
depositLiquidity
uint128
Amount of liquidity deposited to vault
withdrawLiquidity
uint128
Amount of liquidity withdrawn from vault
lowerToUpper
bool
true if liquidity is moved from lower vault to upper
postPreOrder
⛽ 144K (140K - 180K)
Post preorder for ERC20 vault rebalance.
Parameters:
minAmountOut
uint256
minimum amount out of tokens to swap
Return Values:
preOrder_
struct LStrategy.PreOrder
Posted preorder
signOrder
⛽ 210K (103K - 233K)
Sign offchain cowswap order onchain
Parameters:
order
struct GPv2Order.Data
Cowswap order data
uuid
bytes
Cowswap order id
signed
bool
To sign order set to true
resetCowswapAllowance
⛽ 117K (116K - 118K)
Reset cowswap allowance to 0
Parameters:
tokenNumber
uint8
The number of token in LStrategy
collectUniFees
⛽ 279K (239K - 320K)
Collect Uniswap pool fees to erc20 vault
Return Values:
totalCollectedEarnings
uint256[]
Total collected fees
manualPull
⛽ 345K (297K - 487K)
Manually pull tokens from fromVault to toVault
Parameters:
fromVault
contract IIntegrationVault
Pull tokens from this vault
toVault
contract IIntegrationVault
Pull tokens to this vault
tokenAmounts
uint256[]
Token amounts to pull
minTokensAmounts
uint256[]
Minimal token amounts to pull
deadline
uint256
Timestamp after which the transaction is invalid
updateTradingParams
⛽ 68K (42K - 119K)
Sets new trading params
Parameters:
newTradingParams
struct LStrategy.TradingParams
New trading parameters to set
updateRatioParams
⛽ 37K (36K - 53K)
Sets new ratio params
Parameters:
newRatioParams
struct LStrategy.RatioParams
New ratio parameters to set
updateOtherParams
⛽ 41K (33K - 94K)
Sets new other params
Parameters:
newOtherParams
struct LStrategy.OtherParams
New other parameters to set
Structs
Events
PreOrderPosted
Emitted when a new cowswap preOrder is posted.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
preOrder
struct LStrategy.PreOrder
Preorder that was posted
OrderSigned
Emitted when cowswap preOrder was signed onchain.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
order
bytes
Cowswap order
preOrder
struct GPv2Order.Data
PreOrder that the order fulfills
signed
struct LStrategy.PreOrder
Singned or unsigned
ManualPull
Emitted when manual pull from vault is executed.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
tokenAmounts
uint256[]
The amounts of tokens that were
SwapVault
Emitted when vault is swapped.
Parameters:
oldNft
uint256
UniV3 nft that was burned
newNft
uint256
UniV3 nft that was created
newTickLower
int24
Lower tick for created UniV3 nft
newTickUpper
int24
Upper tick for created UniV3 nft
RebalancedErc20UniV3
Emitted when rebalance from UniV3 to ERC20 or vice versa happens
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
fromErc20
bool
true
if the rebalance is made
pulledAmounts
uint256[]
amounts pulled from fromVault
RebalancedUniV3
Parameters:
fromVault
address
The vault to pull liquidity from
toVault
address
The vault to pull liquidity to
pulledAmounts
address
amounts pulled from fromVault
pushedAmounts
address
amounts pushed to toVault
desiredLiquidity
uint256[]
The amount of liquidity desired for rebalance. This could be cut to available erc20 vault balance and available uniV3 vault liquidity.
liquidity
uint256[]
The actual amount of liquidity rebalanced.
TradingParamsUpdated
Emitted when trading params were updated
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
tradingParams
struct LStrategy.TradingParams
New trading parameters
RatioParamsUpdated
Emitted when ratio params were updated
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
ratioParams
struct LStrategy.RatioParams
New ratio parameters
OtherParamsUpdated
Emitted when other params were updated
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
otherParams
struct LStrategy.OtherParams
New trading parameters
CowswapAllowanceReset
FeesCollected
MStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
⛽ 6.64M
Functions
constructor
Deploys a new contract
Parameters:
positionManager_
contract INonfungiblePositionManager
Uniswap V3 position manager
router_
contract ISwapRouter
Uniswap V3 swap router
Specs
✅ deploys a new contract
Edge cases
✅ when positionManager_ address is zero reverts with AZ
✅ when router_ address is zero passes
getAverageTick
UniV3 pool price stats
Return Values:
averageTick
int24
Average tick according to oracle and oracleParams.maxTickDeviation
deviation
int24
Current pool tick - average tick
Specs
✅ returns average UniswapV3Pool price tick
initialize
Set initial values.
📕 Can be only called once.
Parameters:
positionManager_
contract INonfungiblePositionManager
Uniswap V3 position manager
router_
contract ISwapRouter
Uniswap V3 swap router
tokens_
address[]
Tokens under management
erc20Vault_
contract IERC20Vault
erc20Vault of the Strategy
moneyVault_
contract IIntegrationVault
moneyVault of the Strategy
fee_
uint24
Uniswap V3 fee for the pool (needed for oracle and swaps)
admin_
address
Admin of the strategy
createStrategy
⛽ 571K (570K - 573K)
Deploy a new strategy.
Parameters:
tokens_
address[]
Tokens under management
erc20Vault_
contract IERC20Vault
erc20Vault of the Strategy
moneyVault_
contract IIntegrationVault
moneyVault of the Strategy
fee_
uint24
Uniswap V3 fee for the pool (needed for oracle and swaps)
admin_
address
Admin of the new strategy
Specs
✅ creates a new strategy and initializes it
Access control
✅ allowed: any address
Edge cases
✅ when tokens.length is not equal 2 reverts with INVL
✅ when erc20Vault vaultTokens do not match tokens_ reverts with INVA
✅ when moneyVault vaultTokens do not match tokens_ reverts with INVA
✅ when UniSwapV3 pool for tokens does not exist reverts with AZ
rebalance
⛽ 725K (240K - 851K)
Perform a rebalance according to target ratios
Parameters:
minTokensAmount
uint256[]
Lower bounds for amountOut of tokens, that we want to get after swap via SwapRouter
vaultOptions
bytes
Parameters of money vault for operations with it
Return Values:
poolAmounts
int256[]
The amount of each token that was pulled from erc20Vault to the money vault if positive, otherwise vice versa
tokenAmounts
uint256[]
The amount of each token passed to and from SwapRouter dependings on zeroToOne
zeroToOne
bool
Flag, that true if we swapped amount of zero token to first token, otherwise false
Specs
✅ performs a rebalance according to target ratios when token0/token1 ratio is greater than required
✅ performs a rebalance according to target ratios when token0/token1 ratio is less than required
Access control
✅ allowed: MStrategy admin
✅ allowed: MStrategy operator
✅ denied: any other address
Edge cases
✅ when absolute tick deviation >= oracle.maxTickDeviation reverts with INVA
✅ when tick is greater than tickMax - tickNeiborhood the upper bound of the interval is expanded by tickIncrease amount
✅ when tick is less than tickMin + tickNeiborhood the lower bound of the interval is expanded by tickIncrease amount
✅ when current tick has not deviated from the previous rebalance tick reverts with LIMU
manualPull
Manually pull tokens from fromVault to toVault
Parameters:
fromVault
contract IIntegrationVault
Pull tokens from this vault
toVault
contract IIntegrationVault
Pull tokens to this vault
tokenAmounts
uint256[]
Token amounts to pull
Specs
✅ pulls token amounts from fromVault to toVault
Access control
✅ allowed: MStrategy admin
✅ denied: any other address
Edge cases
✅ when token pull amounts are 0 passes
setOracleParams
⛽ 64K (41K - 75K)
Set new Oracle params
Parameters:
params
struct MStrategy.OracleParams
Params to set
Specs
✅ sets new params for oracle
✅ edge cases: when maxSlippageD is more than DENOMINATOR reverts with INVA
Access control
✅ allowed: MStrategy admin
✅ denied: any other address
setRatioParams
⛽ 65K (44K - 124K)
Set new Ratio params
Parameters:
params
struct MStrategy.RatioParams
Params to set
Specs
✅ sets new ratio params
✅ edge cases: tickMin is greater than tickMax reverts with INVA
✅ edge cases: when erc20MoneyRatioD is more than DENOMINATOR reverts with INVA
✅ edge cases: when minErc20MoneyRatioDeviationD is more than DENOMINATOR reverts with INVA
Access control
✅ allowed: MStrategy admin
✅ denied: any other address
Structs
Events
RebalancedPools
Emitted when pool rebalance is initiated.
Parameters:
tokenAmounts
int256[]
Token amounts for rebalance, negative means erc20Vault => moneyVault and vice versa.
SwappedTokens
Emitted when swap is initiated.
Parameters:
params
struct MStrategy.SwapToTargetParams
Swap params
SetOracleParams
Emitted when Oracle params are set.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct MStrategy.OracleParams
Updated params
SetRatioParams
Emitted when Ratio params are set.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct MStrategy.RatioParams
Updated params
MultiPoolHStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
⛽ 5.84M
Functions
constructor
constructs a strategy
initialize
initializes the strategy
Parameters:
immutableParams_
struct MultiPoolHStrategy.ImmutableParams
structure with all immutable params of the strategy
mutableParams_
struct MultiPoolHStrategy.MutableParams
structure with all mutable params of strategy for initial set
admin
address
the addres of the admin of the strategy
createStrategy
⛽ 1.2M (1.18M - 1.25M)
creates the clone of the strategy
Parameters:
immutableParams_
struct MultiPoolHStrategy.ImmutableParams
structure with all immutable params of the strategy
mutableParams_
struct MultiPoolHStrategy.MutableParams
structure with all mutable params of strategy for initial set
admin
address
the addres of the admin of the strategy
Return Values:
strategy
contract MultiPoolHStrategy
new cloned strategy with for given params
updateMutableParams
updates parameters of the strategy. Can be called only by admin
Parameters:
mutableParams_
struct MultiPoolHStrategy.MutableParams
the new parameters
rebalance
⛽ 3.41M
rebalance method. Need to be called if the new position is needed
Parameters:
restrictions
struct MultiPoolHStrategyRebalancer.Restrictions
the restrictions of the amount of tokens to be transferred and positions to be minted
Return Values:
actualAmounts
struct MultiPoolHStrategyRebalancer.Restrictions
actual transferred token amounts and minted positions
Specs
✅ works correctly
checkMutableParams
the function checks that mutableParams_ pass the necessary checks
Parameters:
mutableParams_
struct MultiPoolHStrategy.MutableParams
params to be checked
Structs
Events
UpdateMutableParams
Emitted when Strategy mutableParams are set.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
mutableParams
struct MultiPoolHStrategy.MutableParams
Updated mutableParams
Rebalance
Emitted when Strategy mutableParams are set.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
expectedAmounts
struct MultiPoolHStrategyRebalancer.Restrictions
expected amounts to be transferred and positions to be minted
actualAmounts
struct MultiPoolHStrategyRebalancer.Restrictions
actual transferred amounts and minted positions
PulseRouteStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
Functions
constructor
Parameters:
positionManager_
contract INonfungiblePositionManager
Uniswap v3 NonfungiblePositionManager
initialize
Parameters:
immutableParams_
struct PulseRouteStrategy.ImmutableParams
structure with all immutable params of the strategy
admin
address
admin of the strategy
updateMutableParams
📕 updates mutable params of the strategy. Only the admin can call the function
Parameters:
mutableParams_
struct PulseRouteStrategy.MutableParams
new params to set
rebalance
📕 Rebalancing goes like this:
Function checks the current states of the pools, and if the volatility is significant, the transaction reverts.
If necessary, a new position is minted on uniV3Vault, and the previous one is burned.
Tokens on erc20Vault are swapped via swapRouter so that the proportion matches the tokens on uniV3Vault.
The strategy transfers all possible tokens from erc20Vault to uniV3Vault. Only users with administrator or operator roles can call the function.
Parameters:
deadline
uint256
Timestamp by which the transaction must be completed
calculateNewInterval
📕 calculates a new interval according to the mutable params, the tickSpacing of the pool and the spot tick
Parameters:
mutableParams_
struct PulseRouteStrategy.MutableParams
structure with all mutable params of the strategy
tick
int24
current spot tick of the pool
pool
contract IUniswapV3Pool
the UniV3Vault pool where the new position will be minted
Return Values:
lowerTick
int24
lower tick of the new interval
upperTick
int24
upper tick of the new interval
checkMutableParams
📕 checks mutable params according to strategy restrictions
Parameters:
params
struct PulseRouteStrategy.MutableParams
mutable parameters to be checked
immutableParams_
struct PulseRouteStrategy.ImmutableParams
structure with all immutable params of the strategy
checkImmutableParams
📕 checks immutable params according to strategy restrictions
Parameters:
params
struct PulseRouteStrategy.ImmutableParams
immutable parameters to be checked
checkTickDeviations
Parameters:
mutableParams_
struct PulseRouteStrategy.MutableParams
structure with all mutable params of the strategy
vaultPool
contract IUniswapV3Pool
UniswapV3Pool of uniV3Vault
spotTick
int24
current spot tick of UniswapV3Pool of uniV3Vault
calculateTargetRatioOfToken1
📕 calculate target ratio of token 1 to total capital after rebalance
Parameters:
interval
struct PulseRouteStrategy.Interval
current interval on uniV3Vault
sqrtSpotPriceX96
uint160
sqrt price X96 of spot tick
spotPriceX96
uint256
price X96 of spot tick
Return Values:
targetRatioOfToken1X96
uint256
ratio of token 1 multiplied by 2^96
calculateAmountsForSwap
📕 notion link: https://www.notion.so/mellowprotocol/Swap-formula-53807cbf5c5641eda937dd1847d70f43 calculates the token that needs to be swapped and its amount to get the target ratio of tokens in the erc20Vault.
Parameters:
immutableParams_
struct PulseRouteStrategy.ImmutableParams
structure with all immutable params of the strategy
mutableParams_
struct PulseRouteStrategy.MutableParams
structure with all mutable params of the strategy
priceX96
uint256
price X96 of spot tick
targetRatioOfToken1X96
uint256
target ratio of token 1 to total capital after rebalance
Return Values:
tokenInIndex
uint256
swap token index
amountIn
uint256
number of tokens to swap
depositCallback
Function, that ERC20RootVault calling after deposit
withdrawCallback
Function, that ERC20RootVault calling after withdraw
Structs
Events
TokensSwapped
Emitted after a successful token swap
Parameters:
swapParams
struct ISwapRouter.ExactInputParams
structure with different parameters for handling swap via swapRouter
amountOut
uint256
the actual amount received from the swapRouter during swaps
UpdateMutableParams
Emited when mutable parameters are successfully updated
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
mutableParams
struct PulseRouteStrategy.MutableParams
Updated parameters
Rebalance
Emited when the rebalance is successfully completed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
PositionMinted
Emited when a new uniswap position is created
Parameters:
tokenId
uint256
nft of new uniswap position
PositionBurned
Emited when a uniswap position is burned
Parameters:
tokenId
uint256
nft of uniswap position
PulseStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
Functions
constructor
Parameters:
positionManager_
contract INonfungiblePositionManager
Uniswap v3 NonfungiblePositionManager
initialize
Parameters:
immutableParams_
struct PulseStrategy.ImmutableParams
structure with all immutable params of the strategy
admin
address
admin of the strategy
updateMutableParams
📕 updates mutable params of the strategy. Only the admin can call the function
Parameters:
mutableParams_
struct PulseStrategy.MutableParams
new params to set
rebalance
📕 Rebalancing goes like this:
Function checks the current states of the pools, and if the volatility is significant, the transaction reverts.
If necessary, a new position is minted on uniV3Vault, and the previous one is burned.
Tokens on erc20Vault are swapped via AggregationRouterV5 so that the proportion matches the tokens on uniV3Vault.
The strategy transfers all possible tokens from erc20Vault to uniV3Vault. Only users with administrator or operator roles can call the function.
Parameters:
deadline
uint256
Timestamp by which the transaction must be completed
swapData
bytes
Data for swap on 1inch AggregationRouterV5
checkMutableParams
📕 checks mutable params according to strategy restrictions
Parameters:
params
struct PulseStrategy.MutableParams
mutable parameters to be checked
immutableParams_
struct PulseStrategy.ImmutableParams
structure with all immutable params of the strategy
checkImmutableParams
📕 checks immutable params according to strategy restrictions
Parameters:
params
struct PulseStrategy.ImmutableParams
immutable parameters to be checked
checkTickDeviation
📕 checks deviation of spot ticks of all pools in strategy from corresponding average ticks. If any deviation is large than maxDevation parameter for the pool, then the transaction will be reverted with a LIMIT_OVERFLOW error. If there are no observations 10 seconds ago in any of the considered pools, then the transaction will be reverted with an INVALID_STATE error.
Parameters:
mutableParams_
struct PulseStrategy.MutableParams
structure with all mutable params of the strategy
vaultPool
contract IUniswapV3Pool
UniswapV3Pool of uniV3Vault
calculateNewPosition
Parameters:
mutableParams_
struct PulseStrategy.MutableParams
structure with all mutable params of the strategy
spotTick
int24
current spot tick of UniswapV3Pool of uniV3Vault
pool
contract IUniswapV3Pool
UniswapV3Pool of uniV3Vault
uniV3Nft
uint256
Nft of uniswap position
Return Values:
newInterval
struct PulseStrategy.Interval
expected interval after reblance
neededNewInterval
bool
flag that is true if it is needed to mint new interval
calculateTargetRatioOfToken1
📕 calculate target ratio of token 1 to total capital after rebalance
Parameters:
interval
struct PulseStrategy.Interval
current interval on uniV3Vault
sqrtSpotPriceX96
uint160
sqrt price X96 of spot tick
spotPriceX96
uint256
price X96 of spot tick
Return Values:
targetRatioOfToken1X96
uint256
ratio of token 1 multiplied by 2^96
calculateAmountsForSwap
📕 notion link: https://www.notion.so/mellowprotocol/Swap-formula-53807cbf5c5641eda937dd1847d70f43 calculates the token that needs to be swapped and its amount to get the target ratio of tokens in the erc20Vault.
Parameters:
immutableParams_
struct PulseStrategy.ImmutableParams
structure with all immutable params of the strategy
mutableParams_
struct PulseStrategy.MutableParams
structure with all mutable params of the strategy
priceX96
uint256
price X96 of spot tick
targetRatioOfToken1X96
uint256
target ratio of token 1 to total capital after rebalance
Return Values:
tokenInIndex
uint256
swap token index
amountIn
uint256
number of tokens to swap
depositCallback
Function, that ERC20RootVault calling after deposit
withdrawCallback
Function, that ERC20RootVault calling after withdraw
Structs
Events
TokensSwapped
Emitted after a successful token swap
Parameters:
amountIn
uint256
amount of token, that pushed into SwapRouter
amountOut
uint256
amount of token, that recieved from SwapRouter
tokenInIndex
uint256
index of token, that pushed into SwapRouter
UpdateMutableParams
Emited when mutable parameters are successfully updated
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
mutableParams
struct PulseStrategy.MutableParams
Updated parameters
Rebalance
Emited when the rebalance is successfully completed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
PositionMinted
Emited when a new uniswap position is created
Parameters:
tokenId
uint256
nft of new uniswap position
PositionBurned
Emited when a uniswap position is burned
Parameters:
tokenId
uint256
nft of uniswap position
PulseStrategyV2
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
Functions
constructor
Parameters:
positionManager_
contract INonfungiblePositionManager
Uniswap v3 NonfungiblePositionManager
initialize
Parameters:
immutableParams_
struct PulseStrategyV2.ImmutableParams
structure with all immutable params of the strategy
admin
address
admin of the strategy
setForceRebalanceFlag
updateDesiredAmounts
updateMutableParams
📕 updates mutable params of the strategy. Only the admin can call the function
Parameters:
mutableParams_
struct PulseStrategyV2.MutableParams
new params to set
rebalance
📕 Rebalancing goes like this:
Function checks the current states of the pools, and if the volatility is significant, the transaction reverts.
If necessary, a new position is minted on uniV3Vault, and the previous one is burned.
Tokens on erc20Vault are swapped via AggregationRouterV5 so that the proportion matches the tokens on uniV3Vault.
The strategy transfers all possible tokens from erc20Vault to uniV3Vault. Only users with administrator or operator roles can call the function.
Parameters:
deadline
uint256
Timestamp by which the transaction must be completed
swapData
bytes
Data for swap on 1inch AggregationRouterV5
checkMutableParams
📕 checks mutable params according to strategy restrictions
Parameters:
params
struct PulseStrategyV2.MutableParams
mutable parameters to be checked
immutableParams_
struct PulseStrategyV2.ImmutableParams
structure with all immutable params of the strategy
checkImmutableParams
📕 checks immutable params according to strategy restrictions
Parameters:
params
struct PulseStrategyV2.ImmutableParams
immutable parameters to be checked
checkTickDeviation
📕 checks deviation of spot ticks of all pools in strategy from corresponding average ticks. If any deviation is large than maxDevation parameter for the pool, then the transaction will be reverted with a LIMIT_OVERFLOW error. If there are no observations 10 seconds ago in any of the considered pools, then the transaction will be reverted with an INVALID_STATE error.
Parameters:
mutableParams_
struct PulseStrategyV2.MutableParams
structure with all mutable params of the strategy
vaultPool
contract IUniswapV3Pool
UniswapV3Pool of uniV3Vault
formPositionWithSpotTickInCenter
calculateNewPosition
Parameters:
mutableParams_
struct PulseStrategyV2.MutableParams
structure with all mutable params of the strategy
spotTick
int24
current spot tick of UniswapV3Pool of uniV3Vault
pool
contract IUniswapV3Pool
UniswapV3Pool of uniV3Vault
uniV3Nft
uint256
Nft of uniswap position
Return Values:
newInterval
struct PulseStrategyV2.Interval
expected interval after reblance
neededNewInterval
bool
flag that is true if it is needed to mint new interval
calculateTargetRatioOfToken1
📕 calculate target ratio of token 1 to total capital after rebalance
Parameters:
interval
struct PulseStrategyV2.Interval
current interval on uniV3Vault
sqrtSpotPriceX96
uint160
sqrt price X96 of spot tick
spotPriceX96
uint256
price X96 of spot tick
Return Values:
targetRatioOfToken1X96
uint256
ratio of token 1 multiplied by 2^96
calculateAmountsForSwap
📕 notion link: https://www.notion.so/mellowprotocol/Swap-formula-53807cbf5c5641eda937dd1847d70f43 calculates the token that needs to be swapped and its amount to get the target ratio of tokens in the erc20Vault.
Parameters:
immutableParams_
struct PulseStrategyV2.ImmutableParams
structure with all immutable params of the strategy
mutableParams_
struct PulseStrategyV2.MutableParams
structure with all mutable params of the strategy
priceX96
uint256
price X96 of spot tick
targetRatioOfToken1X96
uint256
target ratio of token 1 to total capital after rebalance
Return Values:
tokenInIndex
uint256
swap token index
amountIn
uint256
number of tokens to swap
depositCallback
Function, that ERC20RootVault calling after deposit
withdrawCallback
Function, that ERC20RootVault calling after withdraw
Structs
Events
TokensSwapped
Emitted after a successful token swap
Parameters:
amountIn
uint256
amount of token, that pushed into SwapRouter
amountOut
uint256
amount of token, that recieved from SwapRouter
tokenInIndex
uint256
index of token, that pushed into SwapRouter
UpdateMutableParams
Emited when mutable parameters are successfully updated
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
mutableParams
struct PulseStrategyV2.MutableParams
Updated parameters
Rebalance
Emited when the rebalance is successfully completed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
PositionMinted
Emited when a new uniswap position is created
Parameters:
tokenId
uint256
nft of new uniswap position
PositionBurned
Emited when a uniswap position is burned
Parameters:
tokenId
uint256
nft of uniswap position
QuickPulseStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
Functions
constructor
Parameters:
positionManager_
contract IAlgebraNonfungiblePositionManager
Algebra NonfungiblePositionManager
initialize
Parameters:
immutableParams_
struct QuickPulseStrategy.ImmutableParams
structure with all immutable params of the strategy
admin
address
admin of the strategy
updateMutableParams
📕 updates mutable params of the strategy. Only the admin can call the function
Parameters:
mutableParams_
struct QuickPulseStrategy.MutableParams
new params to set
rebalance
📕 Rebalancing goes like this:
Function checks the current states of the pools, and if the volatility is significant, the transaction reverts.
If necessary, a new position is minted on quickSwapVault, and the previous one is burned.
Tokens on erc20Vault are swapped via AggregationRouterV5 so that the proportion matches the tokens on quickSwapVault.
The strategy transfers all possible tokens from erc20Vault to quickSwapVault. Only users with administrator or operator roles can call the function.
Parameters:
deadline
uint256
Timestamp by which the transaction must be completed
swapData
bytes
Data for swap on 1inch AggregationRouterV5
checkMutableParams
📕 checks mutable params according to strategy restrictions
Parameters:
params
struct QuickPulseStrategy.MutableParams
mutable parameters to be checked
checkImmutableParams
📕 checks immutable params according to strategy restrictions
Parameters:
params
struct QuickPulseStrategy.ImmutableParams
immutable parameters to be checked
checkTickDeviation
📕 checks deviation of spot ticks of all pools in strategy from corresponding average ticks. If any deviation is large than maxDevation parameter for the pool, then the transaction will be reverted with a LIMIT_OVERFLOW error. If there are no observations 10 seconds ago in any of the considered pools, then the transaction will be reverted with an INVALID_STATE error.
Parameters:
mutableParams_
struct QuickPulseStrategy.MutableParams
structure with all mutable params of the strategy
vaultPool
contract IAlgebraPool
pool of quickSwapVault
calculateNewPosition
Parameters:
mutableParams_
struct QuickPulseStrategy.MutableParams
structure with all mutable params of the strategy
spotTick
int24
current spot tick of AlgebraPool of quickSwapVault
pool
contract IAlgebraPool
AlgebraPool of quickSwapVault
positionNft
uint256
Nft of algebra position
Return Values:
newInterval
struct QuickPulseStrategy.Interval
expected interval after reblance
neededNewInterval
bool
flag that is true if it is needed to mint new interval
calculateTargetRatioOfToken1
📕 calculate target ratio of token 1 to total capital after rebalance
Parameters:
interval
struct QuickPulseStrategy.Interval
current interval on quickSwapVault
sqrtSpotPriceX96
uint160
sqrt price X96 of spot tick
spotPriceX96
uint256
price X96 of spot tick
Return Values:
targetRatioOfToken1X96
uint256
ratio of token 1 multiplied by 2^96
calculateAmountsForSwap
📕 notion link: https://www.notion.so/mellowprotocol/Swap-formula-53807cbf5c5641eda937dd1847d70f43 calculates the token that needs to be swapped and its amount to get the target ratio of tokens in the erc20Vault.
Parameters:
immutableParams_
struct QuickPulseStrategy.ImmutableParams
structure with all immutable params of the strategy
mutableParams_
struct QuickPulseStrategy.MutableParams
structure with all mutable params of the strategy
priceX96
uint256
price X96 of spot tick
targetRatioOfToken1X96
uint256
target ratio of token 1 to total capital after rebalance
Return Values:
tokenInIndex
uint256
swap token index
amountIn
uint256
number of tokens to swap
depositCallback
Function, that ERC20RootVault calling after deposit
withdrawCallback
Function, that ERC20RootVault calling after withdraw
onERC721Received
⛽ 105K
📕 Whenever an {IERC721} tokenId
token is transferred to this contract via {IERC721-safeTransferFrom} by operator
from from
, this function is called. It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with IERC721.onERC721Received.selector
.
Structs
Events
TokensSwapped
Emitted after a successful token swap
Parameters:
amountIn
uint256
amount of token, that pushed into SwapRouter
amountOut
uint256
amount of token, that recieved from SwapRouter
tokenInIndex
uint256
index of token, that pushed into SwapRouter
UpdateMutableParams
Emited when mutable parameters are successfully updated
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
mutableParams
struct QuickPulseStrategy.MutableParams
Updated parameters
Rebalance
Emited when the rebalance is successfully completed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
PositionMinted
Emited when a new algebra position is created
Parameters:
tokenId
uint256
nft of new algebra position
PositionBurned
Emited when a algebra position is burned
Parameters:
tokenId
uint256
nft of algebra position
SinglePositionQuickSwapStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
Functions
constructor
Parameters:
uniswapV3Factory_
contract IUniswapV3Factory
Uniswap V3 pool factory
algebraPositionManager_
contract IAlgebraNonfungiblePositionManager
Algebra NonfungiblePositionManager
helper_
contract SinglePositionStrategyHelper
strategy helper
initialize
Parameters:
immutableParams_
struct SinglePositionQuickSwapStrategy.ImmutableParams
structure with all immutable params of the strategy
admin
address
admin of the strategy
updateMutableParams
📕 updates mutable params of the strategy. Only the admin can call the function
Parameters:
mutableParams_
struct SinglePositionQuickSwapStrategy.MutableParams
new params to set
rebalance
📕 Rebalancing goes like this:
Function checks the current states of the pools, and if the volatility is significant, the transaction reverts.
If necessary, a new position is minted on quickSwapVault, and the previous one is burned.
Tokens on erc20Vault are swapped via swapRouter so that the proportion matches the tokens on quickSwapVault.
The strategy transfers all possible tokens from erc20Vault to quickSwapVault. Only users with administrator or operator roles can call the function.
Parameters:
deadline
uint256
Timestamp by which the transaction must be completed
calculateNewInterval
📕 calculates a new interval according to the mutable params, the tickSpacing of the pool and the spot tick
Parameters:
mutableParams_
struct SinglePositionQuickSwapStrategy.MutableParams
structure with all mutable params of the strategy
tick
int24
current spot tick of the pool
pool
contract IAlgebraPool
the quickSwapVault pool where the new position will be minted
Return Values:
lowerTick
int24
lower tick of the new interval
upperTick
int24
upper tick of the new interval
checkMutableParams
📕 checks mutable params according to strategy restrictions
Parameters:
params
struct SinglePositionQuickSwapStrategy.MutableParams
mutable parameters to be checked
checkImmutableParams
📕 checks immutable params according to strategy restrictions
Parameters:
params
struct SinglePositionQuickSwapStrategy.ImmutableParams
immutable parameters to be checked
checkTickDeviations
📕 checks deviation of spot ticks of all pools in strategy from corresponding average ticks. If any deviation is large than maxDevation parameter for the pool, then the transaction will be reverted with a LIMIT_OVERFLOW error. If there are no observations 10 seconds ago in any of the considered pools, then the transaction will be reverted with an INVALID_STATE error.
Parameters:
immutableParams_
struct SinglePositionQuickSwapStrategy.ImmutableParams
structure with all immutable params of the strategy
mutableParams_
struct SinglePositionQuickSwapStrategy.MutableParams
structure with all mutable params of the strategy
vaultPool
contract IAlgebraPool
UniswapV3Pool of quickSwapVault
calculateTargetRatioOfToken1
📕 calculate target ratio of token 1 to total capital after rebalance
Parameters:
interval
struct SinglePositionQuickSwapStrategy.Interval
current interval on quickSwapVault
sqrtSpotPriceX96
uint160
sqrt price X96 of spot tick
spotPriceX96
uint256
price X96 of spot tick
Return Values:
targetRatioOfToken1X96
uint256
ratio of token 1 multiplied by 2^96
calculateAmountsForSwap
📕 notion link: https://www.notion.so/mellowprotocol/Swap-formula-53807cbf5c5641eda937dd1847d70f43 calculates the token that needs to be swapped and its amount to get the target ratio of tokens in the erc20Vault.
Parameters:
immutableParams_
struct SinglePositionQuickSwapStrategy.ImmutableParams
structure with all immutable params of the strategy
mutableParams_
struct SinglePositionQuickSwapStrategy.MutableParams
structure with all mutable params of the strategy
priceX96
uint256
price X96 of spot tick
targetRatioOfToken1X96
uint256
target ratio of token 1 to total capital after rebalance
Return Values:
tokenInIndex
uint256
swap token index
amountIn
uint256
number of tokens to swap
depositCallback
Function, that ERC20RootVault calling after deposit
withdrawCallback
Function, that ERC20RootVault calling after withdraw
Structs
Events
TokensSwapped
Emitted after a successful token swap
Parameters:
swapParams
struct ISwapRouter.ExactInputParams
structure with different parameters for handling swap via swapRouter
amountOut
uint256
the actual amount received from the swapRouter during swaps
UpdateMutableParams
Emited when mutable parameters are successfully updated
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
mutableParams
struct SinglePositionQuickSwapStrategy.MutableParams
Updated parameters
Rebalance
Emited when the rebalance is successfully completed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
PositionMinted
Emited when a new uniswap position is created
Parameters:
tokenId
uint256
nft of new uniswap position
PositionBurned
Emited when a uniswap position is burned
Parameters:
tokenId
uint256
nft of uniswap position
SinglePositionStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
⛽ 7.31M
Functions
constructor
Parameters:
positionManager_
contract INonfungiblePositionManager
Uniswap v3 NonfungiblePositionManager
Specs
✅ creates contract
initialize
⛽ 671K
Parameters:
immutableParams_
struct SinglePositionStrategy.ImmutableParams
structure with all immutable params of the strategy
admin
address
admin of the strategy
updateMutableParams
⛽ 120K (89K - 245K)
📕 updates mutable params of the strategy. Only the admin can call the function
Parameters:
mutableParams_
struct SinglePositionStrategy.MutableParams
new params to set
rebalance
⛽ 1.16M (804K - 1.38M)
📕 Rebalancing goes like this:
Function checks the current states of the pools, and if the volatility is significant, the transaction reverts.
If necessary, a new position is minted on uniV3Vault, and the previous one is burned.
Tokens on erc20Vault are swapped via swapRouter so that the proportion matches the tokens on uniV3Vault.
The strategy transfers all possible tokens from erc20Vault to uniV3Vault. Only users with administrator or operator roles can call the function.
Parameters:
deadline
uint256
Timestamp by which the transaction must be completed
Specs
✅ works correctly
calculateNewInterval
📕 calculates a new interval according to the mutable params, the tickSpacing of the pool and the spot tick
Parameters:
mutableParams_
struct SinglePositionStrategy.MutableParams
structure with all mutable params of the strategy
tick
int24
current spot tick of the pool
pool
contract IUniswapV3Pool
the UniV3Vault pool where the new position will be minted
Return Values:
lowerTick
int24
lower tick of the new interval
upperTick
int24
upper tick of the new interval
checkMutableParams
📕 checks mutable params according to strategy restrictions
Parameters:
params
struct SinglePositionStrategy.MutableParams
mutable parameters to be checked
immutableParams_
struct SinglePositionStrategy.ImmutableParams
structure with all immutable params of the strategy
checkImmutableParams
📕 checks immutable params according to strategy restrictions
Parameters:
params
struct SinglePositionStrategy.ImmutableParams
immutable parameters to be checked
checkTickDeviations
📕 checks deviation of spot ticks of all pools in strategy from corresponding average ticks. If any deviation is large than maxDevation parameter for the pool, then the transaction will be reverted with a LIMIT_OVERFLOW error. If there are no observations 10 seconds ago in any of the considered pools, then the transaction will be reverted with an INVALID_STATE error.
Parameters:
immutableParams_
struct SinglePositionStrategy.ImmutableParams
structure with all immutable params of the strategy
mutableParams_
struct SinglePositionStrategy.MutableParams
structure with all mutable params of the strategy
vaultPool
contract IUniswapV3Pool
UniswapV3Pool of uniV3Vault
calculateTargetRatioOfToken1
📕 calculate target ratio of token 1 to total capital after rebalance
Parameters:
interval
struct SinglePositionStrategy.Interval
current interval on uniV3Vault
sqrtSpotPriceX96
uint160
sqrt price X96 of spot tick
spotPriceX96
uint256
price X96 of spot tick
Return Values:
targetRatioOfToken1X96
uint256
ratio of token 1 multiplied by 2^96
calculateAmountsForSwap
📕 notion link: https://www.notion.so/mellowprotocol/Swap-formula-53807cbf5c5641eda937dd1847d70f43 calculates the token that needs to be swapped and its amount to get the target ratio of tokens in the erc20Vault.
Parameters:
immutableParams_
struct SinglePositionStrategy.ImmutableParams
structure with all immutable params of the strategy
mutableParams_
struct SinglePositionStrategy.MutableParams
structure with all mutable params of the strategy
priceX96
uint256
price X96 of spot tick
targetRatioOfToken1X96
uint256
target ratio of token 1 to total capital after rebalance
Return Values:
tokenInIndex
uint256
swap token index
amountIn
uint256
number of tokens to swap
depositCallback
Function, that ERC20RootVault calling after deposit
withdrawCallback
Function, that ERC20RootVault calling after withdraw
Structs
Events
TokensSwapped
Emitted after a successful token swap
Parameters:
swapParams
struct ISwapRouter.ExactInputParams
structure with different parameters for handling swap via swapRouter
amountOut
uint256
the actual amount received from the swapRouter during swaps
UpdateMutableParams
Emited when mutable parameters are successfully updated
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
mutableParams
struct SinglePositionStrategy.MutableParams
Updated parameters
Rebalance
Emited when the rebalance is successfully completed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
PositionMinted
Emited when a new uniswap position is created
Parameters:
tokenId
uint256
nft of new uniswap position
PositionBurned
Emited when a uniswap position is burned
Parameters:
tokenId
uint256
nft of uniswap position
BatchCall
⛽ 435K
batchcall
⛽ 23K
Specs
✅ returns results
✅ edge cases: when arrays have different lengths reverts with INVL
✅ edge cases: when targets arrays not only of contracts reverts with "Address: delegate call to non-contract"
ContractMeta
contractName
contractNameBytes
contractVersion
contractVersionBytes
DefaultAccessControl
Inherits from AccessControlEnumerable, AccessControl, ERC165, Context
⛽ 1.35M
This is a default access control with 3 roles:
ADMIN: allowed to do anything
ADMIN_DELEGATE: allowed to do anything except assigning ADMIN and ADMIN_DELEGATE roles
OPERATOR: low-privileged role, generally keeper or some other bot
Functions
constructor
Creates a new contract.
Parameters:
admin
address
Admin of the contract
isAdmin
Checks if the address is ADMIN or ADMIN_DELEGATE.
Parameters:
sender
address
Adddress to check
Return Values:
if
bool
sender is an admin, false
otherwise
isOperator
Checks if the address is OPERATOR.
Parameters:
sender
address
Adddress to check
Return Values:
if
bool
sender is an admin, false
otherwise
Structs
DefaultAccessControlLateInit
Inherits from AccessControlEnumerable, AccessControl, ERC165, Context
⛽ 1.25M
This is a default access control with 3 roles:
ADMIN: allowed to do anything
ADMIN_DELEGATE: allowed to do anything except assigning ADMIN and ADMIN_DELEGATE roles
OPERATOR: low-privileged role, generally keeper or some other bot
Functions
isAdmin
Checks that the address is contract admin.
Parameters:
who
address
Address to check
Return Values:
if
bool
who is admin, false
otherwise
Specs
✅ returns
true
if sender is an admin,false
otherwise
isOperator
Checks that the address is contract admin.
Parameters:
who
address
Address to check
Return Values:
if
bool
who is operator, false
otherwise
Specs
✅ returns
true
if sender is an operator,false
otherwise
init
⛽ 301K
Initializes a new contract with roles and single ADMIN.
Parameters:
admin
address
Admin of the contract
Structs
DefaultProxy
Inherits from TransparentUpgradeableProxy, ERC1967Proxy, ERC1967Upgrade, Proxy
constructor
DefaultProxyAdmin
Inherits from ProxyAdmin, Ownable, Context
ERC20RootVaultHelper
⛽ 445K
getTvlToken0
ERC20Token
⛽ 1.01M
DOMAIN_SEPARATOR
Specs
✅ returns domaint separator
approve
Specs
✅ allows
sender
to transferspender
anamount
and emits Approval
transfer
Specs
✅ transfers
amount
frommsg.sender
toto
✅ rom transfers
amount
fromfrom
toto
if allowed
transferFrom
Specs
✅ transfers
amount
fromfrom
toto
if allowed
permit
Specs
✅ emits Approval
✅ edge cases: when deadline less than current timestamp reverts with TS
✅ edge cases: when incorrect signature reverts with FRB
GearboxHelper
Functions
setParameters
verifyInstances
calculateEarnedCvxAmountByEarnedCrvAmount
calculateClaimableRewards
calculateDesiredTotalValue
calcConvexTokensToWithdraw
calcRateRAY
calculateAmountInMaximum
createUniswapMulticall
checkNecessaryDepositExchange
claimRewards
withdrawFromConvex
depositToConvex
adjustPosition
swapExactOutput
pullFromAddress
openCreditAccount
Events
CreditAccountOpened
Emitted when a credit account linked to this vault is opened in Gearbox
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
creditAccount
address
Address of the opened credit account
PositionAdjusted
Emitted when an adjusment of the position made in Gearbox
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
newTotalAssetsValue
uint256
New value of all assets (debt + real assets) of the vault
HStrategyHelper
⛽ 3.26M
calculateExpectedRatios
calculates the ratios of the capital on all vaults using price from the oracle
Parameters:
domainPositionParams
struct HStrategy.DomainPositionParams
the current state of the position, pool and oracle prediction
Return Values:
ratios
struct HStrategy.ExpectedRatios
ratios of the capital
calculateMissingTokenAmounts
calculates amount of missing tokens for uniV3 and money vaults
Parameters:
moneyVault
contract IIntegrationVault
the strategy money vault
expectedTokenAmounts
struct HStrategy.TokenAmounts
the amount of tokens we expect after rebalance
domainPositionParams
struct HStrategy.DomainPositionParams
current position and pool state combined with predictions from the oracle
liquidity
uint128
current liquidity in position
Return Values:
missingTokenAmounts
struct HStrategy.TokenAmounts
amounts of missing tokens
calculateExtraTokenAmountsForUniV3Vault
calculates extra tokens on uniV3 vault
Parameters:
expectedTokenAmounts
struct HStrategy.TokenAmounts
the amount of tokens we expect after rebalance
domainPositionParams
struct HStrategy.DomainPositionParams
current position and pool state combined with predictions from the oracle
Return Values:
tokenAmounts
uint256[]
extra token amounts on UniV3Vault
calculateExtraTokenAmountsForMoneyVault
calculates extra tokens on money vault
Parameters:
moneyVault
contract IIntegrationVault
the strategy money vault
expectedTokenAmounts
struct HStrategy.TokenAmounts
the amount of tokens we expect after rebalance
Return Values:
tokenAmounts
uint256[]
extra token amounts on MoneyVault
calculateExpectedTokenAmountsByExpectedRatios
calculates expected amounts of tokens after rebalance
Parameters:
expectedRatios
struct HStrategy.ExpectedRatios
ratios of the capital on different assets
expectedTokenAmountsInToken0
struct HStrategy.TokenAmountsInToken0
expected capitals (in token0) on the strategy vaults
domainPositionParams
struct HStrategy.DomainPositionParams
current position and pool state combined with predictions from the oracle
uniV3Helper
contract UniV3Helper
helper for uniswap V3 calculations
Return Values:
amounts
struct HStrategy.TokenAmounts
amounts of tokens expected after rebalance on the strategy vaults
calculateCurrentTokenAmounts
calculates current amounts of tokens
Parameters:
erc20Vault
contract IIntegrationVault
the erc20 vault of the strategy
moneyVault
contract IIntegrationVault
the money vault of the strategy
params
struct HStrategy.DomainPositionParams
current position and pool state combined with predictions from the oracle
Return Values:
amounts
struct HStrategy.TokenAmounts
amounts of tokens
calculateCurrentCapitalInToken0
calculates current capital of the strategy in token0
Parameters:
params
struct HStrategy.DomainPositionParams
current position and pool state combined with predictions from the oracle
currentTokenAmounts
struct HStrategy.TokenAmounts
amounts of the tokens on the erc20 and money vaults
Return Values:
capital
uint256
total capital measured in token0
calculateExpectedTokenAmountsInToken0
calculates expected capitals on the vaults after rebalance
Parameters:
totalCapitalInToken0
uint256
total capital in token0
expectedRatios
struct HStrategy.ExpectedRatios
ratios of the capitals on the vaults expected after rebalance
ratioParams_
struct HStrategy.RatioParams
ratio of the tokens between erc20 and money vault combined with needed deviations for rebalance to be called
Return Values:
amounts
struct HStrategy.TokenAmountsInToken0
capitals expected after rebalance measured in token0
swapNeeded
return true if the token swap is needed. It is needed if we cannot mint a new position without it
Parameters:
currentTokenAmounts
struct HStrategy.TokenAmounts
the amounts of tokens on the vaults
expectedTokenAmounts
struct HStrategy.TokenAmounts
the amounts of tokens expected after rebalancing
ratioParams
struct HStrategy.RatioParams
ratio of the tokens between erc20 and money vault combined with needed deviations for rebalance to be called
domainPositionParams
struct HStrategy.DomainPositionParams
the current state of the position, pool and oracle prediction
Return Values:
needed
bool
true if the token swap is needed
tokenRebalanceNeeded
returns true if the rebalance between assets on different vaults is needed
Parameters:
currentTokenAmounts
struct HStrategy.TokenAmounts
the current amounts of tokens on the vaults
expectedTokenAmounts
struct HStrategy.TokenAmounts
the amounts of tokens expected after rebalance
ratioParams
struct HStrategy.RatioParams
ratio of the tokens between erc20 and money vault combined with needed deviations for rebalance to be called
Return Values:
needed
bool
true if the rebalance is needed
calculateAndCheckDomainPositionParams
Parameters:
tick
int24
current price tick
strategyParams_
struct HStrategy.StrategyParams
the current parameters of the strategy
uniV3Nft
uint256
the nft of the position from position manager
positionManager_
contract INonfungiblePositionManager
the position manager for uniV3
checkSpotTickDeviationFromAverage
Parameters:
tick
int24
current price tick
pool_
address
address of uniV3 pool
oracleParams_
struct HStrategy.OracleParams
oracle parameters
uniV3Helper
contract UniV3Helper
helper for uniswap V3 calculations
calculateNewPositionTicks
Parameters:
spotTick
int24
current price tick
strategyParams_
struct HStrategy.StrategyParams
parameters of strategy
Return Values:
lowerTick
int24
lower tick of new position
upperTick
int24
upper tick of new position
calculateExpectedTokenAmounts
Parameters:
currentTokenAmounts
struct HStrategy.TokenAmounts
current token amounts on vaults in both tokens
domainPositionParams
struct HStrategy.DomainPositionParams
the current state of the position, pool and oracle prediction
hStrategyHelper_
contract HStrategyHelper
address of HStrategyHelper
uniV3Helper
contract UniV3Helper
helper for uniswap V3 calculations
ratioParams
struct HStrategy.RatioParams
ratio parameters
Return Values:
expectedTokenAmounts
struct HStrategy.TokenAmounts
expected amounts of tokens after rebalance on vaults
LStrategyHelper
⛽ 1.5M
constructor
checkOrder
tickFromPriceX96
MultiPoolHStrategyRebalancer
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context
⛽ 7.09M
Functions
constructor
constructs a rebalancer
Parameters:
positionManager_
contract INonfungiblePositionManager
Uniswap V3 NonfungiblePositionManager
initialize
initializes the rebalancer
Parameters:
strategy
address
address of the strategy for current rebalancer
createRebalancer
creates the clone of the rebalancer
Parameters:
strategy
address
address of the strategy for new rebalancer
Return Values:
rebalancer
contract MultiPoolHStrategyRebalancer
new cloned rebalancer for given strategy
getTvls
Parameters:
data
struct MultiPoolHStrategyRebalancer.StrategyData
structure with all immutable, mutable and internal params of the strategy
processRebalance
Parameters:
data
struct MultiPoolHStrategyRebalancer.StrategyData
structure with all immutable, mutable and internal params of the strategy
restrictions
struct MultiPoolHStrategyRebalancer.Restrictions
rebalance restrictions
calculateExpectedAmounts
Parameters:
sqrtPriceX96
struct MultiPoolHStrategyRebalancer.StrategyData
sqrt prices X96 at lower and upper ticks of domain and short intervals
sqrtPriceX96
uint160
sqrt price X96 at current spot tick in swapPool
totalToken0
uint256
current actual amount of token 0 in the root vault system
totalToken1
uint256
current actual amount of token 1 in the root vault system
calculateNewPosition
Parameters:
data
struct MultiPoolHStrategyRebalancer.StrategyData
structure with all immutable, mutable and internal params of the strategy
tick
int24
current spot tick of swapPool
Structs
Events
PositionsMinted
Emitted when new short positions minted in uniV3Vaults
Parameters:
uniV3Nfts
uint256[]
nfts of minted positions
PositionsBurned
Emitted when old short positions burned in uniV3Vaults
Parameters:
uniV3Nfts
uint256[]
nfts of burned positions
TokensSwapped
Emitted when a swap is called on the router
Parameters:
swapParams
struct ISwapRouter.ExactInputSingleParams
parameters to process swap with UniswapV3 router
amountOut
uint256
recived amount of token during the swap
PulseStrategyHelper
getStrategyParams
calculateAmountForSwap
PulseStrategyV2Helper
getStrategyParams
calculateAmountForSwap
QuickPulseStrategyHelper
getStrategyParams
calculateAmountForSwap
QuickSwapHelper
constructor
calculateTvl
liquidityToTokenAmounts
tokenAmountsToLiquidity
tokenAmountsToMaxLiquidity
calculateLiquidityToPull
increaseCumulative
calculateInnerFeesGrow
calculateCollectableRewards
convertTokenToUnderlying
SinglePositionStrategyHelper
checkUniV3PoolState
checkAlgebraPoolState
UniV3Helper
⛽ 2.82M
constructor
liquidityToTokenAmounts
Specs
✅ returns correct vaulues for type(uint128).max
tokenAmountsToLiquidity
tokenAmountsToMaximalLiquidity
getPoolByNft
📕 returns with "Invalid Token ID" for non-existent nfts
getFeesByNft
📕 returns with "Invalid Token ID" for non-existent nfts
calculateTvlBySqrtPriceX96
📕 returns with "Invalid Token ID" for non-existent nfts
calculateTvlByMinMaxPrices
📕 returns with "Invalid Token ID" for non-existent nfts
getTickDeviationForTimeSpan
Specs
✅ returns withFail=true if there is no observation in the pool that was not made before secondsAgo
getPositionTokenAmountsByCapitalOfToken0
📕 calculates the distribution of tokens that can be added to the position after swap for given capital in token 0
Specs
✅ test uniV3Helper, borders: -600 0
✅ test uniV3Helper, borders: 600 1200
✅ test uniV3Helper, borders: -600 600
WhiteList
Inherits from DefaultAccessControl, AccessControlEnumerable, AccessControl, ERC165, Context
⛽ 2.49M
Functions
constructor
deposit
⛽ 483K
Specs
✅ works correctly
✅ reverts on wrong address
updateRoot
⛽ 47K
Structs
Events
Deposit
Emitted when liquidity is deposited
Parameters:
from
address
The source address for the liquidity
tokens
address
ERC20 tokens deposited
actualTokenAmounts
address[]
Token amounts deposited
lpTokenMinted
uint256[]
LP tokens received by the liquidity provider
AllowAllValidator
Inherits from Validator, BaseValidator, ERC165, ContractMeta
⛽ 851K
Functions
constructor
Specs
✅ deploys a new contract
validate
Specs
✅ successful validate
Structs
BaseValidator
Functions
constructor
stagedValidatorParams
Validator params staged to commit.
stagedValidatorParamsTimestamp
Timestamp after which validator params can be committed.
validatorParams
Current validator params.
stageValidatorParams
Stages params that could have been committed after governance delay expires.
Parameters:
newParams
struct IBaseValidator.ValidatorParams
Params to stage
commitValidatorParams
Commits staged params
Structs
Events
StagedValidatorParams
Emitted when new params are staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
newParams
struct IBaseValidator.ValidatorParams
New params that were staged for commit
when
uint256
When the params could be committed
CommittedValidatorParams
Emitted when new params are staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IBaseValidator.ValidatorParams
New params that were staged for commit
CowswapValidator
Inherits from Validator, BaseValidator, ERC165, ContractMeta
⛽ 909K
Functions
constructor
Specs
✅ deploys a new contract
validate
Specs
✅ successful validate
✅ edge cases: when selector is not 0xec6cb13f reverts with INVS
Structs
CurveValidator
Inherits from Validator, BaseValidator, ERC165, ContractMeta
⛽ 1.14M
Functions
constructor
Specs
✅ deploys a new contract
validate
Specs
✅ successful validate
✅ edge cases: when selector is not 0x3df02124 reverts with INVS
✅ edge cases: when token ids are equal reverts with INV
✅ edge cases: when not a vault token reverts with INVTO
✅ edge cases: when pool has no approve permission reverts with FRB
Structs
ERC20Validator
Inherits from Validator, BaseValidator, ERC165, ContractMeta
⛽ 1.14M
Functions
constructor
Specs
✅ deploys a new contract
validate
Specs
✅ successful validate, spender can approve
✅ successful validate, sender is trusted strategy
✅ edge cases: when value is not zero reverts with INV
✅ edge cases: when selector is not 0x095ea7b3 reverts with INVS
✅ edge cases: when no transfer permission reverts with FRB
✅ edge cases: when no approve permission reverts with FRB
Structs
QuickSwapValidator
Inherits from Validator, BaseValidator, ERC165, ContractMeta
Functions
constructor
validate
Structs
UniV2Validator
Inherits from Validator, BaseValidator, ERC165, ContractMeta
⛽ 1.58M
Functions
constructor
Specs
✅ deploys a new contract
validate
Specs
✅ selector is 0x7ff36ab5 or 0xfb3bdb41 successful validate
✅ selector is 0x7ff36ab5 or 0xfb3bdb41 edge cases: when addr is not swap reverts with INVTR
✅ selector is 0x7ff36ab5 or 0xfb3bdb41 edge cases: when selector is wrong reverts with INVS
✅ selector is 0x7ff36ab5 or 0xfb3bdb41 edge cases: when path is too small reverts with INVL
✅ selector is 0x7ff36ab5 or 0xfb3bdb41 edge cases: when not a vault token reverts with INVTO
✅ selector is 0x7ff36ab5 or 0xfb3bdb41 edge cases: when tokens are the same reverts with INVTO
✅ selector is 0x7ff36ab5 or 0xfb3bdb41 edge cases: when pool has no approve permission reverts with FRB
✅ selector is 0x7ff36ab5 or 0xfb3bdb41 edge cases: when sender is not a reciever reverts
✅ selector is one of: 0x4a25d94a, 0x18cbafe5, 0x38ed1739, 0x8803dbee successful validate
✅ selector is one of: 0x4a25d94a, 0x18cbafe5, 0x38ed1739, 0x8803dbee edge cases: when value is not zero reverts with INV
✅ selector is one of: 0x4a25d94a, 0x18cbafe5, 0x38ed1739, 0x8803dbee edge cases: when sender is not reciever reverts
✅ selector is one of: 0x4a25d94a, 0x18cbafe5, 0x38ed1739, 0x8803dbee edge cases: when path too small reverts with INVL
✅ selector is one of: 0x4a25d94a, 0x18cbafe5, 0x38ed1739, 0x8803dbee edge cases: when not a vault token reverts with INVTO
✅ selector is one of: 0x4a25d94a, 0x18cbafe5, 0x38ed1739, 0x8803dbee edge cases: when tokens are the same reverts with INVTO
✅ selector is one of: 0x4a25d94a, 0x18cbafe5, 0x38ed1739, 0x8803dbee edge cases: when pool has no approve permission reverts with FRB
Structs
UniV3Validator
Inherits from Validator, BaseValidator, ERC165, ContractMeta
⛽ 1.75M
Functions
constructor
Specs
✅ deploys a new contract
validate
Specs
✅ edge cases: if addr is not swap reverts with INVTR
✅ edge cases: if value is not zero reverts with INV
✅ edge cases: if selector is wrong reverts with INVS
✅ selector is 0x414bf389 successful validate
✅ selector is 0x414bf389 edge cases: if recipient is not sender reverts with INVTR
✅ selector is 0x414bf389 edge cases: if not a vault token reverts with INVTO
✅ selector is 0x414bf389 edge cases: if tokens are the same reverts with INVTO
✅ selector is 0x414bf389 edge cases: if pool has no permisson reverts with FRB
✅ selector is 0xdb3e2198 successfull validate
✅ selector is 0xdb3e2198 edge cases: if recipient is not sender reverts with INVTR
✅ selector is 0xdb3e2198 edge cases: if not a vault token reverts with INVTO
✅ selector is 0xdb3e2198 edge cases: if tokens are the same reverts with INVTO
✅ selector is 0xdb3e2198 edge cases: if pool has no permisson reverts with FRB
✅ selector is 0xc04b8d59 successfull validate
✅ selector is 0xc04b8d59 edge cases: if recipient is not sender reverts with INVTR
✅ selector is 0xc04b8d59 edge cases: if tokens are the same reverts with INVTO
✅ selector is 0xc04b8d59 edge cases: if pool has no approve permission reverts with FRB
✅ selector is 0xc04b8d59 edge cases: if not a vault token reverts with INVTO
✅ selector is 0xf28c0498 successfull validate
✅ selector is 0xf28c0498 edge cases: if recipient is not sender reverts with INVTR
✅ selector is 0xf28c0498 edge cases: if tokens are the same reverts with INVTO
✅ selector is 0xf28c0498 edge cases: if pool has no approve permission reverts with FRB
✅ selector is 0xf28c0498 edge cases: if not a vault token reverts with INVTO
Structs
Validator
Inherits from BaseValidator, ERC165
Functions
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.
Structs
AaveVault
Inherits from Vault, ERC165, ReentrancyGuard
⛽ 4.96M
Vault that interfaces Aave protocol in the integration layer.
📕 Notes: TVL
The TVL of the vault is cached and updated after each deposit withdraw. So essentially tvl
call doesn't take into account accrued interest / donations to Aave since the last deposit
/ withdraw
aTokens aTokens are fixed at the token creation and addresses are taken from Aave Lending Pool. So essentially each aToken is fixed for life of the AaveVault. If the aToken is missing for some vaultToken, the AaveVault cannot be created.
Push / Pull It is assumed that any amounts of tokens can be deposited / withdrawn from Aave. The contract's vaultTokens are fully allowed to Aave Lending Pool.
tvl
Total value locked for this contract.
📕 Generally it is the underlying token value of this contract in some other DeFi protocol. For example, for USDC Yearn Vault this would be total USDC balance that could be withdrawn for Yearn to this contract. The tvl itself is estimated in some range. Sometimes the range is exact, sometimes it's not
Return Values:
minTokenAmounts
uint256[]
Lower bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
maxTokenAmounts
uint256[]
Upper bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
Specs
✅ returns total value locked
✅ returns total value locked, no time passed from initialization
✅ edge cases: when there are no initial funds returns zeroes
lendingPool
Reference to Aave protocol lending pool.
Specs
✅ returns ILendingPool
✅ access control: allowed: any address
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 if this contract supports 0x18026500 interface
✅ access control: allowed: any address
✅ returns true if this contract supports 0x7a63aa3a interface
✅ access control: allowed: any address
✅ edge cases: when contract does not support the given interface returns false
updateTvls
⛽ 94K (93K - 95K)
Update all tvls to current aToken balances.
Specs
✅ updates total value locked
initialize
⛽ 200K (159K - 245K)
Initialized a new contract.
📕 Can only be initialized by vault governance
Parameters:
nft_
uint256
NFT of the vault in the VaultRegistry
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
Specs
✅ emits Initialized event
✅ initializes contract successfully
✅ edge cases: when vault's nft is not 0 reverts with INIT
✅ edge cases: when tokens are not sorted reverts with INVA
✅ edge cases: when tokens are not unique reverts with INVA
✅ edge cases: when setting zero nft reverts with VZ
✅ edge cases: when setting token with address zero reverts with AZ
✅ edge cases: when token has no permission to become a vault token reverts with FRB
AaveVaultGovernance
Inherits from VaultGovernance, ERC165, ContractMeta
⛽ 2.31M
Governance that manages all Aave Vaults params and can deploy a new Aave Vault.
Functions
constructor
Creates a new contract.
Parameters:
internalParams_
struct IVaultGovernance.InternalParams
Initial Internal Params
delayedProtocolParams_
struct IAaveVaultGovernance.DelayedProtocolParams
Initial Protocol Params
Specs
✅ deploys a new contract
✅ initializes internalParams
Edge cases
✅ when lendingPool address is 0 reverts
✅ when estimatedAaveAPY is 0 reverts
✅ when estimatedAaaveAPY is larger than limit reverts
✅ when protocolGovernance address is 0 reverts
✅ when vaultRegistry address is 0 reverts
delayedProtocolParams
Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
Specs
✅ returns current DelayedProtocolParams
Access control
✅ allowed: any address
Properties
✅ staging DelayedProtocolParams doesn't change delayedProtocolParams
Edge cases
✅ when no params were committed returns non-zero params initialized in 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.
Specs
✅ returns true if this contract supports 0x2f8c3ff3 interface
✅ access control: allowed: any address
stagedDelayedProtocolParams
Delayed Protocol Params staged for commit after delay.
Specs
✅ returns DelayedProtocolParams staged for commit
Access control
✅ allowed: any address
Properties
✅ always equals to params that were just staged
Edge cases
✅ when no params are staged for commit returns zero struct
✅ when params were just committed returns zero struct
stageDelayedProtocolParams
⛽ 88K (52K - 129K)
Stage Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
📕 Can only be called after delayedProtocolParamsTimestamp.
Parameters:
params
struct IAaveVaultGovernance.DelayedProtocolParams
New params
Specs
✅ stages DelayedProtocolParams for commit
✅ sets delay for commit
✅ emits StageDelayedProtocolParams event
Access control
✅ allowed: ProtocolGovernance admin
✅ denied: Vault NFT Owner (aka liquidity provider)
✅ denied: Vault NFT Approved (aka strategy)
✅ denied: deployer
✅ denied: random address
Properties
✅ cannot be called by random address
Edge cases
✅ when estimated Aave APY is larger than limit reverts
✅ when called twice succeeds with the last value
✅ when called with zero params reverts with zero params
commitDelayedProtocolParams
⛽ 50K (49K - 54K)
Commit Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
Specs
✅ commits staged DelayedProtocolParams
✅ resets delay for commit
✅ emits CommitDelayedProtocolParams event
Access control
✅ allowed: ProtocolGovernance admin
✅ denied: Vault NFT Owner (aka liquidity provider)
✅ denied: Vault NFT Approved (aka strategy)
✅ denied: deployer
✅ denied: random address
Properties
✅ cannot be called by random address
✅ reverts if called before the delay has elapsed
✅ succeeds if called after the delay has elapsed
Edge cases
✅ when called twice reverts
✅ when nothing is staged reverts
✅ when delay has not elapsed reverts
createVault
⛽ 729K (665K - 942K)
Deploys a new vault.
Parameters:
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
owner_
address
Owner of the vault NFT
Specs
✅ deploys a new vault
✅ registers vault with vault registry and issues nft
✅ the nft is owned by the owner from #createVault arguments
✅ vault is initialized with nft
Access control
✅ when permissionless allowed: any address
✅ when not permissionless allowed: protocol governance admin
✅ when not permissionless denied: any address
Structs
Events
StageDelayedProtocolParams
Emitted when new DelayedProtocolParams are staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IAaveVaultGovernance.DelayedProtocolParams
New params that were staged for commit
when
uint256
When the params could be committed
CommitDelayedProtocolParams
Emitted when new DelayedProtocolParams are committed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IAaveVaultGovernance.DelayedProtocolParams
New params that are committed
AggregateVault
Vault that combines several integration layer Vaults into one Vault.
subvaultNfts
Get all subvalutNfts in the current Vault
Return Values:
subvaultNfts
uint256[]
Subvaults of NTFs
subvaultOneBasedIndex
Get index of subvault by nft
Parameters:
nft_
uint256
Nft for getting subvault
Return Values:
index
uint256
Index of subvault
hasSubvault
Checks if subvault is present
Parameters:
nft_
uint256
index of subvault for check
Return Values:
if
bool
subvault present, false
otherwise
subvaultAt
Get subvault by index
Parameters:
index
uint256
Index of subvault
Return Values:
address
address
Address of the contract
tvl
Total value locked for this contract.
📕 Generally it is the underlying token value of this contract in some other DeFi protocol. For example, for USDC Yearn Vault this would be total USDC balance that could be withdrawn for Yearn to this contract. The tvl itself is estimated in some range. Sometimes the range is exact, sometimes it's not
Return Values:
minTokenAmounts
uint256[]
Lower bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
maxTokenAmounts
uint256[]
Upper bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
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.
ERC20RootVault
Inherits from AggregateVault, Vault, ERC165, ReentrancyGuard, ERC20Token
⛽ 7.12M
Contract that mints and burns LP tokens in exchange for ERC20 liquidity.
Functions
depositorsAllowlist
List of addresses of depositors from which interaction with private vaults is allowed
Specs
✅ returns non zero length of depositorsAllowlist
✅ access control: allowed: any address
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 if this contract supports 0x23040f0a interface
✅ edge cases: when contract does not support the given interface returns false
✅ access control: allowed: any address
addDepositorsToAllowlist
⛽ 112K (22K - 126K)
Add new depositors in the depositorsAllowlist
📕 The action can be done only by user with admins, owners or by approved rights
Parameters:
depositors
address[]
Array of new depositors
Specs
✅ adds depositor to allow list
✅ access control: allowed: admin
✅ access control: not allowed: deployer
✅ access control: not allowed: any address
removeDepositorsFromAllowlist
⛽ 50K (49K - 53K)
Remove depositors from the depositorsAllowlist
📕 The action can be done only by user with admins, owners or by approved rights
Parameters:
depositors
address[]
Array of depositors for remove
Specs
✅ removes depositor to allow list
✅ access control: allowed: admin
✅ access control: not allowed: deployer
✅ access control: not allowed: any address
initialize
Initialized a new contract.
📕 Can only be initialized by vault governance
Parameters:
nft_
uint256
NFT of the vault in the VaultRegistry
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
strategy_
address
The address that will have approvals for subvaultNfts
subvaultNfts_
uint256[]
The NFTs of the subvaults that will be aggregated by this ERC20RootVault
Specs
✅ edge cases: when root vault is not owner of subvault nft reverts with FRB
✅ edge cases: when subVault index is 0 (rootVault has itself as subVaul) reverts with DUP
✅ edge cases: when subVault index index is 0 reverts with DUP
deposit
⛽ 467K (357K - 750K)
The function of depositing the amount of tokens in exchange
Parameters:
tokenAmounts
uint256[]
Array of amounts of tokens for deposit
minLpTokens
uint256
Minimal value of LP tokens
vaultOptions
bytes
Options of vaults
Return Values:
actualTokenAmounts
uint256[]
Arrays of actual token amounts after deposit
Specs
✅ rsAllowlist returns non zero length of depositorsAllowlist
✅ rsAllowlist access control: allowed: any address
✅ emits Deposit event
✅ checking protocol fees charges fees
✅ edge cases: when performance fee is zero do not charge performance fees
✅ edge cases: when management fee is zero not charges management fees
✅ edge cases: when deposit is disabled reverts with FRB
✅ edge cases: when there is no depositor in allow list reverts with FRB
✅ edge cases: when there is a private vault in delayedStrategyParams reverts with FRB
✅ edge cases: when minLpTokens is greater than lpAmount reverts with LIMU
✅ edge cases: when tokenAmounts is less than or equal to FIRST_DEPOSIT_LIMIT reverts with LIMU
✅ edge cases: when depositCallback Address is set emits deposits callback called
✅ edge cases: when lpAmount is zero reverts with VZ
✅ edge cases: when sum of lpAmount and sender balance is greater than tokenLimitPerAddress reverts with LIMO
✅ edge cases: when sum of lpAmount and totalSupply is greater than tokenLimit reverts with LIMO
✅ access control: allowed: any address
withdraw
⛽ 499K (364K - 983K)
The function of withdrawing the amount of tokens in exchange
Parameters:
to
address
Address to which the withdrawal will be sent
lpTokenAmount
uint256
LP token amount, that requested for withdraw
minTokenAmounts
uint256[]
Array of minmal remining wtoken amounts after withdrawal
vaultsOptions
bytes[]
Options of vaults
Return Values:
actualTokenAmounts
uint256[]
Arrays of actual token amounts after withdrawal
Specs
✅ emits Withdraw event
✅ edge cases: when total supply is 0 reverts with VZ
✅ edge cases: when length of vaultsOptions and length of _subvaultNfts are different reverts with INVL
✅ edge cases: when withdrawn is larger than protocol governance withdraw limit for vault token reverts with LIMO
✅ edge cases: When address of lpCallback is not null emits withdrawCallback
✅ edge cases: When address of lpCallback is not null and lpCallback throws empty error emits WithdrawCallbackLog
✅ edge cases: When address of lpCallback is not null and lpCallback throws non empty error emits WithdrawCallbackLog
✅ access control: allowed: any address
Events
ManagementFeesCharged
Emitted when management fees are charged
Parameters:
treasury
address
Treasury receiver of the fee
feeRate
uint256
Fee percent applied denominated in 10 ** 9
amount
uint256
Amount of lp token minted
ProtocolFeesCharged
Emitted when protocol fees are charged
Parameters:
treasury
address
Treasury receiver of the fee
feeRate
uint256
Fee percent applied denominated in 10 ** 9
amount
uint256
Amount of lp token minted
PerformanceFeesCharged
Emitted when performance fees are charged
Parameters:
treasury
address
Treasury receiver of the fee
feeRate
uint256
Fee percent applied denominated in 10 ** 9
amount
uint256
Amount of lp token minted
Deposit
Emitted when liquidity is deposited
Parameters:
from
address
The source address for the liquidity
tokens
address[]
ERC20 tokens deposited
actualTokenAmounts
uint256[]
Token amounts deposited
lpTokenMinted
uint256
LP tokens received by the liquidity provider
Withdraw
Emitted when liquidity is withdrawn
Parameters:
from
address
The source address for the liquidity
tokens
address[]
ERC20 tokens withdrawn
actualTokenAmounts
uint256[]
Token amounts withdrawn
lpTokenBurned
uint256
LP tokens burned from the liquidity provider
DepositCallbackLog
Emitted when callback in deposit failed
Parameters:
reason
string
Error reason
WithdrawCallbackLog
Emitted when callback in withdraw failed
Parameters:
reason
string
Error reason
ERC20RootVaultGovernance
Inherits from VaultGovernance, ERC165, ContractMeta
⛽ 4.53M
Governance that manages all Lp Issuers params and can deploy a new LpIssuer Vault.
Functions
constructor
Creates a new contract.
Parameters:
internalParams_
struct IVaultGovernance.InternalParams
Initial Internal Params
delayedProtocolParams_
struct IERC20RootVaultGovernance.DelayedProtocolParams
Initial Protocol Params
Specs
✅ deploys a new contract
✅ initializes internalParams
Edge cases
✅ when protocolGovernance address is 0 reverts
✅ when vaultRegistry address is 0 reverts
delayedProtocolParams
Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
Specs
✅ returns current DelayedProtocolParams
Access control
✅ allowed: any address
Properties
✅ staging DelayedProtocolParams doesn't change delayedProtocolParams
Edge cases
✅ when no params were committed returns non-zero params initialized in constructor
stagedDelayedProtocolParams
Delayed Protocol Params staged for commit after delay.
Specs
✅ returns DelayedProtocolParams staged for commit
Access control
✅ allowed: any address
Properties
✅ always equals to params that were just staged
Edge cases
✅ when no params are staged for commit returns zero struct
✅ when params were just committed returns zero struct
delayedProtocolPerVaultParams
Delayed Protocol Per Vault Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
Parameters:
nft
uint256
VaultRegistry NFT of the vault
Specs
✅ returns current DelayedProtocolPerVaultParams
Access control
✅ allowed: any address
Properties
✅ staging DelayedProtocolPerVaultParams doesn't change delayedProtocolPerVaultParams
Edge cases
✅ when no params were committed returns zero params
stagedDelayedProtocolPerVaultParams
Delayed Protocol Per Vault Params staged for commit after delay.
Parameters:
nft
uint256
VaultRegistry NFT of the vault
Specs
✅ returns DelayedProtocolPerVaultParams staged for commit
Access control
✅ allowed: any address
Properties
✅ always equals to params that were just staged
Edge cases
✅ when no params are staged for commit returns zero struct
✅ when params were just committed returns zero struct
stagedDelayedStrategyParams
Delayed Strategy Params staged for commit after delay.
Parameters:
nft
uint256
VaultRegistry NFT of the vault
Specs
✅ returns DelayedStrategyParams staged for commit
Access control
✅ allowed: any address
Properties
✅ always equals to params that were just staged
Edge cases
✅ when no params are staged for commit returns zero struct
✅ when params were just committed returns zero struct
operatorParams
Operator Params.
Specs
✅ returns operatorParams
Access control
✅ allowed: any address
Edge cases
✅ when operatorParams have not been set returns zero params
delayedStrategyParams
Delayed Strategy Params
Parameters:
nft
uint256
VaultRegistry NFT of the vault
Specs
✅ returns current DelayedStrategyParams
Access control
✅ allowed: any address
Properties
✅ staging DelayedStrategyParams doesn't change delayedStrategyParams
Edge cases
✅ when no params were committed returns zero params
strategyParams
Strategy Params.
Parameters:
nft
uint256
VaultRegistry NFT of the vault
supportsInterface
Specs
✅ returns true if this contract supports 0x6a2c3330 interface
✅ access control: allowed: any address
stageDelayedStrategyParams
⛽ 160K (67K - 244K)
Stage Delayed Strategy Params, i.e. Params that could be changed by Strategy or Protocol Governance with Protocol Governance delay.
Parameters:
nft
uint256
VaultRegistry NFT of the vault
params
struct IERC20RootVaultGovernance.DelayedStrategyParams
New params
Specs
✅ stages DelayedStrategyParams for commit
✅ sets zero delay for commit when #commitDelayedStrategyParams was called 0 times (init)
✅ sets governance delay for commit after #commitDelayedStrategyParams was called at least once
✅ emits StageDelayedStrategyParams event
Access control
✅ allowed: ProtocolGovernance admin
✅ allowed: Vault NFT Approved (aka strategy)
✅ allowed: Vault NFT Owner (aka liquidity provider)
✅ denied: deployer
✅ denied: random address
Properties
✅ cannot be called by random address
Edge cases
✅ when managementFee is exceeds MAX_MANAGEMENT_FEE reverts with LIMO
✅ when performnaceFee is exceeds MAX_PERFORMANCE_FEE reverts with LIMO
✅ when called twice succeeds with the last value
✅ when called with zero params succeeds with zero params
commitDelayedStrategyParams
⛽ 118K (75K - 195K)
Commit Delayed Strategy Params, i.e. Params that could be changed by Strategy or Protocol Governance with Protocol Governance delay.
📕 Can only be called after delayedStrategyParamsTimestamp
Parameters:
nft
uint256
VaultRegistry NFT of the vault
Specs
✅ commits staged DelayedStrategyParams
✅ resets delay for commit
✅ emits CommitDelayedStrategyParams event
Access control
✅ allowed: ProtocolGovernance admin
✅ allowed: Vault NFT Owner (aka liquidity provider)
✅ allowed: Vault NFT Approved (aka strategy)
✅ denied: deployer
✅ denied: random address
Properties
✅ cannot be called by random address
✅ reverts if called before the delay has elapsed (after commit was called initally)
✅ succeeds if called after the delay has elapsed
Edge cases
✅ when called twice reverts
✅ when nothing is staged reverts
✅ when delay has not elapsed (after initial commit call) reverts
stageDelayedProtocolPerVaultParams
⛽ 108K (54K - 108K)
Stage Delayed Protocol Per Vault Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
Parameters:
nft
uint256
VaultRegistry NFT of the vault
params
struct IERC20RootVaultGovernance.DelayedProtocolPerVaultParams
New params
Specs
✅ stages DelayedProtocolPerVaultParams for commit
✅ sets delay for commit
✅ emits StageDelayedProtocolPerVaultParams event
Access control
✅ allowed: ProtocolGovernance admin
✅ denied: Vault NFT Owner (aka liquidity provider)
✅ denied: Vault NFT Approved (aka strategy)
✅ denied: deployer
✅ denied: random address
Properties
✅ cannot be called by random address
Edge cases
✅ when called twice succeeds with the last value
✅ when called with zero params succeeds with zero params
✅ when protocol fee is greater than MAX_PROTOCOL_FEE reverts
commitDelayedProtocolPerVaultParams
⛽ 80K (44K - 80K)
Commit Delayed Protocol Per Vault Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
📕 Can only be called after delayedProtocolPerVaultParamsTimestamp
Parameters:
nft
uint256
VaultRegistry NFT of the vault
Specs
✅ commits staged DelayedProtocolPerVaultParams
✅ resets delay for commit
✅ emits CommitDelayedProtocolPerVaultParams event
Access control
✅ allowed: ProtocolGovernance admin
✅ denied: Vault NFT Owner (aka liquidity provider)
✅ denied: Vault NFT Approved (aka strategy)
✅ denied: deployer
✅ denied: random address
Properties
✅ cannot be called by random address
✅ reverts if called before the delay has elapsed only if params have already been commited
✅ succeeds if called after the delay has elapsed
Edge cases
✅ when called twice reverts
✅ when nothing is staged reverts
✅ when delay has not elapsed and params have not been commited reverts
✅ when params have already been set and delay has not elapsed reverts
setStrategyParams
⛽ 113K (37K - 115K)
Set Strategy params, i.e. Params that could be changed by Strategy or Protocol Governance immediately.
Parameters:
nft
uint256
Nft of the vault
params
struct IERC20RootVaultGovernance.StrategyParams
New params
setOperatorParams
⛽ 51K (35K - 77K)
Set Operator params, i.e. Params that could be changed by Operator or Protocol Governance immediately.
Parameters:
params
struct IERC20RootVaultGovernance.OperatorParams
New params
Specs
✅ sets new operatorParams
✅ access constrol allowed: ProtocolGovernance admin or Operator
✅ access constrol denied: any other address
Properties
✅ setting new oprator params overwrites old params immediately
stageDelayedProtocolParams
⛽ 88K (52K - 129K)
Stage Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
📕 Can only be called after delayedProtocolParamsTimestamp.
Parameters:
params
struct IERC20RootVaultGovernance.DelayedProtocolParams
New params
Specs
✅ stages DelayedProtocolParams for commit
✅ sets delay for commit
✅ emits StageDelayedProtocolParams event
Access control
✅ allowed: ProtocolGovernance admin
✅ denied: Vault NFT Owner (aka liquidity provider)
✅ denied: Vault NFT Approved (aka strategy)
✅ denied: deployer
✅ denied: random address
Properties
✅ cannot be called by random address
Edge cases
✅ when called twice succeeds with the last value
✅ when called with zero params reverts with zero params
commitDelayedProtocolParams
⛽ 50K (49K - 54K)
Commit Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
Specs
✅ commits staged DelayedProtocolParams
✅ resets delay for commit
✅ emits CommitDelayedProtocolParams event
Access control
✅ allowed: ProtocolGovernance admin
✅ denied: Vault NFT Owner (aka liquidity provider)
✅ denied: Vault NFT Approved (aka strategy)
✅ denied: deployer
✅ denied: random address
Properties
✅ cannot be called by random address
✅ reverts if called before the delay has elapsed
✅ succeeds if called after the delay has elapsed
Edge cases
✅ when called twice reverts
✅ when nothing is staged reverts
✅ when delay has not elapsed reverts
createVault
⛽ 915K (794K - 1.32M)
Deploys a new vault.
Parameters:
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
strategy_
address
The address that will have approvals for subvaultNfts
subvaultNfts_
uint256[]
The NFTs of the subvaults that will be aggregated by this ERC20RootVault
owner_
address
Owner of the vault NFT
Specs
✅ deploys a new vault
✅ registers vault with vault registry and issues nft
✅ the nft is owned by the owner from #createVault arguments
✅ vault is initialized with nft
Access control
✅ when permissionless allowed: any address
✅ when not permissionless allowed: protocol governance admin
✅ when not permissionless denied: any address
Structs
Events
StageDelayedProtocolPerVaultParams
Emitted when new DelayedProtocolPerVaultParams are staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
nft
uint256
VaultRegistry NFT of the vault
params
struct IERC20RootVaultGovernance.DelayedProtocolPerVaultParams
New params that were staged for commit
when
uint256
When the params could be committed
CommitDelayedProtocolPerVaultParams
Emitted when new DelayedProtocolPerVaultParams are committed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
nft
uint256
VaultRegistry NFT of the vault
params
struct IERC20RootVaultGovernance.DelayedProtocolPerVaultParams
New params that are committed
StageDelayedStrategyParams
Emitted when new DelayedStrategyParams are staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
nft
uint256
VaultRegistry NFT of the vault
params
struct IERC20RootVaultGovernance.DelayedStrategyParams
New params that were staged for commit
when
uint256
When the params could be committed
CommitDelayedStrategyParams
Emitted when new DelayedStrategyParams are committed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
nft
uint256
VaultRegistry NFT of the vault
params
struct IERC20RootVaultGovernance.DelayedStrategyParams
New params that are committed
SetStrategyParams
Emitted when new StrategyParams are set.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
nft
uint256
VaultRegistry NFT of the vault
params
struct IERC20RootVaultGovernance.StrategyParams
New params that are set
SetOperatorParams
Emitted when new OperatorParams are set.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IERC20RootVaultGovernance.OperatorParams
New params that are set
StageDelayedProtocolParams
Emitted when new DelayedProtocolParams are staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IERC20RootVaultGovernance.DelayedProtocolParams
New params that were staged for commit
when
uint256
When the params could be committed
CommitDelayedProtocolParams
Emitted when new DelayedProtocolParams are committed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IERC20RootVaultGovernance.DelayedProtocolParams
New params that are committed
ERC20Vault
Inherits from Vault, ERC165, ReentrancyGuard
⛽ 4.41M
Vault that stores ERC20 tokens.
tvl
Total value locked for this contract.
📕 Generally it is the underlying token value of this contract in some other DeFi protocol. For example, for USDC Yearn Vault this would be total USDC balance that could be withdrawn for Yearn to this contract. The tvl itself is estimated in some range. Sometimes the range is exact, sometimes it's not
Return Values:
minTokenAmounts
uint256[]
Lower bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
maxTokenAmounts
uint256[]
Upper bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
Specs
✅ returns total value locked
✅ edge cases: when there are no initial funds returns zeroes
initialize
Initialized a new contract.
📕 Can only be initialized by vault governance
Parameters:
nft_
uint256
NFT of the vault in the VaultRegistry
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
Specs
✅ emits Initialized event
✅ initializes contract successfully
✅ edge cases: when vault's nft is not 0 reverts with INIT
✅ edge cases: not initialized when vault's nft is 0 returns false
✅ edge cases: when tokens are not sorted reverts with INVA
✅ edge cases: when tokens are not unique reverts with INVA
✅ edge cases: when setting zero nft reverts with VZ
✅ edge cases: when setting empty tokens array reverts with INV
✅ edge cases: when token has no permission to become a vault token reverts with FRB
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 if this contract supports 0x7a63aa3a interface
✅ access control: allowed: any address
✅ edge cases: when contract does not support the given interface returns false
ERC20VaultGovernance
Inherits from VaultGovernance, ERC165, ContractMeta
⛽ 1.59M
Governance that manages all ERC20 Vaults params and can deploy a new ERC20 Vault.
Functions
constructor
Creates a new contract.
Parameters:
internalParams_
struct IVaultGovernance.InternalParams
Initial Internal Params
Specs
✅ deploys a new contract
✅ initializes internalParams
Edge cases
✅ when protocolGovernance address is 0 reverts
✅ when vaultRegistry address is 0 reverts
createVault
⛽ 475K (463K - 648K)
Deploys a new vault.
Parameters:
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
owner_
address
Owner of the vault NFT
Specs
✅ deploys a new vault
✅ registers vault with vault registry and issues nft
✅ the nft is owned by the owner from #createVault arguments
✅ vault is initialized with nft
Access control
✅ when permissionless allowed: any address
✅ when not permissionless allowed: protocol governance admin
✅ when not permissionless denied: any address
Structs
GearboxRootVault
Inherits from AggregateVault, Vault, ERC165, ReentrancyGuard, ERC20Token
Contract that mints and burns LP tokens in exchange for ERC20 liquidity.
Functions
depositorsAllowlist
List of addresses of depositors from which interaction with private vaults is allowed
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.
addDepositorsToAllowlist
Add new depositors in the depositorsAllowlist
📕 The action can be done only by user with admins, owners or by approved rights
Parameters:
depositors
address[]
Array of new depositors
removeDepositorsFromAllowlist
Remove depositors from the depositorsAllowlist
📕 The action can be done only by user with admins, owners or by approved rights
Parameters:
depositors
address[]
Array of depositors for remove
initialize
Initialized a new contract.
📕 Can only be initialized by vault governance
Parameters:
nft_
uint256
NFT of the vault in the VaultRegistry
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
strategy_
address
The address that will have approvals for subvaultNfts
subvaultNfts_
uint256[]
The NFTs of the subvaults that will be aggregated by this ERC20RootVault
deposit
The function of depositing the amount of tokens in exchange
Parameters:
tokenAmounts
uint256[]
Array of amounts of tokens for deposit
minLpTokens
uint256
Minimal value of LP tokens
vaultOptions
bytes
Options of vaults
Return Values:
actualTokenAmounts
uint256[]
Arrays of actual token amounts after deposit
registerWithdrawal
The function of registering withdrawal of lp tokens amount
Parameters:
lpTokenAmount
uint256
Amount the sender wants to withdraw
Return Values:
amountRegistered
uint256
Amount which was actually registered
cancelWithdrawal
The function of cancelling withdrawal of lp tokens amount
Parameters:
lpTokenAmount
uint256
Amount the sender wants to cancel
Return Values:
amountRemained
uint256
Amount for which the withdrawal request remains
invokeExecution
The function of invoking the execution of withdrawal orders and transfers corresponding funds to ERC20 vault
withdraw
The function of withdrawing the amount of tokens in exchange
Parameters:
to
address
Address to which the withdrawal will be sent
vaultsOptions
bytes[]
Options of vaults
Return Values:
actualTokenAmounts
uint256[]
Arrays of actual token amounts after withdrawal
shutdown
The function of invoking the emergency execution of withdrawal orders, transfers corresponding funds to ERC20 vault and stops deposits
reopen
The function of opening deposits back in case of a previous shutdown
Events
ManagementFeesCharged
Emitted when management fees are charged
Parameters:
treasury
address
Treasury receiver of the fee
feeRate
uint256
Fee percent applied denominated in 10 ** 9
amount
uint256
Amount of lp token minted
WithdrawalRegistered
Emitted when a witdrawal request registered
Parameters:
sender
address
Sender of the call (msg.sender)
lpAmountRegistered
uint256
Amount of lp tokens registered for the withdrawal
WithdrawalCancelled
Emitted when some piece of the witdrawal request cancelled
Parameters:
sender
address
Sender of the call (msg.sender)
lpAmountCancelled
uint256
Amount of lp tokens for which the withdrawal is cancelled
ExecutionInvoked
Emitted when the withdrawal orderd execution completed
Parameters:
sender
address
Sender of the call (msg.sender)
amountWithdrawnToERC20
uint256
Amount of vault tokens withdrawn from Gearbox to the ERC20 vault
ProtocolFeesCharged
Emitted when protocol fees are charged
Parameters:
treasury
address
Treasury receiver of the fee
feeRate
uint256
Fee percent applied denominated in 10 ** 9
amount
uint256
Amount of lp token minted
PerformanceFeesCharged
Emitted when performance fees are charged
Parameters:
treasury
address
Treasury receiver of the fee
feeRate
uint256
Fee percent applied denominated in 10 ** 9
amount
uint256
Amount of lp token minted
Deposit
Emitted when liquidity is deposited
Parameters:
from
address
The source address for the liquidity
tokens
address[]
ERC20 tokens deposited
actualTokenAmounts
uint256[]
Token amounts deposited
lpTokenMinted
uint256
LP tokens received by the liquidity provider
Withdraw
Emitted when liquidity is withdrawn
Parameters:
from
address
The source address for the liquidity
actualTokenAmounts
uint256[]
Token amounts withdrawn
lpTokenBurned
uint256
LP tokens burned from the liquidity provider
DepositCallbackLog
Emitted when callback in deposit failed
Parameters:
reason
string
Error reason
WithdrawCallbackLog
Emitted when callback in withdraw failed
Parameters:
reason
string
Error reason
GearboxVault
Inherits from Vault, ERC165, ReentrancyGuard
Functions
tvl
Total value locked for this contract.
📕 Generally it is the underlying token value of this contract in some other DeFi protocol. For example, for USDC Yearn Vault this would be total USDC balance that could be withdrawn for Yearn to this contract. The tvl itself is estimated in some range. Sometimes the range is exact, sometimes it's not
Return Values:
minTokenAmounts
uint256[]
Lower bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
maxTokenAmounts
uint256[]
Upper bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
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.
getCreditAccount
Returns an address of the credit account connected to the address of the vault
getAllAssetsOnCreditAccountValue
Returns value of all assets located on the vault, including taken with leverage (nominated in primary tokens)
getClaimableRewardsValue
Returns value of rewards (CRV, CVX) we can obtain from Convex (nominated in primary tokens)
getMerkleProof
initialize
Initialized a new contract.
📕 Can only be initialized by vault governance
Parameters:
nft_
uint256
NFT of the vault in the VaultRegistry
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
helper_
address
address of helper
openCreditAccount
Opens a new credit account on the address of the vault
adjustPosition
Adjust a position (takes more debt or repays some, depending on the past performance) to achieve the required marginalFactorD9
setMerkleParameters
Sets merkle tree parameters for claiming Gearbox V2 Degen NFT (can be successfully called only by an admin or a strategist)
Parameters:
merkleIndex_
uint256
Required index
merkleTotalAmount_
uint256
Total amount of NFTs we have in Gearbox Degen Contract
merkleProof_
bytes32[]
Proof in Merkle tree
updateTargetMarginalFactor
Updates marginalFactorD9 (can be successfully called only by an admin or a strategist)
Parameters:
marginalFactorD_
uint256
New marginalFactorD9
multicall
A helper function to be able to call Gearbox multicalls from the helper, but on behalf of the vault Can be successfully called only by the helper
swap
A helper function to be able to call Gearbox multicalls from the helper, but on behalf of the vault Can be successfully called only by the helper
openCreditAccountInManager
A helper function to be able to call Gearbox multicalls from the helper, but on behalf of the vault Can be successfully called only by the helper
Events
TargetMarginalFactorUpdated
Emitted when target marginal factor is updated
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
newMarginalFactorD9
uint256
New marginal factor
GearboxVaultGovernance
Inherits from VaultGovernance, ERC165, ContractMeta
Functions
constructor
Creates a new contract
delayedProtocolParams
Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
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.
stagedDelayedProtocolParams
Delayed Protocol Params staged for commit after delay.
stagedDelayedProtocolPerVaultParams
Delayed Protocol Per Vault Params staged for commit after delay.
Parameters:
nft
uint256
VaultRegistry NFT of the vault
strategyParams
Strategy Params.
delayedProtocolPerVaultParams
Delayed Protocol Per Vault Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
Parameters:
nft
uint256
VaultRegistry NFT of the vault
stageDelayedProtocolParams
Stage Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
📕 Can only be called after delayedProtocolParamsTimestamp.
Parameters:
params
struct IGearboxVaultGovernance.DelayedProtocolParams
New params
commitDelayedProtocolParams
Commit Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
stageDelayedProtocolPerVaultParams
commitDelayedProtocolPerVaultParams
Commit Delayed Protocol Per Vault Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
📕 Can only be called after delayedProtocolPerVaultParamsTimestamp
Parameters:
nft
uint256
VaultRegistry NFT of the vault
setStrategyParams
Set Strategy params, i.e. Params that could be changed by Strategy or Protocol Governance immediately.
Parameters:
params
uint256
New params
createVault
Deploys a new vault.
Parameters:
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
owner_
address
Owner of the vault NFT
helper_
address
Gearbox helper contract address
Structs
Events
StageDelayedProtocolPerVaultParams
Emitted when new DelayedProtocolPerVaultParams are staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
nft
uint256
VaultRegistry NFT of the vault
params
struct IGearboxVaultGovernance.DelayedProtocolPerVaultParams
New params that were staged for commit
when
uint256
When the params could be committed
CommitDelayedProtocolPerVaultParams
Emitted when new DelayedProtocolPerVaultParams are committed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
nft
uint256
VaultRegistry NFT of the vault
params
struct IGearboxVaultGovernance.DelayedProtocolPerVaultParams
New params that are committed
StageDelayedProtocolParams
Emitted when new DelayedProtocolParams are staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IGearboxVaultGovernance.DelayedProtocolParams
New params that were staged for commit
when
uint256
When the params could be committed
SetStrategyParams
Emitted when new StrategyParams are set.
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IGearboxVaultGovernance.StrategyParams
New params that are set
CommitDelayedProtocolParams
Emitted when new DelayedProtocolParams are committed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IGearboxVaultGovernance.DelayedProtocolParams
New params that are committed
IntegrationVault
Inherits from Vault, ERC165, ReentrancyGuard
Abstract contract that has logic common for every Vault.
📕 Notes:
ERC-721
Each Vault should be registered in VaultRegistry and get corresponding VaultRegistry NFT.
Access control
push
and pull
methods are only allowed for owner / approved person of the NFT. However, pull
for approved person also checks that pull destination is another vault of the Vault System.
The semantics is: NFT owner owns all Vault liquidity, Approved person is liquidity manager. ApprovedForAll person cannot do anything except ERC-721 token transfers.
Both NFT owner and approved person can call externalCall method which claims liquidity mining rewards (if any)
reclaimTokens
for claiming rewards given by an underlying protocol to erc20Vault in order to sell them there
Functions
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.
push
Pushes tokens on the vault balance to the underlying protocol. For example, for Yearn this operation will take USDC from the contract balance and convert it to yUSDC.
📕 Tokens must be a subset of Vault Tokens. However, the convention is that if tokenAmount == 0 it is the same as token is missing.
Also notice that this operation doesn't guarantee that tokenAmounts will be invested in full.
Parameters:
tokens
address[]
Tokens to push
tokenAmounts
uint256[]
Amounts of tokens to push
options
bytes
Additional options that could be needed for some vaults. E.g. for Uniswap this could be deadline
param. For the exact bytes structure see concrete vault descriptions
Return Values:
actualTokenAmounts
uint256[]
The amounts actually invested. It could be less than tokenAmounts (but not higher)
transferAndPush
The same as push
method above but transfers tokens to vault balance prior to calling push. After the push
it returns all the leftover tokens back (push
method doesn't guarantee that tokenAmounts will be invested in full).
Parameters:
tokens
address
Tokens to push
tokenAmounts
address[]
Amounts of tokens to push
options
uint256[]
Additional options that could be needed for some vaults. E.g. for Uniswap this could be deadline
param. For the exact bytes structure see concrete vault descriptions
Return Values:
actualTokenAmounts
uint256[]
The amounts actually invested. It could be less than tokenAmounts (but not higher)
pull
Pulls tokens from the underlying protocol to the to
address.
📕 Can only be called but Vault Owner or Strategy. Vault owner is the owner of NFT for this vault in VaultManager. Strategy is approved address for the vault NFT. When called by vault owner this method just pulls the tokens from the protocol to the to
address When called by strategy on vault other than zero vault it pulls the tokens to zero vault (required to
== zero vault) When called by strategy on zero vault it pulls the tokens to zero vault, pushes tokens on the to
vault, and reclaims everything that's left. Thus any vault other than zero vault cannot have any tokens on it
Tokens must be a subset of Vault Tokens. However, the convention is that if tokenAmount == 0 it is the same as token is missing.
Pull is fulfilled on the best effort basis, i.e. if the tokenAmounts overflows available funds it withdraws all the funds.
Parameters:
to
address
Address to receive the tokens
tokens
address[]
Tokens to pull
tokenAmounts
uint256[]
Amounts of tokens to pull
options
bytes
Additional options that could be needed for some vaults. E.g. for Uniswap this could be deadline
param. For the exact bytes structure see concrete vault descriptions
Return Values:
actualTokenAmounts
uint256[]
The amounts actually withdrawn. It could be less than tokenAmounts (but not higher)
reclaimTokens
Claim ERC20 tokens from vault balance to zero vault.
📕 Cannot be called from zero vault.
Parameters:
tokens
address[]
Tokens to claim
Return Values:
actualTokenAmounts
uint256[]
Amounts reclaimed
isValidSignature
Verifies offchain signature.
📕 Should return whether the signature provided is valid for the provided hash
MUST return the bytes4 magic value 0x1626ba7e when function passes.
MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)
MUST allow external calls
Parameters:
_hash
bytes32
Hash of the data to be signed
_signature
bytes
Signature byte array associated with _hash
Return Values:
magicValue
bytes4
0x1626ba7e if valid, 0xffffffff otherwise
externalCall
Execute one of whitelisted calls.
📕 Can only be called by Vault Owner or Strategy. Vault owner is the owner of NFT for this vault in VaultManager. Strategy is approved address for the vault NFT.
Since this method allows sending arbitrary transactions, the destinations of the calls are whitelisted by Protocol Governance.
Parameters:
to
address
Address of the reward pool
selector
bytes4
Selector of the call
data
bytes
Abi encoded parameters to to::selector
Return Values:
result
bytes
Result of execution of the call
Events
Push
Emitted on successful push
Parameters:
tokenAmounts
uint256[]
The amounts of tokens to pushed
Pull
Emitted on successful pull
Parameters:
to
address
The target address for pulled tokens
tokenAmounts
uint256[]
The amounts of tokens to pull
ReclaimTokens
Emitted when tokens are reclaimed
Parameters:
to
address
The target address for pulled tokens
tokens
address[]
ERC20 tokens to be reclaimed
tokenAmounts
uint256[]
The amounts of reclaims
MellowVault
Inherits from Vault, ERC165, ReentrancyGuard
⛽ 4.91M
Vault that stores ERC20 tokens.
tvl
Total value locked for this contract.
📕 Generally it is the underlying token value of this contract in some other DeFi protocol. For example, for USDC Yearn Vault this would be total USDC balance that could be withdrawn for Yearn to this contract. The tvl itself is estimated in some range. Sometimes the range is exact, sometimes it's not
Return Values:
minTokenAmounts
uint256[]
Lower bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
maxTokenAmounts
uint256[]
Upper bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
initialize
Initialized a new contract.
📕 Can only be initialized by vault governance
Parameters:
nft_
uint256
NFT of the vault in the VaultRegistry
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
rootVault_
contract IERC20RootVault
Reference to mellow root vault
MellowVaultGovernance
Inherits from VaultGovernance, ERC165, ContractMeta
⛽ 1.6M
Governance that manages all Mellow Vaults params and can deploy a new Mellow Vault.
Functions
constructor
Creates a new contract.
Parameters:
internalParams_
struct IVaultGovernance.InternalParams
Initial Internal Params
createVault
Deploys a new vault.
Parameters:
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
owner_
address
Owner of the vault NFT
underlyingVault
contract IERC20RootVault
Underlying mellow vault
Structs
QuickSwapVault
Inherits from Vault, ERC165, ReentrancyGuard
Vault that interfaces QuickSwap protocol in the integration layer.
Functions
constructor
initialize
Initialized a new contract.
📕 Can only be initialized by vault governance
Parameters:
nft_
uint256
NFT of the vault in the VaultRegistry
vaultTokens_
address
ERC20 tokens that will be managed by this Vault
onERC721Received
📕 Whenever an {IERC721} tokenId
token is transferred to this contract via {IERC721-safeTransferFrom} by operator
from from
, this function is called. It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with IERC721.onERC721Received.selector
.
openFarmingPosition
Parameters:
nft
uint256
nft position of quickswap protocol
farmingCenter_
contract IFarmingCenter
Algebra main farming contract. Manages farmings and performs entry, exit and other actions.
burnFarmingPosition
Parameters:
nft
uint256
nft position of quickswap protocol
farmingCenter_
contract IFarmingCenter
Algebra main farming contract. Manages farmings and performs entry, exit and other actions.
collectEarnings
⛽ 135K (121K - 195K)
Return Values:
collectedFees
uint256[]
array of length 2 with amounts of collected and transferred fees from Quickswap position to ERC20Vault
collectRewards
Parameters:
collectedRewards
amount of collected tokes in underlying tokens
tvl
Total value locked for this contract.
📕 Generally it is the underlying token value of this contract in some other DeFi protocol. For example, for USDC Yearn Vault this would be total USDC balance that could be withdrawn for Yearn to this contract. The tvl itself is estimated in some range. Sometimes the range is exact, sometimes it's not
Return Values:
minTokenAmounts
uint256[]
Lower bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
maxTokenAmounts
uint256[]
Upper bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
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.
strategyParams
Return Values:
params
struct IQuickSwapVaultGovernance.StrategyParams
strategy params of the vault
Events
CollectedEarnings
Emitted when earnings are collected
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
amount0
uint256
Amount of token0 collected
amount1
uint256
Amount of token1 collected
CollectedRewards
Emitted when rewards are collected
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
amount0
uint256
Amount of collected rewardTokenToUnderlying
amount1
uint256
Amount of collected bonusTokenToUnderlying
QuickSwapVaultGovernance
Inherits from VaultGovernance, ERC165, ContractMeta
Governance that manages all QuickSwap Vaults params and can deploy a new QuickSwap Vault.
Functions
constructor
Creates a new contract.
Parameters:
internalParams_
struct IVaultGovernance.InternalParams
Initial Internal Params
strategyParams
Delayed Strategy Params
Parameters:
nft
uint256
VaultRegistry NFT of the vault
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.
setStrategyParams
Delayed Strategy Params staged for commit after delay.
Parameters:
nft
uint256
VaultRegistry NFT of the vault
createVault
Deploys a new vault.
Parameters:
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
owner_
address
Owner of the vault NFT
quickSwapHelper_
address
address of helper
Structs
Events
SetStrategyParams
Emitted when new StrategyParams are set
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
nft
uint256
VaultRegistry NFT of the vault
params
struct IQuickSwapVaultGovernance.StrategyParams
New set params
UniV3Vault
Inherits from Vault, ERC165, ReentrancyGuard
⛽ 6.61M
Vault that interfaces UniswapV3 protocol in the integration layer.
Functions
tvl
Total value locked for this contract.
📕 Generally it is the underlying token value of this contract in some other DeFi protocol. For example, for USDC Yearn Vault this would be total USDC balance that could be withdrawn for Yearn to this contract. The tvl itself is estimated in some range. Sometimes the range is exact, sometimes it's not
Return Values:
minTokenAmounts
uint256[]
Lower bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
maxTokenAmounts
uint256[]
Upper bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
Specs
✅ returns total value locked
✅ edge cases: when there are no initial funds returns zeroes
✅ edge cases: when push was made but there was no minted position returns zeroes
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 if this contract supports 0x88878d28 interface
✅ access control: allowed: any address
✅ returns true if this contract supports 0x7a63aa3a interface
✅ access control: allowed: any address
✅ edge cases: when contract does not support the given interface returns false
positionManager
Reference to INonfungiblePositionManager of UniswapV3 protocol.
Specs
✅ returns INonfungiblePositionManager
✅ access control: allowed: any address
liquidityToTokenAmounts
Returns tokenAmounts corresponding to liquidity, based on the current Uniswap position
Parameters:
liquidity
uint128
Liquidity that will be converted to token amounts
Return Values:
tokenAmounts
uint256[]
Token amounts for the specified liquidity
Specs
✅ returns tokenAmounts corresponding to liquidity
tokenAmountsToLiquidity
Returns liquidity corresponding to token amounts, based on the current Uniswap position
Parameters:
tokenAmounts
uint256[]
Token amounts that will be converted to liquidity
Return Values:
liquidity
uint128
Liquidity for the specified token amounts
Specs
✅ returns zero in case of zero amounts
✅ returns more than zero in case of non-zero amounts
✅ returns proportionally correct
✅ returns correctly in case of tick being out of position by the left
✅ returns correctly in case of tick being out of position by the right
initialize
⛽ 186K
Initialized a new contract.
📕 Can only be initialized by vault governance
Parameters:
nft_
uint256
NFT of the vault in the VaultRegistry
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
fee_
uint24
Fee of the UniV3 pool
uniV3Helper_
address
address of helper for UniV3 arithmetic with ticks
Specs
✅ emits Initialized event
✅ initializes contract successfully
✅ edge cases: when vault's nft is not 0 reverts with INIT
✅ edge cases: when tokens are not sorted reverts with INVA
✅ edge cases: when tokens are not unique reverts with INVA
✅ edge cases: when tokens length is not equal to 2 reverts with INV
✅ edge cases: when setting zero nft reverts with VZ
✅ edge cases: when token has no permission to become a vault token reverts with FRB
onERC721Received
📕 Whenever an {IERC721} tokenId
token is transferred to this contract via {IERC721-safeTransferFrom} by operator
from from
, this function is called. It must return its Solidity selector to confirm the token transfer. If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with IERC721.onERC721Received.selector
.
Specs
✅ updates vault's uniV3Nft
✅ edge cases: when msg.sender is not a position manager reverts
✅ edge cases: when operator is not a strategy reverts
✅ edge cases: when UniV3 token is not valid reverts
✅ edge cases: prevent from adding nft while liquidity is not empty reverts
✅ access control: position manager: allowed
✅ access control: any other address: not allowed
collectEarnings
Collect UniV3 fees to zero vault.
Specs
✅ emits CollectedEarnings event
✅ collecting fees
✅ edge cases: when there is no minted position reverts
✅ access control: allowed: all addresses
Structs
Events
CollectedEarnings
Emitted when earnings are collected
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
to
address
Receiver of the fees
amount0
uint256
Amount of token0 collected
amount1
uint256
Amount of token1 collected
UniV3VaultGovernance
Inherits from VaultGovernance, ERC165, ContractMeta
⛽ 3.02M
Governance that manages all UniV3 Vaults params and can deploy a new UniV3 Vault.
Functions
constructor
Creates a new contract.
Parameters:
internalParams_
struct IVaultGovernance.InternalParams
Initial Internal Params
delayedProtocolParams_
struct IUniV3VaultGovernance.DelayedProtocolParams
Initial Protocol Params
Specs
✅ deploys a new contract
✅ initializes internalParams
Edge cases
✅ when positionManager address is 0 reverts
✅ when oracle address is 0 reverts
✅ when protocolGovernance address is 0 reverts
✅ when vaultRegistry address is 0 reverts
delayedProtocolParams
Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
Specs
✅ returns current DelayedProtocolParams
Access control
✅ allowed: any address
Properties
✅ staging DelayedProtocolParams doesn't change delayedProtocolParams
Edge cases
✅ when no params were committed returns non-zero params initialized in constructor
stagedDelayedProtocolParams
Delayed Protocol Params staged for commit after delay.
Specs
✅ returns DelayedProtocolParams staged for commit
Access control
✅ allowed: any address
Properties
✅ always equals to params that were just staged
Edge cases
✅ when no params are staged for commit returns zero struct
✅ when params were just committed returns zero struct
stagedDelayedStrategyParams
Delayed Strategy Params staged for commit after delay.
Parameters:
nft
uint256
VaultRegistry NFT of the vault
delayedStrategyParams
Delayed Strategy Params
Parameters:
nft
uint256
VaultRegistry NFT of the vault
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 if this contract supports 0xa2e9c513 interface
✅ access control: allowed: any address
stageDelayedProtocolParams
⛽ 88K (52K - 129K)
Stage Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
Parameters:
params
struct IUniV3VaultGovernance.DelayedProtocolParams
New params
Specs
✅ stages DelayedProtocolParams for commit
✅ sets delay for commit
✅ emits StageDelayedProtocolParams event
Access control
✅ allowed: ProtocolGovernance admin
✅ denied: Vault NFT Owner (aka liquidity provider)
✅ denied: Vault NFT Approved (aka strategy)
✅ denied: deployer
✅ denied: random address
Properties
✅ cannot be called by random address
Edge cases
✅ when called twice succeeds with the last value
✅ when called with zero params reverts with zero params
commitDelayedProtocolParams
⛽ 50K (50K - 54K)
Commit Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
Specs
✅ commits staged DelayedProtocolParams
✅ resets delay for commit
✅ emits CommitDelayedProtocolParams event
Access control
✅ allowed: ProtocolGovernance admin
✅ denied: Vault NFT Owner (aka liquidity provider)
✅ denied: Vault NFT Approved (aka strategy)
✅ denied: deployer
✅ denied: random address
Properties
✅ cannot be called by random address
✅ reverts if called before the delay has elapsed
✅ succeeds if called after the delay has elapsed
Edge cases
✅ when called twice reverts
✅ when nothing is staged reverts
✅ when delay has not elapsed reverts
stageDelayedStrategyParams
⛽ 121K
Stage Delayed Strategy Params, i.e. Params that could be changed by Strategy or Protocol Governance with Protocol Governance delay.
Parameters:
nft
uint256
VaultRegistry NFT of the vault
params
struct IUniV3VaultGovernance.DelayedStrategyParams
New params
commitDelayedStrategyParams
⛽ 94K
Commit Delayed Strategy Params, i.e. Params that could be changed by Strategy or Protocol Governance with Protocol Governance delay.
📕 Can only be called after delayedStrategyParamsTimestamp
Parameters:
nft
uint256
VaultRegistry NFT of the vault
createVault
⛽ 563K (550K - 577K)
Deploys a new vault.
Parameters:
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
owner_
address
Owner of the vault NFT
fee_
uint24
Fee of the UniV3 pool
uniV3Helper_
address
address of helper for UniV3 arithmetic with ticks
Specs
✅ deploys a new vault
✅ registers vault with vault registry and issues nft
✅ the nft is owned by the owner from #createVault arguments
✅ vault is initialized with nft
Access control
✅ when permissionless allowed: any address
✅ when not permissionless allowed: protocol governance admin
✅ when not permissionless denied: any address
Edge cases
✅ when fee is not supported by uni v3 reverts
Structs
Events
StageDelayedProtocolParams
Emitted when new DelayedProtocolParams are staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IUniV3VaultGovernance.DelayedProtocolParams
New params that were staged for commit
when
uint256
When the params could be committed
CommitDelayedProtocolParams
Emitted when new DelayedProtocolParams are committed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IUniV3VaultGovernance.DelayedProtocolParams
New params that are committed
StageDelayedStrategyParams
Emitted when new DelayedStrategyParams are staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
nft
uint256
VaultRegistry NFT of the vault
params
struct IUniV3VaultGovernance.DelayedStrategyParams
New params that were staged for commit
when
uint256
When the params could be committed
CommitDelayedStrategyParams
Emitted when new DelayedStrategyParams are committed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
nft
uint256
VaultRegistry NFT of the vault
params
struct IUniV3VaultGovernance.DelayedStrategyParams
New params that are committed
Vault
Inherits from ERC165
Abstract contract that has logic common for every Vault.
📕 Notes:
ERC-721
Each Vault should be registered in VaultRegistry and get corresponding VaultRegistry NFT.
Access control
push
and pull
methods are only allowed for owner / approved person of the NFT. However, pull
for approved person also checks that pull destination is another vault of the Vault System.
The semantics is: NFT owner owns all Vault liquidity, Approved person is liquidity manager. ApprovedForAll person cannot do anything except ERC-721 token transfers.
Both NFT owner and approved person can call externalCall method which claims liquidity mining rewards (if any)
reclaimTokens
for mistakenly transfered tokens (not included into vaultTokens) additionally can be withdrawn by the protocol admin
Functions
initialized
Checks if the vault is initialized
isVaultToken
Checks if a token is vault token
Parameters:
token
address
Address of the token to check
Return Values:
if
bool
this token is managed by Vault
vaultGovernance
Address of the Vault Governance for this contract.
vaultTokens
ERC20 tokens under Vault management.
nft
VaultRegistry NFT for this vault
tvl
Total value locked for this contract.
📕 Generally it is the underlying token value of this contract in some other DeFi protocol. For example, for USDC Yearn Vault this would be total USDC balance that could be withdrawn for Yearn to this contract. The tvl itself is estimated in some range. Sometimes the range is exact, sometimes it's not
Return Values:
minTokenAmounts
uint256[]
Lower bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
maxTokenAmounts
uint256[]
Upper bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
pullExistentials
Existential amounts for each token
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.
Events
Initialized
Emitted when Vault is intialized
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
vaultTokens_
address[]
ERC20 tokens under the vault management
nft_
uint256
VaultRegistry NFT assigned to the vault
VaultGovernance
Inherits from ERC165
Internal contract for managing different params.
📕 The contract should be overriden by the concrete VaultGovernance, define different params structs and use abi.decode / abi.encode to serialize to bytes in this contract. It also should emit events on params change.
Functions
delayedStrategyParamsTimestamp
Timestamp in unix time seconds after which staged Delayed Strategy Params could be committed.
Parameters:
nft
uint256
Nft of the vault
delayedProtocolPerVaultParamsTimestamp
Timestamp in unix time seconds after which staged Delayed Protocol Params Per Vault could be committed.
Parameters:
nft
uint256
Nft of the vault
delayedProtocolParamsTimestamp
Timestamp in unix time seconds after which staged Delayed Protocol Params could be committed.
internalParamsTimestamp
Timestamp in unix time seconds after which staged Internal Params could be committed.
internalParams
Internal Params of the contract.
stagedInternalParams
Staged new Internal Params.
📕 The Internal Params could be committed after internalParamsTimestamp
supportsInterface
stageInternalParams
Stage new Internal Params.
Parameters:
newParams
struct IVaultGovernance.InternalParams
New Internal Params
commitInternalParams
Commit staged Internal Params.
Structs
Events
StagedInternalParams
Emitted when InternalParams are staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IVaultGovernance.InternalParams
New params that were staged for commit
when
uint256
When the params could be committed
CommitedInternalParams
Emitted when InternalParams are staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IVaultGovernance.InternalParams
New params that were staged for commit
DeployedVault
Emitted when New Vault is deployed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
vaultTokens
address[]
Vault tokens for this vault
options
bytes
Options for deploy. The details of the options structure are specified in subcontracts
owner
address
Owner of the VaultRegistry NFT for this vault
vaultAddress
address
Address of the new Vault
vaultNft
uint256
VaultRegistry NFT for the new Vault
YearnVault
Inherits from Vault, ERC165, ReentrancyGuard
⛽ 4.81M
Vault that interfaces Yearn protocol in the integration layer.
📕 Notes: TVL
The TVL of the vault is updated after each deposit withdraw.
yTokens yTokens are fixed at the token creation and addresses are taken from YearnVault governance and if missing there
in YearnVaultRegistry. So essentially each yToken is fixed for life of the YearnVault. If the yToken is missing for some vaultToken, the YearnVault cannot be created.
Push / Pull There are some deposit limits imposed by Yearn vaults. The contract's vaultTokens are fully allowed to corresponding yTokens.
yTokens
Yearn protocol vaults used by this contract
Specs
✅ returns list of yTokens
tvl
Total value locked for this contract.
📕 Generally it is the underlying token value of this contract in some other DeFi protocol. For example, for USDC Yearn Vault this would be total USDC balance that could be withdrawn for Yearn to this contract. The tvl itself is estimated in some range. Sometimes the range is exact, sometimes it's not
Return Values:
minTokenAmounts
uint256[]
Lower bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
maxTokenAmounts
uint256[]
Upper bound for total available balances estimation (nth tokenAmount corresponds to nth token in vaultTokens)
Specs
✅ returns total value locked
✅ edge cases: when there are no initial funds returns zeroes
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 if this contract supports 0x073ab565 interface
✅ access control: allowed: any address
✅ returns true if this contract supports 0x7a63aa3a interface
✅ access control: allowed: any address
✅ edge cases: when contract does not support the given interface returns false
initialize
Initialized a new contract.
📕 Can only be initialized by vault governance
Parameters:
nft_
uint256
NFT of the vault in the VaultRegistry
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
Specs
✅ emits Initialized event
✅ initializes contract successfully
✅ edge cases: when vault's nft is not 0 reverts with INIT
✅ edge cases: when tokens are not sorted reverts with INVA
✅ edge cases: when tokens are not unique reverts with INVA
✅ edge cases: when setting zero nft reverts with VZ
✅ edge cases: when token has no permission to become a vault token reverts with FRB
YearnVaultGovernance
Inherits from VaultGovernance, ERC165, ContractMeta
⛽ 2.4M
Governance that manages all Aave Vaults params and can deploy a new Aave Vault.
Functions
constructor
Creates a new contract
Parameters:
internalParams_
struct IVaultGovernance.InternalParams
Initial Internal Params
delayedProtocolParams_
struct IYearnVaultGovernance.DelayedProtocolParams
Initial Protocol Params
Specs
✅ deploys a new contract
✅ initializes internalParams
Edge cases
✅ when YearnVaultRegistry address is 0 reverts
✅ when protocolGovernance address is 0 reverts
✅ when vaultRegistry address is 0 reverts
yTokenForToken
Determines a corresponding Yearn vault for token
Parameters:
token
address
ERC-20 token for the yToken
Return Values:
If
address
there's a yToken returns its address, otherwise returns 0
Specs
✅ returns yToken (yVault) in yToken overrides (set by #setYTokenForToken) or corresponding to ERC20 token in YearnVaultRegistry
Access control
✅ allowed: any address
Edge cases
✅ when yToken doesn't exist in overrides or YearnVaultRegistry returns 0
✅ when yToken was not overridden by #setYTokenForToken returns token from YearnVaultRegistry
✅ when yToken was overridden by #setYTokenForToken returns overridden token
stagedDelayedProtocolParams
Delayed Protocol Params staged for commit after delay.
Specs
✅ returns DelayedProtocolParams staged for commit
Access control
✅ allowed: any address
Properties
✅ always equals to params that were just staged
Edge cases
✅ when no params are staged for commit returns zero struct
✅ when params were just committed returns zero struct
delayedProtocolParams
Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
Specs
✅ returns current DelayedProtocolParams
Access control
✅ allowed: any address
Properties
✅ staging DelayedProtocolParams doesn't change delayedProtocolParams
Edge cases
✅ when no params were committed returns non-zero params initialized in 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.
Specs
✅ returns true if this contract supports 0x15482137 interface
✅ access control: allowed: any address
stageDelayedProtocolParams
⛽ 75K (49K - 106K)
Stage Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
📕 Can only be called after delayedProtocolParamsTimestamp.
Parameters:
params
struct IYearnVaultGovernance.DelayedProtocolParams
New params
Specs
✅ stages DelayedProtocolParams for commit
✅ sets delay for commit
✅ emits StageDelayedProtocolParams event
Access control
✅ allowed: ProtocolGovernance admin
✅ denied: Vault NFT Owner (aka liquidity provider)
✅ denied: Vault NFT Approved (aka strategy)
✅ denied: deployer
✅ denied: random address
Properties
✅ cannot be called by random address
Edge cases
✅ when called twice succeeds with the last value
✅ when called with zero params reverts with zero params
commitDelayedProtocolParams
⛽ 43K (43K - 45K)
Commit Delayed Protocol Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
Specs
✅ commits staged DelayedProtocolParams
✅ resets delay for commit
✅ emits CommitDelayedProtocolParams event
Access control
✅ allowed: ProtocolGovernance admin
✅ denied: Vault NFT Owner (aka liquidity provider)
✅ denied: Vault NFT Approved (aka strategy)
✅ denied: deployer
✅ denied: random address
Properties
✅ cannot be called by random address
✅ reverts if called before the delay has elapsed
✅ succeeds if called after the delay has elapsed
Edge cases
✅ when called twice reverts
✅ when nothing is staged reverts
✅ when delay has not elapsed reverts
setYTokenForToken
⛽ 51K (35K - 56K)
Sets the manual override for yToken vaults map
📕 Can only be called by Protocol Admin
Parameters:
token
address
ERC-20 token for yToken
yToken
address
for ERC-20 token
Specs
✅ sets a yToken override for a ERC20 token
✅ emits SetYToken event
Access control
✅ allowed: ProtocolGovernance admin
✅ denied: Vault NFT Owner (aka liquidity provider)
✅ denied: Vault NFT Approved (aka strategy)
✅ denied: deployer
✅ denied: random address
Edge cases
✅ when yToken is 0 succeeds
✅ when called twice succeeds
createVault
⛽ 569K (559K - 810K)
Deploys a new vault.
Parameters:
vaultTokens_
address[]
ERC20 tokens that will be managed by this Vault
owner_
address
Owner of the vault NFT
Specs
✅ deploys a new vault
✅ registers vault with vault registry and issues nft
✅ the nft is owned by the owner from #createVault arguments
✅ vault is initialized with nft
Access control
✅ when permissionless allowed: any address
✅ when not permissionless allowed: protocol governance admin
✅ when not permissionless denied: any address
Structs
Events
SetYToken
Emitted when new yToken is set
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
token
address
ERC-20 token for the yToken
yToken
address
yToken for ERC-20 token
StageDelayedProtocolParams
Emitted when new DelayedProtocolParams are staged for commit
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IYearnVaultGovernance.DelayedProtocolParams
New params that were staged for commit
when
uint256
When the params could be committed
CommitDelayedProtocolParams
Emitted when new DelayedProtocolParams are committed
Parameters:
origin
address
Origin of the transaction (tx.origin)
sender
address
Sender of the call (msg.sender)
params
struct IYearnVaultGovernance.DelayedProtocolParams
New params that are committed
Last updated