Skip to content

feat(target_chains/ethereum/sdk/solidity): add convertToUint method to the sdk #1390

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

Merged
merged 8 commits into from
Mar 28, 2024

Conversation

aditya520
Copy link
Member

No description provided.

Copy link

vercel bot commented Mar 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
example-oracle-amm ⬜️ Ignored (Inspect) Visit Preview Mar 28, 2024 9:17pm
xc-admin-frontend ⬜️ Ignored (Inspect) Visit Preview Mar 28, 2024 9:17pm

@ali-behjati ali-behjati changed the title Moving convertToUint to utils feat(target_chains/ethereum/sdk/js): add convertToUint method to the sdk Mar 27, 2024
@ali-behjati ali-behjati changed the title feat(target_chains/ethereum/sdk/js): add convertToUint method to the sdk feat(target_chains/ethereum/sdk/solidity): add convertToUint method to the sdk Mar 27, 2024
Copy link
Contributor

@jayantk jayantk left a comment

Choose a reason for hiding this comment

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

thank you for moving this.

Before I approve this, can you please add some tests for this logic ? If we are providing utilities for users to import, then we need to subject them to the same rigorous standards as other on-chain code we provide for them. You can make a new test file here https://github.com/pyth-network/pyth-crosschain/tree/main/target_chains/ethereum/contracts/forge-test

pragma solidity ^0.8.0;

library PythUtils {
/// @notice Converts a Pyth price to a uint256 with a target number of decimals
Copy link
Contributor

Choose a reason for hiding this comment

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

can you give an example here to clarify what this means (use ethereum and 18 decimals)

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also note that this function can lose precision and you need to be careful about that? For example, if the price is 0.003 and you set targetdecimals to 2, then the result will be 0.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the tests PythTestUtils.t.sol

Copy link
Collaborator

@ali-behjati ali-behjati left a comment

Choose a reason for hiding this comment

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

Can you please run the npm run generate-abi to add the ABI files as well?

@aditya520 aditya520 force-pushed the feat(pridefeed-evm-sdk)-Create-utils branch from e310c50 to f52c14c Compare March 28, 2024 16:25
@aditya520 aditya520 force-pushed the feat(pridefeed-evm-sdk)-Create-utils branch from f52c14c to 1b41cde Compare March 28, 2024 16:31
@aditya520 aditya520 force-pushed the feat(pridefeed-evm-sdk)-Create-utils branch from fab9ada to 72f3f56 Compare March 28, 2024 21:17
@aditya520 aditya520 merged commit 77db9ee into main Mar 28, 2024
@aditya520 aditya520 deleted the feat(pridefeed-evm-sdk)-Create-utils branch March 28, 2024 21:23
aditya520 added a commit that referenced this pull request Mar 31, 2024
…o the sdk (#1390)

* Moving convertToUint to utils

* pre-commit fix

* reversing OracleSwap example

* pre-commit]

* added test

* abi-gen

* Added solc to sdk

* resolved comments
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.

3 participants