abstract-solana 0.0.0.85__py3-none-any.whl → 0.0.0.87__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 +13 -12
- abstract_solana/pumpFun/pump_fun_keys.py +2 -2
- abstract_solana/pumpFun/token_utils.py +10 -6
- {abstract_solana-0.0.0.85.dist-info → abstract_solana-0.0.0.87.dist-info}/METADATA +1 -1
- {abstract_solana-0.0.0.85.dist-info → abstract_solana-0.0.0.87.dist-info}/RECORD +7 -7
- {abstract_solana-0.0.0.85.dist-info → abstract_solana-0.0.0.87.dist-info}/WHEEL +0 -0
- {abstract_solana-0.0.0.85.dist-info → abstract_solana-0.0.0.87.dist-info}/top_level.txt +0 -0
|
@@ -41,7 +41,7 @@ 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,buy=True):
|
|
44
|
+
def get_all_buy_sell_info(mint,payer_pubkey,token_balance=None,sol_in=0,amount=None,buy=True):
|
|
45
45
|
|
|
46
46
|
print("Owner Public Key:", payer_pubkey)
|
|
47
47
|
mint_str = str(mint)
|
|
@@ -60,9 +60,10 @@ def get_all_buy_sell_info(mint,payer_pubkey,token_balance=None,sol_in=0,buy=True
|
|
|
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
|
-
|
|
63
|
+
if amount == None:
|
|
64
|
+
token_price = get_token_price(mint_str)
|
|
65
|
+
print(f"Token Price: {token_price:.20f} SOL")
|
|
66
|
+
= int(LAMPORTS_PER_SOL * token_price)
|
|
66
67
|
print("Calculated Amount:", amount)
|
|
67
68
|
if buy == False:
|
|
68
69
|
if token_balance == None:
|
|
@@ -72,8 +73,8 @@ def get_all_buy_sell_info(mint,payer_pubkey,token_balance=None,sol_in=0,buy=True
|
|
|
72
73
|
return False,amount,token_balance,token_price,token_account,token_account_instructions
|
|
73
74
|
return mint,amount,token_balance,token_price,token_account_pubkey,token_account_instructions
|
|
74
75
|
|
|
75
|
-
def pump_fun_sell(mint: str,
|
|
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)
|
|
76
|
+
def pump_fun_sell(mint: str,amountpayer_pubkey:Pubkey, token_balance: Optional[Union[int, float]] = None, slippage: int = 25, close_token_account: bool = True,amount=None) -> bool:
|
|
77
|
+
mint,amount,token_balance,token_price,token_account,token_account_instructions = get_all_buy_sell_info(mint,payer_pubkey,token_balance=token_balance,amount=amount,buy=False)
|
|
77
78
|
if not mint:
|
|
78
79
|
return mint
|
|
79
80
|
return buildTxn(mint=mint,
|
|
@@ -87,8 +88,8 @@ def pump_fun_sell(mint: str,payer_pubkey:Pubkey, token_balance: Optional[Union[i
|
|
|
87
88
|
token_account_instructions=token_account_instructions,
|
|
88
89
|
buy=False)
|
|
89
90
|
|
|
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)
|
|
91
|
+
def pump_fun_buy(mint: str,payer_pubkey:Pubkey, sol_in: float = 0.001, slippage: int = 25,amount=None) -> bool:
|
|
92
|
+
mint,amount,token_balance,token_price,token_account,token_account_instructions = get_all_buy_sell_info(mint,payer_pubkey,sol_in=sol_in,amount=amount,buy=True)
|
|
92
93
|
if not mint:
|
|
93
94
|
return mint
|
|
94
95
|
return buildTxn(mint=mint,
|
|
@@ -129,20 +130,20 @@ async def complete_txn(txn, payer_keypair,confirm=False):
|
|
|
129
130
|
|
|
130
131
|
print("Transaction confirmed:", confirm)
|
|
131
132
|
return confirm
|
|
132
|
-
def buy_pump(mint: str, payer_keypair: Pubkey, sol_in=None, slippage=None,confirm=False):
|
|
133
|
+
def buy_pump(mint: str, payer_keypair: Pubkey, sol_in=None, slippage=None,confirm=False,amount=None):
|
|
133
134
|
sol_in = sol_in or 0.001
|
|
134
135
|
slippage = slippage or 25
|
|
135
136
|
payer_pubkey = get_pubkey(payer_keypair.pubkey())
|
|
136
|
-
txn = pump_fun_buy(mint=mint, payer_pubkey=payer_pubkey, sol_in=sol_in, slippage=slippage)
|
|
137
|
+
txn = pump_fun_buy(mint=mint, payer_pubkey=payer_pubkey, sol_in=sol_in, slippage=slippage,amount=amount)
|
|
137
138
|
completed = asyncio.run(complete_txn(txn, payer_keypair,confirm=confirm)) # Await here since `complete_txn` is async
|
|
138
139
|
if not completed:
|
|
139
140
|
print("Buy transaction failed")
|
|
140
141
|
return completed
|
|
141
142
|
|
|
142
|
-
def sell_pump(mint:str, payer_keypair:Pubkey, token_balance=None, slippage=None,confirm=False):
|
|
143
|
+
def sell_pump(mint:str, payer_keypair:Pubkey, token_balance=None, slippage=None,confirm=False,amount=None):
|
|
143
144
|
slippage = slippage or 25
|
|
144
145
|
payer_pubkey = get_pubkey(payer_keypair.pubkey())
|
|
145
|
-
txn = pump_fun_sell(mint=mint, payer_pubkey=payer_pubkey, token_balance=token_balance, slippage=slippage)
|
|
146
|
+
txn = pump_fun_sell(mint=mint, payer_pubkey=payer_pubkey, token_balance=token_balance, slippage=slippage,amount=amount)
|
|
146
147
|
completed = asyncio.run(complete_txn(txn, payer_keypair,confirm=confirm))
|
|
147
148
|
if not completed:
|
|
148
149
|
print("sell transaction failed")
|
|
@@ -105,8 +105,8 @@ def get_pump_fun_data(mint_str: str=None,signature=None,commitment="finalized"):
|
|
|
105
105
|
|
|
106
106
|
def getKeys(mint_str,token_account,payer_pubkey,buy=True):
|
|
107
107
|
MINT = get_pubkey(str(mint_str))
|
|
108
|
-
BONDING_CURVE = get_pubkey(derive_bonding_curve(mint_str))
|
|
109
|
-
ASSOCIATED_BONDING_CURVE = get_pubkey(derive_associated_bonding_curve(mint_str))
|
|
108
|
+
BONDING_CURVE = get_pubkey(str(derive_bonding_curve(str(mint_str))[0]))
|
|
109
|
+
ASSOCIATED_BONDING_CURVE = get_pubkey(derive_associated_bonding_curve(str(mint_str)))
|
|
110
110
|
ASSOCIATED_USER = Pubkey.from_string(str(token_account))
|
|
111
111
|
USER = Pubkey.from_string(str(payer_pubkey))
|
|
112
112
|
PUMP_FUN_TOKEN_PROGRAM_SWITCH = TOKEN_PROGRAM_ID_PUBKEY if buy else PUMP_FUN_ASSOC_TOKEN_ACC_PROG_PUBKEY
|
|
@@ -10,16 +10,20 @@ 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
|
|
13
17
|
def get_token_price(mint: str) -> float:
|
|
14
|
-
|
|
15
|
-
bonding_curve = derive_bonding_curve(
|
|
18
|
+
try:
|
|
19
|
+
bonding_curve = derive_bonding_curve(mint_str)
|
|
16
20
|
virtual_reserves = get_virtual_reserves(bonding_curve)
|
|
17
|
-
|
|
18
|
-
virtual_token_reserves = virtual_reserves.virtualTokenReserves / TOKEN_DECIMAL_EXP
|
|
19
|
-
token_price = virtual_sol_reserves / virtual_token_reserves
|
|
21
|
+
token_price = calculate_token_price(virtual_reserves.virtualSolReserves,virtual_reserves.virtualTokenReserves)
|
|
20
22
|
print(f"Token Price: {token_price:.20f} SOL")
|
|
21
23
|
return token_price
|
|
22
|
-
|
|
24
|
+
except Exception as e:
|
|
25
|
+
print(f"Error calculating token price: {e}")
|
|
26
|
+
return None
|
|
23
27
|
def get_account_by_owner(payer, mint_str: str) -> dict:
|
|
24
28
|
payload = {
|
|
25
29
|
"jsonrpc": "2.0",
|
|
@@ -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=2GLgbiRuZzQ7vzPz0s6g6oI8dHTnSuUztgtO9VRplY4,7988
|
|
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=iuxTjIGcWuwM8ZvlERqJdKNCMLig2xmZKXuoI0uqNL0,8340
|
|
17
|
+
abstract_solana/pumpFun/token_utils.py,sha256=KeGGYDgG-Ebfr-M5PDUrPzFDrFe7TGFMP5R53VgnLq0,2814
|
|
18
|
+
abstract_solana-0.0.0.87.dist-info/METADATA,sha256=cYLGM6s63oGKo2sQx54hz-TrVUNcrAYmwtqPdrFjYPE,981
|
|
19
|
+
abstract_solana-0.0.0.87.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
|
20
|
+
abstract_solana-0.0.0.87.dist-info/top_level.txt,sha256=SsJYent8eZQ0FU2jmP8wTj7aFZFhNwxxP-5cCTQ2B-o,16
|
|
21
|
+
abstract_solana-0.0.0.87.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|