Skip to main content

AsyncRedeemer

Git Source

Inherits: ERC721Upgradeable, ReentrancyGuardUpgradeable, MachinePeriphery, Whitelist, IAsyncRedeemer

State Variables

AsyncRedeemerStorageLocation

bytes32 private constant AsyncRedeemerStorageLocation =
0x187c268ec5d498b5b6e4945b27f62abf37217cdbd80e6429181b3e4c2c378900;

Functions

_getAsyncRedeemerStorage

function _getAsyncRedeemerStorage() private pure returns (AsyncRedeemerStorage storage $);

constructor

constructor(address _registry) MachinePeriphery(_registry);

initialize

Initializer of the contract.

function initialize(bytes calldata data) external virtual override initializer;

Parameters

NameTypeDescription
databytes

nextRequestId

ID of the next redeem request to be created.

function nextRequestId() external view override returns (uint256);

lastFinalizedRequestId

ID of the last finalized redeem request.

function lastFinalizedRequestId() external view override returns (uint256);

finalizationDelay

Minimum time (in seconds) to be elapsed between request submission and finalization.

function finalizationDelay() external view override returns (uint256);

getShares

Request ID => Shares

function getShares(uint256 requestId) external view override returns (uint256);

getClaimableAssets

Request ID => Claimable Assets

Reverts if the request is not finalized.

function getClaimableAssets(uint256 requestId) public view override returns (uint256);

previewFinalizeRequests

Returns the total shares and curreent expected assets for a batch of unfinalized requests up to given request ID.

function previewFinalizeRequests(uint256 upToRequestId) public view override returns (uint256, uint256);

Parameters

NameTypeDescription
upToRequestIduint256The request ID up to which to calculate the total shares and assets.

Returns

NameTypeDescription
<none>uint256totalShares The total shares for the batch of requests.
<none>uint256totalAssets The current total assets for the batch of requests.

requestRedeem

Creates a redeem request and issues an associated NFT to the receiver.

function requestRedeem(uint256 shares, address receiver)
public
virtual
override
nonReentrant
whitelistCheck
returns (uint256);

Parameters

NameTypeDescription
sharesuint256The amount of shares to redeem.
receiveraddressThe receiver of the receipt NFT.

Returns

NameTypeDescription
<none>uint256requestId The ID of the redeem request.

finalizeRequests

Finalizes redeem requests up to a given request ID.

Can only be called by the operator of the associated machine.

function finalizeRequests(uint256 upToRequestId, uint256 minAssets)
external
override
onlyMechanic
nonReentrant
returns (uint256, uint256);

Parameters

NameTypeDescription
upToRequestIduint256The request ID up to which to finalize requests.
minAssetsuint256The minimum amount of assets that must be available for the requests to be finalized.

claimAssets

Claims the assets associated with a finalized redeem request and burns the associated NFT.

function claimAssets(uint256 requestId) external override nonReentrant whitelistCheck returns (uint256);

Parameters

NameTypeDescription
requestIduint256the ID of the redeem request and associated NFT.

setFinalizationDelay

Sets the finalization delay for redeem requests.

function setFinalizationDelay(uint256 newDelay) external override onlyRiskManagerTimelock;

Parameters

NameTypeDescription
newDelayuint256The new finalization delay in seconds.

setWhitelistStatus

Enables or disables the whitelist.

function setWhitelistStatus(bool enabled) external override onlyRiskManager;

Parameters

NameTypeDescription
enabledboolTrue to enable the whitelist, false to disable.

setWhitelistedUsers

Whitelists or unwhitelists a list of users.

function setWhitelistedUsers(address[] calldata users, bool whitelisted) external override onlyRiskManager;

Parameters

NameTypeDescription
usersaddress[]The addresses of the users to update.
whitelistedboolTrue to whitelist the users, false to unwhitelist.

_validateFinalizedRequest

Checks that the request exists, is finalized, and has not yet been claimed.

function _validateFinalizedRequest(uint256 requestId) internal view;

_validateFinalizableRequest

Checks that the request exists and is eligible for finalization.

function _validateFinalizableRequest(uint256 requestId) internal view;

Structs

AsyncRedeemerStorage

Note: storage-location: erc7201:makina.storage.AsyncRedeemer

struct AsyncRedeemerStorage {
uint256 _nextRequestId;
uint256 _lastFinalizedRequestId;
uint256 _finalizationDelay;
mapping(uint256 requestId => IAsyncRedeemer.RedeemRequest request) _requests;
}