Skip to content

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

Merged
fengtality merged 7 commits into
developmentfrom
fix/fee-double-counting
Apr 15, 2026
Merged

fix / remove double-counting of priority fee in getFee#620
fengtality merged 7 commits into
developmentfrom
fix/fee-double-counting

Conversation

@fengtality

@fengtality fengtality commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

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>
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>
@rapcmia rapcmia moved this to Development v2.14.0 in Pull Request Board Apr 2, 2026
@rapcmia rapcmia moved this from Development v2.14.0 to Under Review in Pull Request Board Apr 2, 2026
@rapcmia rapcmia added this to the v2.14 milestone Apr 2, 2026
@rapcmia

rapcmia commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Commit 04b6777

  • Test LP operations on Meteora and verify fee is correct ✅
    • Successfully opened position address GViwfJPXZdqBSmeee82x7pt1ZLPZfegfXMFFWtdWxBwB
    • Get Amount added + positon rent + network fee ok
    • The before, after and delta matches the wallet balance
  • Compare reported fee with Solscan transaction fee matched ✅
  • Test poll endpoint with failed transaction signature ✅
    • Submitted an oversized Meteora add-liquidity request on our open position
    • Polled the failed txns from the earlier add-liquidity request via /chains/solana/poll
    • Poll endpoint returned txStatus -1
      curl -s -X POST http://localhost:15888/chains/solana/poll -H "Content-Type: application/json" -d '
      {
        "network": "mainnet-beta",
        "signature": "HzuVjkD2U8XfvUDwuDzhb65aY1Tnejfrkbev7g9WyfR1Cnjo8Hv4AdMXPyrKYdLVdMzQkajsC3uv1cqrfJ8Ljr4"
      }' | jq
      {
        "currentBlock": 411650624,
        "signature": "HzuVjkD2U8XfvUDwuDzhb65aY1Tnejfrkbev7g9WyfR1Cnjo8Hv4AdMXPyrKYdLVdMzQkajsC3uv1cqrfJ8Ljr4",
        "txBlock": 266559915,
        "txStatus": -1,
        "fee": 0.000075,
        "error": "INSUFFICIENT_BALANCE (unknown): Insufficient funds for transaction.",
        "txData": {
          "meta": {
            "fee": 75000,
            "err": {
              "InsufficientFundsForRent": {
                "account_index": 0
              }
            }
          },
          "blockTime": 1716055030
        }
      }
      logs: 2026-04-07 06:36:55 | info | 	Transaction HzuVjkD2U8XfvUDwuDzhb65aY1Tnejfrkbev7g9WyfR1Cnjo8Hv4AdMXPyrKYdLVdMzQkajsC3uv1cqrfJ8Ljr4 failed: INSUFFICIENT_BALANCE (unknown): Insufficient funds for transaction.
      
  • Verify error parsing for slippage errors ❗
    • jupiter/rommuter, code SLIPPAGE_EXCEEDED ✅
    • raydium/clmm, code SLIPPAGE_EXCEEDED ✅
    • For meteora and orca, im still not able to get the SLIPAGE_EXCEEDED error ❗
      • For most of the test i used 0 slippage and do swaps ended with SIMULATION_FAILED, transcation timeout or successful

@fengtality fengtality merged commit 2dfba27 into development Apr 15, 2026
5 checks passed
@fengtality fengtality deleted the fix/fee-double-counting branch April 15, 2026 15:03
@rapcmia rapcmia moved this from Under Review to Development v2.14.0 in Pull Request Board Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Release v2.14.0

Development

Successfully merging this pull request may close these issues.

2 participants