Skip to content

Commit

Permalink
fix: multi vaults expected APR
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Nov 22, 2023
1 parent f3cb5c7 commit 5289334
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions processes/apr/forward.v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,17 @@ func computeVaultV3ForwardAPR(
** If the vault is a single strategy vault, we can use the oracle directly to get the APR of
** the vault as expected APR
**********************************************************************************************/
if vault.Kind == models.VaultKindSingle {
expected, err := oracle.GetStrategyApr(nil, vault.Address, big.NewInt(0))
if err == nil {
netAPR = helpers.ToNormalizedAmount(bigNumber.SetInt(expected), 18)
}
expected, err := oracle.GetStrategyApr(nil, vault.Address, big.NewInt(0))
if err == nil {
netAPR = helpers.ToNormalizedAmount(bigNumber.SetInt(expected), 18)
}

/**********************************************************************************************
** Otherwise we can do the classic calculation of the net APR by summing the APR of each
** strategy weighted by the debt ratio of each strategy.
**********************************************************************************************/
shouldUseV2Method := false
if shouldUseV2Method {
if shouldUseV2Method && vault.Kind == models.VaultKindMultiple {
for _, strategy := range allStrategiesForVault {
if strategy.LastDebtRatio == nil || strategy.LastDebtRatio.IsZero() {
if os.Getenv("ENVIRONMENT") == "dev" {
Expand All @@ -70,10 +68,8 @@ func computeVaultV3ForwardAPR(
humanizedAPR := helpers.ToNormalizedAmount(bigNumber.SetInt(expected), 18)
debtRatio := helpers.ToNormalizedAmount(strategy.LastDebtRatio, 4)
scaledStrategyAPR := bigNumber.NewFloat(0).Mul(humanizedAPR, debtRatio)
scaledStrategyAPR = bigNumber.NewFloat(0).Mul(scaledStrategyAPR, bigNumber.NewFloat(0.9))
netAPR = bigNumber.NewFloat(0).Add(netAPR, scaledStrategyAPR)

// Reduce netAPR by 10% to take into account inaccuracy
netAPR = bigNumber.NewFloat(0).Mul(netAPR, bigNumber.NewFloat(0.9))
}
}

Expand Down

0 comments on commit 5289334

Please sign in to comment.