public async Task <decimal> GetAsync(string tokenAddress, string ownerAddress) { var tokenInfo = await _tokenInfoProvider.GetAsync(tokenAddress); var balance = await _erc20GatewayFactory(tokenAddress).GetBalanceAsync(ownerAddress); return(balance.ToDecimal(tokenInfo.Decimals)); }
public async Task <decimal> GetAsync(string exchangeAddress) { var exchangeGateway = _exchangeGatewayFactory(exchangeAddress); var totalSupply = await exchangeGateway.GetTotalSupplyAsync(); var tokenInfo = await _tokenInfoProvider.GetAsync(exchangeAddress); return(totalSupply.ToDecimal(tokenInfo.Decimals)); }
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))); }
public async Task <TokenInfo> GetAsync(string address) { if (_cache.TryGetValue(address, out var cachedTokenInfo)) { return(cachedTokenInfo); } else { var tokenInfo = await _tokenInfoProvider.GetAsync(address); _cache[address] = tokenInfo; return(tokenInfo); } }
public async Task <IExchangeEntity> MapAsync(EventLog <NewExchangeEventDTO> eventLog) { var exchangeAddress = eventLog.Event.Exchange; var tokenAddress = eventLog.Event.Token; var tokenInfo = await _tokenInfoProvider.GetAsync(tokenAddress); var blockNumber = (ulong)(BigInteger)eventLog.Log.BlockNumber; var tokenLiquidity = await _tokenLiquidityProvider.GetAsync(tokenAddress, exchangeAddress); var ethLiquidity = await _ethLiquidityProvider.GetAsync(exchangeAddress); var totalSupply = await _exchangeTotalSupplyProvider.GetAsync(exchangeAddress); var theme = await _exchangeThemeProvider.GetAsync(tokenInfo.Symbol); return(_exchangeEntityFactory.Create(exchangeAddress, tokenAddress, tokenInfo, blockNumber, ethLiquidity, tokenLiquidity, totalSupply, theme)); }