Launch app

Docs / Protocol

Rounding

Settlement divides a lot, and integer division drops remainders. Blackpool chooses the direction of every one of them so the book can never pay out more than it took in.

  • What a trader gives is rounded up: the USDG a buyer pays, the shares a seller delivers.
  • What a trader receives is rounded down: the shares a buyer gets, the USDG a seller gets.

At the end of each settlement the contract asserts both sums:

assert(quoteOut <= quoteIn && baseOut <= baseIn);

The difference, a few raw units at most, is credited to the treasury. The test suite fuzzes random books and prices and checks after each settlement that the sum of every balance the contract owes is at most what it holds.