@@ -425,42 +425,43 @@ contract LoopringProtocolImpl is LoopringProtocol {
425425 returns (uint [] memory orderInfoList )
426426 {
427427 bytes32 [] memory batch = new bytes32 [](ringSize * 7 ); // ringSize * (owner + tokenS + 4 amounts + wallet)
428+ bytes32 [] memory historyBatch = new bytes32 [](ringSize * 2 ); // ringSize * (orderhash, fillAmount)
428429 orderInfoList = new uint [](ringSize * 6 );
429430
430431 uint p = 0 ;
432+ uint q = 0 ;
433+ uint r = 0 ;
431434 uint prevSplitB = orders[ringSize - 1 ].splitB;
432435 for (uint i = 0 ; i < ringSize; i++ ) {
433436 OrderState memory state = orders[i];
434437 uint nextFillAmountS = orders[(i + 1 ) % ringSize].fillAmountS;
435438
436439 // Store owner and tokenS of every order
437- batch[p] = bytes32 (state.owner);
438- batch[p + 1 ] = bytes32 (state.tokenS);
440+ batch[p++ ] = bytes32 (state.owner);
441+ batch[p++ ] = bytes32 (state.tokenS);
439442
440443 // Store all amounts
441- batch[p + 2 ] = bytes32 (state.fillAmountS - prevSplitB);
442- batch[p + 3 ] = bytes32 (prevSplitB + state.splitS);
443- batch[p + 4 ] = bytes32 (state.lrcReward);
444- batch[p + 5 ] = bytes32 (state.lrcFeeState);
445- batch[p + 6 ] = bytes32 (state.wallet);
446- p += 7 ;
447-
448- // Update fill records
449- if (state.buyNoMoreThanAmountB) {
450- delegate.addCancelledOrFilled (state.orderHash, nextFillAmountS);
451- } else {
452- delegate.addCancelledOrFilled (state.orderHash, state.fillAmountS);
453- }
454-
455- orderInfoList[i * 6 + 0 ] = uint (state.orderHash);
456- orderInfoList[i * 6 + 1 ] = state.fillAmountS;
457- orderInfoList[i * 6 + 2 ] = state.lrcReward;
458- orderInfoList[i * 6 + 3 ] = state.lrcFeeState;
459- orderInfoList[i * 6 + 4 ] = state.splitS;
460- orderInfoList[i * 6 + 5 ] = state.splitB;
444+ batch[p++ ] = bytes32 (state.fillAmountS - prevSplitB);
445+ batch[p++ ] = bytes32 (prevSplitB + state.splitS);
446+ batch[p++ ] = bytes32 (state.lrcReward);
447+ batch[p++ ] = bytes32 (state.lrcFeeState);
448+ batch[p++ ] = bytes32 (state.wallet);
449+
450+ historyBatch[r++ ] = state.orderHash;
451+ historyBatch[r++ ] =
452+ bytes32 (state.buyNoMoreThanAmountB ? nextFillAmountS : state.fillAmountS);
453+
454+ orderInfoList[q++ ] = uint (state.orderHash);
455+ orderInfoList[q++ ] = state.fillAmountS;
456+ orderInfoList[q++ ] = state.lrcReward;
457+ orderInfoList[q++ ] = state.lrcFeeState;
458+ orderInfoList[q++ ] = state.splitS;
459+ orderInfoList[q++ ] = state.splitB;
461460
462461 prevSplitB = state.splitB;
463462 }
463+ // Update fill records
464+ delegate.batchAddCancelledOrFilled (historyBatch);
464465
465466 // Do all transactions
466467 delegate.batchTransferToken (
0 commit comments