-
Notifications
You must be signed in to change notification settings - Fork 1k
Exchanges How to Distribute Gas to Users
-
Take a data snapshot of the users’ Neo positions at regular intervals;
-
Calculate the weight of a single user’s Neo positions, i.e. summing up the weights of this user’s position at all the snapshots. The weight of a position at Snapshot n equals the position times its holding period.
-
Calculate the total weight of all the users’ Neo positions, i.e. summing up the weights of each single user.
-
Calculate the total amount of Gas to be distributed and draw them.
-
Calculate the proportion of Neo owned by each user and distribute the corresponding amount of Gas to each user based on this proportion.
-
We assume that all the addresses in the exchanges are in one wallet;
-
Calculation Procedure: Let TotalNeoGas be the total amount of Gas to be distributed (decided by the exchange), and NeoAmountA1 be the position of User A at the 1st Snapshot moment, then NeoAmountA = NeoAmountA1 + … + NeoAmountAn
NeoAmountTotal = NeoAmountA + … + NeoAmountZ
NeoRatioA = NeoAmountA / NeoAmountTotal
Thus, the amount of Gas that User A should be granted can be calculated as:
DistributedGasA = TotalNeoGas x NeoRatioA -
The shorter the snapshot interval, the more precise the calculation is;
-
If the snapshot interval is not uniform, we will use the weighted average calculation as the following: Let TotalNeoGas be the total amount of Gas to be distributed (decided by the exchange), NeoAmountA1 be the position of User A at the 1st Snapshot, and Tn be the time length between the nth snapshot and the n-1th snapshot, then
NeoAmountA = NeoAmountA1 x T1 + … + NeoAmountAn x Tn
NeoAmountTotal = (NeoAmountA + … + NeoAmountZ) x (T1 + ... + Tn)
NeoRatioA = NeoAmountA / NeoAmountTotal
Thus, the amount of Gas that User A should be granted can be calculated as:
DistributedGasA = TotalNeoGas x NeoRatioA.
- Run the client
./neo-cli.dll /rpc
- Check the version of the client
version
- Check the synchronized height of the client
show state
Height: 区块高度/区块头高度, Nodes: 连接节点数量
- Create a wallet
create wallet /home/NeoNode/test.db3
- Open the wallet created in the last step
open wallet /home/NeoNode/test.db3
- Check the address list in the wallet
list address
- Check the assets in the wallet
list asset
- Get the details of the balances of Neo Gas in the wallet
show gas
- Transfer to your own wallet, and by transferring to yourself change the status of Gas to be drawable.
send NEO AaAHt6Xi51iMCaDaYoDFTFLnGbBN1m75SM 1
- Get the details of the balances of Neo Gas in the wallet again. Now the status of all the Gas should be drawable.
show gas
- Draw Neo Gas
claim gas
-
Brief Introduction
Neo Gas represents the right to use the Neo Blockchain. There will be 100 million Neo Gas in total. Neo Gas are generated along with every new block. The issuance will slow down according to a set slowly-decreasing pace, while Neo Gas will go through a generating process to grow from zero to 100 million. Once Neo is acquired, Neo Gas will be generated in the system following the algorithms. -
Basic Concept
Every Neo has two states, unspent and spent. Each Gas has two states too, which are available and unavailable. A life cycle of a Neo starts from being transferred into an address and ends with being transferred out of that address. When it is transferred in, its state becomes unspent while when it is transferred out, its state becomes spent. When Neo is at the unspent state, its generated Gas will be in unavailable state, in another word, undrawable; when Neo is at the spent state, its generated Gas will be in available state, so the users can draw them. -
Mathematical Model
t_start = the moment that Neo goes into the state of unspent
t_end = the moment that Neo goes into the state of spent
Δt_const = t_end - t_start
Δt_var = t - t_start
Available Gas = f(neo_amount, Δt_const)
Unavailable Gas = f(neo_amount, Δt_var)
Please note that:
Δt_const is fixed, thus the available Gas is of a fixed amount too. And this amount is a function of the amount of Neo held by the user and the duration between the moments that he or she transferred this amount of Neo into and out of his or her address. The current time is a variable, so the amount of the unavailable Gas also grows through time, which means it is a variable. -
Usage
- To pay to the Neo blockchain for recording
- To pay to the Neo blockchain for additional services