This service is designed to handle two primary tasks:
Vault Aggregation:
APR Calculation:
Event Listener: The service listens for LogCollectedFees
events from Arrakis vault contracts, collects the necessary data, and stores it in the database for future APR calculations.
Daily Aggregation: The service runs a daily job that fetches and stores historical vault data, like TVL Token0 and Token1 price.
startingBlock
env property is taken as startTimestamp
)src/
├── aggregators/
│ ├── vault-aggregator/ # Handles daily vault data aggregation
│ └── operations-aggregator/ # Handles listening to "LogCollectedFees" events
├── api/
│ └── lp/ # API module for LP-related data, including APR calculations
├── blockchain-connectors/ # Manages blockchain connectivity and provides ERC20 service
├── contract-connectors/ # Services for interacting with contracts (eg. Arrakis)
├── database/ # MongoDB schemas and database interaction services
├── price-oracles/ # Price-Oracle service (Coingecko API)
├── config/ # Configuration settings for the service
├── shared/ # Shared models, types, classes and enums and utility functions
└── utils/ # Various utility functions
src/aggregators/vault-aggregator/vault-aggregator.service.ts
:
src/aggregators/operations-aggregator/operations-aggregator.service.ts
:
LogCollectedFees
events from startingBlock, then schedules an hourly sync job.src/api/lp/lp.service.ts
:
src/database/
:
CollectedVaultFeeEvent.schema.ts
, VaultHistoricalData.schema.ts
).src/blockchain-connectors/
:
Clone the Repository:
git clone <repository-url>
cd <project-directory>
Install Dependencies:
npm install
Environment Variables:
.env
file. You’ll need:
Run the Application:
npm run start
Running Tests:
npm run test
The vault aggregation logic starts automatically:
LogCollectedFees
events and stores them in the database.The APR calculation is exposed via an API:
LogCollectedFees
events are resynced from the startingBlock now with every restart -> resulting in lots of unncecessary node requests, but more certainty that all data is present