public CoinInfo GetCoinList(FiatType fiatType, int maxSize) { try { CoinInfo result = new CoinInfo(); string methodName = "listings/latest"; var URL = new UriBuilder(string.Concat(serviceUrl, methodName)); var queryString = HttpUtility.ParseQueryString(string.Empty); queryString["start"] = "1"; queryString["limit"] = maxSize.ToString(); queryString["convert"] = fiatType == FiatType.EUR ? "EUR" : fiatType == FiatType.USD ? "USD" : "TRY"; URL.Query = queryString.ToString(); var client = new WebClient(); client.Headers.Add("X-CMC_PRO_API_KEY", apiKey); client.Headers.Add("Accepts", "application/json"); string serviceResponse = client.DownloadString(URL.ToString()); result = JsonConvert.DeserializeObject <CoinInfo>(serviceResponse); return(result); } catch (Exception ex) { LogOperation.InsertLog(new StackTrace().GetFrame(1).GetMethod().Name, string.Concat("Coinbase servisi çağrılırken hata oluştu", ex.Message), DateTime.Now); return(null); } }
// Update is called once per frame void Update() { for (int i = 0; i < TossLocations.Count; i++) { TossLocationInfo info = TossLocations[i]; if (info.InUse && info.NextUse < Time.time) { info.InUse = false; TossLocations[i] = info; } } if (CoinsInfo.Count > 0) { for (int i = CoinsInfo.Count - 1; i >= 0; i--) { CoinInfo Info = CoinsInfo[i]; if (Info.OurRB) { if (Info.OurRB.IsSleeping()) { HandleCoinCleanup(Info); } } } } HandleCoinToss(); }
public void AddCoinInfo(IDbConnection con, IDbTransaction tx, CoinInfo CoinInfo) { var existing = GetCoinInfo(con, CoinInfo.CoinType); if (existing == null) { var query = "INSERT INTO coin_info(cointype, name, coinmarketcapid, priceusd, pricebtc, updated) " + "VALUES(@cointype, @name, @coinmarketcapid, @priceusd, @pricebtc, @updated)"; var coinInfo = new Entities.CoinInfo { CoinType = CoinInfo.CoinType.ToString(), Name = CoinInfo.Name, CoinMarketCapId = CoinInfo.CoinMarketCapId, PriceUSD = CoinInfo.PriceUSD, PriceBTC = CoinInfo.PriceBTC, Updated = CoinInfo.Updated }; con.Execute(query, coinInfo, tx); } else { var query = "update coin_info set priceusd = @priceusd, pricebtc = @pricebtc, updated = @updated " + " WHERE cointype = @cointype "; con.Execute(query, new { priceusd = CoinInfo.PriceUSD, pricebtc = CoinInfo.PriceBTC, updated = CoinInfo.Updated, cointype = CoinInfo.CoinType.ToString() }, tx); } }
private async Task <CryptoItemModel> GetCryptoItemModel(CoinInfo coin) { var priceData = (await CryptoCompareClient.Instance.Prices.MultipleSymbolFullDataAsync(new[] { coin.Symbol }, new[] { "USD" })).Raw .Values.ToArray()[0].Values.ToArray()[0]; return(new CryptoItemModel(coin, priceData)); }
public Summary(CoinInfo coinInfo, CoinFullAggregatedDataDisplay btcPrice, CoinFullAggregatedDataDisplay ethPrice, string coinImgUrl) { this.Info = coinInfo; this.BtcPrice = btcPrice; this.EthPrice = ethPrice; this.ImgUrl = coinImgUrl; }
public async Task AddCoinInfo(CoinInfo coinInfo) { try { await _context.CoinInfo.InsertOneAsync(coinInfo); } catch (Exception ex) { throw ex; } }
static Coin ConvertToCoin(CoinInfo info) { return(new Coin() { Symbol = info.Symbol, IsActive = info.IsActive, Name = info.Name, Type = info.Type, Id = info.Id, Rank = info.Rank }); }
public async Task <bool> DeleteCoinInfo(CoinInfo coinInfo) { try { DeleteResult actionResult = await _context.ApiInformation.DeleteOneAsync(nameof => nameof.Id.Equals(coinInfo.Id)); return(actionResult.IsAcknowledged && actionResult.DeletedCount > 0); } catch (Exception ex) { throw ex; } }
static int Lookup(string szSelectedCoin, decimal hashrate, bool bIncomeInBTC, long interval, string exchange, RegistrySettings rs) { Profitability p = new Profitability(); CoinInformation ci = new CoinInformation(); ExchangeInformation ei = new ExchangeInformation(); CoinInfo inf = rs.Coins[szSelectedCoin]; double diff = 0; try { diff = ci.GetDifficulty(inf.ExplorerType, inf.ExplorerBaseURL, inf.ExplorerChain, inf.Abbreviation); } catch { Console.WriteLine("Unable to fetch difficulty"); return(-1); } decimal reward = 0; try { reward = ci.GetReward(inf.ExplorerType, inf.ExplorerBaseURL, inf.ExplorerChain, inf.Abbreviation); } catch { Console.WriteLine("Unable to fetch reward"); return(-1); } if (hashrate == 0) { switch (inf.DefaultHashRateUnit) { case "H/s": hashrate = Convert.ToDecimal(inf.DefaultHashRate); break; case "kH/s": hashrate = Convert.ToDecimal(inf.DefaultHashRate) * 1000; break; case "MH/s": hashrate = Convert.ToDecimal(inf.DefaultHashRate) * 1000000; break; case "GH/s": hashrate = Convert.ToDecimal(inf.DefaultHashRate) * 100000000; break; default: throw new ArgumentException("invalid hashrate unit"); } } if (!bIncomeInBTC) { Console.WriteLine(p.ProfitOnInterval(interval, hashrate, reward, (decimal)diff).ToString("F8")); } else { decimal exchrate = 0; try { exchrate = (szSelectedCoin.ToLower() != "bitcoin") ? ei.GetExchangeRate((exchange != "") ? exchange : inf.Exchange, inf.Abbreviation) : 1; } catch { Console.WriteLine("Unable to fetch exchange rate"); return(-1); } Console.WriteLine(p.ProfitOnIntervalBTC(interval, hashrate, reward, (decimal)diff, exchrate).ToString("F8")); } return(0); }
void HandleCoinCleanup(CoinInfo InCoinInfo) { ThrowInfo TossResults = new ThrowInfo(); if (InCoinInfo.OurRoll && InCoinInfo.OurResizer) { TossResults.result = InCoinInfo.OurRoll.GetRollstate(); TossResults.radius = InCoinInfo.OurResizer.GetRadius(); TossResults.depth = InCoinInfo.OurResizer.GetDepth(); TossResults.hasValidData = true; switch (TossResults.result) { case RollState.Edge: NumEdge++; break; case RollState.Heads: NumHeads++; break; case RollState.Tails: NumTails++; break; } } else { if (!InCoinInfo.OurRoll) { Debug.LogError("Invalid Current Roll Component."); } if (!InCoinInfo.OurResizer) { Debug.LogError("Invalid Current Resizer Component."); } } if (TossResults.hasValidData) { Tosses.Add(TossResults); } else { Debug.LogError("Invalid Toss Data."); } if (InCoinInfo.OurCoin) { Destroy(InCoinInfo.OurCoin); CoinsInfo.Remove(InCoinInfo); } }
public static object ToResponse(this CoinInfo info) { return new { symbol = info.ExchangeSymbol.GlobalSymbol, currency = info.Currency.ToString(), prices = info.ExchangePrices.Select( x => new { exchanger = x.Exchanger.ToString(), lastPrice = x.LastPrice, percent = x.Percent }) }; }
// This overload of PopulateFromJson populates the basic elements of a single CoinInformation object, // as deserialized from CryptoCompare.com API's coinlist call public static void PopulateFromJson(this CoinInformation coinInformation, CoinInfo coin) { coinInformation.Id = coin.Id; coinInformation.Symbol = coin.Name; coinInformation.Algorithm = coin.Algorithm; coinInformation.CoinName = coin.CoinName; coinInformation.FullName = coin.FullName; coinInformation.FullyPremined = coin.FullyPremined; coinInformation.ImageUrl = coin.ImageUrl; coinInformation.PreMinedValue = coin.PreMinedValue; coinInformation.ProofType = coin.ProofType; coinInformation.SortOrder = coin.SortOrder; coinInformation.TotalCoinsFreeFloat = coin.TotalCoinsFreeFloat; coinInformation.TotalCoinSupply = coin.TotalCoinSupply; coinInformation.Url = coin.Url; }
/// <summary> /// This method processes the request to show coin effect. /// </summary> /// <param name="coinInfo">The CoinInfo from which to take the /// info from to show the coin effect, /// of type CoinInfo</param> private void ProcessCoinRequest(CoinInfo coinInfo) { // Requesting a font effect UIDamageFontManager.Instance .RequestDamageFont(transform.position, coinInfo.Amount >= 0 ? coinInfo.Amount : coinInfo.Amount * -1, coinInfo.FontColour); _coins += coinInfo.Amount; // Adding the amount to the coin, // The amount is both + or - // Updating the the player coin value in the UI UIInGameUIController.Instance.SetPlayerCoins(_coins); _isProcessing = false; // Processing is done }
public async Task <bool> UpdateCoinInfo(CoinInfo coinInfo) { try { ReplaceOneResult actionResult = await _context.CoinInfo .ReplaceOneAsync(n => n.Id.Equals(coinInfo.Id) , coinInfo , new UpdateOptions { IsUpsert = true }); return(actionResult.IsAcknowledged && actionResult.ModifiedCount > 0); } catch (Exception ex) { throw ex; } }
// load data into form private void cbCoinType_SelectedIndexChanged(object sender, EventArgs e) { ExchangeInformation ei = new ExchangeInformation(); CoinInformation ci = new CoinInformation(); lblUpdating.Visible = true; this.Refresh(); string szCoinType = cbCoinType.Items[cbCoinType.SelectedIndex].ToString(); CoinInfo i = rs.Coins[szCoinType]; lblAbbrev.Text = lblRewardCurrency.Text = i.Abbreviation; lblExchangeRateCurrency.Text = "BTC/" + i.Abbreviation; try { tbDifficulty.Text = ci.GetDifficulty(i.ExplorerType, i.ExplorerBaseURL, i.ExplorerChain, i.Abbreviation).ToString(); } catch { tbDifficulty.Text = "Unavailable"; } try { tbReward.Text = ci.GetReward(i.ExplorerType, i.ExplorerBaseURL, i.ExplorerChain, i.Abbreviation).ToString(); } catch { tbReward.Text = "Unavailable"; } for (int c = 0; c < cbHashrateUnit.Items.Count; c++) { if (((Item)cbHashrateUnit.Items[c]).Name == i.DefaultHashRateUnit) { cbHashrateUnit.SelectedIndex = c; } } try { if (i.Exchange != null) { tbExchangeRate.Text = ei.GetExchangeRate(i.Exchange, i.Abbreviation).ToString(); } else { tbExchangeRate.Text = ""; } } catch { tbExchangeRate.Text = "Unavailable"; } if (cbCoinType.Items[cbCoinType.SelectedIndex].ToString().ToLower() == "bitcoin") // case-insensitive for Mono compatibility { tbExchangeRate.Text = "1"; } tbHashrate.Text = i.DefaultHashRate; lblUpdating.Visible = false; this.Refresh(); OnChanged(); }
public void AddCoinToUser(Vector3 t_CoinSpawnPosition, Vector3 t_InitialPositionDisplacement = new Vector3(), Vector3 t_InitialDirection = new Vector3(), double t_Multiplier = 1, bool t_ByPassCoinSpawningRule = false) { double t_CoinToBeAdded = m_CoinEarnStateForLevel * t_Multiplier * (globalMonetizationStateControllerReference != null ? (globalMonetizationStateControllerReference.IsCoinEarnBoostEnabled() ? 2f : 1f) : 1f); m_NumberOfCoinStackedToUpdateInUI += t_CoinToBeAdded; if (!isMoveTowardsHUD) { m_NumberOfCoinEarnedOnThisLevel += t_CoinToBeAdded; GameManager.Instance.UpdateInGameCurrencyAnimated(t_CoinToBeAdded); //UIStateController.Instance.UIGameplayMenuControllerReference.UpdateCoinEarnForLevel (m_NumberOfCoinEarnedOnThisLevel); } if (m_IsCoinEarnAllow || t_ByPassCoinSpawningRule) { GameObject t_NewCoin = coinContainer.PullPreloadedPrefab(); Transform t_NewCoinTransform = t_NewCoin.transform; t_NewCoinTransform.position = t_CoinSpawnPosition; t_NewCoinTransform.eulerAngles = t_InitialDirection; t_NewCoinTransform.localScale = Vector3.zero; CoinInfo t_NewCoinInfo = new CoinInfo() { isInitialDisplacementComplete = animationPosition == Vector3.zero ? true : false, amountOfCoinToBeAdded = m_NumberOfCoinStackedToUpdateInUI, coinContainerTransformReference = t_NewCoinTransform, initialPositionOfDisplacement = t_CoinSpawnPosition + t_InitialPositionDisplacement, initialDistanceFromDisplacement = Vector3.Distance(t_CoinSpawnPosition, t_CoinSpawnPosition + t_InitialPositionDisplacement), initialDistanceFromDisplacementToTarget = isMoveTowardsHUD ? Vector3.Distance(t_CoinSpawnPosition + t_InitialPositionDisplacement + animationPosition, coinHUDTransformReference.position) : Vector3.Distance(t_CoinSpawnPosition, t_CoinSpawnPosition + animationPosition) }; //Debug.Log("Initial Displacement : " + (animationPosition == Vector3.zero ? Vector3.Distance(t_CoinSpawnPosition + t_InitialPositionDisplacement, isMoveTowardsHUD ? coinHUDTransformReference.position : t_CoinSpawnPosition) : Vector3.Distance(t_CoinSpawnPosition, t_CoinSpawnPosition + t_InitialPositionDisplacement))); m_ListOfCoinInfo.Add(t_NewCoinInfo); m_CurrentBufferTimeForCoinEarn = m_BufferTimeForCoinEarn; m_NumberOfCoinStackedToUpdateInUI = 0; m_IsCoinEarnAllow = false; } }
private void button1_Click(object sender, EventArgs e) { CoinInfo coin = coinInfoControl1.GetData(); onlineMarket1.LoadData(ServersLocation, coin.Algorithm, coinInfoControl1.ProfitablePrice); }
public Inventory(CoinInfo playerCoinInfo, int CoinCount) { this.playerCoinInfo = playerCoinInfo; this.InventoryCoinCount = CoinCount; }
void OnTriggerEnter(Collider other) { if (other.tag == "Obstacles" && other.name == "ObstacleGenTriggerer" && !firstObstacleSpawned) { firstObstacleSpawned = true; LevelSpawnManager.Instance.SpawnObstacles(); } else if (other.tag == "Coin" && !disableCoinTrigger) { other.GetComponent <Renderer>().enabled = false; other.GetComponent <Collider>().enabled = false; other.transform.Find("CoinParticle").gameObject.GetComponent <ParticleSystem>().Play(); CoinInfo info = other.transform.gameObject.GetComponent <CoinInfo>(); if (info != null) { LevelManager.Instance.CoinGathered(info.coinValue); } AudioSource.PlayClipAtPoint(coinAudioEffect, Vector3.up, SoundManager.Instance.audioVolume); } else if (other.tag == "Letter" && !disableLetterTrigger) { LetterInfo letterInfo = other.gameObject.GetComponent <LetterInfo>(); string dailyWord = DailyWordManager.Instance.GetDailyWord(); string completedWord = PreferencesManager.Instance.GetCompletedWord(); int dailyWordIndex = dailyWord.IndexOf(letterInfo.letter); if (dailyWordIndex > -1 && completedWord[dailyWordIndex] == '-') { completedWord = completedWord.Insert(dailyWordIndex, letterInfo.letter.ToString()).Remove(dailyWordIndex + 1, 1); } else { int i = 0; while ((i = dailyWord.IndexOf(letterInfo.letter, i)) != -1) { dailyWordIndex = i; if (completedWord[dailyWordIndex] == '-') { completedWord = completedWord.Insert(dailyWordIndex, letterInfo.letter.ToString()).Remove(dailyWordIndex + 1, 1); break; } i++; } } AudioSource.PlayClipAtPoint(wordsAudioEffect, Vector3.up, SoundManager.Instance.audioVolume); PreferencesManager.Instance.SetCompletedWord(completedWord); other.GetComponent <Renderer>().enabled = false; other.GetComponent <Collider>().enabled = false; } else if (other.tag == "Enemy" && !disableEnemyTrigger) { if (!isFalling && canCrash && !shieldPowerupEnabled) { isFalling = true; DisablePlayerControls(); } else if (shieldPowerupEnabled && !speedPowerupEnabled) { StartCoroutine(DisableShield()); } PlayExplosion(other.transform); } else if (other.tag == "PowerUps" && !disablePowerUpTrigger) { String collidedPowerup = other.transform.name; if (shieldPowerupEnabled && !speedPowerupEnabled && !collidedPowerup.Equals("Shield")) { StartCoroutine(DisableShield()); } if (forcedPowerup != String.Empty) { collidedPowerup = forcedPowerup; } switch (collidedPowerup) { case "Speed": ActivateSpeed(); break; case "DoubleBitcoin": ActivateDoubleBitcoin(); break; case "CoinMagnet": ActivateCoinMagnet(); break; case "Flinger": ActivateFlinger(); break; case "LongJump": ActivateLongJump(); break; case "Shield": ActivateShield(); break; case "SecondChance": ActivateSecondChance(); break; case "ObstacleBlaster": ActivateObstacleBlaster(); break; } other.GetComponent <Powerup>().ResetObject(); } }
public Task <string> GetAddressAsync(IAddressPath addressPath, bool isPublicKey, bool display, CoinInfo coinInfo) { var inputScriptType = coinInfo.IsSegwit ? InputScriptType.Spendp2shwitness : InputScriptType.Spendaddress; return(GetAddressAsync(addressPath, isPublicKey, display, coinInfo.AddressType, inputScriptType, coinInfo.CoinName)); }
public CryptoItemModel(CoinInfo info, CoinFullAggregatedData aggregatedData) { this.Info = info; this.AggregatedData = aggregatedData; }
public async Task <CryptoItemModel> Construct(CoinInfo coinInstance) => await GetCryptoItemModel(coinInstance);
public async Task <IActionResult> Info() { CoinInfo ret = await statsHandler.CoinInformation(); return(Ok(ret)); }
void Start() { this.coin = GameObject.Find("coin"); CoinInfo.instance = this; }
public Task <string> GetAddressAsync(IAddressPath addressPath, bool isPublicKey, bool display, CoinInfo coinInfo) { if (coinInfo == null) { throw new ArgumentNullException(nameof(coinInfo)); } var inputScriptType = coinInfo.IsSegwit ? InputScriptType.Spendp2shwitness : InputScriptType.Spendaddress; return(GetAddressAsync(addressPath, isPublicKey, display, coinInfo.AddressType, inputScriptType, coinInfo.CoinName)); }
private void button2_Click(object sender, EventArgs e) { _data = Nicehash.CoinwarzApi.GetCoinInfo("DASH"); }
public CoinInfo GetData() { _data = _data ?? SampleData; DisplaData(); return(_data); }
public async Task <CoinInfo> CoinInformation() { long index = storage.GetLatestBlock()?.BlockIndex ?? 0; //SyncConnection connection = syncConnection; //BitcoinClient client = CryptoClientFactory.Create(connection.ServerDomain, connection.RpcAccessPort, connection.User, connection.Password, connection.Secure); var coinInfo = new CoinInfo { BlockHeight = index, Name = chainConfiguration.Name, Symbol = chainConfiguration.Symbol, Description = chainConfiguration.Description, Url = chainConfiguration.Url, Logo = chainConfiguration.Logo, Icon = chainConfiguration.Icon }; Statistics statitics = await Statistics(); coinInfo.Node = statitics; // If we have network type available, we'll extend with extra metadata. if (syncConnection.HasNetworkType) { Network network = syncConnection.Network; IConsensus consensus = network.Consensus; coinInfo.Configuration = new NetworkInfo { DefaultAPIPort = network.DefaultAPIPort, DefaultMaxInboundConnections = network.DefaultMaxInboundConnections, DefaultMaxOutboundConnections = network.DefaultMaxOutboundConnections, DefaultPort = network.DefaultPort, DefaultRPCPort = network.DefaultRPCPort, DNSSeeds = network.DNSSeeds.Select(s => s.Host).ToList(), FallbackFee = network.FallbackFee, GenesisDate = UnixUtils.UnixTimestampToDate(network.GenesisTime).ToUniversalDateTime(), // Returns Kind.Unspecified, so translate. GenesisHash = network.GenesisHash.ToString(), MinRelayTxFee = network.MinRelayTxFee, MinTxFee = network.MinTxFee, Name = network.Name, NetworkType = network.NetworkType, SeedNodes = network.SeedNodes.Select(s => s.Endpoint.ToString()).ToList(), Consensus = new ConsensusInfo { CoinbaseMaturity = consensus.CoinbaseMaturity, MaxReorgLength = consensus.MaxReorgLength, CoinType = consensus.CoinType, IsProofOfStake = consensus.IsProofOfStake, LastPOWBlock = consensus.LastPOWBlock, MaxMoney = consensus.MaxMoney, PremineReward = consensus.PremineReward.ToUnit(NBitcoin.MoneyUnit.BTC), ProofOfStakeReward = consensus.ProofOfStakeReward.ToUnit(NBitcoin.MoneyUnit.BTC), ProofOfWorkReward = consensus.ProofOfWorkReward.ToUnit(NBitcoin.MoneyUnit.BTC), TargetSpacing = consensus.TargetSpacing } }; } return(coinInfo); }