Fee Model

This article tells about fees on Sui.

Gas Fees on Sui

Sui has a sophisticated gas fee model to achieve the following goals:

  • to ensure low, predictable transaction fees
  • to incentivize validators for transaction processing operations optimization
  • to prevent DDOS attacks

The total amount of gas fee paid by users includes fees paid for transaction execution (computation fee) and object storage (storage fee).

🚧

All calculations below are exemplary. The data used is not real!

📘

Gas Fees

GF = CU*CP + (SU*SP)-SR,

where

CU - Computation Units (an abstract measure of the computing power spent on transaction execution),
CP - Computation Price (the price of one computing unit),
SU - Storage Units (an abstract measure of the Sui storage space occupied by the transaction object data),
SP - Storage Price (the price of one storage unit),
SR - Storage rebate

Computation Units

Different Sui transactions require different computational efforts for transaction execution and processing. Computation units are an abstract measure of such computation efforts. The Sui computation gas schedule is based on a bucketing approach. Transactions are assigned CUs according to the bucket (group) they fall into (see table below).

Bucket RangeComputational Units
0-1,0001,000
1,000-5,0005,000
5,000-10,00010,000
10,000-20,00020,000
20,000-50,00050,000
50,000-200,000200,000
200,000-1,000,0001,000,000
1,000,000-5,000,0005,000,000

❗️

Transactions that cost over 5,000,000 computing units are aborted and get the failed status.

Computation Price

The computation gas price captures the cost of one computation unit. This price is set at the transaction level and submitted by the user as the transaction gas price. It comprises the reference price and the tip. The reference price is used as an anchor for the computation price computation and is submitted each epoch by all validators. Tips are optional, and users may pay them to accelerate transaction execution.

📘

Gas Fees

CP= RGP + T,

where

CP - Computation Price (the price of one computing unit),
RGP- Reference Gas Price,
T- Tip.

Reference Gas Price

The reference price is a credible anchor for users to reference when submitting transactions to the network. It provides reasonable confidence that transactions submitted with gas prices at or close to the reference price are executed promptly. The reference price is calculated in three core steps: gas price survey, tallying rule, and incentivized stake reward distribution rule.

Gas Price Survey

At the beginning of each epoch, all validators submit their reservation price, that is state the minimum gas price at which they are willing to process transactions. The protocol orders these quotes and chooses the 2/3 percentile by stake as the reference price. The gas price survey aims to set a reference price under which a quorum of validators is willing to process transactions promptly.

The Next Epoch Reference Gas Price is calculated as follows:

📘

Reference Gas Price Calculation

Reference gas price for the next epoch is calculated as follows:

  1. Calculate the delta between the maximum and the minimum Next Epoch Gas Prices Quotes that validators submit every epoch:
    D = GPQmax - GPQmin,

where

D - the delta between the maximum and the minimum gas price quotes,
GPQmax - the maximum gas price quote for the next epoch,
GPQmin - the minimum has price quote for the next epoch.

  1. Calculate the 2/3 percentile of the delta:
    P= D*0.666666667,

where

P - 2/3 percentile,
D - the delta between the maximum and the minimum gas price quotes.

  1. Find the nearest Gas Price Quote that is either lower or higher than the Percentile value.

Below is a sample calculation of the Next Epoch Reference Gas Price in MIST using the formula described above.

📘

Reference Gas Price Calculation Sample

100 validators submitted their reference gas price quotes for the next epoch:

875, 250, 500, 1000, 150, 800, 1000, 791, 500, 880, 888, 300, 999, 500, 1000, 100, 500, 999, 1000, 950, 1000, 1000, 1069, 890, 1000, 500, 998, 500, 500, 200, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 950, 499, 1000, 1000, 998, 900, 1000, 950, 1000, 1000, 950, 1000, 1000, 900, 1000, 1000, 1000, 1000, 950, 1009, 1000, 1000, 1000, 1000, 1000, 825, 1000, 1000, 950, 950, 1000, 950, 100, 980, 1000, 950, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 499, 800, 1000, 1000, 1000, 1000, 970, 740, 839

GPQmax = 1069
GPQmin = 100
RV= (1069-30)*0.666666667) = 692.66666,

where

GPQmax - the maximum gas price quote for the next epoch,
GPQmin - the minimum gas price quote for the next epoch,
RV - the reference value to find the reference gas price.

Let's round the reverence value to 693. The closest value from the valiator price quotes listed above will be 740 MIST.

Validators whose gas price quotes are higher than the reference gas price get slashed rewards in the next epoch.

📘

This incentivizes validators to provide lower price quotes, which drives computation gas prices down.

Tallying Rule

Throughout the epoch, validators get signals about the performance of other validators. If some validators are underperforming, peers can report them, and if so, they get slashed rewards in the next epoch.

📘

This is an incentive for validators to show good performance.

Incentivized Stake Reward Distribution Rule

At the end of each epoch, Sui validators receive their staking rewards based on the information obtained from the tallying rule. All else equal, well-performing validators receive their regular staking rewards, whereas validators with too high gas price quotes or validators that are performing badly get slashed (reduced) staking rewards.

Storage Units

Sui transactions also vary depending on the storage size their objects occupy. The current Sui storage schedule is straightforward and maps each byte into 100 storage units. For example, a transaction that stores 25 bytes costs 2,500 storage units.

🚧

On Sui, users pay upfront for storing data. If later some data is deleted from the storage, users get back the storage rebate in the amount of the deleted data.

Storage Price

Storage Price captures the costs of covering one unit of storage. In contrast to the gas price, this is a constant value set through governance. The idea is to ensure users pay for the exact size of the on-chain data storage they use by depositing these fees into the storage fund and then redistributing these fees to future validators. Objects can be deleted from the storage, in which case the user who paid the storage fee for those objects gets a refund or storage rebate.

📘

On the one hand, such design makes the protocol fairer for users, since they don't pay for unused storage. On the other hand, it maximizes the storage efficiency.

Sample Calculations

Below are some sample gas fee calculations to illustrate how Sui fee model works.

📘

Legend

RGP - Reference Gas Price,
CU - Computation Units,
SP - Storage Price,
SU - Storage Units,
SR - Storage Rebate,
GF - Gas Fees

Case 1. Simple transaction storing 10 bytes, no rebate

RGP = 1,000 MIST
CU = 1,000
SP = 75 MIST
SU = 1,000
SR = 0
GF = 1,000_1,000+75_1,000 = 1,075,000 MIST (0.001075 SUI)

Case 2. Simple transaction storing 10 bytes, rebate

RGP = 500 MIST
CU = 1,000
SP = 75 MIST
SU = 1,000
SR = 100,000
GF = 500_1,000+(75_1,000)-100,000 = 475,000 MIST (0.000475 SUI)

Case 3. Complex transaction storing 120 bytes, no rebate

RGP = 1,000 MIST
CU = 5,000
SP = 200 MIST
SU = 12,000
SR = 0
GF = 1,000_5,000+200_12,000 = 7,400,000 MIST (0.0074 SUI)

Complex transaction storing 120 bytes, rebate

RGP = 500 MIST
CU = 5,000
SP = 200 MIST
SU = 12,000
SR = 3,000,000
GF = 500*5,000+200_12,000-3,000,000 = 1,900,000 MIST (0.0019 SUI)

📘

1 SUI = 1,000,000,000 MIST

The table below shows the calculation results. All values are in MIST.

CaseSizeRPGCUSPSUSRMinimum
Gas Budget
Gas Fee
Case 110 Bytes1,0001,000751,00001,075,0001,075,000
Case 210 Bytes5001,000751,000100,000500,000475,000
Case 3120 Bytes1,0005,00020012,00007,400,0007,400,000
Case 4120 Bytes5005,00020012,0003,000,0004,900,0001,900,000

For more information on Sui storage design go here.
Read more about gas fees on Sui here and here.