public override TransactionInfoEx GetTransaction(TransactionBlock previousBlock)
        {
            var chgs = GetBalanceChanges(previousBlock);

            if (chgs.Changes.Count > 1)
            {
                throw new System.Exception("Obslete: Multiple token send not supported. use GetBalanceChanges instead.");
            }

            var transaction = new TransactionInfoEx()
            {
                TokenCode = LyraGlobal.OFFICIALTICKERCODE, Amount = 0, FeeAmount = 0, FeeCode = null
            };

            // let's find te balance that was changed since the previous block - to determine the token being transacted
            foreach (var balance in this.Balances)
            {
                if (previousBlock != null)
                {
                    if (!previousBlock.Balances.ContainsKey(balance.Key) || previousBlock.Balances[balance.Key] != balance.Value)
                    {
                        transaction.TokenCode = balance.Key;

                        if (!previousBlock.Balances.ContainsKey(balance.Key))
                        {
                            transaction.Amount = this.Balances[balance.Key].ToBalanceDecimal();
                        }
                        else
                        {
                            transaction.Amount = (this.Balances[balance.Key] - previousBlock.Balances[balance.Key]).ToBalanceDecimal();
                        }

                        break;
                    }
                }
                else
                {
                    transaction.TokenCode = balance.Key;
                    transaction.Amount    = this.Balances[balance.Key].ToBalanceDecimal();
                    break;
                }
            }

            //// if no token is being transfered, it's default token (like LYR ot LGT depending on configuration) itself
            //if (transaction.Token == LyraGlobal.LYRA_TICKER_CODE)
            //transaction.Amount = this.Balances[LyraGlobal.LYRA_TICKER_CODE] - previousBlock.Balances[LyraGlobal.LYRA_TICKER_CODE];
            transaction.TotalBalanceChange = transaction.Amount;

            return(transaction);
        }
示例#2
0
        public override TransactionInfoEx GetTransaction(TransactionBlock previousBlock)
        {
            var chgs = GetBalanceChanges(previousBlock);

            if (chgs.Changes.Count > 1)
            {
                throw new System.Exception("Obslete: Multiple token send not supported. use GetBalanceChanges instead.");
            }

            // previous block cannot be null for send block as you have to have something to send
            if (previousBlock == null)
            {
                return(null);
            }

            var transaction = new TransactionInfoEx()
            {
                TokenCode = LyraGlobal.OFFICIALTICKERCODE, Amount = 0
            };

            // let's find te balance that was changed since the previous block - to determine the token being transacted
            foreach (var balance in this.Balances)
            {
                if (previousBlock.Balances[balance.Key] != balance.Value && balance.Key != LyraGlobal.OFFICIALTICKERCODE)
                {
                    transaction.TokenCode          = balance.Key;
                    transaction.Amount             = (previousBlock.Balances[balance.Key] - this.Balances[balance.Key]).ToBalanceDecimal();
                    transaction.TotalBalanceChange = transaction.Amount;
                    break;
                }
            }

            // if no token is being transfered, it's default token (like LYR ot LGT depending on configuration) itself
            if (transaction.TokenCode == LyraGlobal.OFFICIALTICKERCODE)
            {
                transaction.Amount             = (previousBlock.Balances[LyraGlobal.OFFICIALTICKERCODE] - this.Balances[LyraGlobal.OFFICIALTICKERCODE] - this.Fee.ToBalanceLong()).ToBalanceDecimal();
                transaction.TotalBalanceChange = transaction.Amount + this.Fee;
            }

            transaction.FeeCode   = this.FeeCode;
            transaction.FeeAmount = this.Fee;

            return(transaction);
        }
示例#3
0
        public override TransactionInfoEx GetTransaction(TransactionBlock previousBlock)
        {
            var transaction = new TransactionInfoEx()
            {
                TokenCode = LyraGlobal.OFFICIALTICKERCODE, Amount = 0, FeeAmount = 0, FeeCode = null
            };

            // let's find te balance that was changed since the previous block - to determine the token being transacted
            foreach (var balance in this.Balances)
            {
                if (previousBlock != null)
                {
                    if (!previousBlock.Balances.ContainsKey(balance.Key) || previousBlock.Balances[balance.Key] != balance.Value)
                    {
                        transaction.TokenCode = balance.Key;

                        if (!previousBlock.Balances.ContainsKey(balance.Key))
                        {
                            transaction.Amount = this.Balances[balance.Key];
                        }
                        else
                        {
                            transaction.Amount = this.Balances[balance.Key] - previousBlock.Balances[balance.Key];
                        }

                        break;
                    }
                }
                else
                {
                    transaction.TokenCode = balance.Key;
                    transaction.Amount    = this.Balances[balance.Key];
                    break;
                }
            }

            //// if no token is being transfered, it's default token (like LYR ot LGT depending on configuration) itself
            //if (transaction.Token == LyraGlobal.LYRA_TICKER_CODE)
            //transaction.Amount = this.Balances[LyraGlobal.LYRA_TICKER_CODE] - previousBlock.Balances[LyraGlobal.LYRA_TICKER_CODE];
            transaction.TotalBalanceChange = transaction.Amount;

            return(transaction);
        }
示例#4
0
        public override TransactionInfoEx GetTransaction(TransactionBlock previousBlock)
        {
            var transaction = new TransactionInfoEx();

            transaction.Amount    = SellAmount;
            transaction.TokenCode = SellTokenCode;
            transaction.FeeCode   = this.FeeCode;
            transaction.FeeAmount = this.Fee;

            if (transaction.FeeCode == transaction.TokenCode)
            {
                transaction.TotalBalanceChange = transaction.Amount + transaction.FeeAmount;
            }
            else
            {
                transaction.TotalBalanceChange = transaction.Amount;
            }
            return(transaction);
        }
示例#5
0
        public override TransactionInfoEx GetTransaction(TransactionBlock previousBlock)
        {
            // previous block cannot be null for send block as you have to have something to send
            if (previousBlock == null)
            {
                return(null);
            }

            var transaction = new TransactionInfoEx()
            {
                TokenCode = LyraGlobal.OFFICIALTICKERCODE, Amount = 0
            };

            // let's find te balance that was changed since the previous block - to determine the token being transacted
            foreach (var balance in this.Balances)
            {
                if (previousBlock.Balances[balance.Key] != balance.Value && balance.Key != LyraGlobal.OFFICIALTICKERCODE)
                {
                    transaction.TokenCode          = balance.Key;
                    transaction.Amount             = previousBlock.Balances[balance.Key] - this.Balances[balance.Key];
                    transaction.TotalBalanceChange = transaction.Amount;
                    break;
                }
            }

            // if no token is being transfered, it's default token (like LYR ot LGT depending on configuration) itself
            if (transaction.TokenCode == LyraGlobal.OFFICIALTICKERCODE)
            {
                transaction.Amount             = previousBlock.Balances[LyraGlobal.OFFICIALTICKERCODE] - this.Balances[LyraGlobal.OFFICIALTICKERCODE] - this.Fee;
                transaction.TotalBalanceChange = transaction.Amount + this.Fee;
            }

            transaction.FeeCode   = this.FeeCode;
            transaction.FeeAmount = this.Fee;

            return(transaction);
        }