Skip to content

fix / remove double-counting of priority fee in getFee#620

Open
fengtality wants to merge 6 commits intodevelopmentfrom
fix/fee-double-counting
Open

fix / remove double-counting of priority fee in getFee#620
fengtality wants to merge 6 commits intodevelopmentfrom
fix/fee-double-counting

Conversation

@fengtality
Copy link
Copy Markdown
Contributor

@fengtality fengtality commented Mar 28, 2026

Summary

  • Fix transaction fee calculation that was double-counting priority fees
  • Solana RPC meta.fee already includes both base fee and priority fee
  • Previous code extracted priority fee from compute budget instructions and added it again

New in this update:

  • Add Solana error parser for user-friendly error messages
  • Simplify /poll endpoint (remove tokens/walletAddress params)
  • Parse on-chain transaction errors into structured format: TYPE (code): message
  • Add error helper functions for consistent error handling

Error Parser

Parses program-specific error codes into user-friendly messages:

Program Error Codes Type
Jupiter 6001 SLIPPAGE_EXCEEDED
Meteora DLMM 6004, 6018, 6040 SLIPPAGE_EXCEEDED, MATH_OVERFLOW, INVALID_POSITION
Raydium CLMM 6029-6031, 6037 SLIPPAGE_EXCEEDED, PRICE_LIMIT_OVERFLOW
Orca Whirlpool 6029-6031 SLIPPAGE_EXCEEDED

Example poll response for failed transaction:

{
  "txStatus": -1,
  "fee": 0.000403,
  "error": "SLIPPAGE_EXCEEDED (0x1771): Slippage tolerance exceeded. The output amount would be less than your minimum.",
  "txData": {...}
}

Affected Connectors

Connector Status
Meteora CLMM ✅ Fixed
Orca CLMM ✅ Fixed
Raydium CLMM ✅ Unaffected (reads meta.fee directly)
PancakeSwap-Sol CLMM ✅ Unaffected (reads meta.fee directly)

Related PRs

QA Note: These 4 PRs should be tested together as a coordinated release.

Repo PR Description
hummingbot #8150 Move retry logic from executors to connectors
hummingbot-api #142 Add SwapExecutor with connector-level retry
hummingbot-api-client #16 Add swap/lp executor client support
gateway #620 Fix fee calculation, add error parsing (this PR)

Test plan

  • Verify build passes
  • Test LP operations on Meteora and verify fee is correct
  • Compare reported fee with Solscan transaction fee
  • Test poll endpoint with failed transaction signature
  • Verify error parsing for slippage errors

🤖 Generated with Claude Code

fengtality and others added 2 commits March 28, 2026 09:11
The Solana RPC `meta.fee` field already includes both base fee and
priority fee. The previous code was extracting the priority fee from
compute budget instructions and adding it again, causing fees to be
reported as nearly double the actual amount.

This fix affects all connectors using sendAndConfirmTransaction:
- Meteora CLMM
- Orca CLMM

Note: Raydium and PancakeSwap-Sol were unaffected as they read
meta.fee directly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add solana-error-parser.ts for parsing program error codes
- Parse on-chain transaction errors into user-friendly messages
- Simplify /poll endpoint: remove tokens/walletAddress params
- Include parsed error in poll response (TYPE (code): message)
- Add error helper functions: simulationFailed, insufficientBalance, slippageExceeded

Error codes supported:
- Jupiter: 6001 (slippage)
- Meteora DLMM: 6004, 6018, 6040
- Raydium CLMM: 6029-6031, 6037
- Orca Whirlpool: 6029-6031

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rapcmia rapcmia requested review from nikspz and rapcmia March 30, 2026 01:48
@rapcmia rapcmia changed the title fix: remove double-counting of priority fee in getFee fix / remove double-counting of priority fee in getFee Mar 31, 2026
fengtality and others added 4 commits March 31, 2026 06:38
Add specific error type for no-route scenarios that allows clients to
know they can retry with flipped direction (ExactIn vs ExactOut).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The noRouteFound error returns 400 (not 404) as it's not a "resource
not found" error but a "bad request" where no route exists.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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