Skip to content

fix: disable fee abstraction when base token price is 0 to prevent incorrect fee conversions#307

Merged
Thaleszh merged 3 commits into
mainfrom
fix/fee-abstraction-zero-price
Apr 1, 2026
Merged

fix: disable fee abstraction when base token price is 0 to prevent incorrect fee conversions#307
Thaleszh merged 3 commits into
mainfrom
fix/fee-abstraction-zero-price

Conversation

@Thaleszh

@Thaleszh Thaleszh commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Description

Disable fee abstraction when base token price is 0 to prevent incorrect fee conversions

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Regression test

PR Checklist:

Make sure each step was done:

  • Updated changelog with PR's intent
  • Lint with make lint-fix

@Thaleszh Thaleszh requested a review from jhelison as a code owner April 1, 2026 14:21
@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The changes address a fee abstraction bug by extending price validation in the oracle keeper. The CalculateFeeTokenPrices function now treats non-positive base token prices as invalid and disables fee abstraction in such cases. A test case was added to verify the module disables itself when the base token price is zero. The changelog documents this fix.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: disabling fee abstraction when base token price is 0 to prevent incorrect fee conversions, which matches the primary code changes in oracle.go.
Description check ✅ Passed The description is directly related to the changeset, explaining the bug fix to disable fee abstraction when base token price is 0, and notes that changelog and linting were completed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/fee-abstraction-zero-price

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 and usage tips.

@codecov

codecov Bot commented Apr 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
x/feeabstraction/keeper/oracle.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
x/feeabstraction/keeper/oracle.go (1)

37-44: ⚠️ Potential issue | 🟡 Minor

Debug message is misleading for zero/negative prices, and clarify the operational design.

The module can be re-enabled through the UpdateParams governance message (line 28 in msg_server.go), which accepts an authority parameter. However, once disabled by zero/negative price, automatic recovery does not occur—the module remains disabled until governance explicitly re-enables it via proposal.

Additionally, the debug message "%s has no price" (line 41) is accurate when the price is missing (!ok) but misleading when the price exists but is zero or negative (!baseTokenPrice.IsPositive()). Consider distinguishing these cases in the log message, e.g., "%s price is not positive" or similar.

The permanent-disable-until-governance-action design is a valid safety choice but may be worth documenting if the behavior isn't already evident to operators. If auto-recovery on price recovery is desired, the BeginBlocker would need periodic re-validation even when disabled.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@x/feeabstraction/keeper/oracle.go` around lines 37 - 44, The code currently
treats missing and non-positive prices the same and logs a misleading message;
update the block that reads twapPriceMap[params.NativeOracleDenom] to
distinguish the two cases: if !ok log via k.Logger(ctx).Debug that the denom has
no price (e.g., "%s has no price"), and if baseTokenPrice exists but
!baseTokenPrice.IsPositive() log a different message (e.g., "%s price is not
positive") before setting params.Enabled = false and calling k.Params.Set(ctx,
params); also add a short inline comment referencing the governance UpdateParams
(msg_server.go) as the required manual re-enable path so operators know the
module remains disabled until a governance proposal re-enables it.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@x/feeabstraction/keeper/oracle.go`:
- Around line 37-44: The code currently treats missing and non-positive prices
the same and logs a misleading message; update the block that reads
twapPriceMap[params.NativeOracleDenom] to distinguish the two cases: if !ok log
via k.Logger(ctx).Debug that the denom has no price (e.g., "%s has no price"),
and if baseTokenPrice exists but !baseTokenPrice.IsPositive() log a different
message (e.g., "%s price is not positive") before setting params.Enabled = false
and calling k.Params.Set(ctx, params); also add a short inline comment
referencing the governance UpdateParams (msg_server.go) as the required manual
re-enable path so operators know the module remains disabled until a governance
proposal re-enables it.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c6eef121-6509-4d83-b6d5-7db572f5775c

📥 Commits

Reviewing files that changed from the base of the PR and between 46bf6ed and 09e05f7.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • x/feeabstraction/keeper/oracle.go
  • x/feeabstraction/keeper/oracle_test.go

@Thaleszh Thaleszh merged commit cfb695d into main Apr 1, 2026
9 of 10 checks passed
@Thaleszh Thaleszh deleted the fix/fee-abstraction-zero-price branch April 1, 2026 17: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