From 0c51e68b6609227faa11a98ce024d9c36816eb47 Mon Sep 17 00:00:00 2001 From: Schlagonia Date: Thu, 19 Oct 2023 01:05:42 -0600 Subject: [PATCH] chore: update to new version --- README.md | 16 ++ ape-config.yaml | 2 + contracts/registry/Registry.sol | 15 +- scripts/deploy_address_provider.py | 4 +- scripts/deploy_registry.py | 6 +- tests/test_registry.py | 350 +++++++++++++++++------------ tests/test_release_registry.py | 14 +- 7 files changed, 246 insertions(+), 161 deletions(-) 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..425012a 100644 --- a/ape-config.yaml +++ b/ape-config.yaml @@ -16,6 +16,8 @@ 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 diff --git a/contracts/registry/Registry.sol b/contracts/registry/Registry.sol index eb0a904..c398a54 100644 --- a/contracts/registry/Registry.sol +++ b/contracts/registry/Registry.sol @@ -55,10 +55,10 @@ contract Registry is Governance { string tag; } - // Default type used for Multi strategy "allocator" vaults. + // Default type used for Multi strategy "Allocator" vaults. uint256 public constant MULTI_STRATEGY_TYPE = 1; - // Default type used for single "Tokenized" strategy vaults. + // Default type used for Single "Tokenized" Strategy vaults. uint256 public constant SINGLE_STRATEGY_TYPE = 2; // Custom name for this Registry. @@ -156,8 +156,8 @@ contract Registry is Governance { /** * @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. @@ -189,8 +189,8 @@ contract Registry is Governance { /** * @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. @@ -227,7 +227,7 @@ contract Registry is Governance { // Deploy New vault. _vault = IVaultFactory(factory).deploy_new_vault( - _asset, + ERC20(_asset), _name, _symbol, _roleManager, @@ -423,7 +423,6 @@ contract Registry is Governance { ) external onlyGovernance { require(assetIsUsed[_asset], "!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/scripts/deploy_address_provider.py b/scripts/deploy_address_provider.py index 5764094..c22d628 100644 --- a/scripts/deploy_address_provider.py +++ b/scripts/deploy_address_provider.py @@ -6,6 +6,7 @@ import hashlib from copy import deepcopy +deployer = accounts.load("") def deploy_address_provider(): print("Deploying Address Provider on ChainID", chain.chain_id) @@ -14,7 +15,6 @@ def deploy_address_provider(): return address_provider = project.AddressProvider - deployer = accounts.load("") deployer_contract = project.Deployer.at( "0x8D85e7c9A4e369E53Acc8d5426aE1568198b0112" ) @@ -34,7 +34,7 @@ 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..76da003 100644 --- a/scripts/deploy_registry.py +++ b/scripts/deploy_registry.py @@ -6,6 +6,7 @@ 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 +16,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 +38,7 @@ 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)