import { Program } from '@coral-xyz/anchor'; import { PublicKey } from '@solana/web3.js'; import { TokenLaunchpadIdl } from '../program'; import { CurveAccount } from '../../domain/model/curve/CurveAccount'; import { convertBNtoBigInt } from './convertBNToBigInt'; import { convertContractCurrency } from './convertContractCurrency'; export async function getCurveAccount( program: Program, mintAddress: string, ): Promise { const [curveAccountKey] = PublicKey.findProgramAddressSync( [Buffer.from('token'), new PublicKey(mintAddress).toBytes()], program.programId, ); const curveAccount = await program.account.curveAccount.fetch(curveAccountKey); if (curveAccount == null) { throw new Error('Curve account data not found'); } const account = convertBNtoBigInt(curveAccount) as CurveAccount; return convertContractCurrency(account); }