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