feat: make kong source of truth for oracle apr#559
Conversation
… forward APY
- Update Kong GraphQL queries to fetch performance.oracle { apr, apy } fields
- Add KongOracle and KongPerformance types to handle nullable float64 data
- Update indexer to extract and store oracle data in TKongVaultSchema
- Add GetKongOracleAPY() accessor function to storage layer
- Replace on-chain oracle contract calls with Kong data fetching in forward.v3.go
- Remove APR Oracle contract configs from chain files (keep struct field for strategy-level usage)
- Maintain backward compatibility with v3:onchainOracle response type
- Implement graceful degradation: return zero APY when Kong data unavailable
There was a problem hiding this comment.
Review Feedback
Breaking Change Found
File: processes/apr/forward.v3.go:68
The current implementation changes the value assigned to V3OracleCurrentAPR:
// Current PR code
V3OracleCurrentAPR: primaryAPR,Problem: Downstream clients expect V3OracleCurrentAPR to contain the APY value (matching the previous behavior), not the APR. This change breaks backward compatibility.
Fix required:
V3OracleCurrentAPR: primaryAPY, // Maintain backward compatibilityOther Observations
Redundant branching in strategies.go - Lines 102-116 now have identical logic for V3 and non-V3 (both call GetCurrentStrategyAPR). The if/else could be simplified to a single path.
Yeah that one confused me, i thought it was a typo done in the past. Makes sense now. tests
Inside the
|
oh yes apparently 🫠 |
Removes the else block that called apr.GetCurrentStrategyAPR() which was part of the old APR oracle implementation. This code path is no longer needed after the Kong GraphQL API integration for V3 vault APY calculations.
murderteeth
left a comment
There was a problem hiding this comment.
build error (lint)
~/git/ydaemon go build -o yDaemon ./cmd
# github.com/yearn/ydaemon/processes/apr
processes/apr/forward.v3.go:59:2: declared and not used: primaryAPR
|
i forget go has built in linter. Cleaned up. |

Description
This PR replaces the legacy on-chain APR Oracle contract integration for V3 vaults with data sourced directly from Kong's GraphQL API. This establishes Kong as the single source of truth for historical APY and forward-looking oracle APR data, simplifying the architecture and reducing RPC calls.
How to Test
1. Build the Application
Compile the
yDaemonbinary from the source.2. Prepare Environment
Ensure your
.envfile is set up with a valid RPC URL for Mainnet (Chain ID 1).# Example .env content RPC_URI_FOR_1=https://eth.llama.rpc.com3. Run yDaemon
Start the server, filtering for Chain 1 to reduce startup time.
4. Verify APR Data
Open a new terminal and query the API for the USDC V3 vault (
0xBe53...). This vault is known to have Oracle APR data.curl -s http://localhost:8080/1/vaults/0xBe53A109B494E5c9f97b9Cd39Fe969BE68BF6204 | jq .apr.forwardAPR5. Expected Result
The JSON response should contain a valid
netAPRvalue (non-zero) and the type should bev3:onchainOracle.{ "type": "v3:onchainOracle", "netAPR": 0.04257556654404793, "composite": { "v3OracleCurrentAPR": 0.04171087783745296, "v3OracleStratRatioAPR": 0 } }