bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 15쪽 중 6쪽
doing so prohibitively expensive fail, the system may be vulnerable and left open for bad actors to drain collateral.
Adapters
Section titled “Adapters”
The
Vat
relies on external Adapter contracts to ensure that the collateral balances in the
Vat
represent real external collateral balances. Adapter contracts are authorized to make arbitrary modifications to all collateral balances. A faulty collateral adapter could result in the loss of all collateral in the system.
Contract Details
Section titled “Contract Details”
Glossary (Vat -
Vault
Engine)
Section titled “Glossary (Vat - Vault Engine)”
gem
: collateral tokens.
dai
: stablecoin tokens.
sin
: unbacked stablecoin (system debt, not belonging to any
urn
).
ilks
: a mapping of
Ilk
types.
Ilk
: a collateral type.
Art
: total normalized stablecoin debt.
rate
: stablecoin debt multiplier (accumulated stability fees).
spot
: collateral price with safety margin, i.e. the maximum stablecoin allowed per unit of collateral.
line
: the debt ceiling for a specific collateral type.
dust
: the debt floor for a specific collateral type.
urns
: a mapping of
Urn
types.
Urn
: a specific Vault.
ink
: collateral balance.
art
: normalized outstanding stablecoin debt.
init
: create a new collateral type.
slip
: modify a user’s collateral balance.
flux
: transfer collateral between users.
move
: transfer stablecoin between users.
grab
: liquidate a Vault.
heal
: create / destroy equal quantities of stablecoin and system debt (
vice
).
fold
: modify the debt multiplier, creating / destroying corresponding debt.
suck
: mint unbacked stablecoin (accounted for with
vice
).
Line
: the total debt ceiling for all collateral types.
frob
: modify a Vault.
lock
: transfer collateral into a Vault.
free
: transfer collateral from a Vault.
draw
: increase Vault debt, creating Dai.
wipe
: decrease Vault debt, destroying Dai.
dink
: change in collateral.
dart
: change in debt.
fork
: to split a Vault - binary approval or splitting/merging Vaults.
dink
: amount of collateral to exchange.
dart
: amount of stablecoin debt to exchange.
wish
: check whether an address is allowed to modify another address’s gem or dai balance.
hope
: enable
wish
for a pair of addresses.
nope
: disable
wish
for a pair of addresses.
Note:
art
and
Art
represent normalized debt, i.e. a value that when multiplied by the correct rate gives the up-to-date, current stablecoin debt.
Accounting
Section titled “Accounting”
debt
is the sum of all
dai
(the total quantity of dai issued).
vice
is the sum of all
sin
(the total quantity of system debt).
Ilk.Art
the sum of all
art
in the
urn
s for that
Ilk
.
debt
is
vice
plus the sum of
Ilk.Art * Ilk.rate
across all
ilks
.
Collateral
Section titled “Collateral”
gem
can always be transferred to any address by it’s owner.
Dai
Section titled “Dai”
dai
can only move with the consent of it’s owner.
dai
can always be transferred to any address by it’s owner.
Released into the public domain (CC0 1.0 Universal)
– trademarks remain with their owners; no warranty. See
full license
.
## /protocol/core/vow
Vow
The
Vow
contract represents the Sky Protocol’s balance sheet. In particular, the
Vow
acts as the recipient of both the system surplus and system debt.
Contract Details
Section titled “Contract Details”
Vow (Glossary)
Section titled “Vow (Glossary)”
sin
: the system debt queue.
Sin
: the total amount of debt in the queue.
Ash
: the total amount of on-auction debt.
wait
: length of the debt queue
sump
: debt auction bid size, i.e. the fixed debt quantity to be covered by any one debt auction
dump
: debt auction lot size, i.e. the starting amount of MKR offered to cover the
lot
/
sump
bump
: surplus auction lot size, i.e. the fixed surplus quantity to be sold by any one surplus auction
hump
: surplus buffer, must be exceeded before surplus auctions are possible
Other terms included in the above diagram:
move
: transfers stablecoin between users.
kick
: starts an auction.
Liquidations Manager
Section titled “Liquidations Manager”
Fess
- Pushes bad debt to the auctions queue (add debt to the queue).
Flog
- Release queued debt for auction (realize debt from the queue).
Heal
-
vow
calls
heal
on the
vat
contract to cancel out surplus and debt. (Optimize debt buffer (
vat.heal
)).
Kiss
- Cancels out surplus and on-auction debt. Release on-auction debt and Heal (
vat.heal
).
Flap
- Trigger a surplus auction (
flapper.kick
)
Flop
- Trigger a deficit auction (
flopper.kick
)
Authorization
Section titled “Authorization”
The
vow
contract calls
kick
on
flop
and
flap
.
System
Data
Section titled “System Data”
System config
Vow.wait
- Flop delay
Vow.sump
- Flop fixed bid size
Vow.dump
- Flop starting lot size
Vow.bump
- Flap fixed lot size
Vow.hump
- Surplus buffer
Debt (
SIN) Queue
Section titled “Debt (SIN) Queue”
When a Vault is liquidated
bite
, the seized debt is put in a queue for an auction in a
Vow
(labeled as
sin[timestamp]
- the system debt unit). This occurs at the block timestamp of the
bite
action. It can be released for auction via
flog
(
flog
releases queued debt for the auction) once the allotted
Vow.wait
(the flop delay) time has expired.
The
Sin
is stored when it’s in the debt queue, but the debt available to auction isn’t explicitly stored anywhere. This is because the debt that is eligible for auction is derived by comparing the
Sin
(i.e. debt on the holding queue) with the dai balance of the
Vow
as recorded in
Vat.dai[Vow]
. For instance, if
Vat.sin[Vow]
is greater than the sum of
Vow.Sin
and the
Ash
(debt currently on auction), then the difference may be eligible for a
Flop
auction.
Notes:
In the case of when a
dog.bite
/
vow.fess
is executed, the debt
tab
is added to
sin[now]
and
Sin
, which blocks that
tab
amount to be sent to the
flop
auction and all of the DAI is recovered with a
flip
auction. In theory, unblocking the
tab
amount in the
Sin
shouldn’t be necessary, but in practice it actually is. If this debt is not unblocked, then when we have a real need to send a
flop
auction, we might have a big
Sin
that blocks it. To summarize, this means that each registry of
sin[era]
that has an amount > 0 should be
flog
’ed before kicking a
flop
auction (this is because in order to kick the whole thing, you need every register to be 0, otherwise, it would be blocking debt).
Each
sin[era]
isn’t required to be a single
bite
, it will group all the
bite
’s that are in the same Ethereum block together.
The
auction-keeper
will
flog
every
era
with positive
Sin
if the
woe
+
Sin
>=
sump
, where
woe
=
vat.sin[vow]
-
vow.Sin
-
vow.Ash
.
Where the components within
vat.sin(vow)
-
vow.Sin
-
vow.Ash
are defined as:
vat.sin(vow)
- total bad debt
vow.Sin
- debt blocked
vow.Ash
- debt in auctions
Vow.sin
records individual portions of debt (marked with a timestamp). These are not directly auctioned off, but cleared when
flog
is called.
If the
Sin
is not covered by holding a
flip
auction within the designated wait time (
tau
), the
Sin
“matures” and gets marked as bad debt to the
Vow
. This bad debt can be covered through a debt auction (
flop
) when it exceeds a minimum value (the
lot
size). In short, the time between the debt being added to the
sin[]
queue and becoming “mature” (when it
flog
s off the queue and is eligible for
Flop
auction) is the amount of time that
Flip
auction has to clear that debt. This is due to the fact that when a
Flip
auction receives DAI, it decreases the
Vow
’s DAI balance in the
Vat
.
Note:
In this case, there is a risk that a circumstance can occur where the
Vow.wait
is different than the
Flip.tau
. The main risk being related to
wait
<
tau
, which would result in debt auctions running before the associated seized-collateral auctions could complete.
Overall
Sin
can affect the system in the following way:
There can be separate
Vow
s each with their own
sin
s
In the case of an upgrade, if we remove a
Vow
that has
sin
, this can create untracked bad debt in the system.
Accounting
Section titled “Accounting”
Vow.Sin
- This calculates the total queued debt in the system.
Vow.Ash
- This calculates the total on-auction debt.
3. Key Mechanisms & Concepts
Section titled “3. Key Mechanisms & Concepts”
It is important to note that the Sky Protocol will deviate from its equilibrium. This occurs when it receives system debt and system surplus through the collateral auctions and Vault stability fee accumulation. The
Vow
contract contains the logic to trigger both the debt (
flop
) and surplus (
flap
) auctions, which work to correct the system’s monetary imbalances.
Summary
System Debt:
In the case where Vaults are bitten (liquidated), their debt is taken on by the
Vow
contract as a
Sin
(the system debt unit). The
Sin
amount is then placed in the
Sin
queue.
Note:
When the
Sin
is not covered by a
flip
auction (within the dedicated
wait
time, the
Sin
is considered to have bad debt to the
Vow
. This bad debt is then covered through a debt auction (
flop
) when it exceeds a minimum value (the
lot
size).
System Surplus:
Occurs from stability fee accumulation, resulting in additional internal Dai in the
Vow
. This surplus is then discharged through a surplus auction (
flap
).
4. Gotchas (Potential source of user error)
Section titled “4. Gotchas (Potential source of user error)”
When the
Vow
is upgraded, there are multiple references to it that must be updated at the same time (
End
,
Jug
,
Pot
).
The
Vow
is the only user with a non-zero
Sin
balance (not a
vat
invariant as there can be multiple
Vow
s).
Ilk storage is split across the
Vat
,
Jug
,
Pot
and
Vow
modules. The
cat
also stores the liquidation penalty and maximum auction size.
A portion of the Stability Fee is allocated for the Dai Savings Rate (DSR) by increasing the amount of
Sin
in the
Vow
at every
Pot.drip( )
call.
Setting an incorrect value for
vow
can cause the surplus to be lost or stolen.
5. Failure Modes (Bounds on Operating Conditions & External Risk Factors)
Section titled “5. Failure Modes (Bounds on Operating Conditions & External Risk Factors)”
Vault Liquidation
Section titled “Vault Liquidation”
A failure mode could arise when no actors call
kiss
,
flog
or
heal
to reconcile/queue the debt.
Auctions
Section titled “Auctions”
A failure mode could arise if a user does not call
flap
or
flop
to kick off auctions.
Vow.wait
, when set too high (
wait
is too long), the
flop
auctions can no longer occur. This provides a risk of undercollateralization.
Vow.wait
, when set too low, can cause too many
flop
auctions, while preventing
flap
auctions from occurring.
Vow.bump
, when set too high, can result in no
flap
auctions being possible. Thus, if no
flap
auction takes place, there will be no MKR bidding as part of that process and, accordingly, no automated MKR burn as a result of a successful auction.
Vow.bump
, when set too low, results in
flap
auctions not being profitable for participants (
lot
size is worth less than gas cost). Thus, no MKR will be bid during a
flap
auction and, as a result, there will be no automated MKR burn.
Vow.sump
, when set too high, no
flop
auctions are possible. This results in the system not being able to recover from an undercollateralized state.
Vow.sump
, when set too low,
flop
auctions are not profitable for participants (where the
lot
size is worth less than gas cost). This results in MKR inflation due to automated MKR minting.
Vow.dump
, when set too high,
flop
auctions risk not being able to close or mint a large amount of MKR, creating a risk of MKR dilution and the possibility of a governance attack.
Vow.dump
, when set too low,
flop
auctions have to be
kick
ed many times before they will be interesting to keepers.
Vow.hump
, when set too high, the
flap
auctions would never occur. If a
flap
auction does not occur, there is no sale of surplus, and thus, no burning of bid MKR.
Vow.hump
, if set too low, can cause surplus to be auctioned off via
flap
auctions before it is used to cancel
sin
from liquidations, necessitating
flop
auctions and making the system run inefficiently.
Released into the public domain (CC0 1.0 Universal)
– trademarks remain with their owners; no warranty. See
full license
.
## /protocol/core/join
Join
Join consists of three smart contracts:
GemJoin
,
ETHJoin
, and
DaiJoin:
GemJoin
- allows standard ERC20 tokens to be deposited for use with the system.
ETHJoin
- allows native Ether to be used with the system.
DaiJoin
- allows users to withdraw their Dai from the system into a standard ERC20 token.
Each
join
contract is created specifically to allow the given token type to be
join
’ed to the
vat
. Because of this, each
join
contract has slightly different logic to account for the different types of tokens within the system.
How exactly do the
Join
contracts help the MCD system operate?
Section titled “How exactly do the Join contracts help the MCD system operate?”
The purpose of join adapters is to retain the security of the system, allowing only trusted smart contracts to add/remove value to/from the
Vat
. The location of collateral deposited/locked in Vaults is in the respective Join adapter.
Key Mechanisms & Concepts
Section titled “Key Mechanisms & Concepts”
The
GemJoin
contract serves a very specified and singular purpose which is relatively abstracted away from the rest of the core smart contract system. When a user desires to enter the system and interact with the
dss
contracts, they must use one of the
join
contracts. After they have finished with the
dss
contracts, they must call
exit
to leave the system and take out their tokens. When the
GemJoin
gets
cage
d by an
auth
ed address, it can
exit
collateral from the Vat but it can no longer
join
new collateral.
User balances for collateral tokens added to the system via
join
are accounted for in the
Vat
as
Gem
according to collateral type
Ilk
until they are converted into locked collateral tokens (
ink
) so the user can draw Dai.
The
DaiJoin
contract serves a similar purpose. It manages the exchange of Dai that is tracked in the
Vat
and ERC-20 Dai that is tracked by
Dai.sol
. After a user draws Dai against their collateral, they will have a balance in
Vat.dai
. This Dai balance can be
exit
’ ed from the Vat using the
DaiJoin
contract which holds the balance of
Vat.dai
and mint’s ERC-20 Dai. When a user wants to move their Dai back into the
Vat
accounting system (to pay back debt, participate in auctions, pack
bag
’s in the
End
, or utilize the DSR, etc), they must call
DaiJoin.join
. By calling
DaiJoin.join
this effectively
burn
’s the ERC-20 Dai and transfers
Vat.dai
from the
DaiJoin
’s balance to the User’s account in the
Vat
. Under normal operation of the system, the
Dai.totalSupply
should equal the
Vat.dai(DaiJoin)
balance. When the
DaiJoin
contract gets
cage
’d by an
auth
’ed address, it can move Dai back into the Vat but it can no longer
exit
Dai from the Vat.
Gotchas (Potential source of user error)
Section titled “Gotchas (Potential source of user error)”
The main source of user error with the
Join
contract is that Users should never
transfer
tokens directly to the contracts, they
must
use the
join
functions or they will not be able to retrieve their tokens.
There are limited sources of user error in the
join
contract system due to the limited functionality of the system. Barring a contract bug, should a user call
join
by accident they could always get their tokens back through the corresponding
exit
call on the given
join
contract.
The main issue to be aware of here would be a well-executed phishing attack. As the system evolves and potentially more
join
contracts are created, or more user interfaces are made, there is the potential for a user to have their funds stolen by a malicious
join
contract which does not actually send tokens to the
vat
, but instead to some other contract or wallet.
Failure Modes (Bounds on Operating Conditions & External Risk Factors)
Section titled “Failure Modes (Bounds on Operating Conditions & External Risk Factors)”
There could potentially be a
vat
upgrade that would require new
join
contracts to be created.
If a
gem
contract were to go through a token upgrade or have the tokens frozen while a user’s collateral was in the system, there could potentially be a scenario in which the users were unable to redeem their collateral after the freeze or upgrade was finished. This scenario likely presents little risk though because the token going through this upgrade would more than likely want to work alongside the Sky community to be sure this was not an issue.
Contract Details:
Section titled “Contract Details:”
Glossary (Join)
Section titled “Glossary (Join)”
vat
- storage of the
Vat
’s address.
ilk
- id of the Ilk for which a
GemJoin
is created for.
gem
- the address of the
ilk
for transferring.
dai
- the address of the
dai
token.
one
- a 10^27 uint used for math in
DaiJoin
.
live
- an access flag for the
join
adapter.
dec
- decimals for the Gem.
Every
join
contract has 4 public functions: a constructor,
join
,
exit
, and
cage
. The constructor is used on contract initialization and sets the core variables of that
join
contract.
Join
and
exit
are both true to their names.
Join
provides a mechanism for users to add the given token type to the
vat
. It has slightly different logic in each variation, but generally resolves down to a
transfer
and a function call in the
vat
.
Exit
is very similar, but instead allows the the user to remove their desired token from the
vat
.
Cage
allows the adapter to be drained (allows tokens to move out but not in).
Released into the public domain (CC0 1.0 Universal)
– trademarks remain with their owners; no warranty. See
full license
.
## /protocol/core/spot
Spot
The
Spot
liaison between the
oracles
and the core contracts. It functions as an interface contract and only stores the current
ilk
list.
Key Mechanisms & Concepts
Section titled “Key Mechanisms & Concepts”
Poke
Section titled “Poke”
poke
is the only non-authenticated function in
spot
. The function takes in a
bytes32
of the
ilk
to be “poked”.
poke
calls two
external
functions:
peek
calls the
OSM
for the given
ilk
and takes back in the
val
and
has
(a boolean which is false if there was an error in the
osm
).
When calculating the
spot
, the
par
is crucial to this calculation as it defines the relationship between DAI and 1 unit of value in the price. The
val
is then divided by the
par
(to get a ratio of
val
to
DAI
) and then the resulting value is divided by the
ilk.mat
. This gives us the current
spot
price for the given
ilk
. The second external call only happens if
has == true
.
file
is then called after calculating the
spot
. This updates the
vat
with the current liquidation price of the
ilk
which the function was called for.
Gotchas
Section titled “Gotchas”
The methods in the
spotter
are relatively basic compared to most other portions of
dss
. There is not much room for user error in the single unauthed method
poke
. If an incorrect
bytes32
is supplied the call will fail.
Any module that is authed against the
spot
has full root access, and can, therefore, add and remove which
ilks
can be “poked”. While not completely breaking the system, this could cause considerable risk.
Failure Modes
Section titled “Failure Modes”
Coding Error
Section titled “Coding Error”
A bug in
spot
would most likely result in the prices for collaterals not being update프로젝트로 돌아가기