From 01aebaadc367820e9a758174186770e2cedc4b18 Mon Sep 17 00:00:00 2001 From: Ewan Sheldon Date: Wed, 26 Jun 2024 11:41:22 +0200 Subject: [PATCH] post liquidation data as embeds --- src/liquidation.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/liquidation.js b/src/liquidation.js index b8c8f0b..b371995 100644 --- a/src/liquidation.js +++ b/src/liquidation.js @@ -12,10 +12,11 @@ const getVaultSupply = async (wallet, manager) => { } }; -const postToDiscord = async content => { +const postToDiscord = async (content, embeds) => { return new Promise((resolve, reject) => { const data = JSON.stringify({ content, + embeds }); const options = { @@ -93,20 +94,22 @@ const scheduleLiquidation = async _ => { const supply = Number((await getVaultSupply(wallet, manager)).toString()); let content = `Liquidator wallet balance: **${liquidatorETHBalance} ETH**, **${liquidatorEUROsBalance} EUROs**\n--------------\n`; + let embeds = []; for (let tokenID = 1; tokenID <= supply; tokenID++) { try { const { minted, totalCollateralValue, vaultAddress } = (await manager.connect(wallet).vaultData(tokenID)).status; if (minted.gt(0)) { const collateralPercentage = totalCollateralValue.mul(100).div(minted); const formattedDebt = ethers.utils.formatEther(minted); - if (collateralPercentage.lt(125)) content += `ID: **${tokenID}**, address: **${vaultAddress}**, debt: **${formattedDebt} EUROs**, collateral: **${collateralPercentage}%**\n`; + const arbiscanURL = `https://arbiscan.io/address/${vaultAddress}`; + if (collateralPercentage.lt(125)) embeds.push({author: {name: `ID: ${tokenID}`, url: arbiscanURL}, title: vaultAddress, description: `debt: ${formattedDebt}, collateral: ${collateralPercentage}%`, url: arbiscanURL}); } } catch (e) { console.log(`vault data error ${tokenID}`); } } - await postToDiscord(content); + await postToDiscord(content, embeds); }); };