Skip to content

Contract Optimization Opportunities

Benjamin Smith edited this page Mar 27, 2019 · 2 revisions

Batch Wheel (modular batch indexing)

At the moment all requests (Deposits, Withdraws and Limit Orders) are index by a mapping(uint => BatchObject). However, this can be reduced to something like mapping(uint4 => BatchObject) by purging all old (finalized slots). This will require special consideration not to overflow a backlog of non-finalized PendingBatches.

Compact Request Encoding

rather than passing (uint8, uint8, uint16, uint128, uint128) then cropping and packing this into uint256 why not just pass the packed version directly into the function.

Remove Non-Fatal Validations

Possible examples in specific functions

  1. placeSellOrder
  • buyToken != sellToken is not fatal. Could be handled by the driver (via simply not passing such orders to the solver).

  • ensure requested tokens are registered. It wouldn't hurt to lift this validation, but then one would still need to ensure the requested tokenID does not exceed the MAX_TOKENS. This would cause IndexError complications in the external services.

  1. deposit
  • reject deposit amounts of zero.