public static SwapViewModel CreateSwapViewModel(ClientSwap swap)
        {
            var fromCurrency = CurrencyViewModelCreator.CreateViewModel(
                currency: swap.SoldCurrency,
                subscribeToUpdates: false);

            var toCurrency = CurrencyViewModelCreator.CreateViewModel(
                currency: swap.PurchasedCurrency,
                subscribeToUpdates: false);

            var fromAmount = AmountHelper.QtyToAmount(swap.Side, swap.Qty, swap.Price);
            var toAmount   = AmountHelper.QtyToAmount(swap.Side.Opposite(), swap.Qty, swap.Price);

            return(new SwapViewModel
            {
                Id = swap.Id.ToString(),
                CompactState = CompactStateBySwap(swap),
                Mode = ModeBySwap(swap),
                Time = swap.TimeStamp,

                FromBrush = new SolidColorBrush(fromCurrency.AmountColor),
                FromAmount = fromAmount,
                FromAmountFormat = fromCurrency.CurrencyFormat,
                FromCurrencyCode = fromCurrency.CurrencyCode,

                ToBrush = new SolidColorBrush(toCurrency.AmountColor),
                ToAmount = toAmount,
                ToAmountFormat = toCurrency.CurrencyFormat,
                ToCurrencyCode = toCurrency.CurrencyCode,

                Price = swap.Price,
                PriceFormat = $"F{swap.Symbol.Quote.Digits}"
            });
        }
Exemple #2
0
        private void DesignerMode()
        {
            var currencies = DesignTime.Currencies;

            FromCurrency          = currencies[0];
            ToCurrency            = currencies[1];
            FromCurrencyViewModel = CurrencyViewModelCreator.CreateViewModel(FromCurrency, false);
            ToCurrencyViewModel   = CurrencyViewModelCreator.CreateViewModel(ToCurrency, false);

            PriceFormat          = $"F{FromCurrency.Digits}";
            CurrencyCode         = FromCurrencyViewModel.CurrencyCode;
            CurrencyFormat       = FromCurrencyViewModel.CurrencyFormat;
            TargetCurrencyCode   = ToCurrencyViewModel.CurrencyCode;
            TargetCurrencyFormat = ToCurrencyViewModel.CurrencyFormat;
            BaseCurrencyCode     = FromCurrencyViewModel.BaseCurrencyCode;
            BaseCurrencyFormat   = FromCurrencyViewModel.BaseCurrencyFormat;

            EstimatedPrice = 0.003m;

            Amount       = 0.00001234m;
            AmountInBase = 10.23m;

            TargetAmount       = Amount / EstimatedPrice;
            TargetAmountInBase = AmountInBase;

            EstimatedPaymentFee       = 0.0001904m;
            EstimatedPaymentFeeInBase = 0.22m;

            EstimatedRedeemFee       = 0.001m;
            EstimatedRedeemFeeInBase = 0.11m;
        }
        private void DesignerMode()
        {
            FromCurrency          = Currencies.Btc;
            ToCurrency            = Currencies.Eth;
            FromCurrencyViewModel = CurrencyViewModelCreator.CreateViewModel(FromCurrency, false);
            ToCurrencyViewModel   = CurrencyViewModelCreator.CreateViewModel(ToCurrency, false);
            CurrencyCode          = FromCurrencyViewModel.CurrencyCode;
            CurrencyFormat        = FromCurrencyViewModel.CurrencyFormat;
            TargetCurrencyCode    = ToCurrencyViewModel.CurrencyCode;
            TargetCurrencyFormat  = ToCurrencyViewModel.CurrencyFormat;
            BaseCurrencyCode      = FromCurrencyViewModel.BaseCurrencyCode;
            BaseCurrencyFormat    = FromCurrencyViewModel.BaseCurrencyFormat;

            PriceFormat    = $"F{Symbols.EthBtc.Quote.Digits}";
            EstimatedPrice = 0.003m;

            Amount       = 0.00001234m;
            AmountInBase = 10.23m;

            TargetAmount       = Amount / EstimatedPrice;
            TargetAmountInBase = AmountInBase;

            Fee       = 0.0001m;
            FeeInBase = 8.43m;
        }
        public static SwapViewModel CreateSwapViewModel(ISwapState s)
        {
            if (s is SwapState swap)
            {
                var order = swap.Order;

                var fromCurrency = CurrencyViewModelCreator.CreateViewModel(
                    currency: order.SoldCurrency(),
                    subscribeToUpdates: false);

                var toCurrency = CurrencyViewModelCreator.CreateViewModel(
                    currency: order.PurchasedCurrency(),
                    subscribeToUpdates: false);

                var fromAmount = AmountHelper.QtyToAmount(order.Side, order.LastQty, order.LastPrice);
                var toAmount   = AmountHelper.QtyToAmount(order.Side.Opposite(), order.LastQty, order.LastPrice);

                return(new SwapViewModel
                {
                    Id = swap.Id.ToString(),
                    CompactState = CompactStateBySwap(swap),
                    Mode = ModeBySwap(swap),
                    Time = order.TimeStamp,

                    FromBrush = new SolidColorBrush(fromCurrency.AmountColor),
                    FromAmount = fromAmount,
                    FromAmountFormat = fromCurrency.CurrencyFormat,
                    FromCurrencyCode = fromCurrency.CurrencyCode,

                    ToBrush = new SolidColorBrush(toCurrency.AmountColor),
                    ToAmount = toAmount,
                    ToAmountFormat = toCurrency.CurrencyFormat,
                    ToCurrencyCode = toCurrency.CurrencyCode,

                    Price = order.LastPrice,
                    PriceFormat = $"F{order.Symbol.PriceDigits}"
                });
            }

            throw new NotSupportedException("Swap not supported");
        }
 private void DesignerMode()
 {
     CurrencyViewModel = CurrencyViewModelCreator.CreateViewModel(
         currency: DesignTime.Currencies.Get <Bitcoin>(),
         subscribeToUpdates: false);
 }