Skip to content

Read per-pool AMM fees from the venue instead of assuming a constant - #462

Open
Naajih09 wants to merge 6 commits into
Divinity-Labs:mainfrom
Naajih09:fix/298-per-pool-fees
Open

Naajih09 wants to merge 6 commits into
Divinity-Labs:mainfrom
Naajih09:fix/298-per-pool-fees

Conversation

@Naajih09

Copy link
Copy Markdown

Closes #298

What this does

Pricing previously used a single fee constant for every AMM pool. Protocols set fees per pool, so pools with a different fee were priced wrongly with no error. This change reads each pool's fee from the venue, caches it, and uses it wherever a fee is needed.

  • Reads the fee for each AMM pool from the venue.
  • Caches the fee and tests the cache, including expiry and refresh.
  • Excludes any pool whose fee cannot be read from execution estimates, and reports it in the response so the exclusion is visible.
  • Removes the fee constant from the pricing path.
  • Echoes network in every response it touches and treats ?network= as required on any new behavior, per the issue's guidance.

Provenance

Responses that use a pool's fee include the pool ID, the fee in basis points, and when that fee was read. Excluded pools are listed with the reason.

Scope

SDEX order-book levels do not have a per-pool fee, so this PR covers AMM pools only. Any SDEX fee handling stays unchanged.

Known limits

  • Fee source. I have not yet confirmed the exact field the venue exposes for each pool's fee. This needs to be checked against the protocol's documentation before merge.
  • Cache lifetime. The cache duration is a judgment call. I'll state the value used and why in the PR review.
  • Not run against a live service. Tests run locally with fixtures. Verification against live pools is still needed.

How to verify

Added interfaces for excluded pools and depth outcomes, updated depth result structure, and modified getDepth function to handle excluded pools.
@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Naajih09 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Fees are assumed, not read

1 participant