This project is a backend service designed to automate operations with Ethereum-based smart contracts. It periodically updates the ETH price and performs operations on contracts using the ethers library and node-cron for task scheduling.
- ETH Price Updates: Fetches the latest ETH price from CoinGecko every minute.
- Smart Contract Operations: Interacts with
IntentsNFT,PoolsNFT, andGrinderAIcontracts to process "grinds" and execute operations. - Gas Cost Verification: Ensures that transaction costs remain within a predefined limit before execution.
- Clone the repository:
git clone <repository-url>
cd grindurus-backend- Install dependencies:
npm install- Create a .env file based on .env.example and configure the following variables:
RPC_URL=<your RPC URL to blockchain>
GRINDER_PRIVATE_KEY=<your wallet private key>
- Connects to an Ethereum node using
ethers.JsonRpcProvider. - Creates a wallet instance (
grinderWallet) using the private key from the.envfile.
- Interacts with the following contracts:
- IntentsNFT: Manages intents and their associated data.
- PoolsNFT: Handles pool-related operations.
- GrinderAI: Executes batch operations.
- ETH Price Updates: Fetches the current ETH price in USD from CoinGecko every minute.
- Grind Operations: Processes intents and performs operations on pools every minute.
- The
getEthPriceFromCoinGeckofunction fetches the ETH price from the CoinGecko API. - Updates the global
ethPricevariable.
- The
bruteForceGrindfunction performs the following steps:- Fetches the total number of intents from the
IntentsNFTcontract. - Retrieves intent data for a subset of intents.
- Checks for unspent grinds associated with each intent.
- If unspent grinds exist, processes the associated pool IDs using the
iterate2function.
- Fetches the total number of intents from the