# 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()](#tokensof), is also included to easily retrieve all the token IDs owned by an account.

{% hint style="info" %}
The Athena position ID is equivalent to the token's ERC-721 token ID.
{% endhint %}

***

## State variables info

### baseDataURI

```solidity
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()](https://doc.athenains.io/liquiditymanager#positioninfo) function.

### nextPositionId

```solidity
uint256 nextPositionId
```

The ID of the next position to be minted.

***

## Read Functions info

### name

```solidity
function name() external view returns (string memory)
```

Returns the token collection name.

### symbol

```solidity
function symbol() external view returns (string memory)
```

Returns the token collection symbol.

### tokenURI

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

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

### balanceOf

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

Returns the number of tokens in `owner`'s account.

### ownerOf

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

Returns the owner of the `tokenId` token.

Requirements:

* `tokenId` must exist.

### getApproved

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

Returns the account approved for `tokenId` token.

Requirements:

* `tokenId` must exist.

### isApprovedForAll

```solidity
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

```solidity
function totalSupply() external view returns (uint256)
```

Returns the total amount of tokens stored by the contract.

### tokenOfOwnerByIndex

```solidity
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

```solidity
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

```solidity
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

```solidity
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

```solidity
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

```solidity
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

```solidity
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

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

Emitted when `tokenId` token is transferred from `from` to `to`.

### Approval

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

Emitted when `owner` enables `approved` to manage the `tokenId` token.

### ApprovalForAll

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

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