revert ma/health checks

This commit is contained in:
saml33 2022-04-13 13:35:28 +10:00
parent 8b6383f149
commit 3464953256
1 changed files with 18 additions and 20 deletions

View File

@ -253,27 +253,25 @@ const handleAlert = async (alert: any, db: any) => {
mangoAccountPk, mangoAccountPk,
mangoGroup.dexProgramId mangoGroup.dexProgramId
) )
if (mangoAccount) { const walletPublicKey = mangoAccount.owner.toBase58()
const walletPublicKey = mangoAccount.owner.toBase58() const health = await mangoAccount.getHealthRatio(
const health = await mangoAccount.getHealthRatio( mangoGroup,
mangoGroup, mangoCache,
mangoCache, "Maint"
"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)) { if (alertSent) {
let message = MESSAGE.replace("@ratio@", alert.health) db.collection("alerts").deleteOne({ _id: alert._id })
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 })
}
} }
} }
} catch (e) { } catch (e) {