From 1e1d7c527e06b92fc3800131f912f726437a3e80 Mon Sep 17 00:00:00 2001 From: "Ricardo J. Mendez" Date: Sun, 20 Feb 2022 07:23:46 +0100 Subject: [PATCH] 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. --- src/liquidator.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/liquidator.ts b/src/liquidator.ts index 588e05d..0a0ac20 100644 --- a/src/liquidator.ts +++ b/src/liquidator.ts @@ -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