abstract-solana 0.0.0.27__py3-none-any.whl → 0.0.0.29__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.

@@ -0,0 +1,129 @@
1
+ from ..pubkey_utils import Pubkey,get_pubkey,derive_bonding_curve,derive_associated_bonding_curve
2
+ from ..log_message_functions import get_for_program_ids_info
3
+ from spl.token.instructions import create_associated_token_account, get_associated_token_address
4
+ from abstract_solcatcher import getGenesisSignature,getTransaction,getAccountInfo
5
+ from construct import Padding, Struct, Int64ul, Flag
6
+ import base64
7
+ from ..constants import (PUMP_FUN_GLOBAL_PUBKEY,
8
+ PUMP_FUN_FEE_RECIPIENT_PUBKEY,
9
+ SYSTEM_PROGRAM_PUBKEY,
10
+ PUMP_FUN_EVENT_AUTHORITY_PUBKEY,
11
+ PUMP_FUN_PROGRAM_PUBKEY,
12
+ TOKEN_PROGRAM_ID_PUBKEY,
13
+ RENT_PUBKEY,
14
+ PUMP_FUN_ASSOC_TOKEN_ACC_PROG_PUBKEY)
15
+
16
+ # Change dictionary keys to lowercase and replace spaces with underscores
17
+ def change_keys_lower(dict_obj):
18
+ new_dict = {}
19
+ for key, value in dict_obj.items():
20
+ new_dict[key.lower().replace(' ', '_')] = value
21
+ return new_dict
22
+
23
+ # Predefined map for different transaction types
24
+ def get_create_map():
25
+ return [
26
+ {'instruction_number': '1', 'instruction_name': 'Mint', 'token_address': 'AkAUSJg1v9xYT3HUxdALH7NsrC6owmwoZuP9MLw8fxTL', 'token_name': '3CAT'},
27
+ {'instruction_number': '2', 'instruction_name': 'Mint Authority', 'token_address': 'TSLvdd1pWpHVjahSpsvCXUbgwsL3JAcvokwaKt1eokM', 'token_name': 'Pump.fun Token Mint Authority'},
28
+ {'instruction_number': '3', 'instruction_name': 'Bonding Curve', 'token_address': '9nhxvNxfSUaJddVco6oa6NodtsCscqCScp6UU1hZkfGm', 'token_name': 'Pump.fun (3CAT) Bonding Curve'},
29
+ {'instruction_number': '4', 'instruction_name': 'Associated Bonding Curve', 'token_address': '889XLp3qvVAHpTYQmhn6cBpYSppV8Gi8E2Rgp9RH2vRy', 'token_name': 'Pump.fun (3CAT) Vault'},
30
+ {'instruction_number': '5', 'instruction_name': 'Global', 'token_address': '4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf', 'token_name': '4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf'},
31
+ {'instruction_number': '6', 'instruction_name': 'Mpl Token Metadata', 'token_address': 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s', 'token_name': 'Metaplex Token Metadata'},
32
+ {'instruction_number': '7', 'instruction_name': 'Metadata', 'token_address': 'CH41RxpjSXHqr1vfLTVYJMsfNs2fBCCWoAE13tPihXh7', 'token_name': 'CH41RxpjSXHqr1vfLTVYJMsfNs2fBCCWoAE13tPihXh7'},
33
+ {'instruction_number': '8', 'instruction_name': 'User', 'token_address': 'Fuy5MvbgzjSok1U8hH6mUY6WnLynzUextDxfEWMiTkn4', 'token_name': 'Fuy5MvbgzjSok1U8hH6mUY6WnLynzUextDxfEWMiTkn4'},
34
+ {'instruction_number': '9', 'instruction_name': 'System Program', 'token_address': '11111111111111111111111111111111', 'token_name': 'System Program'},
35
+ {'instruction_number': '10', 'instruction_name': 'Token Program', 'token_address': 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', 'token_name': 'Token Program'},
36
+ {'instruction_number': '11', 'instruction_name': 'Associated Token Program', 'token_address': 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', 'token_name': 'Associated Token Account Program'},
37
+ {'instruction_number': '12', 'instruction_name': 'Rent', 'token_address': 'SysvarRent111111111111111111111111111111111', 'token_name': 'Rent Program'},
38
+ {'instruction_number': '13', 'instruction_name': 'Event Authority', 'token_address': 'Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1', 'token_name': 'Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1'},
39
+ {'instruction_number': '14', 'instruction_name': 'Program', 'token_address': '6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P', 'token_name': 'Pump.fun'}
40
+ ]
41
+
42
+ # Fetches and organizes transaction types based on provided mint
43
+ def getTxnTypes(mint):
44
+ bonding_curve = str(derive_bonding_curve(mint)[0])
45
+ bonding_curve_signature = getGenesisSignature(address=bonding_curve)
46
+ txn_data = getTransaction(signature=bonding_curve_signature)
47
+ txn_data = get_for_program_ids_info(txn_data)
48
+
49
+ for new_map in get_create_map():
50
+ instructions = txn_data['transaction']['message']['instructions']
51
+ inner_instructions = txn_data['meta']['innerInstructions'][0]['instructions']
52
+ all_instructions = instructions + inner_instructions
53
+
54
+ instruction = [inst for inst in all_instructions if len(inst.get('associatedAccounts', [])) > 13]
55
+
56
+ txn_types = {create_index['instruction_name']: instruction[0]['associatedAccounts'][int(create_index['instruction_number']) - 1] for create_index in get_create_map()}
57
+
58
+ if txn_types:
59
+ txn_types['signature'] = bonding_curve_signature
60
+ break
61
+ return txn_types
62
+
63
+ # Retrieve virtual reserves for a bonding curve using a structured layout
64
+ def get_virtual_reserves(bonding_curve: Pubkey):
65
+ bonding_curve_struct = Struct(
66
+ Padding(8),
67
+ "virtualTokenReserves" / Int64ul,
68
+ "virtualSolReserves" / Int64ul,
69
+ "realTokenReserves" / Int64ul,
70
+ "realSolReserves" / Int64ul,
71
+ "tokenTotalSupply" / Int64ul,
72
+ "complete" / Flag
73
+ )
74
+ account_info = getAccountInfo(account=str(bonding_curve[0]))
75
+
76
+ if not account_info or 'value' not in account_info or 'data' not in account_info['value']:
77
+ print("Failed to retrieve account info.")
78
+ return None
79
+
80
+ data_base64 = account_info['value']['data'][0]
81
+ data = base64.b64decode(data_base64)
82
+ parsed_data = bonding_curve_struct.parse(data)
83
+ return parsed_data
84
+
85
+ # Retrieves comprehensive transaction and reserve data for the mint
86
+ def get_pump_fun_data(mint_str: str):
87
+ txn_types = change_keys_lower(getTxnTypes(mint_str))
88
+ bonding_curve = derive_bonding_curve(mint_str)
89
+ virtual_reserves = get_virtual_reserves(bonding_curve)
90
+ if virtual_reserves is None:
91
+ return None
92
+
93
+ txn_types.update({
94
+ "mint": mint_str,
95
+ "bonding_curve": str(bonding_curve[0]),
96
+ "associated_bonding_curve": str(derive_associated_bonding_curve(mint_str)),
97
+ "virtual_token_reserves": int(virtual_reserves.virtualTokenReserves),
98
+ "virtual_sol_reserves": int(virtual_reserves.virtualSolReserves),
99
+ "token_total_supply": int(virtual_reserves.tokenTotalSupply),
100
+ "complete": bool(virtual_reserves.complete)
101
+ })
102
+
103
+ return txn_types
104
+
105
+ def getKeys(mint_str,token_account,payer_pubkey,buy=True):
106
+ coin_data = get_pump_fun_data(str(mint_str))
107
+ MINT = get_pubkey(mint_str)
108
+ BONDING_CURVE = get_pubkey(coin_data['bonding_curve'])
109
+ ASSOCIATED_BONDING_CURVE = get_pubkey(coin_data['associated_bonding_curve'])
110
+ ASSOCIATED_USER = get_pubkey(token_account)
111
+ USER = get_pubkey(payer_pubkey)
112
+ PUMP_FUN_TOKEN_PROGRAM_SWITCH = TOKEN_PROGRAM_ID_PUBKEY if buy else PUMP_FUN_ASSOC_TOKEN_ACC_PROG_PUBKEY
113
+ PUMP_FUN_RENT_PROGRAM_SWITCH = RENT_PUBKEY if buy else TOKEN_PROGRAM_ID_PUBKEY
114
+ # Build account key list
115
+ keys = [
116
+ AccountMeta(pubkey=PUMP_FUN_GLOBAL_PUBKEY, is_signer=False, is_writable=False),
117
+ AccountMeta(pubkey=PUMP_FUN_FEE_RECIPIENT_PUBKEY, is_signer=False, is_writable=True),
118
+ AccountMeta(pubkey=MINT, is_signer=False, is_writable=False),
119
+ AccountMeta(pubkey=BONDING_CURVE, is_signer=False, is_writable=True),
120
+ AccountMeta(pubkey=ASSOCIATED_BONDING_CURVE, is_signer=False, is_writable=True),
121
+ AccountMeta(pubkey=ASSOCIATED_USER, is_signer=False, is_writable=True),
122
+ AccountMeta(pubkey=USER, is_signer=True, is_writable=True),
123
+ AccountMeta(pubkey=SYSTEM_PROGRAM_PUBKEY, is_signer=False, is_writable=False),
124
+ AccountMeta(pubkey=PUMP_FUN_TOKEN_PROGRAM_SWITCH, is_signer=False, is_writable=False),
125
+ AccountMeta(pubkey=PUMP_FUN_RENT_PROGRAM_SWITCH, is_signer=False, is_writable=False),
126
+ AccountMeta(pubkey=PUMP_FUN_EVENT_AUTHORITY_PUBKEY, is_signer=False, is_writable=False),
127
+ AccountMeta(pubkey=PUMP_FUN_PROGRAM_PUBKEY, is_signer=False, is_writable=False)
128
+ ]
129
+ return keys
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: abstract_solana
3
- Version: 0.0.0.27
3
+ Version: 0.0.0.29
4
4
  Home-page: https://github.com/AbstractEndeavors/abstract_solana
5
5
  Author: putkoff
6
6
  Author-email: partners@abstractendeavors.com
@@ -13,8 +13,9 @@ abstract_solana/utils.py,sha256=RcnGEiZ0aJbcw8ObpjHU3WUFU4Tmy-exCs6qIbEu4_c,444
13
13
  abstract_solana/pumpFun/__init__.py,sha256=BiRxwJd1JWwEft63zqYwZ_Xs6UDp4hjczjzvuwy3sHg,85
14
14
  abstract_solana/pumpFun/buy_sell_pump.py,sha256=6Sdt_c4VjlJV_0mIaUI3Y1GgCcsDlUukeyT1rVpn_nM,7281
15
15
  abstract_solana/pumpFun/pumpFunKeys.py,sha256=yMS_fT-0ESndluVpZ17XdMhpXVtSfhtIG5njy7DJkfI,7961
16
+ abstract_solana/pumpFun/pump_fun_keys.py,sha256=lL7afQx3-PYOHz69rm7Cyr2_tLp0nFXLZAd-7tvztm8,7963
16
17
  abstract_solana/pumpFun/token_utils.py,sha256=oDvY0YVn8vWwSS3yS-tpZVxb3IvqovGPFicxiXg7YHI,2297
17
- abstract_solana-0.0.0.27.dist-info/METADATA,sha256=p2FBE_ecX6JVU10ct_iDtY4bgQRXqudxJTc3iTceVAo,924
18
- abstract_solana-0.0.0.27.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
19
- abstract_solana-0.0.0.27.dist-info/top_level.txt,sha256=SsJYent8eZQ0FU2jmP8wTj7aFZFhNwxxP-5cCTQ2B-o,16
20
- abstract_solana-0.0.0.27.dist-info/RECORD,,
18
+ abstract_solana-0.0.0.29.dist-info/METADATA,sha256=VKLiE-rJvseK9pm840dpoAcwezunhBETYXRrJz2Q31k,924
19
+ abstract_solana-0.0.0.29.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
20
+ abstract_solana-0.0.0.29.dist-info/top_level.txt,sha256=SsJYent8eZQ0FU2jmP8wTj7aFZFhNwxxP-5cCTQ2B-o,16
21
+ abstract_solana-0.0.0.29.dist-info/RECORD,,