USDS 백서

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

rtant and that a higher amount of SKY on the current governing proposal adds to the stability of the system. Unsafe states when migrating to a new chief contract When migrating to a new chief, authority must be transferred to the new contract and revoked from the old. This poses a small coordination problem as the new contract must already have enough SKY on its hat to be safe against governance attacks while the voters enacting the change itself must have enough SKY in the old chief to pass the proposal. Contract Details Section titled “Contract Details” Glossary (Chief) Section titled “Glossary (Chief)” **DSChiefApprovals provides the following public properties:** slates : A mapping of bytes32 to address arrays. Represents sets of candidates. Weighted votes are given to slates. votes : A mapping of voter addresses to the slate they have voted for. approvals : A mapping of candidate addresses to their uint weight. deposits : A mapping of voter addresses to uint number of tokens locked. GOV : DSToken used for voting. IOU : DSToken issued in exchange for locking GOV tokens. hat : Contains the address of the current “chief.” MAX_YAYS : Maximum number of candidates a slate can hold. Most of the functions are decorated with the the note modifier from ds-note , meaning that they fire a standardized event when called. Additionally, one custom event is also provided: Etch(bytes32 indexed slate) : Fired when a slate is created. Released into the public domain (CC0 1.0 Universal) – trademarks remain with their owners; no warranty. See full license . ## /protocol/governance/pause Pause The ds-pause is a delegatecall based proxy with an enforced delay. This allows authorized users to schedule function calls that can only be executed once a predetermined waiting period has elapsed. The configurable delay attribute sets the minimum wait time that will be used during the governance of the system. Contract Details: Section titled “Contract Details:” Key Functionalities (as defined in the smart contract) Section titled “Key Functionalities (as defined in the smart contract)” Plans A plan describes a single delegatecall operation and a unix timestamp eta before which it cannot be executed. A plan consists of: usr : address to delegatecall into tag : the expected codehash of usr fax : calldata to use eta : first possible time of execution (as seconds since unix epoch) It is important to note that each plan has a unique id, defined as a keccack256(abi.encode(usr, tag, fax, eta)). Operations Section titled “Operations” Plans can be manipulated in the following ways: plot : schedule a plan exec : execute a scheduled plan drop : cancel a scheduled plan The pause contract contains the DSPauseProxy contract in order to allow plan to be executed in an isolated storage context to protect the pause from malicious storage modification during plan execution. Key Mechanisms & Concepts Section titled “Key Mechanisms & Concepts” The ds-pause was designed to be used as a component in the Sky Protocol’s governance system in order to give affected parties time to respond to decisions. If those affected by governance decisions have e.g. exit or veto rights, then the pause can serve as an effective check on governance power. Gotchas (Potential source of user error) Section titled “Gotchas (Potential source of user error)” Identity & Trust Section titled “Identity & Trust” In order to protect the internal storage of the pause from malicious writes during plan execution, we perform the delegatecall operation in a separate contract with an isolated storage context (DSPauseProxy), where each pause has its own individual proxy. This means that plans are executed with the identity of the proxy . Thus when integrating the pause into some auth scheme, you will want to trust the pause’s proxy and not the pause itself. Failure Modes (Bounds on Operating Conditions & External Risk Factors) Section titled “Failure Modes (Bounds on Operating Conditions & External Risk Factors)” A break of any of the following would be classified as a critical issue: High level There is no way to bypass the delay The code executed by the delegatecall cannot directly modify storage on the pause The pause will always retain ownership of it’s proxy Administrative authority, owner, and delay can only be changed if an authorized user plots a plan to do so Plot A plan can only be plotted if its eta is after block.timestamp + delay A plan can only be plotted by authorized users Exec A plan can only be executed if it has previously been plotted A plan can only be executed once it’s eta has passed A plan can only be executed if its tag matches extcodehash(usr) A plan can only be executed once A plan can be executed by anyone Drop A plan can only be dropped by authorized users Other Failure Modes Section titled “Other Failure Modes” DSPause.delay - when the pause delay is set to the maximum, governance can no longer modify the system. DSPause.delay - when the pause delay is set to the minimum, it is easier to pass malicious governance actions. Released into the public domain (CC0 1.0 Universal) – trademarks remain with their owners; no warranty. See full license . ## /protocol/governance/spell Spell A DSSpell is an un-owned object that performs one action or series of atomic actions (multiple transactions) one time only. This can be thought of as a one-off DSProxy with no owner (no DSAuth mix-in, it is not a DSThing). This primitive is useful to express objects that do actions which shouldn’t depend on “sender”, like an upgrade to a contract system that needs to be given root permission. By convention, it is usually what is used to change system parameters (where it is given auth via voting in chief ). Contract Details Section titled “Contract Details” The spell.sol contract contains two main contracts: DSSPELL and DSSpellBook. DSSPELL is the core contract that, with call instructions set in the constructor, can actually perform the one-time action. DSSpellBook is a factory contract designed to make the creation of DSSPELLs easier. Glossary (Spell) Section titled “Glossary (Spell)” whom - is the address the spell is targeting, usually SAI_MOM in SCD. mana - is the amount of ETH you are sending, which in spells it is usually 0. data - bytes memory calldata. done - indicates that the spell has been called successfully. Key Mechanisms & Concepts Section titled “Key Mechanisms & Concepts” hat - A spell comes into effect as the hat when someone calls the lift function. This is only possible when the spell in question has more SKY voted towards it than the current hat. cast - Once a spell has become the hat, it can be cast and its new variables will go into effect as part of the live Sky system. It is worth noting that a spell can only be cast once. lift - The process whereby a new spell replaces the old proposal. Note: the hat and lift have more to do with ds-chief than ds-spell but are important to mention here for context. Immutable Actions Section titled “Immutable Actions” whom , mana , and data are set in the constructor, so the action a spell is to perform cannot be changed after the contract has been deployed. Gotchas (Potential source of user error) Section titled “Gotchas (Potential source of user error)” Note that the spell is only marked as “done” if the CALL it makes succeeds, meaning it did not end in an exceptional condition and it did not revert. Conversely, contracts that use return values instead of exceptions to signal errors could be successfully called without having the effect you might desire. “Approving” spells to take action on a system after the spell is deployed generally requires the system to use exception-based error handling to avoid griefing. Failure Modes (Bounds on Operating Conditions & External Risk Factors) Section titled “Failure Modes (Bounds on Operating Conditions & External Risk Factors)” spell - A spell may remain uncast if it did not reach the required amount of SKY in order to pass. If this occurs, the spell may remain available as a later target if enough SKY is voted towards it. lift - Although spells cannot be cast a second time, they can be lifted to become the hat more than once if enough SKY votes remain on that proposal. The proposals parameters will not go into effect, however any additional spell will need to have more than that amount of SKY voted towards it in order to become the new hat. cast - If, when cast is called, the spell’s one-time action fails, done does not get flipped and the spell remains castable. Released into the public domain (CC0 1.0 Universal) – trademarks remain with their owners; no warranty. See full license . ## /protocol/governance/smart-burn-engine Smart Burn Engine Deployments Section titled “Deployments” SmartBurn Engine (SKY & USDS) @ Ethereum Section titled “SmartBurn Engine (SKY & USDS) @ Ethereum” Codebase Deployment Addresses Released into the public domain (CC0 1.0 Universal) – trademarks remain with their owners; no warranty. See full license . ## /protocol/rates/ovreview Rates Overview A fundamental feature of the MCD system is to accumulate stability fees on Vault debt balances, as well as interest on Dai Savings Rate (DSR) deposits. The mechanism used to perform these accumulation functions is subject to an important constraint: accumulation must be a constant-time operation with respect to the number of Vaults and the number of DSR deposits. Otherwise, accumulation events would be very gas-inefficient (and might even exceed block gas limits). For both stability fees and the DSR, the solution is similar: store and update a global “cumulative rate” value (per-collateral for stability fees), which can then be multiplied by a normalized debt or deposit amount to give the total debt or deposit amount when needed. This can be described more concretely with mathematical notation: Discretize time in 1-second intervals, starting from t _0; Let the (per-second) stability fee at time t have value F_i (this generally takes the form 1+ x , where x is small) Let the initial value of the cumulative rate be denoted by R _0 Let a Vault be created at time t_0 with debt D _0 drawn immediately; the normalized debt A (which the system stores on a per-Vault basis) is calculated as D _0/ R _0 Then the cumulative rate _ R ** at time ** T _** is given by:** $$ R(t) \equiv R_0 \prod_{i=t_0 + 1}^{t} F_i = R_0 \cdot F_{t_0 + 1} \cdot F_{t_0 + 2} \cdots F_{t-1} \cdot F_t $$ And the total debt of the Vault at time t would be: $$ D(t) \equiv A \cdot R(t) = D_0 \prod_{t=1}^{T} F_i $$ In the actual system, R is not necessarily updated with every block, and thus actual R values within the system may not have the exact value that they should in theory. The difference in practice, however, should be minor, given a sufficiently large and active ecosystem. Detailed explanations of the two accumulation mechanisms may be found below. Stability Fee Accumulation Section titled “Stability Fee Accumulation” Overview Section titled “Overview” Stability fee accumulation in MCD is largely an interplay between two contracts: the Vat (the system’s central accounting ledger) and the Jug (a specialized module for updating the cumulative rate), with the Vow involved only as the address to which the accumulated fees are credited. The Vat stores, for each collateral type, an Ilk struct that contains the cumulative rate ( rate ) and the total normalized debt associated with that collateral type ( Art ). The Jug stores the per-second rate for each collateral type as a combination of a base value that applies to all collateral types, and a duty value per collateral. The per-second rate for a given collateral type is the sum of its particular duty and the global base . Calling Jug.drip(bytes32 ilk) computes an update to the ilk’s rate based on duty , base , and the time since drip was last called for the given ilk ( rho ). Then the Jug invokes Vat.fold(bytes32 ilk, address vow, int rate_change) which: adds rate_change to rate for the specified ilk increases the Vow’s surplus by Art*rate_change increases the system’s total debt (i.e. issued Dai) by Art*rate_change . Each individual Vault (represented by an Urn struct in the Vat) stores a “normalized debt” parameter called art . Any time it is needed by the code, the Vault’s total debt, including stability fees, can be calculated as art*rate (where rate corresponds to that of the appropriate collateral type). Thus an update to Ilk.rate via Jug.drip(bytes32 ilk) effectively updates the debt for all Vaults collateralized with ilk tokens. Example With Visualizations Section titled “Example With Visualizations” Suppose at time 0, a Vault is opened and 20 Dai is drawn from it. Assume that rate is 1; this implies that the stored art in the Vault’s Urn is also 20. Let the base and duty be set such that after 12 years, art*rate = 30 (this corresponds to an annual stability of roughly 3.4366%). Equivalently, rate = 1.5 after 12 years. Assuming that base + duty does not change, the growth of the effective debt can be graphed as follows: Now suppose that at 12 years, an additional 10 Dai is drawn. The debt vs time graph would change to look like: What art would be stored in the Vat to reflect this change? (hint: not 30!) Recall that art is defined from the requirement that art * rate = Vault debt. Since the Vault’s debt is known to be 40 and rate is known to be 1.5, we can solve for art : 40/1.5 ~ 26.67. The art can be thought of as “debt at time 0”, or “the amount of Dai that if drawn at time zero would result in the present total debt”. The graph below demonstrates this visually; the length of the green bar extending upwards from t = 0 is the post-draw art value. Some consequences of the mechanism that are good to keep in mind: There is no stored history of draws or wipes of Vault debt There is no stored history of stability fee changes, only the cumulative effective rate The rate value for each collateral perpetually increases (unless the fee becomes negative at some point) Who calls drip ? Section titled “Who calls drip?” The system relies on market participants to call drip rather than, say, automatically calling it upon Vault manipulations. The following entities are motivated to call drip : Keepers seeking to liquidate Vaults (since the accumulation of stability fees can push a Vault’s collateralization ratio into unsafe territory, allowing Keepers to liquidate it and profit in the resulting collateral auction) Vault owners wishing to draw Dai (if they don’t call drip prior to drawing from their Vault, they will be charged fees on the drawn Dai going back to the last time drip was called—unless no one calls drip before they repay their Vault, see below) SKY holders (they have a vested interest in seeing the system work well, and the collection of surplus in particular is critical to the ebb and flow of SKY in existence) Despite the variety of incentivized actors, calls to drip are likely to be intermittent due to gas costs and tragedy of the commons until a certain scale can be achieved. Thus the value of the rate parameter for a given collateral type may display the following time behavior: Debt drawn and wiped between rate updates (i.e. between drip calls) would have no stability fees assessed on it. Also, depending on the timing of updates to the stability fee, there may be small discrepancies between the actual value of rate and its ideal value (the value if drip were called in every block). To demonstrate this, consider the following: at t = 0, assume the following values: $$ \text{rate} = 1 \text{ ; total fee} = f $$ in a block with t = 28, drip is called—now: $$ \text{rate} = f^{28} $$ in a block with t = 56, the fee is updated to a new, different value: $$ \text{totalfee} \xrightarrow{} g $$ in a block with t = 70, drip is called again; the actual value of rate that obtains is: $$ \text{rate} = f^{28} g^{42} $$ however, the “ideal” rate (if drip were called at the start of every block) would be: $$ \text{rate}_{ideal} = f^{56}g^{14} $$ Depending on whether f > g or g > f , the net value of fees accrued will be either too small or too large. It is assumed that drip calls will be frequent enough such inaccuracies will be minor, at least after an initial growth period. Governance can mitigate this behavior by calling drip immediately prior to fee changes. The code in fact enforces that drip must be called prior to a duty update, but does not enforce a similar restriction for base (due to the inefficiency of iterating over all collateral types). Dai Savings Rate Accumulation Section titled “Dai Savings Rate Accumulation” Overview Section titled “Overview” DSR accumulation is very similar to stability fee accumulation. It is implemented via the Pot , which interacts with the Vat (and again the Vow’s address is used for accounting for the Dai created). The Pot tracks normalized deposits on a per-user basis ( pie[usr] ) and maintains a cumulative interest rate parameter ( chi ). A drip function analogous to that of Jug is called intermittently by economic actors to trigger savings accumulation. The per-second (or “instantaneous”) savings rate is stored in the dsr parameter (analogous to base+duty in the stability fee case). The chi parameter as a function of time is thus (in the ideal case of drip being called every block) given by: $$ \text{chi}(t) \equiv \text{chi}0 \prod{i=t_0 + 1}^{t} \text{dsr}_i $$ where chi 0 is simply chi(_t _0). Suppose a user joins N Dai into the Pot at time t _0. Then, their internal savings Dai balance is set to: $$ \text{pie[usr]} = N / \text{chi}_0 $$ The total Dai the user can withdraw from the Pot at time t is: $$ \text{pie[usr]} \cdot \text{chi}(t) = N \prod_{i=t_0 + 1}^{t} \text{dsr}_i $$ Thus we see that updates to chi effectively increase all Pot balances at once, without having to iterate over all of them. After updating chi , Pot.drip then calls Vat.suck with arguments such that the additional Dai created from this savings accumulation is credited to the Pot contract while the Vow’s sin (unbacked debt) is increased by the same amount (the global debt and unbacked debt tallies are increased as well). To accomplish this efficiently, the Pot keeps track of a the total sum of all individual pie[usr] values in a variable called Pie . Notable Properties Section titled “Notable Properties” The following points are useful to keep in mind when reasoning about savings accumulation (all have analogs in the fee accumulation mechanism): if drip is called only infrequently, the instantaneously value of chi may differ from the ideal the code requires that drip be called prior to dsr changes, which eliminates deviations of chi from its ideal value due to such changes not coinciding with drip calls chi is a monotonically increasing value unless the effective savings rate becomes negative ( dsr < ONE ) There is no stored record of depositing or withdrawing Dai from the Pot There is no stored record of changes to the dsr Who calls drip ? Section titled “Who calls drip?” The following economic actors are incentivized (or forced) to call Pot.drip : any user withdrawing Dai from the Pot (otherwise they lose money!) any user putting Dai into the Pot—this is not economically rational, but is instead forced by smart contract logic that requires drip to be called in the same block as new Dai is added to the Pot (otherwise, an economic exploit that drains system surplus is possible) any actor with a motive to increase the system debt, for example a Keeper hoping to trigger
프로젝트로 돌아가기