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,
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue