📊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
labelFixed 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.
This configuration with valid data has to be properly encoded for the chosen Pricer to understand. Pricer configs are passed and stored as bytes arrays on either ZNSRootRegistrar (for root domain pricing) or ZNSSubRegistrar (for all subdomain pricing mapped per domain) and are interpreted by the Pricer at the time of registration by decoding the array. This polymorphic design allows to provide full pricer data during the registration call to be able to register and setup a domain in a single transaction, without the need to determine and call a specific Pricer to set the price in order to start selling subdomains.
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^18decimals of precision, versus one that was10^5decimals.
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
FixedPricingalong withStakePayment, 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 theZNSTreasurycontract. 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 frombaseLengthtomaxLength.maxLength: The maximum length of a domain name. If the name is longer than this value, we return the price atmaxLength.baseLength: The base character length of a domain name. If the name is less than or equal to this value,maxPriceis 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 inZNSCurvePricerthat 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, theprecisionMultipliershould be set to1, which will avoid truncation altogether. If truncation is needed,precisionMultipliershould be calculated as:10 ^ (tokenDecimals - requiredPrecision)e.g. if the token has 8 decimals and only 2 are desired, theprecisionMultiplierwould be10 ^ (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.
Please note the following:
precisionMultiplieris NOT a direct value of desired precision, but rather a result of subtracting the precision value from the value of the chosen token's decimals of the as a power of10!If truncation is not needed,
precisionMultipliershould be set to1. It will be set to1as a default value for all newly minted domains, UNLESS the domain registrant explicitly sets it.The
precisionMultipliercannot be set to0, lest it would produce a price of0,disregarding the rest of the config!The
precisionMultipliercannot be set to a value greater than10 ^ 18!The
precisionMultipliercan -- but should NOT -- be set to a value greater than10 ^ decimals(of the token used for payments and pricing). Doing this would result in an incorrect price calculation followed by the incorrect payment.The correct return from
getPrice()is dependent on a domain's owner or operator to set theprecisionMultipliercorrectly -- or leave it at the default value of1.curveMultiplierandbaseLengthcan NOT be set to0at the same time.maxLengthcan NOT be set to0and HAS to be LOWER thanbaseLength.If
maxPriceorbaseLengthare set to0ALL subdomains will get a price of0becoming free to register.
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:
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