Beispiel #1
0
        public void Pow_Test()
        {
            var result1 = BancorHelpers.Pow(1.5m, 1);

            result1.ShouldBe(1.5m);

            BancorHelpers.Pow(1.5m, 2);
        }
Beispiel #2
0
        private long SellOperation(long paidRes)
        {
            var elfPayout = BancorHelpers.CalculateCrossConnectorReturn(
                CpuConverter.ResBalance, CpuConverter.ResWeight,
                CpuConverter.ElfBalance, CpuConverter.ElfWeight,
                paidRes);

            CpuConverter.ElfBalance -= elfPayout;
            CpuConverter.ResBalance += paidRes;

            return(elfPayout);
        }
Beispiel #3
0
        private long BuyOperation(long paidElf)
        {
            var resourcePayout = BancorHelpers.CalculateCrossConnectorReturn(
                CpuConverter.ElfBalance, CpuConverter.ElfWeight,
                CpuConverter.ResBalance, CpuConverter.ResWeight,
                paidElf);

            CpuConverter.ElfBalance += paidElf;
            CpuConverter.ResBalance -= resourcePayout;

            return(resourcePayout);
        }
 public long SellResourceToExchange(string resourceType, long paidRes)
 {
     checked
     {
         AssertCorrectResourceType(resourceType);
         var rt        = GetConverterKey(resourceType);
         var cvt       = State.Converters[rt];
         var elfPayout = BancorHelpers.CalculateCrossConnectorReturn(
             cvt.ResBalance, cvt.ResWeight,
             cvt.ElfBalance, cvt.ElfWeight,
             paidRes);
         cvt.ElfBalance      -= elfPayout;
         cvt.ResBalance      += paidRes;
         State.Converters[rt] = cvt;
         return(elfPayout);
     }
 }
 public long BuyResourceFromExchange(string resourceType, long paidElf)
 {
     checked
     {
         AssertCorrectResourceType(resourceType);
         var rt             = GetConverterKey(resourceType);
         var cvt            = State.Converters[GetConverterKey(resourceType)];
         var resourcePayout = BancorHelpers.CalculateCrossConnectorReturn(
             cvt.ElfBalance, cvt.ElfWeight,
             cvt.ResBalance, cvt.ResWeight,
             paidElf);
         cvt.ElfBalance      += paidElf;
         cvt.ResBalance      -= resourcePayout;
         State.Converters[rt] = cvt;
         return(resourcePayout);
     }
 }