    function _marketBuy(
        address _asset,
        address _quote,
        uint256 _maxFill
    ) internal {
        uint256 _fee = _maxFill.mul(rubiconMarket.getFeeBPS()).div(10000);
        uint256 _buyAmount = rubiconMarket.getBuyAmount(
            ERC20(_asset),
            ERC20(_quote),
            _maxFill.sub(_fee)
        );
        IERC20(_quote).approve(address(rubiconMarket), _maxFill);

        rubiconMarket.buyAllAmount(
            ERC20(_asset),
            _buyAmount,
            ERC20(_quote),
            _maxFill
        );
    }
    function _marketSell(
        address _asset,
        address _quote,
        uint256 _minFill
    ) internal {
        uint256 _feeBPS = rubiconMarket.getFeeBPS();
        uint256 _fee = _minFill.mul(_feeBPS).div(10000);
        uint256 _payAmount = rubiconMarket.getPayAmount(
            ERC20(_asset),
            ERC20(_quote),
            _minFill.add(_fee)
        );
        uint256 _assetBalance = IERC20(_asset).balanceOf(address(this));

        /// @dev recalculate fee in _asset form
        _fee = _payAmount.mul(_feeBPS).div(10000);

        if (_assetBalance < _payAmount) {
            IERC20(_asset).transferFrom(
                msg.sender,
                address(this),
                _payAmount.sub(_assetBalance).add(_fee)
            );
        }

        IERC20(_asset).approve(
            address(rubiconMarket),
            IERC20(_asset).balanceOf(address(this))
        );

        rubiconMarket.sellAllAmount(
            ERC20(_asset),
            _payAmount,
            ERC20(_quote),
            _minFill
        );
    }
    function buy(
        uint256 id,
        uint256 quantity
    ) public virtual can_buy(id) synchronized returns (bool) {
        OfferInfo memory _offer = offers[id];
        uint256 spend = mul(quantity, _offer.buy_amt) / _offer.pay_amt;

        require(uint128(spend) == spend, "spend is not an int");
        require(uint128(quantity) == quantity, "quantity is not an int");

        ///@dev For backwards semantic compatibility.
        if (
            quantity == 0 ||
            spend == 0 ||
            quantity > _offer.pay_amt ||
            spend > _offer.buy_amt
        ) {
            return false;
        }

        offers[id].pay_amt = sub(_offer.pay_amt, quantity);
        offers[id].buy_amt = sub(_offer.buy_amt, spend);

        /// @dev Fee logic added on taker trades
        uint256 fee = mul(spend, feeBPS) / 100_000;
        require(
            _offer.buy_gem.transferFrom(msg.sender, feeTo, fee),
            "Insufficient funds to cover fee"
        );
        ...
    }
      it.only("changes of quote and asset tokens when Position._marketBuy function calculates _fee through dividing by 10000", async function () {
        const { owner, testCoin, testStableCoin, Position} =
          await loadFixture(deployPoolsUtilityFixture);

        // testCoin is quote token when calling Position.buyAllAmountWithLeverage function
        const ownerTestCoinBalanceBefore = await testCoin.balanceOf(owner.address);

        // testStableCoin is asset token when calling Position.buyAllAmountWithLeverage function
        const ownerTestStableCoinBefore = await testStableCoin.balanceOf(owner.address);

        // owner calls Position.buyAllAmountWithLeverage function
        await Position.connect(owner).buyAllAmountWithLeverage(
          testCoin.address,
          testStableCoin.address,
          TEST_AMOUNT,
          x1_25
        );

        // owner sends 25000000000000000000 quote tokens
        const ownerTestCoinBalanceAfter = await testCoin.balanceOf(owner.address);
        expect(ownerTestCoinBalanceAfter.sub(ownerTestCoinBalanceBefore)).to.equal(-25000000000000000000n);

        // owner receives 5624437 asset tokens
        const ownerTestStableCoinAfter = await testStableCoin.balanceOf(owner.address);
        expect(ownerTestStableCoinAfter.sub(ownerTestStableCoinBefore)).to.equal(5624437);
      });
    function _marketBuy(
        address _asset,
        address _quote,
        uint256 _maxFill
    ) internal {
        /** @audit divide by 100_000 for POC purpose */
        // uint256 _fee = _maxFill.mul(rubiconMarket.getFeeBPS()).div(10000);
        uint256 _fee = _maxFill.mul(rubiconMarket.getFeeBPS()).div(100_000);
        /** */

        uint256 _buyAmount = rubiconMarket.getBuyAmount(
            ERC20(_asset),
            ERC20(_quote),
            _maxFill.sub(_fee)
        );
        IERC20(_quote).approve(address(rubiconMarket), _maxFill);

        rubiconMarket.buyAllAmount(
            ERC20(_asset),
            _buyAmount,
            ERC20(_quote),
            _maxFill
        );
    }
      it.only("changes of quote and asset tokens when Position._marketBuy function calculates _fee through dividing by 100_000", async function () {
        const { owner, testCoin, testStableCoin, Position} =
          await loadFixture(deployPoolsUtilityFixture);

        // testCoin is quote token when calling Position.buyAllAmountWithLeverage function
        const ownerTestCoinBalanceBefore = await testCoin.balanceOf(owner.address);

        // testStableCoin is asset token when calling Position.buyAllAmountWithLeverage function
        const ownerTestStableCoinBefore = await testStableCoin.balanceOf(owner.address);

        // owner calls Position.buyAllAmountWithLeverage function
        await Position.connect(owner).buyAllAmountWithLeverage(
          testCoin.address,
          testStableCoin.address,
          TEST_AMOUNT,
          x1_25
        );

        // owner still sends 25000000000000000000 quote tokens
        const ownerTestCoinBalanceAfter = await testCoin.balanceOf(owner.address);
        expect(ownerTestCoinBalanceAfter.sub(ownerTestCoinBalanceBefore)).to.equal(-25000000000000000000n);

        // yet, owner receives 5624943 asset tokens
        const ownerTestStableCoinAfter = await testStableCoin.balanceOf(owner.address);
        expect(ownerTestStableCoinAfter.sub(ownerTestStableCoinBefore)).to.equal(5624943);

        // owner receives more asset tokens in this situation than when Position._marketBuy function calculates _fee through dividing by 10000
        expect(5624943).to.be.gt(5624437);
      });
