revert ma/health checks
This commit is contained in:
parent
8b6383f149
commit
3464953256
38
src/index.ts
38
src/index.ts
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue