# `DssExecLib` Upgrade ## Deployed vs Repository The [version currently used](https://etherscan.io/address/0x8De6DDbCd5053d32292AAA0D2105A32d108484a6) in `spells-mainnet` differs from the latest HEAD in the `master` branch of the [`dss-exec-lib` repository](https://github.com/makerdao/dss-exec-lib). The changes described below take the latest version in the **repository** as the base for comparison. 1. Solidity version upgraded from `0.6.x` to `0.8.x` 2. Use default Solidity `0.8.x` checked math instead of the old safe math helpers 3. Remove `wmul` and `rmul` helpers, which were not being used 4. Add support for setting the debt ceiling for RWA collateral 5. Add sanity checks for `setDebtAuctionBidDuration` and `setDebtAuctionMKRIncreaseRate` The changes below take the latest version in the **repository** as the base for comparison, meaning that, when comparing it with the deployed version in `spells-mainnet`, they are cumulative to the ones above. ## TL;DR 6. Add a new getter for SKY and update the chainlog key for MKR 7. Rename `govGuard` to `mkrGuard` and use the new chainlog key `MKR_GUARD`. 8. Rename functions to use generic terminology instead of specific token references (DAI, MKR) 9. Add an overload to `setIlkAutoLineParameters` function to allow updating amount and gap while preserving TTL 10. Add support for Sky Savings Rate (SSR) with `setSSR` and `accumulateSSR` functions 11. Add Star Spell execution functions 12. Add `setSurplusAuctionMinPriceThreshold` for setting minimum price threshold in surplus auctions 13. Add `setGSMDelay` for setting delay parameter in MCD_PAUSE 14. Add `removeChangelogAddress` to remove keys from the Chainlog 15. Update payment functions to support both DAI and USDS 16. Rename D3M to DDM (Direct Deposit Module) in related functions ## Changelog ### Removed Features 1. `setSurplusAuctionBidDuration`: this function was relevant only to the previous [`Flap` contract](https://github.com/makerdao/dss/blob/fa4f6630afb0624d04a003e920b0d71a00331d98/src/flap.sol#L71). Both the active [`MCD_FLAP` contract (`FlapUniV2SwapOnly`)](https://etherscan.io/address/0x374d9c3d5134052bc558f432afa1df6575f07407) and [`FlapperUniV2`](https://github.com/makerdao/dss-flappers/blob/e136bb19e6176762b63b26314c7ae6339f6a96b5/src/FlapperUniV2.sol) do not implement a `ttl`, hence `file(flapper, "ttl", value)` reverts. 2. `setMinSurplusAuctionBidIncrease(uint256 _pct_bps)`: Set minimum bid increase for surplus auctions. Same reason as above. 3. `setSurplusAuctionBidDuration(uint256 _length)`: Set bid duration for surplus auctions. Same reason as above. 4. `setSurplusAuctionDuration(uint256 _length)`: Set total auction duration for surplus auctions. Same reason as above. 5. `.*Call()`: Those functions can easily be replaced by `try...catch` blocks externally and inlined when required in `DssExecLib`. 6. `setMedianWritersQuorum(address _median, uint256 _minQuorum)`: all Medians have been replaced by the new Chronicle oracles, which are owned by Chronicle labs, not the Sky Protocol, so this function has no use anymore. 7. `whitelistOracleMedians(address _oracle)`: same reason as above. 8. `setMaxTotalDAILiquidationAmountLEGACY`: `MCD_CAT` has been properly scuttled for a while. ### Added Features 1. [`setSurplusAuctionMinPriceThreshold(uint256 _pct_bps)`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L567): Set the minimum price threshold (`want`) for surplus auctions (`FlapperUniV2SwapOnly`). 2. [`setGSMDelay(uint256 _delay)`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L903): set the `delay` parameter in `MCD_PAUSE`, enforcing an arbitrary minimum threshold of 12 hours. 3. [`setSSR(uint256 _rate, bool _doDrip)`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L544): the SSR counter-party to the existing `setDSR()`. 4. [`accumulateSSR()`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L453): the SSR counter-party to the existing `accumulateDSR()`. 5. [`removeChangelogAddress(bytes32)`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L325): removes a key from the Chainlog. 6. [`executeStarSpell(address _starProxy, address _starSpell)`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L1110): executes a Star Spell through its proxy and returns the execution result. 7. [`tryExecuteStarSpell(address _starProxy, address _starSpell)`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L1121): attempts to execute a Star Spell through its proxy without reverting on failure, returning success status and result data. 8. [`setIlkAutoLineParameters(bytes32 _ilk, uint256 _amount, uint256 _gap)`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L723): overloaded function to configure the amount and gap parameters for the Debt Ceiling auto line module while keeping the existing TTL value. ### Updated Features 1. ~~`setD3MTargetInterestRate`~~ -> [`setDDMTargetInterestRate`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L914): use the updated nomenclature DDM (Direct Deposit Module) instead of D3M. 2. ~~`sendPaymentFromSurplusBuffer(address, uint256)`~~ -> [`sendPaymentFromSurplusBuffer(address _join, address _target, uint256 _amount)`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L1047): added the native `_join` argument to allow the caller to choose between `MCD_DAI_JOIN` and `USDS_JOIN` to send DAI or USDS respectively. 3. ~~`addReaderToWhitelist(address)`~~ -> [`addToWhitelist(address)`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L366): use a more general name, as the `kiss()`/`diss()` pattern is no longer restricted to Oracles and OSMs, and could be used in other contexts. 4. ~~`removeReaderFromWhitelist(address)`~~ -> [`removeFromWhitelist(address)`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L373): same as above, for removals. 5. ~~`setDebtAuctionDAIAmount`~~ -> [`setDebtAuctionDebtAmount`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L580): use a more generic term for the debt amount parameter in debt auctions. This refers to a `Vow` parameter. 6. ~~`setDebtAuctionMKRAmount`~~ -> [`setDebtAuctionGovAmount`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L587): use a more generic term for the governance token amount in debt auctions instead of specifically referencing MKR. This refers to a `Vow` parameter. 7. ~~`setMaxTotalDAILiquidationAmount`~~ -> [`setMaxTotalDebtLiquidationAmount`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L625): use a more generic term for the maximum liquidation amount instead of specifically referencing DAI. 8. ~~`setDAIReferenceValue`~~ -> [`setParity`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L654): use a more generic term for setting the stablecoin reference value instead of specifically referencing DAI. 8. ~~`govGuard`~~ -> [`mkrGuard`](https://github.com/makerdao/dss-exec-lib/blob/revamp-for-chief-migration/src/DssExecLib.sol#L262): use the new name and chainlog key for the old `GOV_GUARD` contract. ### General Improvements 1. Upgraded the compiler version to Solidity 0.8.16 (the same currently used in Spells) 2. Renamed/reorganized some interfaces declared locally. 3. Refactored tests so they can be run with `forge test` without any additional parameters if the `ETH_RPC_URL` is set. 4. Refactored repository structure to match other Sky Protocol repos 5. Introduced `forge fmt` as the default formatter with a CI action to run `forge fmt --check` and enforce the code style. 6. Improved README with more up-do-date information about the Sky Protocol. ### Known Issues 1. Methods related to the `flop()` contract (debt auctions) have not been updated to use generic terminology. The flop auction mechanism has been disabled after the migration to SKY as the governance token, and a new version has not been prioritized yet. These methods will be updated when a new debt auction mechanism is implemented. ## Release Plan Since the Solidity compiler version is being updated, the new release should be tagged `0.1.0`, a _minor_ bump from the current `0.0.9`. Once reviewed and audited, the deployed version will be replaced in `spells-mainnet`.