Passing on accounts without a minimum of equity
My liquidator was getting stuck on a loop with accounts with 0 equity but that were reported as negative health. This will also help avoiding accounts that you don't consider worth the opportunity cost.
This commit is contained in:
parent
c3d18aa04f
commit
1e1d7c527e
|
@ -65,6 +65,13 @@ const groupIds = config.getGroup(cluster, groupName) ?? (() => { throw new Error
|
|||
const TARGETS = process.env.TARGETS?.replace(/\s+/g,' ').trim().split(' ').map((s) => parseFloat(s))
|
||||
?? [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
|
||||
// Do not liquidate accounts that have less than this much in value
|
||||
const minEquity = parseInt(
|
||||
process.env.MIN_EQUITY || '5',
|
||||
);
|
||||
console.log(`Minimum equity required to bother: ${minEquity}`);
|
||||
|
||||
|
||||
const mangoProgramId = groupIds.mangoProgramId;
|
||||
const mangoGroupKey = groupIds.publicKey;
|
||||
|
||||
|
@ -276,6 +283,13 @@ async function maybeLiquidateAccount(mangoAccount: MangoAccount): Promise<boolea
|
|||
return false;
|
||||
}
|
||||
|
||||
const equity = mangoAccount.computeValue(mangoGroup, cache).toNumber()
|
||||
if (equity < minEquity) {
|
||||
// console.log(`Account ${mangoAccountKeyString} only has ${equity}, PASS`);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const health = mangoAccount.getHealthRatio(mangoGroup, cache, 'Maint');
|
||||
const accountInfoString = mangoAccount.toPrettyString(
|
||||
groupIds,
|
||||
|
|
Loading…
Reference in New Issue