Parse-Docs
  • Getting Started
  • Introduction
    • PARSE stablecoin
    • Payment Gateway
    • Governance
  • technical guide
    • Target Price
    • Tax Protocol
    • Rebase Protocol
    • Architecture and Functionality
Powered by GitBook
On this page
  • Relations between contracts
  • ParseToken
  • State Variables
  • events
  • transfer()
  • approve()
  • transferFrom()
  • shareOf()
  • balanceOf()
  • totalShareSupply()
  • totalSupply()
  • PolicyMaker
  • State Variables
  • computeTaxRate()
  • computeRebasePercentage()
  • inTaxOrRebaseWindow()
  • Orchestrator
  • rebaseOrTax()
  • MarketOracle
  • CPIOracle
  1. technical guide

Architecture and Functionality

PreviousRebase Protocol

Last updated 2 years ago

Contracts related to PARSE stablecoin are mentioned in the table below:

contract
address

ParseToken

PolicyMaker

Orchestrator

Treasury

MarketOracle

CPIOracle

contract
address

ParseToken

PolicyMaker

Orchestrator

Treasury

MarketOracle

CPIOracle

All contracts are upgradeable. To upgrade a contract, members of DAO must vote on approving the upgrade proposal.

Relations between contracts

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

ParseToken is an ERC20 token, which is implemented based on the OpenZeppelin version 4 contracts.

State Variables

name
description

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.

events

In addition to events that a standard ERC20 token emits, there are some specific events:

  • rebased

  • taxRateUpdated

  • policyMakerUpdated

  • treasuryUpdated

transfer()

function transfer(address to, uint256 amount) public virtual override returns (bool)

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.

approve()

function approve(address spender, uint256 amount) public virtual override returns (bool)

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().

transferFrom()

function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool)

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.

Example

suppose the taxRate is 2%. Alice approves Bob to spend 1000 PARSE from her balance. At this stage, no tax will impose on anyone. Bob uses transferFrom() to pay 500 PARSE from Alice's balance. Alice's balance is decreased by 510 PARSE, and Bob can spend another 500 PARSE from Alice's balance.

shareOf()

function shareOf(address account) public view returns (uint256)

It is a none ERC20-standard function and returns the shares of the requested account.

balanceOf()

function balanceOf(address account) public view override returns (uint256)

It calculates the amount of PARSE of the requested account.

totalShareSupply()

function scaledTotalSupply() external pure returns (uint256)

It is a none ERC20-standard function and returns the total number of shares.

totalSupply()

function totalSupply() external view override returns (uint256)

It returns the total amount of PARSE tokens.

PolicyMaker

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.

State Variables

At least three kinds of public state variables can be found in this contract.

  • parameters of tax protocol such as θ,s\theta, sθ,s.

  • parameters of rebase protocol such as l,u,gl, u, gl,u,g.

  • parameters related to scheduling.

computeTaxRate()

function computeTaxRate(uint256 normalizedRate, uint256 taxStepThreshold, uint256 taxThetaThreshold, uint256 taxValue) public pure returns (uint256)

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.

computeRebasePercentage()

function computeRebasePercentage(int256 normalizedRate,int256 lower,int256 upper,int256 growth) public pure returns (int256)

As same as computeTaxRate() this function gives users the ability to compute rebase percentage.

inTaxOrRebaseWindow()

function inTaxOrRebaseWindow() public view returns (bool)

Using this function, anyone can see whether or not the current block timestamp is in the executable window.

Orchestrator

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.

rebaseOrTax()

function rebaseOrTax() external

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.

MarketOracle

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.

CPIOracle

It is almost as same as the MarketOracle.

0xe2f2a5c287993345a840db3b0845fbc70f5935a5
0xe2f2a5c287993345a840db3b0845fbc70f5935a5
0xe2f2a5c287993345a840db3b0845fbc70f5935a5
0xe2f2a5c287993345a840db3b0845fbc70f5935a5
0xe2f2a5c287993345a840db3b0845fbc70f5935a5
0xe2f2a5c287993345a840db3b0845fbc70f5935a5
0xe2f2a5c287993345a840db3b0845fbc70f5935a5
0xe2f2a5c287993345a840db3b0845fbc70f5935a5
0xe2f2a5c287993345a840db3b0845fbc70f5935a5
0xe2f2a5c287993345a840db3b0845fbc70f5935a5
0xe2f2a5c287993345a840db3b0845fbc70f5935a5
0xe2f2a5c287993345a840db3b0845fbc70f5935a5