Skip to content

Commit

Permalink
add trades and rearrange
Browse files Browse the repository at this point in the history
  • Loading branch information
0xroll committed Dec 20, 2024
1 parent f7bfa5b commit 6448891
Show file tree
Hide file tree
Showing 2 changed files with 291 additions and 160 deletions.
112 changes: 71 additions & 41 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,47 +66,6 @@ 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 |

### Pool Snapshot

Snapshot of the pool'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 |
| pool_address | The smart contract address of the pool. | string |
| token_index | The index of the token in the smart contract (one row for each token in a pool). | number |
| funding_rate | The funding rate in this pool at the time of the snapshot, as a percentage. | number |
| fee_rate | he pool's fee rate, as a percentage. | number |
| total_value_locked_usd | The total value locked in USD. | number |
| volume_usd | The volume of positions opened and closed in the given snapshot in USD. | number |
| 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 |

### 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 (AMM)

Liquidity providers snapshot (one entry for each token in a vault).
Expand All @@ -104,6 +86,24 @@ Liquidity providers snapshot (one entry for each token in a vault).
| 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.

| 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 |
| pool_address | The smart contract address of the pool. | string |
| token_index | The index of the token in the smart contract (one row for each token in a pool). | number |
| funding_rate | The funding rate in this pool at the time of the snapshot, as a percentage. | number |
| fee_rate | he pool's fee rate, as a percentage. | number |
| total_value_locked_usd | The total value locked in USD. | number |
| volume_usd | The volume of positions opened and closed in the given snapshot in USD. | number |
| 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.
Expand Down Expand Up @@ -148,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

0 comments on commit 6448891

Please sign in to comment.