public async Task <SingleServiceResponse <TopHolderList> > FetchTopHoldersAsync(string contractAddress, int numberOfHolders = 100)
        {
            var result     = new SingleServiceResponse <TopHolderList>();
            var parameters = new Dictionary <string, object>()
            {
                { "limit", numberOfHolders }
            };

            try
            {
                using var client = new WebClient();
                string httpApiResult = await client.DownloadStringTaskAsync(
                    ConstructRequest("getTopTokenHolders", contractAddress, parameters));

                result.ObjectResponse = new TopHolderList
                {
                    Holders = JsonSerializer.Deserialize <TopHolderList>(httpApiResult).Holders
                };
            }
            catch (Exception ex)
            {
                result.Message = ex.GetFullMessage();
            }
            return(result);
        }
Beispiel #2
0
        public async Task <SingleServiceResponse <TokenData> > FetchTokenAsync(string tokenId)
        {
            var result = new SingleServiceResponse <TokenData>();

            try
            {
                var tokenDataRequest = new GraphQLRequest
                {
                    Query         = @"
                query GetTokenData ($id: String, $first: Int){
                    tokenDayDatas(
                    first: $first,
                    orderBy: date,
                    orderDirection: desc,
                    where: { 
                      token: $id
                    }) {
                        token {
                        symbol
                        name
                        id
                    }
                    priceUSD
                    dailyTxns
                    totalLiquidityUSD
                    totalLiquidityETH
                    totalLiquidityToken
                    }
                }",
                    OperationName = "GetTokenData",
                    Variables     = new
                    {
                        id    = tokenId,
                        first = 1
                    }
                };

                TokenData tokenDayData = null;
                GraphQLResponse <TokenDataList> tokenDataResponse = null;

                tokenDataResponse = await _graphQLClient.SendQueryAsync <TokenDataList>(tokenDataRequest);

                if (!(tokenDataResponse.Data is null))
                {
                    if (tokenDataResponse.Data.TokenDayDatas.AnyAndNotNull())
                    {
                        tokenDayData = tokenDataResponse.Data.TokenDayDatas.FirstOrDefault();
                    }
                }

                result.ObjectResponse = tokenDayData;
            }
            catch (Exception ex)
            {
                result.Message = ex.GetFullMessage();
            }
            return(result);
        }
        public async Task <SingleServiceResponse <TokenInfo> > FetchTokenInfoAsync(string contractAddress)
        {
            var result     = new SingleServiceResponse <TokenInfo>();
            var parameters = new Dictionary <string, object>();

            try
            {
                using var client = new WebClient();
                string httpApiResult = await client.DownloadStringTaskAsync(
                    ConstructRequest("getTokenInfo", contractAddress, parameters));

                result.ObjectResponse = JsonSerializer.Deserialize <TokenInfo>(httpApiResult);
            }
            catch (Exception ex)
            {
                result.Message = ex.GetFullMessage();
            }
            return(result);
        }
Beispiel #4
0
        public async Task <SingleServiceResponse <SmartContract> > IsSmartContractVerifiedAsync(string contractAddress)
        {
            var result     = new SingleServiceResponse <SmartContract>();
            var parameters = new Dictionary <string, object>()
            {
                { "module", "contract" },
                { "action", "getabi" },
                { "address", contractAddress }
            };

            try
            {
                using var client = new WebClient();
                string httpApiResult = await client.DownloadStringTaskAsync(ConstructRequest(parameters));

                result.ObjectResponse = JsonSerializer.Deserialize <SmartContract>(httpApiResult);
            }
            catch (Exception ex)
            {
                result.Message = ex.GetFullMessage();
            }
            return(result);
        }
Beispiel #5
0
        public static Tuple <IReplyMarkup, string> ForPremiumTelegram(
            Gem gem,
            SingleServiceResponse <TokenInfo> ethPlorerTokenInfoResponse,
            SingleServiceResponse <SmartContract> etherScanResponse,
            SingleServiceResponse <TopHolderList> ethPlorerTopHoldersResponse
            )
        {
            string tokenInfoDetails = string.Empty;

            if (gem.Recently == TokenActionType.KYBER_ADDED_TO_ACTIVE)
            {
                tokenInfoDetails += $"🥇 *Token Details*\n";

                if (ethPlorerTokenInfoResponse.Success)
                {
                    var dec = Convert.ToInt32(ethPlorerTokenInfoResponse.ObjectResponse.Decimals);
                    var val = BigInteger.Parse(ethPlorerTokenInfoResponse.ObjectResponse.TotalSupply);

                    var owner = string.IsNullOrWhiteSpace(ethPlorerTokenInfoResponse.ObjectResponse.Owner)
                        ? $"Owner: [0x](https://etherscan.io/)\n"
                        : $"Owner: [{ethPlorerTokenInfoResponse.ObjectResponse.Owner}](https://etherscan.io/address/{ethPlorerTokenInfoResponse.ObjectResponse.Owner})\n";

                    tokenInfoDetails +=
                        $"Transfers: _{ethPlorerTokenInfoResponse.ObjectResponse.TransfersCount}_\n" +
                        owner +
                        $"Total supply: _{UnitConversion.Convert.FromWei(val, dec)}_ {gem.Symbol} \n\n";
                }
                else
                {
                    tokenInfoDetails += $"`Data unavailable` \n\n";
                }
            }

            string contractInfo = string.Empty;

            if (gem.Recently == TokenActionType.KYBER_ADDED_TO_ACTIVE)
            {
                if (etherScanResponse.Success)
                {
                    contractInfo = etherScanResponse.ObjectResponse.IsVerified
                        ? $"✅ [Contract](https://etherscan.io/address/{gem.Id}#code) is verified \n\n"
                        : $"❌ [Contract](https://etherscan.io/address/{gem.Id}#code) is NOT verified \n\n";
                }
                else
                {
                    contractInfo += $"`Data unavailable` \n\n";
                }
            }

            string topHoldersInfo = string.Empty;

            if (gem.Recently == TokenActionType.KYBER_ADDED_TO_ACTIVE)
            {
                if (ethPlorerTokenInfoResponse.Success)
                {
                    topHoldersInfo += $"🌐 *Current hodlers*: {ethPlorerTokenInfoResponse.ObjectResponse.HoldersCount}.\n";
                }
                else
                {
                    topHoldersInfo += $"🌐 *Current hodlers*\n";
                }

                if (ethPlorerTopHoldersResponse.Success)
                {
                    topHoldersInfo += $"Top 5 below:\n";

                    var counter = 1;

                    foreach (var item in ethPlorerTopHoldersResponse.ObjectResponse.Holders)
                    {
                        topHoldersInfo += $"[Hodler - {counter++}](https://etherscan.io/token/{gem.Id}?a={item.Address}) - `{item.Share}%` \n";
                    }

                    topHoldersInfo += $"\n\n";
                }
                else
                {
                    topHoldersInfo += $"`Data unavailable` \n\n";
                }
            }

            var banner =
                Content(gem) +
                tokenInfoDetails +
                contractInfo +
                topHoldersInfo;

            var buttons = new InlineKeyboardMarkup(new[]
            {
                KyberButtons(gem),
                SharedMessageContent.EtherscanButtons(gem.Id),
                new []
                {
                    InlineKeyboardButton.WithUrl("📧 Support", $"https://t.me/GemTrackerCommunity")
                }
            });

            return(new Tuple <IReplyMarkup, string>(buttons, banner));
        }
        public static string TokenAndLiquidityDataContent(TokenActionType tokenAction, string symbol, SingleServiceResponse <TokenData> tokenData)
        {
            string tokenInfo     = string.Empty;
            string liquidityInfo = string.Empty;

            if (tokenAction == TokenActionType.ADDED)
            {
                tokenInfo = $"🥇 *Token - ${symbol}*\n";

                if (tokenData.Success)
                {
                    tokenInfo +=
                        $"Initial Price: _${tokenData.ObjectResponse.Price} USD_\n" +
                        $"Txns: _{tokenData.ObjectResponse.DailyTxns}_\n\n";
                }
                else
                {
                    tokenInfo += $"`Data unavailable` \n\n";
                }

                liquidityInfo = $"🥈 *Liquidity*\n";

                if (tokenData.Success)
                {
                    liquidityInfo +=
                        $"USD: _${tokenData.ObjectResponse.LiquidityUSD}_\n" +
                        $"ETH: _{tokenData.ObjectResponse.LiquidityETH}_\n" +
                        $"{symbol}: _{tokenData.ObjectResponse.LiquidityToken}_\n\n";
                }
                else
                {
                    liquidityInfo += $"`Data unavailable` \n\n";
                }
            }

            return(tokenInfo + liquidityInfo);
        }
        public static string TokenHoldersContent(TokenActionType tokenAction, string tokenId, int topHodlersNumber, SingleServiceResponse <TopHolderList> serviceResponse)
        {
            string topHoldersInfo = string.Empty;

            if (tokenAction == TokenActionType.ADDED || tokenAction == TokenActionType.KYBER_ADDED_TO_ACTIVE)
            {
                if (serviceResponse.Success)
                {
                    topHoldersInfo += $"🌐 Top {topHodlersNumber} hodlers below:\n";

                    var counter = 1;

                    foreach (var item in serviceResponse.ObjectResponse.Holders)
                    {
                        topHoldersInfo += $"[Hodler - {counter++}](https://etherscan.io/token/{tokenId}?a={item.Address}) - `{item.Share}%` \n";
                    }

                    topHoldersInfo += $"\n\n";
                }
                else
                {
                    topHoldersInfo += $"`Data unavailable` \n\n";
                }
            }

            return(topHoldersInfo);
        }
        public static string TokenContractContent(TokenActionType tokenAction, string tokenId, SingleServiceResponse <SmartContract> contract)
        {
            string contractInfo = string.Empty;

            if (tokenAction == TokenActionType.ADDED || tokenAction == TokenActionType.KYBER_ADDED_TO_ACTIVE)
            {
                if (contract.Success)
                {
                    contractInfo = contract.ObjectResponse.IsVerified
                        ? $"✅ [Contract](https://etherscan.io/address/{tokenId}#code) is verified \n\n"
                        : $"❌ [Contract](https://etherscan.io/address/{tokenId}#code) is NOT verified \n\n";
                }
                else
                {
                    contractInfo += $"`Data unavailable` \n\n";
                }
            }

            return(contractInfo);
        }
        public static string TokenDetailsContent(TokenActionType tokenAction, string symbol, SingleServiceResponse <TokenInfo> tokenInfo)
        {
            string tokenInfoDetails = string.Empty;

            if (tokenAction == TokenActionType.ADDED || tokenAction == TokenActionType.KYBER_ADDED_TO_ACTIVE)
            {
                tokenInfoDetails += $"🥇 *Token Details*\n";

                if (tokenInfo.Success)
                {
                    var dec = Convert.ToInt32(tokenInfo.ObjectResponse.Decimals);
                    var val = BigInteger.Parse(tokenInfo.ObjectResponse.TotalSupply);

                    var owner = string.IsNullOrWhiteSpace(tokenInfo.ObjectResponse.Owner)
                        ? $"Owner: `Data unavailable`\n"
                        : $"Owner: [{tokenInfo.ObjectResponse.Owner}](https://etherscan.io/address/{tokenInfo.ObjectResponse.Owner})\n";

                    tokenInfoDetails +=
                        $"Transfers: _{tokenInfo.ObjectResponse.TransfersCount}_\n" +
                        $"Hodlers: {tokenInfo.ObjectResponse.HoldersCount}\n" +
                        owner +
                        $"Total supply: _{UnitConversion.Convert.FromWei(val, dec)}_ {symbol} \n\n";
                }
                else
                {
                    tokenInfoDetails += $"`Data unavailable` \n\n";
                }
            }

            return(tokenInfoDetails);
        }
Beispiel #10
0
        public static Tuple <IReplyMarkup, string> ForPremiumTelegram(
            Gem gem,
            SingleServiceResponse <TokenData> uniResponse,
            SingleServiceResponse <TokenInfo> ethPlorerTokenInfoResponse,
            SingleServiceResponse <SmartContract> etherScanResponse,
            ListServiceResponse <PairData> pairResponse,
            SingleServiceResponse <TopHolderList> ethPlorerTopHoldersResponse
            )
        {
            string tokenInfo = string.Empty;

            if (gem.Recently == TokenActionType.ADDED)
            {
                tokenInfo = $"🥇 *Token - ${gem.Symbol}*\n";

                if (uniResponse.Success)
                {
                    tokenInfo +=
                        $"Initial Price: _${uniResponse.ObjectResponse.Price} USD_\n" +
                        $"Txns: _{uniResponse.ObjectResponse.DailyTxns}_\n\n";
                }
                else
                {
                    tokenInfo += $"`Data unavailable` \n\n";
                }
            }

            string tokenInfoDetails = string.Empty;

            if (gem.Recently == TokenActionType.ADDED)
            {
                tokenInfoDetails += $"🥇 *Token Details*\n";

                if (ethPlorerTokenInfoResponse.Success)
                {
                    var dec = Convert.ToInt32(ethPlorerTokenInfoResponse.ObjectResponse.Decimals);
                    var val = BigInteger.Parse(ethPlorerTokenInfoResponse.ObjectResponse.TotalSupply);

                    var owner = string.IsNullOrWhiteSpace(ethPlorerTokenInfoResponse.ObjectResponse.Owner)
                        ? $"Owner: [0x](https://etherscan.io/)\n"
                        : $"Owner: [{ethPlorerTokenInfoResponse.ObjectResponse.Owner}](https://etherscan.io/address/{ethPlorerTokenInfoResponse.ObjectResponse.Owner})\n";

                    tokenInfoDetails +=
                        $"Transfers: _{ethPlorerTokenInfoResponse.ObjectResponse.TransfersCount}_\n" +
                        owner +
                        $"Total supply: _{UnitConversion.Convert.FromWei(val, dec)}_ {gem.Symbol} \n\n";
                }
                else
                {
                    tokenInfoDetails += $"`Data unavailable` \n\n";
                }
            }

            string liquidityInfo = string.Empty;

            if (gem.Recently == TokenActionType.ADDED)
            {
                liquidityInfo = $"🥈 *Liquidity*\n";

                if (uniResponse.Success)
                {
                    liquidityInfo +=
                        $"USD: _${uniResponse.ObjectResponse.LiquidityUSD}_\n" +
                        $"ETH: _{uniResponse.ObjectResponse.LiquidityETH}_\n" +
                        $"{gem.Symbol}: _{uniResponse.ObjectResponse.LiquidityToken}_\n\n";
                }
                else
                {
                    liquidityInfo += $"`Data unavailable` \n\n";
                }
            }

            string contractInfo = string.Empty;

            if (gem.Recently == TokenActionType.ADDED)
            {
                if (etherScanResponse.Success)
                {
                    contractInfo = etherScanResponse.ObjectResponse.IsVerified
                        ? $"✅ [Contract](https://etherscan.io/address/{gem.Id}#code) is verified \n\n"
                        : $"❌ [Contract](https://etherscan.io/address/{gem.Id}#code) is NOT verified \n\n";
                }
                else
                {
                    contractInfo += $"`Data unavailable` \n\n";
                }
            }

            var formPair = string.Empty;

            if (gem.Recently == TokenActionType.ADDED)
            {
                formPair = $"🥉 *Pairs*\n";

                if (pairResponse.Success)
                {
                    foreach (var item in pairResponse.ListResponse)
                    {
                        formPair +=
                            $"`{item.Token0.Symbol}/{item.Token1.Symbol}`\n" +
                            $"Total value: _${item.TotalLiquidityUSD} USD_\n" +
                            $"Created at: _{item.CreatedAt:dd.MM.yyyy}_\n" +
                            $"[Uniswap](https://info.uniswap.org/pair/{item.Id}) |" +
                            $" [DEXT](https://www.dextools.io/app/uniswap/pair-explorer/{item.Id}) |" +
                            $" [Astro](https://app.astrotools.io/pair-explorer/{item.Id}) |" +
                            $" [MoonTools](https://app.moontools.io/pairs/{item.Id}) |" +
                            $" [UniCrypt](https://v2.unicrypt.network/pair/{item.Id})" +
                            $"\n\n";
                    }
                }
                else
                {
                    formPair += $"`Data unavailable` \n\n";
                }
            }

            string topHoldersInfo = string.Empty;

            if (gem.Recently == TokenActionType.ADDED)
            {
                if (ethPlorerTokenInfoResponse.Success)
                {
                    topHoldersInfo += $"🌐 *Current hodlers*: {ethPlorerTokenInfoResponse.ObjectResponse.HoldersCount}.\n";
                }
                else
                {
                    topHoldersInfo += $"🌐 *Current hodlers*\n";
                }

                if (ethPlorerTopHoldersResponse.Success)
                {
                    topHoldersInfo += $"Top 5 below:\n";

                    var counter = 1;

                    foreach (var item in ethPlorerTopHoldersResponse.ObjectResponse.Holders)
                    {
                        topHoldersInfo += $"[Hodler - {counter++}](https://etherscan.io/token/{gem.Id}?a={item.Address}) - `{item.Share}%` \n";
                    }

                    topHoldersInfo += $"\n\n";
                }
                else
                {
                    topHoldersInfo += $"`Data unavailable` \n\n";
                }
            }

            var banner =
                Content(gem) +
                tokenInfo +
                tokenInfoDetails +
                liquidityInfo +
                contractInfo +
                formPair +
                topHoldersInfo;

            var buttons = new InlineKeyboardMarkup(new[]
            {
                UniswapButtons(gem),
                SharedMessageContent.EtherscanButtons(gem.Id),
                new []
                {
                    InlineKeyboardButton.WithUrl("📧 Support", $"https://t.me/GemTrackerCommunity")
                }
            });

            return(new Tuple <IReplyMarkup, string>(buttons, banner));
        }