Skip to content

feat: estimate transaction fees before Soroban submission - #147

Open
samuelisi wants to merge 1 commit into
stellar-vortex-protocol:mainfrom
samuelisi:feature/soroban-fee-estimation
Open

feat: estimate transaction fees before Soroban submission#147
samuelisi wants to merge 1 commit into
stellar-vortex-protocol:mainfrom
samuelisi:feature/soroban-fee-estimation

Conversation

@samuelisi

@samuelisi samuelisi commented Jul 25, 2026

Copy link
Copy Markdown

Summary

  • Adds StellarTxService (src/soroban/stellar-tx.service.ts) with estimateFee and prepareTransaction, which use SorobanRpc.Server's simulateTransaction + getFeeStats APIs to compute base fee + resource fee instead of hardcoding a fee value.
  • Base (inclusion) fee is congestion-aware: sourced from network fee stats at a configurable percentile (stellar.feePercentile, env STELLAR_FEE_PERCENTILE, defaults to p50), falling back to BASE_FEE if fee stats are unavailable or degenerate.
  • Extends SorobanService with thin wrappers (getFeeStats, simulateTransaction, prepareTransaction) around the previously-private SorobanRpc.Server instance so this logic is testable without hitting the network.
  • Registers StellarTxService in SorobanModule so it's available for the settlement transaction flows landing in later issues.

Closes #31
closes #25
closes #35
closes #32

Test plan

  • npm run lint
  • npm run typecheck
  • npm test (24 passed, including 6 new specs in stellar-tx.service.spec.ts covering base-fee percentile lookup, fallback to BASE_FEE on RPC failure/degenerate stats, fee-estimate arithmetic, simulation-error handling, and prepared-transaction fee application)
  • npm run test:e2e (23 passed)
Full command output
$ npm run lint

> vortex-backend@0.1.0 lint
> eslint src test scripts --ext .ts


$ npm run typecheck

> vortex-backend@0.1.0 typecheck
> tsc --noEmit


$ npm test

> vortex-backend@0.1.0 test
> jest

Test Suites: 4 passed, 4 total
Tests:       24 passed, 24 total
Snapshots:   0 total
Time:        4.387 s
Ran all test suites.

$ npm run test:e2e

> vortex-backend@0.1.0 test:e2e
> jest --config ./test/jest-e2e.json

Test Suites: 5 passed, 5 total
Tests:       23 passed, 23 total
Snapshots:   0 total
Time:        6.217 s, estimated 10 s
Ran all test suites.

🤖 Generated with Claude Code

Add StellarTxService.estimateFee/prepareTransaction, which use
SorobanRpc.Server's simulateTransaction and getFeeStats APIs to compute
a congestion-aware base fee plus the simulated resource fee, instead of
relying on a hardcoded fee value. The inclusion-fee percentile used for
the base fee is configurable via STELLAR_FEE_PERCENTILE (defaults to p50).

Closes stellar-vortex-protocol#31
@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

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

1 participant