USDS 백서

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 15쪽 중 7쪽

d anymore. In this case, the system would need to authorize a new spot which would then be able to update the prices. Overall this is not a catastrophic failure as this would only pause all price fluctuation for some period. Feeds Section titled “Feeds” The spot relies upon a set of trusted oracles to provide price data. Should these price feeds fail, it would become possible for unbacked Dai to be minted, or safe Vaults could be unfairly liquidated. Spot Price Becoming Stale Section titled “Spot Price Becoming Stale” When poke is not called frequently enough, the Vat ’s spot price will become stale. This could arise for a few reasons including tragedy of the commons or miner collusion and could lead to negative outcomes such as inappropriate liquidations, or the prevention of liquidations that should be possible. Contract Details Section titled “Contract Details” Math Section titled “Math” All mathematical operations will revert on overflow or underflow Complexity Section titled “Complexity” All methods execute in constant time Variables Section titled “Variables” ilk a given collateral type ilk.pip the contract which holds the current price of a given ilk ilk.mat the liquidation ratio for a given ilk vat the core of the mcd system par value of DAI in the reference asset (e.g. $1 per DAI) Collateral Section titled “Collateral” Only authorized users can update any variables in contract Released into the public domain (CC0 1.0 Universal) – trademarks remain with their owners; no warranty. See full license . ## /protocol/core/osm OSM (Oracle Security Module) The OSM (named via acronym from “Oracle Security Module”) ensures that new price values propagated from the Oracles are not taken up by the system until a specified delay has passed. Values are read from any contract that has the read() and peek() interfaces via the poke() method; the read() and peek() methods will give the current value of the price feed, and other contracts must be whitelisted in order to call these. An OSM contract can only read from a single price feed, so in practice one OSM contract must be deployed per collateral type. Key Mechanisms & Concepts Section titled “Key Mechanisms & Concepts” The central mechanism of the OSM is to periodically feed a delayed price into the MCD system for a particular collateral type. For this to work properly, an external actor must regularly call the poke() method to update the current price and read the next price. The contract tracks the time of the last call to poke() in the zzz variable (rounded down to the nearest multiple of hop , and will not allow poke() to be called again until block.timestamp is at least zzz+hop . Values are read from a designated DSValue contract (its address is stored in src ). The purpose of this delayed updating mechanism is to ensure that there is time to detect and react to an Oracle attack (e.g. setting a collateral’s price to zero). Responses to this include calling stop() or void() , or triggering Emergency Shutdown. Other contracts, if whitelisted, may inspect the cur value via the peek() and read() methods ( peek() returns an additional boolean indicating whether the value has actually been set; read() reverts if the value has not been set). The nxt value may be inspected via peep() . The contract uses a dual-tier authorization scheme: addresses mapped to 1 in wards may start and stop, set the src , call void() , and add new readers; addresses mapped to 1 in buds may call peek() , peep() , and read() . Gotchas (Potential Sources of User Error) Section titled “Gotchas (Potential Sources of User Error)” Confusing peek() for peep() (or vice-versa) Section titled “Confusing peek() for peep() (or vice-versa)” The names of these methods differ by only a single character and in current linguistic usage, both “peek” and “peep” have essentially the same meaning. This makes it easy for a developer to confuse the two and call the wrong one. The effects of such an error are naturally context-dependent, but could e.g. completely invalidate the purpose of the OSM if the peep() is called where instead peek() should be used. A mnemonic to help distinguish them: “since ‘k’ comes before ‘p’ in the English alphabet, the value returned by peek() comes before the value returned by peep() in chronological order”. Or: “ peek() returns the current value”. Failure Modes (Bounds on Operating Conditions & External Risk Factors) Section titled “Failure Modes (Bounds on Operating Conditions & External Risk Factors)” poke() is not called promptly, allowing malicious prices to be swiftly uptaken Section titled “poke() is not called promptly, allowing malicious prices to be swiftly uptaken” For several reasons, poke() is always callable as soon as block.timestamp / hop increments, regardless of when the last poke() call occurred (because zzz is rounded down to the nearest multiple of hop ). This means the contract does not actually guarantee that a time interval of at least hop seconds has passed since the last poke() call before the next one; rather this is only (approximately) guaranteed if the last poke() call occurred shortly after the previous increase of block.timestamp / hop . Thus, a malicious price value can be acknowledged by the system in a time potentially much less than hop . This was a deliberate design decision. The arguments that favoured it, roughly speaking, are: Providing a predictable time at which SKY holders should check for evidence of oracle attacks (in practice, hop is 1 hour, so checks must be performed at the top of the hour) Allowing all OSMs to be reliably poked at the same time in a single transaction The fact that poke is public, and thus callable by anyone, helps mitigate concerns, though it does not eliminate them. For example, network congestion could prevent anyone from successfully calling poke() for a period of time. If anSKY holder observes that poke has not been promptly called, the actions they can take include: Call poke() themselves and decide if the next value is malicious or not Call stop() or void() (the former if only nxt is malicious; the latter if the malicious value is already in cur ) Trigger emergency shutdown (if the integrity of the overall system has already been compromised or if it is believed the rogue oracle(s) cannot be fixed in a reasonable length of time) In the future, the contract’s logic may be tweaked to further mitigate this (e.g. by only allowing poke() calls in a short time window each hop period). Authorization Attacks and Misconfigurations Section titled “Authorization Attacks and Misconfigurations” Various damaging actions can be taken by authorized individuals or contracts, either maliciously or accidentally: Revoking access of core contracts to the methods that read values, causing mayhem as prices fail to update Completely revoking all access to the contract Changing src to either a malicious contract or to something that lacks a peek() interface, causing transactions that poke() the affected OSM to revert Calling disruptive functions like stop and void inappropriately The only solution to these issues is diligence and care regarding the wards of the OSM. Contract Details - Glossary (OSM) Section titled “Contract Details - Glossary (OSM)” Storage Layout Section titled “Storage Layout” stopped : flag ( uint256 ) that disables price feed updates if non-zero src : address of DSValue that the OSM will read from ONE_HOUR : 3600 seconds ( uint16(3600) ) hop : time delay between poke calls ( uint16 ); defaults to ONE_HOUR zzz : time of last update (rounded down to nearest multiple of hop ) cur : Feed struct that holds the current price value nxt : Feed struct that holds the next price value bud : mapping from address to uint256 ; whitelists feed readers Public Methods Section titled “Public Methods” Administrative Methods Section titled “Administrative Methods” These functions can only be called by authorized addresses (i.e. addresses usr such that wards[usr] == 1 ). rely / deny : add or remove authorized users (via modifications to the wards mapping) stop() / start() : toggle whether price feed can be updated (by changing the value of stopped ) change(address) : change data source for prices (by setting src ) step(uint16) : change interval between price updates (by setting hop ) void() : similar to stop , except it also sets cur and nxt to a Feed struct with zero values kiss(address) / diss(address) : add/remove authorized feed consumers (via modifications to the buds mapping) Feed Reading Methods Section titled “Feed Reading Methods” These can only be called by whitelisted addresses (i.e. addresses usr such that buds[usr] == 1 ): peek() : returns the current feed value and a boolean indicating whether it is valid peep() : returns the next feed value (i.e. the one that will become the current value upon the next poke() call), and a boolean indicating whether it is valid read() : returns the current feed value; reverts if it was not set by some valid mechanism Feed Updating Methods Section titled “Feed Updating Methods” poke() : updates the current feed value and reads the next one Feed struct: a struct with two uint128 members, val and has . Used to store price feed data. Released into the public domain (CC0 1.0 Universal) – trademarks remain with their owners; no warranty. See full license . ## /protocol/vaults/collateral-liquidation Collateral Liquidation In the context of the Sky protocol, a liquidation is the automatic transfer of collateral from an insufficiently collateralized Vault, along with the transfer of that Vault’s debt to the protocol. In the liquidation contract (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. Features Section titled “Features” Instant Settlement Section titled “Instant Settlement” Unlike the old Liquidation 1.2 system which utilized English auctions, in which DAI bids are placed, with a participant’s capital remaining locked until they are outbid or until the auction terminates, Liquidation 2.0 uses Dutch auctions which settle instantly. They do so according to a price calculated from the initial price and the time elapsed since the auction began. Price versus time curves are discussed more later. The lack of a lock-up period mitigates much of the price volatility risk for auction participants and allows for faster capital recycling. Flash Lending of Collateral Section titled “Flash Lending of Collateral” This feature, enabled by instant settlement, eliminates any capital requirement for bidders (excepting gas)—in the sense that even a participant with zero DAI (and nothing to trade for DAI) could still purchase from an auction by directing the sale of the auction’s collateral into other protocols in exchange for DAI. Thus, all DAI liquidity available across DeFi can be used by any participant to purchase collateral, subject only to gas requirements. The exact mechanics are discussed above, but essentially a participant needs to specify a contract who (which conforms to a particular interface), and calldata to supply to it, and the auction contract will automatically invoke whatever logic is in the external contract. Price as a Function of Time Section titled “Price as a Function of Time” Price-versus-time curves are specified through an interface that treats price at the current time as a function of the initial price of an auction and the time at which that price was set. How to determine the most effective price curve for a given collateral is still an active area of research; some initial options (linear, step-wise exponential, and continuous exponential) have been implemented for research purposes and initial deployment. Other candidates besides these include a piecewise linear curve and a piecewise exponential curve. This module is configurable and can be replaced in the course of innovation. It is important for bidders to take into account that while the price almost always decreases with time, there are infrequent occasions on which the price of an active auction may increase, and this could potentially result in collateral being purchased at a higher price than intended. The most obvious event that would increase the price in a running auction is if that auction is reset (via redo ), but changes to the configurable parameters of a price decrease calculator (or even the switching out of one calculator for another) by governance can also increase the price. It is recommended that bidders (or bidding UIs that abstract this detail away from the user) choose the maximum acceptable price ( max ) argument to take carefully to ensure a desirable outcome if the price should unexpectedly increase. Resetting an Auction Section titled “Resetting an Auction” As mentioned above, auctions can reach a defunct state that requires resetting for two reasons: too much time has elapsed since the auction started (controlled by the tail governance parameter) the ratio of the current price to the initial price has fallen below a certain level (specified by the cusp governance parameter). The reset function, when called, first ensures that at least one of these conditions holds. Then it adjusts the starting time of the auction to the current time, and sets the starting price in exactly the same way as is done in the initialization function (i.e. the current OSM price increased percentage-wise by the buf parameter). This process will repeat until all collateral has been sold or the whole debt has been collected (unless the auction is canceled via yank , e.g. during Emergency Shutdown); contrast this behavior with the current auctions, which reset until at least one bid is received. Improved Keeper Wallet Security Section titled “Improved Keeper Wallet Security” If keepers decide to use the clipperCallee pattern, then they need not store DAI or collateral on that account. This means a keeper need only hold enough ETH to execute transactions that can orchestrate the Clipper.take call, sending collateral to a contract that returns DAI to the msg.sender to pay for the collateral all in one transaction. The contract implementing the clipperCallee interface can send any remaining collateral or DAI beyond owe to a cold wallet address inaccessible to the keeper. NOTE: If the keeper chooses to behave as an EOA address, then the DAI and collateral would be exposed just as in LIQ-1.2 unless special care is taken to create a proxy contract. Contract Details Section titled “Contract Details” Parameters Set By Governance (through file ) Section titled “Parameters Set By Governance (through file)” Abacus/LinearDecrease – tau [seconds] Section titled “Abacus/LinearDecrease – tau [seconds]” Seconds after auction start when the price reaches zero. Abacus/StairstepExponentialDecrease – cut [ray] Section titled “Abacus/StairstepExponentialDecrease – cut [ray]” Per- step multiplicative factor. cut = 0.99 * RAY specifies a 1% drop every step seconds. Abacus/StairstepExponentialDecrease – step [seconds] Section titled “Abacus/StairstepExponentialDecrease – step [seconds]” Length of time between price drops. Abacus/ExponentialDecrease – cut [ray] Section titled “Abacus/ExponentialDecrease – cut [ray]” Per-second multiplicative factor. cut = 0.99 * RAY specifies a 1% drop every second. Clipper – buf [ray] Section titled “Clipper – buf [ray]” The multiplicative factor to increase the starting price of an auction. E.g. if the current OSM price of an asset is 1,000 and buf = 1.2 * RAY (20% above), then the initial price of that auction will be 1,200. Clipper – calc [address] Section titled “Clipper – calc [address]” The contract address of the price calculator function. Adheres to Abacus interface. Some examples of price functions are found in abaci.sol file. Clipper – chip [wad] Section titled “Clipper – chip [wad]” Percentage of tab to suck from vow to incentivize keepers when liquidating a vault or resetting an already existing auction. chip = 0.02 * WAD is 2%. Clipper – cusp [ray] Section titled “Clipper – cusp [ray]” Percentage price drop that can occur before an auction must be reset. Together with tail , this parameter determines when an auction needs to be reset. E.g. if the initial price of an auction ( top ) is set to 1,200 and cusp = 0.6 * RAY (60% of the starting price), then the auction will need to be reset when reaching just below the price of 720. Clipper – dog [address] Section titled “Clipper – dog [address]” The address of the liquidation module contract. Clipper – spotter [address] Section titled “Clipper – spotter [address]” The Collateral price module contract address. Clipper – tail [seconds] Section titled “Clipper – tail [seconds]” Seconds that can elapse before an auction must be reset. Together with cusp , this parameter determines when an auction needs to be reset. E.g. if tail is 1800 seconds, then if an auction is not complete after 30 minutes have elapsed, it will need to be reset. Clipper – tip [rad] Section titled “Clipper – tip [rad]” Flat fee to suck from vow to incentivize keepers when liquidating a vault or resetting an already existing auction. tip = 100 * RAD is 100 DAI. Clipper – vow [address] Section titled “Clipper – vow [address]” The address of the accounting system contract. The recipient of DAI raised in auctions. Dog – Hole [rad] Section titled “Dog – Hole [rad]” Max DAI needed to cover debt + liquidation penalty of active auctions. Hole = 10,000,000 * RAD is 10M DAI. Dog – ilk.chop [wad] Section titled “Dog – ilk.chop [wad]” Liquidation Penalty per collateral ( ilk ). E.g. if there is a vault ready to be liquidated that has a debt of 1,000 DAI and chop = 1.13 * WAD (13% above), then the max amount to be raised by the auction will be 1,130 DAI. Dog – ilk.clip [address] Section titled “Dog – ilk.clip [address]” The address of the auction module contract. One clip per collateral ( ilk ). Dog – ilk.hole [rad] Section titled “Dog – ilk.hole [rad]” Max DAI needed to cover debt + liquidation penalty of active auctions per collateral ( ilk ). hole = 10,000,000 * RAD is 10M DAI. Dog – vow [address] Section titled “Dog – vow [address]” The address of the accounting system contract. The recipient of the bad debt coming from a vault when it’s liquidated. Vault Liquidation Section titled “Vault Liquidation” https://github.com/sky-ecosystem/dss/blob/liq-2.0/src/dog.sol The Vault liquidation function ( Dog.bark ) takes three caller supplied arguments: Section titled “The Vault liquidation function (Dog.bark) takes three caller supplied arguments:” ilk : the collateral ilk urn : the Vault to be liquidated kpr : the address where DAI incentives will be sent Dog.bark performs several actions: Section titled “Dog.bark performs several actions:” confiscates the given Vault urn if it’s undercollateralized and sends the collateral to the ilk ’s Clipper increments the vow ’s bad debt accumulator pushes the bad debt into the debt queue adds the bad debt plus the liquidation penalty to the Hole with the Dirt accumulator adds the bad debt plus the liquidation penalty to the ilk.hole with the ilk.dirt accumulator initiates the auction by calling Clipper.kick() fires the Bark() event In the context of the Sky protocol, a “liquidation” is the automatic transfer of collateral from an insufficiently collateralized Vault, along with the transfer of that Vault’s debt to the protocol. In both the Liquidation 1.2 version (the Cat ) and the Liquidation 2.0 version
프로젝트로 돌아가기