Skip to content

Commit

Permalink
update relative price
Browse files Browse the repository at this point in the history
  • Loading branch information
themacexpert committed Jan 24, 2025
1 parent e01b316 commit a1aff3e
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ async function calculateRelativePrice(
const nativeTokenPrice = response.data[NETWORK_IDS[network]].usd;

// Calculate relative price with 18 decimal places
// Formula: (nativeTokenPrice / assetPrice) * 10^18
// Formula: (assetPrice / nativeTokenPrice) * 10^18
// This gives us how many units of the asset we need to equal 1 unit of native token
const relativePrice = (nativeTokenPrice / assetPrice) * Math.pow(10, 18);
const relativePrice = ( assetPrice / nativeTokenPrice ) * Math.pow(10, 18);

// Return as string to preserve precision
return relativePrice.toFixed(0);
Expand Down Expand Up @@ -118,4 +118,4 @@ async function main() {
}
}

main();
main();

0 comments on commit a1aff3e

Please sign in to comment.