Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create SCHEMA_AMM (with vault) #48

Merged
merged 8 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions schemas/derivatives/SCHEMA.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,29 @@ Pools in the protocol (one entry for each token).
| token_address | The contract address of the token. | string |
| token_symbol | The symbol of the token. | string |

### Pairs (AMM)

Pairs traded in the protocol (one entry for each pair).

| Property | Description | Type |
|-------------------------|-----------------------------------------------------------|--------|
| chain_id | Standard chain id. | number |
| timestamp | The timestamp of the block the pool was created on. | number |
| creation_block_number | The block number this pool was created on. | number |
| pair_name | The name of the pool (ie, name() in the smart contract). | string |
| pair_index | The index of the token in the smart contract (one row for each pair). | number |
| pair_address | The contract address of the pair. | string |
| pair_symbol | The symbol of the pair. | string |
| pair_liquidity | The liquidity available for trading for the pair (24h rolling average, in tokens). | number |
| pair_liquidity_usd | The liquidity available for trading for the pair (24h rolling average, in USD). | number |
| volume_usd | The volume of each pair opened and closed in the given snapshot (24h rolling average, in USD). | number |
| open_interest_longs_usd | The sum of open interest of longs held for each pair, in USD. | number |
| open_interest_shorts_usd | The sum of open interest in shorts held for each pair, in USD. | number |
| liquidation_fees_usd | The total liquidation fees accrued for each pair (24h rolling average, in USD). | number |
| funding_rate | The funding rate for each pair at the time of the snapshot, as a percentage. | number |
| open_fees_usd | The total open fees accrued for each pair (24h rolling average, in USD). | number |
| close_fees_usd | The total close fees accrued for each pair (24h rolling average, in USD). | number |

### LP Snapshot

Liquidity providers snapshot (one entry for each token in a pool).
Expand All @@ -43,6 +66,26 @@ Liquidity providers snapshot (one entry for each token in a pool).
| user_fees_usd | (Optional) The portion of fees accrued to users of the protocol, in USD. | number |
| protocol_fees_usd | (Optional) The portion of fees accrued to the protocol, in USD. | number |

### LP Snapshot (AMM)

Liquidity providers snapshot (one entry for each token in a vault).

| Property | Description | Type |
|-------------------------|-----------------------------------------------------------|--------|
| timestamp | The timestamp of the snapshot. | number |
| block_date | The timestamp truncated (ie, YYYY-MM-DD format for daily snapshots and YYYY-MM-DD HH:00:00 for hourly snapshots). | date |
| chain_id | Standard chain id. | number |
| vault_address | The address of the vault. | string |
| lp_address | The address of the liquidity provider. | string |
| token_index | The index of the token in the smart contract. | number |
| token_address | The address of the token provided as liquidity. | string |
| token_symbol | The symbol of the token. | string |
| amount_useful | The amount of tokens supplied by the LP that are liquid and usable by users in the vault, decimal normalized. | number |
| amount_useful_usd | The amount of liquid tokens supplied in USD. | number |
| liquidity_change_amount | The amount of tokens lost (indicated by negative sign) or gained (indicated by positive sign) by the LP, decimal normalized. | number |
| liquidity_amount_usd | The amount lost or gained by the LP, in USD. | number |
| total_lp_fees_usd | Total fees generated for the LP at the time of snapshot (in USD). | number |

### Pool Snapshot

Snapshot of the pool's metrics.
Expand All @@ -61,6 +104,26 @@ Snapshot of the pool's metrics.
| open_interest_longs_usd | The sum of open interest of longs held within this pool in USD. | number |
| open_interest_shorts_usd | The sum of open interest in shorts held within this pool in USD. | number |

### Vault Snapshot (AMM)

Snapshot of the vault's metrics.

| Property | Description | Type |
|-------------------------|-----------------------------------------------------------|--------|
| timestamp | The timestamp of the snapshot. | number |
| block_date | The timestamp truncated (ie, YYYY-MM-DD format for daily snapshots and YYYY-MM-DD HH:00:00 for hourly snapshots). | date |
| chain_id | Standard chain id. | number |
| vault_address | The smart contract address of the vault. | string |
| token_address | The smart contract address of the token. | string |
| token_index | The index of the token in the smart contract. | number |
| token_amount | Total Value Locked at snapshot, in tokens. | number |
| token_amount_usd | Total Value Locked at snapshot (amount for each token, in USD). | number |
| liquidity_available_usd | The total liquidity available in the vault for trading, in USD. | number |
| open_interest_longs_usd | The aggregate value of open long positions backed by the vault’s liquidity at snapshot, in USD. | number |
| open_interest_shorts_usd | The aggregate value of open short positions backed by the vault’s liquidity at snapshot, in USD. | number |
| volume_usd | The volume of trades generated by the vault in the given snapshot (24h rolling average, in USD). | number |
| vault_fees_usd | The portion of fees accrued by the protocol (24h rolling average, in USD). | number |

### Trades

Trade data, 1 entry for each close, open, or update of a trade.
Expand All @@ -85,6 +148,36 @@ Trade data, 1 entry for each close, open, or update of a trade.
| trade_action | The action of trade being recorded in this entry (ie, OPEN, CLOSE, INCREASE, DECREASE, LIQUIDATED). | string |
| trade_type | The type of the trade being recorded in this entry (ie, LONG, SHORT). | string |

### Trades (AMM)

Trade data, one entry for each close, open, or update of a trade.

| Property | Description | Type |
|-------------------------|-----------------------------------------------------------|--------|
| timestamp | The timestamp of the trade. | number |
| chain_id | Standard chain id. | number |
| transaction_hash | The hash of the transaction this trade was performed in. | string |
| log_index | Event log index. | number |
| block_number | The block number of the trade. | number |
| pool_address | The address of the pool this token was traded in. | string |
| taker_address | The address of the taker. | string |
| pair_index | The address of the pair that is traded. | string |
| amount | The value that a trader is putting (and used as collateral) to open a long or a short, decimal normalized. | number |
| amount_usd | The trade amount in USD (if deposit is only made in stable, amount = amount_usd). | number |
| notional_value | The value of the leveraged amount of the trade, decimal normalized. | number |
| notional_value_usd | The notional value, in USD. | number |
| open_interest_longs_usd | The aggregate value of open long positions held by the trader at snapshot, in USD. | number |
| open_interest_shorts_usd | The aggregate value of open short positions held by the trader at snapshot, in USD. | number |
| taker_pnl_usd | (Only applicable after trade is closed) The total profit and loss of the trade on the taker's side, in USD. | number |
| trade_action | The action of trade being recorded in this entry (ie, OPEN, CLOSE, INCREASE, DECREASE, LIQUIDATED). | string |
| trade_type | The type of the trade being recorded in this entry (ie, LONG, SHORT). | string |
| open_fee_rate | The open fee applied to to the taker trade, as percentage. | number |
| close_fee_rate | The close fee applied to to the taker trade, as percentage. | number |
| open_fee_usd | The open fee applied to to the taker trade, in USD. | number |
| close_fee_usd | The close fee applied to to the taker trade, in USD. | number |
| liquidation_fee_rate | (If applicable, i.e. PnL<0, 0 otherwise) The liquidation fee applied to to the taker trade, as percentage. | number |
| liquidation_fee_usd | (If applicable, i.e. PnL<0, 0 otherwise) The liquidation fee applied to to the taker trade, in USD. | number |

### Incentive Claim Data

Transactional data on user level incentives claimed data.
Expand Down
Loading
Loading