abstract-solana 0.0.0.60__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.60 → abstract_solana-0.0.0.62}/PKG-INFO +1 -1
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/setup.py +1 -1
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/buy_sell_pump.py +63 -72
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/PKG-INFO +1 -1
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/test/test_abstract_solana.py +3 -3
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/README.md +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/setup.cfg +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/__init__.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/account_key_utils.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/constants.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/genesis_functions.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/index_utils.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/keypair_utils.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/log_message_functions.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/price_utils.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/pubkey_utils.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/__init__.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/pump_fun_keys.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/token_utils.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/signature_data_parse.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/utils.py +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/SOURCES.txt +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/dependency_links.txt +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/requires.txt +0 -0
- {abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/top_level.txt +0 -0
{abstract_solana-0.0.0.60 → 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,61 +13,34 @@ 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
|
-
|
|
68
|
-
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):
|
|
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
|
|
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
|
-
keys = getKeys(mint,
|
|
43
|
+
keys = getKeys(mint, token_account=token_account, payer_pubkey=payer_pubkey,buy=buy)
|
|
71
44
|
slippage_adjustment = 1 - (slippage / 100)
|
|
72
45
|
sol_change = sol_in if buy else float(token_balance) * float(token_price)
|
|
73
46
|
sol_change_with_slippage = sol_change * slippage_adjustment
|
|
@@ -93,40 +66,41 @@ def buildTxn(mint,payer_pubkey, amount, slippage, token_account_pubkey,sol_in=0,
|
|
|
93
66
|
txn.add(close_account_instructions)
|
|
94
67
|
return txn
|
|
95
68
|
|
|
96
|
-
def get_all_buy_sell_info(mint,payer_pubkey,token_balance=None,sol_in=0):
|
|
97
|
-
|
|
69
|
+
def get_all_buy_sell_info(mint,payer_pubkey,token_balance=None,sol_in=0,buy=True):
|
|
70
|
+
|
|
98
71
|
print("Owner Public Key:", payer_pubkey)
|
|
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")
|
|
117
90
|
amount = int(LAMPORTS_PER_SOL * token_price)
|
|
118
91
|
print("Calculated Amount:", amount)
|
|
119
|
-
if
|
|
120
|
-
token_balance
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
92
|
+
if buy == False:
|
|
93
|
+
if token_balance == None:
|
|
94
|
+
token_balance = get_token_balance(token_account,mint_str)
|
|
95
|
+
print("Token Balance:", token_balance)
|
|
96
|
+
if token_balance == 0:
|
|
97
|
+
return False,amount,token_balance,token_price,token_account,token_account_instructions
|
|
124
98
|
return mint,amount,token_balance,token_price,token_account_pubkey,token_account_instructions
|
|
125
|
-
|
|
126
|
-
print(e)
|
|
127
|
-
|
|
99
|
+
|
|
128
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:
|
|
129
|
-
mint,amount,token_balance,token_price,
|
|
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
|
|
130
104
|
return buildTxn(mint=mint,
|
|
131
105
|
payer_pubkey=payer_pubkey,
|
|
132
106
|
amount=amount,
|
|
@@ -134,13 +108,14 @@ def pump_fun_sell(mint: str,payer_pubkey:Pubkey, token_balance: Optional[Union[i
|
|
|
134
108
|
sol_in=0,
|
|
135
109
|
token_balance=token_balance,
|
|
136
110
|
token_price=token_price,
|
|
137
|
-
|
|
111
|
+
token_account=token_account,
|
|
138
112
|
token_account_instructions=token_account_instructions,
|
|
139
113
|
buy=False)
|
|
140
114
|
|
|
141
115
|
def pump_fun_buy(mint: str,payer_pubkey:Pubkey, sol_in: float = 0.001, slippage: int = 25) -> bool:
|
|
142
|
-
mint,amount,token_balance,token_price,
|
|
143
|
-
|
|
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,)
|
|
117
|
+
if not mint:
|
|
118
|
+
return mint
|
|
144
119
|
return buildTxn(mint=mint,
|
|
145
120
|
payer_pubkey=payer_pubkey,
|
|
146
121
|
amount=amount,
|
|
@@ -148,7 +123,23 @@ def pump_fun_buy(mint: str,payer_pubkey:Pubkey, sol_in: float = 0.001, slippage:
|
|
|
148
123
|
sol_in=sol_in,
|
|
149
124
|
token_balance=0,
|
|
150
125
|
token_price=0,
|
|
151
|
-
|
|
126
|
+
token_account=token_account,
|
|
152
127
|
token_account_instructions=token_account_instructions,
|
|
153
128
|
buy=True)
|
|
154
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
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from spl.token.instructions import CloseAccountParams
|
|
2
|
-
from abstract_solana import get_pubkey,confirm_txn,pump_fun_buy,load_from_private_key,sendTransaction,load_from_private_key
|
|
2
|
+
from src.abstract_solana import get_pubkey,confirm_txn,pump_fun_sell,pump_fun_buy,load_from_private_key,sendTransaction,load_from_private_key
|
|
3
3
|
from solana.rpc.types import TxOpts
|
|
4
4
|
payer_keypair = load_from_private_key()
|
|
5
5
|
payer_pubkey = get_pubkey(payer_keypair.pubkey())
|
|
6
6
|
mint_str = "3bb6QmvustnZ627Kg2QvwTSi8gmxp7Y6orwXUokEwUyV"
|
|
7
|
-
|
|
8
|
-
txn = pump_fun_buy(mint=mint_str,payer_pubkey=payer_pubkey)
|
|
7
|
+
txn = pump_fun_sell(mint=mint_str,payer_pubkey=payer_pubkey, token_balance=None, slippage=25)
|
|
8
|
+
#txn = pump_fun_buy(mint=mint_str,payer_pubkey=payer_pubkey)
|
|
9
9
|
txn.sign(payer_keypair)
|
|
10
10
|
txn_sig = sendTransaction(txn, payer_keypair, TxOpts(skip_preflight=True))
|
|
11
11
|
print("Transaction Signature", txn_sig)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_solana-0.0.0.60 → 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.60 → 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.60 → 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.60 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/__init__.py
RENAMED
|
File without changes
|
{abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/pump_fun_keys.py
RENAMED
|
File without changes
|
{abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana/pumpFun/token_utils.py
RENAMED
|
File without changes
|
{abstract_solana-0.0.0.60 → 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.60 → 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.60 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/requires.txt
RENAMED
|
File without changes
|
{abstract_solana-0.0.0.60 → abstract_solana-0.0.0.62}/src/abstract_solana.egg-info/top_level.txt
RENAMED
|
File without changes
|