Repository navigation
feat(api): add sort_by=fee to v3 mempool transactions - #2739
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Fee cursors above PostgreSQL’s signed bigint maximum still pass validation and cause HTTP 500 instead of being rejected with HTTP 400.
1 open issue
What changed in this PR
Adds highest-total-fee-first sorting to GET /extended/v3/mempool/transactions, while preserving receipt-time sorting as the default.
Changes:
- Adds
sort_by=feewith order-specific cursors and mismatch validation. - Extends keyset pagination and adds a partial index for fee ordering.
- Tests fee ordering, tie-breaking, pagination, filtering, and invalid parameters.
| File | Description |
|---|---|
tests/api/mempool/mempool-v3.test.ts |
Tests fee sorting and cursor behavior. |
src/datastore/v3/pg-store-v3.ts |
Supports fee-based ordering and keyset pagination. |
src/api/schemas/v3/params.ts |
Defines and documents supported sort orders. |
src/api/schemas/v3/cursors.ts |
Adds the fee-prefixed list cursor format. |
src/api/routes/v3/mempool.ts |
Accepts sort selection and rejects mismatched cursors. |
migrations/1779800000032_mempool-txs-fee-rate-tx-id-index.ts |
Adds a partial fee-and-transaction-ID index for pending transactions. |
Review effort: Balanced
bgridley-stacks
approved these changes
Nov 2, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds
sort_by(receipt_timeorfee) andorder(ascordesc) toGET /extended/v3/mempool/transactions, so pending transactions can be listed by receipt time or total fee in either direction; the default stays newest first. A cursor only pages thesort_byit was returned for, but works in eitherorder.