Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Keeper

Git Source

Inherits: AccessControlUpgradeable, UUPSUpgradeable, IKeeper

Follows Tapio Governance model

Fast-path executor that lets curators adjust parameters within bounds enforced by ParameterRegistry

UUPS upgradeable. Governor is admin, curator and guardian are roles.

State Variables

DENOMINATOR

This is the denominator used for formatting ranges

uint256 private constant DENOMINATOR = 1e10;

PROTOCOL_OWNER_ROLE

bytes32 public constant PROTOCOL_OWNER_ROLE = keccak256("PROTOCOL_OWNER_ROLE");

CURATOR_ROLE

bytes32 public constant CURATOR_ROLE = keccak256("CURATOR_ROLE");

GUARDIAN_ROLE

bytes32 public constant GUARDIAN_ROLE = keccak256("GUARDIAN_ROLE");

GOVERNOR_ROLE

bytes32 public constant GOVERNOR_ROLE = keccak256("GOVERNOR_ROLE");

registry

IParameterRegistry private registry;

rampAController

IRampAController private rampAController;

spa

SelfPeggingAsset private spa;

spaToken

SPAToken private spaToken;

treasury

address public treasury;

Functions

constructor

Note: oz-upgrades-unsafe-allow: constructor

constructor();

initialize

function initialize(
    address _owner,
    address _governor,
    address _curator,
    address _guardian,
    IParameterRegistry _registry,
    IRampAController _rampAController,
    SelfPeggingAsset _spa,
    SPAToken _spaToken
)
    public
    initializer;

rampA

Allows curators to gradually ramp the A coefficient within allowed bounds

function rampA(uint256 newA, uint256 endTime) external override onlyRole(CURATOR_ROLE);

Parameters

NameTypeDescription
newAuint256The target A value
endTimeuint256Timestamp when ramping should complete

setMinRampTime

Set the minimum ramp time

function setMinRampTime(uint256 newMinRampTime) external override onlyRole(GOVERNOR_ROLE);

Parameters

NameTypeDescription
newMinRampTimeuint256is the new minimum ramp time

setSwapFee

Set the swap fee within allowed bounds

function setSwapFee(uint256 newFee) external override onlyRole(GOVERNOR_ROLE);

Parameters

NameTypeDescription
newFeeuint256The new swap fee value

setMintFee

Set the mint fee within allowed bounds

function setMintFee(uint256 newFee) external override onlyRole(GOVERNOR_ROLE);

Parameters

NameTypeDescription
newFeeuint256The new mint fee value

setRedeemFee

Set the redeem fee within allowed bounds

function setRedeemFee(uint256 newFee) external override onlyRole(GOVERNOR_ROLE);

Parameters

NameTypeDescription
newFeeuint256The new redeem fee value

cancelRamp

Allows guardians to cancel an ongoing A ramp in emergencies

function cancelRamp() external override onlyRole(GUARDIAN_ROLE);

setOffPegFeeMultiplier

Set the off-peg fee multiplier within allowed bounds

function setOffPegFeeMultiplier(uint256 newMultiplier) external override onlyRole(GOVERNOR_ROLE);

Parameters

NameTypeDescription
newMultiplieruint256The new off-peg fee multiplier value

setExchangeRateFeeFactor

Set the exchange rate fee within allowed bounds

function setExchangeRateFeeFactor(uint256 newFeeFactor) external override onlyRole(GOVERNOR_ROLE);

Parameters

NameTypeDescription
newFeeFactoruint256The new exchange rate fee value

setBufferPercent

Set the buffer within allowed bounds

function setBufferPercent(uint256 newBuffer) external override onlyRole(GOVERNOR_ROLE);

Parameters

NameTypeDescription
newBufferuint256The new buffer value

setTokenSymbol

Set the token symbol

function setTokenSymbol(string calldata newSymbol) external override onlyRole(GOVERNOR_ROLE);

Parameters

NameTypeDescription
newSymbolstringThe new token symbol

setDecayPeriod

Set the decay period

function setDecayPeriod(uint256 newDecayPeriod) external override onlyRole(GOVERNOR_ROLE);

Parameters

NameTypeDescription
newDecayPerioduint256The new decay period in seconds

setRateChangeSkipPeriod

Set the rate change skip period

function setRateChangeSkipPeriod(uint256 newSkipPeriod) external override onlyRole(GOVERNOR_ROLE);

Parameters

NameTypeDescription
newSkipPerioduint256The new skip period in seconds

updateFeeErrorMargin

Set the fee error margin within allowed bounds

function updateFeeErrorMargin(uint256 newMargin) external override onlyRole(GOVERNOR_ROLE);

Parameters

NameTypeDescription
newMarginuint256The new fee error margin value

updateYieldErrorMargin

Set the yield error margin within allowed bounds

function updateYieldErrorMargin(uint256 newMargin) external override onlyRole(GOVERNOR_ROLE);

Parameters

NameTypeDescription
newMarginuint256The new yield error margin value

distributeLoss

Distribute any losses incurred

function distributeLoss() external override onlyRole(GOVERNOR_ROLE);

setTreasury

Set treasury address that will receive withdrawn SPA tokens from Buffer

function setTreasury(address newTreasury) external onlyRole(GOVERNOR_ROLE);

withdrawAdminFee

Withdraw Buffer through SPAToken and send newly-minted SPA tokens to Treasury

function withdrawAdminFee(uint256 amount) external onlyRole(GOVERNOR_ROLE);

Parameters

NameTypeDescription
amountuint256Amount of tokens to withdraw (18-decimals)

pause

Pause the SPA

function pause() external override onlyRole(GUARDIAN_ROLE);

unpause

Unpause the SPA

function unpause() external override onlyRole(PROTOCOL_OWNER_ROLE);

getRegistry

Get the parameter registry used for bounds checking

function getRegistry() external view override returns (IParameterRegistry);

Returns

NameTypeDescription
<none>IParameterRegistryThe parameter registry address

getRampAController

Get the RampAController being managed

function getRampAController() external view override returns (IRampAController);

Returns

NameTypeDescription
<none>IRampAControllerThe RampAController address

getSpa

Get the SelfPeggingAsset being managed

function getSpa() external view override returns (SelfPeggingAsset);

Returns

NameTypeDescription
<none>SelfPeggingAssetThe SelfPeggingAsset address

getSpaToken

Get the SPA token being managed

function getSpaToken() external view override returns (SPAToken);

Returns

NameTypeDescription
<none>SPATokenThe SPA token address

_authorizeUpgrade

Authorisation to upgrade the implementation of the contract.

function _authorizeUpgrade(address) internal override onlyRole(PROTOCOL_OWNER_ROLE);

checkBounds

Validates if new value is within both absolute and relative bounds

function checkBounds(uint256 newValue, uint256 currentValue, IParameterRegistry.Bounds memory bounds) internal pure;

Parameters

NameTypeDescription
newValueuint256The new value to check
currentValueuint256The current value for relative bounds checking
boundsIParameterRegistry.BoundsThe bounds object containing min, max, and relative change limits

checkRange

Checks if new value is within the allowed relative change from current value

function checkRange(uint256 newValue, uint256 currentValue, IParameterRegistry.Bounds memory bounds) internal pure;

Parameters

NameTypeDescription
newValueuint256The new value to check
currentValueuint256The current value to compare against
boundsIParameterRegistry.BoundsThe bounds object containing relative change limits

Errors

ZeroAddress

error ZeroAddress();

OutOfBounds

error OutOfBounds();

DeltaTooBig

error DeltaTooBig();

RelativeRangeNotSet

error RelativeRangeNotSet();

WrongSymbol

error WrongSymbol();