https://hackmd.io/@JeremyCREAM/HkkYv3ICd
If you want to build docker image, please define the .env at the root path in this project first.
INFURA_KEY= // This is a key from https://infura.io/dashboard/ethereum/[PROJECT ID]/settings
NETWORK= // Define network for interacting with Ethereum node. Ex: mainnet.
LOG_LEVEL= // Define the log level you want to log. Ex:trace,debug,info,warn and error.
LOG_STATUS_BLOCK_GAP= // Define the log block gap. Ex: 100.
if you didn't run any attach command before.
kubectl create -f deployment.yml
or
kubectl apply -f deployment.yml
kubectl get pods
kubectl logs token-monitor-[YOUR POD NAME]
kubectl delete ds token-monitor
There is an event interface.I knew the program may could listen the event with ethers library. But I found something weird that the listening function maybe not fire sometimes. So I decided to query the transactions at every new block but filtered by event.
Review the document of ethers library and check the crUSDC smart contract interface on the Etherscan website. Review and compare the better way to run instance in k8s pod.
Followed the homework hints and kept searching on the document of ethers library. Checked event interface on Etherscan website.
Doing borrow,repay borrow,mint and redeem on CREAM finance platform for many times.
Because I used listening skill, but if many class instances were running ,same listening function would fire if listened same event. It looked bad, so I chose Singleton design pattern to avoid the problem. Also I concerned the block generated time was not too long for querying data with gRPC, so I used lock to make sure the function must be executed in order.
Use modularization and factory skills to make sure the project follows SOLID principle and OOP design as possible.There are some end-to-end test and unit test to keep the code quality.The test coverage is above 80%.
Because the project is for logging, I choose daemonSet kind to deploy the program.