Skip to content

Commit

Permalink
fix: remove assumption that the second strategy is always a CVX one (#…
Browse files Browse the repository at this point in the history
…525)

 (vault: 0x5fA5B62c8AF877CB37031e0a3B2f34A78e3C56A6)
  • Loading branch information
crebsy authored Jun 17, 2023
1 parent 3f6dd0d commit efa4929
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions yearn/apy/curve/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,15 @@ def calculate_simple(vault, gauge: Gauge, samples: ApySamples) -> Apy:
cvx_strategy = first_strategy
crv_strategy = second_strategy

cvx_vault = _ConvexVault(cvx_strategy, vault, gauge.gauge)
crv_debt_ratio = vault.vault.strategies(crv_strategy)[2] / 1e4
cvx_apy_data = cvx_vault.get_detailed_apy_data(base_asset_price, pool_price, base_apr)
if _ConvexVault.is_convex_strategy(cvx_strategy):
cvx_vault = _ConvexVault(cvx_strategy, vault, gauge.gauge)
crv_debt_ratio = vault.vault.strategies(crv_strategy)[2] / 1e4
cvx_apy_data = cvx_vault.get_detailed_apy_data(base_asset_price, pool_price, base_apr)
else:
# TODO handle this case
logger.warn(f"no APY calculations for strategy {str(cvx_strategy)}")
cvx_apy_data = ConvexDetailedApyData()
crv_debt_ratio = 1
else:
cvx_apy_data = ConvexDetailedApyData()
crv_debt_ratio = 1
Expand Down Expand Up @@ -358,7 +364,10 @@ def is_convex_vault(vault) -> bool:

@staticmethod
def is_convex_strategy(strategy) -> bool:
return "convex" in strategy.name.lower()
if isinstance(strategy.name, str):
return "convex" in strategy.name.lower()
else:
return "convex" in strategy.name().lower()

def apy(self, base_asset_price, pool_price, base_apr, pool_apy: float, management_fee: float, performance_fee: float) -> Apy:
"""The standard APY data."""
Expand Down

0 comments on commit efa4929

Please sign in to comment.