Skip to main content

MachineUtils

Git Source

State Variables

FEE_ACCRUAL_RATE_DIVISOR

uint256 private constant FEE_ACCRUAL_RATE_DIVISOR = 1e18;

Functions

updateTotalAum

function updateTotalAum(Machine.MachineStorage storage $, address oracleRegistry) external returns (uint256);

manageFees

function manageFees(Machine.MachineStorage storage $) external returns (uint256);

updateSpokeCaliberAccountingData

Updates the spoke caliber accounting data in the machine storage.

function updateSpokeCaliberAccountingData(
Machine.MachineStorage storage $,
address tokenRegistry,
address chainRegistry,
address wormhole,
bytes calldata response,
GuardianSignature[] calldata signatures
) external;

Parameters

NameTypeDescription
$Machine.MachineStorageThe machine storage struct.
tokenRegistryaddressThe address of the token registry.
chainRegistryaddressThe address of the chain registry.
wormholeaddressThe address of the Core Wormhole contract.
responsebytesThe Wormhole CCQ response payload containing the accounting data.
signaturesGuardianSignature[]The array of Wormhole guardians signatures attesting to the validity of the response.

migrateFromPreDeposit

Manages the migration from a pre-deposit vault to a machine, and initializes the machine's accounting state.

function migrateFromPreDeposit(Machine.MachineStorage storage $, address preDepositVault, address oracleRegistry)
external;

Parameters

NameTypeDescription
$Machine.MachineStorageThe machine storage struct.
preDepositVaultaddressThe address of the pre-deposit vault.
oracleRegistryaddressThe address of the oracle registry.

getSharePrice

Calculates the share price based on given AUM, share supply and share token decimals offset.

function getSharePrice(uint256 aum, uint256 supply, uint256 shareTokenDecimalsOffset) public pure returns (uint256);

Parameters

NameTypeDescription
aumuint256The AUM of the machine.
supplyuint256The supply of the share token.
shareTokenDecimalsOffsetuint256The decimals offset between share token and accounting token.

Returns

NameTypeDescription
<none>uint256The calculated share price.

_handlePerChainQueryResponse

Handles a received Wormhole CCQ PerChainQueryResponse object and updates the corresponding caliber accounting data in the machine storage.

function _handlePerChainQueryResponse(
Machine.MachineStorage storage $,
address tokenRegistry,
address chainRegistry,
PerChainQueryResponse memory pcr
) private;

Parameters

NameTypeDescription
$Machine.MachineStorageThe machine storage struct.
tokenRegistryaddressThe address of the token registry.
chainRegistryaddressThe address of the chain registry.
pcrPerChainQueryResponseThe PerChainQueryResponse object containing the accounting data.

_decodeAndMapBridgeAmounts

Decodes (foreignToken, amount) pairs, resolves local tokens, and stores amounts in the map.

function _decodeAndMapBridgeAmounts(
uint256 chainId,
bytes[] memory data,
EnumerableMap.AddressToUintMap storage map,
address tokenRegistry
) private;

_getTotalAum

Computes the total AUM of the machine.

function _getTotalAum(Machine.MachineStorage storage $, address oracleRegistry) private view returns (uint256);

Parameters

NameTypeDescription
$Machine.MachineStorageThe machine storage struct.
oracleRegistryaddressThe address of the oracle registry.

_checkBridgeState

Checks if the bridge state is consistent between the machine and spoke caliber.

function _checkBridgeState(
EnumerableMap.AddressToUintMap storage insMap,
EnumerableMap.AddressToUintMap storage outsMap
) private view;

_accountingValueOf

Computes the accounting value of a given token amount.

function _accountingValueOf(address oracleRegistry, address accountingToken, address token, uint256 amount)
private
view
returns (uint256);