Add mintable filter

Check if owner can mint tokens
This commit is contained in:
n0xy
2024-02-20 15:17:38 -03:00
committed by GitHub
parent 660415519f
commit 7cea6c4803

28
buy.ts
View File

@ -199,12 +199,39 @@ export async function processRaydiumPool(
return;
}
const mintable = await checkMintable(poolState.baseMint)
if(mintable) {
console.log('Mintable check passed, proceding with buy');
await buy(id, poolState);
} else {
console.log('Skipping, owner can mint tokens!')
}
} catch (e) {
logger.error({ ...poolState, error: e }, `Failed to process pool`);
}
}
export async function checkMintable(vault: PublicKey) {
try {
let { data } = (await solanaConnection.getAccountInfo(vault)) || {};
if (!data) {
return;
}
// Deserialize Data.
const deserialize = MintLayout.decode(data)
const mintoption = deserialize.mintAuthorityOption
if (mintoption === 0) {
return true;
} else {
return false;
}
} catch {
return null;
}
}
export async function processOpenBookMarket(
updatedAccountInfo: KeyedAccountInfo,
) {
@ -291,6 +318,7 @@ async function buy(
{
mint: accountData.baseMint,
url: `https://solscan.io/tx/${signature}?cluster=${network}`,
dexURL: `https://dexscreener.com/solana/${accountData.baseMint}?maker=${wallet.publicKey}`
},
'Buy',
);