Skip to content

fix: harden proxy view fee previews#446

Open
carrion256 wants to merge 4 commits into
audit/fee-anchor-lifecycle-specfrom
audit/fee-preview-and-proxy-view-truthfulness
Open

fix: harden proxy view fee previews#446
carrion256 wants to merge 4 commits into
audit/fee-anchor-lifecycle-specfrom
audit/fee-preview-and-proxy-view-truthfulness

Conversation

@carrion256

@carrion256 carrion256 commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Stacked follow-up to PR #428 for the fee-anchor lifecycle cluster. This patch handles the latest proxy-view / fee-preview truthfulness rows with one Halborn-detectable commit per finding:

  • A-085 / Nexus 86ddc60c-b4d9-4e2e-a9ad-705890b3fc89 / #FIND-085 / commit 863a2b62: include configured max_total_assets_growth_rate in the proxy_view fee snapshot tuple.
  • A-077 / Nexus 082f9cb2-f33c-4006-8528-ef7a7b2918cc / #FIND-077 / commit 5842847b: replace unchecked u128 as i128 fee snapshot casts with to_i128(...) so overlarge stored fee-anchor/config values fail closed.
  • A-028 / Nexus ae756926-e93c-4d54-a4a6-3a706ed20867 / #FIND-028 / commit 335a946b: compute proxy_view max_deposit / max_mint against the opposite-side conversion headroom, not only same-side total/idle/supply headroom.
  • A-080 / Nexus 4460259b-12db-44b2-9396-262b531275c7 / #FIND-080 / commit 35b3685e: make fee-aware preview simulation return ConversionOverflow when management/performance fee minting would exceed u128::MAX instead of saturating supply.

Key files

  • contract/vault/soroban/src/contract/entrypoints.rs
  • contract/vault/soroban/src/fungible_vault.rs
  • contract/vault/soroban/tests/integration_tests.rs

Verification

  • cargo fmt --all -- --check
  • git diff --check
  • cargo test -p templar-soroban-runtime --test integration_tests soroban_contract_proxy_view -- --nocapture (4 passed)
  • cargo test -p templar-soroban-runtime --test integration_tests soroban_contract_fee_aware_preview_fails_on_supply_overflow -- --nocapture (1 passed)
  • cargo test -p templar-soroban-runtime --test integration_tests -- --nocapture (60 passed)
  • just -f contract/vault/soroban/justfile size-budget-check (runtime deploy WASM 96709 bytes <= 131072 bytes)
  • post-commit Soroban size-budget hook passed on each split commit; final head passed at 96709 bytes

Stack

Base: audit/fee-anchor-lifecycle-spec / PR #428.


This change is Reviewable

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ac26b1d3-590e-4e1e-b5e6-b333906478b7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch audit/fee-preview-and-proxy-view-truthfulness

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a128113c1c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +924 to +927
let fee_growth_rate = match config.fees.max_total_assets_growth_rate {
Some(rate) => to_i128(u128::from(rate))?,
None => 0,
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve growth-cap absence in proxy_view

When the fee config has no max_total_assets_growth_rate (the default uncapped mode), this maps it to 0, which is indistinguishable from a configured Some(Wad::zero()). Those two states are materially different because total_assets_for_fee_accrual treats None as uncapped growth but Some(0) as no growth beyond the anchor, and governance currently accepts Some(0). Downstream consumers of the new fee snapshot cannot reconstruct the actual fee policy and may simulate fee accrual incorrectly; return a presence flag/optional encoding or another unambiguous sentinel instead of collapsing None to zero.

Useful? React with 👍 / 👎.

@carrion256 carrion256 force-pushed the audit/fee-preview-and-proxy-view-truthfulness branch from a128113 to 8e550d7 Compare May 18, 2026 14:36
@carrion256 carrion256 force-pushed the audit/fee-anchor-lifecycle-spec branch from d31bf3c to ba08a36 Compare May 18, 2026 14:43
@carrion256 carrion256 force-pushed the audit/fee-preview-and-proxy-view-truthfulness branch 2 times, most recently from 6c6e6c8 to 35b3685 Compare May 18, 2026 14:45
@carrion256

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@carrion256 carrion256 force-pushed the audit/fee-preview-and-proxy-view-truthfulness branch 2 times, most recently from 35b3685 to e17ca85 Compare May 18, 2026 14:55
@carrion256 carrion256 force-pushed the audit/fee-anchor-lifecycle-spec branch from 8b940a2 to 3c4abaf Compare May 19, 2026 08:28
@carrion256 carrion256 force-pushed the audit/fee-preview-and-proxy-view-truthfulness branch from e17ca85 to 3118c26 Compare May 19, 2026 08:36
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