Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use decimal places with token values on the home page #74

Merged
merged 4 commits into from
Jun 6, 2024

Conversation

rabi-siddique
Copy link
Contributor

No description provided.

Copy link

cloudflare-workers-and-pages bot commented Jun 5, 2024

Deploying agoric-inter-dashboard with  Cloudflare Pages  Cloudflare Pages

Latest commit: 90369ec
Status: ✅  Deploy successful!
Preview URL: https://4494ec7a.agoric-inter-dashboard.pages.dev
Branch Preview URL: https://rs-decimal-places-homepage.agoric-inter-dashboard.pages.dev

View logs

Copy link

github-actions bot commented Jun 5, 2024

Cloudflare deployment logs are available here

@rabi-siddique rabi-siddique force-pushed the rs-decimal-places-homepage branch from 698ca68 to bf27078 Compare June 5, 2024 10:24
@rabi-siddique rabi-siddique changed the title chore: use decimal places with token values chore: use decimal places with token values on the home page Jun 5, 2024
@rabi-siddique rabi-siddique requested a review from frazarshad June 5, 2024 10:31
src/pages/InterProtocol.tsx Outdated Show resolved Hide resolved
Comment on lines +123 to +124
((Number(node_?.value) / tokenDivisor) * Number(oraclePrices[node_?.denom]?.typeOutAmount || tokenDivisor)) /
tokenDivisor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
((Number(node_?.value) / tokenDivisor) * Number(oraclePrices[node_?.denom]?.typeOutAmount || tokenDivisor)) /
tokenDivisor;
((Number(node_?.value) / tokenDivisor) * Number(oraclePrices[node_?.denom]?.typeOutAmount || 0)) /
Number(oraclePrices[node_?.denom]?.typeInAmount;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This results in incorrect value for Total Reserve Assets

Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably use Number(oraclePrices[node_?.denom]?.typeInAmount instead of the deafault of 0 then

Copy link
Contributor Author

@rabi-siddique rabi-siddique Jun 6, 2024

Choose a reason for hiding this comment

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

we should probably use Number(oraclePrices[node_?.denom]?.typeInAmount

I reckon you are implying typeOutAmount?

Copy link
Contributor

Choose a reason for hiding this comment

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

no typeInAmount

the goal is to divide typeInAmount by typeInAmount to create a value of 1

Copy link
Contributor

Choose a reason for hiding this comment

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

but i think if typeOutAmount is not present, then typeInAmount wont also be present. lets do this instead:

Number(oraclePrices[node_?.denom]?.typeOutAmount || 1)) /
          Number(oraclePrices[node_?.denom]?.typeInAmount || 1);

dashboardResponse.reserveMetrics.nodes.reduce((agg, node) => agg + Number(node.shortfallBalance), 0) / 1_000_000;
const totalLockedCollateral = dashboardResponse.vaultManagerMetrics.nodes.reduce((agg, node) => {
dashboardResponse?.reserveMetrics?.nodes?.reduce((agg, node) => agg + Number(node?.shortfallBalance), 0) /
istTokenDivisor;
Copy link
Contributor

Choose a reason for hiding this comment

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

probably shouldnt be divided by the istTokenDivisor but rather the token divisior of each node

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you sure? It results in different values compared to production

Copy link
Contributor

Choose a reason for hiding this comment

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

not 100%. my logic is that this value represent reserve data. when we calculate totalReserve above, which also represents reserve data, we also use token divisor rather than ist divisor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am confused too:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor

Choose a reason for hiding this comment

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

i guess then istdivisor is fine

src/pages/InterProtocol.tsx Outdated Show resolved Hide resolved
@rabi-siddique rabi-siddique force-pushed the rs-decimal-places-homepage branch from 7c7fbf1 to 37e1e57 Compare June 5, 2024 12:39
Number(oraclePrices[node.liquidatingCollateralBrand]?.typeOutAmount) || 0) / 1_000_000;
((Number(node?.totalCollateral) / tokenDivisor) *
Number(oraclePrices[node?.liquidatingCollateralBrand]?.typeOutAmount) || 0) /
Number(oraclePrices[node?.liquidatingCollateralBrand]?.typeInAmount || 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

dont use default value here. 0 will result in a divide by zero error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't that be fine? 0/0 will be NaN..........would be easier to point anomalies from the dashboard UI.
If we omit the 0 default, it will still be a NaN(0/undefined and undefined/undefined)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing the defaults. It's going to yield a NaN regardless.

Copy link
Contributor

Choose a reason for hiding this comment

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

true. i thought it might throw an Error.

@rabi-siddique rabi-siddique force-pushed the rs-decimal-places-homepage branch from 37e1e57 to f42d015 Compare June 6, 2024 09:20
@rabi-siddique rabi-siddique force-pushed the rs-decimal-places-homepage branch from 6380e0f to 81b1a32 Compare June 6, 2024 09:49
@rabi-siddique rabi-siddique requested a review from frazarshad June 6, 2024 09:57
@rabi-siddique rabi-siddique merged commit 1d18434 into master Jun 6, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants