insrt
Search
⌃K
🚶♂

Minter Reward Model (the Math)

The mechanism of how mint attempts are resolved.

Summary

Upon mint attempt, the PerpetualMint contracts request a random number from ChainlinkVRF. The random number is used to determine whether the mint attempt is successful, and then, if the attempt was successful, which of the deposited tokens is minted. If the attempt is unsuccessful, an alternative prize is minted, and the random number is used to determine what rarity the prize will have.

Determining Mint Outcome

This is an outline of what the protocol does upon a user minting:
  1. 1.
    When a user requests to mint, Insrt fetches a random number from ChainlinkVRF.
  2. 2.
    The size of the random number is between 0 and 2^256 - 1. This range is far too large for our purposes, since all probabilities are determined relative to a denominator or basis
    BB
    , which for PerpetualMint, is
    B=1000000000B = 1000000000
    . This means the random number can be "Chunked" and maintain its randomness. "Chunking" is the process where a number is split up into its bit constituents. Since the bits are random to begin with, splitting them maintains the original randomness, so long as no bit shifting is done. For example, if a number 1289312375 is random, and it is chunked into 12893 and 12375, then those two numbers are also random. The amount of chunks depends on how many random numbers are needed overall. In the case of an ERC721 asset mint, this is two numbers, so the random number is chunked into two. The first number
    tt
    is used to determine whether the mint is successful and the second random number
    pp
    is used to determine which of the deposited assets is picked.
  3. 3.
    The method to determine the outcome of the mint attempt using
    tt
    is outlined below:
    1. 1.
      Each deposited NFT has a risk parameter
      Ri∈(0,B]R_{i} \in (0,B]
      associated with it.
    2. 2.
      The chance for a mint to be successful, denoted by
      P(M)P(M)
      , is the average risk parameter across all deposited assets in a pool. Given that each deposited NFT has a risk parameter
      RiR_{i}
      assigned to it, the total risk across all assets is
      S=∑i=1NRiS = \sum\limits_{i=1}^{N}R_{i}
      where
      NN
      is the number of deposited assets. Hence,
      P(M)P(M)
      is found to be
      P(M)=1N∑i=1NRi P(M) = \frac{1}{N}\sum\limits_{i=1}^{N}R_{i}
      , where
      0<P(M)≤B0 < P(M) \leq B
      .
    3. 3.
      Since the random number
      t∈[0,2128−1]t \in [0, 2^{128}-1]
      may be larger than the basis
      BB
      , we normalize it by taking
      t~=tmod  (B)\tilde{t} = t \mod (B)
      in order to ensure
      t~∈[0,B−1]\tilde{t} \in [0, B-1]
      . This number
      t~\tilde{t}
      is referred to as the "mint number".
    4. 4.
      If
      t~\tilde{t}
      is greater than or equal to the average risk,
      t~≥P(M)\tilde{t} \geq P(M)
      , the mint is deemed successful. Otherwise, the mint is deemed unsuccessful and no deposited NFT is minted.

Determining Minted Asset Upon Successful Mint

In the case of a successful mint, another random number is used to select which deposited NFT is assigned from a collection.
  1. 1.
    Recall that each deposited NFT has a risk parameter
    Ri∈(0,B]R_{i} \in (0,B]
    associated with it, and that the total risk across all assets is
    S=∑i=1NRiS = \sum\limits_{i=1}^{N}R_{i}
    , where
    NN
    is the number of deposited assets.
  2. 2.
    Since the random number
    pp
    may be larger than the sum of risks
    SS
    , we once again normalize it by taking
    p~=pmod  (S)\tilde{p} = p \mod (S)
    , where
    p~∈[0,S−1]\tilde{p} \in [0, S-1]
    . This number
    p~\tilde{p}
    is referred to as the "picking number".
  3. 3.
    We then compare the sampled value of
    p~\tilde{p}
    to the cumulative sums of the risks
    RiR_{i}
    . The selected index is the smallest
    ii
    which satisfies the condition
    p~<∑j=1iRj\tilde{p} < \sum\limits_{j=1}^{i}R_{j}
    . In other words, if
    p~\tilde{p}
    lies in the interval
    [∑j=1i−1Rj , ∑j=1iRj)[\sum\limits_{j=1}^{i-1} R_j\,, \,\sum\limits_{j=1}^{i} R_j)
    , the index
    ii
    is selected.
​

Determining ERC1155 Minted Asset Owner

The process for determining whether an ERC1155 asset is minted, and which token from the collection is minted, is similar to the steps taken for ERC721 collections outlined above. The key difference is that since more than one Depositor may have deposited the same token ID, it is necessary to determine which Depositor is chosen out of those who have deposited the minted token ID.
If the mint attempt pertains to an ERC1155 collection, the second random number
pp
is further chunked into
p1p_{1}
and
p2p_{2}
, which are used to select the minted token, and the depositor of the minted token respectively, as there may be more than one depositor.
Each Depositor is associated with a "total risk", denoted by
RdR_{d}
, corresponding to the selected token ID that is to be paid out as a prize.
RdR_{d}
represents the aggregate risk of a Depositor for a specific token ID, accounting for the possibility that a single user may deposit more than one token with the same ID. Formally, we can say
Rd=K⋅RiR_{d} = K \cdot R_{i}
, where
KK
is the number of tokens deposited, and
RiR_{i}
is the user-defined risk parameter for the NFT.
The random number
p1p_{1}
is normalized with respect to the sum of depositor risks
R=∑d=0DRd R = \sum\limits_{d=0}^{D}R_{d}
, where
D D
is the number of depositors; giving us
p1~=p1 mod (R)\tilde{p_{1}} = p_{1} \bmod(R)
.
The individual depositor risks
RdR_{d}
are added until
p1~\tilde{p_{1}}
exceeds the cumulative risk. At that point, the depositor matching the last added risk value is selected as the depositor of the minted asset.

Determining Consolation Asset

If the mint is unsuccessful, the second random number
p2p_{2}
is used to determine the rarity of the consolation prize that is minted.
The consolation assets have five tiers with the following probabilities:
​
Tier 1: P(T1)=5000000001000000000=50%\text{Tier 1: } P(T1) = \frac{500000000}{1000000000} = 50\%
,
​
Tier 2: P(T2)=3300000001000000000=33%\text{Tier 2: } P(T2) = \frac{330000000}{1000000000} = 33\%
,
​
Tier 3: P(T3)=1250000001000000000=12.5%\text{Tier 3: } P(T3) = \frac{125000000}{1000000000} = 12.5\%
,
​
Tier 4: P(T4)=400000001000000000=4%\text{Tier 4: } P(T4) = \frac{40000000}{1000000000} = 4\%
, and
​
Tier 5: P(T5)=50000001000000000=0.5%\text{Tier 5: } P(T5) = \frac{5000000}{1000000000} = 0.5\%
.
The number
p2p_{2}
is then normalized to be smaller than the sample space
SS
, which in this case is the basis
BB
; resulting in a "picking number" of
p2~=p2 mod (B)\tilde{p_{2}} = p_{2} \bmod(B)
.
The number
p2~\tilde{p_{2}}
is then compared to
T1,T2,T3,T4,T5T1, T2, T3, T4, T5
so that, for example, if
p2~<T1\tilde{p_{2}} < T1
a tier 1 asset is minted, if
T3<p2~<T2 T3 < \tilde{p_{2}} < T2
a tier 2 asset is minted and if
p2~<T5 \tilde{p_{2}}< T5
a tier 5 asset is minted. The method of value determination for the consolation assets may be found here.