USDS 백서

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

rad-precision value. function file(bytes32 what, address data) external; function file(bytes32 what, uint256 data) external; function file(bytes32 ilk, bytes32 what, address data) external; function file(bytes32 ilk, bytes32 what, uint256 data) external; (Authenticated) Parameter modification functions, available to governance. The precision for a numeric argument should match the parameter being set. function chop(bytes32 ilk) external view returns (uint256); Getter for the chop value of a given ilk . chop has wad precision. function bark(bytes32 ilk, address urn, address kpr) external returns (uint256 id); The main liquidation function. Initiates an auction. A keeper calls this function to begin the auction of urn for a particular ilk . kpr is the address where the keeper incentive is sent, allowing keepers to have liquidation rewards sent to a different address than the caller. function digs(bytes32 ilk, uint256 rad) external; (Authenticated) Removes collateral from the accumulator. Called by the Clipper . The rad argument has rad precision. function cage() external; (Authenticated) Deactivates the Dog and sets live to 0. Clipper Interface Section titled “Clipper Interface” function wards(address) external view returns (uint256); function rely(address) external; function deny(address) external; Standard Sky Ecosystem authorization structure. function ilk() external view returns (bytes32); The ilk that this Clipper is associated with. function dog() external view returns (address); function vow() external view returns (address); function spotter() external view returns (address); DSS core address introspection. function calc() external view returns (address); The address of the pricing function used by this Clipper. function buf() external view returns (uint256); // ray function tail() external view returns (uint256); // seconds function cusp() external view returns (uint256); // ray function chip() external view returns (uint256); // wad function tip() external view returns (uint256); // rad Getters for governance-configured auction parameters. function chost() external view returns (uint256); // rad Getter for the stored product of Vat.ilk.dust and Dog.ilk.chop . This value is used as a heuristic for whether a partial purchase will leave an auction with too little collateral and whether incentives should be given out when redo is called. function kicks() external view returns (uint256); Auction counter. Increments each time an auction is initiated. function active(uint256 pos) external view returns (uint256); Returns the id of the auction at index pos in the list of active auctions. function sales(uint256) external view returns ( uint256 pos, uint256 tab, // rad uint256 lot, // wad address usr, uint96 tic, // Unix epoch uint256 top); // ray Returns information on a particular auction. Completed auctions are removed from the mapping. function stopped() external view returns (uint256); Returns the current circuit breaker status. 0 for all functions allowed, 1 if kick cannot be called, 2 if kick and redo cannot be called, and 3 if kick , redo and take cannot be called. function file(bytes32 what, address data) external; function file(bytes32 what, uint256 data) external; (Authenticated) Parameter modification functions, available to governance. Numeric arguments should match the precision of the parameter being set. function kick(uint256 tab, uint256 lot, address usr, address kpr) external returns (uint256 id); (Authenticated) Initiates the auction. Called by the Dog . tab is rad-precion, lot is wad-precision. function redo(uint256 id, address kpr) external; Called to reset an auction due to expiry or price deviation. function take( uint256 id, uint256 amt, // wad uint256 max, // ray address who, bytes calldata data) external; Called to purchase collateral. function list() external view returns (uint256[] memory); function count() external view returns (uint256); Helpers for iterating the list of active auctions. Use list() to get the unsorted array of auctions. Get the number of active auctions with count() . The function active(uint256 pos) (see above) can be used to access individual entries without needing to call list() . function getStatus(uint256 id) external view returns (bool needsRedo, uint256 price); Returns a bool if the auction is eligible for redo and the current price. function upchost() external; Updates the chost value stored in the contract to equal the product of Vat.ilk.dust and Dog.ilk.chop (the precision of the final value is rad). This allows take and redo to obtain chost with a single SLOAD (reading dust from the Vat requires 5 SLOAD operations due to how the API is structured, and reading chop is an additional SLOAD ). function yank(uint256 id) external; (Authenticated) Allows an auction to be removed during Emergency Shutdown or via a goveranance action. 4. Known Risks Section titled “4. Known Risks” This section covers some of the known risks with Liquidations 2.0 Incentive Farming Section titled “Incentive Farming” Periodically, governance may increase the ilk.dust amount. When this happens, it’s usually because gas has become so expensive it impacts the efficiency of liquidations. That is, the cost of calling Dog.bark() , Clipper.take() , or Clipper.redo() may exceed the collateral offered. Incentives may be used as a remedy to this potential issue and possibly a way for the protocol to keep ilk.dust lower; however, governance must take care when increasing the ilk s dust , tip , or chip not to incentivize the creation of many Vaults to farm this incentive. An example of an exploit is as follows: governance decides to increment dust by 1500 DAI at the same time they scale ilk.tip to subsidize auctions. an attacker realizes it would be profitable between gas and the chop to shard ( fork ) their existing Vault into many Vaults or create many new Vaults. the spell is voted on and passed using one transaction the attacker puts their Vaults at the edge of unsafe, poke() s the OSM when next price is going down, then calls Dog.bark() on all their Vaults to collect the incentive. Using the gains, they can also slightly overbid for their Vaults auctions. In order to thwart this attack governance must be careful when setting ilk.tip and ilk.chip so as not to create this perverse incentive. Price Decreases Too Quickly Section titled “Price Decreases Too Quickly” If the price decreases too quickly it can have the following consequences: the auction ends without any bid, then it needs to be reset and possibly this will keep happening bidders end up having reverts due the auction ended before tx confirmation bidders end up paying much less than what they were willing to pay (possibly generating permanent bad debt) Price Decreases Too Slowly Section titled “Price Decreases Too Slowly” If the price decreases too slowly it can have the following consequences: Auction price never catches up with the market price, eventually being reset After the reset the price catches up, but is less than an optimal market price After the reset the price catches up, but still leaves bad debt After the reset the auction price still might not catch up, causing more resets and very likely leaving bad debt Front-Running Section titled “Front-Running” In LIQ-1.2 there is limited front-running risk as it requires capital to participate in auctions; however, in liquidations 2.0 if a keeper chooses to participate with no capital, there is substantial front-running risk from generalized front-running bots. The easier it is to replace the from address of the transaction with one’s own, the greater the risk. To mitigate this risk keepers are encouraged to used authorized proxy contracts to interact with liquidations 2.0 and provide some amount of their own capital when bidding. More aggressive gas prices may also work. Unfortunately, we found no great way to prevent generalized front-running that preserves single-block composability. OSM Risk for Start Price Section titled “OSM Risk for Start Price” Because Clipper.kick and Clipper.redo consult the OSM for the collateral price, we are vulnerable to an oracle attack that can only be mitigated by the oracle delay, Dog.Hole , and ilk.hole . We must rely on the number of guards in place to prevent price manipulation and oracle attacks. The fact that the price is delayed by one hour, however, prseents a risk of its own: since the price is out-of-date relative to the market, it may be either too high or too low to allow for efficient settlement given other parameters like ‘buf’ and the price decrease function. The consequences of either case are effectively covered by the sections on the risk of the price decreasing either too quickly or too slowly. Setting Hole or ilk.hole Too High Section titled “Setting Hole or ilk.hole Too High” While Dog.Hole and ilk.hole can be set much higher in liquidations 2.0, there are still risks to setting this too high. A value for Dog.Hole that’s set too high could result in far too much DAI demand, breaking the peg high. This is somewhat mitigated by the PSM and stablecoin collateral types, but should still factor in to how this parameter is set. An ilk.hole that is set too high, may have the additional result of causing a downward spiral as the liquidations push the asset price lower. In addition, if there is an oracle attack, this parameter can be thought of as our maximum exposure. Setting Hole or ilk.hole Too Low Section titled “Setting Hole or ilk.hole Too Low” If we set either Dog.Hole or ilk.hole too low, we run the risk of not being able to liquidate enough collateral at once. This could lead to a buildup of undercollateralized positions in the system, eventually causing the accrual of bad debt. Auction Parameter Changes Affect Running Auctions Section titled “Auction Parameter Changes Affect Running Auctions” Parameters, e.g. tail , cusp , or the price decrease function or any of its parameters, can be changed at any time by governance and will affect the behavior of running auctions. Integrators should take this possibility into account, reasoning through how sudden changes in parameters would impact their bidding strategies. Governance should endeavor to change parameters infrequently and if possible, only when there are not any auctions that will be affected. 5. Invariants Section titled “5. Invariants” These invariants have not yet been formally proven, and thus should only be considered intended behavior for now. Dog Invariants Section titled “Dog Invariants” sum_over_all_ilks(Dog.ilk.dirt) == Dog.Dirt (c26.1) Clipper Invariants Section titled “Clipper Invariants” sum_over_auction_ids(Clipper.sales[id].lot) <= Vat.gem(Clipper) (c27.1) The above is an inequality (and not an equality ) because it is impossible to prevent a user or contract from choosing to send collateral to a Clipper , even though it only makes sense for the Dog to do so. Governance (or a new module) could create a violation of this property by calling kick without transferring appropriate collateral to the Clipper . Thus this is actually a pseudo-invariant that only holds if callers of kick respect the requirement to send collateral to the Clipper , but it should hold for the live system if deployment and authorization is done correctly. It should hold if only active auctions are summed over as well. Invariants involving quantities from both the Dog and Clipper Section titled “Invariants involving quantities from both the Dog and Clipper” sum_over_auctions_ids_and_ilks(Dog.ilk.clip.sales[id].tab) == Dog.Dirt (c28.1) The above should hold if only active auctions are summed over as well. sum_over_auctions_ids(Dog.ilk.clip.sales[id].tab) == Dog.ilk.dirt (c28.2) The above should hold if only active auctions are summed over as well. Note that (c28.1) and (c28.2) together imply (c26.1). Released into the public domain (CC0 1.0 Universal) – trademarks remain with their owners; no warranty. See full license . ## /protocol/vaults/cdp-manager CDP Manager The DssCdpManager (aka manager ) was created to enable a formalized process for Vaults to be transferred between owners, much like assets are transferred. It is recommended that all interactions with Vaults be done through the CDP Manager. Once unlocked collateral has been deposited into the Sky Protocol, users can make use of the following features: Multi Vault ownership and numerical identification (users can own N number of Vaults) Vault transferability Contract Details Section titled “Contract Details” Key Functionalities (as defined in the smart contract) Section titled “Key Functionalities (as defined in the smart contract)” cdpAllow(uint cdp, address usr, uint ok) : Allow/Disallow ( ok ) a usr address to manage the cdp . urnAllow(address usr, uint ok) : Allow/Disallow ( ok ) a usr address to interact with an urn for the purposes of either entering ( src ) or quitting ( dst). open(bytes32 ilk, address usr) : Opens a new Vault for usr to be used for an ilk collateral type. give(uint cdp, address dst) : Transfers cdp to dst . frob(uint cdp, int dink, int dart) : Increments/decrements the ink amount of collateral locked and increments/decrements the art amount of debt in the cdp depositing the generated DAI or collateral freed in the cdp address. frob(uint cdp, address dst, int dink, int dart) : Increments/decrements the ink amount of collateral locked and increments/decrements the art amount of debt in the cdp depositing the generated DAI or collateral freed into a specified dst address. flux(bytes32 ilk, uint cdp, address dst, uint wad) : Moves wad (precision 18) amount of collateral ilk from cdp to dst . flux(uint cdp, address dst, uint wad) : Moves wad amount of cdp collateral from cdp to dst . move(uint cdp, address dst, uint rad) : Moves rad (precision 45) amount of DAI from cdp to dst . quit(uint cdp, address dst) : Moves the collateral locked and debt generated from cdp to dst . Note: dst refers to the destination address. Storage Layout Section titled “Storage Layout” vat : core contract address that holds the Vaults. cdpi : Auto incremental id. urns : Mapping CDPId => UrnHandler list : Mapping CDPId => Prev & Next CDPIds (double linked list) owns : Mapping CDPId => Owner ilks : Mapping CDPId => Ilk (collateral type) first : Mapping Owner => First CDPId last : Mapping Owner => Last CDPId count : Mapping Owner => Amount of CDPs allows : Mapping Owner => CDPId => Allowed Addr => True/False Key Mechanisms & Concepts Section titled “Key Mechanisms & Concepts” Summary Section titled “Summary” The CDP Manager was created as a way to enable Vaults to be treated more like assets that can be exchanged. Originally, the dss core contracts did not have the functionality to enable transferring Vault positions. The CDP Manager was created to wrap this functionality and enable transferring between users. High-level Purpose Section titled “High-level Purpose” The manager receives the vat address in its creation and acts as an interface contract between it and the users. The manager keeps an internal registry of id => owner and id => urn allowing for the owner to execute vat functions for their urn via the manager . The manager keeps a double linked list structure that allows the retrieval of all the Vaults that an owner has via on-chain calls. In short, this is what the GetCdps is for. This contract is a helper contract that allows the fetching of all the Vaults in just one call. CDP Manager Usage Example (common path): Section titled “CDP Manager Usage Example (common path):” A User executes open and gets a CDPId in return. After this, the CDPId gets associated with an urn with manager.urns(cdpId) and then join ’s collateral to it. The user can then execute frob to choose which dst address they want to use to send the generated DAI to. If the user executes frob without dst then the generated DAI will remain in the Vault’s urn . In this case, the user can move it at a later point in time. Note that this is the same process for collateral that is freed after frob (for the frob function that doesn’t require the dst address). The user can flux it to another address at a later time. In the case where a user wants to abandon the manager , they can use quit as a way to migrate their position of their Vault to another dst address. Gotchas (Potential source of user error) Section titled “Gotchas (Potential source of user error)” For the developers who want to integrate with the manager , they will need to understand that the Vault actions are still in the urn environment. Regardless of this, the manager tries to abstract the urn usage by a CDPId . This means that developers will need to get the urn ( urn = manager.urns(cdpId) ) to allow the join ing of collateral to that Vault. As the manager assigns a specific ilk per CDPId and doesn’t allow others to use it for theirs, there is a second flux function which expects an ilk parameter. This function has the simple purpose of taking out collateral that was wrongly sent to a Vault that can’t handle it/is incompatible. Frob Function(s): When you frob in the CDP manager, you generate new DAI in the vat via the CDP manager which is then deposited in the urn that the CDP manager manages. This process depends on which frob function you use (there exist two frob functions). In short, one allows a destination address and the other doesn’t require it. If you use the frob function that has the destiny ( dst ) address, you are saying that you can send any Dai generated or collateral that has been freed. The second frob function is meant for leaving the collateral in the urn address because the urn is owned by the CDP manager. In this case, you would need to manually use the flux or move functions to get the DAI or collateral out. These functions ( flux and move ) may be more beneficial for a developer working with the proxy function, as it allows for more flexibility. For example, by using these functions you can move a specific amount of collateral and can use the other functions to do it. Overall, it can make working with it a little more flexible on specific developer needs. As mentioned above in the summary, the dss core contracts originally did not have the functionality to enable the transfer of Vault positions. Since then, the core contracts have also implemented a native transfer functionality called fork which allows the transferring of a Vault to another address. However, there is a restriction, which is that the address owner that will be receiving the Vault needs to provide authorization that they do in fact want to receive it. This was created for the situation when a user is transferring the collateral that is locked as well as the debt generated. If you are simply moving collateral to another address, there is no issue but in the case that you are also transferring the debt generated, there is a chance of putting a perfectly safe Vault in a risky position. This makes the contract functionality a little more restrictive. Therefore, the CDP manager is a good option to keep a simple way of transferring Vaults and recognizing them via a numeric ID. Failure Modes (Bounds on Operating Conditions & External Risk Factors) Section titled “Failure Modes (Bounds on Operating Conditions & External Risk Factors)” Potential Issues around Chain Reorganization Section titled “Potential Issues around Chain Reorganization” When open is executed, a new urn is created and a cdpId is assigned to it for a specific owner . If the use
프로젝트로 돌아가기