Hoops Finance is a DeFi analytics platform that indexes Soroban Liquidity Pools from leading ecosystem protocols. It provides comprehensive risk analysis and performance metrics for liquidity pools, allowing investors to make informed, risk-adjusted investments. The platform offers an analytics API for data retrieval and integration.
The indexer is responsible for monitoring and parsing relevant transactions from the Stellar ledger. It identifies transactions involving specific addresses, such as token contracts, pair contracts, and user addresses. The data is sourced from Stellar Expert and Google Big Query using the Stellar Development Foundation's Hubble dataset.
Key Processes:
EventParser: Parses Soroban contract events emitted by transactions.
const events = humanizeEvents(xdrEvents);
const parsedEvents = events.map(event => {
const protocol = EventParser.getProtocolFromTopic(event.topics[0]);
return protocol === 'soroswap' ? SoroswapEvents.parse(event) : TokenEvents.parse(event);
});
TransactionMeta: Responsible for parsing transaction metadata objects to capture fees, events, and return values.
const parsedEvents = EventParser.parse(sorobanMeta.events());
const feeInfo = this.extractFeeInfo(sorobanMeta.ext().v1());
const parsedMeta = { ...feeInfo, events: parsedEvents };
TransactionResults: Parses transaction results to determine the outcome of contract invocations.
const operationResults = parsedTransaction.operationResults.map(result => ({
opType: result.opType,
opResultCode: result.opResultCode,
value: result.value,
}));
TransactionParser: Parses entire transactions to extract all relevant data, including operations, contracts, and functions.
const parsedTransaction = {
source: tx.source,
isFeeBump: tx.isFeeBump,
operations: tx.operations.map(op => parseOperation(op)),
};
DeFiIndexer: Indexes all pools and contracts associated with a protocol by processing liquidity pairs and calculating their USD values.
const pairs = await this.getPairsFromFactory(factoryContract);
const pairDetails = await Promise.all(pairs.map(pairAddress => this.getPairDetails(pairAddress)));
MongoDB stores the indexed data, including details about liquidity pools, tokens, swaps, and other relevant metrics. The database supports efficient querying for the analytics API.