From 3464953256a5a170dca391fc1a9efb8e96984f8e Mon Sep 17 00:00:00 2001 From: saml33 Date: Wed, 13 Apr 2022 13:35:28 +1000 Subject: [PATCH] revert ma/health checks --- src/index.ts | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/index.ts b/src/index.ts index cac3859..ae6213e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -253,27 +253,25 @@ const handleAlert = async (alert: any, db: any) => { mangoAccountPk, mangoGroup.dexProgramId ) - if (mangoAccount) { - const walletPublicKey = mangoAccount.owner.toBase58() - const health = await mangoAccount.getHealthRatio( - mangoGroup, - mangoCache, - "Maint" + const walletPublicKey = mangoAccount.owner.toBase58() + const health = await mangoAccount.getHealthRatio( + mangoGroup, + mangoCache, + "Maint" + ) + if (health.toNumber() <= parseFloat(alert.health)) { + let message = MESSAGE.replace("@ratio@", alert.health) + message += + "Deposit more collateral or reduce your liabilities to improve your account health. \n" + message += `View your account: https://trade.mango.markets/account?pubkey=${alert.mangoAccountPk}` + const alertSent = await sendAlert( + alert, + message, + Number(health), + walletPublicKey ) - if (health && health.toNumber() <= parseFloat(alert.health)) { - let message = MESSAGE.replace("@ratio@", alert.health) - message += - "Deposit more collateral or reduce your liabilities to improve your account health. \n" - message += `View your account: https://trade.mango.markets/account?pubkey=${alert.mangoAccountPk}` - const alertSent = await sendAlert( - alert, - message, - Number(health), - walletPublicKey - ) - if (alertSent) { - db.collection("alerts").deleteOne({ _id: alert._id }) - } + if (alertSent) { + db.collection("alerts").deleteOne({ _id: alert._id }) } } } catch (e) {