Skip to content

Fix: frax apy issues#558

Draft
rossgalloway wants to merge 3 commits intomainfrom
fix--frax-apy-issues
Draft

Fix: frax apy issues#558
rossgalloway wants to merge 3 commits intomainfrom
fix--frax-apy-issues

Conversation

@rossgalloway
Copy link
Collaborator

Factory Vault forward APY calculations for Frax strategies were being incorrectly calculated due to a misconfiguration of a call to get convex PIDs. They were getting frax PIDs instead of convex PIDs.

This has been fixed by falling back to finding the Convex PID via a chain of contract calls. ABIs and new contracts to make these calls have been added.

This PR also adds a helper file called apy_trace.go, which allows trace logs to be saved for particular vaults as they flow through the program. I know that there are probably more serious ways to debug, but I could not figure out how to get the general debugger to focus only on specific contracts as the program runs and this solution allows for it.

Before:
image

after:
image

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.

Summary

This PR fixes Frax APY calculations for Convex strategies by replacing the FraxPid() call with a proper contract chain lookup: Strategy → userVault → stakingToken → convexPoolId.

Issues

Incomplete fix in getConvexRewardAPY

getConvexRewardAPY (lines 33-44) still uses the old FraxPid fallback pattern. This function is called on line 53 of forward.convex.go for the same Frax strategies. The same fix should likely be applied here.

Manual testing shows one vault still broken

Tested locally with the two vaults visible in the PR screenshots:

eUSD-FRAXBP (0x468C76f16B7735303f7215b3839D270d058b3d7a)

curl -s http://localhost:3000/1/vaults/0x468C76f16B7735303f7215b3839D270d058b3d7a | jq '.apr.forwardAPR.netAPR'
0.199858839456339

ZUSDFBP3CRV (0xc52d44abA4B7739173821afF175aEb53367E629E)

curl -s http://localhost:3000/1/vaults/0xc52d44abA4B7739173821afF175aEb53367E629E | jq '.apr.forwardAPR.netAPR'
116132303628549560000000

The second vault is returning an obviously incorrect APY value.

Suggestions

  • Consider extracting the PID lookup logic into a shared helper function since it's needed in both getCVXPoolAPY and getConvexRewardAPY
  • Include vault/contract addresses in PR descriptions when testing specific contracts - makes review easier

Reviewed using review-pr skill

@rossgalloway
Copy link
Collaborator Author

Summary

This PR fixes Frax APY calculations for Convex strategies by replacing the FraxPid() call with a proper contract chain lookup: Strategy → userVault → stakingToken → convexPoolId.

Issues

Incomplete fix in getConvexRewardAPY

getConvexRewardAPY (lines 33-44) still uses the old FraxPid fallback pattern. This function is called on line 53 of forward.convex.go for the same Frax strategies. The same fix should likely be applied here.

Manual testing shows one vault still broken

Tested locally with the two vaults visible in the PR screenshots:

eUSD-FRAXBP (0x468C76f16B7735303f7215b3839D270d058b3d7a)

curl -s http://localhost:3000/1/vaults/0x468C76f16B7735303f7215b3839D270d058b3d7a | jq '.apr.forwardAPR.netAPR'
0.199858839456339

ZUSDFBP3CRV (0xc52d44abA4B7739173821afF175aEb53367E629E)

curl -s http://localhost:3000/1/vaults/0xc52d44abA4B7739173821afF175aEb53367E629E | jq '.apr.forwardAPR.netAPR'
116132303628549560000000

The second vault is returning an obviously incorrect APY value.

Suggestions

* Consider extracting the PID lookup logic into a shared helper function since it's needed in both `getCVXPoolAPY` and `getConvexRewardAPY`

* Include vault/contract addresses in PR descriptions when testing specific contracts - makes review easier

Reviewed using review-pr skill

The obviously incorrect APR is not a calculation issue. It is caused by the underlying pool being devalued with a shitty depegged asset. We need to retire that vault (will do that right now). The APY value is "correct" if you price the rewards relative to the pool value.

@murderteeth
Copy link
Collaborator

Summary

This PR fixes Frax APY calculations for Convex strategies by replacing the FraxPid() call with a proper contract chain lookup: Strategy → userVault → stakingToken → convexPoolId.

Issues

Incomplete fix in getConvexRewardAPY

getConvexRewardAPY (lines 33-44) still uses the old FraxPid fallback pattern. This function is called on line 53 of forward.convex.go for the same Frax strategies. The same fix should likely be applied here.

Manual testing shows one vault still broken

Tested locally with the two vaults visible in the PR screenshots:
eUSD-FRAXBP (0x468C76f16B7735303f7215b3839D270d058b3d7a)

curl -s http://localhost:3000/1/vaults/0x468C76f16B7735303f7215b3839D270d058b3d7a | jq '.apr.forwardAPR.netAPR'
0.199858839456339

ZUSDFBP3CRV (0xc52d44abA4B7739173821afF175aEb53367E629E)

curl -s http://localhost:3000/1/vaults/0xc52d44abA4B7739173821afF175aEb53367E629E | jq '.apr.forwardAPR.netAPR'
116132303628549560000000

The second vault is returning an obviously incorrect APY value.

Suggestions

* Consider extracting the PID lookup logic into a shared helper function since it's needed in both `getCVXPoolAPY` and `getConvexRewardAPY`

* Include vault/contract addresses in PR descriptions when testing specific contracts - makes review easier

Reviewed using review-pr skill

The obviously incorrect APR is not a calculation issue. It is caused by the underlying pool being devalued with a shitty depegged asset. We need to retire that vault (will do that right now). The APY value is "correct" if you price the rewards relative to the pool value.

  • i'm not clear. why is it zero in your "after" screen shot but 116132303628549560000000 when i query it locally
  • does getConvexRewardAPY matter?

@rossgalloway rossgalloway marked this pull request as draft January 16, 2026 18:02
@rossgalloway
Copy link
Collaborator Author

converting this to draft while I continue to work out the kinks

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