Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for Vow, Flapper, Flopper, Pot, Jug #101

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 178 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,82 +423,254 @@ _SystemState_: Adds _liquidationPenalty_ * _due_ to the _totalDaiAmountToCoverDe

#### Accumulation of Stability Fees for Collateral Types (Jug)

> fill me with the description of the contract
> The primary function of the Jug smart contract is to accumulate stability fees for a particular collateral type whenever its _drip()_ method is called.

##### handleInit
Updates:
- _CollateralType_

Fetches the _CollateralType_ according to _arg1_, sets _stabilityFee_ to '1' and _stabilityFeeUpdateAt_ to the timestamp of the block.

##### handleDrip
Updates:
- _CollateralType_

Updates the _stabilityFeeUpdatedAt_ of the CollateralType.

##### handleFile
Updates:
- _SystemState_
- _ColllateralType_

Updates variables according to the _what_ variable.

what="duty": Updates _CollateralType.stabilityFee_ to the Ray value from _data_.

what="base": Updates _SystemState.baseStabilityFee_ to the Ray value from _data_.

what="vow": Updates _SystemState.jugVowContract_ to the Address from _data_.

#### The Dai Savings Rate (Pot)

> fill me with the description of the contract
> The Pot is the core of theDai Savings Rate. It allows users to deposit dai and activate the Dai Savings Rate and earning savings on their dai.

##### handleFile
Updates:
- _SystemState_

Updates the _SystemState_ according to the _what_ variable.

_what_="dsr": Updates _SystemState.savingsRate_ with the Ray value from _data_.

_what_="vow": Updates _SystemState.potVowContract_ with the value from _data_.

##### handleCage
Creates:
- _LiveChangeLog_

Updates:
- _SystemState_

Updates the _SystemState.savingsRate_ to 1 and creates a new _LiveChangeLog_.

##### handleJoin
Updates:
- _User_
- _SystemState_

Adds the WDA value _arg1_ to _User.savings_ and _SystemState.totalSavingsInPot_. The Subgraph will update these values according to the result.

##### handleExit
Updates:
- _User_
- _SystemState_

Substracts the WDA value _arg1_ from _User.savings_ and _SystemState.totalSavingsInPot_. The Subgraph will update these values according to the result.

##### handleDrip
Updates:
- _SystemState_

Binds the Pot contract to get the _chi_ value from the contract. Afterwards, the subgraph will update _SystemState.rateAccumulator_ with the resultvalue and sets _SystemState.lastPotDripAt_ to the timestamp of the block.

### System Stabilizer Module:

> fill me with the description of the module

#### Surplus Auction House (Flapper)

> fill me with the description of the contract
> Flapper is a Surplus Auction. These auctions are used to auction off a fixed amount of the surplus Dai in the system for MKR. This surplus Dai will come from the Stability Fees that are accumulated from Vaults. In this auction type, bidders compete with increasing amounts of MKR. Once the auction has ended, the Dai auctioned off is sent to the winning bidder. The system then burns the MKR received from the winning bid.

##### handleFile
Updates:
- _SystemState_

Updates _SystemState_ according to the _what_ value.

_what_="beg": Updates _surplusAuctionMinimumBidIncrease_ to the WAD value from _data_.

_what_="ttl": Updates _surplusAuctionBidDuration_ to the value from _data_.

_what_="tau": Updates _surplusAuctionDuration_ to the value from _data_.

##### handleCage
Creates:
- _LiveChangeLog_

Creates the LiveChangeLog event with the required values.

##### handleKick
Updates:
- _SystemState_
- _SurplusAuction_

Updates _bidAmount_, _quantity_, _highestBidder_ from the _SurplusAuction_ entities to the values from the event and sets _active_ to true. If _SystemState.surplusAuctionBidDuration_ is set, it will add the block timestamp to this value.

##### handleTick
Updates:
- _SurplusAuction_

Sets _SurplusAuction.endTimeAt_ to the timestamp of the block and adds _SystemState.surplusAuctionBidDuration_ to it

##### handleDeal
Updates:
- _SurplusAuction_

Sets the _highestBidder_ to the transaction creator.

##### handleTend
Updates:
- _SurplusAuction_

Sets the _highestBidder_ to the transaction creator and updates the _bidAmount_ to Int value of _arg2_.

##### handleYank
Updates:
- _SurplusAuction_

Deactivates (_active_=false) the _SurplusAuction_ and sets the _deletedAt_ variable.

#### Debt Auction House (Flopper)

> fill me with the description of the contract
> Debt Auctions are used to recapitalize the system by auctioning off MKR for a fixed amount of DAI. In this process, bidders compete by offering to accept decreasing amounts of MKR for the DAI they will end up paying.

##### handleFile
Updates:
- _SystemSate_

Updates the _SystemSate_ according to the _what_ value.

_what_="beg": Updates _debtAuctionMinimumBidIncrease_ to the WAD value from _data_.

_what_="pad": Updates _debtAuctionLotSizeIncrease_ to the WAD value from _data_.

_what_="ttl": Updates _debtAuctionBidDuration_ to the value from _data_.

_what_="tau": Updates _debtAuctionDuration_ to the value from _data_.

##### handleCage
Creates:
- _LiveChangeLog_

Creates the entity _LiveChangeLog_

##### handleKick
Updates:
- _DebtAuction_

Receives a _Kick_ event as input. Sets _bidAmount_ to the _bid_ value, _quantity_ to the _lot_ value and _hgihestBidder_ to the _gal_ value from the event. Sets the endTimeAt to the timestamp of the block plus _SystemState.debtAuctionBidDuration_.


##### handleTick
Updates:
- _DebtAuction_

Calculates _SystemState.debtAuctionLotSizeIncrease_ * _auction.quantity_ (lot in the contract), converts the result to WAD and sets it to _DebtAuction.quantity_. Updates _endTimeAt_ to the block timestamp + _SystemState.debtAuctionBidDuration_.

##### handleDeal
Updates:
- _DebtAuction_

Deactivates the _DebtAuction_(_active_ = false) and sets the _deletedAt_ variable to the timestamp of the block.

##### handleDent
Updates:
- _DebtAuction_

Sets the _highestBidder_ to the transaction creator and the _quantity_ to the Int value from _arg2_. Updates _endTimeAt_ to the block timestamp + _SystemState.debtAuctionBidDuration_.

##### handleYank
Updates:
- _DebtAuction_

Deactivates the _DebtAuction_(_active_ = false) and sets the _deletedAt_ variable to the timestamp of the block.

#### Balance Sheet (Vow)

> fill me with the description of the contract
> The Vow contract represents the Maker Protocol's balance sheet. In particular, the Vow acts as the recipient of both the system surplus and system debt. Its main functions are to cover deficits via debt (Flop) auctions and discharge surpluses via surplus (Flap) auctions.

##### handleFile
Updates:
- _SystemState_

Sets variables according to the _what_ value from the _LogNote_ event.

_what_="wait": Updates _debtAuctionDelay_ to the value from _data_.

_what_="bump": Updates _surplusAuctionLotSize_ to the RAD value from _data_.

_what_="sump": Updates _debtAuctionBidSize_ to the RAD value from _data_.

_what_="dump": Updates _debtAuctionInitialLotSize_ to the WAD value from _data_.

_what_="hump": Updates _surplusAuctionBuffer_ to the RAD value from _data_.

_what_="flapper": Updates _vowFlapperContract_ to the Address from _arg2_.

_what_="flopper": Updates _vowFlopperContract_ to the Address from _arg2_.

##### handleCage
Creates:
- _LiveChangeLog_

Creates a _LiveChangeLog_ entity

##### handleFlog
Creates:
- _PopDebtQueueLog_

Updates:
- _SystemState_

Binds to the Vow contract to receive the _sin_ value from the _era_ (=_arg1_). It afterwards substracts the RAD value from the result from the _SystemState.systemDebtInQueue_ value. It updates _SystemState.systemDebtInQueue_ with the result from this calculation. The subgraph will then create the _PopDebtQueueLog_ entity.

##### handleFrog

##### handleFess
Creates:
- _PushDebtQueueLog_

Updates:
- _SystemState_

Adds _SystemState.systemDebtInQueue_ with the RAD value from _tab(=_arg1) and updates _SystemState.systemDebtInQueue_ with the result.

##### handleFlap
Creates:
- _VowFlapLog_

Creates a _VowFlapLog_ entity and sets the _VowFlapLog.surplusAuctionLotSize_ to the value from _SystemState.surplusAuctionLotSize_.

##### handleFlop
Creates:
- _VowFlopLog_

Updates:
- _SystemState_

Adds _SystemState.debtOnAuctionTotalAmount_ (=_ash_; if the value is not set it will default to 0) with _SystemState.debtAuctionBidSize_(=_sump_) and sets the result to _SystemState.debtOnAuctionTotalAmount_. The subgraph will create the entity _VowFlopLog_ afterwards.

##### handleKiss
Updates:
- _SystemState_

Sets the _SystemState.debtOnAuctionTotalAmount_ to the RAD value from _arg1_ + the current value from _debtOnAuctionTotalAmount_.