Skip to content

Commit

Permalink
post liquidation data as embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
ewansheldon committed Jun 26, 2024
1 parent 63c480d commit 01aebaa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/liquidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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);
});
};

Expand Down

0 comments on commit 01aebaa

Please sign in to comment.