Skip to main content

OlympusDepositPositionManager

Git Source

Inherits: DEPOSv1

Title: Olympus Deposit Position Manager

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

Constants​

_OHM_SCALE​

uint256 internal constant _OHM_SCALE = 1e9;

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;

Functions​

constructor​

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

Parameters

NameTypeDescription
kernel_address
tokenRenderer_address

KEYCODE​

5 byte identifier for a module.

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

Returns

NameTypeDescription
<none>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​

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​

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);

Parameters

NameTypeDescription
operator_address
params_IDepositPositionManager.MintParams

Returns

NameTypeDescription
positionIduint256

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);

Parameters

NameTypeDescription
params_IDepositPositionManager.MintParamsThe parameters for the position creation

Returns

NameTypeDescription
positionIduint256The ID of the new position

setRemainingDeposit​

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​

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​

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​

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

Parameters

NameTypeDescription
id_uint256

Returns

NameTypeDescription
<none>string

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;

Parameters

NameTypeDescription
from_address
to_address
tokenId_uint256

getPositionCount​

Get the total number of positions

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

Returns

NameTypeDescription
<none>uint256The total number of positions

_getPosition​

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

Parameters

NameTypeDescription
positionId_uint256

Returns

NameTypeDescription
<none>Position

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[]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>PositionThe 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);

Parameters

NameTypeDescription
position_Position

Returns

NameTypeDescription
<none>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);

Parameters

NameTypeDescription
amount_uint256
conversionPrice_uint256

Returns

NameTypeDescription
<none>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>uint256The amount of OHM that would be received

_setTokenRenderer​

function _setTokenRenderer(address renderer_) internal;

Parameters

NameTypeDescription
renderer_address

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>addressThe address of the current renderer contract (or zero address if not set)

supportsInterface​

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

Parameters

NameTypeDescription
interfaceId_bytes4

Returns

NameTypeDescription
<none>bool

_onlyValidPosition​

function _onlyValidPosition(uint256 positionId_) internal view;

Parameters

NameTypeDescription
positionId_uint256

onlyValidPosition​

modifier onlyValidPosition(uint256 positionId_);

Parameters

NameTypeDescription
positionId_uint256

_onlyPositionOperator​

function _onlyPositionOperator(uint256 positionId_) internal view;

Parameters

NameTypeDescription
positionId_uint256

onlyPositionOperator​

modifier onlyPositionOperator(uint256 positionId_);

Parameters

NameTypeDescription
positionId_uint256

_onlyPositionOwner​

function _onlyPositionOwner(uint256 positionId_) internal view;

Parameters

NameTypeDescription
positionId_uint256

onlyPositionOwner​

modifier onlyPositionOwner(uint256 positionId_);

Parameters

NameTypeDescription
positionId_uint256