Closed Oighty closed 2 months ago
@0xJem let me know what you think of this version for iterative settlement. It's less invasive than I expected.
First bid on second settle call is below minPrice
This isn't possible, actually. It will be filtered out in the decryption stage.
Update callback test salts (think there may be a fix to port over from the other branch?)
I haven't seen any failures
Implement minBidSize -> quoteToken feature on this branch?
Let's clarify what's required
I haven't seen any failures
I had to clear the bytecode on my end. Disregard
Implement minBidSize -> quoteToken feature on this branch?
Let's clarify what's required
Going to do this on a separate branch.
Good to merge?
I changed the base to develop
, since we will have a couple of PRs merging in and don't think we should be leaving master
in a potentially broken state.
Goal of settlement: Process sorted bids to find marginal clearing price of batch auction.
Problem: The EVM limits the number of bids we can process in a single transaction due to the gas limit. Therefore, auctions that require more bids to settle than can be processed are bricked.
Solution: Allow auction to be settled over multiple transactions if needed.
The implementation of these changes is fairly minimal; however, testing all of the edge cases will require quite a bit of work. I made the following changes:
_getLotMarginalPrice
is the function within EMP that iterates through bids to find the marginal price. Most of the changes are focused here.num_
parameter for the number of bids to iterate through (passed through higher-level functions that call it). The loop now iterates overnum_
ornumBids
still in queue, whichever is smaller.finished
variable toMarginalPriceResult
which is set whenever one of the result blocks are hit. An important thing to note is that, unlike the decrypt process, settlement can end without hitting the end of the queue. Therefore, this can be set in multiple places where we previously exited the loop.settle
transaction, we need to store the intermediate result. To do so, we store the totalprocessedAmountIn
from previous calls and thelastPrice
seen in a new mapping:_lotSettlement
_settle
uses the result of_getLotMarginalPrice
to determine what to do next.result.finished
is true, it behaves as before. This includes updating the auction status, emitting an event, and calculating thetotalIn
andtotalOut
values to provide to the AuctionHouse.result.finished
is false, it skips the previous behavior and stores the partial results for use on the next call. It specifically does not update the status of the auction so that the function can be called again.Tasks
settle
call is a partial fill.