BaseDSS
Overview
BaseDSS
is an abstract contract that provides a base implementation for a DSS. It includes the hooks which are called from the core contract whenever an operator interacts with core to register/unregister with the DSS or stake/unstake vaults from the DSS.
Usage
To implement BaseDSS
in a derived contract, ensure the following steps:
Import BaseDSS
import {BaseDSS} from "./BaseDSS.sol";
contract SampleDSS is BaseDSS {
Initialize the DSS:
- Call
_init()
with the core contract address and the desired maximum slashable percentage. - Sets the core address and registers the DSS with the core.
function initializeDSS(address core, uint256 maxSlashablePercentageWad) external {
// Calls the internal _init function from BaseDSS
_init(core, maxSlashablePercentageWad);
emit DSSInitialized(core, maxSlashablePercentageWad);
}
Optional Overloading:
Registration/UnregistrationHook
function registrationHook(address operator, bytes memory data) public override onlyCore {
super.registrationHook(operator, data); // Calls the BaseDSS hook logic
// Add any custom logic here
}
function unregistrationHook(address operator) public override onlyCore {
super.unregistrationHook(operator); // Calls the BaseDSS hook logic
// Add any custom logic here
}
RequestUpdateStakeHook/FinishUpdateStakeHook
function requestUpdateStakeHook(address operator, IBaseDSS.StakeUpdateRequest memory newStake)
public
override
onlyCore
{
super.requestUpdateStakeHook(operator, newStake); // Calls the BaseDSS hook logic
// Add any custom logic here
}
function finishUpdateStakeHook(address operator, IBaseDSS.QueuedStakeUpdate memory queuedStakeUpdate)
public
override
onlyCore
{
super.finishUpdateStakeHook(operator, queuedStakeUpdate); // Calls the BaseDSS hook logic
// Add any custom logic here
}
Jailing/Unjailing
function jailOperator(address operator) external {
_jailOperator(operator); // Uses internal function to jail the operator
}
function unjailOperator(address operator) external {
_unjailOperator(operator); // Uses internal function to unjail the operator
}
Using custom pointer for BaseDSSPtr and BaseDSSOpStatePtr
function baseDssStatePtr() internal view override returns (BaseDSSLib.State storage $) {
// return the pointer to the BaseDSSLib.State storage variable.
}
function baseDssOpStatePtr(address operator) internal pure override returns (BaseDSSOperatorLib.State storage $) {
// return the pointer to the BaseDSSOperatorLib.State storage variable.
}