Architecture and Functionality
Last updated
Last updated
Contracts related to PARSE stablecoin are mentioned in the table below:
PolicyMaker
Orchestrator
MarketOracle
All contracts are upgradeable. To upgrade a contract, members of DAO must vote on approving the upgrade proposal.
a) Users can interact with the ParseToken contract like an ordinary ERC20 token contract.
b) Every day, a user calls the Orchestrator to trigger tax and rebase protocols.
c) Orchestrator sends a transaction to the PolicyMaker contract.
d, e) PolicyMaker reads data from the oracles and calculates taxRate
and deltaSuppluy.
f) PolicyMaker sets those parameters to the ParseToke contract.
g) Treasury Contract manages the collected taxes.
ParseToken is an ERC20 token, which is implemented based on the OpenZeppelin version 4 contracts.
policyMaker
address of policy maker contract
treasury
address of treasury contract
taxRate
determines how much tax will impose on transfers.
taxExpirationTime
the time passes (in seconds) from the moment of setting the taxRate
that remains valid.
lastTimeTaxUpdated
block timestamp of the last time taxRate
was updated.
In addition to events that a standard ERC20 token emits, there are some specific events:
rebased
taxRateUpdated
policyMakerUpdated
treasuryUpdated
If the price of PARSE is in the tax window, before transferring value
from the sender's address to receive's address, the contract calculates tax-value
and subtracts it from the senders' balance and adds it to the treasury.
It allows the spender
to withdraw an amount
of PARSE from the transaction sender's address. no tax will impose on any type of approval, such as increaseAllowance()
and decreaseAllowance()
.
Working the same as the transfer
function. note that only the allower (address in from
variable) will pay tax, and the tax it pays does not impact the approval amount.
It is a none ERC20-standard function and returns the shares of the requested account.
It calculates the amount of PARSE of the requested account.
It is a none ERC20-standard function and returns the total number of shares.
It returns the total amount of PARSE tokens.
This contract manages the supply of PARSE stablecoin and determines whether or not to impose a tax on transactions. The functionality of this contract is quite complicated. We encourage interested readers to examine this contract's source code in order to understand its functionality deeply. In this article, we explore some important ones.
At least three kinds of public state variables can be found in this contract.
parameters of tax protocol such as .
parameters of rebase protocol such as .
parameters related to scheduling.
This public function helps users to calculate the tax rate based on arbitrary parameters. The contract uses exactly this function to calculate the tax rate. The publicness of this function improves the transparency and predictability of the ecosystem.
As same as computeTaxRate()
this function gives users the ability to compute rebase percentage.
Using this function, anyone can see whether or not the current block timestamp is in the executable window.
Users call the orchestrator contract to execute rebase protocol or to calculate the taxRate
. In other words, the Orchestrator contract is the entry point for making monetary policies. The orchestrator contract has a list of transactions. Those transactions execute after someone calls rebaseOrTax()
function. The purpose of such transactions is to inform certain smart contracts that possibly rebase will happen or taxRate
will be changed.
This function is the means of access to activating rebase protocol and recalculating taxRate
. It must call directly by an externally owned account. Note that it will be reverted if someone calls rebaseOrTax()
function at the wrong time. For more information about the timing, click here.
The list of transactions is stored in the transactions
variable. The visibility of this variable is public, so anyone can see it by requesting from any Polygon node.
Data providers approved by DAO push prices into the MarketOracle contract. There is a certain amount of time that a price is valid after it is pushed. When getData()
function is called the contract checks if there is at least minimumProviders
(a global variable in the contract) valid data in the contract then returns the median of them.
It is almost as same as the MarketOracle.