diff --git a/README.md b/README.md index 9240f18..1a8351a 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,9 @@ Below you will find links to each of the following verticals. - [General](./schemas/general/SCHEMA.md) - [DEX](./schemas/dex/SCHEMA.md) (Decentralized Exchange) - [Lending](./schemas/lending/SCHEMA.md) / MM (Money Market) / CDP (Collateralized Debt Position) -- Perpetuals / Options / Derivatives +- [Derivatives](./schemas/derivatives/schema.json) (Perpetuals / Options) - [Bridges](./schemas/bridge/SCHEMA.md) (Pool-Based, Mint-Based, Intent-Based) - [LSTs](./schemas/lst/SCHEMA.md) (Liquid Staking Tokens) - [Yield Aggregators](./schemas/yield-aggregator/SCHEMA.md) (Leverage, Gambling, RWA, ALM, Liquidity/LP, Index) - [DEX Aggregator](./schemas/dex-aggregator/SCHEMA.md) -- Restaking -- AVS -- LRT (Liquid Restaking Tokens) - [NFT](./schemas/nft/SCHEMA.md) diff --git a/schemas/derivatives/SCHEMA.md b/schemas/derivatives/SCHEMA.md new file mode 100644 index 0000000..b910931 --- /dev/null +++ b/schemas/derivatives/SCHEMA.md @@ -0,0 +1,85 @@ +# Derivatives + +OpenBlock Labs standard schema for derivatives protocols (options and perps). + +## Version: 1.0.0-alpha + +### Pools + +Pools in the protocol (one entry for each token). + +| Property | Description | Type | +|-------------------------|-----------------------------------------------------------|--------| +| chain_id | Standard chain id. | number | +| creation_timestamp | The timestamp of the block the pool was created on. | number | +| creation_block_number | The block number this pool was created on. | number | +| pool_address | The contract address of the pool. | string | +| pool_name | The name of the pool (ie, name() in the smart contract). | string | +| token_index | The index of the token in the smart contract (one row for each token in a pool). | number | +| token_address | The contract address of the token. | string | +| token_symbol | The symbol of the token. | string | + +### LP Snapshot + +Liquidity providers snapshot (one entry for each token in a pool). + +| Property | Description | Type | +|-------------------------|-----------------------------------------------------------|--------| +| timestamp | The timestamp of the snapshot. | number | +| chain_id | Standard chain id. | number | +| pool_address | The address of the pool. | 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 | +| deposit_amount | (Optional, for Order Books) The amount deposited into the pool, decimal normalized. | number | +| deposit_amount_usd | (Optional, for Order Books) The amount deposited, in USD. | number | +| amount_useful | (Optional, for LPs) The amount of tokens supplied that are liquid and usable by users of the protocol, decimal normalized. | number | +| amount_useful_usd | (Optional, for LPs) The amount of liquid tokens supplied in USD. | number | +| liquidated_amount | The amount of tokens liquidated from the LP, decimal normalized. | number | +| liquidated_amount_usd | The amount liquidated, in USD. | number | +| total_fees_usd | (Optional) All fees generated by the LP in the given snapshot in USD. | number | +| 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 | +| chain_id | Standard chain id. | number | +| pool_address | The smart contract address of the pool. | string | +| 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 | + +### Trades + +Trade data, 1 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 | +| maker_address | The address of the maker. | string | +| taker_address | The address of the taker. | string | +| token_address | The address of the token. | string | +| amount | The value that a trader is putting to open a long or short, decimal normalized. | number | +| amount_usd | The trade amount in 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 | +| maker_pnl_usd | (Only applicable on trade close) The total profit and loss of the trade on the maker's side, in USD. | number | +| taker_pnl_usd | (Only applicable on trade close) 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 | + +> Note: This markdown file is auto-generated. diff --git a/schemas/derivatives/schema.json b/schemas/derivatives/schema.json new file mode 100644 index 0000000..92e931d --- /dev/null +++ b/schemas/derivatives/schema.json @@ -0,0 +1,239 @@ +{ + "schema": "Derivatives", + "description": "OpenBlock Labs standard schema for derivatives protocols (options and perps).", + "version": "1.0.0-alpha", + "tables": [ + { + "label": "Pools", + "table_name": "derivatives_pools", + "aggregation": "none", + "description": "Pools in the protocol (one entry for each token).", + "properties": { + "chain_id": { + "description": "Standard chain id.", + "type": "number" + }, + "creation_timestamp": { + "description": "The timestamp of the block the pool was created on.", + "type": "number" + }, + "creation_block_number": { + "description": "The block number this pool was created on.", + "type": "number" + }, + "pool_address": { + "description": "The contract address of the pool.", + "type": "string" + }, + "pool_name": { + "description": "The name of the pool (ie, name() in the smart contract).", + "type": "string" + }, + "token_index": { + "description": "The index of the token in the smart contract (one row for each token in a pool).", + "type": "number" + }, + "token_address": { + "description": "The contract address of the token.", + "type": "string" + }, + "token_symbol": { + "description": "The symbol of the token.", + "type": "string" + } + } + }, + { + "label": "LP Snapshot", + "table_name": "lp_snapshot", + "aggregation": "none", + "description": "Liquidity providers snapshot (one entry for each token in a pool).", + "properties": { + "timestamp": { + "description": "The timestamp of the snapshot.", + "type": "number" + }, + "chain_id": { + "description": "Standard chain id.", + "type": "number" + }, + "pool_address": { + "description": "The address of the pool.", + "type": "string" + }, + "lp_address": { + "description": "The address of the liquidity provider.", + "type": "string" + }, + "token_index": { + "description": "The index of the token in the smart contract.", + "type": "number" + }, + "token_address": { + "description": "The address of the token provided as liquidity.", + "type": "string" + }, + "token_symbol": { + "description": "The symbol of the token.", + "type": "string" + }, + "deposit_amount": { + "description": "(Optional, for Order Books) The amount deposited into the pool, decimal normalized.", + "type": "number" + }, + "deposit_amount_usd": { + "description": "(Optional, for Order Books) The amount deposited, in USD.", + "type": "number" + }, + "amount_useful": { + "description": "(Optional, for LPs) The amount of tokens supplied that are liquid and usable by users of the protocol, decimal normalized.", + "type": "number" + }, + "amount_useful_usd": { + "description": "(Optional, for LPs) The amount of liquid tokens supplied in USD.", + "type": "number" + }, + "liquidated_amount": { + "description": "The amount of tokens liquidated from the LP, decimal normalized.", + "type": "number" + }, + "liquidated_amount_usd": { + "description": "The amount liquidated, in USD.", + "type": "number" + }, + "total_fees_usd": { + "description": "(Optional) All fees generated by the LP in the given snapshot in USD.", + "type": "number" + }, + "user_fees_usd": { + "description": "(Optional) The portion of fees accrued to users of the protocol, in USD.", + "type": "number" + }, + "protocol_fees_usd": { + "description": "(Optional) The portion of fees accrued to the protocol, in USD.", + "type": "number" + } + } + }, + { + "label": "Pool Snapshot", + "table_name": "pool_snapshot", + "aggregation": "none", + "description": "Snapshot of the pool's metrics.", + "properties": { + "timestamp": { + "description": "The timestamp of the snapshot.", + "type": "number" + }, + "chain_id": { + "description": "Standard chain id.", + "type": "number" + }, + "pool_address": { + "description": "The smart contract address of the pool.", + "type": "string" + }, + "funding_rate": { + "description": "The funding rate in this pool at the time of the snapshot, as a percentage.", + "type": "number" + }, + "fee_rate": { + "description": "he pool's fee rate, as a percentage.", + "type": "number" + }, + "total_value_locked_usd": { + "description": "The total value locked in USD.", + "type": "number" + }, + "volume_usd": { + "description": "The volume of positions opened and closed in the given snapshot in USD.", + "type": "number" + }, + "open_interest_longs_usd": { + "description": "The sum of open interest of longs held within this pool in USD.", + "type": "number" + }, + "open_interest_shorts_usd": { + "description": "The sum of open interest in shorts held within this pool in USD.", + "type": "number" + } + } + }, + { + "label": "Trades", + "table_name": "trades", + "aggregation": "none", + "description": "Trade data, 1 entry for each close, open, or update of a trade.", + "properties": { + "timestamp": { + "description": "The timestamp of the trade.", + "type": "number" + }, + "chain_id": { + "description": "Standard chain id.", + "type": "number" + }, + "transaction_hash": { + "description": "The hash of the transaction this trade was performed in.", + "type": "string" + }, + "log_index": { + "description": "Event log index.", + "type": "number" + }, + "block_number": { + "description": "The block number of the trade.", + "type": "number" + }, + "pool_address": { + "description": "The address of the pool this token was traded in.", + "type": "string" + }, + "maker_address": { + "description": "The address of the maker.", + "type": "string" + }, + "taker_address": { + "description": "The address of the taker.", + "type": "string" + }, + "token_address": { + "description": "The address of the token.", + "type": "string" + }, + "amount": { + "description": "The value that a trader is putting to open a long or short, decimal normalized.", + "type": "number" + }, + "amount_usd": { + "description": "The trade amount in USD.", + "type": "number" + }, + "notional_value": { + "description": "The value of the leveraged amount of the trade, decimal normalized.", + "type": "number" + }, + "notional_value_usd": { + "description": "The notional value, in USD.", + "type": "number" + }, + "maker_pnl_usd": { + "description": "(Only applicable on trade close) The total profit and loss of the trade on the maker's side, in USD.", + "type": "number" + }, + "taker_pnl_usd": { + "description": "(Only applicable on trade close) The total profit and loss of the trade on the taker's side, in USD.", + "type": "number" + }, + "trade_action": { + "description": "The action of trade being recorded in this entry (ie, OPEN, CLOSE, INCREASE, DECREASE, LIQUIDATED).", + "type": "string" + }, + "trade_type": { + "description": "The type of the trade being recorded in this entry (ie, LONG, SHORT).", + "type": "string" + } + } + } + ] +}