abstract-solana 0.0.0.24__tar.gz → 0.0.0.25__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.24 → abstract_solana-0.0.0.25}/PKG-INFO +1 -1
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/setup.py +1 -1
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/constants.py +1 -1
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana.egg-info/PKG-INFO +1 -1
- abstract_solana-0.0.0.25/test/test_abstract_solana.py +10 -0
- abstract_solana-0.0.0.24/test/test_abstract_solana.py +0 -186
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/README.md +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/setup.cfg +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/__init__.py +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/account_key_utils.py +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/genesis_functions.py +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/index_utils.py +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/keypair_utils.py +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/log_message_functions.py +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/price_utils.py +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/pubkey_utils.py +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/signature_data_parse.py +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/utils.py +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana.egg-info/SOURCES.txt +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana.egg-info/dependency_links.txt +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana.egg-info/requires.txt +0 -0
- {abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana.egg-info/top_level.txt +0 -0
|
@@ -10,7 +10,7 @@ SOL_MINT_PUBKEY=get_pubkey(SOL_MINT)
|
|
|
10
10
|
|
|
11
11
|
PUMP_FUN_GLOBAL = "4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf"
|
|
12
12
|
PUMP_FUN_GLOBAL_PUBKEY = get_pubkey(PUMP_FUN_GLOBAL)
|
|
13
|
-
|
|
13
|
+
PUMP_FUN_FEE_RECIPIENT = "CebN5WGQ4jvEPvsVU4EoHEpgzq1VV7AbicfhtW4xC9iM"
|
|
14
14
|
PUMP_FUN_FEE_RECIPIENT_PUBKEY = get_pubkey(PUMP_FUN_FEE_RECIPIENT)
|
|
15
15
|
PUMP_FUN_ASSOC_TOKEN_ACC_PROG = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
16
16
|
PUMP_FUN_ASSOC_TOKEN_ACC_PROG_PUBKEY = get_pubkey(PUMP_FUN_ASSOC_TOKEN_ACC_PROG)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from abstract_solana import Pubkey,get_pubkey,Optional,Union,LAMPORTS_PER_SOL,get_any_value
|
|
2
|
+
|
|
3
|
+
from abstract_solcatcher import *
|
|
4
|
+
#type: ignore
|
|
5
|
+
mint_str = "3bb6QmvustnZ627Kg2QvwTSi8gmxp7Y6orwXUokEwUyV"
|
|
6
|
+
result = pump_fun_sell(mint_str=mint_str, token_balance=None, slippage=25)
|
|
7
|
+
# Example usage
|
|
8
|
+
input(result)
|
|
9
|
+
|
|
10
|
+
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
from abstract_solana import Pubkey,get_pubkey,Optional,Union,LAMPORTS_PER_SOL,get_any_value
|
|
2
|
-
from abstract_solana.pumpFunKeys import get_pump_fun_data
|
|
3
|
-
from abstract_solcatcher import *
|
|
4
|
-
from abstract_security import *
|
|
5
|
-
import struct
|
|
6
|
-
import base58,time
|
|
7
|
-
from solders.hash import Hash
|
|
8
|
-
from solders.instruction import Instruction
|
|
9
|
-
from solders.compute_budget import set_compute_unit_limit, set_compute_unit_price #type: ignore
|
|
10
|
-
from solana.rpc.types import TokenAccountOpts,TxOpts
|
|
11
|
-
from solders.keypair import Keypair
|
|
12
|
-
from solana.transaction import AccountMeta, Transaction
|
|
13
|
-
from construct import Padding, Struct, Int64ul, Flag
|
|
14
|
-
LAMPORTS_PER_SOL = 1_000_000_000
|
|
15
|
-
UNIT_PRICE = 1_000_000
|
|
16
|
-
UNIT_BUDGET = 100_000
|
|
17
|
-
def sendTransaction(txn: Transaction, payer_keypair, opts=TxOpts(skip_preflight=True)) -> dict:
|
|
18
|
-
# Sign the transaction
|
|
19
|
-
txn.sign(payer_keypair)
|
|
20
|
-
|
|
21
|
-
# Serialize the transaction to a base64 string
|
|
22
|
-
txn_base64 = base58.b58encode(txn.serialize()).decode('utf-8')
|
|
23
|
-
|
|
24
|
-
# Prepare the RPC request payload
|
|
25
|
-
payload = {
|
|
26
|
-
"jsonrpc": "2.0",
|
|
27
|
-
"id": 1,
|
|
28
|
-
"method": "sendTransaction",
|
|
29
|
-
"params": [txn_base64, {"skipPreflight": opts.skip_preflight, "preflightCommitment": "finalized"}]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
# Send the transaction
|
|
33
|
-
response = requests.post(
|
|
34
|
-
url="https://rpc.ankr.com/solana/c3b7fd92e298d5682b6ef095eaa4e92160989a713f5ee9ac2693b4da8ff5a370",
|
|
35
|
-
json=payload
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
# Parse the JSON response
|
|
39
|
-
response_json = response.json()
|
|
40
|
-
|
|
41
|
-
# Return the result or the entire response in case of error
|
|
42
|
-
return response_json.get('result', response_json)
|
|
43
|
-
def load_from_private_key(env_key='AMM_P'):
|
|
44
|
-
env_value = get_env_value(key=env_key)
|
|
45
|
-
if env_value:
|
|
46
|
-
return Keypair.from_base58_string(env_value)
|
|
47
|
-
|
|
48
|
-
def load_keypair_from_file(filename):
|
|
49
|
-
curr = os.path.join(sys.path[0], 'data', filename)
|
|
50
|
-
with open(curr, 'r') as file:
|
|
51
|
-
secret = json.load(file)
|
|
52
|
-
secret_key = bytes(secret)
|
|
53
|
-
print(base58.b58encode(secret_key))
|
|
54
|
-
return Keypair.from_bytete_key()
|
|
55
|
-
payer_keypair = load_from_private_key()
|
|
56
|
-
payer_pubkey = str(payer_keypair.pubkey())
|
|
57
|
-
owner=Pubkey.from_string(payer_pubkey)
|
|
58
|
-
def get_token_balance(payer,mint_str: str):
|
|
59
|
-
|
|
60
|
-
response = getTokenAccountBalance(str(payer),str(mint_str))
|
|
61
|
-
response=response.get('value',response)
|
|
62
|
-
ui_amount = get_any_value(response, "uiAmount") or 0
|
|
63
|
-
return float(ui_amount)
|
|
64
|
-
def check_existing_token_account(owner: Pubkey, mint: Pubkey):
|
|
65
|
-
try:
|
|
66
|
-
account_data = get_account_by_owner(str(owner), str(mint))
|
|
67
|
-
if account_data:
|
|
68
|
-
token_account = account_data['pubkey']
|
|
69
|
-
print(f"Existing token account found: {token_account}")
|
|
70
|
-
return token_account, None
|
|
71
|
-
else:
|
|
72
|
-
print("No existing token account found. Creating a new one...")
|
|
73
|
-
token_account = get_associated_token_address(owner, mint)
|
|
74
|
-
token_account_instructions = create_associated_token_account(owner, owner, mint)
|
|
75
|
-
return token_account, token_account_instructions
|
|
76
|
-
except Exception as e:
|
|
77
|
-
print(f"Error checking or creating token account: {e}")
|
|
78
|
-
return None, None
|
|
79
|
-
def confirm_txn(txn_sig, max_retries=20, retry_interval=3):
|
|
80
|
-
retries = 0
|
|
81
|
-
|
|
82
|
-
while retries < max_retries:
|
|
83
|
-
try:
|
|
84
|
-
|
|
85
|
-
txn_res = get_transaction(signature=str(txn_sig))
|
|
86
|
-
if txn_res:
|
|
87
|
-
print(txn_res)
|
|
88
|
-
print(f"\n\nhttps://solscan.io/tx/{str(txn_sig)}")
|
|
89
|
-
break
|
|
90
|
-
txn_json = safe_json_loads(txn_res.get('transaction',{}).get('meta',{}))
|
|
91
|
-
error = txn_json.get('err')
|
|
92
|
-
if error is None:
|
|
93
|
-
print("Transaction confirmed... try count:", retries+1)
|
|
94
|
-
return True
|
|
95
|
-
print("Error: Transaction not confirmed. Retrying...")
|
|
96
|
-
if error:
|
|
97
|
-
print("Transaction failed.")
|
|
98
|
-
return False
|
|
99
|
-
except Exception as e:
|
|
100
|
-
print("Awaiting confirmation... try count:", retries+1)
|
|
101
|
-
retries += 1
|
|
102
|
-
time.sleep(retry_interval)
|
|
103
|
-
print("Max retries reached. Transaction confirmation failed.")
|
|
104
|
-
return None
|
|
105
|
-
|
|
106
|
-
def get_coin_data(mint_str):
|
|
107
|
-
return get_pump_fun_data(str(mint_str))
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def buildTxn(mint, amount, slippage, token_account_pubkey,sol_in=0,token_price=None,token_balance=None,token_account_instructions=None,close_token_account=False,buy=True):
|
|
112
|
-
# Get keys for the transaction, pass the token account's pubkey instead of the AccountMeta object
|
|
113
|
-
keys = getKeys(get_coin_data(mint), token_account_pubkey, owner,buy=buy)
|
|
114
|
-
|
|
115
|
-
if buy:
|
|
116
|
-
# Calculate max_sol_cost
|
|
117
|
-
slippage_adjustment = 1 + (slippage / 100)
|
|
118
|
-
sol_in_with_slippage = sol_in * slippage_adjustment
|
|
119
|
-
max_sol_cost = int(sol_in_with_slippage * LAMPORTS_PER_SOL)
|
|
120
|
-
print("Max Sol Cost:", sol_in_with_slippage)
|
|
121
|
-
hex_data = bytes.fromhex("66063d1201daebea")
|
|
122
|
-
solCost = max_sol_cost
|
|
123
|
-
else:
|
|
124
|
-
# Calculate minimum SOL output
|
|
125
|
-
sol_out = float(token_balance) * float(token_price)
|
|
126
|
-
slippage_adjustment = 1 - (slippage / 100)
|
|
127
|
-
sol_out_with_slippage = sol_out * slippage_adjustment
|
|
128
|
-
min_sol_output = int(sol_out_with_slippage * LAMPORTS_PER_SOL)
|
|
129
|
-
print("Min Sol Output:", sol_out_with_slippage)
|
|
130
|
-
hex_data = bytes.fromhex("33e685a4017f83ad")
|
|
131
|
-
solCost = min_sol_output
|
|
132
|
-
|
|
133
|
-
data = bytearray()
|
|
134
|
-
data.extend(hex_data)
|
|
135
|
-
data.extend(struct.pack('<Q', amount))
|
|
136
|
-
data.extend(struct.pack('<Q', solCost))
|
|
137
|
-
data = bytes(data)
|
|
138
|
-
PUMP_FUN_PROGRAM = Pubkey.from_string("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P")
|
|
139
|
-
|
|
140
|
-
swap_instruction = Instruction(PUMP_FUN_PROGRAM, data, keys)
|
|
141
|
-
blockHash = requests.post(url="https://rpc.ankr.com/solana/c3b7fd92e298d5682b6ef095eaa4e92160989a713f5ee9ac2693b4da8ff5a370",data=json.dumps({"id":1,"jsonrpc":"2.0","method":"getLatestBlockhash","params":[{"commitment":"processed"}]}))
|
|
142
|
-
recent_blockhash = get_any_value(blockHash.json(),'blockhash')
|
|
143
|
-
recent_blockhash = Hash.from_string(recent_blockhash)
|
|
144
|
-
txn = Transaction(recent_blockhash=recent_blockhash, fee_payer=owner)
|
|
145
|
-
txn.add(set_compute_unit_price(UNIT_PRICE))
|
|
146
|
-
txn.add(set_compute_unit_limit(UNIT_BUDGET))
|
|
147
|
-
|
|
148
|
-
if buy:
|
|
149
|
-
if token_account_instructions:
|
|
150
|
-
txn.add(token_account_instructions)
|
|
151
|
-
txn.add(swap_instruction)
|
|
152
|
-
else:
|
|
153
|
-
txn.add(swap_instruction)
|
|
154
|
-
if close_token_account:
|
|
155
|
-
close_account_instructions = close_account(CloseAccountParams(PUMP_FUN_PROGRAM_PUBKEY, token_account_pubkey, owner, owner))
|
|
156
|
-
txn.add(close_account_instructions)
|
|
157
|
-
|
|
158
|
-
txn.sign(payer_keypair)
|
|
159
|
-
# Send and confirm transaction
|
|
160
|
-
txn_sig = sendTransaction(txn, payer_keypair, TxOpts(skip_preflight=True))
|
|
161
|
-
print("Transaction Signature", txn_sig)
|
|
162
|
-
confirm = confirm_txn(txn_sig)
|
|
163
|
-
print(confirm)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
def isListZero(obj):
|
|
171
|
-
if obj and isinstance(obj, list):
|
|
172
|
-
return obj[0]
|
|
173
|
-
return obj
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
mint_str = "3bb6QmvustnZ627Kg2QvwTSi8gmxp7Y6orwXUokEwUyV"
|
|
182
|
-
result = pump_fun_sell(mint_str=mint_str, token_balance=None, slippage=25)
|
|
183
|
-
# Example usage
|
|
184
|
-
input(result)
|
|
185
|
-
|
|
186
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/account_key_utils.py
RENAMED
|
File without changes
|
{abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/genesis_functions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/log_message_functions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana/signature_data_parse.py
RENAMED
|
File without changes
|
|
File without changes
|
{abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana.egg-info/requires.txt
RENAMED
|
File without changes
|
{abstract_solana-0.0.0.24 → abstract_solana-0.0.0.25}/src/abstract_solana.egg-info/top_level.txt
RENAMED
|
File without changes
|