Skip to main content

OlympusDepositPositionManager

Git Source

Inherits: DEPOSv1

Title: Olympus Deposit Position Manager

forge-lint: disable-start(mixed-case-function, mixed-case-variable)

Implementation of the {DEPOSv1} interface This contract is used to create, manage, and wrap/unwrap deposit positions. Positions are optionally convertible.

State Variables​

_tokenRenderer​

The address of the token renderer contract

If set, tokenURI() will delegate to this contract. If not set, tokenURI() returns an empty string.

address internal _tokenRenderer

_OHM_SCALE​

uint256 internal constant _OHM_SCALE = 1e9

Functions​

constructor​

constructor(address kernel_, address tokenRenderer_)
Module(Kernel(kernel_))
ERC721("Olympus Deposit Position", "ODP");

KEYCODE​

5 byte identifier for a module.

function KEYCODE() public pure override returns (Keycode);

VERSION​

Returns which semantic version of a module is being implemented.

function VERSION() public pure override returns (uint8 major, uint8 minor);

Returns

NameTypeDescription
majoruint8- Major version upgrade indicates breaking change to the interface.
minoruint8- Minor version change retains backward-compatible interface.

wrap​

Wraps a position into an ERC721 token This is useful if the position owner wants a tokenized representation of their position. It is functionally equivalent to the position itself.

This function reverts if:

  • The position ID is invalid
  • The caller is not the owner of the position
  • The position is already wrapped This is a public function that can be called by any address holding a position
function wrap(uint256 positionId_)
external
virtual
override
onlyValidPosition(positionId_)
onlyPositionOwner(positionId_);

Parameters

NameTypeDescription
positionId_uint256The ID of the position to wrap

unwrap​

Unwraps/burns an ERC721 position token This is useful if the position owner wants to unwrap their token back into the position.

This function reverts if:

  • The position ID is invalid
  • The caller is not the owner of the position
  • The position is not wrapped This is a public function that can be called by any address holding a position
function unwrap(uint256 positionId_)
external
virtual
override
onlyValidPosition(positionId_)
onlyPositionOwner(positionId_);

Parameters

NameTypeDescription
positionId_uint256The ID of the position to unwrap

_create​

function _create(address operator_, IDepositPositionManager.MintParams memory params_)
internal
returns (uint256 positionId);

mint​

This function reverts if:

  • The caller is not permissioned
  • The owner is the zero address
  • The convertible deposit token is the zero address
  • The remaining deposit is 0
  • The conversion price is 0
  • The conversion expiry is in the past This is a permissioned function that can only be called by approved policies
function mint(IDepositPositionManager.MintParams calldata params_)
external
virtual
override
permissioned
returns (uint256 positionId);

setRemainingDeposit​

Updates the remaining deposit of a position

This function reverts if:

  • The caller is not permissioned
  • The position ID is invalid
  • The caller is not the operator that created the position This is a permissioned function that can only be called by approved policies
function setRemainingDeposit(uint256 positionId_, uint256 amount_)
external
virtual
override
permissioned
onlyValidPosition(positionId_)
onlyPositionOperator(positionId_);

Parameters

NameTypeDescription
positionId_uint256The ID of the position to update
amount_uint256The new amount of the position

setAdditionalData​

Updates the additional data of a position

This function reverts if:

  • The caller is not permissioned
  • The position ID is invalid
  • The caller is not the operator that created the position This is a permissioned function that can only be called by approved policies
function setAdditionalData(uint256 positionId_, bytes calldata additionalData_)
external
virtual
override
permissioned
onlyValidPosition(positionId_)
onlyPositionOperator(positionId_);

Parameters

NameTypeDescription
positionId_uint256The ID of the position to update
additionalData_bytesThe new additional data of the position

split​

Splits the specified amount of the position into a new position This is useful if the position owner wants to split their position into multiple smaller positions.

This function reverts if:

  • The caller is not permissioned
  • The caller is not the operator that created the position
  • The amount is 0
  • The amount is greater than the remaining deposit
  • to_ is the zero address This is a permissioned function that can only be called by approved policies
function split(uint256 positionId_, uint256 amount_, address to_, bool wrap_)
external
virtual
override
permissioned
onlyValidPosition(positionId_)
onlyPositionOperator(positionId_)
returns (uint256 newPositionId);

Parameters

NameTypeDescription
positionId_uint256The ID of the position to split
amount_uint256The amount of the position to split
to_addressThe address to split the position to
wrap_boolWhether the new position should be wrapped

Returns

NameTypeDescription
newPositionIduint256The ID of the new position

tokenURI​

See {IERC721Metadata-tokenURI}.

function tokenURI(uint256 id_) public view virtual override returns (string memory);

transferFrom​

This function performs the following:

  • Updates the owner of the position
  • Calls transferFrom on the parent contract
function transferFrom(address from_, address to_, uint256 tokenId_) public override;

getPositionCount​

Get the total number of positions

function getPositionCount() external view virtual override returns (uint256);

Returns

NameTypeDescription
<none>uint256_count The total number of positions

_getPosition​

function _getPosition(uint256 positionId_) internal view returns (Position memory);

getUserPositionIds​

Get the IDs of all positions for a given user

function getUserPositionIds(address user_) external view virtual override returns (uint256[] memory);

Parameters

NameTypeDescription
user_addressThe address of the user

Returns

NameTypeDescription
<none>uint256[]_positionIds An array of position IDs

getPosition​

Get the position for a given ID

This function reverts if:

  • The position ID is invalid
function getPosition(uint256 positionId_) external view virtual override returns (Position memory);

Parameters

NameTypeDescription
positionId_uint256The ID of the position

Returns

NameTypeDescription
<none>Position_position The position for the given ID

isExpired​

Check if a position is expired

This function reverts if:

  • The position ID is invalid
function isExpired(uint256 positionId_) external view virtual override returns (bool);

Parameters

NameTypeDescription
positionId_uint256The ID of the position

Returns

NameTypeDescription
<none>boolisExpired_ Returns true if the conversion expiry timestamp is now or in the past

_isConvertible​

function _isConvertible(Position memory position_) internal pure returns (bool);

isConvertible​

Check if a position is convertible

This function reverts if:

  • The position ID is invalid
function isConvertible(uint256 positionId_) external view virtual override returns (bool);

Parameters

NameTypeDescription
positionId_uint256The ID of the position

Returns

NameTypeDescription
<none>boolisConvertible_ Returns true if the conversion price is not the maximum value

_previewConvert​

function _previewConvert(uint256 amount_, uint256 conversionPrice_) internal pure returns (uint256);

previewConvert​

Preview the amount of OHM that would be received for a given amount of convertible deposit tokens

function previewConvert(uint256 positionId_, uint256 amount_)
public
view
virtual
override
onlyValidPosition(positionId_)
returns (uint256);

Parameters

NameTypeDescription
positionId_uint256The ID of the position
amount_uint256The amount of convertible deposit tokens to convert

Returns

NameTypeDescription
<none>uint256_ohmOut The amount of OHM that would be received

_setTokenRenderer​

function _setTokenRenderer(address renderer_) internal;

setTokenRenderer​

Set the token renderer contract

This function reverts if:

  • The caller is not permissioned
  • The renderer contract does not implement the required interface
function setTokenRenderer(address renderer_) external virtual override permissioned;

Parameters

NameTypeDescription
renderer_addressThe address of the renderer contract

getTokenRenderer​

Get the current token renderer contract

function getTokenRenderer() external view virtual override returns (address);

Returns

NameTypeDescription
<none>address_renderer The address of the current renderer contract (or zero address if not set)

supportsInterface​

function supportsInterface(bytes4 interfaceId_) public view virtual override returns (bool);

_onlyValidPosition​

function _onlyValidPosition(uint256 positionId_) internal view;

onlyValidPosition​

modifier onlyValidPosition(uint256 positionId_) ;

_onlyPositionOperator​

function _onlyPositionOperator(uint256 positionId_) internal view;

onlyPositionOperator​

modifier onlyPositionOperator(uint256 positionId_) ;

_onlyPositionOwner​

function _onlyPositionOwner(uint256 positionId_) internal view;

onlyPositionOwner​

modifier onlyPositionOwner(uint256 positionId_) ;