Closed labyla closed 1 month ago
hey @labyla here you can find how we derive the curve account for token https://github.com/wen-moon-ser/moonshot-sdk/blob/main/src/solana/utils/getCurveAccount.ts
import { PublicKey } from '@solana/web3.js';
import { TokenLaunchpadIdl } from '../program';
import { CurveAccount } from '../../domain';
import { convertBNtoBigInt } from './convertBNToBigInt';
import { convertContractEnums } from './convertContractCurrency';
import { BaseAnchorProvider } from '../provider';
export async function getCurveAccount(
provider: BaseAnchorProvider<TokenLaunchpadIdl>,
mintAddress: string,
): Promise<CurveAccount> {
const [curveAccountKey] = PublicKey.findProgramAddressSync(
[Buffer.from('token'), new PublicKey(mintAddress).toBytes()],
provider.program.programId,
);
const curveAccount = await provider.program.account.curveAccount.fetch(
curveAccountKey,
provider.commitment,
);
if (curveAccount == null) {
throw new Error('Curve account data not found');
}
const account = convertBNtoBigInt(curveAccount) as CurveAccount;
return convertContractEnums(account);
}
Feel free to re-open it in case you still have questions
Okay. Thanks a lot ♥
Hello! I can't understand how you find seeds for accounts (for example seeds for curve account: "token" & mint address). Could you please explain it to me? I would be very grateful.