abstract-solana 0.0.0.88__py3-none-any.whl → 0.0.0.90__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 +15 -16
- abstract_solana/pumpFun/pump_fun_keys.py +8 -4
- abstract_solana/pumpFun/token_utils.py +10 -9
- {abstract_solana-0.0.0.88.dist-info → abstract_solana-0.0.0.90.dist-info}/METADATA +1 -1
- {abstract_solana-0.0.0.88.dist-info → abstract_solana-0.0.0.90.dist-info}/RECORD +7 -7
- {abstract_solana-0.0.0.88.dist-info → abstract_solana-0.0.0.90.dist-info}/WHEEL +0 -0
- {abstract_solana-0.0.0.88.dist-info → abstract_solana-0.0.0.90.dist-info}/top_level.txt +0 -0
|
@@ -41,13 +41,13 @@ def buildTxn(mint,payer_pubkey, amount, slippage, token_account,sol_in=0,token_p
|
|
|
41
41
|
txn.add(close_account_instructions)
|
|
42
42
|
return txn
|
|
43
43
|
|
|
44
|
-
def get_all_buy_sell_info(mint,payer_pubkey,token_balance=None,sol_in=0,
|
|
44
|
+
def get_all_buy_sell_info(mint,payer_pubkey,token_balance=None,sol_in=0,buy=True):
|
|
45
45
|
|
|
46
46
|
print("Owner Public Key:", payer_pubkey)
|
|
47
47
|
mint_str = str(mint)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
if not get_pubkey(mint_str).is_on_curve():
|
|
49
|
+
print('Mint public key is not on curve')
|
|
50
|
+
return False,amount,token_balance,token_price,token_account,token_account_instructions
|
|
51
51
|
mint_pubkey = get_pubkey(mint_str)
|
|
52
52
|
token_account, token_account_instructions = check_existing_token_account(payer_pubkey, mint_pubkey)
|
|
53
53
|
token_account_pubkey = get_pubkey(token_account)
|
|
@@ -60,10 +60,9 @@ def get_all_buy_sell_info(mint,payer_pubkey,token_balance=None,sol_in=0,amount=N
|
|
|
60
60
|
print("Failed to retrieve or create token account.")
|
|
61
61
|
return False,amount,token_balance,token_price,token_account,token_account_instructions
|
|
62
62
|
# Calculate token price
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
amount= int(LAMPORTS_PER_SOL * token_price)
|
|
63
|
+
token_price = get_token_price(mint_str)
|
|
64
|
+
print(f"Token Price: {token_price:.20f} SOL")
|
|
65
|
+
amount = int(LAMPORTS_PER_SOL * token_price)
|
|
67
66
|
print("Calculated Amount:", amount)
|
|
68
67
|
if buy == False:
|
|
69
68
|
if token_balance == None:
|
|
@@ -73,8 +72,8 @@ def get_all_buy_sell_info(mint,payer_pubkey,token_balance=None,sol_in=0,amount=N
|
|
|
73
72
|
return False,amount,token_balance,token_price,token_account,token_account_instructions
|
|
74
73
|
return mint,amount,token_balance,token_price,token_account_pubkey,token_account_instructions
|
|
75
74
|
|
|
76
|
-
def pump_fun_sell(mint: str,
|
|
77
|
-
mint,amount,token_balance,token_price,token_account,token_account_instructions = get_all_buy_sell_info(mint,payer_pubkey,token_balance=token_balance,
|
|
75
|
+
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:
|
|
76
|
+
mint,amount,token_balance,token_price,token_account,token_account_instructions = get_all_buy_sell_info(mint,payer_pubkey,token_balance=token_balance,buy=False)
|
|
78
77
|
if not mint:
|
|
79
78
|
return mint
|
|
80
79
|
return buildTxn(mint=mint,
|
|
@@ -88,8 +87,8 @@ def pump_fun_sell(mint: str,amountpayer_pubkey:Pubkey, token_balance: Optional[U
|
|
|
88
87
|
token_account_instructions=token_account_instructions,
|
|
89
88
|
buy=False)
|
|
90
89
|
|
|
91
|
-
def pump_fun_buy(mint: str,payer_pubkey:Pubkey, sol_in: float = 0.001, slippage: int = 25
|
|
92
|
-
mint,amount,token_balance,token_price,token_account,token_account_instructions = get_all_buy_sell_info(mint,payer_pubkey,sol_in=sol_in,
|
|
90
|
+
def pump_fun_buy(mint: str,payer_pubkey:Pubkey, sol_in: float = 0.001, slippage: int = 25) -> bool:
|
|
91
|
+
mint,amount,token_balance,token_price,token_account,token_account_instructions = get_all_buy_sell_info(mint,payer_pubkey,sol_in=sol_in,buy=True)
|
|
93
92
|
if not mint:
|
|
94
93
|
return mint
|
|
95
94
|
return buildTxn(mint=mint,
|
|
@@ -130,20 +129,20 @@ async def complete_txn(txn, payer_keypair,confirm=False):
|
|
|
130
129
|
|
|
131
130
|
print("Transaction confirmed:", confirm)
|
|
132
131
|
return confirm
|
|
133
|
-
def buy_pump(mint: str, payer_keypair: Pubkey, sol_in=None, slippage=None,confirm=False
|
|
132
|
+
def buy_pump(mint: str, payer_keypair: Pubkey, sol_in=None, slippage=None,confirm=False):
|
|
134
133
|
sol_in = sol_in or 0.001
|
|
135
134
|
slippage = slippage or 25
|
|
136
135
|
payer_pubkey = get_pubkey(payer_keypair.pubkey())
|
|
137
|
-
txn = pump_fun_buy(mint=mint, payer_pubkey=payer_pubkey, sol_in=sol_in, slippage=slippage
|
|
136
|
+
txn = pump_fun_buy(mint=mint, payer_pubkey=payer_pubkey, sol_in=sol_in, slippage=slippage)
|
|
138
137
|
completed = asyncio.run(complete_txn(txn, payer_keypair,confirm=confirm)) # Await here since `complete_txn` is async
|
|
139
138
|
if not completed:
|
|
140
139
|
print("Buy transaction failed")
|
|
141
140
|
return completed
|
|
142
141
|
|
|
143
|
-
def sell_pump(mint:str, payer_keypair:Pubkey, token_balance=None, slippage=None,confirm=False
|
|
142
|
+
def sell_pump(mint:str, payer_keypair:Pubkey, token_balance=None, slippage=None,confirm=False):
|
|
144
143
|
slippage = slippage or 25
|
|
145
144
|
payer_pubkey = get_pubkey(payer_keypair.pubkey())
|
|
146
|
-
txn = pump_fun_sell(mint=mint, payer_pubkey=payer_pubkey, token_balance=token_balance, slippage=slippage
|
|
145
|
+
txn = pump_fun_sell(mint=mint, payer_pubkey=payer_pubkey, token_balance=token_balance, slippage=slippage)
|
|
147
146
|
completed = asyncio.run(complete_txn(txn, payer_keypair,confirm=confirm))
|
|
148
147
|
if not completed:
|
|
149
148
|
print("sell transaction failed")
|
|
@@ -83,9 +83,11 @@ def get_virtual_reserves(bonding_curve: Pubkey):
|
|
|
83
83
|
|
|
84
84
|
# Retrieves comprehensive transaction and reserve data for the mint
|
|
85
85
|
def get_pump_fun_data(mint_str: str=None,signature=None,commitment="finalized"):
|
|
86
|
-
if
|
|
86
|
+
if mint_str:
|
|
87
|
+
txn_types = change_keys_lower(getTxnTypes(mint_str))
|
|
88
|
+
if signature:
|
|
87
89
|
txn_types = change_keys_lower(get_txnTypesFromGenesisSignature(signature,commitment=commitment))
|
|
88
|
-
|
|
90
|
+
mint_str = mint_str or txn_types.get('mint')
|
|
89
91
|
bonding_curve = derive_bonding_curve(mint_str)
|
|
90
92
|
virtual_reserves = get_virtual_reserves(bonding_curve)
|
|
91
93
|
if virtual_reserves is None:
|
|
@@ -105,8 +107,10 @@ def get_pump_fun_data(mint_str: str=None,signature=None,commitment="finalized"):
|
|
|
105
107
|
|
|
106
108
|
def getKeys(mint_str,token_account,payer_pubkey,buy=True):
|
|
107
109
|
MINT = get_pubkey(str(mint_str))
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
bonding_curve = derive_bonding_curve(str(mint_str))
|
|
111
|
+
associated_bonding_curve = derive_associated_bonding_curve(str(mint_str))
|
|
112
|
+
BONDING_CURVE = get_pubkey(str(bonding_curve[0]))
|
|
113
|
+
ASSOCIATED_BONDING_CURVE = get_pubkey(str(associated_bonding_curve))
|
|
110
114
|
ASSOCIATED_USER = Pubkey.from_string(str(token_account))
|
|
111
115
|
USER = Pubkey.from_string(str(payer_pubkey))
|
|
112
116
|
PUMP_FUN_TOKEN_PROGRAM_SWITCH = TOKEN_PROGRAM_ID_PUBKEY if buy else PUMP_FUN_ASSOC_TOKEN_ACC_PROG_PUBKEY
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from ..constants import TOKEN_DECIMAL_EXP,SOL_DECIMAL_EXP
|
|
2
|
-
from ..pubkey_utils import Pubkey
|
|
3
|
-
from .pump_fun_keys import
|
|
2
|
+
from ..pubkey_utils import Pubkey
|
|
3
|
+
from .pump_fun_keys import get_pump_fun_data
|
|
4
4
|
from abstract_solcatcher import getTokenAccountBalance,getTokenAccountsByOwner
|
|
5
5
|
from spl.token.instructions import create_associated_token_account, get_associated_token_address
|
|
6
6
|
from abstract_utilities import get_any_value
|
|
@@ -10,15 +10,16 @@ def get_token_balance(payer,mint: str):
|
|
|
10
10
|
response=response.get('value',response)
|
|
11
11
|
ui_amount = get_any_value(response, "uiAmount") or 0
|
|
12
12
|
return float(ui_amount)
|
|
13
|
-
def calculate_token_price(virtual_sol_reserves,virtual_token_reserves):
|
|
14
|
-
virtual_sol_reserves = virtual_sol_reserves / SOL_DECIMAL_EXP
|
|
15
|
-
virtual_token_reserves = virtual_token_reserves / TOKEN_DECIMAL_EXP
|
|
16
|
-
return virtual_sol_reserves / virtual_token_reserves
|
|
17
13
|
def get_token_price(mint: str) -> float:
|
|
18
14
|
try:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
# Get coin data
|
|
16
|
+
coin_data = get_pump_fun_data(str(mint))
|
|
17
|
+
if not coin_data:
|
|
18
|
+
print("Failed to retrieve coin data...")
|
|
19
|
+
return None
|
|
20
|
+
virtual_sol_reserves = coin_data['virtual_sol_reserves'] / SOL_DECIMAL_EXP
|
|
21
|
+
virtual_token_reserves = coin_data['virtual_token_reserves'] / TOKEN_DECIMAL_EXP
|
|
22
|
+
token_price = virtual_sol_reserves / virtual_token_reserves
|
|
22
23
|
print(f"Token Price: {token_price:.20f} SOL")
|
|
23
24
|
return token_price
|
|
24
25
|
except Exception as e:
|
|
@@ -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=fBJRFVfH00bczQ1ZrVPaHh4ot8eJ8ZwanqfPSpp2ur0,7830
|
|
15
15
|
abstract_solana/pumpFun/pumpFunKeys.py,sha256=yMS_fT-0ESndluVpZ17XdMhpXVtSfhtIG5njy7DJkfI,7961
|
|
16
|
-
abstract_solana/pumpFun/pump_fun_keys.py,sha256=
|
|
17
|
-
abstract_solana/pumpFun/token_utils.py,sha256=
|
|
18
|
-
abstract_solana-0.0.0.
|
|
19
|
-
abstract_solana-0.0.0.
|
|
20
|
-
abstract_solana-0.0.0.
|
|
21
|
-
abstract_solana-0.0.0.
|
|
16
|
+
abstract_solana/pumpFun/pump_fun_keys.py,sha256=jj_yLqXnVipuT9MalM7wp7x1LLmuE6c5mDQtRruxUTE,8492
|
|
17
|
+
abstract_solana/pumpFun/token_utils.py,sha256=NhMvpTnw3QZk8DmeKYFzuqEMEZEHUlrBKfFp7662ohw,2684
|
|
18
|
+
abstract_solana-0.0.0.90.dist-info/METADATA,sha256=dgPvkIpaEAlzv_8MiMyjEcTXd5RL2VoYrCOqOGmOmlE,981
|
|
19
|
+
abstract_solana-0.0.0.90.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
|
20
|
+
abstract_solana-0.0.0.90.dist-info/top_level.txt,sha256=SsJYent8eZQ0FU2jmP8wTj7aFZFhNwxxP-5cCTQ2B-o,16
|
|
21
|
+
abstract_solana-0.0.0.90.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|