HegicOptionsETH
About
Stats
Public Functions
27
Event Types
7
Code Size
75,532 bytes
Events (7) keyboard_arrow_up
Functions
supportsInterface keyboard_arrow_up
balanceOf keyboard_arrow_up
Source Code
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _holderTokens[owner].length();
}
ownerOf keyboard_arrow_up
name keyboard_arrow_up
symbol keyboard_arrow_up
tokenURI keyboard_arrow_up
Requirements help
null
Source Code
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory _tokenURI = _tokenURIs[tokenId];
// If there is no base URI, return the token URI.
if (bytes(_baseURI).length == 0) {
return _tokenURI;
}
// If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
if (bytes(_tokenURI).length > 0) {
return string(abi.encodePacked(_baseURI, _tokenURI));
}
// If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
return string(abi.encodePacked(_baseURI, tokenId.toString()));
}
baseURI keyboard_arrow_up
tokenOfOwnerByIndex keyboard_arrow_up
totalSupply keyboard_arrow_up
tokenByIndex keyboard_arrow_up
approve keyboard_arrow_up
Requirements help
Source Code
function approve(address to, uint256 tokenId) public virtual override {
address owner = ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
getApproved keyboard_arrow_up
Requirements help
null
Source Code
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
setApprovalForAll keyboard_arrow_up
Requirements help
Source Code
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
isApprovedForAll keyboard_arrow_up
transferFrom keyboard_arrow_up
Requirements help
Source Code
function transferFrom(address from, address to, uint256 tokenId) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
safeTransferFrom keyboard_arrow_up
Requirements help
Source Code
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
safeTransferFrom keyboard_arrow_up
Requirements help
Source Code
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
createOption keyboard_arrow_up
Parameters help
Source Code
function createOption(
uint _period,
uint _amount,
uint _strike,
IHegicOptions.OptionType _optionType,
address _to
)
payable
external
returns (uint newTokenId)
{
uint optionId = optionsProvider.create{value: msg.value}(_period, _amount, _strike, _optionType);
_transferBalance(msg.sender); // if sender sent more than needed, contract will return excess
newTokenId = tokenize(optionId, _to);
emit Created(_to, newTokenId, optionId);
}
exerciseOption keyboard_arrow_up
Modifiers help
onlyTokenOwnerOrApproved checks for the following:
null
Source Code
function exerciseOption(uint _tokenId) external onlyTokenOwnerOrApproved(_tokenId) returns (uint profit){
uint optionId = underlyingOptionId[_tokenId];
optionsProvider.exercise(optionId);
// contract pays token owner, even if called by an approved account
profit = _transferBalance(ownerOf(_tokenId));
emit Exercised(ownerOf(_tokenId), _tokenId, optionId, profit);
}
tokenizeOption keyboard_arrow_up
Requirements help
Source Code
function tokenizeOption(uint _optionId, address _to) external returns (uint newTokenId) {
(, address holder, , , , , ,) = optionsProvider.options(_optionId);
require(holder != address(this), "HONFT/already-tokenized");
require(holder == msg.sender, "HONFT/invalid-holder");
newTokenId = tokenize(_optionId, _to);
}
detokenizeOption keyboard_arrow_up
Modifiers help
onlyTokenOwnerOrApproved checks for the following:
null
Requirements help
null
Source Code
function detokenizeOption(uint _tokenId, bool _burnToken) external onlyTokenOwnerOrApproved(_tokenId) {
require(checkValidToken(_tokenId), "HONFT/option-not-owned-by-contract");
uint optionId = underlyingOptionId[_tokenId];
address owner = ownerOf(_tokenId);
// checks if optionsProvider will allow to transfer option ownership
(IHegicOptions.State state, , , , , , uint expiration , ) = getUnderlyingOptionParams(_tokenId);
if(state == IHegicOptions.State.Active && expiration > block.timestamp)
optionsProvider.transfer(optionId, payable(ownerOf(_tokenId)));
delete ownedByThis[_tokenId];
if(_burnToken) {
delete holdingToken[optionId];
_burn(_tokenId);
}
emit Detokenized(owner, _tokenId, optionId, _burnToken);
}
burnToken keyboard_arrow_up
Modifiers help
onlyTokenOwnerOrApproved checks for the following:
null
Requirements help
One or more of the following:
-
UNKNOWN VALUE
must be equal to
UNKNOWN VALUE
- OR
owner
must be equal to
UNKNOWN VALUE
- ORnull
Source Code
function burnToken(uint _tokenId) external onlyTokenOwnerOrApproved(_tokenId) {
(IHegicOptions.State state, , , , , , uint expiration , ) = getUnderlyingOptionParams(_tokenId);
// only allows to burn inactive options, even if still owned by the contract
if(state == IHegicOptions.State.Active || expiration > block.timestamp)
require(!ownedByThis[_tokenId], "HONFT/cannot-burn-option");
delete holdingToken[underlyingOptionId[_tokenId]];
_burn(_tokenId);
}
getOptionCostETH keyboard_arrow_up
Parameters help
Source Code
function getOptionCostETH(
uint _period,
uint _amount,
uint _strike,
IHegicOptions.OptionType _optionType
)
public
view
override
returns (uint ethCost)
{
(ethCost, , , ) = IHegicETHOptions(address(optionsProvider)).fees(_period, _amount, _strike, _optionType);
}