abstract-solana 0.0.0.34__py3-none-any.whl → 0.0.0.35__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of abstract-solana might be problematic. Click here for more details.
- abstract_solana/pumpFun/buy_sell_pump.py +24 -28
- {abstract_solana-0.0.0.34.dist-info → abstract_solana-0.0.0.35.dist-info}/METADATA +1 -1
- {abstract_solana-0.0.0.34.dist-info → abstract_solana-0.0.0.35.dist-info}/RECORD +5 -5
- {abstract_solana-0.0.0.34.dist-info → abstract_solana-0.0.0.35.dist-info}/WHEEL +0 -0
- {abstract_solana-0.0.0.34.dist-info → abstract_solana-0.0.0.35.dist-info}/top_level.txt +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import struct,base58,time
|
|
2
|
+
from typing import Optional,Union
|
|
2
3
|
from solders.hash import Hash
|
|
3
4
|
from solders.keypair import Keypair
|
|
4
5
|
from solders.instruction import Instruction
|
|
5
6
|
from solana.rpc.types import TokenAccountOpts,TxOpts
|
|
6
7
|
from solana.transaction import Transaction
|
|
7
|
-
from ..pubkey_utils import Pubkey,get_pubkey
|
|
8
8
|
from ..constants import PUMP_FUN_PROGRAM_PUBKEY,LAMPORTS_PER_SOL
|
|
9
9
|
from solders.compute_budget import set_compute_unit_limit, set_compute_unit_price
|
|
10
10
|
from .token_utils import get_token_balance
|
|
@@ -60,9 +60,9 @@ def confirm_txn(txn_sig, max_retries=20, retry_interval=3):
|
|
|
60
60
|
time.sleep(retry_interval)
|
|
61
61
|
print("Max retries reached. Transaction confirmation failed.")
|
|
62
62
|
return None
|
|
63
|
-
def buildTxn(mint, amount, slippage, token_account_pubkey,sol_in=0,token_price=0,token_balance=0,token_account_instructions=None,close_token_account=False,buy=True):
|
|
63
|
+
def buildTxn(mint,payer_pubkey, amount, slippage, token_account_pubkey,sol_in=0,token_price=0,token_balance=0,token_account_instructions=None,close_token_account=False,buy=True):
|
|
64
64
|
# Get keys for the transaction, pass the token account's pubkey instead of the AccountMeta object
|
|
65
|
-
keys = getKeys(get_coin_data(mint), token_account_pubkey,
|
|
65
|
+
keys = getKeys(get_coin_data(mint), token_account_pubkey, payer_pubkey,buy=buy)
|
|
66
66
|
slippage_adjustment = 1 - (slippage / 100)
|
|
67
67
|
sol_change = sol_in if buy else float(token_balance) * float(token_price)
|
|
68
68
|
sol_change_with_slippage = sol_change * slippage_adjustment
|
|
@@ -77,25 +77,21 @@ def buildTxn(mint, amount, slippage, token_account_pubkey,sol_in=0,token_price=0
|
|
|
77
77
|
blockHash = getLatestBlockhash(commitment="processed")
|
|
78
78
|
recent_blockhash = get_any_value(blockHash.json(),'blockhash')
|
|
79
79
|
recent_blockhash = Hash.from_string(recent_blockhash)
|
|
80
|
-
txn = Transaction(recent_blockhash=recent_blockhash, fee_payer=
|
|
80
|
+
txn = Transaction(recent_blockhash=recent_blockhash, fee_payer=payer_pubkey)
|
|
81
81
|
txn.add(set_compute_unit_price(UNIT_PRICE))
|
|
82
82
|
txn.add(set_compute_unit_limit(UNIT_BUDGET))
|
|
83
83
|
if buy and token_account_instructions:
|
|
84
84
|
txn.add(token_account_instructions)
|
|
85
85
|
txn.add(swap_instruction)
|
|
86
86
|
if buy == False and close_token_account:
|
|
87
|
-
close_account_instructions = close_account(CloseAccountParams(PUMP_FUN_PROGRAM_PUBKEY, token_account_pubkey,
|
|
87
|
+
close_account_instructions = close_account(CloseAccountParams(PUMP_FUN_PROGRAM_PUBKEY, token_account_pubkey, payer_pubkey, payer_pubkey))
|
|
88
88
|
txn.add(close_account_instructions)
|
|
89
89
|
txn.sign(payer_keypair)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
print(confirm)
|
|
94
|
-
def get_all_buy_sell_info(mint,payer_keypair=None,token_balance=None):
|
|
90
|
+
return txn
|
|
91
|
+
|
|
92
|
+
def get_all_buy_sell_info(mint,payer_pubkey,token_balance=None,sol_in=0):
|
|
95
93
|
try:
|
|
96
|
-
|
|
97
|
-
payer_pubkey = payer_keypair.pubkey()
|
|
98
|
-
print("Owner Public Key:", owner)
|
|
94
|
+
print("Owner Public Key:", payer_pubkey)
|
|
99
95
|
mint_str = str(mint)
|
|
100
96
|
if not get_pubkey(mint_str).is_on_curve():
|
|
101
97
|
print('Mint public key is not on curve')
|
|
@@ -109,7 +105,7 @@ def get_all_buy_sell_info(mint,payer_keypair=None,token_balance=None):
|
|
|
109
105
|
print("Failed to retrieve coin data...")
|
|
110
106
|
return False
|
|
111
107
|
mint_pubkey = get_pubkey(mint_str)
|
|
112
|
-
token_account, token_account_instructions = check_existing_token_account(
|
|
108
|
+
token_account, token_account_instructions = check_existing_token_account(payer_pubkey, mint_pubkey)
|
|
113
109
|
token_account_pubkey = get_pubkey(token_account)
|
|
114
110
|
# Ensure the token_account is a valid Pubkey
|
|
115
111
|
if not isinstance(token_account_pubkey, Pubkey):
|
|
@@ -133,22 +129,22 @@ def get_all_buy_sell_info(mint,payer_keypair=None,token_balance=None):
|
|
|
133
129
|
except Exception as e:
|
|
134
130
|
print(e)
|
|
135
131
|
|
|
136
|
-
def pump_fun_sell(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
132
|
+
def pump_fun_sell(mint: str,payer_pubkey:Pubkey, token_balance: Optional[Union[int, float]] = None, slippage: int = 25, close_token_account: bool = True) -> bool:
|
|
133
|
+
mint,amount,token_balance,token_price,token_account_pubkey,token_account_instructions = get_all_buy_sell_info(mint,payer_pubkey,token_balance=token_balance)
|
|
134
|
+
return buildTxn(mint=mint,
|
|
135
|
+
amount=amount,
|
|
136
|
+
slippage=slippage,
|
|
137
|
+
sol_in=0,
|
|
138
|
+
token_balance=token_balance,
|
|
139
|
+
token_price=token_price,
|
|
140
|
+
token_account_pubkey=token_account_pubkey,
|
|
141
|
+
token_account_instructions=token_account_instructions,
|
|
142
|
+
buy=False)
|
|
147
143
|
|
|
148
|
-
def pump_fun_buy(
|
|
149
|
-
mint,amount,token_balance,token_price,token_account_pubkey,token_account_instructions = get_all_buy_sell_info(mint,
|
|
144
|
+
def pump_fun_buy(mint: str,payer_pubkey:Pubkey, sol_in: float = 0.001, slippage: int = 25) -> bool:
|
|
145
|
+
mint,amount,token_balance,token_price,token_account_pubkey,token_account_instructions = get_all_buy_sell_info(mint,payer_pubkey,sol_in=sol_in)
|
|
150
146
|
# Build the transaction
|
|
151
|
-
buildTxn(mint=mint,
|
|
147
|
+
return buildTxn(mint=mint,
|
|
152
148
|
amount=amount,
|
|
153
149
|
slippage=slippage,
|
|
154
150
|
sol_in=sol_in,
|
|
@@ -11,11 +11,11 @@ abstract_solana/pumpFunKeys.py,sha256=KHZyQ_GFS9XzmNNMzEDQkAZsiM5Mpua6ZE1e3WebEr
|
|
|
11
11
|
abstract_solana/signature_data_parse.py,sha256=5AOMtJZADWcwR0JLDbd2kXZNzW129qeB0lvYUrE_tm0,1974
|
|
12
12
|
abstract_solana/utils.py,sha256=RcnGEiZ0aJbcw8ObpjHU3WUFU4Tmy-exCs6qIbEu4_c,444
|
|
13
13
|
abstract_solana/pumpFun/__init__.py,sha256=BiRxwJd1JWwEft63zqYwZ_Xs6UDp4hjczjzvuwy3sHg,85
|
|
14
|
-
abstract_solana/pumpFun/buy_sell_pump.py,sha256=
|
|
14
|
+
abstract_solana/pumpFun/buy_sell_pump.py,sha256=pGyuFmG07KieuCdl0sxrhNDYKamgLx79zfBv5g08y8c,7198
|
|
15
15
|
abstract_solana/pumpFun/pumpFunKeys.py,sha256=yMS_fT-0ESndluVpZ17XdMhpXVtSfhtIG5njy7DJkfI,7961
|
|
16
16
|
abstract_solana/pumpFun/pump_fun_keys.py,sha256=lL7afQx3-PYOHz69rm7Cyr2_tLp0nFXLZAd-7tvztm8,7963
|
|
17
17
|
abstract_solana/pumpFun/token_utils.py,sha256=oDvY0YVn8vWwSS3yS-tpZVxb3IvqovGPFicxiXg7YHI,2297
|
|
18
|
-
abstract_solana-0.0.0.
|
|
19
|
-
abstract_solana-0.0.0.
|
|
20
|
-
abstract_solana-0.0.0.
|
|
21
|
-
abstract_solana-0.0.0.
|
|
18
|
+
abstract_solana-0.0.0.35.dist-info/METADATA,sha256=9SrN44bJzSnHTWb24HT0Ddcv11o2qZ0r-nU2rnMLhHo,924
|
|
19
|
+
abstract_solana-0.0.0.35.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
|
20
|
+
abstract_solana-0.0.0.35.dist-info/top_level.txt,sha256=SsJYent8eZQ0FU2jmP8wTj7aFZFhNwxxP-5cCTQ2B-o,16
|
|
21
|
+
abstract_solana-0.0.0.35.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|