Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,5 @@ RISK_CDN_URL= # Risk score CDN URL (defaults to https://risk.yearn.fi/cdn/
- All addresses must be checksummed for consistency
- Price data fetched from multiple sources with fallbacks
- Risk scores calculated using 11-factor assessment system
- APY calculations support multiple strategies: Curve, Convex, Velodrome, Aerodrome, etc.
- APY calculations support multiple strategies: Curve, Convex, Velodrome, Aerodrome, etc.
- V3 Vault APRs are sourced from Kong (single source of truth) bypassing direct on-chain Oracle calls.
357 changes: 0 additions & 357 deletions common/contracts/yVaultsV3.APROracle.go

This file was deleted.

4 changes: 0 additions & 4 deletions common/env/chain.arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ var ARBITRUM = TChain{
Address: common.HexToAddress(`0x0e5b46E4b2a05fd53F5a4cD974eb98a9a613bcb7`),
Block: 30385403,
},
APROracleContract: TContractData{
Address: common.HexToAddress(`0x1981AD9F44F2EA9aDd2dC4AD7D075c102C70aF92`),
Block: 265347717,
},
StakingRewardRegistry: []TContractData{
{
Address: common.HexToAddress(`0x26d8EA1d8759d0F9abBcf8181b1fD5D3635daD69`),
Expand Down
4 changes: 0 additions & 4 deletions common/env/chain.base.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ var BASE = TChain{
Label: `YEARN`,
},
},
APROracleContract: TContractData{
Address: common.HexToAddress(`0x1981AD9F44F2EA9aDd2dC4AD7D075c102C70aF92`),
Block: 63167152,
},
ExtraVaults: []models.TVaultsFromRegistry{},
BlacklistedVaults: []common.Address{},
ExtraTokens: []common.Address{
Expand Down
4 changes: 0 additions & 4 deletions common/env/chain.ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ var ETHEREUM = TChain{
Address: common.HexToAddress(`0x8ee392a4787397126C163Cb9844d7c447da419D8`),
Block: 14166636,
},
APROracleContract: TContractData{
Address: common.HexToAddress(`0x1981AD9F44F2EA9aDd2dC4AD7D075c102C70aF92`),
Block: 19070394,
},
ExtraStakingContracts: []TExtraStakingContracts{
{
VaultAddress: common.HexToAddress(`0xe24BA27551aBE96Ca401D39761cA2319Ea14e3CB`),
Expand Down
1 change: 0 additions & 1 deletion common/env/chain.gnosis.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var GNOSIS = TChain{
Block: 821923,
},
PartnerContract: TContractData{},
APROracleContract: TContractData{},
Coin: models.TERC20Token{
Address: DEFAULT_COIN_ADDRESS,
UnderlyingTokensAddresses: []common.Address{},
Expand Down
4 changes: 0 additions & 4 deletions common/env/chain.katana.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ var KATANA = TChain{
Label: `PUBLIC_ERC4626`,
},
},
APROracleContract: TContractData{
Address: common.HexToAddress(`0x1981AD9F44F2EA9aDd2dC4AD7D075c102C70aF92`),
Block: 2237016,
},
ExtraVaults: []models.TVaultsFromRegistry{},
BlacklistedVaults: []common.Address{},
ExtraTokens: []common.Address{},
Expand Down
4 changes: 0 additions & 4 deletions common/env/chain.polygon.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ var POLYGON = TChain{
Address: common.HexToAddress(`0xca11bde05977b3631167028862be2a173976ca11`),
Block: 25770160,
},
APROracleContract: TContractData{
Address: common.HexToAddress(`0x1981AD9F44F2EA9aDd2dC4AD7D075c102C70aF92`),
Block: 52516525,
},
Coin: models.TERC20Token{
Address: DEFAULT_COIN_ADDRESS,
UnderlyingTokensAddresses: []common.Address{},
Expand Down
1 change: 0 additions & 1 deletion common/env/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ type TChain struct {
MulticallContract TContractData
YBribeV3Contract TContractData
PartnerContract TContractData
APROracleContract TContractData
Coin models.TERC20Token
StakingRewardRegistry []TContractData
Registries []TContractData
Expand Down
34 changes: 34 additions & 0 deletions docs/apr-oracle-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# APR Oracle Integration (Kong)

As of version `yDaemon v3.0.0+`, the integration with the on-chain APR Oracle contract for V3 vaults has been replaced with a direct integration with Kong's GraphQL API.

## Overview

Previously, `yDaemon` calculated forward-looking APRs for V3 vaults by making RPC calls to a specific Oracle smart contract. This dependency has been removed in favor of fetching pre-calculated oracle data directly from Yearn's data aggregator, **Kong**.

## Data Source

The `performance.oracle` field from Kong's GraphQL API is now the single source of truth for:
- **Oracle APR**: The annualized rate based on recent performance.
- **Oracle APY**: The annualized yield (compounded).

## Implementation Details

- **Internal Logic**: The `forward.v3.go` process queries the internal storage (populated by the Kong indexer) instead of computing values on-chain.
- **Strategies**: Strategy-level APRs (`NetAPR`) for V3 also utilize this data source via `GetCurrentStrategyAPR` or the vault-level fallback, ensuring consistency.
- **Fallback**: If Kong data is unavailable or null, the system gracefully defaults to zero values, preventing API crashes.

## API Response

The external API response structure for vaults remains unchanged to ensure backward compatibility. The `apr.forwardAPR` object is populated with the data retrieved from Kong.

```json
"forwardAPR": {
"type": "v3:onchainOracle",
"netAPR": 0.045, // Sourced from Kong
"composite": {
"v3OracleCurrentAPR": 0.045,
"v3OracleStratRatioAPR": 0.045
}
}
```
10 changes: 0 additions & 10 deletions internal/fetcher/strategies.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,6 @@ func getStrategyAPR(chainID uint64, versionMajor string, strategy models.TStrate
** For earlier versions: Only try to get current APR
******************************************************************************************/
if versionMajor == `3` {
if forwardAPR, err := apr.ComputeForwardStrategyAPR(strategy); err == nil {
netAPR = forwardAPR
aprType = models.APRTypeForward
} else if currentAPR, err := apr.GetCurrentStrategyAPR(chainID, strategy.Address.Hex()); err == nil {
netAPR = currentAPR
aprType = models.APRTypeCurrent
} else {
return netAPR, aprType, errors.New(`Error while computing forward APR for ` + strategy.Address.Hex() + ` | ` + strategy.VaultAddress.Hex() + `: ` + err.Error())
}
} else {
if currentAPR, err := apr.GetCurrentStrategyAPR(chainID, strategy.Address.Hex()); err == nil {
netAPR = currentAPR
aprType = models.APRTypeCurrent
Expand Down
22 changes: 16 additions & 6 deletions internal/indexer/indexer.kong.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,23 @@ func IndexNewVaults(chainID uint64) map[common.Address]models.TVaultsFromRegistr
})
}

// Extract performance data from Kong response (oracle APR/APY)
performance := models.TKongPerformance{}
if data.Vault.Performance != nil {
performance.Oracle = models.TKongOracle{
Apr: data.Vault.Performance.Oracle.Apr,
Apy: data.Vault.Performance.Oracle.Apy,
}
}

kongSchema := models.TKongVaultSchema{
ManagementFee: data.Vault.GetManagementFee(),
PerformanceFee: data.Vault.GetPerformanceFee(),
APY: data.APY,
Debts: debts,
TVL: data.Vault.GetTVL(),
TotalAssets: data.TotalAssets,
ManagementFee: data.Vault.GetManagementFee(),
PerformanceFee: data.Vault.GetPerformanceFee(),
APY: data.APY,
Performance: performance,
Debts: debts,
TVL: data.Vault.GetTVL(),
TotalAssets: data.TotalAssets,
StrategyAddresses: data.Vault.GetStrategies(),
}
storage.StoreKongVaultData(chainID, vaultAddr, kongSchema)
Expand Down
22 changes: 22 additions & 0 deletions internal/kong/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ type KongFees struct {
PerformanceFee float64 `json:"performanceFee"`
}

type KongOracle struct {
Apr *float64 `json:"apr"` // Float or null
Apy *float64 `json:"apy"` // Float or null
}

type KongPerformance struct {
Oracle KongOracle `json:"oracle"`
}

type KongVault struct {
Address string `json:"address"`
ChainID int `json:"chainId"`
Expand All @@ -84,6 +93,7 @@ type KongVault struct {
Strategies []string `json:"strategies"`
Debts []KongDebt `json:"debts"`
TVL *KongTVL `json:"tvl"`
Performance *KongPerformance `json:"performance"` // Oracle APR/APY data
APY models.KongAPY `json:"apy"`
TotalAssets *bigNumber.Int `json:"totalAssets"`
ManagementFee *string `json:"managementFee"` // BigInt as string (basis points)
Expand Down Expand Up @@ -200,6 +210,12 @@ func (c *Client) FetchVaultsForChain(ctx context.Context, chainID uint64) ([]Kon
managementFee
performanceFee
}
performance {
oracle {
apr
apy
}
}
apy {
pricePerShare
weeklyNet
Expand Down Expand Up @@ -281,6 +297,12 @@ func (c *Client) FetchAllVaults(ctx context.Context) (map[uint64][]KongVault, er
managementFee
performanceFee
}
performance {
oracle {
apr
apy
}
}
apy {
pricePerShare
weeklyNet
Expand Down
22 changes: 16 additions & 6 deletions internal/models/vaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@ type KongAPY struct {
Decimals uint64 `json:"decimals"` // Token decimals for PPS normalization
}

type TKongOracle struct {
Apr *float64 `json:"apr"` // Float or null
Apy *float64 `json:"apy"` // Float or null
}

type TKongPerformance struct {
Oracle TKongOracle `json:"oracle"`
}

type TKongVaultSchema struct {
Hook struct {
Fees struct {
Expand All @@ -327,11 +336,12 @@ type TKongVaultSchema struct {
ManagementFee CoercibleUint64 `json:"managementFee"`
PerformanceFee CoercibleUint64 `json:"performanceFee"`
} `json:"snapshot"`
TVL float64 `json:"tvl"` // TVL from Kong (tvl.close field)
Debts []TKongDebt `json:"debts"` // Debts array from Kong
TotalAssets *bigNumber.Int `json:"totalAssets"` // Total assets from Kong
APY KongAPY `json:"apy"`
ManagementFee uint64 `json:"managementFee"` // Basis points from Kong (direct field takes priority)
PerformanceFee uint64 `json:"performanceFee"` // Basis points from Kong (direct field takes priority)
TVL float64 `json:"tvl"` // TVL from Kong (tvl.close field)
Debts []TKongDebt `json:"debts"` // Debts array from Kong
TotalAssets *bigNumber.Int `json:"totalAssets"` // Total assets from Kong
Performance TKongPerformance `json:"performance"` // Oracle APR/APY data from Kong
APY KongAPY `json:"apy"`
ManagementFee uint64 `json:"managementFee"` // Basis points from Kong (direct field takes priority)
PerformanceFee uint64 `json:"performanceFee"` // Basis points from Kong (direct field takes priority)
StrategyAddresses []common.Address `json:"strategyAddresses"` // Strategy addresses from Kong
}
12 changes: 12 additions & 0 deletions internal/storage/elem.vaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,16 @@ func GetKongTotalAssets(chainID uint64, vaultAddress common.Address) (*bigNumber
return nil, false
}
return data.TotalAssets, true
}

/**************************************************************************************************
** GetKongOracleAPY retrieves oracle APR/APY from Kong data for a vault
** Returns (apr, apy, exists) where apr and apy are *float64 (may be nil)
**************************************************************************************************/
func GetKongOracleAPY(chainID uint64, vaultAddress common.Address) (*float64, *float64, bool) {
data, ok := GetKongVaultData(chainID, vaultAddress)
if !ok {
return nil, nil, false
}
return data.Performance.Oracle.Apr, data.Performance.Oracle.Apy, true
}
61 changes: 0 additions & 61 deletions processes/apr/forward.strategy.go

This file was deleted.

Loading