Skip to content

feat: make kong source of truth for oracle apr#559

Merged
matheus1lva merged 8 commits intomainfrom
feat/kong-oracle-apy-integration
Jan 22, 2026
Merged

feat: make kong source of truth for oracle apr#559
matheus1lva merged 8 commits intomainfrom
feat/kong-oracle-apy-integration

Conversation

@matheus1lva
Copy link
Collaborator

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 yDaemon binary from the source.

go build -o yDaemon ./cmd

2. Prepare Environment

Ensure your .env file is set up with a valid RPC URL for Mainnet (Chain ID 1).

# Example .env content
RPC_URI_FOR_1=https://eth.llama.rpc.com

3. Run yDaemon

Start the server, filtering for Chain 1 to reduce startup time.

./yDaemon -chains 1

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.forwardAPR

5. Expected Result

The JSON response should contain a valid netAPR value (non-zero) and the type should be v3:onchainOracle.

{
  "type": "v3:onchainOracle",
  "netAPR": 0.04257556654404793,
  "composite": {
    "v3OracleCurrentAPR": 0.04171087783745296,
    "v3OracleStratRatioAPR": 0
  }
}

… 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
@murderteeth murderteeth self-requested a review January 21, 2026 06:46
Copy link
Collaborator

@murderteeth murderteeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 compatibility

Other 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.


@matheus1lva
Copy link
Collaborator Author

// Current PR code
V3OracleCurrentAPR: primaryAPR,

Yeah that one confused me, i thought it was a typo done in the past. Makes sense now.

tests

"forwardAPR": {
"type": "v3:onchainOracle",
"netAPR": 0.06499804259456621,
"composite": {
"boost": null,
"poolAPY": null,
"boostedAPR": null,
"baseAPR": null,
"cvxAPR": null,
"rewardsAPR": null,
"v3OracleCurrentAPR": 0.07222130997657228,
"v3OracleStratRatioAPR": 0.06499804259456621
}
}

Inside the apr.forwardApr

CleanShot 2026-01-21 at 12 04 11@2x

Copy link
Collaborator

@murderteeth murderteeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you forget to push a commit?

i realize it looks wrong, but this is how it should be set,

V3OracleCurrentAPR: primaryAPY

tx for the detailed test steps

@matheus1lva
Copy link
Collaborator Author

matheus1lva commented Jan 22, 2026

did you forget to push a commit?

i realize it looks wrong, but this is how it should be set,

V3OracleCurrentAPR: primaryAPY

tx for the detailed test steps

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 murderteeth self-requested a review January 22, 2026 19:21
Copy link
Collaborator

@murderteeth murderteeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@matheus1lva
Copy link
Collaborator Author

matheus1lva commented Jan 22, 2026

i forget go has built in linter.

Cleaned up.

6e06  HEAD -> feat/kong-oracle-apy-integration
➜  ydaemon git:(feat/kong-oracle-apy-integration) go build -o yDaemon ./cmd     
➜  ydaemon git:(feat/kong-oracle-apy-integration) 

@murderteeth murderteeth self-requested a review January 22, 2026 20:11
@matheus1lva matheus1lva merged commit 7733f54 into main Jan 22, 2026
3 checks passed
@matheus1lva matheus1lva deleted the feat/kong-oracle-apy-integration branch January 22, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants