fix: align learning examples with refactored modules

This commit is contained in:
smypmsa
2025-03-19 16:01:46 +00:00
parent e6236a9a86
commit ca91c879c3
14 changed files with 141 additions and 84 deletions
@@ -4,7 +4,8 @@ import sys
from solders.pubkey import Pubkey
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from config import PUMP_PROGRAM
from core.pubkeys import PumpAddresses, SystemAddresses
def get_bonding_curve_address(mint: Pubkey, program_id: Pubkey) -> tuple[Pubkey, int]:
@@ -19,16 +20,14 @@ def find_associated_bonding_curve(mint: Pubkey, bonding_curve: Pubkey) -> Pubkey
Find the associated bonding curve for a given mint and bonding curve.
This uses the standard ATA derivation.
"""
from config import SYSTEM_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM as ATA_PROGRAM_ID
from config import SYSTEM_TOKEN_PROGRAM as TOKEN_PROGRAM_ID
derived_address, _ = Pubkey.find_program_address(
[
bytes(bonding_curve),
bytes(TOKEN_PROGRAM_ID),
bytes(SystemAddresses.TOKEN_PROGRAM),
bytes(mint),
],
ATA_PROGRAM_ID,
SystemAddresses.ASSOCIATED_TOKEN_PROGRAM,
)
return derived_address
@@ -39,7 +38,9 @@ def main():
try:
mint = Pubkey.from_string(mint_address)
bonding_curve_address, bump = get_bonding_curve_address(mint, PUMP_PROGRAM)
bonding_curve_address, bump = get_bonding_curve_address(
mint, PumpAddresses.PROGRAM
)
# Calculate the associated bonding curve
associated_bonding_curve = find_associated_bonding_curve(