After the CoLoa hardfork, 3 new consensus contracts are deployed:
NewSD/USD price can be fed to the consensus by the sealer/miner, every PriceSamplingInterval of block (~10 mins). Sealer can choose to feed the price or not. The median price is calculate by the median value of the last
PriceSamplingDuration blocks, (maximum 1008 values). The median price is only calculated when there's a super majority of sealers feed their prices. (That is 2/3 of 1008 = 672)
DEX is an onchain decentralized exchange for MNTY/NewSD pair, built for converting between the two tokens. The limit orders placed there can be filled by other user order, or will be filled by the system absorptions.
The order ID is calculated as bellow:
OrderID = sha256(maker+index)
Where:
This allows user to manage their own off-chain order list, much like an HDWallet does.
In initialization phase of the block, before any user tx is included, the DEX.OnBlockInitilized() is executed by the consensus, generating the first tx and receipt in the block. This execution does:
For every price block, the median price up to that block is passed to the DEX.OnBlockInitilized(MedianPrice), and the following additional actions are taken care by the execution:
No NewSD is mint out of thin air, nor to anyone will. NewSD must be exchanged with NTY by the market demand itself.
There are 3 conditions for an absorption to be triggered.
Passive absorption is triggered when there is no absorption for a week. This is the most defensive supply absorption mechanism to make sure the supply will continuously adjust to even the smallest change of demand, when the network is mature and well adopted.
For Passive and Active conditions, NewSD supply change is always calculated by the fed Median Price.
Active absorption is triggered when the price level is disruptively changed in an exponential ways, to quickly adjust to a new demand waves. An active absorption is triggered when.
or
When the price keeps going in the same direction (up or down), the next supply Change must be at least two times as large as the last one. This condition allows the network quickly adjust to the sudden change of market demand, but still makes it exponentially expensive for adversaries to manipulate the price of NewSD.
When the price is changing in one direction (from up to down, or vice versa), the next supply change must be at least half as large as the last one, in opposite direction. This change of direction allow the network to wind down the absorption in a stabilizing market.
For each block during the absorption, a market order is filled for the consensus with the amount of:
If there's not enough limit order to fill, no more token supply is changed. Additional order can be placed during the absorption time.
The absorption will end after either:
In the mainnet:
AbsorptionExpiration = 1 week
AbsorptionDuration = half a week
This is the most complicated mechanism of absorption, but provide the necessary flexibility to adjust the supply without waiting for a price to be deviated too far from an anchoring value. Anyone can initialize a preemptive absorption with a stake and a price. PeA requires an voting auction before and Lockdown after the absorption.
The Auction for Initiator starts when the first intiator submits her proposal on chain. NTY holders will vote for them as soon as the proposal is submitted. Each vote can have the following values:
If SlashingRate and LockdownExpiration is not provided, the global version of the params is used.
Proposal Requirements:
Anyone with NTY and/or MNTY can vote for or against a proposal. The weight of each vote is the total of NTY and MNTY, and only calculate at the ranking time. An address votes for a proposal, then transfer all NTY and MNTY out after that will have zero weight after that.
A rank of the a proposal is calculate as below:
When the active condition is reached, the proposal with the highest Rank win the auction, and active a new Pre-emptive Absorption.
The following global params are adapting to each winning proposal and preemptive absorption:
The adapting formula:
After the Voting Auction success, a new Pre-emptive Absorption is triggered with (Amount, LockdownExpiration, SlashingRate).
For each limit order absorbed by a PeA, an identical limit order is filled for the PeA maker with her token allowance for the DEX. If the allowance and balance are not sufficient, the side absorption will simply be ignored.
The PeA absorption will continues until the target supply is reached, even when no side-absorption occur.
During the lockdown, whenever the median price deviation goes in the opposite direction of the PeA:
The absorption will be resumed when the new median price goes in the same direction again.
The slashing MNTY amount is calculated as bellow:
The actual amount to be slashed must be positive and no more than the remaining stake.
If all the lockdown stake is slashed, the PeA will be prematurely stopped. Otherwise, the remaining stake will be refunded when the LockdownExpiration over.
Preemptive Absorption initiators are market makers, "bank" reserves, OTC dealers which are in control of large flows of money (NewSD). Not sitting outside of the system nor being centralized in anyway, they profit themselves by reserving and trading large amount of money (NewSD) while providing a high level of liquidity and stability to the network. As part of the decentralized system, anyone can be the Initiator, but without a large amount of fund, everyone can still be traders. NTY holders, initiators and traders together form a decentralized circle of stabilization, where each and everyone can profit themselves while provide the liquidity of NewSD as a service to the user of the network.