func: function settleRing(
          TokenTransferDelegate delegate,
          uint          ringSize,
          OrderState[]  orders,
          address       feeRecipient,
          address       _lrcTokenAddress
          )
          private
          returns (bytes32[] memory orderInfoList)
      {
          bytes32[] memory batch = new bytes32[](ringSize * 7); 
          bytes32[] memory historyBatch = new bytes32[](ringSize * 2); 
          orderInfoList = new bytes32[](ringSize * 7);
          uint p = 0;
          uint q = 0;
          uint r = 0;
          uint prevSplitB = orders[ringSize - 1].splitB;
          for (uint i = 0; i < ringSize; i++) {
              OrderState memory state = orders[i];
              uint nextFillAmountS = orders[(i + 1) % ringSize].fillAmountS;
              
              batch[p++] = bytes32(state.owner);
              batch[p++] = bytes32(state.tokenS);
              
              batch[p++] = bytes32(state.fillAmountS.sub(prevSplitB));
              batch[p++] = bytes32(prevSplitB.add(state.splitS));
              batch[p++] = bytes32(state.lrcReward);
              batch[p++] = bytes32(state.lrcFeeState);
              batch[p++] = bytes32(state.wallet);
              historyBatch[r++] = state.orderHash;
              historyBatch[r++] = bytes32(
                  state.buyNoMoreThanAmountB ? nextFillAmountS : state.fillAmountS);
              orderInfoList[q++] = bytes32(state.orderHash);
              orderInfoList[q++] = bytes32(state.owner);
              orderInfoList[q++] = bytes32(state.tokenS);
              orderInfoList[q++] = bytes32(state.fillAmountS);
              orderInfoList[q++] = bytes32(state.lrcReward);
              orderInfoList[q++] = bytes32(
                  state.lrcFeeState > 0 ? int(state.lrcFeeState) : -int(state.lrcReward)
              );
              orderInfoList[q++] = bytes32(
                  state.splitS > 0 ? int(state.splitS) : -int(state.splitB)
              );
              prevSplitB = state.splitB;
          }
          
          delegate.batchAddCancelledOrFilled(historyBatch);
          
          delegate.batchTransferToken(
              _lrcTokenAddress,
              tx.origin,
              feeRecipient,
              walletSplitPercentage,
              batch
          );
      }