Skip to content

Priority fees #36

@iLewisMC

Description

@iLewisMC

How do I add priority fees. Ive made a test file to try and see which parmeter it needs ive even been through the whole src and I cant seem to get it working. Swaps are working fine when I dont try to define priority fee.

CODE:
`import asyncio
import base58
from solders.keypair import Keypair
from solana.rpc.async_api import AsyncClient
from jupiter_python_sdk.jupiter import Jupiter
import json
import os
import logging

Set up logging

logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(levelname)s: %(message)s')
logger = logging.getLogger()

async def test_priority_fee_parameters():
"""Test different parameter names for priority fee"""

# Load your wallet
wallet_path = 'wallets.json'  # Update this path if needed

with open(wallet_path, 'r') as f:
    wallet_data = json.load(f)

# Get private key from wallet
private_key_bytes = base58.b58decode(wallet_data['private_key'])
keypair = Keypair.from_bytes(private_key_bytes)

# Initialize RPC client
rpc_endpoint = "https://api.mainnet-beta.solana.com"
async_client = AsyncClient(rpc_endpoint)

# Initialize Jupiter
jupiter = Jupiter(
    async_client=async_client,
    keypair=keypair,
    quote_api_url="https://quote-api.jup.ag/v6/quote?",
    swap_api_url="https://quote-api.jup.ag/v6/swap"
)

# Get a quote first (small amount to avoid actual swaps)
logger.info("Getting quote...")
quote = await jupiter.quote(
    input_mint="So11111111111111111111111111111111111111112",  # SOL
    output_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",  # USDC
    amount=100000  # 0.0001 SOL - very small amount
)

if not quote:
    logger.error("Failed to get quote")
    return

logger.info("Quote received successfully")

# Test different parameter names
test_params = [
    'prioritization_fee',
    'prioritizationFee',
    'prioritization_fee_lamports',
    'prioritizationFeeLamports'
]

for param_name in test_params:
    try:
        logger.info(f"Testing parameter: {param_name}")
        
        # Create parameters dictionary dynamically
        params = {
            'input_mint': "So11111111111111111111111111111111111111112",
            'output_mint': "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
            'amount': 100000,  # Very small amount
            'slippage_bps': 100,
            param_name: 10000  # 10,000 lamports priority fee
        }
        
        # Try to get swap transaction data (but don't execute it)
        transaction_data = await jupiter.swap(**params)
        
        # If we get here, it worked!
        logger.info(f"✅ SUCCESS with parameter: {param_name}")
        return param_name
        
    except Exception as e:
        logger.error(f"❌ FAILED with parameter {param_name}: {str(e)}")

logger.info("All parameter names failed")
return None

async def main():
result = await test_priority_fee_parameters()
if result:
print(f"\n✅ The correct parameter name is: {result}")
else:
print("\n❌ Could not determine the correct parameter name")

if name == "main":
asyncio.run(main())`

OUTPUT
`Starting bot...
2025-03-16 10:11:08,689 - INFO: Getting quote...
2025-03-16 10:11:08,856 - INFO: Quote received successfully
2025-03-16 10:11:08,856 - INFO: Testing parameter: prioritization_fee
2025-03-16 10:11:08,856 - ERROR: ❌ FAILED with parameter prioritization_fee: Jupiter.swap() got an unexpected keyword argument 'prioritization_fee'
2025-03-16 10:11:08,858 - INFO: Testing parameter: prioritizationFee
2025-03-16 10:11:08,858 - ERROR: ❌ FAILED with parameter prioritizationFee: Jupiter.swap() got an unexpected keyword argument 'prioritizationFee'
2025-03-16 10:11:08,858 - INFO: Testing parameter: prioritization_fee_lamports
2025-03-16 10:11:08,858 - ERROR: ❌ FAILED with parameter prioritization_fee_lamports: Jupiter.swap() got an unexpected keyword argument 'prioritization_fee_lamports'
2025-03-16 10:11:08,858 - INFO: Testing parameter: prioritizationFeeLamports
2025-03-16 10:11:08,859 - ERROR: ❌ FAILED with parameter prioritizationFeeLamports: Jupiter.swap() got an unexpected keyword argument 'prioritizationFeeLamports'
2025-03-16 10:11:08,859 - INFO: All parameter names failed

❌ Could not determine the correct parameter name
Press any key to continue . . .`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions