Skip to content
LogoLogo

SecurityModule

Git Source

Inherits: ERC20Upgradeable, ReentrancyGuard, MachinePeriphery, ISecurityModule

Constants

MAX_BPS

Full scale value in basis points

uint256 private constant MAX_BPS = 10_000;

SecurityModuleStorageLocation

bytes32 private constant SecurityModuleStorageLocation =
        0x008282b5c1b058474ce5feb89ba7468762b87f27435b2f525bf76e3e0c3af500;

Functions

_getSecurityModuleStorage

function _getSecurityModuleStorage() private pure returns (SecurityModuleStorage storage $);

Returns

NameTypeDescription
$SecurityModuleStorage

constructor

constructor(address _peripheryRegistry) MachinePeriphery(_peripheryRegistry);

Parameters

NameTypeDescription
_peripheryRegistryaddress

initialize

Initializer of the contract.

function initialize(bytes calldata _data) external virtual initializer;

Parameters

NameTypeDescription
_databytesThe initialization data, if any.

notSlashingMode

modifier notSlashingMode();

decimals

Returns the decimals places of the token.

function decimals() public pure override(ERC20Upgradeable, IERC20Metadata) returns (uint8);

Returns

NameTypeDescription
<none>uint8

machine

Address of the associated machine.

function machine() public view override(IMachinePeriphery, MachinePeriphery) returns (address);

Returns

NameTypeDescription
<none>address

machineShare

Address of the machine share token locked in this contract.

function machineShare() public view override returns (address);

Returns

NameTypeDescription
<none>address

cooldownReceipt

Address of the cooldown receipt NFT.

function cooldownReceipt() public view override returns (address);

Returns

NameTypeDescription
<none>address

cooldownDuration

Cooldown duration in seconds for unlocking.

function cooldownDuration() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256

maxSlashableBps

Maximum slashable proportion of the vault balance in basis points.

function maxSlashableBps() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256

minBalanceAfterSlash

Minimum balance that must remain in the vault after a slash.

function minBalanceAfterSlash() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256

pendingCooldown

Returns data of a pending cooldown.

function pendingCooldown(uint256 cooldownId) external view override returns (uint256, uint256, uint256);

Parameters

NameTypeDescription
cooldownIduint256The ID of the cooldown receipt NFT representing the pending cooldown.

Returns

NameTypeDescription
<none>uint256The amount of security shares to be redeemed.
<none>uint256The current expected amount of machine shares that can be redeemed.
<none>uint256The timestamp at which the cooldown period will end and the shares can be redeemed.

slashingMode

Whether the security module is in slashing mode.

function slashingMode() public view override returns (bool);

Returns

NameTypeDescription
<none>bool

totalLockedAmount

Total amount of machine shares locked in the module.

function totalLockedAmount() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256

maxSlashable

Total amount of machine shares currently slashable in the module.

function maxSlashable() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256

convertToShares

Converts machine shares to security shares.

function convertToShares(uint256 assets) public view override returns (uint256);

Parameters

NameTypeDescription
assetsuint256The amount of machine shares to convert.

Returns

NameTypeDescription
<none>uint256The amount of security shares corresponding to the input machine shares.

convertToAssets

Converts security shares to machine shares.

function convertToAssets(uint256 shares) public view override returns (uint256);

Parameters

NameTypeDescription
sharesuint256The amount of security shares to convert.

Returns

NameTypeDescription
<none>uint256The amount of machine shares corresponding to the input security shares.

previewLock

Estimates the amount of security shares that would be received for a given amount of machine shares.

function previewLock(uint256 assets) public view override notSlashingMode returns (uint256);

Parameters

NameTypeDescription
assetsuint256The amount of machine shares to convert.

Returns

NameTypeDescription
<none>uint256The estimated amount of security shares corresponding to the input machine shares.

lock

Locks machine shares in the module and mints security shares.

function lock(uint256 assets, address receiver, uint256 minShares)
        external
        override
        nonReentrant
        notSlashingMode
        returns (uint256);

Parameters

NameTypeDescription
assetsuint256The amount of machine shares to lock.
receiveraddressThe address that will receive the security shares.
minSharesuint256The minimum amount of security shares to receive.

Returns

NameTypeDescription
<none>uint256The amount of security shares minted.

startCooldown

Requests a cooldown for redeeming security shares. Shares are locked in the contract until the cooldown is cancelled or expires. A cooldown receipt NFT is minted to the specified receiver address.

function startCooldown(uint256 shares, address receiver)
        external
        override
        nonReentrant
        returns (uint256, uint256, uint256);

Parameters

NameTypeDescription
sharesuint256The amount of security shares to redeem.
receiveraddressThe address that will receive the cooldown receipt.

Returns

NameTypeDescription
<none>uint256The ID of the minted cooldown receipt NFT representing the pending cooldown.
<none>uint256The maximum amount of machine shares that can be redeemed.
<none>uint256The timestamp at which the cooldown period will end and the shares can be redeemed.

cancelCooldown

Cancels a pending cooldown. Shares for which the cooldown was cancelled are transferred back to caller. The associated cooldown receipt NFT is burned.

function cancelCooldown(uint256 cooldownId) external override nonReentrant returns (uint256);

Parameters

NameTypeDescription
cooldownIduint256The ID of the cooldown receipt NFT representing the pending cooldown.

Returns

NameTypeDescription
<none>uint256The amount of security shares for which the cooldown was cancelled.

redeem

Redeems security shares and transfers machine shares to caller.

function redeem(uint256 cooldownId, uint256 minAssets) external override nonReentrant returns (uint256);

Parameters

NameTypeDescription
cooldownIduint256The ID of the cooldown receipt NFT representing the pending cooldown.
minAssetsuint256The minimum amount of machine shares to receive.

Returns

NameTypeDescription
<none>uint256The amount of machine shares transferred to the receiver.

slash

Slashes a specified amount from the total locked amount and triggers the slashing mode.

function slash(uint256 amount) external override nonReentrant onlySecurityCouncil;

Parameters

NameTypeDescription
amountuint256The amount to slash from the total locked amount.

settleSlashing

Settles the current slashing, allowing the contract to exit slashing mode and resume normal operations.

function settleSlashing() external override onlySecurityCouncil;

setCooldownDuration

Sets the cooldown duration for unlocking.

function setCooldownDuration(uint256 newCooldownDuration) external override onlyRiskManagerTimelock;

Parameters

NameTypeDescription
newCooldownDurationuint256The new cooldown duration in seconds.

setMaxSlashableBps

Sets the maximum slashable proportion of the vault balance in basis points.

function setMaxSlashableBps(uint256 newMaxSlashableBps) external override onlyRiskManagerTimelock;

Parameters

NameTypeDescription
newMaxSlashableBpsuint256The new maximum slashable proportion in basis points.

setMinBalanceAfterSlash

Sets the minimum balance that must remain in the vault after a slash.

function setMinBalanceAfterSlash(uint256 newMinBalanceAfterSlash) external override onlyRiskManagerTimelock;

Parameters

NameTypeDescription
newMinBalanceAfterSlashuint256The new minimum balance after slash.

_setMachine

Disables machine setter from parent MachinePeriphery contract.

function _setMachine(address) internal pure override;

Parameters

NameTypeDescription
_address

_checkReceiptOwner

Checks that caller is the owner of the cooldown receipt NFT.

function _checkReceiptOwner(uint256 cooldownId) internal view returns (address);

Parameters

NameTypeDescription
cooldownIduint256

Returns

NameTypeDescription
<none>address

Structs

SecurityModuleStorage

Note:

  • storage-location: erc7201:makina.storage.SecurityModule
struct SecurityModuleStorage {
        address _machineShare;
        address _cooldownReceipt;
        uint256 _cooldownDuration;
        uint256 _maxSlashableBps;
        uint256 _minBalanceAfterSlash;
        mapping(uint256 cooldownId => PendingCooldown cooldownData) _pendingCooldowns;
        bool _slashingMode;
    }

Properties

NameTypeDescription
_machineShareaddress
_cooldownReceiptaddress
_cooldownDurationuint256
_maxSlashableBpsuint256
_minBalanceAfterSlashuint256
_pendingCooldownsmapping(uint256 cooldownId => PendingCooldown cooldownData)
_slashingModebool