OlympusDepositPositionManager
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
| Name | Type | Description |
|---|---|---|
| kernel_ | address | |
| tokenRenderer_ | address |
KEYCODE
5 byte identifier for a module.
function KEYCODE() public pure override returns (Keycode);
Returns
| Name | Type | Description |
|---|---|---|
| <none> | Keycode |
VERSION
Returns which semantic version of a module is being implemented.
function VERSION() public pure override returns (uint8 major, uint8 minor);
Returns
| Name | Type | Description |
|---|---|---|
| major | uint8 | - Major version upgrade indicates breaking change to the interface. |
| minor | uint8 | - 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
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 | The ID of the position to unwrap |
_create
function _create(
address operator_,
IDepositPositionManager.MintParams memory params_
) internal returns (uint256 positionId);
Parameters
| Name | Type | Description |
|---|---|---|
| operator_ | address | |
| params_ | IDepositPositionManager.MintParams |
Returns
| Name | Type | Description |
|---|---|---|
| positionId | uint256 |
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
| Name | Type | Description |
|---|---|---|
| params_ | IDepositPositionManager.MintParams | The parameters for the position creation |
Returns
| Name | Type | Description |
|---|---|---|
| positionId | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 | The ID of the position to update |
| amount_ | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 | The ID of the position to update |
| additionalData_ | bytes | The 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
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 | The ID of the position to split |
| amount_ | uint256 | The amount of the position to split |
| to_ | address | The address to split the position to |
| wrap_ | bool | Whether the new position should be wrapped |
Returns
| Name | Type | Description |
|---|---|---|
| newPositionId | uint256 | The ID of the new position |
tokenURI
function tokenURI(uint256 id_) public view virtual override returns (string memory);
Parameters
| Name | Type | Description |
|---|---|---|
| id_ | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | string |
transferFrom
This function performs the following:
- Updates the owner of the position
- Calls
transferFromon the parent contract
function transferFrom(address from_, address to_, uint256 tokenId_) public override;
Parameters
| Name | Type | Description |
|---|---|---|
| from_ | address | |
| to_ | address | |
| tokenId_ | uint256 |
getPositionCount
Get the total number of positions
function getPositionCount() external view virtual override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | The total number of positions |
_getPosition
function _getPosition(uint256 positionId_) internal view returns (Position memory);
Parameters
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| user_ | address | The address of the user |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 | The ID of the position |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | 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
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 | The ID of the position |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool | isExpired_ Returns true if the conversion expiry timestamp is now or in the past |
_isConvertible
function _isConvertible(Position memory position_) internal pure returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
| position_ | Position |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 | The ID of the position |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool | isConvertible_ Returns true if the conversion price is not the maximum value |
_previewConvert
function _previewConvert(
uint256 amount_,
uint256 conversionPrice_
) internal pure returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
| amount_ | uint256 | |
| conversionPrice_ | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 | The ID of the position |
| amount_ | uint256 | The amount of convertible deposit tokens to convert |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 | The amount of OHM that would be received |
_setTokenRenderer
function _setTokenRenderer(address renderer_) internal;
Parameters
| Name | Type | Description |
|---|---|---|
| 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
| Name | Type | Description |
|---|---|---|
| renderer_ | address | The address of the renderer contract |
getTokenRenderer
Get the current token renderer contract
function getTokenRenderer() external view virtual override returns (address);
Returns
| Name | Type | Description |
|---|---|---|
| <none> | address | The address of the current renderer contract (or zero address if not set) |
supportsInterface
function supportsInterface(bytes4 interfaceId_) public view virtual override returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
| interfaceId_ | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
_onlyValidPosition
function _onlyValidPosition(uint256 positionId_) internal view;
Parameters
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 |
onlyValidPosition
modifier onlyValidPosition(uint256 positionId_);
Parameters
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 |
_onlyPositionOperator
function _onlyPositionOperator(uint256 positionId_) internal view;
Parameters
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 |
onlyPositionOperator
modifier onlyPositionOperator(uint256 positionId_);
Parameters
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 |
_onlyPositionOwner
function _onlyPositionOwner(uint256 positionId_) internal view;
Parameters
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 |
onlyPositionOwner
modifier onlyPositionOwner(uint256 positionId_);
Parameters
| Name | Type | Description |
|---|---|---|
| positionId_ | uint256 |