From c35ef575614e30128f46a51ae15b79211f95dc5f Mon Sep 17 00:00:00 2001 From: mstfash Date: Tue, 31 Aug 2021 17:23:00 +0200 Subject: [PATCH 1/2] fix liquidation price --- composables/protocols/useReflexerPosition.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/composables/protocols/useReflexerPosition.ts b/composables/protocols/useReflexerPosition.ts index 61479e5..59e2c10 100644 --- a/composables/protocols/useReflexerPosition.ts +++ b/composables/protocols/useReflexerPosition.ts @@ -25,6 +25,8 @@ const defaultSafe = { netvalue: "0" }; +const oracleRelayerAddress = "0x4ed9C0dCa0479bC64d8f4EB3007126D5791f7851"; + const safeId = ref(null); const safes = ref([]); const isNewSafe = ref(false); @@ -202,6 +204,10 @@ async function getSafeTypes(web3) { .getColInfo(reflexerSafes.types) .call(); + const rawRedemptionPrice = await web3.eth.getStorageAt( + oracleRelayerAddress, + 4 + ); return reflexerSafes.allSafes.map( ({ type, token, key: tokenKey, disabled, safeTokenType }, i) => { const [rate, price, ratioCbyD, debtCeiling, totalDebt] = rawData[i]; @@ -213,7 +219,13 @@ async function getSafeTypes(web3) { disabled, safeTokenType, 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) .dividedBy(new BigNumber(ratioCbyD).dividedBy(1e27)) .toFixed(), From 7801ec17512d6ea7a186e73d2e0a964ee0786a3e Mon Sep 17 00:00:00 2001 From: mstfash Date: Tue, 31 Aug 2021 19:25:22 +0200 Subject: [PATCH 2/2] adding a fix for safe liquidation price --- composables/protocols/useReflexerPosition.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composables/protocols/useReflexerPosition.ts b/composables/protocols/useReflexerPosition.ts index 59e2c10..37e824c 100644 --- a/composables/protocols/useReflexerPosition.ts +++ b/composables/protocols/useReflexerPosition.ts @@ -256,6 +256,10 @@ async function getSafes(user, web3) { .getSafes(user) .call(); + const rawRedemptionPrice = await web3.eth.getStorageAt( + oracleRelayerAddress, + 4 + ); return rawData.map( ([ id, @@ -272,7 +276,9 @@ async function getSafes(user, web3) { ]) => { const collateral = new BigNumber(collInWei).dividedBy(1e18); const debt = new BigNumber(debtInWei).dividedBy(1e18); - const price = new BigNumber(priceInWei).dividedBy(1e27); + const price = new BigNumber(priceInWei) + .times(rawRedemptionPrice) + .dividedBy(1e54); const safe = reflexerSafes.getSafeByType(type);