Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.

Commit 9205a3a

Browse files
gbalabasquerbrianmcmichael
andauthoredFeb 18, 2021
First step to decouple action from the lib implementation + renaming … (#64)
Co-authored-by: Brian McMichael <brian@brianmcmichael.com>
1 parent e7b62b2 commit 9205a3a

File tree

3 files changed

+87
-83
lines changed

3 files changed

+87
-83
lines changed
 

‎src/DssAction.sol

+26-22
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@
2020
pragma solidity ^0.6.11;
2121

2222
import "./CollateralOpts.sol";
23-
import { DssExecLib as lib, OracleLike } from "./DssExecLib.sol";
23+
import { DssExecLib } from "./DssExecLib.sol";
24+
25+
interface OracleLike {
26+
function src() external view returns (address);
27+
}
2428

2529
abstract contract DssAction {
2630

27-
using lib for *;
31+
using DssExecLib for *;
2832

2933
// Office Hours defaults to true by default.
3034
// To disable office hours, override this function and
@@ -61,52 +65,52 @@ abstract contract DssAction {
6165
// Complete collateral onboarding logic.
6266
function addNewCollateral(CollateralOpts memory co) internal {
6367
// Add the collateral to the system.
64-
lib.addCollateralBase(co.ilk, co.gem, co.join, co.flip, co.pip);
68+
DssExecLib.addCollateralBase(co.ilk, co.gem, co.join, co.flip, co.pip);
6569

6670
// Allow FlipperMom to access to the ilk Flipper
67-
address _flipperMom = lib.flipperMom();
68-
lib.authorize(co.flip, _flipperMom);
71+
address _flipperMom = DssExecLib.flipperMom();
72+
DssExecLib.authorize(co.flip, _flipperMom);
6973
// Disallow Cat to kick auctions in ilk Flipper
70-
if(!co.isLiquidatable) { lib.deauthorize(_flipperMom, co.flip); }
74+
if(!co.isLiquidatable) { DssExecLib.deauthorize(_flipperMom, co.flip); }
7175

7276
if(co.isOSM) { // If pip == OSM
7377
// Allow OsmMom to access to the TOKEN OSM
74-
lib.authorize(co.pip, lib.osmMom());
78+
DssExecLib.authorize(co.pip, DssExecLib.osmMom());
7579
if (co.whitelistOSM) { // If median is src in OSM
7680
// Whitelist OSM to read the Median data (only necessary if it is the first time the token is being added to an ilk)
77-
lib.addReaderToMedianWhitelist(address(OracleLike(co.pip).src()), co.pip);
81+
DssExecLib.addReaderToMedianWhitelist(address(OracleLike(co.pip).src()), co.pip);
7882
}
7983
// Whitelist Spotter to read the OSM data (only necessary if it is the first time the token is being added to an ilk)
80-
lib.addReaderToOSMWhitelist(co.pip, lib.spotter());
84+
DssExecLib.addReaderToOSMWhitelist(co.pip, DssExecLib.spotter());
8185
// Whitelist End to read the OSM data (only necessary if it is the first time the token is being added to an ilk)
82-
lib.addReaderToOSMWhitelist(co.pip, lib.end());
86+
DssExecLib.addReaderToOSMWhitelist(co.pip, DssExecLib.end());
8387
// Set TOKEN OSM in the OsmMom for new ilk
84-
lib.allowOSMFreeze(co.pip, co.ilk);
88+
DssExecLib.allowOSMFreeze(co.pip, co.ilk);
8589
}
8690
// Increase the global debt ceiling by the ilk ceiling
87-
lib.increaseGlobalDebtCeiling(co.ilkDebtCeiling);
91+
DssExecLib.increaseGlobalDebtCeiling(co.ilkDebtCeiling);
8892
// Set the ilk debt ceiling
89-
lib.setIlkDebtCeiling(co.ilk, co.ilkDebtCeiling);
93+
DssExecLib.setIlkDebtCeiling(co.ilk, co.ilkDebtCeiling);
9094
// Set the ilk dust
91-
lib.setIlkMinVaultAmount(co.ilk, co.minVaultAmount);
95+
DssExecLib.setIlkMinVaultAmount(co.ilk, co.minVaultAmount);
9296
// Set the dunk size
93-
lib.setIlkMaxLiquidationAmount(co.ilk, co.maxLiquidationAmount);
97+
DssExecLib.setIlkMaxLiquidationAmount(co.ilk, co.maxLiquidationAmount);
9498
// Set the ilk liquidation penalty
95-
lib.setIlkLiquidationPenalty(co.ilk, co.liquidationPenalty);
99+
DssExecLib.setIlkLiquidationPenalty(co.ilk, co.liquidationPenalty);
96100

97101
// Set the ilk stability fee
98-
lib.setIlkStabilityFee(co.ilk, co.ilkStabilityFee, true);
102+
DssExecLib.setIlkStabilityFee(co.ilk, co.ilkStabilityFee, true);
99103

100104
// Set the ilk percentage between bids
101-
lib.setIlkMinAuctionBidIncrease(co.ilk, co.bidIncrease);
105+
DssExecLib.setIlkMinAuctionBidIncrease(co.ilk, co.bidIncrease);
102106
// Set the ilk time max time between bids
103-
lib.setIlkBidDuration(co.ilk, co.bidDuration);
107+
DssExecLib.setIlkBidDuration(co.ilk, co.bidDuration);
104108
// Set the ilk max auction duration
105-
lib.setIlkAuctionDuration(co.ilk, co.auctionDuration);
109+
DssExecLib.setIlkAuctionDuration(co.ilk, co.auctionDuration);
106110
// Set the ilk min collateralization ratio
107-
lib.setIlkLiquidationRatio(co.ilk, co.liquidationRatio);
111+
DssExecLib.setIlkLiquidationRatio(co.ilk, co.liquidationRatio);
108112

109113
// Update ilk spot value in Vat
110-
lib.updateCollateralPrice(co.ilk);
114+
DssExecLib.updateCollateralPrice(co.ilk);
111115
}
112116
}

‎src/test/DssExec.t.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ contract DssLibSpellAction is DssAction { // This could be changed to a library
6262
});
6363
addNewCollateral(XMPL_A);
6464

65-
lib.setIlkDebtCeiling("ETH-A", 10 * MILLION);
66-
lib.setGlobalDebtCeiling(10000 * MILLION);
65+
DssExecLib.setIlkDebtCeiling("ETH-A", 10 * MILLION);
66+
DssExecLib.setGlobalDebtCeiling(10000 * MILLION);
6767
}
6868
}
6969

0 commit comments

Comments
 (0)