{"id":17592468,"url":"https://github.com/bobthebuidler/ypricemagic","last_synced_at":"2026-04-17T15:02:36.903Z","repository":{"id":37528811,"uuid":"384335572","full_name":"BobTheBuidler/ypricemagic","owner":"BobTheBuidler","description":"Fetch accurate prices for tokens solely using on-chain data.","archived":false,"fork":false,"pushed_at":"2024-04-11T23:42:28.000Z","size":6371,"stargazers_count":58,"open_issues_count":1,"forks_count":19,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-12T02:59:16.086Z","etag":null,"topics":["erc20-tokens","ethereum-contract","evm","python","python3","web3","web3py"],"latest_commit_sha":null,"homepage":"https://bobthebuidler.github.io/ypricemagic/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BobTheBuidler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-07-09T05:52:19.000Z","updated_at":"2024-07-23T16:40:27.222Z","dependencies_parsed_at":"2024-04-15T00:34:47.867Z","dependency_job_id":"4419ed5d-e1ec-444a-8397-cb7d76f22f27","html_url":"https://github.com/BobTheBuidler/ypricemagic","commit_stats":{"total_commits":310,"total_committers":3,"mean_commits":"103.33333333333333","dds":"0.45483870967741935","last_synced_commit":"9ff92742afc0eaa72914be773aa6d0b1d86a14c2"},"previous_names":[],"tags_count":353,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BobTheBuidler%2Fypricemagic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BobTheBuidler%2Fypricemagic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BobTheBuidler%2Fypricemagic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BobTheBuidler%2Fypricemagic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BobTheBuidler","download_url":"https://codeload.github.com/BobTheBuidler/ypricemagic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244047646,"owners_count":20389206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["erc20-tokens","ethereum-contract","evm","python","python3","web3","web3py"],"created_at":"2024-10-22T05:23:19.481Z","updated_at":"2026-01-30T05:18:57.275Z","avatar_url":"https://github.com/BobTheBuidler.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ypricemagic\n\n[![PyPI](https://img.shields.io/pypi/v/ypricemagic.svg?logo=Python\u0026logoColor=white)](https://pypi.org/project/ypricemagic)\n[![Monthly Downloads](https://img.shields.io/pypi/dm/ypricemagic)](https://pypistats.org/packages/ypricemagic)\n\nUse this tool to extract historical on-chain price data from an archive node.\n\nypricemagic is built to work seamlessly with both sync and async Python codebases using the [ez-a-sync framework](https://github.com/BobTheBuidler/ez-a-sync).\n\n## Requirements\n- Python 3.9 or higher.\n- At least 16GB of RAM.\n\n## Prerequisites\n- First, you will need to bring your own archive node. This can be one you run yourself, or one from one of the common providers (Tenderly, Alchemy, QuickNode, etc.)\n- You will also need an auth token for [Etherscan](https://etherscan.io/)'s API. Follow their [guide](https://docs.etherscan.io/etherscan-v2/getting-an-api-key) to get your key, and set env var `ETHERSCAN_TOKEN` with its value.\n\n## Installation\nypricemagic is published on [PyPI](https://pypi.org/). Simply install it just as you would any other library.\n```\npip install ypricemagic\n```\n\n## Network Configuration\nypricemagic utilizes the Brownie framework for Ethereum smart contract interactions. As such, it's essential that users configure a Brownie network to use their chosen RPC. Ensure you have access to an Ethereum node (e.g., through Infura or Alchemy) and add the provided API endpoint to your Brownie network configuration.\n\nRefer to the [Brownie documentation on network management](https://eth-brownie.readthedocs.io/en/stable/network-management.html) for detailed guidance on setting up your networks. This setup is critical, as without it, ypricemagic will not be able to communicate with your RPC. \n\n## Usage\n\nThere are 2 main entrypoints to ypricemagic, \n[y.get_price](https://bobthebuidler.github.io/ypricemagic/source/y.html#y.get_price) and [y.get_prices](https://bobthebuidler.github.io/ypricemagic/source/y.html#y.get_prices).\n\n```python\nfrom y import get_price\nprice = get_price(token,block)\n\n# OR\n\nfrom y import get_prices\nprices = get_prices(tokens, block)\n```\n\nYou can also use ypricemagic asynchronously:\n```python\nprice = await get_price(token, block, sync=False)\n\n# OR\n\nprices = await get_prices(tokens, block, sync=False)\n```\n\nSee the [docs](https://bobthebuidler.github.io/ypricemagic) for more usage information.\n\n## Debug logging\nIf you need to spot long-running async calls, enable the `y.stuck?` logger at DEBUG to get periodic \"still executing\" messages. Details: [y.stuck? logger](CONTRIBUTING.md#y-stuck-logger).\n\n## Extras\nYou can also import protocol specific modules. For example:\n```python\nfrom ypricemagic import uniswap\nuniswap.get_price(token, block)\n```\n```python\nfrom ypricemagic.compound import get_price\nget_price(compoundToken, block)\n```\nThese are not 'supported' per se and are subject to change at any time. But they can come in handy. The [not-very-organized docs site](https://bobthebuidler.github.io/ypricemagic) will be your friend here.\n\nEnjoy!\n\n\n### Shoutouts\nShoutout to [Banteg](https://github.com/banteg) [(@bantg)](https://twitter.com/bantg) and [nymmrx](https://github.com/nymmrx) [(@nymmrx)](https://twitter.com/nymmrx) for their awesome work on [yearn-exporter](https://github.com/yearn/yearn-exporter) that made this library possible.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobthebuidler%2Fypricemagic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbobthebuidler%2Fypricemagic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobthebuidler%2Fypricemagic/lists"}