Contracts API
ContractRegistry
Inherits from Multicall, ContractMeta
⛽ 1.82M
Functions
constructor
addresses
Addresses of the registered contracts
names
Names of the registered contracts
versions
All versions of the contract
Parameters:
versionAddress
Address of the contract at a given version
Parameters:
latestVersion
Latest version of the contract
Parameters:
registerContract
⛽ 256K (254K - 259K)
Register a new contract
Parameters:
Specs
✅ registers IContractMeta compatible contract and updates respective view methods - #addresses - #versions - #names - #latestVersion - #versionAddress
Access control
✅ allowed: operator (deployer)
✅ denied with FRB: random address
✅ allowed: protocol admin
Edge cases
✅ when new contract major version differs more, than on one reverts with INVA
✅ when new contract version lower or equal existing one reverts with INVA
✅ when contract has invalid version reverts with INVA
✅ when contract name is not alphanumeric reverts with INV
✅ when address is already registered reverts with DUP
Events
ContractRegistered
ProtocolGovernance
Inherits from Multicall, UnitPricesGovernance, DefaultAccessControl, AccessControlEnumerable, AccessControl, ERC165, Context, ContractMeta
⛽ 4.68M
Governance that manages all params common for Mellow Permissionless Vaults protocol.
Functions
constructor
Creates a new contract
Parameters:
Specs
✅ deploys a new contract
stagedParams
Staged pending protocol parameters.
Specs
✅ imestamp timestamp equals #stageParams's block.timestamp + governanceDelay
✅ imestamp clears by #commitParams
✅ imestamp edge cases when nothing is set returns zero
✅ imestamp access control allowed: any address
Access control
✅ allowed: any address
Properties
✅ updates by #stageParams
✅ clears by #commitParams
params
Current protocol parameters.
stagedValidatorsAddresses
validatorsAddresses
Addresses that has validators.
validatorsAddress
Address that has validators.
Parameters:
Return Values:
Specs
✅ returns correct value
✅ s properties @property: updates when committed validator grant for a new address
✅ s properties @property: doesn't update when committed validator grant for an existing address
✅ s access control allowed: any address
permissionAddresses
Addresses for which non-zero permissions are set.
stagedPermissionGrantsAddresses
Permission addresses staged for commit.
addressesByPermission
Return all addresses where rawPermissionMask bit for permissionId is set to 1.
Parameters:
Return Values:
Specs
✅ returns addresses that has the given permission set to true
Access control
✅ allowed: any address
Properties
✅ updates by #stagePermissionGrants + #commitPermissionGrants or #revokePermissions
✅ is not affected by forceAllowMask
✅ returns empty array on unknown permissionId
hasPermission
Checks if address has permission or given permission is force allowed for any address.
Parameters:
hasAllPermissions
Checks if address has all permissions.
Parameters:
Specs
✅ checks if an address has all permissions set to true
Access control
✅ allowed: any address
Properties
✅ returns false on random address
✅ is not affected by staged permissions
✅ is affected by committed permissions
✅ returns true for any address when forceAllowMask is set to true
Edge cases
✅ on unknown permission id returns false
maxTokensPerVault
Max different ERC20 token addresses that could be managed by the protocol.
Specs
✅ returns correct value
governanceDelay
The delay for committing any governance params.
Specs
✅ returns correct value
protocolTreasury
The address of the protocol treasury.
Specs
✅ returns correct value
forceAllowMask
Permissions mask which defines if ordinary permission should be reverted. This bitmask is xored with ordinary mask.
Specs
✅ returns correct value
withdrawLimit
Withdraw limit per token per block.
Parameters:
Return Values:
Specs
✅ returns correct value
supportsInterface
Specs
✅ returns true for IProtocolGovernance interface (0xca11fe03)
✅ access control: allowed: any address
✅ edge cases: when contract does not support the given interface returns false
stageValidator
⛽ 129K (43K - 142K)
Stages a new validator for the given address
Parameters:
Specs
✅ emits ValidatorStaged event
Access control
✅ allowed: admin
✅ denied: deployer
✅ denied: random address
Edge cases
✅ when attempting to stage grant to zero address reverts with AZ when target has zero address
✅ when attempting to stage grant to zero address reverts with AZ when validator has zero address
rollbackStagedValidators
⛽ 39K (28K - 42K)
Rollback all staged validators.
Specs
✅ rolls back all staged validators
✅ emits AllStagedValidatorsRolledBack event
Access control
✅ allowed: admin
✅ denied: deployer
✅ denied: random address
commitValidator
⛽ 86K (47K - 117K)
Commits validator for the given address.
📕 Reverts if governance delay has not passed yet.
Parameters:
Specs
✅ commits staged validators
✅ emits ValidatorCommitted event
Access control
✅ allowed: admin
✅ denied: deployer
✅ denied: random address
Edge cases
✅ when attempting to commit validator for zero address reverts with NULL
✅ when nothing is staged for the given address reverts with NULL
✅ when attempting to commit validator too early reverts with TS
commitAllValidatorsSurpassedDelay
⛽ 132K (27K - 463K)
Commites all staged validators for which governance delay passed
Return Values:
Specs
✅ emits ValidatorCommitted event
Access control
✅ allowed: admin
✅ denied: deployer
✅ denied: random address
Properties
✅ commits all staged validators
✅ commits all staged validators after delay
Edge cases
✅ when attempting to commit a single validator too early does not commit validator
✅ when attempting to commit multiple validators too early does not commit these validators
revokeValidator
⛽ 38K
Revoke validator instantly from the given address.
Parameters:
Specs
✅ emits ValidatorRevoked event
Edge cases
✅ when attempting to revoke from zero address reverts with NULL
rollbackStagedPermissionGrants
⛽ 37K (28K - 42K)
Rollback all staged granted permission grant.
Specs
✅ rolls back all staged permission grants
✅ emits AllStagedPermissionGrantsRolledBack event
Access control
✅ allowed: admin
✅ denied: deployer
✅ denied: random address
commitPermissionGrants
⛽ 71K (46K - 117K)
Commits permission grants for the given address.
📕 Reverts if governance delay has not passed yet.
Parameters:
Specs
✅ commits staged permission grants
✅ emits PermissionGrantsCommitted event
Access control
✅ allowed: admin
✅ denied: deployer
✅ denied: random address
Edge cases
✅ when attempting to commit permissions for zero address reverts with NULL
✅ when nothing is staged for the given address reverts with NULL
✅ when attempting to commit permissions too early reverts with TS
commitAllPermissionGrantsSurpassedDelay
⛽ 145K (27K - 248K)
Commites all staged permission grants for which governance delay passed.
Return Values:
Specs
✅ emits PermissionGrantsCommitted event
Access control
✅ allowed: admin
✅ denied: deployer
✅ denied: random address
Properties
✅ commits all staged permission grants
✅ commits all staged permission grants after delay
Edge cases
✅ when attempting to commit a single permission too early does not commit permission
✅ when attempting to commit multiple permissions too early does not commit these permissions
revokePermissions
⛽ 62K (32K - 275K)
Revoke permission instantly from the given address.
Parameters:
Specs
✅ emits PermissionRevoked event
Edge cases
✅ when attempting to revoke from zero address reverts with NULL
commitParams
⛽ 66K (54K - 81K)
Commits staged protocol params. Reverts if governance delay has not passed yet.
Specs
✅ emits ParamsCommitted event
Access control
✅ allowed: protocol admin
✅ denied: deployer
✅ denied: random address
Edge cases
✅ when attempting to commit params too early reverts with TS
✅ when attempting to commit params without setting pending params reverts with NULL
stagePermissionGrants
⛽ 166K (44K - 383K)
Stage granted permissions that could have been committed after governance delay expires. Resets commit delay and permissions if there are already staged permissions for this address.
Parameters:
Specs
✅ emits PermissionGrantsStaged event
Access control
✅ allowed: admin
✅ denied: deployer
✅ denied: random address
Edge cases
✅ when attempting to stage grant to zero address reverts with NULL
stageParams
⛽ 140K (62K - 165K)
Sets new pending params that could have been committed after governance delay expires.
Parameters:
Specs
✅ emits ParamsStaged event
Access control
✅ allowed: admin
✅ denied: random address
Edge cases
✅ when given invalid params when maxTokensPerVault is zero reverts with NULL
✅ when given invalid params when governanceDelay is zero reverts with NULL
✅ when given invalid params when governanceDelay exceeds MAX_GOVERNANCE_DELAY reverts with LIMO
✅ when given invalid params when withdrawLimit less than MIN_WITHDRAW_LIMIT reverts with LIMO
Structs
Events
ValidatorStaged
Emitted when validators are staged to be granted for specific address.
Parameters:
ValidatorRevoked
Validator revoked
Parameters:
AllStagedValidatorsRolledBack
Emitted when staged validators are rolled back
Parameters:
ValidatorCommitted
Emitted when staged validators are comitted for specific address
Parameters:
PermissionGrantsStaged
Emitted when new permissions are staged to be granted for specific address.
Parameters:
PermissionsRevoked
Emitted when permissions are revoked
Parameters:
AllStagedPermissionGrantsRolledBack
Emitted when staged permissions are rolled back
Parameters:
PermissionGrantsCommitted
Emitted when staged permissions are comitted for specific address
Parameters:
ParamsStaged
Emitted when pending parameters are set
Parameters:
ParamsCommitted
Emitted when pending parameters are committed
Parameters:
UnitPricesGovernance
Inherits from DefaultAccessControl, AccessControlEnumerable, AccessControl, ERC165, Context
⛽ 1.82M
Functions
constructor
supportsInterface
📕 Returns true if this contract implements the interface defined by interfaceId
. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.
stageUnitPrice
⛽ 72K (54K - 74K)
Stage estimated amount of token worth 1 USD staged for commit.
Parameters:
rollbackUnitPrice
⛽ 31K (30K - 31K)
Reset staged value
Parameters:
commitUnitPrice
⛽ 50K
Commit staged unit price
Parameters:
Structs
Events
UnitPriceStaged
UnitPrice staged for commit
Parameters:
UnitPriceRolledBack
UnitPrice rolled back
Parameters:
UnitPriceCommitted
UnitPrice committed
Parameters:
VaultRegistry
Inherits from ERC721, ERC165, Context, ContractMeta
⛽ 3.07M
This contract is used to manage ERC721 NFT for all Vaults.
Functions
constructor
Creates a new contract.
Parameters:
Specs
✅ creates VaultRegistry
✅ initializes ProtocolGovernance address
✅ initializes ERC721 token name
✅ initializes ERC721 token symbol
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:
Return Values:
Specs
✅ resolves Vault address by VaultRegistry NFT
✅ access control: allowed: any address
Edge cases
✅ when Vault NFT is not registered in VaultRegistry returns zero address
nftForVault
Get NFT ID for given Vault contract address.
Parameters:
Return Values:
Specs
✅ resolves VaultRegistry NFT by Vault address
✅ access control: allowed: any address
Edge cases
✅ when Vault is not registered in VaultRegistry returns zero
isLocked
Checks if the nft is locked for all transfers
Parameters:
Return Values:
Specs
✅ checks if token is locked (not transferable)
✅ access control: allowed: any address
Edge cases
✅ when VaultRegistry NFT is not registered in VaultRegistry returns false
protocolGovernance
Address of the ProtocolGovernance.
Specs
✅ returns ProtocolGovernance address
✅ access control: allowed: any address
stagedProtocolGovernance
Address of the staged ProtocolGovernance.
Specs
✅ returns ProtocolGovernance address staged for commit
✅ access control: allowed: any address
✅ imestamp returns timestamp after which #commitStagedProtocolGovernance can be called
✅ imestamp access control: allowed: any address
✅ imestamp edge cases when nothing is staged returns 0
✅ imestamp edge cases right after #commitStagedProtocolGovernance was called returns 0
Edge cases
✅ when nothing is staged returns zero address
✅ right after #commitStagedProtocolGovernance was called returns zero address
stagedProtocolGovernanceTimestamp
Minimal timestamp when staged ProtocolGovernance can be applied.
Specs
✅ returns timestamp after which #commitStagedProtocolGovernance can be called
✅ access control: allowed: any address
Edge cases
✅ when nothing is staged returns 0
✅ right after #commitStagedProtocolGovernance was called returns 0
vaultsCount
Number of Vaults registered.
Specs
✅ returns the number of registered vaults
✅ access control: allowed: any address
Properties
✅ when N new vaults have been registered, vaults count will be increased by N
supportsInterface
Specs
✅ returns true if this contract supports a certain interface
✅ access control: allowed: any address
✅ edge cases: when contract does not support the given interface returns false
registerVault
⛽ 167K (154K - 188K)
Register new Vault and mint NFT.
Parameters:
Return Values:
Specs
✅ binds minted ERC721 NFT to Vault address and transfers minted NFT to owner specified in args
✅ emits VaultRegistered event
✅ access control: allowed: any account with Register Vault permissions
✅ access control: denied: any other address
✅ access control: denied: protocol governance admin
Properties
✅ minted NFT equals to vaultRegistry#vaultsCount
Edge cases
✅ when address doesn't conform to IVault interface (IERC165) reverts with INVI
✅ when vault has already been registered reverts with DUP
✅ when owner address is zero reverts with AZ
stageProtocolGovernance
⛽ 75K (43K - 80K)
Stage new ProtocolGovernance.
Parameters:
Specs
✅ stages new ProtocolGovernance for commit
✅ sets the stagedProtocolGovernanceTimestamp after which #commitStagedProtocolGovernance can be called
✅ access control: allowed: ProtocolGovernance Admin
✅ access control: denied: any other address
✅ access control: denied: deployer
Edge cases
✅ when new ProtocolGovernance is a zero address reverts with AZ
commitStagedProtocolGovernance
⛽ 34K
Commit new ProtocolGovernance.
Specs
✅ commits staged ProtocolGovernance
✅ resets staged ProtocolGovernanceTimestamp
✅ resets staged ProtocolGovernance
✅ access control: allowed: ProtocolGovernance Admin
✅ access control: denied: any other address
Edge cases
✅ when nothing is staged reverts with INIT
✅ when called before stagedProtocolGovernanceTimestamp reverts with TS
✅ when called before stagedProtocolGovernanceTimestamp reverts with TS
lockNft
⛽ 46K (29K - 49K)
Specs
✅ locks NFT (disables any transfer)
✅ emits TokenLocked event
✅ access control: allowed: NFT owner
✅ access control: denied: any other address
✅ access control: denied: protocol admin
Edge cases
✅ when NFT has already been locked succeeds
Events
TokenLocked
Emitted when token is locked for transfers
Parameters:
VaultRegistered
Emitted when new Vault is registered in VaultRegistry
Parameters:
StagedProtocolGovernance
Parameters:
CommitedProtocolGovernance
Parameters:
CommonLibrary
CommonLibrary shared utilities
ExceptionsLibrary
Exceptions stores project`s smart-contracts exceptions
PermissionIdsLibrary
Stores permission ids for addresses
SemverLibrary
ChainlinkOracle
Inherits from DefaultAccessControl, AccessControlEnumerable, AccessControl, ERC165, Context, ContractMeta
⛽ 2.77M
Contract for getting chainlink data
Functions
constructor
hasOracle
Checks if token has chainlink oracle
Parameters:
Return Values:
Specs
✅ returns true if oracle is supported
✅ edge cases: when oracle is not supported returns false
supportedTokens
A list of supported tokens
Specs
✅ returns list of supported tokens
priceX96
Oracle price for tokens as a Q64.96 value. Returns pricing information based on the indexes of non-zero bits in safetyIndicesSet. It is possible that not all indices will have their respective prices returned.
📕 The price is token1 / token0 i.e. how many weis of token1 required for 1 wei of token0. The safety indexes are:
1 - unsafe, this is typically a spot price that can be easily manipulated,
2 - 4 - more or less safe, this is typically a uniV3 oracle, where the safety is defined by the timespan of the average price
5 - safe - this is typically a chailink oracle
Parameters:
Return Values:
supportsInterface
📕 Returns true if this contract implements the interface defined by interfaceId
. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.
Specs
✅ returns true for ChainlinkOracle interface (0x8e3bd5d7)
✅ edge cases: when contract does not support the given interface returns false
addChainlinkOracles
⛽ 82K (81K - 83K)
Add a Chainlink price feed for a token
Parameters:
Specs
✅ emits OraclesAdded event
✅ when oracles have set by addChainLinkOracles function returns prices
✅ edge cases: when arrays have different lengths reverts with INV
✅ edge cases: when sender has no admin righs reverts with FRB
Structs
Events
OraclesAdded
Emitted when new Chainlink oracle is added
Parameters:
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:
Return Values:
supportsInterface
📕 Returns true if this contract implements the interface defined by interfaceId
. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.
Specs
✅ returns true for IUniV2Oracle interface (0x2748645e)
✅ edge cases: when contract does not support the given interface returns false
UniV3Oracle
Inherits from DefaultAccessControl, AccessControlEnumerable, AccessControl, ERC165, Context, ContractMeta
⛽ 3.44M
Functions
constructor
priceX96
Oracle price for tokens as a Q64.96 value. Returns pricing information based on the indexes of non-zero bits in safetyIndicesSet. It is possible that not all indices will have their respective prices returned.
📕 Logic of this function is next: If there is no initialized pool for the passed tokens, empty arrays will be returned. Depending on safetyIndicesSet if the 1st bit in safetyIndicesSet is non-zero, then the response will contain the spot price. If there is a non-zero 2nd bit in the safetyIndicesSet and the corresponding position in the pool was created no later than LOW_OBS_DELTA seconds ago, then the average price for the last LOW_OBS_DELTA seconds will be returned. The same logic exists for the 3rd and MID_OBS_DELTA, and 4th index and HIGH_OBS_DELTA.
Parameters:
Return Values:
supportsInterface
📕 Returns true if this contract implements the interface defined by interfaceId
. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.
Specs
✅ returns true for IUniV3Oracle interface (0x2a3602d6)
✅ when contract does not support the given interface returns false
addUniV3Pools
⛽ 73K (39K - 89K)
Add UniV3 pools for prices.
Parameters:
Specs
✅ when adding [weth, usdc] pools with fee = 500 adds pools
✅ when adding [weth, usdc] pools with fee = 3000 adds pools
✅ when adding [weth, usdc] pools with fee = 10000 does not return prices
Structs
Events
PoolsUpdated
Emitted when new pool is added or updated and become available for oracle prices
Parameters:
HStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
⛽ 7.59M
Functions
constructor
constructs a strategy
Parameters:
Specs
✅ deploys a new contract
initialize
initializes the strategy
Parameters:
createStrategy
⛽ 536K (536K - 539K)
creates the clone of the strategy
Parameters:
Return Values:
Specs
✅ creates a new strategy and initializes it
updateStrategyParams
⛽ 48K (44K - 51K)
updates parameters of the strategy. Can be called only by admin
Parameters:
updateMintingParams
updates parameters for minting position. Can be called only by admin
Parameters:
updateOracleParams
updates oracle parameters. Can be called only by admin
Parameters:
updateRatioParams
⛽ 39K (38K - 40K)
updates parameters of the capital ratios and deviation. Can be called only by admin
Parameters:
updateSwapFees
updates swap fees for uniswapV3Pool swaps
Parameters:
manualPull
⛽ 468K (256K - 517K)
manual pulling tokens from vault. Can be called only by admin
Parameters:
Specs
✅ pulls token amounts from fromVault to toVault
rebalance
⛽ 1.44M (352K - 1.75M)
rebalance method. Need to be called if the new position is needed
Parameters:
Return Values:
Specs
✅ performs a rebalance according to strategy params
Structs
Events
MintUniV3Position
Emitted when new position in UniV3Pool has been minted.
Parameters:
BurnUniV3Position
Emitted when position in UniV3Pool has been burnt.
Parameters:
SwapTokensOnERC20Vault
Emitted when swap is initiated.
Parameters:
UpdateStrategyParams
Emitted when Strategy strategyParams are set.
Parameters:
UpdateMintingParams
Emitted when Strategy mintingParams are set.
Parameters:
UpdateOracleParams
Emitted when Strategy oracleParams are set.
Parameters:
UpdateRatioParams
Emitted when Strategy ratioParams are set.
Parameters:
UpdateSwapFees
Emitted when new swap fees for UniV3Pool swaps are set.
Parameters:
LStrategy
Inherits from DefaultAccessControl, AccessControlEnumerable, AccessControl, ERC165, Context
⛽ 7.65M
Functions
constructor
getTargetPriceX96
Target price based on mutable params, as a Q64.96 value
targetUniV3LiquidityRatio
Target liquidity ratio for UniV3 vaults
rebalanceERC20UniV3Vaults
⛽ 505K (326K - 1.69M)
Make a rebalance between ERC20 and UniV3 Vaults
Parameters:
Return Values:
rebalanceUniV3Vaults
⛽ 432K (138K - 900K)
Make a rebalance of UniV3 vaults
Parameters:
Return Values:
postPreOrder
⛽ 144K (140K - 180K)
Post preorder for ERC20 vault rebalance.
Parameters:
Return Values:
signOrder
⛽ 210K (103K - 233K)
Sign offchain cowswap order onchain
Parameters:
resetCowswapAllowance
⛽ 117K (116K - 118K)
Reset cowswap allowance to 0
Parameters:
collectUniFees
⛽ 279K (239K - 320K)
Collect Uniswap pool fees to erc20 vault
Return Values:
manualPull
⛽ 345K (297K - 487K)
Manually pull tokens from fromVault to toVault
Parameters:
updateTradingParams
⛽ 68K (42K - 119K)
Sets new trading params
Parameters:
updateRatioParams
⛽ 37K (36K - 53K)
Sets new ratio params
Parameters:
updateOtherParams
⛽ 41K (33K - 94K)
Sets new other params
Parameters:
Structs
Events
PreOrderPosted
Emitted when a new cowswap preOrder is posted.
Parameters:
OrderSigned
Emitted when cowswap preOrder was signed onchain.
Parameters:
ManualPull
Emitted when manual pull from vault is executed.
Parameters:
SwapVault
Emitted when vault is swapped.
Parameters:
RebalancedErc20UniV3
Emitted when rebalance from UniV3 to ERC20 or vice versa happens
Parameters:
RebalancedUniV3
Parameters:
TradingParamsUpdated
Emitted when trading params were updated
Parameters:
RatioParamsUpdated
Emitted when ratio params were updated
Parameters:
OtherParamsUpdated
Emitted when other params were updated
Parameters:
CowswapAllowanceReset
FeesCollected
MStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
⛽ 6.64M
Functions
constructor
Deploys a new contract
Parameters:
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:
Specs
✅ returns average UniswapV3Pool price tick
initialize
Set initial values.
📕 Can be only called once.
Parameters:
createStrategy
⛽ 571K (570K - 573K)
Deploy a new strategy.
Parameters:
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:
Return Values:
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:
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:
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:
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:
SwappedTokens
Emitted when swap is initiated.
Parameters:
SetOracleParams
Emitted when Oracle params are set.
Parameters:
SetRatioParams
Emitted when Ratio params are set.
Parameters:
MultiPoolHStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
⛽ 5.84M
Functions
constructor
constructs a strategy
initialize
initializes the strategy
Parameters:
createStrategy
⛽ 1.2M (1.18M - 1.25M)
creates the clone of the strategy
Parameters:
Return Values:
updateMutableParams
updates parameters of the strategy. Can be called only by admin
Parameters:
rebalance
⛽ 3.41M
rebalance method. Need to be called if the new position is needed
Parameters:
Return Values:
Specs
✅ works correctly
checkMutableParams
the function checks that mutableParams_ pass the necessary checks
Parameters:
Structs
Events
UpdateMutableParams
Emitted when Strategy mutableParams are set.
Parameters:
Rebalance
Emitted when Strategy mutableParams are set.
Parameters:
PulseRouteStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
Functions
constructor
Parameters:
initialize
Parameters:
updateMutableParams
📕 updates mutable params of the strategy. Only the admin can call the function
Parameters:
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:
calculateNewInterval
📕 calculates a new interval according to the mutable params, the tickSpacing of the pool and the spot tick
Parameters:
Return Values:
checkMutableParams
📕 checks mutable params according to strategy restrictions
Parameters:
checkImmutableParams
📕 checks immutable params according to strategy restrictions
Parameters:
checkTickDeviations
Parameters:
calculateTargetRatioOfToken1
📕 calculate target ratio of token 1 to total capital after rebalance
Parameters:
Return Values:
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:
Return Values:
depositCallback
Function, that ERC20RootVault calling after deposit
withdrawCallback
Function, that ERC20RootVault calling after withdraw
Structs
Events
TokensSwapped
Emitted after a successful token swap
Parameters:
UpdateMutableParams
Emited when mutable parameters are successfully updated
Parameters:
Rebalance
Emited when the rebalance is successfully completed
Parameters:
PositionMinted
Emited when a new uniswap position is created
Parameters:
PositionBurned
Emited when a uniswap position is burned
Parameters:
PulseStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
Functions
constructor
Parameters:
initialize
Parameters:
updateMutableParams
📕 updates mutable params of the strategy. Only the admin can call the function
Parameters:
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:
checkMutableParams
📕 checks mutable params according to strategy restrictions
Parameters:
checkImmutableParams
📕 checks immutable params according to strategy restrictions
Parameters:
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:
calculateNewPosition
Parameters:
Return Values:
calculateTargetRatioOfToken1
📕 calculate target ratio of token 1 to total capital after rebalance
Parameters:
Return Values:
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:
Return Values:
depositCallback
Function, that ERC20RootVault calling after deposit
withdrawCallback
Function, that ERC20RootVault calling after withdraw
Structs
Events
TokensSwapped
Emitted after a successful token swap
Parameters:
UpdateMutableParams
Emited when mutable parameters are successfully updated
Parameters:
Rebalance
Emited when the rebalance is successfully completed
Parameters:
PositionMinted
Emited when a new uniswap position is created
Parameters:
PositionBurned
Emited when a uniswap position is burned
Parameters:
PulseStrategyV2
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
Functions
constructor
Parameters:
initialize
Parameters:
setForceRebalanceFlag
updateDesiredAmounts
updateMutableParams
📕 updates mutable params of the strategy. Only the admin can call the function
Parameters:
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:
checkMutableParams
📕 checks mutable params according to strategy restrictions
Parameters:
checkImmutableParams
📕 checks immutable params according to strategy restrictions
Parameters:
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:
formPositionWithSpotTickInCenter
calculateNewPosition
Parameters:
Return Values:
calculateTargetRatioOfToken1
📕 calculate target ratio of token 1 to total capital after rebalance
Parameters:
Return Values:
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:
Return Values:
depositCallback
Function, that ERC20RootVault calling after deposit
withdrawCallback
Function, that ERC20RootVault calling after withdraw
Structs
Events
TokensSwapped
Emitted after a successful token swap
Parameters:
UpdateMutableParams
Emited when mutable parameters are successfully updated
Parameters:
Rebalance
Emited when the rebalance is successfully completed
Parameters:
PositionMinted
Emited when a new uniswap position is created
Parameters:
PositionBurned
Emited when a uniswap position is burned
Parameters:
QuickPulseStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
Functions
constructor
Parameters:
initialize
Parameters:
updateMutableParams
📕 updates mutable params of the strategy. Only the admin can call the function
Parameters:
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:
checkMutableParams
📕 checks mutable params according to strategy restrictions
Parameters:
checkImmutableParams
📕 checks immutable params according to strategy restrictions
Parameters:
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:
calculateNewPosition
Parameters:
Return Values:
calculateTargetRatioOfToken1
📕 calculate target ratio of token 1 to total capital after rebalance
Parameters:
Return Values:
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:
Return Values:
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:
UpdateMutableParams
Emited when mutable parameters are successfully updated
Parameters:
Rebalance
Emited when the rebalance is successfully completed
Parameters:
PositionMinted
Emited when a new algebra position is created
Parameters:
PositionBurned
Emited when a algebra position is burned
Parameters:
SinglePositionQuickSwapStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
Functions
constructor
Parameters:
initialize
Parameters:
updateMutableParams
📕 updates mutable params of the strategy. Only the admin can call the function
Parameters:
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:
calculateNewInterval
📕 calculates a new interval according to the mutable params, the tickSpacing of the pool and the spot tick
Parameters:
Return Values:
checkMutableParams
📕 checks mutable params according to strategy restrictions
Parameters:
checkImmutableParams
📕 checks immutable params according to strategy restrictions
Parameters:
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:
calculateTargetRatioOfToken1
📕 calculate target ratio of token 1 to total capital after rebalance
Parameters:
Return Values:
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:
Return Values:
depositCallback
Function, that ERC20RootVault calling after deposit
withdrawCallback
Function, that ERC20RootVault calling after withdraw
Structs
Events
TokensSwapped
Emitted after a successful token swap
Parameters:
UpdateMutableParams
Emited when mutable parameters are successfully updated
Parameters:
Rebalance
Emited when the rebalance is successfully completed
Parameters:
PositionMinted
Emited when a new uniswap position is created
Parameters:
PositionBurned
Emited when a uniswap position is burned
Parameters:
SinglePositionStrategy
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context, Multicall, ContractMeta
⛽ 7.31M
Functions
constructor
Parameters:
Specs
✅ creates contract
initialize
⛽ 671K
Parameters:
updateMutableParams
⛽ 120K (89K - 245K)
📕 updates mutable params of the strategy. Only the admin can call the function
Parameters:
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:
Specs
✅ works correctly
calculateNewInterval
📕 calculates a new interval according to the mutable params, the tickSpacing of the pool and the spot tick
Parameters:
Return Values:
checkMutableParams
📕 checks mutable params according to strategy restrictions
Parameters:
checkImmutableParams
📕 checks immutable params according to strategy restrictions
Parameters:
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:
calculateTargetRatioOfToken1
📕 calculate target ratio of token 1 to total capital after rebalance
Parameters:
Return Values:
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:
Return Values:
depositCallback
Function, that ERC20RootVault calling after deposit
withdrawCallback
Function, that ERC20RootVault calling after withdraw
Structs
Events
TokensSwapped
Emitted after a successful token swap
Parameters:
UpdateMutableParams
Emited when mutable parameters are successfully updated
Parameters:
Rebalance
Emited when the rebalance is successfully completed
Parameters:
PositionMinted
Emited when a new uniswap position is created
Parameters:
PositionBurned
Emited when a uniswap position is burned
Parameters:
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:
isAdmin
Checks if the address is ADMIN or ADMIN_DELEGATE.
Parameters:
Return Values:
isOperator
Checks if the address is OPERATOR.
Parameters:
Return Values:
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:
Return Values:
Specs
✅ returns
true
if sender is an admin,false
otherwise
isOperator
Checks that the address is contract admin.
Parameters:
Return Values:
Specs
✅ returns
true
if sender is an operator,false
otherwise
init
⛽ 301K
Initializes a new contract with roles and single ADMIN.
Parameters:
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:
PositionAdjusted
Emitted when an adjusment of the position made in Gearbox
Parameters:
HStrategyHelper
⛽ 3.26M
calculateExpectedRatios
calculates the ratios of the capital on all vaults using price from the oracle
Parameters:
Return Values:
calculateMissingTokenAmounts
calculates amount of missing tokens for uniV3 and money vaults
Parameters:
Return Values:
calculateExtraTokenAmountsForUniV3Vault
calculates extra tokens on uniV3 vault
Parameters:
Return Values:
calculateExtraTokenAmountsForMoneyVault
calculates extra tokens on money vault
Parameters:
Return Values:
calculateExpectedTokenAmountsByExpectedRatios
calculates expected amounts of tokens after rebalance
Parameters:
Return Values:
calculateCurrentTokenAmounts
calculates current amounts of tokens
Parameters:
Return Values:
calculateCurrentCapitalInToken0
calculates current capital of the strategy in token0
Parameters:
Return Values:
calculateExpectedTokenAmountsInToken0
calculates expected capitals on the vaults after rebalance
Parameters:
Return Values:
swapNeeded
return true if the token swap is needed. It is needed if we cannot mint a new position without it
Parameters:
Return Values:
tokenRebalanceNeeded
returns true if the rebalance between assets on different vaults is needed
Parameters:
Return Values:
calculateAndCheckDomainPositionParams
Parameters:
checkSpotTickDeviationFromAverage
Parameters:
calculateNewPositionTicks
Parameters:
Return Values:
calculateExpectedTokenAmounts
Parameters:
Return Values:
LStrategyHelper
⛽ 1.5M
constructor
checkOrder
tickFromPriceX96
MultiPoolHStrategyRebalancer
Inherits from DefaultAccessControlLateInit, AccessControlEnumerable, AccessControl, ERC165, Context
⛽ 7.09M
Functions
constructor
constructs a rebalancer
Parameters:
initialize
initializes the rebalancer
Parameters:
createRebalancer
creates the clone of the rebalancer
Parameters:
Return Values:
getTvls
Parameters:
processRebalance
Parameters:
calculateExpectedAmounts
Parameters:
calculateNewPosition
Parameters:
Structs
Events
PositionsMinted
Emitted when new short positions minted in uniV3Vaults
Parameters:
PositionsBurned
Emitted when old short positions burned in uniV3Vaults
Parameters:
TokensSwapped
Emitted when a swap is called on the router
Parameters:
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:
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:
commitValidatorParams
Commits staged params
Structs
Events
StagedValidatorParams
Emitted when new params are staged for commit
Parameters:
CommittedValidatorParams
Emitted when new params are staged for commit
Parameters:
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:
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:
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:
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:
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:
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:
CommitDelayedProtocolParams
Emitted when new DelayedProtocolParams are committed
Parameters:
AggregateVault
Vault that combines several integration layer Vaults into one Vault.
subvaultNfts
Get all subvalutNfts in the current Vault
Return Values:
subvaultOneBasedIndex
Get index of subvault by nft
Parameters:
Return Values:
hasSubvault
Checks if subvault is present
Parameters:
Return Values:
subvaultAt
Get subvault by index
Parameters:
Return Values:
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:
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:
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:
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:
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:
Return Values:
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:
Return Values:
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:
ProtocolFeesCharged
Emitted when protocol fees are charged
Parameters:
PerformanceFeesCharged
Emitted when performance fees are charged
Parameters:
Deposit
Emitted when liquidity is deposited
Parameters:
Withdraw
Emitted when liquidity is withdrawn
Parameters:
DepositCallbackLog
Emitted when callback in deposit failed
Parameters:
WithdrawCallbackLog
Emitted when callback in withdraw failed
Parameters:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
setOperatorParams
⛽ 51K (35K - 77K)
Set Operator params, i.e. Params that could be changed by Operator or Protocol Governance immediately.
Parameters:
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:
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:
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:
CommitDelayedProtocolPerVaultParams
Emitted when new DelayedProtocolPerVaultParams are committed
Parameters:
StageDelayedStrategyParams
Emitted when new DelayedStrategyParams are staged for commit
Parameters:
CommitDelayedStrategyParams
Emitted when new DelayedStrategyParams are committed
Parameters:
SetStrategyParams
Emitted when new StrategyParams are set.
Parameters:
SetOperatorParams
Emitted when new OperatorParams are set.
Parameters:
StageDelayedProtocolParams
Emitted when new DelayedProtocolParams are staged for commit
Parameters:
CommitDelayedProtocolParams
Emitted when new DelayedProtocolParams are committed
Parameters:
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:
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:
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:
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:
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:
removeDepositorsFromAllowlist
Remove depositors from the depositorsAllowlist
📕 The action can be done only by user with admins, owners or by approved rights
Parameters:
initialize
Initialized a new contract.
📕 Can only be initialized by vault governance
Parameters:
deposit
The function of depositing the amount of tokens in exchange
Parameters:
Return Values:
registerWithdrawal
The function of registering withdrawal of lp tokens amount
Parameters:
Return Values:
cancelWithdrawal
The function of cancelling withdrawal of lp tokens amount
Parameters:
Return Values:
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:
Return Values:
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:
WithdrawalRegistered
Emitted when a witdrawal request registered
Parameters:
WithdrawalCancelled
Emitted when some piece of the witdrawal request cancelled
Parameters:
ExecutionInvoked
Emitted when the withdrawal orderd execution completed
Parameters:
ProtocolFeesCharged
Emitted when protocol fees are charged
Parameters:
PerformanceFeesCharged
Emitted when performance fees are charged
Parameters:
Deposit
Emitted when liquidity is deposited
Parameters:
Withdraw
Emitted when liquidity is withdrawn
Parameters:
DepositCallbackLog
Emitted when callback in deposit failed
Parameters:
WithdrawCallbackLog
Emitted when callback in withdraw failed
Parameters:
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:
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:
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:
updateTargetMarginalFactor
Updates marginalFactorD9 (can be successfully called only by an admin or a strategist)
Parameters:
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:
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:
strategyParams
Strategy Params.
delayedProtocolPerVaultParams
Delayed Protocol Per Vault Params, i.e. Params that could be changed by Protocol Governance with Protocol Governance delay.
Parameters:
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:
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:
setStrategyParams
Set Strategy params, i.e. Params that could be changed by Strategy or Protocol Governance immediately.
Parameters:
createVault
Deploys a new vault.
Parameters:
Structs
Events
StageDelayedProtocolPerVaultParams
Emitted when new DelayedProtocolPerVaultParams are staged for commit
Parameters:
CommitDelayedProtocolPerVaultParams
Emitted when new DelayedProtocolPerVaultParams are committed
Parameters:
StageDelayedProtocolParams
Emitted when new DelayedProtocolParams are staged for commit
Parameters:
SetStrategyParams
Emitted when new StrategyParams are set.
Parameters:
CommitDelayedProtocolParams
Emitted when new DelayedProtocolParams are committed
Parameters:
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:
Return Values:
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:
Return Values:
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:
Return Values:
reclaimTokens
Claim ERC20 tokens from vault balance to zero vault.
📕 Cannot be called from zero vault.
Parameters:
Return Values:
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:
Return Values:
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:
Return Values:
Events
Push
Emitted on successful push
Parameters:
Pull
Emitted on successful pull
Parameters:
ReclaimTokens
Emitted when tokens are reclaimed
Parameters:
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:
initialize
Initialized a new contract.
📕 Can only be initialized by vault governance
Parameters:
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:
createVault
Deploys a new vault.
Parameters:
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:
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:
burnFarmingPosition
Parameters:
collectEarnings
⛽ 135K (121K - 195K)
Return Values:
collectRewards
Parameters:
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:
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:
Events
CollectedEarnings
Emitted when earnings are collected
Parameters:
CollectedRewards
Emitted when rewards are collected
Parameters:
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:
strategyParams
Delayed Strategy Params
Parameters:
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:
createVault
Deploys a new vault.
Parameters:
Structs
Events
SetStrategyParams
Emitted when new StrategyParams are set
Parameters:
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:
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:
Return Values:
Specs
✅ returns tokenAmounts corresponding to liquidity
tokenAmountsToLiquidity
Returns liquidity corresponding to token amounts, based on the current Uniswap position
Parameters:
Return Values:
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:
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:
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:
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:
delayedStrategyParams
Delayed Strategy Params
Parameters:
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:
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:
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:
createVault
⛽ 563K (550K - 577K)
Deploys a new vault.
Parameters:
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:
CommitDelayedProtocolParams
Emitted when new DelayedProtocolParams are committed
Parameters:
StageDelayedStrategyParams
Emitted when new DelayedStrategyParams are staged for commit
Parameters:
CommitDelayedStrategyParams
Emitted when new DelayedStrategyParams are committed
Parameters:
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:
Return Values:
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:
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:
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:
delayedProtocolPerVaultParamsTimestamp
Timestamp in unix time seconds after which staged Delayed Protocol Params Per Vault could be committed.
Parameters:
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:
commitInternalParams
Commit staged Internal Params.
Structs
Events
StagedInternalParams
Emitted when InternalParams are staged for commit
Parameters:
CommitedInternalParams
Emitted when InternalParams are staged for commit
Parameters:
DeployedVault
Emitted when New Vault is deployed
Parameters:
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:
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:
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:
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:
Return Values:
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:
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:
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:
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:
StageDelayedProtocolParams
Emitted when new DelayedProtocolParams are staged for commit
Parameters:
CommitDelayedProtocolParams
Emitted when new DelayedProtocolParams are committed
Parameters:
Last updated