starling
Concepts

Oversubscription

A flock buys used = min(total deposits, size). If the deposits exceed the size, every depositor is filled with the same fraction used / total of their deposit and gets the rest back when they claim.

Why it works this way

A flock with a hard "first come, first served" cap would be filled in seconds by scripts running many wallets, and everybody else would be left out. With pro rata filling, joining early gives nothing: the fraction is the same for all, so there is nothing to win by being fast. The only thing that counts is how much you deposit relative to the others, and you can see that before the deadline and leave if the fill is too small for you.

Example

Size 0.25 ETH. Alice deposits 0.5, Bob 0.3, Carol 0.2. Total 1.0, so the fill is 25%.

depositfilledtokens sharerefund
Alice0.500.12550%0.375
Bob0.300.07530%0.225
Carol0.200.05020%0.150

All three paid the same price per token. The unit tests run this exact case.

Rounding

Tokens and refunds are computed tokensOut × deposit / total and deposit × (total − used) / total, both rounded down. The sum paid out can therefore never exceed what the contract holds for the flock; at most a few wei of dust stay in it, and they can never reach the creator's fee reserve. This was found by fuzzing: an earlier version rounded the refund up and could eat into the reserve by a few wei.

The commit limit

Deposits are capped at COMMIT_MULTIPLE × size (100 ×), so a flock cannot be buried under an unbounded pile of deposits. You can read the current fill at any time: size / total from flocks(id), or shareOf(id, who) after the launch.