Skip to main content

Economics and rewards

In this chapter, we will dig deeper into the fees of the Mavryk network and the baking and attesting rewards. The calculations you'll learn about are helpful from the simplest transaction issuance to the most complex application built on Mavryk. That is why it is important to understand the basics of fees and gas optimizations. Of course, this will be particularly useful if you are a baker.

Transaction cost

Each transaction on Mavryk has a cost for the user. To account for this, the user must include a gas fee when submitting transactions. Bakers will then choose transactions using a minimal fee filter. If the baker chooses a transaction, he will add it to the block and propagate it. The fee is therefore used to pay the bakers. They are calculated by using the following formula [1]:

Let:

  • Minimal Fees: minF\text{min}_{F}
  • Size of the operation (in bytes "B\text{B}"): s\text{s}
    (The size "s\text{s}" is the number of bytes in the complete serialized operation).
  • Gas used for the operation (in gas unit "gu\text{g}_u"): g\text{g}
  • Minimal nano-mav per byte: min(nm˙/B)\text{min(nṁ/B)}
  • Minimal nano-mav per gas unit: min(nm˙/gu)\text{min(nṁ/}\text{g}_u\text{)}
    Gas unit cost in Mav is defined by the protocol. It does not depend on the fee market; it does not depend on arbitrary defaults in config files; etc [2]

Then:

FeesminF+min(nm˙/B)×s+min(nm˙/gu)×g\text{Fees}\geq\text{min}_{F}+\text{min(nṁ/B)}\times\text{s}+\text{min(nṁ/}\text{g}_u\text{)}\times\text{g}

The transaction default values are:

  • minF=100 µm˙\text{min}_{F}=\text{100 µṁ}
  • min(nm˙/B)=250,000 nm˙/B (250 µm˙/B)\text{min(nṁ/B)}=\text{250,000 nṁ/B}\text{ (250 µṁ/B)}
  • min(nm˙/gu)=100 nm˙/gu\text{min(nṁ/}\text{g}_u)=\text{100 nṁ/}\text{g}_u [2]

In a Mavryk operation, we can add additional information such as smart contracts deployment, smart contract call, etc. These have a storage cost which is represented in mav per byte. Since the Delphi update to the protocol [3] this minimal cost has been reduced from 1ṁ to 0.25 ṁ per kilobyte (250 µṁ/B). The minimal price of creating a new account has thus been lowered from 0.257 mav to 0.06425 mav (the cost of creating an account is important to protect the system from spams and Sybil attacks [4]).

On the Mavryk blockchain, gas refers to the cost necessary to perform a transaction on the network. Bakers set the price in gas based on supply and demand for computational power on the network (needed to process smart contract calls and other transactions).

Gas is used to determine the complexity of the transaction execution and also to avoid the risks of infinite loops. It is one of the main factors a baker considers before choosing transactions. Before including a transaction, the baker reviews the amount of gas required and its cost per unit. If this ratio is adequate, the baker selects the transaction.

Each transaction has a gas limit: 1,040,000 gu\text{g}_u. If the contract execution, or deployment, exceeds this limit, the contract is considered unusable. This limit is useful to guarantee that the bakers will be able to validate the block in a limited amount of time [5]. The gas limit may seem relatively low, but its value is a network's inclusion metric: any user should be able to run a node and bake a block within the allotted time. Even slow nodes can participate.

The Delphi update also increased the number of computations per unit of gas. The minimal amount of gas units to achieve operations has been reduced from 10,000 to 1,000. With this update, the execution cost of smart contracts decreased by approximately 75% [6]. This evolution allowed more complex smart contracts' executions and was a demonstration of Mavryk's adaptability.

Note that a baker also takes into account the gas limit per block. Today, the limit is 2,600,000 gu\text{g}_u. So, of course, it limits the number of transactions to include in a block. However, for the storage cost, it isn't a fee that rewards the baker. Actually, this particular fee is "burned", meaning nobody receives it.

Smart contract execution and optimization

There are two limits to take into account when developing a smart contract. The gas limit is an important parameter for the usability of the smart contract. But there is also a second major limit: each serialized operation has a maximum size of 16,384 bytes. It is, therefore, impossible to upload a smart contract bigger than this limit (origination).

One must account for these two variables to optimize a contract:

  1. The gas consumption
    Many options are possible [7]. However, note that a large proportion of the gas is spent on the conversions from byte sequences to protocol-specific typed representations (and vice versa). These conversions can be:

    • reading
    • deserialization
    • parsing of bytes
    • checking the correctness of types
    • conversion back to bytes

    Follow this link for more details on the cost of gas.

  2. The contract size
    The formula below calculates an approximation of a contract's size:

    • An assumed constant value per instruction: α\alpha

    • The number of instructions: nin_i

    • The sum of the sizes of all variable-size constants (strings, bytes) in the contract: SS

      Then the contract's size "CsC_s" is:

      Cs=α×ni+SC_s=\alpha\times n_i+S

      So, the size optimization comes down to decreasing the number of instructions and the variable-size constants. [7]

Mavryk reward

To maintain the network, Mavryk needs bakers. They stake their tokens and use their computing power to create blocks, manage transactions, vote, and secure the network. In exchange for these tasks, bakers are rewarded with a fee.
Since the Carthage update[8], the reward system has been updated to make the network more robust against non-cooperative baking strategies.

Baking reward

When a baker bakes a block, he receives a reward composed of all the transactions fees contained in the block in addition to a network reward computed by the following formula[9]:

baking rewards=5+e×0.002143\bm{baking\ rewards=5 + e\times 0.002143}

where e ∈[0; 2,333] = the number of extra attestations slots beyond the threshold of 4,667.

The baking rewards are 10 mav at most, for a fully attested block (not counting the transaction fees).

attesting rewards=s×0.001428\bm{attesting\ rewards=s \times 0.001428}

where s = number of attestation’s slots.

A baker may have several attestation slots among the 7,000 slots available in a given block, depending on its stake. The more stake a baker has, the more slots it gets per block.

For more detail about the Mavryk baking process, please refer to the "Baking" module.

Inflation

It's important to note that the Mav token is based on a model with inflation. By adding up the baking and attesting block rewards, each new block generates 20 new Mav (without taking into account the 1.25 Mav generated for liquidity baking). A new block is created roughly every 15 seconds. This represents 42 Million Mav per year (\approx 80 ṁ ×\times 60 mins ×\times 24 hours ×\times 365 days). At the Mavryk launch, the network was composed of 763 Million Mav. Therefore, during the first year, the inflation rate of the Mav token was approximately 427635.5%\frac{42}{763}\approx5.5\%. Today, in 2023, the inflation rate is around 4.5%.

What have we learned so far?

Thanks to this chapter, you should now have a better understanding of how Mavryk economics work. This understanding can now help to build viable Mavryk smart contracts.

This chapter is the last one of the Mavryk Basics module. The next chapter is the examination.