Exemplo n.º 1
0
        public void TestMarketOrderPartialFill()
        {
            InitExchange();

            var baseSymbol  = DomainSettings.StakingTokenSymbol;
            var quoteSymbol = maxDivTokenSymbol;

            var buyer  = new ExchangeUser(baseSymbol, quoteSymbol);
            var seller = new ExchangeUser(baseSymbol, quoteSymbol);

            buyer.FundQuoteToken(quantity: 2m, fundFuel: true);
            seller.FundBaseToken(quantity: 2m, fundFuel: true);

            seller.OpenLimitOrder(0.2m, 1m, Sell);
            Assert.IsTrue(buyer.OpenMarketOrder(0.3m, Buy) == 0.2m, "");
        }
Exemplo n.º 2
0
        public void TestMarketOrderTotalFillNoOrderbookWipe()
        {
            InitExchange();

            var baseSymbol  = Nexus.StakingTokenSymbol;
            var quoteSymbol = maxDivTokenSymbol;

            var buyer  = new ExchangeUser(baseSymbol, quoteSymbol);
            var seller = new ExchangeUser(baseSymbol, quoteSymbol);

            buyer.FundQuoteToken(quantity: 2m, fundFuel: true);
            seller.FundBaseToken(quantity: 2m, fundFuel: true);

            seller.OpenLimitOrder(0.1m, 1m, Sell);
            seller.OpenLimitOrder(0.1m, 2m, Sell);
            Assert.IsTrue(buyer.OpenMarketOrder(0.25m, Buy) == 0.175m, "");
        }
Exemplo n.º 3
0
        public void TestIoCLimitOrderUnmatched()
        {
            InitExchange();

            var baseSymbol  = DomainSettings.StakingTokenSymbol;
            var quoteSymbol = maxDivTokenSymbol;

            var buyer  = new ExchangeUser(baseSymbol, quoteSymbol);
            var seller = new ExchangeUser(baseSymbol, quoteSymbol);

            buyer.FundQuoteToken(quantity: 2m, fundFuel: true);
            seller.FundBaseToken(quantity: 2m, fundFuel: true);

            //-----------------------------------------
            //test unmatched IoC orders
            seller.OpenLimitOrder(0.01m, 0.5m, Sell);
            buyer.OpenLimitOrder(0.01m, 0.1m, Buy);
            Assert.IsTrue(buyer.OpenLimitOrder(0.123m, 0.3m, Buy, IoC: true) == 0, "Shouldn't have filled any part of the order");
            Assert.IsTrue(seller.OpenLimitOrder(0.123m, 0.3m, Sell, IoC: true) == 0, "Shouldn't have filled any part of the order");
        }
Exemplo n.º 4
0
        public void TestIoCLimitOrderCompleteFulfilment()
        {
            InitExchange();

            var baseSymbol  = DomainSettings.StakingTokenSymbol;
            var quoteSymbol = maxDivTokenSymbol;

            var buyer  = new ExchangeUser(baseSymbol, quoteSymbol);
            var seller = new ExchangeUser(baseSymbol, quoteSymbol);

            buyer.FundQuoteToken(quantity: 2m, fundFuel: true);
            seller.FundBaseToken(quantity: 2m, fundFuel: true);

            //-----------------------------------------
            //test fully matched IoC orders
            buyer.OpenLimitOrder(0.1m, 1m, Buy, IoC: false);
            Assert.IsTrue(seller.OpenLimitOrder(0.1m, 1m, Sell, IoC: true) == 0.1m, "Unexpected amount of tokens received");

            seller.OpenLimitOrder(0.1m, 1m, Sell, IoC: false);
            Assert.IsTrue(buyer.OpenLimitOrder(0.1m, 1m, Buy, IoC: true) == 0.1m, "Unexpected amount of tokens received");
        }
Exemplo n.º 5
0
        public void TestLimitMinimumQuantity()
        {
            InitExchange();

            var baseSymbol  = DomainSettings.StakingTokenSymbol;
            var quoteSymbol = maxDivTokenSymbol;

            var buyer  = new ExchangeUser(baseSymbol, quoteSymbol);
            var seller = new ExchangeUser(baseSymbol, quoteSymbol);

            buyer.FundQuoteToken(quantity: 2m, fundFuel: true);
            seller.FundBaseToken(quantity: 2m, fundFuel: true);

            //-----------------------------------------
            //test order amount and prices at the limit

            var minimumBaseToken  = UnitConversion.ToDecimal(simulator.Nexus.RootChain.InvokeContract(simulator.Nexus.RootStorage, "exchange", "GetMinimumTokenQuantity", buyer.baseToken).AsNumber(), buyer.baseToken.Decimals);
            var minimumQuoteToken = UnitConversion.ToDecimal(simulator.Nexus.RootChain.InvokeContract(simulator.Nexus.RootStorage, "exchange", "GetMinimumTokenQuantity", buyer.quoteToken).AsNumber(), buyer.baseToken.Decimals);

            buyer.OpenLimitOrder(minimumBaseToken, minimumQuoteToken, Buy);
            seller.OpenLimitOrder(minimumBaseToken, minimumQuoteToken, Sell);
        }