abstract-solana 0.0.0.38__py3-none-any.whl → 0.0.0.39__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 +25 -27
- {abstract_solana-0.0.0.38.dist-info → abstract_solana-0.0.0.39.dist-info}/METADATA +1 -1
- {abstract_solana-0.0.0.38.dist-info → abstract_solana-0.0.0.39.dist-info}/RECORD +5 -5
- {abstract_solana-0.0.0.38.dist-info → abstract_solana-0.0.0.39.dist-info}/WHEEL +0 -0
- {abstract_solana-0.0.0.38.dist-info → abstract_solana-0.0.0.39.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import struct,base58,time
|
|
2
|
+
from typing import Optional,Union
|
|
2
3
|
from solders.hash import Hash
|
|
4
|
+
from solders.keypair import Keypair
|
|
3
5
|
from solders.instruction import Instruction
|
|
4
6
|
from solana.rpc.types import TokenAccountOpts,TxOpts
|
|
5
7
|
from solana.transaction import Transaction
|
|
@@ -59,9 +61,9 @@ def confirm_txn(txn_sig, max_retries=20, retry_interval=3):
|
|
|
59
61
|
time.sleep(retry_interval)
|
|
60
62
|
print("Max retries reached. Transaction confirmation failed.")
|
|
61
63
|
return None
|
|
62
|
-
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):
|
|
64
|
+
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):
|
|
63
65
|
# Get keys for the transaction, pass the token account's pubkey instead of the AccountMeta object
|
|
64
|
-
keys = getKeys(get_coin_data(mint), token_account_pubkey,
|
|
66
|
+
keys = getKeys(get_coin_data(mint), token_account_pubkey, payer_pubkey,buy=buy)
|
|
65
67
|
slippage_adjustment = 1 - (slippage / 100)
|
|
66
68
|
sol_change = sol_in if buy else float(token_balance) * float(token_price)
|
|
67
69
|
sol_change_with_slippage = sol_change * slippage_adjustment
|
|
@@ -76,25 +78,21 @@ def buildTxn(mint, amount, slippage, token_account_pubkey,sol_in=0,token_price=0
|
|
|
76
78
|
blockHash = getLatestBlockhash(commitment="processed")
|
|
77
79
|
recent_blockhash = get_any_value(blockHash.json(),'blockhash')
|
|
78
80
|
recent_blockhash = Hash.from_string(recent_blockhash)
|
|
79
|
-
txn = Transaction(recent_blockhash=recent_blockhash, fee_payer=
|
|
81
|
+
txn = Transaction(recent_blockhash=recent_blockhash, fee_payer=payer_pubkey)
|
|
80
82
|
txn.add(set_compute_unit_price(UNIT_PRICE))
|
|
81
83
|
txn.add(set_compute_unit_limit(UNIT_BUDGET))
|
|
82
84
|
if buy and token_account_instructions:
|
|
83
85
|
txn.add(token_account_instructions)
|
|
84
86
|
txn.add(swap_instruction)
|
|
85
87
|
if buy == False and close_token_account:
|
|
86
|
-
close_account_instructions = close_account(CloseAccountParams(PUMP_FUN_PROGRAM_PUBKEY, token_account_pubkey,
|
|
88
|
+
close_account_instructions = close_account(CloseAccountParams(PUMP_FUN_PROGRAM_PUBKEY, token_account_pubkey, payer_pubkey, payer_pubkey))
|
|
87
89
|
txn.add(close_account_instructions)
|
|
88
90
|
txn.sign(payer_keypair)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
print(confirm)
|
|
93
|
-
def get_all_buy_sell_info(mint,payer_keypair=None,token_balance=None):
|
|
91
|
+
return txn
|
|
92
|
+
|
|
93
|
+
def get_all_buy_sell_info(mint,payer_pubkey,token_balance=None,sol_in=0):
|
|
94
94
|
try:
|
|
95
|
-
|
|
96
|
-
payer_pubkey = payer_keypair.pubkey()
|
|
97
|
-
print("Owner Public Key:", owner)
|
|
95
|
+
print("Owner Public Key:", payer_pubkey)
|
|
98
96
|
mint_str = str(mint)
|
|
99
97
|
if not get_pubkey(mint_str).is_on_curve():
|
|
100
98
|
print('Mint public key is not on curve')
|
|
@@ -108,7 +106,7 @@ def get_all_buy_sell_info(mint,payer_keypair=None,token_balance=None):
|
|
|
108
106
|
print("Failed to retrieve coin data...")
|
|
109
107
|
return False
|
|
110
108
|
mint_pubkey = get_pubkey(mint_str)
|
|
111
|
-
token_account, token_account_instructions = check_existing_token_account(
|
|
109
|
+
token_account, token_account_instructions = check_existing_token_account(payer_pubkey, mint_pubkey)
|
|
112
110
|
token_account_pubkey = get_pubkey(token_account)
|
|
113
111
|
# Ensure the token_account is a valid Pubkey
|
|
114
112
|
if not isinstance(token_account_pubkey, Pubkey):
|
|
@@ -132,22 +130,22 @@ def get_all_buy_sell_info(mint,payer_keypair=None,token_balance=None):
|
|
|
132
130
|
except Exception as e:
|
|
133
131
|
print(e)
|
|
134
132
|
|
|
135
|
-
def pump_fun_sell(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
133
|
+
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:
|
|
134
|
+
mint,amount,token_balance,token_price,token_account_pubkey,token_account_instructions = get_all_buy_sell_info(mint,payer_pubkey,token_balance=token_balance)
|
|
135
|
+
return buildTxn(mint=mint,
|
|
136
|
+
amount=amount,
|
|
137
|
+
slippage=slippage,
|
|
138
|
+
sol_in=0,
|
|
139
|
+
token_balance=token_balance,
|
|
140
|
+
token_price=token_price,
|
|
141
|
+
token_account_pubkey=token_account_pubkey,
|
|
142
|
+
token_account_instructions=token_account_instructions,
|
|
143
|
+
buy=False)
|
|
146
144
|
|
|
147
|
-
def pump_fun_buy(
|
|
148
|
-
mint,amount,token_balance,token_price,token_account_pubkey,token_account_instructions = get_all_buy_sell_info(mint,
|
|
145
|
+
def pump_fun_buy(mint: str,payer_pubkey:Pubkey, sol_in: float = 0.001, slippage: int = 25) -> bool:
|
|
146
|
+
mint,amount,token_balance,token_price,token_account_pubkey,token_account_instructions = get_all_buy_sell_info(mint,payer_pubkey,sol_in=sol_in)
|
|
149
147
|
# Build the transaction
|
|
150
|
-
buildTxn(mint=mint,
|
|
148
|
+
return buildTxn(mint=mint,
|
|
151
149
|
amount=amount,
|
|
152
150
|
slippage=slippage,
|
|
153
151
|
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=DN0tMVKNkEJMw6KTLXnE3kDuDHmHsqqMoLhtHTRuvuw,7243
|
|
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.39.dist-info/METADATA,sha256=JsjvLeJsaI40tdZ6ylO5l02zFBv-dfIe2tlB_qkeZvM,924
|
|
19
|
+
abstract_solana-0.0.0.39.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
|
20
|
+
abstract_solana-0.0.0.39.dist-info/top_level.txt,sha256=SsJYent8eZQ0FU2jmP8wTj7aFZFhNwxxP-5cCTQ2B-o,16
|
|
21
|
+
abstract_solana-0.0.0.39.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|