public IExchangeEventEntity Create(
     string id,
     string exchangeAddress,
     string callerAddress,
     ExchangeEventType type,
     decimal ethAmount,
     decimal tokenAmount,
     decimal ethLiquidityBeforeEvent,
     decimal ethLiquidityAfterEvent,
     decimal tokenLiquidityBeforeEvent,
     decimal tokenLiquidityAfterEvent,
     string txHash,
     int logIndex,
     DateTime timeStamp,
     decimal ethFee,
     decimal tokenFee,
     string tokenAddress,
     ulong blockNumber,
     decimal callerBalance)
 {
     return(new MongoExchangeEventEntity
     {
         Id = id,
         ExchangeAddress = exchangeAddress,
         CallerAddress = callerAddress,
         Type = type,
         EthAmount = ethAmount,
         TokenAmount = tokenAmount,
         EthLiquidityBeforeEvent = ethLiquidityBeforeEvent,
         EthLiquidityAfterEvent = ethLiquidityAfterEvent,
         TokenLiquidityBeforeEvent = tokenLiquidityBeforeEvent,
         TokenLiquidityAfterEvent = tokenLiquidityAfterEvent,
         TxHash = txHash,
         LogIndex = logIndex,
         Timestamp = timeStamp,
         EthFee = ethFee,
         TokenFee = tokenFee,
         TokenAddress = tokenAddress,
         BlockNumber = blockNumber,
         CallerBalance = callerBalance
     });
 }
Beispiel #2
0
        private async Task <IExchangeEventEntity> CreateEntityAsync(
            IEventLog eventLog,
            ExchangeEventType eventType,
            ExchangeState beforeState,
            ExchangeState afterState,
            string callerAddress,
            decimal ethAmount,
            decimal tokenAmount,
            decimal ethFee,
            decimal tokenFee,
            string tokenAddress)
        {
            var blockNumber    = (ulong)eventLog.Log.BlockNumber.Value;
            var blockTimestamp =
                await _blockTimestampProvider.GetByBlockNumberAsync(blockNumber);

            var exchangeAddress = eventLog.Log.Address;

            var callerBalance = await _exchangeGatewayFactory(exchangeAddress).GetBalanceOfAsync(callerAddress, blockNumber);

            var tokenInfo = await _tokenInfoProvider.GetAsync(tokenAddress);

            return(_exchangeEventEntityFactory.Create(
                       $"{eventLog.Log.TransactionHash}_{eventLog.Log.LogIndex.Value}",
                       exchangeAddress,
                       callerAddress,
                       eventType,
                       ethAmount,
                       tokenAmount,
                       beforeState.EthLiquidity,
                       afterState.EthLiquidity,
                       beforeState.TokenLiquidity,
                       afterState.TokenLiquidity,
                       eventLog.Log.TransactionHash,
                       (int)eventLog.Log.LogIndex.Value,
                       blockTimestamp,
                       ethFee,
                       tokenFee,
                       tokenAddress,
                       blockNumber,
                       callerBalance.ToDecimal(tokenInfo.Decimals)));
        }