Skip to content

Retrieve prices for native assets and ERC20/ERC721 tokens in a custom chain using multiple oracles

License

Notifications You must be signed in to change notification settings

safe-global/safe-price-service

Repository files navigation

Python CI Coverage Status pre-commit Python 3.11 Django 5 Docker Image Version (latest semver)

Safe Price Service

Returns fiat prices for base currencies and ERC20 tokens.

This logic was previously on the Safe Transaction Service. As it was not needed anymore but a lot of work was done, a decision was made to create a new service and give it to the Ethereum community.

It's expected that the project will be community driven, Safe team will only take care of updating dependencies and reviewing community PRs, so please don't open issues about your favorite token not returning a price or price being wrong.

Configuration

One instance of the service can support multiple EVM compatible chains.

cp .env.sample .env

Configure environment variables on .env:

  • DJANGO_SECRET_KEY: IMPORTANT: Update it with a secure generated string.
  • ETHEREUM_NODES_URLS: Comma separated list of the node RPCs for the chains supported for fetching prices.
  • PRICES_CACHE_TTL_MINUTES: Minutes to keep a price in cache.

Execution

docker compose build
docker compose up

Then go to http://localhost:8000 to see the service documentation.

Example request to get USD for Gnosis token on mainnet: http://localhost:8000/api/v1/1/tokens/0x6810e776880C02933D47DB1b9fc05908e5386b96/prices/usd/

Endpoints

  • /v1/{chainId}/tokens/{address}/prices/usd/

Contributors

See contributors

About

Retrieve prices for native assets and ERC20/ERC721 tokens in a custom chain using multiple oracles

Resources

License

Stars

Watchers

Forks

Packages

No packages published