mirror of
https://github.com/chainstacklabs/pumpfun-bonkfun-bot.git
synced 2026-07-27 23:37:45 +00:00
fix: use base64 explicitly
This commit is contained in:
@@ -46,7 +46,7 @@ def get_associated_bonding_curve_address(
|
||||
async def get_bonding_curve_state(
|
||||
conn: AsyncClient, curve_address: Pubkey
|
||||
) -> BondingCurveState:
|
||||
response = await conn.get_account_info(curve_address)
|
||||
response = await conn.get_account_info(curve_address, encoding="base64")
|
||||
if not response.value or not response.value.data:
|
||||
raise ValueError("Invalid curve state: No data")
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ async def close_account_if_exists(client: SolanaClient, wallet: Wallet, account:
|
||||
"""Safely close a token account if it exists and reclaim rent."""
|
||||
try:
|
||||
solana_client = await client.get_client()
|
||||
info = await solana_client.get_account_info(account)
|
||||
info = await solana_client.get_account_info(account, encoding="base64") # base64 encoding for account data by deafult
|
||||
|
||||
# WARNING: This will permanently burn all tokens in the account before closing it
|
||||
# Closing account is impossible if balance is positive
|
||||
|
||||
@@ -38,7 +38,7 @@ class BondingCurveState:
|
||||
async def get_bonding_curve_state(
|
||||
conn: AsyncClient, curve_address: Pubkey
|
||||
) -> BondingCurveState:
|
||||
response = await conn.get_account_info(curve_address)
|
||||
response = await conn.get_account_info(curve_address, encoding="base64")
|
||||
if not response.value or not response.value.data:
|
||||
raise ValueError("Invalid curve state: No data")
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ async def get_market_address_by_base_mint(base_mint_address: Pubkey, amm_program
|
||||
|
||||
async def get_market_data(market_address: Pubkey):
|
||||
async with AsyncClient(RPC_ENDPOINT) as client:
|
||||
response = await client.get_account_info_json_parsed(market_address)
|
||||
response = await client.get_account_info(market_address, encoding="base64")
|
||||
data = response.value.data
|
||||
parsed_data = {}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class BondingCurveState:
|
||||
async def get_pump_curve_state(
|
||||
conn: AsyncClient, curve_address: Pubkey
|
||||
) -> BondingCurveState:
|
||||
response = await conn.get_account_info(curve_address)
|
||||
response = await conn.get_account_info(curve_address, encoding="base64")
|
||||
if not response.value or not response.value.data:
|
||||
raise ValueError("Invalid curve state: No data")
|
||||
|
||||
@@ -109,7 +109,7 @@ async def buy_token(
|
||||
# Create associated token account with retries
|
||||
for ata_attempt in range(max_retries):
|
||||
try:
|
||||
account_info = await client.get_account_info(associated_token_account)
|
||||
account_info = await client.get_account_info(associated_token_account, encoding="base64")
|
||||
if account_info.value is None:
|
||||
print(
|
||||
f"Creating associated token account (Attempt {ata_attempt + 1})..."
|
||||
|
||||
@@ -59,7 +59,7 @@ class BondingCurveState:
|
||||
async def get_pump_curve_state(
|
||||
conn: AsyncClient, curve_address: Pubkey
|
||||
) -> BondingCurveState:
|
||||
response = await conn.get_account_info(curve_address)
|
||||
response = await conn.get_account_info(curve_address, encoding="base64")
|
||||
if not response.value or not response.value.data:
|
||||
raise ValueError("Invalid curve state: No data")
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ load_dotenv()
|
||||
|
||||
# Configuration constants
|
||||
RPC_ENDPOINT = os.environ.get("SOLANA_NODE_RPC_ENDPOINT")
|
||||
TOKEN_MINT = Pubkey.from_string("35ySx7Rt3RqeTp75QB81FgRvPT5yDY2m5BupsUYDpump")
|
||||
TOKEN_MINT = Pubkey.from_string("8XNrSusWrzYpizYXJb5yeB66AWX1cfQ86SBJFqVTpump")
|
||||
PRIVATE_KEY = base58.b58decode(os.environ.get("SOLANA_PRIVATE_KEY"))
|
||||
PAYER = Keypair.from_bytes(PRIVATE_KEY)
|
||||
SLIPPAGE = 0.25 # Slippage tolerance (25%) - the maximum price movement you'll accept
|
||||
@@ -63,7 +63,7 @@ async def get_market_address_by_base_mint(client: AsyncClient, base_mint_address
|
||||
|
||||
response = await client.get_program_accounts(
|
||||
amm_program_id,
|
||||
encoding="jsonParsed",
|
||||
encoding="base64",
|
||||
filters=filters
|
||||
)
|
||||
|
||||
@@ -82,7 +82,7 @@ async def get_market_data(client: AsyncClient, market_address: Pubkey) -> dict:
|
||||
Returns:
|
||||
Dictionary containing the parsed market data
|
||||
"""
|
||||
response = await client.get_account_info_json_parsed(market_address)
|
||||
response = await client.get_account_info(market_address, encoding="base64")
|
||||
data = response.value.data
|
||||
parsed_data: dict = {}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class AccountCleanupManager:
|
||||
)
|
||||
|
||||
try:
|
||||
info = await solana_client.get_account_info(ata)
|
||||
info = await solana_client.get_account_info(ata, encoding="base64")
|
||||
if not info.value:
|
||||
logger.info(f"ATA {ata} does not exist or already closed.")
|
||||
return
|
||||
|
||||
@@ -121,7 +121,7 @@ class TokenBuyer(Trader):
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Buy operation failed: {str(e)}")
|
||||
logger.error(f"Buy operation failed: {e!s}")
|
||||
return TradeResult(success=False, error_message=str(e))
|
||||
|
||||
async def _ensure_associated_token_account(
|
||||
@@ -136,7 +136,7 @@ class TokenBuyer(Trader):
|
||||
try:
|
||||
solana_client = await self.client.get_client()
|
||||
account_info = await solana_client.get_account_info(
|
||||
associated_token_account
|
||||
associated_token_account, encoding="base64"
|
||||
)
|
||||
|
||||
if account_info.value is None:
|
||||
@@ -166,7 +166,7 @@ class TokenBuyer(Trader):
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error creating associated token account: {str(e)}")
|
||||
logger.error(f"Error creating associated token account: {e!s}")
|
||||
raise
|
||||
|
||||
async def _send_buy_transaction(
|
||||
@@ -245,5 +245,5 @@ class TokenBuyer(Trader):
|
||||
),
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Buy transaction failed: {str(e)}")
|
||||
logger.error(f"Buy transaction failed: {e!s}")
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user