The Token Price Oracle Service is a high-performance, asynchronous API designed to provide accurate and real-time token price data. This service integrates seamlessly with multiple data sources, ensuring reliability, scalability, and flexibility for developers building applications that require up-to-date cryptocurrency price information.
-
Asynchronous API
The service is built using modern asynchronous Rust libraries to handle high-concurrency requests efficiently. Users can fetch token prices without blocking, allowing for smooth integration into distributed systems or microservice architectures.
-
Stateless Proof-of-Work (PoW) DDoS Protection system.
By utilizing cryptographic techniques, it ensures that only clients expending computational effort can proceed, deterring abusive requests. This approach is efficient, scalable, and configurable, offering flexibility to enable or disable protection based on operational requirements.
-
Integration with Multiple Data Sources
Connects to multiple cryptocurrency exchanges, market aggregators, and data providers to fetch live and historical price data. Utilizes redundancy by querying multiple sources, ensuring high availability and accuracy even if one provider is down.
-
Real-Time Price Updates
Supports WebSocket and HTTP APIs for continuous price feeds or on-demand queries. Ensures low latency in delivering updates to keep your application in sync with market changes.
-
Advanced Caching System
Implements an intelligent in-memory caching layer to handle a large number of concurrent readers efficiently. Reduces the number of external API calls to data providers, significantly cutting operational costs. Configurable cache expiration to balance data freshness with performance. Particularly beneficial for applications with heavy read traffic, ensuring high performance while minimizing API provider expenses.
-
Customizable Aggregation Logic
Offers configurable algorithms for price aggregation (e.g., weighted averages, median pricing). Allows developers to fine-tune how prices are calculated from different data sources based on their application's requirements.
-
Secure and Scalable
Implements secure communication channels (e.g., HTTPS, token-based authentication) for API usage. Scales horizontally to handle a growing number of requests and maintain performance under heavy loads.
-
DeFi Applications
Fetch real-time prices for on-chain token swaps, lending, or liquidity pool management.
-
Portfolio Management
Provide users with live token valuations and historical price trends.
-
Analytics Dashboards
Aggregate and visualize token price movements for traders and investors.
-
High-Read Workloads
Use the advanced caching system to efficiently serve thousands of simultaneous requests while minimizing costs.
Subscribe to real-time price updates with a customizable feed (e.g., specific tokens or exchanges).
- Accuracy: By aggregating data from multiple reliable sources, the service minimizes the risk of price manipulation or inaccuracies.
- Efficiency: Built-in caching and asynchronous processing enable high throughput and low response times.
- Cost Savings: The advanced caching system optimizes for high-read scenarios, reducing the reliance on external APIs and significantly lowering costs for frequent access.
- Flexibility: Easy integration into applications of varying scale and complexity.
- Scalability: Designed to grow with your needs, handling thousands of concurrent users and API calls.
The Token Price Oracle Service is your dependable solution for accessing accurate, real-time cryptocurrency price data while minimizing costs for high-demand applications.
- MVP Solution. Getting price data for btc/eth tokens from the 1 source (coingeko). Store data only in the runtime custom cash. (Done)
- Add ability to configur list of tokens, coingeko keys, time intervals in the config file. Add unit tests. (Done)
- Implement DDoS Protection system (Done)
- Develop client to emulate full business process. (Done)
- Add light weight DB to store data and provide historical price data.
- Add ability to work with multiple proxies to bypass request limits.
- Integrate more data sources
- Fetch the latest price for all token.
Request:
- Method: GET
- Endpoint:
/prices
Request example:
Header (If ddos protection enabled) :
X-Access-Token:
{"access_token": "access_0938b24f-80ee-4669-bc2d-1df2d7c4c2c0","signature": "aa3aff15432f68286e9c60f3cef1d82f173aca54fcec6158d5a29ee04ca02723"}
Response example:
{[
{ token_ticker: "ethereum", price_list: [{ currency: "usd", price: "3649.95" }] },
{ token_ticker: "bitcoin", price_list: [{ currency: "usd", price: "96991" }] }
]}
- Fetch the latest price for a specific token. (todo)
Request:
- Method: GET
- Endpoint:
/price/{token}
- Get task
Request:
- Method: GET
- Endpoint:
/puzzle/get_task
Response example:
{
"task": "dcb891a4-11ae-4a8f-a45e-f9a4b5e7f330",
"signature": "f9071a790bd757e269224b010a1b1403dd5ded374bf871f77a76f80e1a739d5e",
"difficulty": 1
}
- Check resolution and recived access token.
Request:
- Method: POST
- Endpoint:
/puzzle/check_resolution
Request example:
{
"task": "dcb891a4-11ae-4a8f-a45e-f9a4b5e7f330",
"nonce": 10,
"signature": "f9071a790bd757e269224b010a1b1403dd5ded374bf871f77a76f80e1a739d5e"
}
Response example:
{
"access_token": "access_1a6597f0-617c-4abb-bd9b-f47b1e00e9b3",
"signature": "0acd1487703345a366aafb897035bd9b002e6cedd5f0a999b74a11ce7946296e"
}
- Configure token oracle
- token_oracle/config.toml (Puzzle configuration)
- token_oracle/coingecko_conf_test/prod.toml (Access to the Coingecko and data structure)
- Configure client
- client/config.toml
- Run Token Oracle
cd token_oracle
Run with test config
APP_ENV=test cargo run
Run with prod config
APP_ENV=prod cargo run
- Run Client
cd client
cargo run