fix liquidation price

This commit is contained in:
mstfash 2021-08-31 17:23:00 +02:00
parent 4f2ea1cb68
commit c35ef57561

View File

@ -25,6 +25,8 @@ const defaultSafe = {
netvalue: "0" netvalue: "0"
}; };
const oracleRelayerAddress = "0x4ed9C0dCa0479bC64d8f4EB3007126D5791f7851";
const safeId = ref(null); const safeId = ref(null);
const safes = ref([]); const safes = ref([]);
const isNewSafe = ref(false); const isNewSafe = ref(false);
@ -202,6 +204,10 @@ async function getSafeTypes(web3) {
.getColInfo(reflexerSafes.types) .getColInfo(reflexerSafes.types)
.call(); .call();
const rawRedemptionPrice = await web3.eth.getStorageAt(
oracleRelayerAddress,
4
);
return reflexerSafes.allSafes.map( return reflexerSafes.allSafes.map(
({ type, token, key: tokenKey, disabled, safeTokenType }, i) => { ({ type, token, key: tokenKey, disabled, safeTokenType }, i) => {
const [rate, price, ratioCbyD, debtCeiling, totalDebt] = rawData[i]; const [rate, price, ratioCbyD, debtCeiling, totalDebt] = rawData[i];
@ -213,7 +219,13 @@ async function getSafeTypes(web3) {
disabled, disabled,
safeTokenType, safeTokenType,
rate: calRate(rate), rate: calRate(rate),
price: new BigNumber(price).dividedBy(1e27).toFixed(), redemptionPrice: new BigNumber(rawRedemptionPrice)
.dividedBy(1e27)
.toFixed(),
price: new BigNumber(price)
.times(rawRedemptionPrice)
.dividedBy(1e54)
.toFixed(),
liquidation: new BigNumber(1) liquidation: new BigNumber(1)
.dividedBy(new BigNumber(ratioCbyD).dividedBy(1e27)) .dividedBy(new BigNumber(ratioCbyD).dividedBy(1e27))
.toFixed(), .toFixed(),