Implementation
IMPLEMENTATION
Normally, on the Ethereum blockchain network, ERC20 is most commonly used as a standard, creating a mapping of each ERC20 to the smart contract itself is not a standard in the Ethereum blockchain network, therefore we have created a new standard called ERC20-multi.
Since each token has its own contract address, by using ERC20-multi, we could hold the information of each token.
Each token has the following attribute mapped in the Solid protocol:
Amount of the “Solid version” of the token (supply of Solid)
Exponential average trading volume (EATV)
Last traded timestamp
Individuals can buy with any ERC-20 token in the Ethereum blockchain network, the amount that one can get is calculated based on the mechanism stated in the above session of this paper.
Functions
Mathematical calculation is expensive on the Ethereum blockchain network, which could consume a lot of gas. Calculation such as square root and cubic root could be costly. Therefore, the most optimized algorithm of such functions should be used.
The discussion below is based on Solidity in the Ethereum blockchain network.
Square root function
The square root function used here (a fast square root algorithm by bit shift) is different from the one used in the UNISWAPV2 contract in the Ethereum blockchain network (Babylonian method), which is generally consuming less gas.
For big number such as 1000000000000000, the Babylonian method consumes 3569 gases, while the square root function here only consumes 1008 gases. The Babylonian method generally consumes more gas but only consumes slightly less when the input is small (< 273) compared to the square root function.
Cubic root function
The cubic root function adapted an algorithm (with quadratic convergence) [2], which is generally consuming less gas than methods such as the nth-Newton-Raphson method and binary search.
Initialization
As there could be a division-by-0 error when the supply is 0, there are minimum values staked balance and supply that should be set to avoid such error.
The default value for pointer mapping storing data is always 0 in solidity and could not be changed, therefore, a function is created so that this function must be called to assign the minimum values accordingly before any trade takes place in all ERC20 token.
EAVT uses an interval of 1800 seconds, multiplied by 48 would be 86400 seconds (seconds in a day), however, note that on Ethereum blockchain network blocks updates every ~14 seconds, so theoretically there is a fixed possibility for δ.
Proof by staking means locking liquidity as a way to ensure those supply would not be burnt through the Solid Protocol, which could be different from other terms also with the same name (“Proof by staking”)
Last updated