Skip to content

Commit

Permalink
fix: APY for 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Oct 17, 2023
1 parent c416511 commit 9eeae99
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 17 deletions.
10 changes: 10 additions & 0 deletions common/env/chain.ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ var ETHEREUM = TChain{
common.HexToAddress("0xc09cfb625e586B117282399433257a1C0841edf3"), // Staked Yearn BAL Vault - Disabled for now
common.HexToAddress("0xD725F5742047B4B4A3110D0b38284227fcaB041e"), // LP Yearn BAL Vault - Disabled for now
common.HexToAddress("0xD61e198e139369a40818FE05F5d5e6e045Cd6eaF"), // Balancer yBAL Stable Pool - Disabled for now
//
// common.HexToAddress(`0x39CAF13a104FF567f71fd2A4c68C026FDB6E740B`),
// common.HexToAddress(`0x4560b99C904aAD03027B5178CCa81584744AC01f`),
// common.HexToAddress(`0x5c0A86A32c129538D62C106Eb8115a8b02358d57`),
// common.HexToAddress(`0x2D5D4869381C4Fce34789BC1D38aCCe747E295AE`),
// common.HexToAddress(`0xd88dBBA3f9c4391Ee46f5FF548f289054db6E51C`),
// common.HexToAddress(`0xC4dAf3b5e2A9e93861c3FBDd25f1e943B8D87417`),
// common.HexToAddress(`0x801Ab06154Bf539dea4385a39f5fa8534fB53073`),
// common.HexToAddress(`0xF59D66c1d593Fb10e2f8c2a6fD2C958792434B9c`),
// common.HexToAddress(`0x341bb10D8f5947f3066502DC8125d9b8949FD3D6`),
},
ExtraTokens: []common.Address{
common.HexToAddress("0x34fe2a45D8df28459d7705F37eD13d7aE4382009"), // yvWBTC
Expand Down
13 changes: 13 additions & 0 deletions internal/multicalls/calls.vaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,16 @@ func GetExpectedReturn(name string, contractAddress common.Address, strategyAddr
Version: version,
}
}
func GetDebtRatio(name string, contractAddress common.Address) ethereum.Call {
parsedData, err := YearnVaultABI.Pack("debtRatio")
if err != nil {
logs.Error("Error packing YearnVaultABI debtRatio", err)
}
return ethereum.Call{
Target: contractAddress,
Abi: YearnVaultABI,
Method: `debtRatio`,
CallData: parsedData,
Name: name,
}
}
13 changes: 10 additions & 3 deletions internal/vaults/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ func BuildCategory(t models.TVault) string {
baseForStableCurrencies := []string{`USD`, `EUR`, `AUD`, `CHF`, `KRW`, `GBP`, `JPY`}
baseForCurve := []string{`curve`, `crv`}
baseForBalancer := []string{`balancer`, `bal`}
baseForVelodrom := []string{`velodrome`, `velo`}
baseForVelodrome := []string{`velodrome`, `velo`}
baseForAerodrome := []string{`aerodrome`, `aero`}
allNames := []string{
strings.ToLower(t.FormatedName),
strings.ToLower(t.Name),
Expand All @@ -205,9 +206,12 @@ func BuildCategory(t models.TVault) string {
if helpers.Intersects(allNames, baseForBalancer) {
category = `Balancer`
}
if helpers.Intersects(allNames, baseForVelodrom) {
if helpers.Intersects(allNames, baseForVelodrome) {
category = `Velodrome`
}
if helpers.Intersects(allNames, baseForAerodrome) {
category = `Aerodrome`
}
} else {
//No meta, back to custom classification
baseForBitcoin := []string{`btc`, `bitcoin`}
Expand All @@ -233,9 +237,12 @@ func BuildCategory(t models.TVault) string {
if helpers.Intersects(allNames, baseForBalancer) {
category = `Balancer`
}
if helpers.Intersects(allNames, baseForVelodrom) {
if helpers.Intersects(allNames, baseForVelodrome) {
category = `Velodrome`
}
if helpers.Intersects(allNames, baseForAerodrome) {
category = `Aerodrome`
}
}
return category
}
Expand Down
12 changes: 3 additions & 9 deletions processes/apy/forward.curve.helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ func calculateCurveLikeStrategyAPR(
chainID := vault.ChainID

if subgraphItem.LatestWeeklyApy == 0 {
logs.Error(`No APY data for vault ` + vault.Address.Hex())
return TStrategyAPR{}
logs.Warning(`No APY data for vault ` + vault.Address.Hex())
// return TStrategyAPR{}
}

/**********************************************************************************************
Expand Down Expand Up @@ -311,18 +311,11 @@ func computeCurveLikeForwardAPR(
RewardsAPR := bigNumber.NewFloat(0)
for _, strategy := range allStrategiesForVault {
if strategy.DebtRatio == nil || strategy.DebtRatio.IsZero() {
//only log if on dev
if os.Getenv("ENVIRONMENT") == "dev" {
logs.Info("Skipping strategy " + strategy.Address.Hex() + " for vault " + vault.Address.Hex() + " because debt ratio is zero")
}
continue
}
if strategy.TotalDebt == nil || strategy.TotalDebt.IsZero() {
if os.Getenv("ENVIRONMENT") == "dev" {
logs.Info("Skipping strategy " + strategy.Address.Hex() + " for vault " + vault.Address.Hex() + " because total debt is zero")
}
continue
}

strategyAPR := calculateCurveLikeStrategyAPR(
vault,
Expand All @@ -341,6 +334,7 @@ func computeCurveLikeForwardAPR(
CvxAPR = bigNumber.NewFloat(0).Add(CvxAPR, strategyAPR.Composite.CvxAPR)
RewardsAPR = bigNumber.NewFloat(0).Add(RewardsAPR, strategyAPR.Composite.RewardsAPR)
}

return TForwardAPR{
Type: strings.TrimSpace(TypeOf),
NetAPR: NetAPR,
Expand Down
9 changes: 4 additions & 5 deletions processes/apy/forward.velodrome.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package apy

import (
"os"
"strings"
"time"

Expand Down Expand Up @@ -167,11 +168,9 @@ func computeVeloLikeForwardAPR(
RewardsAPR := bigNumber.NewFloat(0)
for _, strategy := range allStrategiesForVault {
if strategy.DebtRatio == nil || strategy.DebtRatio.IsZero() {
logs.Info("Skipping strategy " + strategy.Address.Hex() + " for vault " + vault.Address.Hex() + " because debt ratio is zero")
continue
}
if strategy.TotalDebt == nil || strategy.TotalDebt.IsZero() {
logs.Info("Skipping strategy " + strategy.Address.Hex() + " for vault " + vault.Address.Hex() + " because total debt is zero")
if os.Getenv("ENVIRONMENT") == "dev" {
logs.Info("Skipping strategy " + strategy.Address.Hex() + " for vault " + vault.Address.Hex() + " because debt ratio is zero")
}
continue
}

Expand Down

0 comments on commit 9eeae99

Please sign in to comment.