AthenaPositionToken

The AthenaPositionToken contract is a slightly modified ERC-721 token representing a liquidity position in the Athena protocol. The contract includes the ERC721Enumerable extension, which adds enumerability of all the token IDs in the contract as well as all token IDs owned by each account. An additional Athena-specific method, tokensOf(), is also included to easily retrieve all the token IDs owned by an account.

The Athena position ID is equivalent to the token's ERC-721 token ID.


State variables info

baseDataURI

string baseDataURI

The base URI for the token metadata. The metadata does NOT include the position's parameters. To retrieve the position's parameters, use the LiquidityManager contract's positionInfo() function.

nextPositionId

uint256 nextPositionId

The ID of the next position to be minted.


Read Functions info

name

function name() external view returns (string memory)

Returns the token collection name.

symbol

function symbol() external view returns (string memory)

Returns the token collection symbol.

tokenURI

function tokenURI(uint256 tokenId) external view returns (string memory)

Returns the Uniform Resource Identifier (URI) for tokenId token.

balanceOf

function balanceOf(address owner) external view returns (uint256 balance)

Returns the number of tokens in owner's account.

ownerOf

function ownerOf(uint256 tokenId) external view returns (address owner)

Returns the owner of the tokenId token.

Requirements:

  • tokenId must exist.

getApproved

function getApproved(uint256 tokenId) external view returns (address operator)

Returns the account approved for tokenId token.

Requirements:

  • tokenId must exist.

isApprovedForAll

function isApprovedForAll(
    address owner,
    address operator
) external view returns (bool)

Returns if the operator is allowed to manage all of the assets of owner.

See {setApprovalForAll}

totalSupply

function totalSupply() external view returns (uint256)

Returns the total amount of tokens stored by the contract.

tokenOfOwnerByIndex

function tokenOfOwnerByIndex(
    address owner,
    uint256 index
) external view returns (uint256)

Returns a token ID owned by owner at a given index of its token list. Use along with {balanceOf} to enumerate all of owner's tokens.

tokenByIndex

function tokenByIndex(uint256 index) external view returns (uint256)

Returns a token ID at a given index of all the tokens stored by the contract. Use along with {totalSupply} to enumerate all tokens.

tokensOf

function tokensOf(
    address account_
) external view returns (uint256[] memory tokens)

Returns the token IDs owned by an account

Parameters:

Name
Type
Description

account_

address

The account to query

Return values:

Name
Type
Description

tokens

uint256[]

The token IDs owned by the account


Write Functions info

safeTransferFrom

function safeTransferFrom(
    address from,
    address to,
    uint256 tokenId,
    bytes calldata data
) external

Safely transfers tokenId token from from to to.

Requirements:

  • from cannot be the zero address.

  • to cannot be the zero address.

  • tokenId token must exist and be owned by from.

  • If the caller is not from, it must be approved to move this token by either {approve} or {setApprovalForAll}.

  • If to refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.

Emits a {Transfer} event.

transferFrom

function transferFrom(address from, address to, uint256 tokenId) external

Transfers tokenId token from from to to.

WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must understand this adds an external call which potentially creates a re-entrancy vulnerability.

Requirements:

  • from cannot be the zero address.

  • to cannot be the zero address.

  • tokenId token must be owned by from.

  • If the caller is not from, it must be approved to move this token by either {approve} or {setApprovalForAll}.

Emits a {Transfer} event.

approve

function approve(address to, uint256 tokenId) external

Gives permission to to to transfer tokenId token to another account. The approval is cleared when the token is transferred.

Only a single account can be approved at a time, so approving the zero address clears previous approvals.

Requirements:

  • The caller must own the token or be an approved operator.

  • tokenId must exist.

Emits an {Approval} event.

setApprovalForAll

function setApprovalForAll(address operator, bool approved) external

Approve or remove operator as an operator for the caller. Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.

Requirements:

  • The operator cannot be the address zero.

Emits an {ApprovalForAll} event.


Events info

Transfer

event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)

Emitted when tokenId token is transferred from from to to.

Approval

event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId)

Emitted when owner enables approved to manage the tokenId token.

ApprovalForAll

event ApprovalForAll(address indexed owner, address indexed operator, bool approved)

Emitted when owner enables or disables (approved) operator to manage all of its assets.

Last updated