Pricing & Amounts

Price representation

Every bench stores a single integer price, purchase_price_per_100m: the amount of the purchase asset, in its base units, required to buy 100,000,000 base units of the asset for sale.

For a purchase spending spend base units of the purchase asset, the bench sends

tokens = ⌊ spend × 100,000,000 / purchase_price_per_100m ⌋

base units of the asset for sale.

To convert a human-readable price to the on-chain value:

purchase_price_per_100m = price × 10^purchase_decimals × 100,000,000 / 10^selling_decimals

where price is the amount of purchase asset per whole unit of the asset for sale.

Example: selling ALPHA (6 decimals) at 0.009405 USDC (6 decimals) each: purchase_price_per_100m = 0.009405 × 10^6 × 10^8 / 10^6 = 940,500. Spending 10 USDC (10,000,000 base units) buys ⌊ 10,000,000 × 100,000,000 / 940,500 ⌋ = 1,063,264,221 base units, i.e. 1,063.264221 ALPHA.

The price must be greater than zero. The intermediate multiplication cannot overflow; the resulting token amount must fit in a 64-bit integer.

Rounding

Token amounts are rounded down. Fractions of a base unit stay in the bench in favour of the seller. Purchases that would round down to zero tokens are rejected (ERR:ZERO AMT).

Dust and automatic end

The least purchasable amount of a bench is the number of tokens (in base units) that the smallest unit of the purchase asset buys, rounded up. When a sale leaves fewer tokens than this in the bench, nobody could buy them, so the bench ends automatically: its time_end is set to the time of that last sale. Any such dust is returned to the owner on close.

Similarly, if no start time was configured, the bench's time_start is set to the time of the first sale.

Purchase limits

Purchase limits are expressed in base units of the purchase asset, and are cumulative per account for the lifetime of the bench. See Buying.