Skip to content

Commit

Permalink
Add Velvet smoke check
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Dec 12, 2024
1 parent af5efb1 commit 86762ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions eth_defi/velvet/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,18 @@ def has_deposit_distribution_to_all_positions(self):
def get_flow_manager(self):
raise NotImplementedError("Velvet does not support individual deposit/redemption events yet")

def check_valid_vault_contract(self):
def check_valid_contract(self):
"""Check that we have connected to a proper Velvet capital vault contract, not wrong contract.
:raise AssertionError:
Looks bad
"""
try:
portfolio_contract = self.portfolio_contract
config = portfolio_contract.functions.protocolConfig().call()
assert config.startswith("0x")
except Exception as e:
raise AssertionError(f"Does not look like a Velvet portfolio contract: {self.portfolio_address}") from e

def fetch_info(self) -> VelvetVaultInfo:
"""Read vault parameters from the chain."""
Expand All @@ -116,10 +122,11 @@ def vault_address(self) -> HexAddress:
return self.info["vaultAddress"]

@property
def vault_contract(self) -> Contract:
def portfolio_contract(self) -> Contract:
return get_deployed_contract(
self.web3,
"velvet/"
"velvet/PortfolioV3_4.json",
self.portfolio_address
)

@property
Expand Down
2 changes: 2 additions & 0 deletions tests/velvet/test_velvet_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ def test_fetch_info(vault: VelvetVault):
assert vault.vault_address == "0x9d247fbc63e4d50b257be939a264d68758b43d04"
assert vault.owner_address == "0x0c9db006f1c7bfaa0716d70f012ec470587a8d4f"

vault.check_valid_contract()


def test_fetch_vault_portfolio(vault: VelvetVault):
"""Read vault token balances."""
Expand Down

0 comments on commit 86762ab

Please sign in to comment.