๐Ÿ“ŠPricing

Pricing Modules

At present there are two contracts deployed as ZNS pricers, managing all domains:

  • Curved Pricing: Calculates the price of a domain based on the character length of that domain's label

  • Fixed Pricing: Provides a fixed price for every subdomain regardless of its character length

The minimum requirements for a compatible price contract are located in IZNSPricer.sol if users are inclined to create them themselves. Users wishing to create their own pricing module must only inherit from this contract, otherwise it will be incompatible with the system.

Configuration

Both available pricers require some form of configuration to be set.

Fixed Pricer

The fixed price contract is simple in that it only requires two configuration values:

  • Price: The given price of a domain relative to the amount of precision specified by the paymentToken.

    • e.g. If the price is set to 1000 tokens, the resolved number of tokens to transfer in payment will be different for a specified payment token that has 10^18 decimals of precision, versus one that was 10^5 decimals.

  • Stake fee percentage: The registration fee for STAKE type payments represented in percentage as basis points (parts per 10,000), e.g., 2% would be represented as 200. This value can be zero (0) and is not required to be set. As an example, the stake fee percentage can be added when using FixedPricing along with StakePayment, so that a parent domain's owner or beneficiary can receive a payment -- as they will will not receive any of the stake held in the ZNSTreasury contract. If STAKE payment type is not used, this fee will not be charged, even if set.

Curve Pricer

The curved pricing contract is slightly more complex:

  • maxPrice: The maximum price for a domain with a character length <= baseLength.

  • curveMultiplier: Multiplier which we use to bend the price curve in interval from baseLength to maxLength.

  • maxLength: The maximum length of a domain name. If the name is longer than this value, we return the price at maxLength.

  • baseLength: The base character length of a domain name. If the name is less than or equal to this value, maxPrice is returned.

  • precisionMultiplier: The precision multiplier of the price. This multiplier should be picked based on the number of token decimals to calculate properly. This is an optional parameter in ZNSCurvePricer that can be set by a domain's owner or operator to truncate unwanted decimals off the subdomain price. If a domain's owner does not require precision, the precisionMultiplier should be set to 1, which will avoid truncation altogether. If truncation is needed, precisionMultiplier should be calculated as: 10 ^ (tokenDecimals - requiredPrecision) e.g. if the token has 8 decimals and only 2 are desired, the precisionMultiplier would be 10 ^ (8 - 2) = 10 ^ 6. This would result in 1.23456789 TOKEN to being returned as 1.23 TOKEN.

  • feePercentage: The registration fee value percentage as basis points (parts per 10,000) e.g., a 2% value would be represented as 200.

By way of example, consider when baseLength == 3 and maxLength == 30.Domains with the character length 1, 2, or 3 will return the maxPrice. Domains with a character length of 31 or beyond will return the minPrice . Domains with lengths of 4 to 30 will be priced according to the curved pricing formula below:

The curved pricing function

Mathematically speaking, division and subsequent multiplication of the same number will cancel out, however, this method takes advantage of the way Solidity stores numbers; x * (y / m) is not always the same as (y / m) * x in Solidity.

Because occurs first in this equation, there is a forced truncation of the actual number, followed by multiplication to bring it back to its original values -- only with zeros beyond the specified digits of precision.

Last updated