Merge pull request #18 from ricardojmendez/skip-min-equity

Passing on accounts without a minimum of equity
This commit is contained in:
Riordan Panayides 2022-02-23 10:17:59 +00:00 committed by GitHub
commit 2a189ac952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -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,