Machine
Inherits: MakinaGovernable, BridgeController, SpokeSnapshotConsumer, ReentrancyGuard, IMachine
Constants
MachineStorageLocation
bytes32 private constant MachineStorageLocation =
0x55fe2a17e400bcd0e2125123a7fc955478e727b29a4c522f4f2bd95d961bd900;Functions
_getMachineStorage
function _getMachineStorage() private pure returns (MachineStorage storage $);Returns
| Name | Type | Description |
|---|---|---|
| $ | MachineStorage |
constructor
constructor(address _registry, address _creForwarder)
MakinaContext(_registry)
SpokeSnapshotConsumer(_creForwarder);Parameters
| Name | Type | Description |
|---|---|---|
| _registry | address | |
| _creForwarder | address |
initialize
Initializer of the contract.
function initialize(
MachineInitParams calldata mParams,
MakinaGovernableInitParams calldata mgParams,
SpokeSnapshotConsumerInitParams calldata sscParams,
address _preDepositVault,
address _shareToken,
address _accountingToken,
address _hubCaliber
) external override initializer;Parameters
| Name | Type | Description |
|---|---|---|
| mParams | MachineInitParams | The machine initialization parameters. |
| mgParams | MakinaGovernableInitParams | The makina governable initialization parameters. |
| sscParams | SpokeSnapshotConsumerInitParams | The spoke snapshot consumer initialization parameters. |
| _preDepositVault | address | The address of the pre-deposit vault. |
| _shareToken | address | The address of the share token. |
| _accountingToken | address | The address of the accounting token. |
| _hubCaliber | address | The address of the hub caliber. |
depositor
Address of the depositor.
function depositor() external view override returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
redeemer
Address of the redeemer.
function redeemer() external view override returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
shareToken
Address of the share token.
function shareToken() external view override returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
accountingToken
Address of the accounting token.
function accountingToken() external view override returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
hubCaliber
Address of the hub caliber.
function hubCaliber() external view override returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
feeManager
Address of the fee manager.
function feeManager() external view override returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
caliberStaleThreshold
Maximum duration a caliber can remain unaccounted for before it is considered stale.
function caliberStaleThreshold() external view override returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
maxFixedFeeAccrualRate
Maximum fixed fee accrual rate per second used to compute an upper bound on shares to be minted, 1e18 = 100%.
function maxFixedFeeAccrualRate() external view override returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
maxPerfFeeAccrualRate
Maximum performance fee accrual rate per second used to compute an upper bound on shares to be minted, 1e18 = 100%.
function maxPerfFeeAccrualRate() external view override returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
feeMintCooldown
Minimum time that must elapse between two fee minting events.
function feeMintCooldown() external view override returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
shareLimit
Share token supply limit that cannot be exceeded by new deposits.
function shareLimit() external view override returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
maxSharePriceChangeRate
Maximum relative share price change rate per second during total AUM updates, 1e18 = 100%.
function maxSharePriceChangeRate() external view override returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
maxMint
Maximum amount of shares that can currently be minted through asset deposits.
function maxMint() public view override returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
maxWithdraw
Maximum amount of accounting tokens that can currently be withdrawn through share redemptions.
function maxWithdraw() public view override returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
lastTotalAum
Last total machine AUM.
function lastTotalAum() external view override returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
lastGlobalAccountingTime
Timestamp of the last global machine accounting.
function lastGlobalAccountingTime() external view override returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
getSpokeCalibersLength
Number of calibers associated with the machine.
function getSpokeCalibersLength() external view override returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
getSpokeChainId
Spoke caliber index => Spoke chain ID.
function getSpokeChainId(uint256 idx) external view override returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| idx | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
getSpokeCaliberNetAum
Spoke chain ID => Spoke caliber's net AUM and accounting timestamp.
function getSpokeCaliberNetAum(uint256 chainId) external view override returns (uint256, uint256);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | |
| <none> | uint256 |
getSpokeCaliberMailbox
Spoke chain ID => Spoke caliber mailbox address.
function getSpokeCaliberMailbox(uint256 chainId) external view override returns (address);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
isSpokeCaliberEnabled
Spoke chain ID => Whether the spoke caliber is enabled.
function isSpokeCaliberEnabled(uint256 chainId) external view override returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
getSpokeBridgeAdapter
Spoke chain ID => Spoke bridge ID => Spoke bridge adapter.
function getSpokeBridgeAdapter(uint256 chainId, uint16 bridgeId) external view override returns (address);Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| bridgeId | uint16 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
isIdleToken
Token => Is the token registered as an idle token in this machine.
function isIdleToken(address token) external view override returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
getIdleTokensLength
Length of the idle tokens list.
function getIdleTokensLength() external view override returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
getIdleToken
Idle token index => Idle token address.
There are no guarantees on the ordering of values inside the idle tokens list, and it may change when values are added or removed.
function getIdleToken(uint256 idx) external view override returns (address);Parameters
| Name | Type | Description |
|---|---|---|
| idx | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
convertToShares
Returns the amount of shares that the machine would exchange for the amount of accounting tokens provided.
function convertToShares(uint256 assets) public view override returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| assets | uint256 | The amount of accounting tokens. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | shares The amount of shares. |
convertToAssets
Returns the amount of accounting tokens that the machine would exchange for the amount of shares provided.
function convertToAssets(uint256 shares) public view override returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| shares | uint256 | The amount of shares. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | assets The amount of accounting tokens. |
manageTransfer
Manages the transfer of tokens between a machine and a caliber. The transfer direction depends on the caller.
function manageTransfer(address token, uint256 amount, bytes calldata data) external override nonReentrant;Parameters
| Name | Type | Description |
|---|---|---|
| token | address | The address of the token. |
| amount | uint256 | The amount of tokens to transfer. |
| data | bytes | ABI-encoded parameters required for bridge-related transfers. Ignored for transfers between a machine and its hub caliber. |
transferToHubCaliber
Initiates a token transfer to the hub caliber.
function transferToHubCaliber(address token, uint256 amount) external override notRecoveryMode onlyMechanic;Parameters
| Name | Type | Description |
|---|---|---|
| token | address | The address of the token to transfer. |
| amount | uint256 | The amount of token to transfer. |
transferToSpokeCaliber
Initiates a token transfer to the spoke caliber.
function transferToSpokeCaliber(
uint16 bridgeId,
uint256 chainId,
address token,
uint256 amount,
uint256 minOutputAmount
) external override nonReentrant notRecoveryMode onlyMechanic;Parameters
| Name | Type | Description |
|---|---|---|
| bridgeId | uint16 | The ID of the bridge to use for the transfer. |
| chainId | uint256 | The chain ID of the spoke caliber. |
| token | address | The address of the token to transfer. |
| amount | uint256 | The amount of token to transfer. |
| minOutputAmount | uint256 | The minimum output amount expected from the transfer. |
sendOutBridgeTransfer
Executes a scheduled outgoing bridge transfer.
function sendOutBridgeTransfer(uint16 bridgeId, uint256 transferId, bytes calldata data)
external
override
notRecoveryMode
onlyMechanic;Parameters
| Name | Type | Description |
|---|---|---|
| bridgeId | uint16 | The ID of the bridge. |
| transferId | uint256 | The ID of the transfer to execute. |
| data | bytes | The optional data needed to execute the transfer. |
authorizeInBridgeTransfer
Registers a message hash as authorized for an incoming bridge transfer.
function authorizeInBridgeTransfer(uint16 bridgeId, bytes32 messageHash) external override onlyOperator;Parameters
| Name | Type | Description |
|---|---|---|
| bridgeId | uint16 | The ID of the bridge. |
| messageHash | bytes32 | The hash of the message to authorize. |
claimInBridgeTransfer
Transfers a received bridge transfer out of the corresponding bridge adapter.
function claimInBridgeTransfer(uint16 bridgeId, uint256 transferId) external override onlyOperator;Parameters
| Name | Type | Description |
|---|---|---|
| bridgeId | uint16 | The ID of the bridge. |
| transferId | uint256 | The ID of the transfer to claim. |
cancelOutBridgeTransfer
Cancels an outgoing bridge transfer.
function cancelOutBridgeTransfer(uint16 bridgeId, uint256 transferId) external override onlyOperator;Parameters
| Name | Type | Description |
|---|---|---|
| bridgeId | uint16 | The ID of the bridge. |
| transferId | uint256 | The ID of the transfer to cancel. |
updateTotalAum
Updates the total AUM of the machine.
function updateTotalAum() external override nonReentrant onlyAccountingAuthorized returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | totalAum The updated total AUM. |
deposit
Deposits accounting tokens into the machine and mints shares to the receiver.
function deposit(uint256 assets, address receiver, uint256 minShares, bytes32 referralKey)
external
override
nonReentrant
notRecoveryMode
returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| assets | uint256 | The amount of accounting tokens to deposit. |
| receiver | address | The receiver of minted shares. |
| minShares | uint256 | The minimum amount of shares to be minted. |
| referralKey | bytes32 | The optional identifier used to track a referral source. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | shares The amount of shares minted. |
redeem
Redeems shares from the machine and transfers accounting tokens to the receiver.
function redeem(uint256 shares, address receiver, uint256 minAssets)
external
override
nonReentrant
notRecoveryMode
returns (uint256);Parameters
| Name | Type | Description |
|---|---|---|
| shares | uint256 | The amount of shares to redeem. |
| receiver | address | The receiver of the accounting tokens. |
| minAssets | uint256 | The minimum amount of accounting tokens to be transferred. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | assets The amount of accounting tokens transferred. |
onReport
function onReport(bytes calldata metadata, bytes calldata report) external override nonReentrant;Parameters
| Name | Type | Description |
|---|---|---|
| metadata | bytes | |
| report | bytes |
setSpokeCaliber
Registers a spoke caliber mailbox and related bridge adapters.
function setSpokeCaliber(
uint256 chainId,
address spokeCaliberMailbox,
uint16[] calldata bridges,
address[] calldata adapters
) external override nonReentrant restricted;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | The chain ID of the spoke caliber. |
| spokeCaliberMailbox | address | The address of the spoke caliber mailbox. |
| bridges | uint16[] | The list of bridges supported with the spoke caliber mailbox. |
| adapters | address[] | The list of corresponding spoke adapters for each bridge. Must be the same length as bridges. |
disableSpokeCaliber
Disables a spoke caliber.
function disableSpokeCaliber(uint256 chainId) external override nonReentrant restricted;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | The chain ID of the spoke caliber to disable. |
enableSpokeCaliber
Re-enables a spoke caliber.
function enableSpokeCaliber(uint256 chainId) external override nonReentrant restricted;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | The chain ID of the spoke caliber to enable. |
setSpokeBridgeAdapter
Registers a spoke bridge adapter.
function setSpokeBridgeAdapter(uint256 chainId, uint16 bridgeId, address adapter)
external
override
nonReentrant
restricted;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | The chain ID of the spoke bridge adapter. |
| bridgeId | uint16 | The ID of the bridge. |
| adapter | address | The address of the spoke bridge adapter. |
setDepositor
Sets the depositor address.
function setDepositor(address newDepositor) external override restricted;Parameters
| Name | Type | Description |
|---|---|---|
| newDepositor | address | The address of the new depositor. |
setRedeemer
Sets the redeemer address.
function setRedeemer(address newRedeemer) external override restricted;Parameters
| Name | Type | Description |
|---|---|---|
| newRedeemer | address | The address of the new redeemer. |
setFeeManager
Sets the fee manager address.
function setFeeManager(address newFeeManager) external override restricted;Parameters
| Name | Type | Description |
|---|---|---|
| newFeeManager | address | The address of the new fee manager. |
setCaliberStaleThreshold
Sets the caliber accounting staleness threshold.
function setCaliberStaleThreshold(uint256 newCaliberStaleThreshold) external override onlyRiskManagerTimelock;Parameters
| Name | Type | Description |
|---|---|---|
| newCaliberStaleThreshold | uint256 | The new threshold in seconds. |
setMaxFixedFeeAccrualRate
Sets the maximum fixed fee accrual rate.
function setMaxFixedFeeAccrualRate(uint256 newMaxAccrualRate) external override onlyRiskManagerTimelock;Parameters
| Name | Type | Description |
|---|---|---|
| newMaxAccrualRate | uint256 | The new maximum fixed fee accrual rate per second, 1e18 = 100%. |
setMaxPerfFeeAccrualRate
Sets the maximum performance fee accrual rate.
function setMaxPerfFeeAccrualRate(uint256 newMaxAccrualRate) external override onlyRiskManagerTimelock;Parameters
| Name | Type | Description |
|---|---|---|
| newMaxAccrualRate | uint256 | The new maximum performance fee accrual rate per second, 1e18 = 100%. |
setFeeMintCooldown
Sets the minimum time to be elapsed between two fee minting events.
function setFeeMintCooldown(uint256 newFeeMintCooldown) external override onlyRiskManagerTimelock;Parameters
| Name | Type | Description |
|---|---|---|
| newFeeMintCooldown | uint256 | The new cooldown in seconds. |
setShareLimit
Sets the new share token supply limit that cannot be exceeded by new deposits.
function setShareLimit(uint256 newShareLimit) external override onlyRiskManager;Parameters
| Name | Type | Description |
|---|---|---|
| newShareLimit | uint256 | The new share limit. |
setMaxSharePriceChangeRate
Sets the new maximum relative share price change rate per second during total AUM updates, 1e18 = 100%.
function setMaxSharePriceChangeRate(uint256 newMaxSharePriceChangeRate) external override onlyRiskManagerTimelock;Parameters
| Name | Type | Description |
|---|---|---|
| newMaxSharePriceChangeRate | uint256 | The new maximum relative share price change rate. |
disableOutTransfer
Disables outgoing transfers for a bridge.
function disableOutTransfer(uint16 bridgeId) external override onlyRiskManagerTimelock;Parameters
| Name | Type | Description |
|---|---|---|
| bridgeId | uint16 | The ID of the bridge. |
enableOutTransfer
Enables outgoing transfers for a bridge.
function enableOutTransfer(uint16 bridgeId) external override onlyRiskManagerTimelock;Parameters
| Name | Type | Description |
|---|---|---|
| bridgeId | uint16 | The ID of the bridge. |
setMaxBridgeLossBps
Sets the maximum allowed value loss in basis points for transfers via this bridge.
function setMaxBridgeLossBps(uint16 bridgeId, uint256 maxBridgeLossBps) external override onlyRiskManagerTimelock;Parameters
| Name | Type | Description |
|---|---|---|
| bridgeId | uint16 | The ID of the bridge. |
| maxBridgeLossBps | uint256 | The maximum allowed value loss in basis points. |
resetBridgingState
Resets internal bridge counters for a given token, and withdraws token balances held by all bridge adapters.
This function is intended to be used by the DAO to realign bridge accounting state and maintain protocol consistency, typically in response to operator deviations, external bridge discrepancies, or unbounded counter growth.
function resetBridgingState(address token) external override nonReentrant onlySecurityCouncil;Parameters
| Name | Type | Description |
|---|---|---|
| token | address | The address of the token. |
_setSpokeBridgeAdapter
Sets the spoke bridge adapter for a given chain ID and bridge ID.
function _setSpokeBridgeAdapter(uint256 chainId, uint16 bridgeId, address adapter) internal;Parameters
| Name | Type | Description |
|---|---|---|
| chainId | uint256 | |
| bridgeId | uint16 | |
| adapter | address |
_notifyIdleToken
Checks token balance, and registers token if needed.
function _notifyIdleToken(address token) internal;Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
Structs
MachineStorage
Note:
- storage-location: erc7201:makina.storage.Machine
struct MachineStorage {
address _shareToken;
address _accountingToken;
address _depositor;
address _redeemer;
address _feeManager;
uint256 _caliberStaleThreshold;
uint256 _lastTotalAum;
uint256 _lastGlobalAccountingTime;
uint256 _lastMintedFeesTime;
uint256 _lastMintedFeesSharePrice;
uint256 _maxFixedFeeAccrualRate;
uint256 _maxPerfFeeAccrualRate;
uint256 _feeMintCooldown;
uint256 _shareTokenDecimalsOffset;
uint256 _shareLimit;
uint256 _hubChainId;
address _hubCaliber;
uint256[] _spokeChainIds;
mapping(uint256 chainId => SpokeCaliberData data) _spokeCalibersData;
EnumerableSet.AddressSet _idleTokens;
uint256 _maxSharePriceChangeRate;
}Properties
| Name | Type | Description |
|---|---|---|
| _shareToken | address | |
| _accountingToken | address | |
| _depositor | address | |
| _redeemer | address | |
| _feeManager | address | |
| _caliberStaleThreshold | uint256 | |
| _lastTotalAum | uint256 | |
| _lastGlobalAccountingTime | uint256 | |
| _lastMintedFeesTime | uint256 | |
| _lastMintedFeesSharePrice | uint256 | |
| _maxFixedFeeAccrualRate | uint256 | |
| _maxPerfFeeAccrualRate | uint256 | |
| _feeMintCooldown | uint256 | |
| _shareTokenDecimalsOffset | uint256 | |
| _shareLimit | uint256 | |
| _hubChainId | uint256 | |
| _hubCaliber | address | |
| _spokeChainIds | uint256[] | |
| _spokeCalibersData | mapping(uint256 chainId => SpokeCaliberData data) | |
| _idleTokens | EnumerableSet.AddressSet | |
| _maxSharePriceChangeRate | uint256 |