From 38fa04a18e980c611762e7a9b19f672848d23635 Mon Sep 17 00:00:00 2001 From: Schlag <89420541+Schlagonia@users.noreply.github.com> Date: Fri, 20 Oct 2023 08:56:32 -0600 Subject: [PATCH] feat: add types to registry (#21) * feat: add types to registry * feat: deafult values * feat: just use vault array * chore: back info struct * chore: update to new version * fix: black * chore: update work flow * chore: reuse ivault * feat: check losses * fix: lint --- .github/workflows/test.yaml | 5 +- README.md | 16 + ape-config.yaml | 6 +- contracts/Mocks/MockFactory.sol | 6 +- .../debtAllocators/GenericDebtAllocator.sol | 10 + contracts/registry/Registry.sol | 326 ++++++---------- contracts/registry/ReleaseRegistry.sol | 8 +- scripts/deploy_address_provider.py | 7 +- scripts/deploy_registry.py | 9 +- tests/test_registry.py | 350 +++++++++++------- tests/test_release_registry.py | 14 +- 11 files changed, 377 insertions(+), 380 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fe9b19d..35854bb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,11 +16,10 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 16 - - uses: ApeWorX/github-action@v2 + - uses: ApeWorX/github-action@v2.0 with: python-version: '3.10' - ape-version-pin: "==0.6.8" - ape-plugins-list: 'solidity==0.6.3 vyper==0.6.5 hardhat==0.6.4 infura==0.6.1 etherscan==0.6.4' + - name: install vyper run: pip install git+https://github.com/vyperlang/vyper - run: ape compile --force --size diff --git a/README.md b/README.md index 26255a3..1002529 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,19 @@ export WEB3_INFURA_PROJECT_ID=your_infura_api_key export ETHERSCAN_API_KEY=your_api_key + +### Deployment + +Deployment of periphery contracts such as the [Registry Factory](https://github.com/yearn/vault-periphery/blob/master/contracts/registry/RegistryFactory.sol) or [Address Provider](https://github.com/yearn/vault-periphery/blob/master/contracts/AddressProvider.vy) are done using a create2 factory in order to get a deterministic address that is the same on each EVM chain. + +This can be done permissionlessly if the most recent contract has not yet been deployed on a chain you would like to use it on. + +1. [Add an Ape account](https://docs.apeworx.io/ape/stable/commands/accounts.html) +2. Go to the contracts specific deployment script under `scripts/` and add your account name to the `accounts.load("you_acct_name")` at the top of the script. +3. Run the deployment script + ```sh + ape run scripts/deploy_contract_name.py --network YOUR_RPC_URL + ``` + - For chains that don't support 1559 tx's you may need to add a `type="0x0"` argument at the end of the deployment tx. + - ie `tx = deployer_contract.deploy(bytecode, salt, sender=deployer, type="0x0")` +3. The address the contract was deployed at will print in the console and should match any other chain the same version has been deployed on. \ No newline at end of file diff --git a/ape-config.yaml b/ape-config.yaml index 6d64527..858dc57 100644 --- a/ape-config.yaml +++ b/ape-config.yaml @@ -16,16 +16,20 @@ dependencies: - name: yearn-vaults github: yearn/yearn-vaults-v3 ref: v3.0.1 + exclude: + - test/ - name: tokenized-strategy github: yearn/tokenized-strategy ref: v3.0.1 contracts_folder: src exclude: - - src/test/**/* + - test/ - name: periphery github: yearn/tokenized-strategy-periphery ref: master contracts_folder: src + exclude: + - test/ solidity: import_remapping: diff --git a/contracts/Mocks/MockFactory.sol b/contracts/Mocks/MockFactory.sol index 91c4f23..28341bf 100644 --- a/contracts/Mocks/MockFactory.sol +++ b/contracts/Mocks/MockFactory.sol @@ -2,11 +2,11 @@ pragma solidity 0.8.18; contract MockFactory { - string public api_version; + string public apiVersion; address public vault_bluePrint; - constructor(string memory apiVersion) { - api_version = apiVersion; + constructor(string memory _apiVersion) { + apiVersion = _apiVersion; } } diff --git a/contracts/debtAllocators/GenericDebtAllocator.sol b/contracts/debtAllocators/GenericDebtAllocator.sol index a4c85f2..0575924 100644 --- a/contracts/debtAllocators/GenericDebtAllocator.sol +++ b/contracts/debtAllocators/GenericDebtAllocator.sol @@ -156,6 +156,16 @@ contract GenericDebtAllocator is Governance { // Check if it's over the threshold. if (toPull > config.minimumChange) { + // Can't lower debt if there is unrealised losses. + if ( + _vault.assess_share_of_unrealised_losses( + _strategy, + params.current_debt + ) > 0 + ) { + return (false, bytes("unrealised loss")); + } + // If so return true and the calldata. return ( true, diff --git a/contracts/registry/Registry.sol b/contracts/registry/Registry.sol index 576a60d..49f45cf 100644 --- a/contracts/registry/Registry.sol +++ b/contracts/registry/Registry.sol @@ -5,21 +5,10 @@ import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {Governance} from "@periphery/utils/Governance.sol"; +import {IVault} from "@yearn-vaults/interfaces/IVault.sol"; import {IVaultFactory} from "@yearn-vaults/interfaces/IVaultFactory.sol"; import {ReleaseRegistry} from "./ReleaseRegistry.sol"; -interface IVault { - function asset() external view returns (address); - - function api_version() external view returns (string memory); -} - -interface IStrategy { - function asset() external view returns (address); - - function apiVersion() external view returns (string memory); -} - /** * @title YearnV3 Registry * @author yearn.finance @@ -35,25 +24,15 @@ contract Registry is Governance { event NewEndorsedVault( address indexed vault, address indexed asset, - uint256 releaseVersion - ); - - event NewEndorsedStrategy( - address indexed strategy, - address indexed asset, - uint256 releaseVersion + uint256 releaseVersion, + uint256 vaultType ); event RemovedVault( address indexed vault, address indexed asset, - uint256 releaseVersion - ); - - event RemovedStrategy( - address indexed strategy, - address indexed asset, - uint256 releaseVersion + uint256 releaseVersion, + uint256 vaultType ); // Struct stored for every endorsed vault or strategy for @@ -62,13 +41,21 @@ contract Registry is Governance { // The token thats being used. address asset; // The release number corresponding to the release registries version. - uint256 releaseVersion; + uint96 releaseVersion; + // Type of vault. + uint128 vaultType; // Time when the vault was deployed for easier indexing. - uint256 deploymentTimestamp; + uint128 deploymentTimestamp; // String so that management to tag a vault with any info for FE's. string tag; } + // Default type used for Multi strategy "Allocator" vaults. + uint256 public constant MULTI_STRATEGY_TYPE = 1; + + // Default type used for Single "Tokenized" Strategy vaults. + uint256 public constant SINGLE_STRATEGY_TYPE = 2; + // Custom name for this Registry. string public name; @@ -84,11 +71,8 @@ contract Registry is Governance { // asset => array of all endorsed vaults. mapping(address => address[]) internal _endorsedVaults; - // asset => array of all endorsed strategies. - mapping(address => address[]) internal _endorsedStrategies; - // vault/strategy address => Info struct. - mapping(address => Info) public info; + mapping(address => Info) public vaultInfo; /** * @param _governance Address to set as owner of the Registry. @@ -130,16 +114,6 @@ contract Registry is Governance { return _endorsedVaults[_asset].length; } - /** - * @notice The amount of endorsed strategies for a specific token. - * @return The amount of endorsed strategies. - */ - function numEndorsedStrategies( - address _asset - ) public view returns (uint256) { - return _endorsedStrategies[_asset].length; - } - /** * @notice Get the array of vaults endorsed for an `_asset`. * @param _asset The underlying token used by the vaults. @@ -151,17 +125,6 @@ contract Registry is Governance { return _endorsedVaults[_asset]; } - /** - * @notice Get the array of strategies endorsed for an `_asset`. - * @param _asset The underlying token used by the strategies. - * @return The endorsed strategies. - */ - function getEndorsedStrategies( - address _asset - ) external view returns (address[] memory) { - return _endorsedStrategies[_asset]; - } - /** * @notice Get all endorsed vaults deployed using the Registry. * @dev This will return a nested array of all vaults deployed @@ -187,33 +150,42 @@ contract Registry is Governance { } /** - * @notice Get all strategies endorsed through this registry. - * @dev This will return a nested array of all endorsed strategies - * separated by their underlying asset. - * - * This is only meant for off chain viewing and should not be used during any - * on chain tx's. - * - * @return allEndorsedStrategies A nested array containing all strategies. + * @notice + * Create and endorse a new multi strategy "Allocator" + * vault and endorse it in this registry. + * @dev + * Throws if caller isn't `owner`. + * Throws if no releases are registered yet. + * Emits a `NewEndorsedVault` event. + * @param _asset The asset that may be deposited into the new Vault. + * @param _name Specify a custom Vault name. . + * @param _symbol Specify a custom Vault symbol name. + * @param _roleManager The address authorized for guardian interactions in the new Vault. + * @param _profitMaxUnlockTime The time strategy profits will unlock over. + * @return _vault address of the newly-deployed vault */ - function getAllEndorsedStrategies() - external - view - returns (address[][] memory allEndorsedStrategies) - { - address[] memory allAssets = assets; - uint256 length = assets.length; - - allEndorsedStrategies = new address[][](length); - for (uint256 i; i < length; ++i) { - allEndorsedStrategies[i] = _endorsedStrategies[allAssets[i]]; - } + function newEndorsedVault( + address _asset, + string memory _name, + string memory _symbol, + address _roleManager, + uint256 _profitMaxUnlockTime + ) public returns (address _vault) { + return + newEndorsedVault( + _asset, + _name, + _symbol, + _roleManager, + _profitMaxUnlockTime, + 0 // Default to latest version. + ); } /** * @notice - * Create a new vault for the given asset using a given release in the - * release registry. + * Create and endorse a new multi strategy "Allocator" + * vault and endorse it in this registry. * @dev * Throws if caller isn't `owner`. * Throws if no releases are registered yet. @@ -250,7 +222,7 @@ contract Registry is Governance { // Deploy New vault. _vault = IVaultFactory(factory).deploy_new_vault( - _asset, + ERC20(_asset), _name, _symbol, _roleManager, @@ -258,7 +230,35 @@ contract Registry is Governance { ); // Register the vault with this Registry - _registerVault(_vault, _asset, _releaseTarget, block.timestamp); + _registerVault( + _vault, + _asset, + _releaseTarget, + MULTI_STRATEGY_TYPE, + block.timestamp + ); + } + + /** + * @notice Endorse an already deployed multi strategy vault. + * @dev To be used with default values for `_releaseDelta`, `_vaultType` + * and `_deploymentTimestamp`. + + * @param _vault Address of the vault to endorse. + */ + function endorseMultiStrategyVault(address _vault) external { + endorseVault(_vault, 0, MULTI_STRATEGY_TYPE, 0); + } + + /** + * @notice Endorse an already deployed Single Strategy vault. + * @dev To be used with default values for `_releaseDelta`, `_vaultType` + * and `_deploymentTimestamp`. + * + * @param _vault Address of the vault to endorse. + */ + function endorseSingleStrategyVault(address _vault) external { + endorseVault(_vault, 0, SINGLE_STRATEGY_TYPE, 0); } /** @@ -271,25 +271,34 @@ contract Registry is Governance { * Emits a `NewEndorsedVault` event. * @param _vault The vault that will be endorsed by the Registry. * @param _releaseDelta Specify the number of releases prior to the latest to use as a target. + * @param _vaultType Type of vault to endorse. * @param _deploymentTimestamp The timestamp of when the vault was deployed for FE use. */ function endorseVault( address _vault, uint256 _releaseDelta, + uint256 _vaultType, uint256 _deploymentTimestamp ) public onlyGovernance { + // Cannot endorse twice. + require(vaultInfo[_vault].asset == address(0), "endorsed"); + require(_vaultType != 0, "no 0 type"); + require(_vaultType <= type(uint128).max, "type too high"); + require(_deploymentTimestamp <= block.timestamp, "!deployment time"); + // Will underflow if no releases created yet, or targeting prior to release history - uint256 releaseTarget = ReleaseRegistry(releaseRegistry).numReleases() - + uint256 _releaseTarget = ReleaseRegistry(releaseRegistry) + .numReleases() - 1 - _releaseDelta; // dev: no releases // Get the API version for the target specified string memory apiVersion = IVaultFactory( - ReleaseRegistry(releaseRegistry).factories(releaseTarget) - ).api_version(); + ReleaseRegistry(releaseRegistry).factories(_releaseTarget) + ).apiVersion(); require( - keccak256(bytes(IVault(_vault).api_version())) == + keccak256(bytes(IVault(_vault).apiVersion())) == keccak256(bytes((apiVersion))), "Wrong API Version" ); @@ -298,36 +307,28 @@ contract Registry is Governance { _registerVault( _vault, IVault(_vault).asset(), - releaseTarget, + _releaseTarget, + _vaultType, _deploymentTimestamp ); } - /** - * @notice Endorse an already deployed vault. - * @dev To be used with default values for `_releaseDelta` and - * `_deploymentTimestamp`. - * - * @param _vault Address of the vault to endorse. - */ - function endorseVault(address _vault) external { - endorseVault(_vault, 0, 0); - } - function _registerVault( address _vault, address _asset, uint256 _releaseTarget, + uint256 _vaultType, uint256 _deploymentTimestamp ) internal { // Add to the endorsed vaults array. _endorsedVaults[_asset].push(_vault); // Set the Info struct for this vault - info[_vault] = Info({ + vaultInfo[_vault] = Info({ asset: _asset, - releaseVersion: _releaseTarget, - deploymentTimestamp: _deploymentTimestamp, + releaseVersion: uint96(_releaseTarget), + vaultType: uint128(_vaultType), + deploymentTimestamp: uint128(_deploymentTimestamp), tag: "" }); @@ -337,73 +338,7 @@ contract Registry is Governance { assetIsUsed[_asset] = true; } - emit NewEndorsedVault(_vault, _asset, _releaseTarget); - } - - /** - * @notice - * Adds an existing strategy to the list of "endorsed" strategies for that asset. - * @dev - * Throws if caller isn't `owner`. - * Throws if no releases are registered yet. - * Throws if `strategies`'s api version does not match the release specified. - * Emits a `NewEndorsedStrategy` event. - * @param _strategy The strategy that will be endorsed by the Registry. - * @param _releaseDelta Specify the number of releases prior to the latest to use as a target. - * @param _deploymentTimestamp The timestamp of when the strategy was deployed for FE use. - */ - function endorseStrategy( - address _strategy, - uint256 _releaseDelta, - uint256 _deploymentTimestamp - ) public onlyGovernance { - // Will underflow if no releases created yet, or targeting prior to release history - uint256 _releaseTarget = ReleaseRegistry(releaseRegistry) - .numReleases() - - 1 - - _releaseDelta; // dev: no releases - - // Get the API version for this release - string memory apiVersion = IVaultFactory( - ReleaseRegistry(releaseRegistry).factories(_releaseTarget) - ).api_version(); - - // Make sure the API versions match - require( - keccak256(bytes((IStrategy(_strategy).apiVersion()))) == - keccak256(bytes((apiVersion))), - "Wrong API Version" - ); - - address _asset = IStrategy(_strategy).asset(); - - _endorsedStrategies[_asset].push(_strategy); - - info[_strategy] = Info({ - asset: _asset, - releaseVersion: _releaseTarget, - deploymentTimestamp: _deploymentTimestamp, - tag: "" - }); - - if (!assetIsUsed[_asset]) { - // We have a new asset to add - assets.push(_asset); - assetIsUsed[_asset] = true; - } - - emit NewEndorsedStrategy(_strategy, _asset, _releaseTarget); - } - - /** - * @notice Endorse an already deployed strategy. - * @dev To be used with default values for `_releaseDelta` and - * `_deploymentTimestamp`. - * - * @param _strategy Address of the strategy to endorse. - */ - function endorseStrategy(address _strategy) external { - endorseStrategy(_strategy, 0, 0); + emit NewEndorsedVault(_vault, _asset, _releaseTarget, _vaultType); } /** @@ -419,8 +354,8 @@ contract Registry is Governance { address _vault, string memory _tag ) external onlyGovernance { - require(info[_vault].asset != address(0), "!Endorsed"); - info[_vault].tag = _tag; + require(vaultInfo[_vault].asset != address(0), "!Endorsed"); + vaultInfo[_vault].tag = _tag; } /** @@ -438,13 +373,13 @@ contract Registry is Governance { address _vault, uint256 _index ) external onlyGovernance { - require(info[_vault].asset != address(0), "!endorsed"); + require(vaultInfo[_vault].asset != address(0), "!endorsed"); // Get the asset the vault is using. address asset = IVault(_vault).asset(); // Get the release version for this specific vault. uint256 releaseTarget = ReleaseRegistry(releaseRegistry).releaseTargets( - IVault(_vault).api_version() + IVault(_vault).apiVersion() ); require(_endorsedVaults[asset][_index] == _vault, "wrong index"); @@ -457,52 +392,16 @@ contract Registry is Governance { // Pop the last item off the array. _endorsedVaults[asset].pop(); - // Reset the info config. - delete info[_vault]; - // Emit the event. - emit RemovedVault(_vault, asset, releaseTarget); - } - - /** - * @notice Remove a `_strategy` at a specific `_index`. - * @dev Can be used as a efficient way to remove a strategy - * to not have to iterate over the full array. - * - * NOTE: This will not remove the asset from the `assets` array - * if it is no longer in use and will have to be done manually. - * - * @param _strategy Address of the strategy to remove. - * @param _index Index in the `endorsedStrategies` array `_strategy` sits at. - */ - function removeStrategy( - address _strategy, - uint256 _index - ) external onlyGovernance { - require(info[_strategy].asset != address(0), "!endorsed"); - - // Get the asset the vault is using. - address asset = IStrategy(_strategy).asset(); - // Get the release version for this specific vault. - uint256 releaseTarget = ReleaseRegistry(releaseRegistry).releaseTargets( - IStrategy(_strategy).apiVersion() + emit RemovedVault( + _vault, + asset, + releaseTarget, + vaultInfo[_vault].vaultType ); - require(_endorsedStrategies[asset][_index] == _strategy, "wrong index"); - - // Set the last index to the spot we are removing. - _endorsedStrategies[asset][_index] = _endorsedStrategies[asset][ - _endorsedStrategies[asset].length - 1 - ]; - - // Pop the last item off the array. - _endorsedStrategies[asset].pop(); - - // Reset the info config. - delete info[_strategy]; - - // Emit the event. - emit RemovedStrategy(_strategy, asset, releaseTarget); + // Delete the struct. + delete vaultInfo[_vault]; } /** @@ -518,12 +417,7 @@ contract Registry is Governance { uint256 _index ) external onlyGovernance { require(assetIsUsed[_asset], "!in use"); - require( - _endorsedVaults[_asset].length == 0 && - _endorsedStrategies[_asset].length == 0, - "still in use" - ); - + require(_endorsedVaults[_asset].length == 0, "still in use"); require(assets[_index] == _asset, "wrong asset"); // Replace `_asset` with the last index. diff --git a/contracts/registry/ReleaseRegistry.sol b/contracts/registry/ReleaseRegistry.sol index 2408598..807b3e8 100644 --- a/contracts/registry/ReleaseRegistry.sol +++ b/contracts/registry/ReleaseRegistry.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.18; import {Governance} from "@periphery/utils/Governance.sol"; interface IFactory { - function api_version() external view returns (string memory); + function apiVersion() external view returns (string memory); } /** @@ -51,7 +51,7 @@ contract ReleaseRegistry is Governance { * @return The api version of the latest release. */ function latestRelease() external view returns (string memory) { - return IFactory(factories[numReleases - 1]).api_version(); // dev: no release + return IFactory(factories[numReleases - 1]).apiVersion(); // dev: no release } /** @@ -69,13 +69,13 @@ contract ReleaseRegistry is Governance { // Check if the release is different from the current one uint256 releaseId = numReleases; - string memory apiVersion = IFactory(_factory).api_version(); + string memory apiVersion = IFactory(_factory).apiVersion(); if (releaseId > 0) { // Make sure this isn't the same as the last one require( keccak256( - bytes(IFactory(factories[releaseId - 1]).api_version()) + bytes(IFactory(factories[releaseId - 1]).apiVersion()) ) != keccak256(bytes(apiVersion)), "ReleaseRegistry: same api version" ); diff --git a/scripts/deploy_address_provider.py b/scripts/deploy_address_provider.py index 5764094..33fdfc0 100644 --- a/scripts/deploy_address_provider.py +++ b/scripts/deploy_address_provider.py @@ -6,6 +6,8 @@ import hashlib from copy import deepcopy +deployer = accounts.load("") + def deploy_address_provider(): print("Deploying Address Provider on ChainID", chain.chain_id) @@ -14,7 +16,6 @@ def deploy_address_provider(): return address_provider = project.AddressProvider - deployer = accounts.load("") deployer_contract = project.Deployer.at( "0x8D85e7c9A4e369E53Acc8d5426aE1568198b0112" ) @@ -34,7 +35,9 @@ def deploy_address_provider(): print("Init balance:", deployer.balance / 1e18) # generate and deploy - constructor = address_provider.constructor.encode_input("GOV") + constructor = address_provider.constructor.encode_input( + "0x33333333D5eFb92f19a5F94a43456b3cec2797AE" + ) deploy_bytecode = HexBytes( HexBytes(address_provider.contract_type.deployment_bytecode.bytecode) diff --git a/scripts/deploy_registry.py b/scripts/deploy_registry.py index 7f8ecc3..509c388 100644 --- a/scripts/deploy_registry.py +++ b/scripts/deploy_registry.py @@ -6,6 +6,8 @@ import hashlib from copy import deepcopy +deployer = accounts.load("") + def deploy_release_and_factory(): print("Deploying Vault Registry on ChainID", chain.chain_id) @@ -15,12 +17,11 @@ def deploy_release_and_factory(): release_registry = project.ReleaseRegistry factory = project.RegistryFactory - deployer = accounts.load("") deployer_contract = project.Deployer.at( "0x8D85e7c9A4e369E53Acc8d5426aE1568198b0112" ) - salt_string = "v3.0.0" + salt_string = "v3.0.1" # Create a SHA-256 hash object hash_object = hashlib.sha256() @@ -38,7 +39,9 @@ def deploy_release_and_factory(): if input("Do you want to deploy a new Release Registry? ") == "y": # generate and deploy release registry - release_constructor = release_registry.constructor.encode_input("GOV") + release_constructor = release_registry.constructor.encode_input( + "0x33333333D5eFb92f19a5F94a43456b3cec2797AE" + ) release_deploy_bytecode = HexBytes( HexBytes(release_registry.contract_type.deployment_bytecode.bytecode) diff --git a/tests/test_registry.py b/tests/test_registry.py index f0179ba..0398b4a 100644 --- a/tests/test_registry.py +++ b/tests/test_registry.py @@ -11,7 +11,7 @@ def add_new_release(release_registry, factory, owner): assert len(event) == 1 assert event[0].factory == factory - assert event[0].apiVersion == factory.api_version() + assert event[0].apiVersion == factory.apiVersion() def test__set_up(registry, asset, release_registry, daddy): @@ -19,7 +19,6 @@ def test__set_up(registry, asset, release_registry, daddy): assert registry.releaseRegistry() == release_registry assert registry.numAssets() == 0 assert registry.numEndorsedVaults(asset) == 0 - assert registry.numEndorsedStrategies(asset) == 0 def test__deploy_new_vault(registry, asset, release_registry, vault_factory, daddy): @@ -49,6 +48,7 @@ def test__deploy_new_vault(registry, asset, release_registry, vault_factory, dad assert event[0].asset == asset.address assert event[0].vault == new_vault assert event[0].releaseVersion == 0 + assert event[0].vaultType == registry.MULTI_STRATEGY_TYPE() # make sure the vault is set up correctly assert new_vault.name() == name @@ -65,9 +65,13 @@ def test__deploy_new_vault(registry, asset, release_registry, vault_factory, dad assert len(all_vaults) == 1 assert len(all_vaults[0]) == 1 assert all_vaults[0][0] == new_vault.address - assert registry.info(new_vault.address).asset == asset.address - assert registry.info(new_vault.address).releaseVersion == 0 - assert registry.info(new_vault.address).deploymentTimestamp == block + assert registry.vaultInfo(new_vault.address).asset == asset.address + assert registry.vaultInfo(new_vault.address).releaseVersion == 0 + assert registry.vaultInfo(new_vault.address).deploymentTimestamp == block + assert ( + registry.vaultInfo(new_vault.address).vaultType + == registry.MULTI_STRATEGY_TYPE() + ) def test__endorse_deployed_vault( @@ -94,7 +98,17 @@ def test__endorse_deployed_vault( ) # Endorse vault - registry.endorseVault(new_vault.address, 0, block, sender=daddy) + tx = registry.endorseVault( + new_vault.address, 0, registry.MULTI_STRATEGY_TYPE(), block, sender=daddy + ) + + event = list(tx.decode_logs(registry.NewEndorsedVault)) + + assert len(event) == 1 + assert event[0].vault == new_vault.address + assert event[0].asset == asset.address + assert event[0].releaseVersion == 0 + assert event[0].vaultType == registry.MULTI_STRATEGY_TYPE() # Make sure it was endorsed correctly assert registry.numAssets() == 1 @@ -105,9 +119,13 @@ def test__endorse_deployed_vault( assert len(all_vaults) == 1 assert len(all_vaults[0]) == 1 assert all_vaults[0][0] == new_vault.address - assert registry.info(new_vault.address).asset == asset.address - assert registry.info(new_vault.address).releaseVersion == 0 - assert registry.info(new_vault.address).deploymentTimestamp == block + assert registry.vaultInfo(new_vault.address).asset == asset.address + assert registry.vaultInfo(new_vault.address).releaseVersion == 0 + assert ( + registry.vaultInfo(new_vault.address).vaultType + == registry.MULTI_STRATEGY_TYPE() + ) + assert registry.vaultInfo(new_vault.address).deploymentTimestamp == block def test__endorse_deployed_vault__default_values( @@ -132,7 +150,15 @@ def test__endorse_deployed_vault__default_values( ) # Endorse vault - registry.endorseVault(new_vault.address, sender=daddy) + tx = registry.endorseMultiStrategyVault(new_vault.address, sender=daddy) + + event = list(tx.decode_logs(registry.NewEndorsedVault)) + + assert len(event) == 1 + assert event[0].vault == new_vault.address + assert event[0].asset == asset.address + assert event[0].releaseVersion == 0 + assert event[0].vaultType == registry.MULTI_STRATEGY_TYPE() # Make sure it was endorsed correctly assert registry.numAssets() == 1 @@ -143,9 +169,13 @@ def test__endorse_deployed_vault__default_values( assert len(all_vaults) == 1 assert len(all_vaults[0]) == 1 assert all_vaults[0][0] == new_vault.address - assert registry.info(new_vault.address).asset == asset.address - assert registry.info(new_vault.address).releaseVersion == 0 - assert registry.info(new_vault.address).deploymentTimestamp == 0 + assert registry.vaultInfo(new_vault.address).asset == asset.address + assert registry.vaultInfo(new_vault.address).releaseVersion == 0 + assert ( + registry.vaultInfo(new_vault.address).vaultType + == registry.MULTI_STRATEGY_TYPE() + ) + assert registry.vaultInfo(new_vault.address).deploymentTimestamp == 0 def test__endorse_deployed_strategy( @@ -157,27 +187,34 @@ def test__endorse_deployed_strategy( ) block = chain.pending_timestamp - 1 - tx = registry.endorseStrategy(strategy, 0, block, sender=daddy) + tx = registry.endorseVault( + strategy, 0, registry.SINGLE_STRATEGY_TYPE(), block, sender=daddy + ) - event = list(tx.decode_logs(registry.NewEndorsedStrategy)) + event = list(tx.decode_logs(registry.NewEndorsedVault)) assert len(event) == 1 - assert event[0].strategy == strategy.address + assert event[0].vault == strategy.address assert event[0].asset == asset.address assert event[0].releaseVersion == 0 + assert event[0].vaultType == registry.SINGLE_STRATEGY_TYPE() # Make sure it was endorsed correctly assert registry.numAssets() == 1 assert registry.getAssets()[0] == asset.address - assert registry.numEndorsedStrategies(asset) == 1 - assert registry.getEndorsedStrategies(asset)[0] == strategy.address - all_strategies = registry.getAllEndorsedStrategies() - assert len(all_strategies) == 1 - assert len(all_strategies[0]) == 1 - assert all_strategies[0][0] == strategy.address - assert registry.info(strategy.address).asset == asset.address - assert registry.info(strategy.address).releaseVersion == 0 - assert registry.info(strategy.address).deploymentTimestamp == block + assert registry.numEndorsedVaults(asset) == 1 + assert registry.getEndorsedVaults(asset)[0] == strategy.address + all_vaults = registry.getAllEndorsedVaults() + assert len(all_vaults) == 1 + assert len(all_vaults[0]) == 1 + assert all_vaults[0][0] == strategy.address + assert registry.vaultInfo(strategy.address).asset == asset.address + assert registry.vaultInfo(strategy.address).releaseVersion == 0 + assert ( + registry.vaultInfo(strategy.address).vaultType + == registry.SINGLE_STRATEGY_TYPE() + ) + assert registry.vaultInfo(strategy.address).deploymentTimestamp == block def test__endorse_deployed_strategy__default_values( @@ -188,27 +225,32 @@ def test__endorse_deployed_strategy__default_values( release_registry=release_registry, factory=vault_factory, owner=daddy ) - tx = registry.endorseStrategy(strategy, sender=daddy) + tx = registry.endorseSingleStrategyVault(strategy, sender=daddy) - event = list(tx.decode_logs(registry.NewEndorsedStrategy)) + event = list(tx.decode_logs(registry.NewEndorsedVault)) assert len(event) == 1 - assert event[0].strategy == strategy.address + assert event[0].vault == strategy.address assert event[0].asset == asset.address assert event[0].releaseVersion == 0 + assert event[0].vaultType == registry.SINGLE_STRATEGY_TYPE() # Make sure it was endorsed correctly assert registry.numAssets() == 1 assert registry.getAssets()[0] == asset.address - assert registry.numEndorsedStrategies(asset) == 1 - assert registry.getEndorsedStrategies(asset)[0] == strategy.address - all_strategies = registry.getAllEndorsedStrategies() - assert len(all_strategies) == 1 - assert len(all_strategies[0]) == 1 - assert all_strategies[0][0] == strategy.address - assert registry.info(strategy.address).asset == asset.address - assert registry.info(strategy.address).releaseVersion == 0 - assert registry.info(strategy.address).deploymentTimestamp == 0 + assert registry.numEndorsedVaults(asset) == 1 + assert registry.getEndorsedVaults(asset)[0] == strategy.address + all_vaults = registry.getAllEndorsedVaults() + assert len(all_vaults) == 1 + assert len(all_vaults[0]) == 1 + assert all_vaults[0][0] == strategy.address + assert registry.vaultInfo(strategy.address).asset == asset.address + assert registry.vaultInfo(strategy.address).releaseVersion == 0 + assert ( + registry.vaultInfo(strategy.address).vaultType + == registry.SINGLE_STRATEGY_TYPE() + ) + assert registry.vaultInfo(strategy.address).deploymentTimestamp == 0 def test__deploy_vault_with_new_release( @@ -248,6 +290,7 @@ def test__deploy_vault_with_new_release( assert event[0].asset == asset.address assert event[0].vault == new_vault assert event[0].releaseVersion == 1 + assert event[0].vaultType == registry.MULTI_STRATEGY_TYPE() # make sure the vault is set up correctly assert new_vault.name() == name @@ -264,9 +307,13 @@ def test__deploy_vault_with_new_release( assert len(all_vaults) == 1 assert len(all_vaults[0]) == 1 assert all_vaults[0][0] == new_vault.address - assert registry.info(new_vault.address).asset == asset.address - assert registry.info(new_vault.address).releaseVersion == 1 - assert registry.info(new_vault.address).deploymentTimestamp == block + assert registry.vaultInfo(new_vault.address).asset == asset.address + assert registry.vaultInfo(new_vault.address).releaseVersion == 1 + assert ( + registry.vaultInfo(new_vault.address).vaultType + == registry.MULTI_STRATEGY_TYPE() + ) + assert registry.vaultInfo(new_vault.address).deploymentTimestamp == block def test__deploy_vault_with_old_release( @@ -306,6 +353,7 @@ def test__deploy_vault_with_old_release( assert event[0].asset == asset.address assert event[0].vault == new_vault assert event[0].releaseVersion == 0 + assert event[0].vaultType == registry.MULTI_STRATEGY_TYPE() # make sure the vault is set up correctly assert new_vault.name() == name @@ -322,9 +370,13 @@ def test__deploy_vault_with_old_release( assert len(all_vaults) == 1 assert len(all_vaults[0]) == 1 assert all_vaults[0][0] == new_vault.address - assert registry.info(new_vault.address).asset == asset.address - assert registry.info(new_vault.address).releaseVersion == 0 - assert registry.info(new_vault.address).deploymentTimestamp == block + assert registry.vaultInfo(new_vault.address).asset == asset.address + assert registry.vaultInfo(new_vault.address).releaseVersion == 0 + assert ( + registry.vaultInfo(new_vault.address).vaultType + == registry.MULTI_STRATEGY_TYPE() + ) + assert registry.vaultInfo(new_vault.address).deploymentTimestamp == block def test__endorse_deployed_vault_wrong_api__reverts( @@ -358,9 +410,9 @@ def test__endorse_deployed_vault_wrong_api__reverts( # Endorse vault with incorrect api version with ape.reverts("Wrong API Version"): - registry.endorseVault(new_vault, 1, 0, sender=daddy) + registry.endorseVault(new_vault, 1, 1, 0, sender=daddy) - registry.endorseVault(new_vault, 0, 0, sender=daddy) + registry.endorseVault(new_vault, 0, registry.MULTI_STRATEGY_TYPE(), 0, sender=daddy) def test__endorse_strategy_wrong_api__reverts( @@ -383,9 +435,11 @@ def test__endorse_strategy_wrong_api__reverts( # Endorse vault with incorrect api version with ape.reverts("Wrong API Version"): - registry.endorseStrategy(strategy, 1, 0, sender=daddy) + registry.endorseVault( + strategy, 1, registry.SINGLE_STRATEGY_TYPE(), 0, sender=daddy + ) - registry.endorseStrategy(strategy, 0, 0, sender=daddy) + registry.endorseVault(strategy, 0, registry.SINGLE_STRATEGY_TYPE(), 0, sender=daddy) def test__tag_vault(registry, asset, release_registry, vault_factory, daddy, strategy): @@ -405,32 +459,32 @@ def test__tag_vault(registry, asset, release_registry, vault_factory, daddy, str vault = project.dependencies["yearn-vaults"]["v3.0.1"].VaultV3.at(event[0].vault) # Make sure it is endorsed but not tagged. - assert registry.info(vault.address).asset == asset.address - assert registry.info(vault.address).tag == "" + assert registry.vaultInfo(vault.address).asset == asset.address + assert registry.vaultInfo(vault.address).tag == "" tag = "Test Tag" registry.tagVault(vault.address, tag, sender=daddy) - assert registry.info(vault.address).asset == asset.address - assert registry.info(vault.address).tag == tag + assert registry.vaultInfo(vault.address).asset == asset.address + assert registry.vaultInfo(vault.address).tag == tag # Try to tag an un endorsed vault with ape.reverts("!Endorsed"): registry.tagVault(strategy.address, tag, sender=daddy) # Endorse the strategy then tag it. - registry.endorseStrategy(strategy.address, sender=daddy) + registry.endorseSingleStrategyVault(strategy.address, sender=daddy) - assert registry.info(strategy.address).asset == asset.address - assert registry.info(strategy.address).tag == "" + assert registry.vaultInfo(strategy.address).asset == asset.address + assert registry.vaultInfo(strategy.address).tag == "" tag = "Test Tag" registry.tagVault(strategy.address, tag, sender=daddy) - assert registry.info(strategy.address).asset == asset.address - assert registry.info(strategy.address).tag == tag + assert registry.vaultInfo(strategy.address).asset == asset.address + assert registry.vaultInfo(strategy.address).tag == tag def test__remove_vault(registry, asset, release_registry, vault_factory, daddy): @@ -459,6 +513,7 @@ def test__remove_vault(registry, asset, release_registry, vault_factory, daddy): assert len(event) == 1 assert event[0].asset == asset.address assert event[0].vault == new_vault + assert event[0].vaultType == registry.MULTI_STRATEGY_TYPE() assert event[0].releaseVersion == 0 # Make sure it was endorsed correctly @@ -470,9 +525,13 @@ def test__remove_vault(registry, asset, release_registry, vault_factory, daddy): assert len(all_vaults) == 1 assert len(all_vaults[0]) == 1 assert all_vaults[0][0] == new_vault.address - assert registry.info(new_vault.address).asset == asset.address - assert registry.info(new_vault.address).releaseVersion == 0 - assert registry.info(new_vault.address).deploymentTimestamp == block + assert registry.vaultInfo(new_vault.address).asset == asset.address + assert registry.vaultInfo(new_vault.address).releaseVersion == 0 + assert ( + registry.vaultInfo(new_vault.address).vaultType + == registry.MULTI_STRATEGY_TYPE() + ) + assert registry.vaultInfo(new_vault.address).deploymentTimestamp == block # Remove the vault tx = registry.removeVault(new_vault, 0, sender=daddy) @@ -483,6 +542,7 @@ def test__remove_vault(registry, asset, release_registry, vault_factory, daddy): assert event[0].vault == new_vault.address assert event[0].asset == asset.address assert event[0].releaseVersion == 0 + assert event[0].vaultType == registry.MULTI_STRATEGY_TYPE() # Make sure it was removed assert registry.numAssets() == 1 @@ -492,10 +552,11 @@ def test__remove_vault(registry, asset, release_registry, vault_factory, daddy): all_vaults = registry.getAllEndorsedVaults() assert len(all_vaults) == 1 assert all_vaults[0] == [] - assert registry.info(new_vault.address).asset == ZERO_ADDRESS - assert registry.info(new_vault.address).releaseVersion == 0 - assert registry.info(new_vault.address).deploymentTimestamp == 0 - assert registry.info(new_vault.address).tag == "" + assert registry.vaultInfo(new_vault.address).asset == ZERO_ADDRESS + assert registry.vaultInfo(new_vault.address).releaseVersion == 0 + assert registry.vaultInfo(new_vault.address).deploymentTimestamp == 0 + assert registry.vaultInfo(new_vault.address).vaultType == 0 + assert registry.vaultInfo(new_vault.address).tag == "" def test__remove_vault__two_vaults( @@ -540,10 +601,10 @@ def test__remove_vault__two_vaults( assert len(all_vaults) == 1 assert len(all_vaults[0]) == 2 assert all_vaults[0] == [new_vault.address, second_vault.address] - assert registry.info(new_vault.address).asset == asset.address - assert registry.info(new_vault.address).releaseVersion == 0 - assert registry.info(second_vault.address).asset == asset.address - assert registry.info(second_vault.address).releaseVersion == 0 + assert registry.vaultInfo(new_vault.address).asset == asset.address + assert registry.vaultInfo(new_vault.address).releaseVersion == 0 + assert registry.vaultInfo(second_vault.address).asset == asset.address + assert registry.vaultInfo(second_vault.address).releaseVersion == 0 # Remove the first vault tx = registry.removeVault(new_vault, 0, sender=daddy) @@ -564,11 +625,11 @@ def test__remove_vault__two_vaults( assert len(all_vaults) == 1 assert len(all_vaults[0]) == 1 assert all_vaults[0][0] == second_vault.address - assert registry.info(new_vault.address).asset == ZERO_ADDRESS - assert registry.info(new_vault.address).releaseVersion == 0 - assert registry.info(new_vault.address).tag == "" - assert registry.info(second_vault.address).asset == asset.address - assert registry.info(second_vault.address).releaseVersion == 0 + assert registry.vaultInfo(new_vault.address).asset == ZERO_ADDRESS + assert registry.vaultInfo(new_vault.address).releaseVersion == 0 + assert registry.vaultInfo(new_vault.address).tag == "" + assert registry.vaultInfo(second_vault.address).asset == asset.address + assert registry.vaultInfo(second_vault.address).releaseVersion == 0 def test__remove_strategy( @@ -581,48 +642,53 @@ def test__remove_strategy( assert release_registry.numReleases() == 1 - tx = registry.endorseStrategy(strategy, sender=daddy) + tx = registry.endorseSingleStrategyVault(strategy, sender=daddy) - event = list(tx.decode_logs(registry.NewEndorsedStrategy)) + event = list(tx.decode_logs(registry.NewEndorsedVault)) assert len(event) == 1 assert event[0].asset == asset.address - assert event[0].strategy == strategy + assert event[0].vault == strategy assert event[0].releaseVersion == 0 # Make sure it was endorsed correctly assert registry.numAssets() == 1 assert registry.getAssets()[0] == asset.address - assert registry.numEndorsedStrategies(asset) == 1 - assert registry.getEndorsedStrategies(asset)[0] == strategy.address - all_strategies = registry.getAllEndorsedStrategies() - assert len(all_strategies) == 1 - assert len(all_strategies[0]) == 1 - assert all_strategies[0][0] == strategy.address - assert registry.info(strategy.address).asset == asset.address - assert registry.info(strategy.address).releaseVersion == 0 + assert registry.numEndorsedVaults(asset) == 1 + assert registry.getEndorsedVaults(asset)[0] == strategy.address + all_vaults = registry.getAllEndorsedVaults() + assert len(all_vaults) == 1 + assert len(all_vaults[0]) == 1 + assert all_vaults[0][0] == strategy.address + assert registry.vaultInfo(strategy.address).asset == asset.address + assert registry.vaultInfo(strategy.address).releaseVersion == 0 + assert ( + registry.vaultInfo(strategy.address).vaultType + == registry.SINGLE_STRATEGY_TYPE() + ) # Remove the strategy - tx = registry.removeStrategy(strategy, 0, sender=daddy) + tx = registry.removeVault(strategy, 0, sender=daddy) - event = list(tx.decode_logs(registry.RemovedStrategy)) + event = list(tx.decode_logs(registry.RemovedVault)) assert len(event) == 1 - assert event[0].strategy == strategy.address + assert event[0].vault == strategy.address assert event[0].asset == asset.address assert event[0].releaseVersion == 0 # Make sure it was removed assert registry.numAssets() == 1 assert registry.getAssets() == [asset.address] - assert registry.numEndorsedStrategies(asset) == 0 - assert registry.getEndorsedStrategies(asset) == [] - all_strategies = registry.getAllEndorsedStrategies() - assert len(all_strategies) == 1 - assert all_strategies[0] == [] - assert registry.info(strategy.address).asset == ZERO_ADDRESS - assert registry.info(strategy.address).releaseVersion == 0 - assert registry.info(strategy.address).deploymentTimestamp == 0 - assert registry.info(strategy.address).tag == "" + assert registry.numEndorsedVaults(asset) == 0 + assert registry.getEndorsedVaults(asset) == [] + all_vaults = registry.getAllEndorsedVaults() + assert len(all_vaults) == 1 + assert all_vaults[0] == [] + assert registry.vaultInfo(strategy.address).asset == ZERO_ADDRESS + assert registry.vaultInfo(strategy.address).releaseVersion == 0 + assert registry.vaultInfo(strategy.address).deploymentTimestamp == 0 + assert registry.vaultInfo(strategy.address).vaultType == 0 + assert registry.vaultInfo(strategy.address).tag == "" def test__remove_strategy__two_strategies( @@ -635,52 +701,61 @@ def test__remove_strategy__two_strategies( assert release_registry.numReleases() == 1 - registry.endorseStrategy(strategy, sender=daddy) + registry.endorseSingleStrategyVault(strategy, sender=daddy) second_strategy = create_strategy() - registry.endorseStrategy(second_strategy, sender=daddy) + registry.endorseSingleStrategyVault(second_strategy, sender=daddy) # Make sure they are endorsed correctly assert registry.numAssets() == 1 assert registry.getAssets()[0] == asset.address - assert registry.numEndorsedStrategies(asset) == 2 - assert registry.getEndorsedStrategies(asset) == [ + assert registry.numEndorsedVaults(asset) == 2 + assert registry.getEndorsedVaults(asset) == [ strategy.address, second_strategy.address, ] - all_strategies = registry.getAllEndorsedStrategies() - assert len(all_strategies) == 1 - assert len(all_strategies[0]) == 2 - assert all_strategies[0] == [strategy.address, second_strategy.address] - assert registry.info(strategy.address).asset == asset.address - assert registry.info(strategy.address).releaseVersion == 0 - assert registry.info(second_strategy.address).asset == asset.address - assert registry.info(second_strategy.address).releaseVersion == 0 + all_vaults = registry.getAllEndorsedVaults() + assert len(all_vaults) == 1 + assert len(all_vaults[0]) == 2 + assert all_vaults[0] == [strategy.address, second_strategy.address] + assert registry.vaultInfo(strategy.address).asset == asset.address + assert registry.vaultInfo(strategy.address).releaseVersion == 0 + assert registry.vaultInfo(second_strategy.address).asset == asset.address + assert registry.vaultInfo(second_strategy.address).releaseVersion == 0 + assert ( + registry.vaultInfo(second_strategy.address).vaultType + == registry.SINGLE_STRATEGY_TYPE() + ) # Remove the first strategy - tx = registry.removeStrategy(strategy, 0, sender=daddy) + tx = registry.removeVault(strategy, 0, sender=daddy) - event = list(tx.decode_logs(registry.RemovedStrategy)) + event = list(tx.decode_logs(registry.RemovedVault)) assert len(event) == 1 - assert event[0].strategy == strategy.address + assert event[0].vault == strategy.address assert event[0].asset == asset.address assert event[0].releaseVersion == 0 # Make sure the second is still endorsed assert registry.numAssets() == 1 assert registry.getAssets()[0] == asset.address - assert registry.numEndorsedStrategies(asset) == 1 - assert registry.getEndorsedStrategies(asset)[0] == second_strategy.address - all_strategies = registry.getAllEndorsedStrategies() - assert len(all_strategies) == 1 - assert len(all_strategies[0]) == 1 - assert all_strategies[0][0] == second_strategy.address - assert registry.info(strategy.address).asset == ZERO_ADDRESS - assert registry.info(strategy.address).releaseVersion == 0 - assert registry.info(strategy.address).tag == "" - assert registry.info(second_strategy.address).asset == asset.address - assert registry.info(second_strategy.address).releaseVersion == 0 + assert registry.numEndorsedVaults(asset) == 1 + assert registry.getEndorsedVaults(asset)[0] == second_strategy.address + all_vaults = registry.getAllEndorsedVaults() + assert len(all_vaults) == 1 + assert len(all_vaults[0]) == 1 + assert all_vaults[0][0] == second_strategy.address + assert registry.vaultInfo(strategy.address).asset == ZERO_ADDRESS + assert registry.vaultInfo(strategy.address).releaseVersion == 0 + assert registry.vaultInfo(strategy.address).vaultType == 0 + assert registry.vaultInfo(strategy.address).tag == "" + assert registry.vaultInfo(second_strategy.address).asset == asset.address + assert registry.vaultInfo(second_strategy.address).releaseVersion == 0 + assert ( + registry.vaultInfo(second_strategy.address).vaultType + == registry.SINGLE_STRATEGY_TYPE() + ) def test__remove_asset( @@ -693,26 +768,26 @@ def test__remove_asset( assert release_registry.numReleases() == 1 - registry.endorseStrategy(strategy, sender=daddy) + registry.endorseSingleStrategyVault(strategy, sender=daddy) # Make sure it was endorsed correctly assert registry.numAssets() == 1 assert registry.getAssets()[0] == asset.address - assert registry.numEndorsedStrategies(asset) == 1 - assert registry.getEndorsedStrategies(asset)[0] == strategy.address - all_strategies = registry.getAllEndorsedStrategies() - assert len(all_strategies) == 1 - assert len(all_strategies[0]) == 1 - assert all_strategies[0][0] == strategy.address - assert registry.info(strategy.address).asset == asset.address - assert registry.info(strategy.address).releaseVersion == 0 + assert registry.numEndorsedVaults(asset) == 1 + assert registry.getEndorsedVaults(asset)[0] == strategy.address + all_vaults = registry.getAllEndorsedVaults() + assert len(all_vaults) == 1 + assert len(all_vaults[0]) == 1 + assert all_vaults[0][0] == strategy.address + assert registry.vaultInfo(strategy.address).asset == asset.address + assert registry.vaultInfo(strategy.address).releaseVersion == 0 # Should not be able to remove the asset with ape.reverts("still in use"): registry.removeAsset(asset.address, 0, sender=daddy) # Remove the strategy - registry.removeStrategy(strategy.address, 0, sender=daddy) + registry.removeVault(strategy.address, 0, sender=daddy) registry.removeAsset(asset.address, 0, sender=daddy) @@ -745,19 +820,15 @@ def test__access( # Cant endorse a vault with ape.reverts("!governance"): - registry.endorseVault(new_vault, 0, 0, sender=user) + registry.endorseVault(new_vault, 0, 1, 0, sender=user) # cant endorse vault with default values with ape.reverts("!governance"): - registry.endorseVault(new_vault, sender=user) - - # cant endorse strategy - with ape.reverts("!governance"): - registry.endorseStrategy(strategy, 0, 0, sender=user) + registry.endorseMultiStrategyVault(new_vault, sender=user) # cant endorse strategy with default values with ape.reverts("!governance"): - registry.endorseStrategy(strategy, sender=user) + registry.endorseSingleStrategyVault(strategy, sender=user) with ape.reverts("!governance"): registry.tagVault(strategy, "tag", sender=user) @@ -765,9 +836,6 @@ def test__access( with ape.reverts("!governance"): registry.removeVault(new_vault.address, 0, sender=user) - with ape.reverts("!governance"): - registry.removeStrategy(strategy.address, 0, sender=user) - with ape.reverts("!governance"): registry.removeAsset(asset.address, 0, sender=user) diff --git a/tests/test_release_registry.py b/tests/test_release_registry.py index 4d44d18..b9aacaf 100644 --- a/tests/test_release_registry.py +++ b/tests/test_release_registry.py @@ -22,13 +22,13 @@ def test_new_release(release_registry, daddy, vault_factory): assert len(event) == 1 assert event[0].releaseId == 0 assert event[0].factory == vault_factory - assert event[0].apiVersion == vault_factory.api_version() + assert event[0].apiVersion == vault_factory.apiVersion() assert release_registry.numReleases() == 1 assert release_registry.factories(0) == vault_factory.address - assert release_registry.releaseTargets(vault_factory.api_version()) == 0 + assert release_registry.releaseTargets(vault_factory.apiVersion()) == 0 assert release_registry.latestFactory() == vault_factory.address - assert release_registry.latestRelease() == vault_factory.api_version() + assert release_registry.latestRelease() == vault_factory.apiVersion() new_api = "4.3.2" # Deploy a new mock factory with a different api @@ -45,13 +45,13 @@ def test_new_release(release_registry, daddy, vault_factory): assert release_registry.numReleases() == 2 assert release_registry.factories(1) == new_factory.address - assert release_registry.releaseTargets(new_factory.api_version()) == 1 + assert release_registry.releaseTargets(new_factory.apiVersion()) == 1 assert release_registry.latestFactory() == new_factory.address assert release_registry.latestRelease() == new_api # make sure the first factory is still returning assert release_registry.factories(0) == vault_factory.address - assert release_registry.releaseTargets(vault_factory.api_version()) == 0 + assert release_registry.releaseTargets(vault_factory.apiVersion()) == 0 def test_access(release_registry, daddy, user, vault_factory): @@ -82,12 +82,12 @@ def test__add_same_factory(release_registry, daddy, vault_factory): assert len(event) == 1 assert event[0].releaseId == 0 assert event[0].factory == vault_factory - assert event[0].apiVersion == vault_factory.api_version() + assert event[0].apiVersion == vault_factory.apiVersion() assert release_registry.numReleases() == 1 assert release_registry.factories(0) == vault_factory.address assert release_registry.latestFactory() == vault_factory.address - assert release_registry.latestRelease() == vault_factory.api_version() + assert release_registry.latestRelease() == vault_factory.apiVersion() with ape.reverts("ReleaseRegistry: same api version"): release_registry.newRelease(vault_factory.address, sender=daddy)