Skip to content

Commit

Permalink
updated-price-feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanya-ruby committed Mar 21, 2024
1 parent 5ad6e95 commit 0b42fa6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/routes/protocol.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default function Protocol() {
priceAmount={coinsDetails?.scaledPriceSc} //"0.31152640"
circulatingAmount={coinsDetails?.scaledNumberSc} //"1,345,402.15"
tokenName={`${process.env.REACT_APP_SC_SYMBOL}`}
equivalence={scConverted}
equivalence={`${scConverted} ${process.env.REACT_APP_CHAIN_COIN}`}
/>
<CoinCard
coinIcon="/coin-icon-two.png"
Expand Down
4 changes: 2 additions & 2 deletions src/utils/ethereum.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ export const getCoinDetails = async (
];
} else if (NETWORK_ID === "11155111") {
promiseArray = [
scaledUnscaledPromise(web3Promise(stableCoin, "totalSupply"), scDecimals),
scaledUnscaledPromise(web3Promise(stableCoin, "totalSupply"), BC_DECIMALS),
scaledUnscaledPromise(web3Promise(djed, "scPrice", 0), scDecimals),
scaledUnscaledPromise(web3Promise(reserveCoin, "totalSupply"), rcDecimals),
scaledUnscaledPromise(web3Promise(djed, "R", 0), BC_DECIMALS),
scaledPromise(web3Promise(djed, "rcBuyingPrice", 0), BC_DECIMALS),
scaledPromise(web3Promise(djed, "scPrice", 0), scDecimals) // Example change for ADDRESS_2
scaledPromise(web3Promise(djed, "scPrice", 0), scDecimals)
];
}

Expand Down
7 changes: 1 addition & 6 deletions src/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ export function percentScaledPromise(promise, scaling) {
// currency conversions:
export function calculateBcUsdEquivalent(coinsDetails, amountFloat) {
const adaPerUsd = parseFloat(coinsDetails?.scaledScExchangeRate.replaceAll(",", ""));

const eqPrice = (1e6 * amountFloat) / adaPerUsd;

return decimalScaling(eqPrice.toFixed(0).toString(10), 6);
}

Expand All @@ -117,11 +115,8 @@ export function getBcUsdEquivalent(coinsDetails, amountFloat) {

export function calculateRcUsdEquivalent(coinsDetails, amountFloat) {
const adaPerRc = parseFloat(coinsDetails?.scaledSellPriceRc);

const adaPerUsd = parseFloat(coinsDetails?.scaledScExchangeRate.replaceAll(",", ""));

const eqPrice = (1e6 * amountFloat * adaPerRc) / adaPerUsd;

return decimalScaling(eqPrice.toFixed(0).toString(10), 6);
}
export function getRcUsdEquivalent(coinsDetails, amountFloat) {
Expand All @@ -131,7 +126,7 @@ export function getRcUsdEquivalent(coinsDetails, amountFloat) {
export function getScAdaEquivalent(coinsDetails, amountFloat) {
const adaPerSc = parseFloat(coinsDetails?.scaledPriceSc.replaceAll(",", ""));
const eqPrice = 1e6 * amountFloat * adaPerSc;
return decimalScaling(eqPrice.toFixed(0).toString(10), 6) + " mADA";
return decimalScaling(eqPrice.toFixed(0).toString(10), 6);
}

export function validatePositiveNumber(amountScaled) {
Expand Down

0 comments on commit 0b42fa6

Please sign in to comment.