Commit Graph

597 Commits

Author SHA1 Message Date
0xfnzero 1d3c0ff5da fix: force Token-2022 for pump suffix mints 2026-05-28 05:21:24 +08:00
Wood 34f400e89d Merge pull request #103 from HelvetiCrypt/wait-for-all-submits
Add SwapParams.wait_for_all_submits to restore all-routes signature collection
2026-05-28 02:46:39 +08:00
HelvetiCrypt bd1772bed2 Add SwapParams.wait_for_all_submits to restore all-routes signature collection
v4.0.11 switched the fast-submit (`wait_tx_confirmed = false`) result loop
from `wait_for_all_submitted` to `wait_for_first_submitted`. The new
function returns as soon as one SWQOS route's HTTP submit completes and
drains whatever signatures are in `ResultCollector.results` at that
moment — slower routes' signatures arrive after the caller has returned.

This is correct for fire-and-forget low-latency submits, but breaks
callers that do their own on-chain confirmation against a pinned durable
nonce. Only one of the submitted txs can land (nonce is consumed by
whichever lands first), but the caller has no way of knowing in advance
which route it will be. Their post-submit logic feeds every returned
signature to `getSignatureStatuses` to find the landed one — with only
the fastest HTTP responder returned (often not the one that lands), the
landed tx isn't in the polled set.

Adds an opt-in `SwapParams.wait_for_all_submits: bool` (default false,
plumbed through `TradeBuyParams` / `TradeSellParams`). When true and
`wait_tx_confirmed = false`, `execute_parallel` uses
`wait_for_all_submitted` (still in the codebase, was
`#[allow(dead_code)]`) so every submitted signature is returned. Zero
behaviour change for current users.
2026-05-27 08:02:49 +00:00
0xfnzero 5449d51591 Release sol-trade-sdk 4.0.14 v4.0.14 2026-05-25 22:01:15 +08:00
0xfnzero b973061f92 Update DEX protocol support for 4.0.13 v4.0.13 2026-05-25 01:47:48 +08:00
0xfnzero 57e4c5d221 Fix PumpFun V2 buyback fee mutability v4.0.12 2026-05-22 08:56:20 +08:00
0xfnzero 8ed2aef931 Fix trade execution correctness and release 4.0.11 v4.0.11 2026-05-21 17:50:06 +08:00
0xfnzero 0cf0064e80 docs: clarify PumpFun V2 configuration 2026-05-21 14:48:43 +08:00
0xfnzero 4968c48a2e Release sol-trade-sdk v4.0.10
Sync Pump program IDLs with the latest definitions.
v4.0.10
2026-05-20 19:41:16 +08:00
0xfnzero 5908c84798 Merge remote-tracking branch 'origin/main' into codex/swqos-dual-fee-mode 2026-05-19 06:21:44 +08:00
0xfnzero 6dab47f8f9 Optimize SWQOS dual fee lane submission 2026-05-19 06:21:37 +08:00
0xfnzero a076e0f8cd chore: flatten synced IDL files
Remove the redundant idl/bitquery source snapshot tree and keep synced Bitquery IDLs only under the SDK's canonical local IDL filenames.
2026-05-16 15:03:10 +08:00
0xfnzero 05ac079d6d release: update DEX protocol support for v4.0.9
Sync supported DEX IDLs from bitquery/solana-idl-lib, upgrade protocol builders, and keep trade submission hot paths free of RPC query calls.

Include exact-output coverage, token-account setup fixes for WSOL and stable pairs, and low-latency transaction build improvements.
v4.0.9
2026-05-16 06:42:50 +08:00
0xfnzero f6db55c874 release: update Pump program metadata for v4.0.8 v4.0.8 2026-05-15 01:08:33 +08:00
0xfnzero 69b4f9bb9f docs: add donation wallet address to README_CN 2026-05-14 19:26:31 +08:00
0xfnzero 532bc1195d docs: add donation wallet address to README 2026-05-14 19:24:53 +08:00
0xfnzero 8944c5455c Refine crate description wording 2026-05-14 00:25:44 +08:00
0xfnzero 0d846930ad fix(pumpswap): use live global fee recipients 2026-05-13 21:16:17 +08:00
0xfnzero 703ae5e4db fix(pumpfun): preserve observed fee recipient 2026-05-12 05:55:45 +08:00
0xfnzero 8e0210af97 fix(swqos): replace non-portable try_from_base58_string with bs58 decode + TryFrom
The patched solana-keypair in the main workspace adds try_from_base58_string,
but sol-safekey and other consumers use the standard crates.io version which
only provides from_base58_string (panics) and TryFrom<&[u8]> (fallible).

Use bs58::decode + Keypair::try_from to keep proper error handling while
remaining compatible with the standard solana-keypair crate.
2026-05-09 15:02:25 +08:00
0xfnzero e605485ecf fix(bonding-curve): tolerate extra trailing bytes in account data
BondingCurveAccount::try_from_slice requires the entire input slice to
be consumed, which fails with "Not all bytes read" when the on-chain
bonding curve account has been extended with new fields (e.g. after a
protocol upgrade). Switch to BorshDeserialize::deserialize which reads
the known fields and silently ignores any trailing bytes.
2026-05-09 14:46:52 +08:00
0xfnzero 8dec2f8d8c fix(sell): trust observed creator_vault directly to prevent Anchor 2006
In build_sell_v1/v2, the creator_vault was previously derived via
effective_creator_for_trade() passed to resolve_creator_vault_for_ix_with_fee_sharing.
When observed_trade_creator differs from bonding_curve.creator (e.g. creator
updated post-deployment), the derived vault PDA mismatches the on-chain
seeds constraint, causing Anchor error 2006 (ConstraintSeeds) on sell.

The pump.fun sell instruction validates creator_vault seeds as
PDA("creator-vault", bonding_curve.creator), but buy does not check seeds,
so buy succeeds while sell fails with 2006.

Fix: when protocol_params.creator_vault is a valid non-default/non-phantom
value (observed from gRPC / update_fee_shares), use it directly without
re-derivation. Only fall back to resolve via bonding_curve.creator when
creator_vault is missing. This ensures the authoritative observed vault
is never overridden by a stale or mismatched creator.
2026-05-09 14:41:22 +08:00
0xfnzero b505bebdac fix(pumpfun): use is_cashback_coin instead of is_mayhem_mode for sell user_volume_accumulator
The Pump.fun IDL explicitly states that user_volume_accumulator is
passed as remaining_accounts[0] for cashback coins during sell.
Using is_mayhem_mode incorrectly omitted the account for cashback
tokens, causing the program to misread bonding_curve_v2 as
user_volume_accumulator and resulting in Custom(6024) Overflow.
2026-05-09 08:18:58 +08:00
0xfnzero 1cc051a874 feat(pumpfun): runtime V2 flag, buyback fee pool fix, legacy ix encoding
- Replace compile-time `pumpfun-v2` feature flag with runtime
  `TradeConfig::use_pumpfun_v2(bool)` for flexible V1/V2 switching
- Fix BUYBACK_FEE_RECIPIENTS pool: replace wrong addresses (was reusing
  standard pool + FEE_CONFIG) with official buyback pool from
  FEE_RECIPIENTS.md
- Fix legacy buy/buy_exact_sol_in ix data encoding: use 2-byte
  Option<bool> (option tag + value) matching official Pump SDK, 26 bytes
  total instead of broken 25
- Add `SwapParams.use_pumpfun_v2` field and wire through TradingClient
  buy/sell paths
- V2 instructions read `quote_mint` from `PumpFunParams` (not
  BondingCurveAccount which lacks the field)
- Fix `fetch_bonding_curve_account` to use BorshDeserialize instead of
  non-existent `decode_from_chain_account_data`
- Update all examples with `use_pumpfun_v2: false` field
- Update README with unified V1/V2 section showing both enabling methods
2026-05-09 07:15:07 +08:00
0xfnzero 0311a0b876 docs(readme): update SWQoS partner list to Jito, Temporal, FlashBlock, BlockRazor, Astralane, SpeedLanding
Remove non-partner services (Nextblock, ZeroSlot, Bloxroute, Node1).
Update code examples to use partner service configs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-09 00:05:53 +08:00
0xfnzero b49c1c803e fix(pump): restore 26-byte legacy buy instruction data encoding
The refactored ix data encoder was producing 25-byte buy instructions
(1-byte track_volume), but the on-chain Pump program expects Anchor's
2-byte Option<bool> encoding (option tag + value), totaling 26 bytes.
The 1-byte shortfall caused instruction data under-read that manifested
as error 0xbbf (ConstraintOwner) for all legacy buy/buy_exact_sol_in.

Restore the 2-byte encoding: option tag (1u8) followed by the cashback
flag as the bool value, matching the pre-refactoring inline encoder.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-08 23:37:07 +08:00
0xfnzero ce8fb99626 Revert "fix(pump): default token program to legacy SPL Token instead of Token-2022"
This reverts commit 49843d8a20.
2026-05-08 23:28:21 +08:00
0xfnzero 49843d8a20 fix(pump): default token program to legacy SPL Token instead of Token-2022
The `effective_pump_mint_token_program` helper was defaulting to
TOKEN_PROGRAM_2022 when `token_program` was Pubkey::default(), causing
Anchor error 0xbbf (account owned by wrong program) for all legacy
PumpFun coins whose ATAs are owned by the original Token Program.

Fall back to TOKEN_PROGRAM (legacy) when no explicit token program is
provided. Token-2022 must be set explicitly for create_v2 coins.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-08 23:23:39 +08:00
0xfnzero 60d1db4755 feat(pump): add buy_v2, sell_v2, buy_exact_quote_in_v2 instruction builders
Support Pump.fun Bonding Curve v2 unified trading interface with quote_mint
parameter for SOL-paired (WSOL) and USDC-paired coins.

- Add BUY_V2, SELL_V2, BUY_EXACT_QUOTE_IN_V2 discriminators
- Implement 27/26-account v2 instruction layouts matching official IDL
- Add PumpFunParams::quote_mint and use_v2_ix fields (default legacy)
- Add with_quote_mint() builder, buyback fee recipient pool, and PDA helpers
- Add v2 ix data encoders in pumpfun_ix_data.rs
- Legacy instructions remain default for backward compatibility

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-08 20:48:11 +08:00
0xfnzero 7a8d2a9c17 docs(readme): bump crates.io examples to v4.0.7
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-06 00:40:09 +08:00
0xfnzero 75bfbf6d54 fix(pumpfun): trust explicit ix creator_vault over creator-derived PDA
- resolve_creator_vault_for_ix_with_fee_sharing uses non-placeholder ix vault as-is.
- When ix vault missing, fall back to fee_sharing_creator_vault_if_active then PDA(creator).
- Add Pump troubleshooting CN doc; extend PumpFunParams field documentation.
- Bump to v4.0.7.

Co-authored-by: Cursor <cursoragent@cursor.com>
v4.0.7
2026-05-06 00:25:54 +08:00
0xfnzero 184f1cc583 fix(instruction): complete pump ix modules and pumpfun utils after params split
Adds pumpfun_ix_data / pumpswap_ix_data; exports used by trading::core::params::PumpFunParams.
chore(release): bump version to 4.0.6

Co-authored-by: Cursor <cursoragent@cursor.com>
v4.0.6
2026-05-04 14:32:47 +08:00
0xfnzero 55c13e2f25 chore(release): bump version to 4.0.5
Prepare GitHub release for client/params refactor and rlib-only library target.

Co-authored-by: Cursor <cursoragent@cursor.com>
v4.0.5
2026-05-04 14:29:23 +08:00
0xfnzero fda211ea87 refactor: extract TradingClient façade to client/mod.rs
refactor: split trading/core/params into per-protocol modules + dex_swap
build: crate-type rlib only (drop unused cdylib)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-04 13:46:11 +08:00
0xfnzero 85d2c602f3 fix(calc): return 0 for zero sell amount in slippage helper
calculate_with_slippage_sell previously fell through to the branch that
returned 1 when amount <= basis_points/10_000, which is true for amount=0
and typical bps values—yielding a bogus minimum of 1. Short-circuit on
zero input so sell quotes stay correct.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-03 17:30:09 +08:00
0xfnzero 02d939b3cf fix(pumpswap): align remaining accounts with official SDK for buyback
- Append pool-v2 in buy/sell remaining accounts only when pool coin_creator
  is not default, matching @pump-fun/pump-swap-sdk. Always appending pool-v2
  shifted buyback pubkey/ATA and caused BuybackFeeRecipientNotAuthorized (6053).

- Add coin_creator to PumpSwapParams (filled from decoded Pool / from_trade).
  Update pumpswap_trading example to pass pool_data.coin_creator.

- Document buyback fee recipient constants against GlobalConfig.buyback_fee_recipients.

- Extend PumpSwap quote math to include cashback_fee_basis_points in creator-side fees.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-03 14:50:26 +08:00
0xfnzero e8ec9103ab release: sol-trade-sdk 4.0.4
fix(swqos): extend parallel-submit wait/grace windows for late HTTP responses

- Scale primary submit timeout with configured channel count (clamped 3–5s)
- After primary expiry, optionally poll longer so slow providers still land before drain
- Short settle sleeps to reduce counter vs TaskResult races and dropped signatures when
  wait_transaction_confirmed is false

Co-authored-by: Cursor <cursoragent@cursor.com>
v4.0.4
2026-05-03 03:01:20 +08:00
Wood 0fe54f0e94 Merge pull request #100 from 0xfnzero/feat/pump-fee-recipient-upgrade
feat(pump): add protocol fee recipient accounts for PumpFun and PumpSwap
2026-04-27 14:53:23 +08:00
0xfnzero 7ac07247a3 feat(pump): add protocol fee recipient accounts for PumpFun and PumpSwap
- PumpFun buy/sell: append bonding-curve-v2 and random extra fee recipient (writable)
- PumpSwap buy/sell: append pool-v2, protocol fee pubkey, and fee quote mint ATA
- Keep utils helpers and constants aligned with on-chain layout (2026-04 upgrade)

Made-with: Cursor
2026-04-23 12:35:39 +08:00
0xfnzero 06ed710869 fix(swqos): Speedlanding QUIC TLS, quinn runtime, and SWQoS fallback
- Enable quinn feature runtime-tokio so QUIC clients (Speedlanding/Soyas) initialize instead of failing with "no async runtime found".
- Align Speedlanding with the official client: use solana_tls_utils new_dummy_x509_certificate and SkipServerVerification; use fixed TLS SNI "speed-landing" (not the PoP hostname).
- Raise per-SWQoS init timeout to 15s; always log init failures/timeouts; if every SWQoS client fails, fall back to Default RPC and print active channel labels.
- Improve SWQoS submission visibility (Default RPC path and related logging); adjust Soyas TLS credential handling where applicable.

Made-with: Cursor
2026-04-16 20:11:41 +08:00
0xfnzero d711346c55 fix(meteora-damm-v2): use correct token program for output ATA creation
- Pass token_a/token_b program based on swap direction (is_a_in) when
  creating the output mint ATA in buy flow, matching ATA address derivation
  for SPL Token vs Token-2022 mints.
- Resolve token_a_program and token_b_program from on-chain mint account
  owners in MeteoraDammV2Params::from_pool_address_by_rpc instead of
  hardcoding the classic SPL Token program.

Fixes incorrect ATA creation for Token-2022 output mints (issue #99).

Made-with: Cursor
2026-04-14 13:04:01 +08:00
0xfnzero 06ef2fed84 feat(swqos): align endpoint tables with SwqosRegion and document fallbacks
- Extend SWQOS regional constants to 10 entries (Dublin, Singapore, Default)
  so indices match SwqosRegion 0..9 everywhere
- Document geographic nearest-fill among published PoPs; call out Default and
  single-PoP provider constraints in comments
- Fix Node1 QUIC Default endpoint to match HTTP; tune ZeroSlot/Blox/Speedlanding
  regional mappings where a closer published PoP exists
- Add unit tests for table length and Astralane/Node1 cross-table consistency
- Update SwqosRegion rustdoc, README, and trading_client example accordingly

Made-with: Cursor
2026-04-14 02:13:42 +08:00
0xfnzero a391539000 chore: release 4.0.3
- Bump version and README crates.io examples to 4.0.3.

Made-with: Cursor
v4.0.3
2026-04-12 00:55:52 +08:00
0xfnzero c75ca4b034 fix(pumpfun): canonical BC PDAs, trust stream fee recipient, harden creator vault
- Always derive bonding curve and associated bonding vault from mint (avoids stale cached PDAs / wrong pool).
- Use non-default fee_recipient from parser/stream as account #2 without extra authorization filtering (addresses Pump 6000 NotAuthorized when event fee was rejected).
- Rework resolve_creator_vault_for_ix: default-creator cases, phantom default PDA, fee-sharing vault; add unit tests.
- PumpFunParams: respect explicit mayhem_mode from events; fallback creator_vault via get_creator_vault_pda when resolve returns None.
- Remove unused lazy_static tip-cache stub and lazy_static dependency.

Made-with: Cursor
2026-04-12 00:34:44 +08:00
0xfnzero b13b4fda0a fix(pumpfun): resolve creator_vault with fee-sharing PDA (mint-aware)
- Add get_fee_sharing_config_pda per @pump-fun/pump-sdk (sharing-config + mint under pump-fees)
- resolve_creator_vault_for_ix now takes mint: accept gRPC creator_vault when it matches either
  PDA(creator) or PDA(fee_sharing_config(mint)) for migrated / fee-sharing bonding curves
- Mayhem uses the same Pump buy/sell account layout (IDL); Token-2022 + fee pool differ, not creator_vault seeds

Made-with: Cursor
2026-04-11 19:44:54 +08:00
0xfnzero 4dec087ea6 fix(pumpfun): resolve creator_vault vs PDA(creator); validate fee recipient pool
- Add resolve_creator_vault_for_ix: use gRPC creator_vault only when it matches
  PDA(['creator-vault', bonding_curve.creator]); on mismatch use derived PDA to
  avoid ConstraintSeeds (2006) from stale/wrong stream vaults
- pump_fun_fee_recipient_meta: only use event fee_recipient if authorized for
  is_mayhem_mode (avoids 6000 NotAuthorized when standard AMM fee is used on
  Mayhem coins)
- Align PumpFunParams::from_trade/from_dev_trade cached creator_vault with the
  same resolution logic

Made-with: Cursor
2026-04-11 19:37:05 +08:00
0xfnzero 9c9ecf3e5b fix(pumpfun): prefer event creator_vault; align fees with pump-sdk
- Use protocol_params.creator_vault for buy/sell when non-default to avoid
  ConstraintSeeds (2006) when gRPC/event creator drifts from on-chain bonding curve
- Preserve event creator_vault in PumpFunParams::from_trade/from_dev_trade instead
  of always overwriting with PDA(creator)
- Fee recipient: prefer gRPC fee_recipient; else random from CURRENT_FEE_RECIPIENTS
  pool (standard) or MAYHEM pool, matching @pump-fun/pump-sdk fees.ts
- Add cold-path helpers: extend_bonding_curve_account_instruction, PUMP_BONDING_CURVE_MIN_DATA_LEN

Made-with: Cursor
2026-04-11 19:13:12 +08:00
0xfnzero 4b451af5ff feat: Pump.fun mayhem_mode, Solana 3.1.12, TradeConfig builder alignment
- PumpFunParams::from_trade/from_dev_trade: add mayhem_mode Option; infer Mayhem
  via is_mayhem_fee_recipient when None (fixes fee recipient / NotAuthorized 6000
  when AMM protocol fee pubkey is used).
- Add is_mayhem_fee_recipient and is_amm_fee_recipient helpers in pumpfun utils.
- Bump solana-* crates to 3.1.12; align tonic/prost; use solana-message for
  AddressLookupTableAccount; add solana-system-interface 3.0.
- Update examples and latency script for new PumpFunParams signature.
- SWQoS and transaction builder adjustments for dependency changes.

Made-with: Cursor
2026-04-11 18:43:18 +08:00
0xfnzero 8f2f99f3d9 chore: remove duplicate nodejs and python SDK subdirectories
These incomplete SDK implementations in the Rust repository were outdated
and redundant. The complete versions are maintained in separate repositories:
- sol-trade-sdk-ts (Node.js)
- sol-trade-sdk-python (Python)

🤖 Generated with [Qoder](https://qoder.com)
2026-04-10 15:37:53 +08:00
0xfnzero 971ef41fad feat: add global MEV protection and refactor TradeConfig to builder pattern
- Add `mev_protection: bool` to `TradeConfig` and `InfrastructureConfig` (default: false)
  - Astralane QUIC: switches to port 9000 (MEV-protected endpoint) when enabled
  - BlockRazor HTTP: uses `mode=sandwichMitigation` query param when enabled
  - BlockRazor gRPC: uses `mode=sandwichMitigation` when enabled
- Add `SWQOS_ENDPOINTS_ASTRALANE_QUIC_MEV` constants (port 9000) to `constants/swqos.rs`
- Fix `astralane_quic.rs` IP candidates to use the actual port from the address (supports both 7000 and 9000)
- Refactor `TradeConfig` to builder pattern via `TradeConfig::builder()`
  - Introduce `TradeConfigBuilder` with all optional fields and clear defaults
  - `TradeConfig::new()` kept as a shortcut (calls `builder().build()`) for backward compatibility
  - Remove old `with_wsol_ata_config` / `with_check_min_tip` / `with_swqos_cores_from_end` / `with_mev_protection` chain methods
- Update all 16 examples to use `TradeConfig::builder()` with commented-out options so users can discover all available settings at a glance
- Update README.md and README_CN.md code snippets to use builder pattern

🤖 Generated with [Qoder][https://qoder.com]
2026-04-08 02:13:37 +08:00