- Clone this repository:
git clone [email protected]:FatKidddd/tokkalabs.git
- Navigate to the project directory:
cd tokkalabs
- Create a .env file from .env.local
cp .env.local .env
, fill in missing API key
- Start db:
sudo docker-compose -f db-only.yml up -d
- Install deps:
yarn install
- Run tests to verify:
yarn test
- Run express server & script:
yarn start:dev
- Visit http://localhost:3000/api-docs to interact with Swagger UI
sudo docker-compose down
to stop all services
Note: to set up pre-commit linting + prettier yarn husky:prepare
- To access db:
sudo docker exec -it txnfeesdb psql -U user -d txnfeesdb
- To view all txnfees
SELECT * from txnfees;
- Start db & express server (takes 3 mins to build):
sudo docker-compose up --build
- Visit http://localhost:3000/api-docs to interact with Swagger UI
sudo docker-compose down
to stop all services
-
(txn hash) -> USDT txn fee
- find in db
- if found:
- retrieve from db
- return USDT txn fee
- else:
- query txn hash from etherscan
- parse fields
- using timeStamp, query binance API klines with startTime = timeStamp - epsilon, endTime = timeStamp + epsilon, where epsilon is probably some seconds
- mid = (low + high) / 2
- add to db
- return USDT txn fee
- query txn hash from etherscan
- if found:
- find in db
-
(Batch job) (startBlock, endBlock) -> transactions with all their prices
- function that takes in (startBlock, endBlock) -> populate db
- txn hash
- timeStamp
- gasUsed
- gasPrice
- binance ETHUSDT price
- txn fee in USDT
Useful Binance API live data - websocket current avg price historical data - use klines / candlesticks OHLC
Useful Etherscan API live data - websocket ERC20 transfers historical - convert timestamps into closest blocks, query using start and end blocks
- Use Redis for caching
- (not implemented) making batch processing more efficient by avoiding repeated queries
- (not implemented) make batch processing able to handle larger query range
- Inaccurate pricing dependent on timeframe given to binance API -> should add in uncertainty / another field for resolution
This project is licensed under the MIT License - see the LICENSE file for details
Boilerplate with TypeScript, Express, ESLint, Prettier, Husky + Lint-staged, and Vitest