Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Update Liquidation #4

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Conversation

dissimilllate
Copy link
Contributor

No description provided.

@dissimilllate dissimilllate changed the title feat: show liquidator profit in usd Update Liquidation Jul 5, 2023
@@ -126,9 +131,32 @@ async function main() {
console.log(`Borrower balance in XCN after liquidation: ${formatNumber(summary.after.borrowerXcnBalance / 1e18)}`);
console.log(`Borrower balance locked for supply in XCN: ${formatNumber(summary.after.borrowerXcnLockedForSupply / 1e18)}`);

const liquidatorProfit = (summary.after.xcnLockedForSupply - amountToRepay) / 1e18;
const protocolSeizeShareMantissa = await oXCN.protocolSeizeShareMantissa() / 1e16;
const protocolSeizeShareCoefficient = await oXCN.protocolSeizeShareMantissa() / 1e18;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using additional variable to keep formulas simple, because:
protocolSeizeShareMantissa = await oXCN.protocolSeizeShareMantissa() / 1e16; // 2.8, whilst we need 0.028 for calculations

In javascript:
2.8 / 1e2 = 0.027999999999999997


// The percent, ranging from 0% to 100%, of a liquidatable account's borrow that can be repaid in a single liquidate transaction.
// https://docs.onyx.org/comptroller/close-factor
const closeFactorPercentage = (await Comptroller.callStatic.closeFactorMantissa() / 1e16)
const liquidationIncentiveMantissa = (await Comptroller.callStatic.liquidationIncentiveMantissa() / 1e16);
const liquidationIncentiveCoefficient = (await Comptroller.callStatic.liquidationIncentiveMantissa() / 1e18);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using additional variable to keep formulas simple, because:
liquidationIncentiveCoefficient = (await Comptroller.callStatic.liquidationIncentiveMantissa() / 1e16); // 110, whilst we need 1.1 for calculations

In javascript:
1.1 / 1e2 = 0.011000000000000001

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants