Monitoring and indexing ERC4626 vault activities. The system consists of three main components working together to provide complete visibility into vault operations.
contract-listener: NestJS event monitoring servicecontracts: Hardhat project with vault implementationgraph: Subgraph indexing service
The core component that uses ethers.js to monitor the vault contract in realtime. It captures all deposit and withdrawal events, stores them in a PostgreSQL database, and provides RESTful API endpoints for querying the data.
- Built with NestJS framework
- Uses ethers.js for blockchain interaction
- Realtime event monitoring
- PostgreSQL database storage
- RESTful API endpoints
- Transaction history tracking
First, navigate to the app:
cd apps/contract-listenerThen, rename the .env.example to .env and configure the environment variables:
# Application
PORT=3000
NODE_ENV=development
# Database
DATABASE_HOST=dorg-postgres
DATABASE_PORT=5432
DATABASE_USER=postgres
DATABASE_PASSWORD=postgres
DATABASE_NAME=dorg
# Blockchain
WS_URL=wss://opt-sepolia.g.alchemy.com/v2/YU9cnPZhP1bB5L73LlbCJX7JOk61DYYf
CONTRACT_ADDRESS=0x6aA4C7396579cE2666F38acB9dfB84BD373e4CB9
START_BLOCK=26544587Start the service:
docker compose upAvailable endpoints:
GET /vault/deposits/:wallet- Deposit summaryGET /vault/withdrawals/:wallet- Withdrawal summaryGET /vault/deposits/:wallet/history- Deposit historyGET /vault/withdrawals/:wallet/history- Withdrawal history
A set of command-line tools for interacting with the vault.
- Network: Optimism Sepolia
- Vault Address: 0x6aA4C7396579cE2666F38acB9dfB84BD373e4CB9
- Underlying Token: Trust (0x6B73Afbd5b53827F6d741dD27157E0c34Da83Ff9) (Deployed using Thirdweb)
To deploy the vault to Optimism Sepolia:
- Navigate to the contracts directory:
cd apps/contracts- Configure your environment:
# Copy the example environment file
cp .env.example .env
# Add your private key
PRIVATE_KEY=your_private_key- Configure the vault module:
- Open
apps/contracts/ignition/modules/vault.ts - Update the
mockERC20Addressparameter with your desired ERC20 token address
const mockERC20Address = m.getParameter("Trust", "YOUR_ERC20_ADDRESS");- Deploy the vault:
# Deploy using Hardhat Ignition
pnpm hardhat ignition deploy ignition/modules/vault.ts --network op-sepoliaThe following tasks are available for generating test events. Before running any task, ensure to update the contract addresses in the respective task files found at 'apps/contracts/tasks':
# Approve tokens
pnpm hardhat approve --amount <amount> --network <network>
# Deposit tokens
pnpm hardhat deposit --amount <amount> --network <network>
# Withdraw tokens
pnpm hardhat withdraw --amount <amount> --network <network>A GraphQL-based indexing service that provides efficient querying of historical vault data, enabling complex analytics and historical tracking.
- Event indexing
- Historical data analysis
- GraphQL query support
- Playground: The Graph Studio
