Skip to main content

OsTokenRedeemer

Git Source ↗

Inherits: Ownable2Step ↗, Multicall →, IOsTokenRedeemer

This contract is used to redeem OsTokens for the underlying asset.

Events

PositionsManagerUpdated

Event emitted when the positions manager is updated

event PositionsManagerUpdated(address indexed positionsManager);

Parameters

NameTypeDescription
positionsManageraddressThe address of the new positions manager

RedeemablePositionsProposed

Event emitted when new redeemable positions are proposed

event RedeemablePositionsProposed(bytes32 indexed merkleRoot, string ipfsHash);

Parameters

NameTypeDescription
merkleRootbytes32The Merkle root of the redeemable positions
ipfsHashstringThe IPFS hash of the redeemable positions

RedeemablePositionsAccepted

Event emitted when the pending redeemable positions are accepted

event RedeemablePositionsAccepted(bytes32 indexed merkleRoot, string ipfsHash);

Parameters

NameTypeDescription
merkleRootbytes32The Merkle root of the accepted redeemable positions
ipfsHashstringThe IPFS hash of the accepted redeemable positions

RedeemablePositionsDenied

Event emitted when the new redeemable positions are denied

event RedeemablePositionsDenied(bytes32 indexed merkleRoot, string ipfsHash);

Parameters

NameTypeDescription
merkleRootbytes32The Merkle root of the denied redeemable positions
ipfsHashstringThe IPFS hash of the denied redeemable positions

RedeemablePositionsRemoved

Event emitted when the redeemable positions are removed

event RedeemablePositionsRemoved(bytes32 indexed merkleRoot, string ipfsHash);

Parameters

NameTypeDescription
merkleRootbytes32The Merkle root of the removed redeemable positions
ipfsHashstringThe IPFS hash of the removed redeemable positions

ExitQueueEntered

Event emitted on shares added to the exit queue

event ExitQueueEntered(address indexed owner, address indexed receiver, uint256 positionTicket, uint256 shares);

Parameters

NameTypeDescription
owneraddressThe address that owns the shares
receiveraddressThe address that will receive withdrawn assets
positionTicketuint256The exit queue ticket that was assigned to the position
sharesuint256The number of shares that queued for the exit

ExitedAssetsClaimed

Event emitted on claim of the exited assets

event ExitedAssetsClaimed(
address indexed receiver, uint256 prevPositionTicket, uint256 newPositionTicket, uint256 withdrawnAssets
);

Parameters

NameTypeDescription
receiveraddressThe address that has received withdrawn assets
prevPositionTicketuint256The exit queue ticket received after the enterExitQueue call
newPositionTicketuint256The new exit queue ticket in case not all the shares were withdrawn. Otherwise 0.
withdrawnAssetsuint256The total number of assets withdrawn

OsTokenSharesSwapped

Event emitted on shares swapped for assets

event OsTokenSharesSwapped(address indexed sender, address indexed receiver, uint256 shares, uint256 assets);

Parameters

NameTypeDescription
senderaddressThe address that initiated the swap
receiveraddressThe address that will receive the shares
sharesuint256The number of shares received
assetsuint256The number of assets spent

CheckpointCreated

Event emitted on checkpoint creation

event CheckpointCreated(uint256 shares, uint256 assets);

Parameters

NameTypeDescription
sharesuint256The number of burned shares
assetsuint256The amount of exited assets

OsTokenPositionsRedeemed

Event emitted when OsToken positions are redeemed

event OsTokenPositionsRedeemed(uint256 shares, uint256 assets);

Parameters

NameTypeDescription
sharesuint256The number of shares redeemed
assetsuint256The number of assets redeemed

Structs

RedeemablePositions

Struct to store the redeemable positions Merkle root and IPFS hash

struct RedeemablePositions {
bytes32 merkleRoot;
string ipfsHash;
}

Properties

NameTypeDescription
merkleRootbytes32The Merkle root of the redeemable positions
ipfsHashstringThe IPFS hash of the redeemable positions

OsTokenPosition

Struct to store the redeemed OsToken position details

struct OsTokenPosition {
address vault;
address owner;
uint256 leafShares;
uint256 sharesToRedeem;
}

Properties

NameTypeDescription
vaultaddressThe address of the Vault
owneraddressThe address of the position owner
leafSharesuint256The amount of OsToken shares used to calculate the merkle leaf
sharesToRedeemuint256

Functions

exitQueueUpdateDelay

The delay in seconds for the exit queue updates

function exitQueueUpdateDelay() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The delay in seconds

queuedShares

The number of queued OsToken shares

function queuedShares() external view returns (uint128);

Returns

NameTypeDescription
<none>uint128The number of queued shares

unclaimedAssets

The number of unclaimed assets in the exit queue

function unclaimedAssets() external view returns (uint128);

Returns

NameTypeDescription
<none>uint128The number of unclaimed assets

redeemedShares

The number of redeemed OsToken shares

function redeemedShares() external view returns (uint128);

Returns

NameTypeDescription
<none>uint128The number of redeemed shares

redeemedAssets

The number of redeemed assets

function redeemedAssets() external view returns (uint128);

Returns

NameTypeDescription
<none>uint128The number of redeemed assets

swappedShares

The number of swapped OsToken shares

function swappedShares() external view returns (uint128);

Returns

NameTypeDescription
<none>uint128The number of swapped shares

swappedAssets

The number of swapped assets

function swappedAssets() external view returns (uint128);

Returns

NameTypeDescription
<none>uint128The number of swapped assets

leafToProcessedShares

Maps a Merkle tree leaf to processed shares

function leafToProcessedShares(bytes32 leaf) external view returns (uint256 processedShares);

Parameters

NameTypeDescription
leafbytes32The leaf of the Merkle tree

Returns

NameTypeDescription
processedSharesuint256The number of processed shares corresponding to the leaf

exitRequests

Maps a exit request hash to the number of exiting shares

function exitRequests(bytes32 exitRequestHash) external view returns (uint256 shares);

Parameters

NameTypeDescription
exitRequestHashbytes32The hash of the exit request

Returns

NameTypeDescription
sharesuint256The number of shares that are exiting for the given exit request hash

exitQueueTimestamp

The timestamp when the exit queue was last updated

function exitQueueTimestamp() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The timestamp of the last exit queue update

positionsManager

The address that can propose redeemable OsToken positions

function positionsManager() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the positions manager

nonce

The current nonce for the redemptions

function nonce() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The current nonce value

getExitQueueData

Get the current exit queue data

function getExitQueueData() external view override returns (uint256, uint256, uint256);

Returns

NameTypeDescription
<none>uint256queuedShares The total number of shares currently queued for exit
<none>uint256unclaimedAssets The total number of assets that have not been claimed yet
<none>uint256totalTickets The total number of tickets (shares) processed in the exit queue

redeemablePositions

The current redeemable positions Merkle root and IPFS hash

function redeemablePositions() external view override returns (bytes32 merkleRoot, string memory ipfsHash);

Returns

NameTypeDescription
merkleRootbytes32The Merkle root of the redeemable positions
ipfsHashstringThe IPFS hash of the redeemable positions

pendingRedeemablePositions

The pending redeemable positions Merkle root and IPFS hash that is waiting to be accepted

function pendingRedeemablePositions() external view override returns (bytes32 merkleRoot, string memory ipfsHash);

Returns

NameTypeDescription
merkleRootbytes32The Merkle root of the pending redeemable positions
ipfsHashstringThe IPFS hash of the pending redeemable positions

getExitQueueIndex

Gets the index of the exit queue for a given position ticket.

function getExitQueueIndex(uint256 positionTicket) external view override returns (int256);

Parameters

NameTypeDescription
positionTicketuint256The position ticket to search for

Returns

NameTypeDescription
<none>int256The index of the exit queue or -1 if not found

canProcessExitQueue

Checks if the exit queue can be processed

function canProcessExitQueue() external view override returns (bool);

Returns

NameTypeDescription
<none>boolTrue if the exit queue can be processed, false otherwise

calculateExitedAssets

Calculates the exited assets for a given position ticket and exit queue index.

function calculateExitedAssets(address receiver, uint256 positionTicket, uint256 exitQueueIndex)
public
view
override
returns (uint256 leftTickets, uint256 exitedTickets, uint256 exitedAssets);

Parameters

NameTypeDescription
receiveraddressThe address of the receiver
positionTicketuint256The position ticket to calculate exited assets for
exitQueueIndexuint256The index of the exit queue to calculate exited assets for

Returns

NameTypeDescription
leftTicketsuint256The number of tickets left in the exit queue
exitedTicketsuint256The number of tickets that have exited
exitedAssetsuint256The number of assets that have exited

setPositionsManager

Update the address of the positions manager. Can only be called by the owner.

function setPositionsManager(address positionsManager_) external override onlyOwner;

Parameters

NameTypeDescription
positionsManager_addressThe address of the new positions manager

proposeRedeemablePositions

Proposes new redeemable positions. Can only be called by the positions manager.

function proposeRedeemablePositions(RedeemablePositions calldata newPositions) external override;

Parameters

NameTypeDescription
newPositionsRedeemablePositionsThe new redeemable positions to propose

acceptRedeemablePositions

Accepts the pending redeemable positions. Can only be called by the owner.

function acceptRedeemablePositions() external override onlyOwner;

denyRedeemablePositions

Denies the pending redeemable positions. Can only be called by the owner.

function denyRedeemablePositions() external override onlyOwner;

removeRedeemablePositions

Removes the redeemable positions. Can only be called by the owner.

function removeRedeemablePositions() external override onlyOwner;

permitOsToken

Permit OsToken shares to be used for redemption.

function permitOsToken(uint256 shares, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external override;

Parameters

NameTypeDescription
sharesuint256The number of shares to permit
deadlineuint256The deadline for the permit
vuint8The recovery byte of the signature
rbytes32The output of the ECDSA signature
sbytes32The output of the ECDSA signature

enterExitQueue

Enters the exit queue with a given number of shares and receiver address.

function enterExitQueue(uint256 shares, address receiver) external override returns (uint256 positionTicket);

Parameters

NameTypeDescription
sharesuint256The number of shares to enter the exit queue with
receiveraddressThe address that will receive the assets after exit

Returns

NameTypeDescription
positionTicketuint256The position ticket for the entered exit queue

claimExitedAssets

Claims exited assets for a given position ticket and exit queue index.

function claimExitedAssets(uint256 positionTicket, uint256 exitQueueIndex) external override;

Parameters

NameTypeDescription
positionTicketuint256The position ticket to claim exited assets for
exitQueueIndexuint256The index of the exit queue to claim exited assets for

redeemOsTokenPositions

function redeemOsTokenPositions(
OsTokenPosition[] memory positions,
bytes32[] calldata proof,
bool[] calldata proofFlags
) external override;

processExitQueue

Process the exit queue and checkpoint swapped or redeemed shares. Can only be called once per exitQueueUpdateDelay.

function processExitQueue() external override;