# Entity Reference

### Overview

This section provides a comprehensive reference for all entities in the Kodiak Islands subgraph, including their fields, relationships, and purpose.

### Core Entities

**KodiakVault**

Represents an individual vault in the Kodiak Islands protocol.

| Field                    | Type                 | Description                                          |
| ------------------------ | -------------------- | ---------------------------------------------------- |
| id                       | ID                   | Smart contract address of the vault                  |
| protocol                 | KodiakIslandProtocol | The protocol this vault belongs to                   |
| name                     | String               | Name of the liquidity pool                           |
| symbol                   | String               | Symbol of the liquidity pool                         |
| inputToken               | Token                | Token that needs to be deposited to take a position  |
| outputToken              | Token                | Token that is minted to track ownership of position  |
| manager                  | Bytes                | Manager of the vault                                 |
| managerFee               | BigDecimal           | Manager fee (in percentage) of the vault             |
| managerTreasury          | Bytes                | Manager treasury address                             |
| implementation           | Bytes                | Implementation address of the vault                  |
| createdTimestamp         | BigInt               | Creation timestamp                                   |
| createdBlockNumber       | BigInt               | Creation block number                                |
| totalValueLockedUSD      | BigDecimal           | Current TVL of this pool in USD                      |
| cumulativeLpFeesUSD      | BigDecimal           | All revenue generated, accrued to the supply side    |
| cumulativeManagerFeesUSD | BigDecimal           | All revenue generated, accrued to the protocol       |
| cumulativeTotalFeesUSD   | BigDecimal           | All revenue generated by the vault                   |
| inputTokenBalance        | BigInt               | Amount of input token in the pool                    |
| outputTokenSupply        | BigInt               | Total supply of output token                         |
| outputTokenPriceUSD      | BigDecimal           | Price per share of output token in USD               |
| pricePerShare            | BigDecimal           | Amount of input token per full share of output token |
| volumeToken0             | BigDecimal           | Volume of token0                                     |
| volumeToken1             | BigDecimal           | Volume of token1                                     |
| volumeUSD                | BigDecimal           | Volume in USD                                        |
| weeklyVolumeUSD          | BigDecimal           | Weekly volume in USD                                 |
| weeklyFeesEarnedUSD      | BigDecimal           | Weekly fees earned in USD                            |
| lowerTick                | BigInt               | Lower price tick of current position                 |
| upperTick                | BigInt               | Upper price tick of current position                 |
| \_token0                 | Token                | token0 of vault                                      |
| \_token1                 | Token                | token1 of vault                                      |
| \_token0Amount           | BigInt               | token0 amount                                        |
| \_token1Amount           | BigInt               | token1 amount                                        |
| \_token0AmountUSD        | BigDecimal           | token0 amount in USD                                 |
| \_token1AmountUSD        | BigDecimal           | token1 amount in USD                                 |

**KodiakApr**

Tracks APR (Annual Percentage Rate) information for vaults.

| Field      | Type       | Description              |
| ---------- | ---------- | ------------------------ |
| id         | ID         | Unique identifier        |
| averageApr | BigDecimal | Average APR of the vault |

**KodiakAprAccumulated**

Tracks accumulated APR data over time.

| Field        | Type                        | Description                                 |
| ------------ | --------------------------- | ------------------------------------------- |
| id           | ID                          | Unique identifier                           |
| vault        | KodiakVault                 | The vault this APR data belongs to          |
| accumulated  | BigDecimal                  | Accumulated APR value                       |
| count        | BigInt                      | Count of data points                        |
| lastSnapshot | KodiakVaultDailySnapshot    | Last snapshot used for calculation          |
| snapshots    | \[KodiakVaultDailySnapshot] | Array of snapshots used for APR calculation |

#### Events

**Event Interface**

Base interface for all events in the protocol.

| Field       | Type                 | Description                              |
| ----------- | -------------------- | ---------------------------------------- |
| id          | ID                   | Transaction hash + Log index             |
| hash        | String               | Transaction hash                         |
| logIndex    | Int                  | Event log index                          |
| protocol    | KodiakIslandProtocol | The protocol this transaction belongs to |
| to          | String               | Address that received tokens             |
| from        | String               | Address that sent tokens                 |
| blockNumber | BigInt               | Block number of this event               |
| timestamp   | BigInt               | Timestamp of this event                  |

**KodiakDeposit**

Records deposit events to vaults.

| Field                                  | Type        | Description                               |
| -------------------------------------- | ----------- | ----------------------------------------- |
| asset                                  | Token       | Token deposited                           |
| amount                                 | BigInt      | Amount of token deposited in native units |
| amountUSD                              | BigDecimal  | Amount of token deposited in USD          |
| amount0                                | BigDecimal  | Amount of token0                          |
| amount1                                | BigDecimal  | Amount of token1                          |
| vault                                  | KodiakVault | The vault involving this transaction      |
| *Plus all fields from Event interface* |             |                                           |

**KodiakWithdraw**

Records withdrawal events from vaults.

| Field                                  | Type        | Description                               |
| -------------------------------------- | ----------- | ----------------------------------------- |
| asset                                  | Token       | Token withdrawn                           |
| amount                                 | BigInt      | Amount of token withdrawn in native units |
| amountUSD                              | BigDecimal  | Amount of token withdrawn in USD          |
| vault                                  | KodiakVault | The vault involving this transaction      |
| *Plus all fields from Event interface* |             |                                           |

**KodiakStrategyChange**

Records changes to vault strategies.

| Field     | Type   | Description             |
| --------- | ------ | ----------------------- |
| id        | ID     | Unique identifier       |
| lowerTick | BigInt | New lower tick boundary |
| upperTick | BigInt | New upper tick boundary |
| timestamp | BigInt | Timestamp of the change |

#### Snapshots

**KodiakUsageMetricsDailySnapshot**

Daily snapshot of protocol usage metrics.

| Field                 | Type                 | Description                               |
| --------------------- | -------------------- | ----------------------------------------- |
| id                    | ID                   | Days since Unix epoch time                |
| protocol              | KodiakIslandProtocol | Protocol this snapshot is associated with |
| dailyActiveUsers      | Int                  | Number of unique daily active users       |
| cumulativeUniqueUsers | Int                  | Number of cumulative unique users         |
| dailyTransactionCount | Int                  | Total number of transactions in a day     |
| dailyDepositCount     | Int                  | Total number of deposits in a day         |
| dailyWithdrawCount    | Int                  | Total number of withdrawals in a day      |
| totalPoolCount        | Int                  | Total number of pools                     |
| blockNumber           | BigInt               | Block number of this snapshot             |
| timestamp             | BigInt               | Timestamp of this snapshot                |

**KodiakUsageMetricsHourlySnapshot**

Hourly snapshot of protocol usage metrics.

| Field                  | Type                 | Description                               |
| ---------------------- | -------------------- | ----------------------------------------- |
| id                     | ID                   | Hours since Unix epoch time               |
| protocol               | KodiakIslandProtocol | Protocol this snapshot is associated with |
| hourlyActiveUsers      | Int                  | Number of unique hourly active users      |
| cumulativeUniqueUsers  | Int                  | Number of cumulative unique users         |
| hourlyTransactionCount | Int                  | Total number of transactions in an hour   |
| hourlyDepositCount     | Int                  | Total number of deposits in an hour       |
| hourlyWithdrawCount    | Int                  | Total number of withdrawals in an hour    |
| blockNumber            | BigInt               | Block number of this snapshot             |
| timestamp              | BigInt               | Timestamp of this snapshot                |

**KodiakFinancialsDailySnapshot**

Daily snapshot of protocol financial metrics.

| Field                    | Type                 | Description                                      |
| ------------------------ | -------------------- | ------------------------------------------------ |
| id                       | ID                   | Days since Unix epoch time                       |
| protocol                 | KodiakIslandProtocol | Protocol this snapshot is associated with        |
| totalValueLockedUSD      | BigDecimal           | Current TVL of the entire protocol               |
| dailyLpFeesUSD           | BigDecimal           | Daily revenue claimed by suppliers               |
| cumulativeLpFeesUSD      | BigDecimal           | Cumulative revenue claimed by suppliers          |
| dailyManagerFeesUSD      | BigDecimal           | Daily revenue claimed by protocol                |
| cumulativeManagerFeesUSD | BigDecimal           | Cumulative revenue claimed by protocol           |
| dailyTotalFeesUSD        | BigDecimal           | All daily revenue generated by the protocol      |
| cumulativeTotalFeesUSD   | BigDecimal           | All cumulative revenue generated by the protocol |
| blockNumber              | BigInt               | Block number of this snapshot                    |
| timestamp                | BigInt               | Timestamp of this snapshot                       |

**KodiakVaultDailySnapshot**

Daily snapshot of vault metrics.

| Field                    | Type                    | Description                                          |
| ------------------------ | ----------------------- | ---------------------------------------------------- |
| id                       | ID                      | Vault address + Days since Unix epoch time           |
| protocol                 | KodiakIslandProtocol    | The protocol this snapshot belongs to                |
| vault                    | KodiakVault             | The vault this snapshot belongs to                   |
| totalValueLockedUSD      | BigDecimal              | Current TVL of this pool in USD                      |
| cumulativeLpFeesUSD      | BigDecimal              | All revenue generated, accrued to the supply side    |
| dailyLpFeesUSD           | BigDecimal              | Daily revenue generated, accrued to the supply side  |
| cumulativeManagerFeesUSD | BigDecimal              | All revenue generated, accrued to the protocol       |
| dailyManagerFeesUSD      | BigDecimal              | Daily revenue generated, accrued to the protocol     |
| cumulativeTotalFeesUSD   | BigDecimal              | All revenue generated by the vault                   |
| dailyTotalFeesUSD        | BigDecimal              | Daily revenue generated by the vault                 |
| inputTokenBalance        | BigInt                  | Amount of input token in the pool                    |
| outputTokenSupply        | BigInt                  | Total supply of output token                         |
| outputTokenPriceUSD      | BigDecimal              | Price per share of output token in USD               |
| pricePerShare            | BigDecimal              | Amount of input token per full share of output token |
| volumeUSD                | BigDecimal              | Volume in USD                                        |
| volumeToken0             | BigDecimal              | Volume of token0                                     |
| volumeToken1             | BigDecimal              | Volume of token1                                     |
| apr                      | BigDecimal              | Annual Percentage Rate                               |
| blockNumber              | BigInt                  | Block number of this snapshot                        |
| timestamp                | BigInt                  | Timestamp of this snapshot                           |
| lowerTick                | BigInt                  | Lower price tick of current position                 |
| upperTick                | BigInt                  | Upper price tick of current position                 |
| tickChanges              | \[KodiakStrategyChange] | Array of strategy changes                            |
| \_baseLowerTick          | BigInt                  | Base lower tick                                      |
| \_baseUpperTick          | BigInt                  | Base upper tick                                      |
| \_token0                 | Token                   | token0 of vault                                      |
| \_token1                 | Token                   | token1 of vault                                      |
| \_token0Amount           | BigInt                  | token0 amount                                        |
| \_token1Amount           | BigInt                  | token1 amount                                        |
| \_token0AmountUSD        | BigDecimal              | token0 amount in USD                                 |
| \_token1AmountUSD        | BigDecimal              | token1 amount in USD                                 |

**KodiakVaultHourlySnapshot**

Hourly snapshot of vault metrics.

| Field                    | Type                    | Description                                          |
| ------------------------ | ----------------------- | ---------------------------------------------------- |
| id                       | ID                      | Vault address + Hours since Unix epoch time          |
| protocol                 | KodiakIslandProtocol    | The protocol this snapshot belongs to                |
| vault                    | KodiakVault             | The vault this snapshot belongs to                   |
| totalValueLockedUSD      | BigDecimal              | Current TVL of this pool in USD                      |
| cumulativeLpFeesUSD      | BigDecimal              | All revenue generated, accrued to the supply side    |
| hourlyLpFeesUSD          | BigDecimal              | Hourly revenue generated, accrued to the supply side |
| cumulativeManagerFeesUSD | BigDecimal              | All revenue generated, accrued to the protocol       |
| hourlyManagerFeesUSD     | BigDecimal              | Hourly revenue generated, accrued to the protocol    |
| cumulativeTotalFeesUSD   | BigDecimal              | All revenue generated by the vault                   |
| hourlyTotalFeesUSD       | BigDecimal              | Hourly revenue generated by the vault                |
| inputTokenBalance        | BigInt                  | Amount of input token in the pool                    |
| outputTokenSupply        | BigInt                  | Total supply of output token                         |
| outputTokenPriceUSD      | BigDecimal              | Price per share of output token in USD               |
| pricePerShare            | BigDecimal              | Amount of input token per full share of output token |
| volumeUSD                | BigDecimal              | Volume in USD                                        |
| volumeToken0             | BigDecimal              | Volume of token0                                     |
| volumeToken1             | BigDecimal              | Volume of token1                                     |
| blockNumber              | BigInt                  | Block number of this snapshot                        |
| timestamp                | BigInt                  | Timestamp of this snapshot                           |
| lowerTick                | BigInt                  | Lower price tick of current position                 |
| upperTick                | BigInt                  | Upper price tick of current position                 |
| tickChanges              | \[KodiakStrategyChange] | Array of strategy changes                            |
| \_baseLowerTick          | BigInt                  | Base lower tick                                      |
| \_baseUpperTick          | BigInt                  | Base upper tick                                      |

#### Entity Relationships

The Kodiak Islands subgraph entities have the following key relationships:

1. **Protocol to Vaults**: One-to-many relationship where KodiakIslandProtocol has multiple KodiakVault entities.
2. **Vaults to Events**: One-to-many relationship where each KodiakVault can have multiple deposit and withdrawal events.
3. **Vaults to Snapshots**: One-to-many relationship where each KodiakVault has multiple daily and hourly snapshots.
4. **Protocol to Snapshots**: One-to-many relationship where the protocol has multiple usage and financial snapshots.
5. **Vault to APR**: One-to-one relationship where each vault has associated APR data.

This comprehensive entity structure allows for detailed tracking of all aspects of the Kodiak Islands protocol and its activities.
