abstract-solana 0.0.0.61__tar.gz → 0.0.0.62__tar.gz
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-0.0.0.61 → abstract_solana-0.0.0.62}/PKG-INFO +1 -1
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/setup.py +1 -1
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/buy_sell_pump.py +49 -57
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/PKG-INFO +1 -1
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/README.md +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/setup.cfg +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/__init__.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/account_key_utils.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/constants.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/genesis_functions.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/index_utils.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/keypair_utils.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/log_message_functions.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/price_utils.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/pubkey_utils.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/__init__.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/pump_fun_keys.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/token_utils.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/signature_data_parse.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/utils.py +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/SOURCES.txt +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/dependency_links.txt +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/requires.txt +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/top_level.txt +0 -0
- {abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/test/test_abstract_solana.py +0 -0
{abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/buy_sell_pump.py
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import struct,base58,time,requests
|
|
1
|
+
import struct,base58,time,requests,asyncio,time
|
|
2
2
|
from typing import Optional,Union
|
|
3
3
|
from solders.hash import Hash
|
|
4
4
|
from solders.keypair import Keypair
|
|
5
5
|
from solders.instruction import Instruction
|
|
6
6
|
from solana.rpc.types import TokenAccountOpts,TxOpts
|
|
7
7
|
from solana.transaction import Transaction
|
|
8
|
-
from abstract_solcatcher import getLatestBlockHash
|
|
8
|
+
from abstract_solcatcher import getLatestBlockHash,getTransaction
|
|
9
9
|
from abstract_utilities import get_any_value
|
|
10
10
|
from ..pubkey_utils import Pubkey,get_pubkey
|
|
11
11
|
from spl.token.instructions import CloseAccountParams,close_account
|
|
@@ -13,58 +13,31 @@ from ..constants import PUMP_FUN_PROGRAM_PUBKEY,LAMPORTS_PER_SOL,UNIT_PRICE,UNIT
|
|
|
13
13
|
from solders.compute_budget import set_compute_unit_limit, set_compute_unit_price
|
|
14
14
|
from .token_utils import get_token_balance,check_existing_token_account,get_token_price
|
|
15
15
|
from .pump_fun_keys import getKeys
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
txn.sign(payer_keypair)
|
|
19
|
-
|
|
20
|
-
# Serialize the transaction to a base64 string
|
|
21
|
-
txn_base64 = base58.b58encode(txn.serialize()).decode('utf-8')
|
|
22
|
-
|
|
23
|
-
# Prepare the RPC request payload
|
|
24
|
-
payload = {
|
|
25
|
-
"jsonrpc": "2.0",
|
|
26
|
-
"id": 1,
|
|
27
|
-
"method": "sendTransaction",
|
|
28
|
-
"params": [txn_base64, {"skipPreflight": opts.skip_preflight, "preflightCommitment": "finalized"}]
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
# Send the transaction
|
|
32
|
-
response = requests.post(
|
|
33
|
-
url="https://rpc.ankr.com/solana/c3b7fd92e298d5682b6ef095eaa4e92160989a713f5ee9ac2693b4da8ff5a370",
|
|
34
|
-
json=payload
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
# Parse the JSON response
|
|
38
|
-
response_json = response.json()
|
|
39
|
-
|
|
40
|
-
# Return the result or the entire response in case of error
|
|
41
|
-
return response_json.get('result', response_json)
|
|
42
|
-
def confirm_txn(txn_sig, max_retries=20, retry_interval=3):
|
|
16
|
+
from abstract_solcatcher import sendTransaction,getTransaction
|
|
17
|
+
async def confirm_txn(txn_sig, max_retries=20, retry_interval=3):
|
|
43
18
|
retries = 0
|
|
44
|
-
|
|
45
19
|
while retries < max_retries:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return None
|
|
20
|
+
txn_res = await getTransaction(signature=str(txn_sig))
|
|
21
|
+
print(txn_res)
|
|
22
|
+
if txn_res:
|
|
23
|
+
print(txn_res)
|
|
24
|
+
print(f"\n\nhttps://solscan.io/tx/{str(txn_sig)}")
|
|
25
|
+
return txn_res
|
|
26
|
+
retries += 1
|
|
27
|
+
print(f"Retrying... ({retries}/{max_retries})")
|
|
28
|
+
await asyncio.sleep(retry_interval)
|
|
29
|
+
print(f"Failed to confirm transaction after {max_retries} attempts.")
|
|
30
|
+
return txn_sig
|
|
31
|
+
def complete_txn(txn, payer_keypair):
|
|
32
|
+
txn_sig = sendTransaction(txn=txn, payer_keypair=payer_keypair, skip_preflight=True))
|
|
33
|
+
print("Transaction Signature", txn_sig)
|
|
34
|
+
confirm = asyncio.run(confirm_txn(txn_sig))
|
|
35
|
+
while not confirm:
|
|
36
|
+
print("Waiting for transaction confirmation...")
|
|
37
|
+
time.sleep(1) # Wait for 1 second before checking again
|
|
38
|
+
confirm = confirm_txn(txn_sig)
|
|
39
|
+
print("Transaction confirmed:", confirm)
|
|
40
|
+
return confirm
|
|
68
41
|
def buildTxn(mint,payer_pubkey, amount, slippage, token_account,sol_in=0,token_price=0,token_balance=0,token_account_instructions=None,close_token_account=False,buy=True):
|
|
69
42
|
# Get keys for the transaction, pass the token account's pubkey instead of the AccountMeta object
|
|
70
43
|
keys = getKeys(mint, token_account=token_account, payer_pubkey=payer_pubkey,buy=buy)
|
|
@@ -99,18 +72,18 @@ def get_all_buy_sell_info(mint,payer_pubkey,token_balance=None,sol_in=0,buy=True
|
|
|
99
72
|
mint_str = str(mint)
|
|
100
73
|
if not get_pubkey(mint_str).is_on_curve():
|
|
101
74
|
print('Mint public key is not on curve')
|
|
102
|
-
return False
|
|
75
|
+
return False,amount,token_balance,token_price,token_account,token_account_instructions
|
|
103
76
|
mint_pubkey = get_pubkey(mint_str)
|
|
104
77
|
token_account, token_account_instructions = check_existing_token_account(payer_pubkey, mint_pubkey)
|
|
105
78
|
token_account_pubkey = get_pubkey(token_account)
|
|
106
79
|
# Ensure the token_account is a valid Pubkey
|
|
107
80
|
if not isinstance(token_account_pubkey, Pubkey):
|
|
108
81
|
print("Failed to create or retrieve a valid token account Pubkey...")
|
|
109
|
-
return False
|
|
82
|
+
return False,amount,token_balance,token_price,token_account,token_account_instructions
|
|
110
83
|
print("Token Account:", token_account)
|
|
111
84
|
if not token_account:
|
|
112
85
|
print("Failed to retrieve or create token account.")
|
|
113
|
-
return False
|
|
86
|
+
return False,amount,token_balance,token_price,token_account,token_account_instructions
|
|
114
87
|
# Calculate token price
|
|
115
88
|
token_price = get_token_price(mint_str)
|
|
116
89
|
print(f"Token Price: {token_price:.20f} SOL")
|
|
@@ -121,11 +94,13 @@ def get_all_buy_sell_info(mint,payer_pubkey,token_balance=None,sol_in=0,buy=True
|
|
|
121
94
|
token_balance = get_token_balance(token_account,mint_str)
|
|
122
95
|
print("Token Balance:", token_balance)
|
|
123
96
|
if token_balance == 0:
|
|
124
|
-
return False
|
|
97
|
+
return False,amount,token_balance,token_price,token_account,token_account_instructions
|
|
125
98
|
return mint,amount,token_balance,token_price,token_account_pubkey,token_account_instructions
|
|
126
99
|
|
|
127
100
|
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:
|
|
128
101
|
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)
|
|
102
|
+
if not mint:
|
|
103
|
+
return mint
|
|
129
104
|
return buildTxn(mint=mint,
|
|
130
105
|
payer_pubkey=payer_pubkey,
|
|
131
106
|
amount=amount,
|
|
@@ -139,7 +114,8 @@ def pump_fun_sell(mint: str,payer_pubkey:Pubkey, token_balance: Optional[Union[i
|
|
|
139
114
|
|
|
140
115
|
def pump_fun_buy(mint: str,payer_pubkey:Pubkey, sol_in: float = 0.001, slippage: int = 25) -> bool:
|
|
141
116
|
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,)
|
|
142
|
-
|
|
117
|
+
if not mint:
|
|
118
|
+
return mint
|
|
143
119
|
return buildTxn(mint=mint,
|
|
144
120
|
payer_pubkey=payer_pubkey,
|
|
145
121
|
amount=amount,
|
|
@@ -151,3 +127,19 @@ def pump_fun_buy(mint: str,payer_pubkey:Pubkey, sol_in: float = 0.001, slippage:
|
|
|
151
127
|
token_account_instructions=token_account_instructions,
|
|
152
128
|
buy=True)
|
|
153
129
|
return True
|
|
130
|
+
|
|
131
|
+
def buy_pump(mint=mint_str, payer_keypair=payer_keypair,sol_in=0.001,slippage=25)
|
|
132
|
+
payer_pubkey = get_pubkey(payer_keypair.pubkey())
|
|
133
|
+
txn = pump_fun_buy(mint=mint_str, payer_pubkey=payer_pubkey,sol_in=sol_in,slippage=slippage)
|
|
134
|
+
completed = complete_txn(txn, payer_keypair)
|
|
135
|
+
if not completed:
|
|
136
|
+
print("Buy transaction failed")
|
|
137
|
+
return completed
|
|
138
|
+
|
|
139
|
+
def sell_pump(mint=mint_str, payer_keypair=payer_keypair, token_balance=None, slippage=25)
|
|
140
|
+
payer_pubkey = get_pubkey(payer_keypair.pubkey())
|
|
141
|
+
txn = pump_fun_sell(mint=mint_str, payer_pubkey=payer_pubkey, token_balance=token_balance, slippage=slippage)
|
|
142
|
+
completed = complete_txn(txn, payer_keypair)
|
|
143
|
+
if not completed:
|
|
144
|
+
print("sell transaction failed")
|
|
145
|
+
return completed
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/account_key_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/genesis_functions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/log_message_functions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/__init__.py
RENAMED
|
File without changes
|
{abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/pump_fun_keys.py
RENAMED
|
File without changes
|
{abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/token_utils.py
RENAMED
|
File without changes
|
{abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana/signature_data_parse.py
RENAMED
|
File without changes
|
|
File without changes
|
{abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/requires.txt
RENAMED
|
File without changes
|
{abstract_solana-0.0.0.61 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|