Add mango auto approve support (#148)
This commit is contained in:
parent
61b17cbe6c
commit
eb02fc3130
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue