-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvement/aura fed to base fed #9
base: main
Are you sure you want to change the base?
Changes from all commits
a7ff7d5
9016b97
6c3e158
4023eff
6ecff7f
e7b4769
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,11 +14,12 @@ abstract contract BaseFed { | |
address public pendingGov; | ||
//Chair address allowed to perform expansions and contractions | ||
address public chair; | ||
//Address of contract that is allowed to call the migrate functions | ||
address public migrator; | ||
|
||
constructor(address _DOLA, address _gov, address _chair){ | ||
require(gov != address(0), "Gov set to 0"); | ||
require(_gov != address(0), "Gov set to 0"); | ||
require(_DOLA != address(0), "Must be correct DOLA address"); | ||
require(block.chainid == 1, "Must mint DOLA on Mainnet"); | ||
gov = _gov; | ||
chair = _chair; | ||
DOLA = IERC20(_DOLA); | ||
|
@@ -38,6 +39,11 @@ abstract contract BaseFed { | |
_; | ||
} | ||
|
||
modifier onlyMigrator(){ | ||
require(msg.sender == migrator, "ONLY MIGRATOR"); | ||
_; | ||
} | ||
|
||
/** | ||
* @notice Sets the pendingGov, which can claim gov role. | ||
* @dev Only callable by gov | ||
|
@@ -67,6 +73,15 @@ abstract contract BaseFed { | |
emit NewChair(newChair); | ||
} | ||
|
||
/** | ||
* @notice Sets the migrator of the Fed | ||
* @dev Should only be set if it's desired to migrate claims and debts to another fed | ||
* @param newMigrator Address of the contract to migrate to | ||
*/ | ||
function setMigrator(address newMigrator) onlyGov external { | ||
migrator = newMigrator; | ||
} | ||
|
||
/** | ||
* @notice Resigns from the Fed role | ||
* @dev Useful in case of key compromise or multi-sig compromise | ||
|
@@ -128,14 +143,36 @@ abstract contract BaseFed { | |
function takeProfit(uint flag) external virtual; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small suggestion. Can try a pattern like this which enforces events are always implemented without relying on developer to remember.
|
||
|
||
/** | ||
* @notice Function for withdrawing underlying of Fed in emergency. | ||
* @notice Withdraws claims from Fed in case of an emergency. | ||
Can be useful in case of Fed accounting errors, hacks of underlying market or accidents. | ||
* @dev Will likely destroy all contract accounting. Use carefully. Should send withdrawn tokens to gov. | ||
*/ | ||
function emergencyWithdraw() onlyGov external virtual{ | ||
revert("NOT IMPLEMENTED"); | ||
} | ||
|
||
/** | ||
* @notice Migrates both claims and debt to another fed from this one | ||
* @dev Must send claims tokens to the new fed. This can be LP tokens, cTokens etc. | ||
* @dev Must make sure accounting is correct, with the total number of claims and debt between feds staying the same after migration | ||
* @param claimsToMigrate The number of claims to migrate to the other fed | ||
* @return debtToMigrate The debt associated with the transfered claims | ||
*/ | ||
function migrateTo(uint claimsToMigrate) onlyMigrator external virtual returns(uint debtToMigrate){ | ||
revert("NOT IMPLEMENTED"); | ||
} | ||
|
||
/** | ||
* @notice Migrates both claims and debt from another fed to this one | ||
* @dev Must call the migraTo function of the target fed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo |
||
* @dev Must increment both claims and debt | ||
* @param fed The address of the fed to migrate from | ||
* @param claimsToMigrate The amount of claims to migrate from the target fed | ||
*/ | ||
function migrateFrom(address fed, uint claimsToMigrate) onlyChair external virtual { | ||
revert("NOT IMPLEMENTED"); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
// ********************** | ||
// * Standard Functions * | ||
// ********************** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
pragma solidity ^0.8.13; | ||
|
||
import "src/MintingFed.sol"; | ||
|
||
abstract contract LossyFed is MintingFed { | ||
uint public maxLossExpansionBps; | ||
uint public maxLossContractionBps; | ||
uint public maxLossTakeProfitBps; | ||
uint public maxLossSetableByGuardian = 500; | ||
address public guardian; | ||
constructor(address _DOLA, | ||
address _gov, | ||
address _chair, | ||
address _guardian, | ||
uint _maxLossExpansionBps, | ||
uint _maxLossContractionBps, | ||
uint _maxLossTakeProfitBps | ||
) MintingFed(_DOLA, _gov, _chair) | ||
{ | ||
require(_maxLossExpansionBps < 10000, "Expansion max loss too high"); | ||
require(_maxLossContractionBps < 10000, "Contraction max loss too high"); | ||
require(_maxLossTakeProfitBps < 10000, "TakeProfit max loss too high"); | ||
guardian = _guardian; | ||
maxLossExpansionBps = _maxLossExpansionBps; | ||
maxLossContractionBps = _maxLossContractionBps; | ||
maxLossTakeProfitBps = _maxLossTakeProfitBps; | ||
} | ||
|
||
modifier onlyGuardian { | ||
require(msg.sender == guardian || msg.sender == gov, "ONLY GOV OR GUARDIAN"); | ||
_; | ||
} | ||
|
||
function setMaxLossExpansionBps(uint newMaxLossExpansionBps) onlyGov external { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updating max loss on Expansions and TakeProfit are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, idea is that an emergency contraction may need to happen in short order, due to a hack of an underlying protocol. We saw that play out during the Euler hack, where fast contractions were instrumental in avoiding as much bad debt as possible. |
||
require(newMaxLossExpansionBps <= 10000, "Max loss above 100%"); | ||
maxLossExpansionBps = newMaxLossExpansionBps; | ||
} | ||
|
||
function setMaxLossContractionBps(uint newMaxLossContractionBps) onlyGuardian external{ | ||
if(msg.sender == guardian){ | ||
//We limit the max loss a guardian can set, as we only want governance to be able to set a very high maxloss | ||
require(newMaxLossContractionBps <= maxLossSetableByGuardian, "Above allowed maxloss for chair"); | ||
} | ||
require(newMaxLossContractionBps <= 10000, "Max loss above 100%"); | ||
maxLossContractionBps = newMaxLossContractionBps; | ||
} | ||
|
||
function setMaxLossTakeProfitBps(uint newMaxLossTakeProfitBps) onlyGov external { | ||
require(newMaxLossTakeProfitBps <= 10000, "Max loss above 100%"); | ||
maxLossTakeProfitBps = newMaxLossTakeProfitBps; | ||
} | ||
|
||
function setMaxLossSetableByGuardian(uint newMaxLossSetableByGuardian) onlyGov external { | ||
require(newMaxLossSetableByGuardian < 10000, "Max loss above 100%"); | ||
maxLossSetableByGuardian = newMaxLossSetableByGuardian; | ||
} | ||
|
||
function setGuardian(address newGuardian) onlyGov external { | ||
guardian = newGuardian; | ||
emit NewGuardian(newGuardian); | ||
} | ||
|
||
event NewGuardian(address); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small observation: Most role update functions have events except for
ResignChair
andSetMigrator
.