Example #1
0
        public Bet(IBetBonus bonus, IStake stake, IStake entireStake, string id, IEnumerable <int> selectedSystems, IEnumerable <ISelection> selections, string reofferRefId, long sumOfWins, bool?customBet, int?calculationOdds)
        {
            Guard.Argument(stake, nameof(stake)).NotNull();
            Guard.Argument(id, nameof(id)).Require(string.IsNullOrEmpty(id) || TicketHelper.ValidateTicketId(id));
            var systems = selectedSystems == null ? new List <int>() : selectedSystems.ToList();

            Guard.Argument(systems, nameof(systems)).Require(selectedSystems == null ||
                                                             (systems.Any()
                                                              //&& systems.Count < 64
                                                              && systems.Count == systems.Distinct().Count() &&
                                                              systems.All(a => a > 0)));
            var listSelections = selections.ToList();

            Guard.Argument(listSelections, nameof(listSelections)).NotNull();
            if (!listSelections.Any())
            {
                throw new ArgumentOutOfRangeException(nameof(selections));
            }
            Guard.Argument(listSelections, nameof(listSelections)).Require(/*listSelections.Count < 64 && */ listSelections.Count == listSelections.Distinct().Count());

            Guard.Argument(reofferRefId, nameof(reofferRefId)).Require(string.IsNullOrEmpty(reofferRefId) || reofferRefId.Length <= 50);
            Guard.Argument(sumOfWins, nameof(sumOfWins)).NotNegative();
            bool customBetBool = customBet ?? false;

            Guard.Argument(customBet, nameof(customBet)).Require((customBetBool && calculationOdds != null && calculationOdds >= 0) || (!customBetBool && calculationOdds == null));

            Bonus           = bonus;
            Stake           = stake;
            EntireStake     = entireStake;
            Id              = id;
            SelectedSystems = systems;
            Selections      = listSelections;
            ReofferRefId    = reofferRefId;
            SumOfWins       = sumOfWins;
            CustomBet       = customBet;
            CalculationOdds = calculationOdds;

            if (SelectedSystems != null)
            {
                var enumerable = SelectedSystems as IList <int> ?? SelectedSystems.ToList();
                if (SelectedSystems != null && enumerable.Any(a => a > Selections.Count()))
                {
                    throw new ArgumentException("Invalid value in SelectedSystems.");
                }
            }
        }
 protected ApiStake MapStake(IStake stake)
 {
     return(new ApiStake()
     {
         Name = stake.Name,
         DisplayName = stake.DisplayName,
         Category = stake.Category,
         Description = stake.Description,
         Token = new ApiToken()
         {
             Symbol = stake.Token.Symbol,
             Address = stake.Token.ContractAddress,
             Decimals = stake.Token.Decimals
         },
         CirculatingSupply = stake.CirculatingSupply,
         StakingAddress = stake.StakingAddress,
         Power = MapStakingPower(stake.Power),
         FundMultipliers = stake.FundMultipliers,
         TimeMultipliers = stake.TimeMultipliers
                           .Select(tm => new ApiTimeMultiplier()
         {
             RangeMin = tm.RangeMin,
             RangeMax = tm.RangeMax,
             Multiplier = tm.Multiplier
         })
                           .ToList(),
         Market = MapMarket(stake.Market),
         Links = new ApiStakeLinks()
         {
             [nameof(ApiStakeLinks.Self)] = new Uri(AppSettings.HostUrl.OriginalString.TrimEnd('/') + $"/api/v1/stakes/{stake.Token.Symbol}", UriKind.Absolute),
             ["Pool"] = stake.PoolUri,
             [nameof(ApiStakeLinks.Fact)] = stake.FactSheetUri,
             [nameof(ApiStakeLinks.External)] = stake.InvictusUri
         }
     });
 }
Example #3
0
 public Stake(IStake stake)
 {
     _value = stake.Value;
     _type  = stake.Type.HasValue ? MtsTicketHelper.ConvertStakeType(stake.Type.Value) : (StakeType?)null;
 }
Example #4
0
 /// <summary>
 /// Sets the <see cref="IStake" />
 /// </summary>
 /// <param name="value">The quantity multiplied by 10000 and rounded to a long value</param>
 /// <param name="stakeType">Type of the stake</param>
 /// <returns>Returns a <see cref="IBetBuilder" /></returns>
 public IBetBuilder SetEntireStake(long value, StakeType stakeType)
 {
     _entireStake = new Stake(value, stakeType);
     return(this);
 }
Example #5
0
 /// <summary>
 /// Sets the <see cref="IStake" />
 /// </summary>
 /// <param name="value">The quantity multiplied by 10000 and rounded to a long value</param>
 /// <param name="stakeType">Type of the stake</param>
 /// <returns>Returns a <see cref="IBetBuilder" /></returns>
 public IBetBuilder SetStake(long value, StakeType stakeType)
 {
     _stake = new Stake(value, stakeType);
     ValidateData(false, false, true);
     return(this);
 }
Example #6
0
 internal Wager(IBet <TResults> bet, TResults expectedResults, IStake stake)
 {
     _bet            = bet;
     ExpectedResults = expectedResults;
     Stake           = stake;
 }