bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 15쪽 중 8쪽
(the
Dog
), an auction is started promptly to sell the transferred collateral for DAI in an attempt to cancel out the debt now assigned to the protocol. This makes the behavior of the new contract very similar to that of the old one, but there are some important differences, explained below.
Partial vs. Total Liquidations
Section titled “Partial vs. Total Liquidations”
In the current system, in each call to the liquidation function (
Cat.bite
) transfers a fixed amount of debt (the
dunk
) from the affected Vault, along with a proportional amount of the Vault’s collateral to the protocol. For example, if 50% of a Vault’s debt is taken by the protocol, then half of its collateral is taken as well. If the Vault’s debt is less than the
dunk
, then all debt and collateral is taken. In 2.0, all debt is taken when the liquidation function (
Dog.bark
) is called, and no analogue of the
dunk
parameter exists. The reasoning behind this change is that because the new auctions allow partial purchases of collateral, the liquidity available to a participant no longer limits their ability to participate in auctions, so instead the total number of auctions should be minimized. Just to emphasize, there is no longer a minimum DAI liquidity requirement for the sale of collateral on a per-participant basis.
Limits on DAI Needed to Cover Debt and Fees of Active Auctions
Section titled “Limits on DAI Needed to Cover Debt and Fees of Active Auctions”
In situations involving large amounts of collateral at auction, the current and new designs modify the behavior described in the previous section. Both liquidations 1.2 and 2.0 implement a limit on the total amount of DAI needed to cover the summed debt and liquidation penalty associated with all active auctions. In
LIQ-1.2
this is called the
box
, and in
LIQ-2.0
we call this the
Hole
. Whenever the maximum possible addition to this value is less than the amount of debt+fees that would otherwise be sent to auction, a partial liquidation is performed so as not to exceed this amount. In the current system there is only a global limit; in 2.0, in addition to the global limit, there is also a per-collateral limit. Similar to how there is an
ilk.line
for a collateral’s debt ceiling and a
Line
for the overall system debt ceiling, there is now an
ilk.hole
to correspond with the
Hole
. This ensures that typical market depth against DAI can be taken into account on a per-collateral basis by those determining risk parameters. The
Dirt
accumulator tracks the total DAI needed to cover the debt and penalty fees of all active auctions, and must be less than
Hole
for a call to
bark
to succeed. For each collateral type,
ilk.dirt
tracks the total DAI needed to cover the debt and penalty fees of a all active auctions for that
ilk
, and must be less than
ilk.hole
for a call to
bark
(on a Vault of that
ilk
) to succeed.
Auction Initiation
Section titled “Auction Initiation”
https://github.com/sky-ecosystem/dss/blob/liq-2.0/src/clip.sol
The auction initiation function (
Clipper.kick
) takes four caller supplied arguments:
Section titled “The auction initiation function (Clipper.kick) takes four caller supplied arguments:”
tab
: the target DAI to raise from the auction (
debt
+
stability fees
+
liquidation penalty
) [rad]
lot
: the amount of collateral available for purchase [wad]
usr
: the address to return any excess collateral to
kpr
: the address where DAI incentives will be sent
Clipper.kick
performs several checks and actions:
Section titled “Clipper.kick performs several checks and actions:”
checks that the caller is authorized (only the
Dog
or governance may call
Clipper.kick
)
checks that liquidations are enabled in the four-stage circuit breaker
increments a counter and assigns a unique numerical
id
to the new auction
inserts the
id
into a list tracking active auctions
creates a structure to record the parameters of the auction; this includes:
it’s position in the active auctions list
the target amount of DAI to raise from bidders (
tab
)
the amount of collateral available for purchase (
lot
)
the Vault that was liquidated to create this auction
allows return of collateral if not all of it is sold
allows the return of collateral and
tab
when
Clipper.yank
is called by
End.snip
the timestamp of the auctions creation (as a Unix epoch)
the initial price of collateral in the auction (
top
)
sends an incentive denominated in DAI to the
kpr
fires the
Kick()
event
The initial price is set by reading the current price in the corresponding Oracle Security Module (OSM) and multiplying by a configurable percentage (the
buf
parameter). Note that the
current
OSM price is between one and two hours delayed relative to the actual market price. A keeper doesn’t make a call to
Clipper.kick
directly, but rather makes a call to
Dog.bark
which in turn calls
Clipper.kick
.
Liquidation Incentive Mechanism
Section titled “Liquidation Incentive Mechanism”
In this design, there is less incentive to quickly liquidate Vaults than in the current system, because there is no inherent advantage obtained by doing so. In contrast, the current auction system grants the account triggering a liquidation the privilege of making the first bid in the resulting auction. It is unclear whether this matters significantly in practice, or whether some stronger incentive should be added (for example, a small DAI reward paid to liquidators).
To ensure there was a remedy for this potential issue, an incentive mechanism was added for liquidators. The form of the incentive is, on a per-collateral type basis, a constant amount of DAI plus an amount of DAI that scales linearly with the amount of debt associated with the liquidation. Either contribution can be set to zero. Such a structure is justified by the following:
The reward is set per-collateral to give maximum flexibility to include not just per-collateral risk parameters like
mat
(collateralization ratio) and
chop
(liquidation penalty) in its setting, but also to allow for unique market conditions that might only apply to one or a few collateral types.
The component of the reward that increases linearly with the total Vault debt is intended to be used to reward liquidators for reducing risk to the system, as risk itself scales with the size of undercollateralized Vaults—a Vault that is twice as big as another represents twice the risk of bad debt accrual. Or viewed another way, liquidating two vaults of size X represents the same risk reduction as liquidating one Vault of size 2X—thus the reward to a liquidator ought to be similar. Further, the system can
afford
to pay more for larger liquidations, because the liquidation penalty is also proportional to the amount of debt outstanding for a given Vault.
The constant component of the reward can be used to cover gas costs (which are per-Vault for liquidators) or to allow SKY holders to effectively pay Keepers to clear small Vaults that would otherwise not be attractive for liquidation.
These parameters must be set extremely carefully, lest it be possible to exploit the system by “farming” liquidation rewards (e.g. creating Vaults with the intention of liquidating them and profiting from the too-high rewards). Generally, the liquidation reward should remain less than the minimum liquidation penalty by some margin of safety so that the system is unlikely to accrue a deficit. This doesn’t necessarily prevent farming, it just helps ensure the system remains solvent. For example, incentives can be farmed in a capital-efficient way when
Dirt
is close to
Hole
or when
ilk.dirt
is close to
ilk.hole
for some collateral type. An attacker would purchase a small amount of collateral from a running auction, freeing up a small amount of room relative to either
Hole
or
ilk.hole
, then liquidate a small portion of an existing Vault to collect the reward, and repeat the process. This can be done over and over in the same transaction, and the activation of EIP 2929 (scheduled for the Berlin hard fork at the time of writing) will significantly reduce the associated gas costs (due to warm storage reads and writes). Note that since the attacker does not need to create their own Vaults, the size of the liquidation penalty in relation to the incentive value is not a deterrent; only gas costs matter to the attacker. The fact that the Dog prevents partial liquidations that remove less than
ilk.dust
debt from a Vault helps to mitigate this scenario–so long as the liquidation penalty exceeds the total reward for this minimal liquidation size,
and the liquidation penalty is reliably collected by the resulting auction
(which may not hold under conditions of market or network perturbation), the system should not on balance accrue bad debt.
Four-Stage Liquidation Circuit Breaker
Section titled “Four-Stage Liquidation Circuit Breaker”
In this section, we’ll cover the four stages of the liquidation circuit breaker. In contrast to
LIQ-1.2
, Liquidations 2.0 comes with a four-stage circuit breaker built into the
Clipper
contract. The stages are:
liquidations enabled
(
0
): This means the breaker is not tripped and the protocol can liquidate new Vaults as well as service old liquidations.
new liquidations disabled
(
1
): This means no new liquidations (
Clipper.kick
).
new liquidations and resets disabled
(
2
): This means no new liquidations (
Clipper.kick
), and auctions that have reached either a price or time endpoint cannot be reset (
Clipper.redo
).
liquidations disabled
(
3
): This means no new liquidations (
Clipper.kick
), no takes (
Clipper.take
), and no resets (
Clipper.redo
).
Just like in
LIQ-1.2
, the circuit breaker will be available through a
ClipperMom
contract giving governance the ability to bypass the
GSM
delay for circuit breaker actions.
Bidding (Purchasing)
Section titled “Bidding (Purchasing)”
https://github.com/sky-ecosystem/dss/blob/liq-2.0/src/clip.sol
The purchasing function (
Clipper.take
) takes five caller supplied arguments:
Section titled “The purchasing function (Clipper.take) takes five caller supplied arguments:”
id
: the numerical id of the auction to bid on
amt
: the maximum amount of collateral to buy (
amt
) — a purchase behaves like a limit order [wad]
max
: the maximum acceptable price in DAI per unit collateral (
max
) [ray]
who
: address that will receive the collateral (
who
)
data
: an arbitrary bytestring (if provided, the address
who
, if it is neither the
Dog
nor
Vat
address stored by the Clipper, is called as a contract via an interface described below, to which this data is passed) [bytes]
Clipper.take
performs several initial checks:
Section titled “Clipper.take performs several initial checks:”
a reentrancy check to ensure the function is not being recursively invoked
that the four-stage circuit breaker is not tripped
that the auction id corresponds to a valid auction
that the auction does not need to be reset, either due to having experienced too large a percentage decrease in price, or having existed for too long of a time duration
that the caller’s specified maximum price is at least the current auction price
Then, the amount of collateral to attempt to purchase is computed as the minimum of the collateral left in the auction (
lot
) and the caller’s specified quantity (
amt
)—the resulting value is the
slice
. This value is then multiplied by the current price of the auction to compute the DAI owed in exchange (
owe
). If
owe
exceeds the DAI collection target of the auction (
tab
), then
owe
is adjusted to be equal to
tab
, and
slice
is set to
tab / price
(i.e. the auction will not sell more collateral than is needed to cover debt+fees from the liquidated Vault).
To make it less likely that auctions are left in a state that is unattractive to bid on, further logic is applied if there will be both left over DAI target and collateral based on the initial determinations for
slice
and
owe
. If the remaining
tab
in such a case would be less than
chost
(a value stored by the contract, asynchronously set to
ilk.dust * ilk.chop / WAD
by the
upchost()
function), then: 1) If the overall DAI target is less than
chost
,
the function reverts. Callers should be aware of this possibility and account for it when necessary.
2) Otherwise,
owe
is set to
tab - chost
, and
slice
is set to
(tab - chost) / price
.
This heuristic for preventing a too-small remaining collateral amount and/or DAI target is imperfect and may fail in some situations; if this occurs, there is no serious harm to the protocol; the auction will simply remain uncompleted. However, governance may wish to fully clear such “lost” auctions via
take
or
yank
to avoid cluttering the list of active auctions each
Clipper
maintains, which could impair the performance of DEX and aggregator integrations (and possibly off-chain bots too, depending on how they are written).
Next, collateral is transferred (within the protocol’s
Vat
to the
who
address provided by the caller. If the caller provided a bytestring with greater than zero length, an external call is made to the
who
address, assuming it exposes a function, follow Solidity conventions, with the following signature:
clipperCall
(
address
,
// recipient of DAI
uint256
,
// owe [rad]
uint256
,
// slice [wad]
bytes
calldata
)
The first argument is the recipient of DAI. That is, this is the address the
clipperCallee
must return DAI to. The second argument is DAI owed (as a 45 decimal digit fixed-precision integer, or
rad
), the third argument is the collateral being purchased (as an 18 decimal digit fixed-precision integer, or
wad
), regardless of the precision of the external token contract, and the last argument is identical to what bytestring the caller originally supplied to the purchase function. As mentioned earlier, a locking mechanism prevents reentry into the purchase function during this external call, and the
Clipper.redo
call, for security reasons. Example implementations of the
ClipperCallee
interface can be found in the
exchange-callees
repository.
After the external call completes (or immediately following the transfer of collateral, if no external call was executed), DAI is transferred (internally, within
Vat
from
msg.sender
to the protocol.
Lastly, various values are updated to record the changed state of the auction: the DAI needed to cover debt and fees for outstanding auctions, and outstanding auctions of the given collateral type, are reduced (via a callback to the liquidator contract) is reduced by
owe
, and the
tab
(DAI collection target) and
lot
(collateral for sale) of the auction are adjusted as well. If all collateral has been drained from an auction, all its data is cleared and it is removed from the active auctions list. If collateral remains, but the DAI collection target has been reached, the same is done and excess collateral is returned to the liquidated Vault.
Example Liquidation
Section titled “Example Liquidation”
Figure 1
: NOTE: in the above figure,
tau
is
tail
.
In this example we can see a linear decrease function (
calc
), with an
ETH-A
OSM price of
200 DAI
, a
buf
of
20%
, a
tail (tau)
of
21600
seconds, a
tab
of
*60,000 DAI
with a
lot
of
347.32
ETH. There are two bidders,
Alice
and
Bob
.
Alice
calls
take
first and is willing to give
*50,000 DAI
in return for
256.41
ETH collateral, a price of
195 DAI
per ETH. The price of ETH continues to fall over time, and
Bob
picks up the remaining
90.91
ETH for
10,000 DAI
, a price of
110 DAI
per ETH. If more than
tail
seconds have elapsed since the start of the auction, or if the price has fallen to less than
cusp
percent of
top
, then
Clipper.take
would revert if called, and the auction would need to be reset with a
Clipper.redo
call.
Incentive to call
redo()
Section titled “Incentive to call redo()”
https://github.com/sky-ecosystem/dss/blob/liq-2.0/src/clip.sol
The auction initiation function (
Clipper.redo
) takes two caller supplied arguments:
Section titled “The auction initiation function (Clipper.redo) takes two caller supplied arguments:”
id
: the current auction id
kpr
: the address where DAI incentives will be sent
Clipper.redo
performs several checks and actions:
Section titled “Clipper.redo performs several checks and actions:”
a reentrancy check to ensure the function is not being recursively invoked
that the four-stage circuit breaker is not tripped
that the auction id corresponds to a valid auction
that the auction needs to be reset, either due to having experienced too large a percentage decrease in price, or having existed for too long of a time duration
updates several fields of the existing auction
tic
to reset the auction start time
top
with the current OSM price and
buf
percent
vat.suck
s DAI to the
kpr
as an incentive if eligible
fires the
Redo()
event
An auction that has expired or which is currently offered at a value higher than the oracle threshold will likely not complete at favorable values. The system therefore provides a direct incentive to
Clipper.redo
the auction, resetting it’s expiration and setting the starting price to match the current oracle price + buf. The redo includes the same Dai incentive to the keeper as the
Clipper.kick
, which is based on the flat fee plus the governance-defined percentage of collateral. There is one exception to this incentive. If the
tab
or
lot * price
remaining is under the
Clipper.chost
limit, then there will be no incentive paid to
redo
the auction. This is to help prevent incentive farming attacks where no keepers bid on dusty lots, and
Clipper.redo
is called repeatedly. If auctions in this state build up, governance may choose to pay a keeper to clean them up.
Emergency Shutdown
Section titled “Emergency Shutdown”
https://github.com/sky-ecosystem/dss/blob/liq-2.0/src/end.sol
A started auction can be reverted via the
auth
function called
yank
in
Clipper
contract. This function requires that the auction exists and executes the following actions:
calls
dog.digs
in order to decrease its
Dirt
and
ilk.dirt
values by the remaining auction
tab
sends the remaining collateral to its
msg.sender
removes the auction struct data
fires the
Yank()
event
This function might be thought of as a general purpose operation to migrate existing auctions to a new contract; however, the only use-case now is in the
End
module, which takes care of system shutdown.
The
End
module will be upgraded together with the auction contracts as a new function
End.snip
is required.
This function
End.snip
is responsible for calling
Clipper.yank
for any running auction when shutdown is triggered. It will receive the collateral from
Clipper.yank
and will send it back to the vault owner together with the remaining debt to recover. One consideration to note is that the debt that the vault owner will receive includes the liquidation penalty part already charged.
Interfaces
Section titled “Interfaces”
Dog
Interface
Section titled “Dog Interface”
function wards(address) external view returns (uint256);
function rely(address) external;
function deny(address) external;
Standard Sky Ecosystem authorization structure.
function vat() external view returns (address);
function vow() external view returns (address);
DSS core address introspection.
function ilks(bytes32 ilk) external view returns (
address clip,
uint256 chop, // wad
uint256 hole, // rad
uint256 dirt); // rad
Returns values configured for a given ilk (ex.
ETH-A
).
function live() external view returns (uint256);
Returns
1
if the system is active.
function Hole() external view returns (uint256);
function Dirt() external view returns (uint256);
Getters for the global Hole and Dirt configuration. Both return a 프로젝트로 돌아가기