Skip to content

Hipo: fix APY halved by outdated treasury state semantics#2844

Open
behrang wants to merge 2 commits into
DefiLlama:masterfrom
HipoFinance:hipo-apy-fix
Open

Hipo: fix APY halved by outdated treasury state semantics#2844
behrang wants to merge 2 commits into
DefiLlama:masterfrom
HipoFinance:hipo-apy-fix

Conversation

@behrang

@behrang behrang commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Since Hipo's treasury upgrade, get_treasury_state returns the pool exchange rate before/after the latest round (previous_rate/current_rate) at stack positions 11/12, replacing last_staked/last_recovered. The rate advances once per validation round, so the growth must be compounded per single round duration; the old 2-round duration halved the APY (showed ~8.3% instead of the actual ~17.3%). Also adds apyBaseInception derived from the launch exchange rate of 1.0.

Summary by CodeRabbit

  • Enhancements
    • Improved hGRAM APY calculations using current and historical exchange rates.
    • Added an inception-based APY metric to show estimated performance since launch.

Since Hipo's treasury upgrade, get_treasury_state returns the pool
exchange rate before/after the latest round (previous_rate/current_rate)
at stack positions 11/12, replacing last_staked/last_recovered. The rate
advances once per validation round, so the growth must be compounded per
single round duration; the old 2-round duration halved the APY (showed
~8.3% instead of the actual ~17.3%). Also adds apyBaseInception derived
from the launch exchange rate of 1.0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@behrang, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f36d8249-9b89-48b9-a2c8-84d0bf8bf183

📥 Commits

Reviewing files that changed from the base of the PR and between 77d3e8e and 0344873.

📒 Files selected for processing (1)
  • src/adaptors/hipo/index.js
📝 Walkthrough

Walkthrough

The Hipo adapter now calculates APY from treasury exchange-rate changes, derives compounding from round duration, and returns an additional inception-based APY metric.

Changes

Hipo APY calculation

Layer / File(s) Summary
Exchange-rate APY calculation
src/adaptors/hipo/index.js
Adds launch-time tracking, recalculates apyBase from previous and current treasury rates, computes apyBaseInception, and includes it in the returned pool object.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: 0xkr3p, slasher125

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: correcting Hipo APY calculation after treasury state semantics changed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

The hipo adapter exports pools:

Test Suites: 1 passed, 1 total
Tests: 11 passed, 11 total
Snapshots: 0 total
Time: 0.239 s
Ran all test suites.

Nb of pools: 1
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────────┬───────┬─────────┬─────────┬───────────────┬────────────────────┬───────────────────┬────────────────────────────────────────────────────────┐
│ (index) │ pool                                                   │ chain │ project │ symbol  │ tvlUsd        │ apyBase            │ apyBaseInception  │ underlyingTokens                                       │
├─────────┼────────────────────────────────────────────────────────┼───────┼─────────┼─────────┼───────────────┼────────────────────┼───────────────────┼────────────────────────────────────────────────────────┤
│ 0       │ 'eqclyzhp4xe8fpchqz76o-_rmuhavc_9baogyjrwjrcbz2ez-ton' │ 'TON' │ 'hipo'  │ 'hGRAM' │ 3589033.45002 │ 15.624562164011557 │ 4.986485134856422 │ [ 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c' ] │
└─────────┴────────────────────────────────────────────────────────┴───────┴─────────┴─────────┴───────────────┴────────────────────┴───────────────────┴────────────────────────────────────────────────────────┘

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/adaptors/hipo/index.js`:
- Around line 52-63: Validate previousRate, currentRate, and roundDuration in
the APY calculation before computing compoundingFrequency; require finite rate
values and roundDuration greater than zero, and throw when any value is invalid.
Remove the `|| 1` fallback from the currentRate/previousRate calculation so
malformed treasury data cannot be persisted as a 0% APY.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 01bad34c-1217-45b8-a8c2-617077890b1f

📥 Commits

Reviewing files that changed from the base of the PR and between e978b0a and 77d3e8e.

📒 Files selected for processing (1)
  • src/adaptors/hipo/index.js

Comment thread src/adaptors/hipo/index.js Outdated
Throw on non-finite or non-positive rates and round duration instead of
falling back to a 0% APY when treasury data is malformed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

The hipo adapter exports pools:

Test Suites: 1 passed, 1 total
Tests: 11 passed, 11 total
Snapshots: 0 total
Time: 0.232 s
Ran all test suites.

Nb of pools: 1
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────────┬───────┬─────────┬─────────┬───────────────┬────────────────────┬───────────────────┬────────────────────────────────────────────────────────┐
│ (index) │ pool                                                   │ chain │ project │ symbol  │ tvlUsd        │ apyBase            │ apyBaseInception  │ underlyingTokens                                       │
├─────────┼────────────────────────────────────────────────────────┼───────┼─────────┼─────────┼───────────────┼────────────────────┼───────────────────┼────────────────────────────────────────────────────────┤
│ 0       │ 'eqclyzhp4xe8fpchqz76o-_rmuhavc_9baogyjrwjrcbz2ez-ton' │ 'TON' │ 'hipo'  │ 'hGRAM' │ 3589033.45002 │ 15.624562164011557 │ 4.986392785697613 │ [ 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c' ] │
└─────────┴────────────────────────────────────────────────────────┴───────┴─────────┴─────────┴───────────────┴────────────────────┴───────────────────┴────────────────────────────────────────────────────────┘

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.

1 participant