The SnapshotService
is a core component of the Brokkr Snapshot application, responsible for aggregating and validating snapshot data across multiple investment portfolios. It interfaces with various database and contract services to compile comprehensive snapshots, ensuring data integrity through robust Quality Assurance (QA) checks.
- Comprehensive Snapshot Aggregation: Gathers snapshot data from diverse portfolio types including Token Index, Token Based, Arrakis Vault, and DCA.
- Quality Assurance Checks: Validates snapshot data against predefined thresholds and consistency checks to ensure accuracy.
- Modular Design: Leverages specialized services for database interactions and contract communications, promoting maintainability and scalability.
- Efficient Data Handling: Utilizes asynchronous operations and optimized querying to handle large datasets effectively.
-
Clone the Repository:
git clone https://github.com/your-repo/brokkr-snapshot.git cd brokkr-snapshot
-
Install Dependencies:
npm install
-
Configure Environment Variables: Create a
.env
file in the root directory and configure the necessary environment variables as per the.env.example
template. -
Run the Application:
npm run start
-
getTotalSnapshotWithChecks(snapshotBlock: number, usdThreshold: number)
Aggregates snapshots across all portfolio types and performs QA checks to validate the data.
Returns:
{ snapshot: SnapshotType[]; isValid: boolean; errors: string[]; }
The SnapshotService
interacts with several other services to perform its operations:
-
Database Services:
TokenIndexDbService
TokenBasedDbService
VaultDbService
DcaDbService
-
Contract Services:
TokenIndexContractService
TokenBasedContractService
ArrakisContractsService
DcaContractService
-
Configuration and QA:
BrokkrSnapshotConfigService
QaService
src/
├── config/
│ └── brokkr-snapshot-config.service.ts
├── contract-connectors/
│ ├── arrakis-contracts/
│ ├── dca-contract/
│ ├── token-based-contract/
│ └── token-index-contract/
├── db/
│ ├── dca-db/
│ ├── token-based-db/
│ ├── token-index-db/
│ └── vault-db/
├── shared/
│ ├── constants.ts
│ └── models/
│ └── ISnapshot.ts
├── snapshot/
│ ├── snapshot.service.ts
│ ├── snapshot.controller.ts
│ └── addresses.json
└── qa/
└── qa.service.ts
config/
: Configuration services and modules.contract-connectors/
: Services that interact with blockchain contracts.db/
: Database interaction services and models.shared/
: Shared constants and models used across the application.snapshot/
: The main SnapshotService and its controller.snapshot/addresses.json
: A JSON file with productAddress and userAddress arrays. If some users need be added manually, it can be done here!
qa/
: Quality Assurance services for validating snapshot data.