Add mango auto approve support (#148)

This commit is contained in:
Maximilian Schneider 2021-03-17 03:18:54 +01:00 committed by GitHub
parent 61b17cbe6c
commit eb02fc3130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -430,6 +430,8 @@ function isSafeInstruction(publicKeys, owner, txInstructions) {
} else {
if (instruction.type === 'raydium') {
// Whitelist raydium for now.
} else if (instruction.type === 'mango') {
// Whitelist mango for now.
} else if (
['cancelOrder', 'matchOrders', 'cancelOrderV3'].includes(
instruction.type,

View File

@ -23,6 +23,10 @@ const RAYDIUM_LP_PROGRAM_ID = new PublicKey(
'RVKd61ztZW9GUwhRbbLoYVRE5Xf1B2tVscKqwZqXgEr',
);
const MANGO_PROGRAM_ID = new PublicKey(
'JD3bq9hGdy38PuWQ4h2YJpELmHVGPPfFSuFkpzAd9zfu',
);
const marketCache = {};
let marketCacheConnection = null;
const cacheDuration = 15 * 1000;
@ -129,6 +133,15 @@ const toInstruction = async (
accountKeys,
decodedInstruction,
);
} else if (programId.equals(MANGO_PROGRAM_ID)) {
console.log('[' + index + '] Handled as mango markets instruction');
let decodedInstruction = decodeMangoInstruction(decoded);
return await handleMangoInstruction(
connection,
instruction,
accountKeys,
decodedInstruction,
);
} else {
return {
type: 'Unknown',
@ -147,6 +160,18 @@ const toInstruction = async (
return;
};
const handleMangoInstruction = async (
connection,
instruction,
accountKeys,
decodedInstruction,
) => {
// TODO
return {
type: 'mango',
};
};
const handleRayStakeInstruction = async (
connection,
instruction,
@ -171,6 +196,11 @@ const handleRayLpInstruction = async (
};
};
const decodeMangoInstruction = () => {
// TODO
return undefined;
};
const decodeStakeInstruction = () => {
// TODO
return undefined;