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

Create cow repository for USD estimation based on native price (+tests) #56

Merged
merged 13 commits into from
Jul 22, 2024

Conversation

anxolin
Copy link
Contributor

@anxolin anxolin commented Jul 16, 2024

This PR will calculate the USD price for any token by using native price endpoint of CoW API

This PR includes the implementation of the logic (basically gets native price of USDC and the token and compare it to each other)

The tests asserts that it works for some representative case: WETH (because it has 18 decimals, and USDC has 6, so we make sure it takes decimals into account.

It will test 404 case when you pass something is not a token. --> will return null

It will test 400 case

  • Will test for example when the tokens are not supported --> we return null
  • Other 400 errors will be throwing (I tested this too). It will try to use the description and error type returned by the backend

It will also test that any other error that is not a 200, then it will throw --> tests the 418 I'm not a teapot code

image

Extra

This PR also includes

  • Improves the setup of IoC (now all apps and libs will set it up as part of the jest config). They will all use a shared setup script
  • Adds 50% error tolerance for the coingecko integration test (it was failing at some point)

Copy link

socket-security bot commented Jul 16, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@types/[email protected] None 0 1.74 kB types
npm/[email protected] None 0 351 kB mikemcl

View full report↗︎

@anxolin anxolin changed the title Create cow API USD estimation Create cow repository for USD estimation based on native price (+tests) Jul 17, 2024
@anxolin anxolin requested a review from a team July 17, 2024 18:16
@anxolin anxolin marked this pull request as ready for review July 17, 2024 18:16
libs/repositories/src/const.ts Outdated Show resolved Hide resolved
libs/repositories/src/cowApi.ts Show resolved Hide resolved
libs/repositories/src/utils/fetch.ts Outdated Show resolved Hide resolved
@anxolin anxolin requested a review from alfetopito July 18, 2024 10:51
@anxolin anxolin merged commit 0e3969b into main Jul 22, 2024
6 checks passed
@anxolin anxolin deleted the usd-orderbook-repo branch July 22, 2024 15:34
@anxolin anxolin mentioned this pull request Jul 26, 2024
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