mirror of
https://github.com/FlipsideCrypto/sei-models.git
synced 2026-02-06 15:21:52 +00:00
remove vertex models, docs and macros (#115)
This commit is contained in:
parent
8094147174
commit
7a68d0cbfb
@ -1,65 +0,0 @@
|
||||
{% test vertex_missing_products(
|
||||
model,
|
||||
filter) %}
|
||||
|
||||
with recent_records as (
|
||||
select
|
||||
*
|
||||
from
|
||||
{{ model }}
|
||||
where
|
||||
modified_timestamp >= SYSDATE() - INTERVAL '7 days'
|
||||
{% if model.name == 'vertex_market_stats' %}
|
||||
AND product_type = 'perp' AND product_id <> 0 AND BASE_VOLUME_24H > 0
|
||||
{% endif %}
|
||||
),
|
||||
|
||||
invalid_product_ids as (
|
||||
select distinct product_id
|
||||
from {{ ref('silver__vertex_dim_products') }}
|
||||
where product_id not in (select product_id from recent_records)
|
||||
AND block_timestamp < sysdate() - INTERVAL '2 days'
|
||||
{% if filter %}
|
||||
AND {{ filter }}
|
||||
{% endif %}
|
||||
{% if model.name == 'vertex_market_stats' %} --stops from test erroring right after deployment
|
||||
AND product_id in (
|
||||
select product_id
|
||||
from (
|
||||
select product_id,
|
||||
min(hour) as min_hour
|
||||
from {{model}}
|
||||
group by 1
|
||||
having min_hour <= SYSDATE() - INTERVAL '2 days'
|
||||
)
|
||||
)
|
||||
{% endif %}
|
||||
)
|
||||
select *
|
||||
from invalid_product_ids
|
||||
|
||||
{% endtest %}
|
||||
|
||||
{% test vertex_product_level_recency(
|
||||
model,
|
||||
filter) %}
|
||||
|
||||
with recent_records as (
|
||||
select distinct(product_id) from {{model}}
|
||||
where block_timestamp >= SYSDATE() - INTERVAL '7 days'
|
||||
),
|
||||
|
||||
invalid_product_ids as (
|
||||
select *
|
||||
from {{ ref('silver__vertex_dim_products') }}
|
||||
where product_id not in (select product_id from recent_records)
|
||||
AND block_timestamp < sysdate() - INTERVAL '2 days'
|
||||
{% if filter %}
|
||||
AND {{ filter }}
|
||||
{% endif %}
|
||||
)
|
||||
|
||||
select *
|
||||
from invalid_product_ids
|
||||
|
||||
{% endtest %}
|
||||
@ -72,20 +72,6 @@ There is more information on how to use dbt docs in the last section of this doc
|
||||
- [ez_native_transfers](#!/model/model.sei_models.core_evm__ez_native_transfers)
|
||||
- [ez_decoded_event_logs](#!/model/model.sei_models.core_evm__ez_decoded_event_logs)
|
||||
|
||||
### Flipside Partner Tables (sei.partner_name)
|
||||
|
||||
**Vertex Tables:**
|
||||
- [dim_products](#!/model/model.sei_models.vertex__dim_products)
|
||||
- [ez_clearing_house_events](#!/model/model.sei_models.vertex__ez_clearing_house_events)
|
||||
- [ez_liquidations](#!/model/model.sei_models.vertex__ez_liquidations)
|
||||
- [ez_perp_trades](#!/model/model.sei_models.vertex__ez_perp_trades)
|
||||
- [ez_spot_trades](#!/model/model.sei_models.vertex__ez_spot_trades)
|
||||
- [ez_account_stats](#!/model/model.sei_models.vertex__ez_account_stats)
|
||||
- [ez_edge_trades](#!/model/model.sei_models.vertex__ez_edge_trades)
|
||||
- [ez_market_depth_stats](#!/model/model.sei_models.vertex__ez_market_depth_stats)
|
||||
- [ez_market_stats](#!/model/model.sei_models.vertex__ez_market_stats)
|
||||
- [ez_money_markets](#!/model/model.sei_models.vertex__ez_money_markets)
|
||||
|
||||
## **Data Model Overview**
|
||||
|
||||
The SEI
|
||||
|
||||
@ -1,550 +0,0 @@
|
||||
{% docs vertex_symbol %}
|
||||
|
||||
The specific Vertex product symbol, if it is a futures product it will have a -PERP suffix.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_digest %}
|
||||
|
||||
The identifier for a specific trade, this can be split across two or more base deltas in order to fill the entire amount of the trade.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_trader %}
|
||||
|
||||
The wallet address of the trader, there can be multiple subaccounts associated with a trader.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_subaccount %}
|
||||
|
||||
Independent Vertex account of trader with its own margin, balance, positions, and trades. Any wallet can open an arbitrary number of these. Risk is not carried over from subaccount to subaccount.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_trade_type %}
|
||||
|
||||
They type of trade taken, long/short for perps or buy/sell for spot.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_expiration %}
|
||||
|
||||
Time after which the order should automatically be cancelled, as a timestamp in seconds after the unix epoch, converted to datetime.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_order_type %}
|
||||
|
||||
Decode from raw expiration number to binary then converted back to int from the most significant two bits:
|
||||
Value: 0
|
||||
Description: Default order, where it will attempt to take from the book and then become a resting limit order if there is quantity remaining
|
||||
|
||||
Value: 1
|
||||
Description: Immediate-or-cancel order, which is the same as a default order except it doesn’t become a resting limit order
|
||||
|
||||
Value: 2
|
||||
Description: Fill-or-kill order, which is the same as an IOC order except either the entire order has to be filled or none of it
|
||||
|
||||
Value: 3
|
||||
Description: Post-only order, where the order is not allowed to take from the book. An error is returned if the order would cross the bid ask spread
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_market_reduce_flag %}
|
||||
|
||||
A reduce-only is an order that will either close or reduce your position. The reduce-only flag can only be set on IOC or FOK order types. Send a reduce-only order by setting the 3rd most significant bit on the expiration field.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_nonce %}
|
||||
|
||||
Number used to differentiate between the same order multiple times, and a user trying to place an order with the same parameters twice. Represented as a string.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_is_taker %}
|
||||
|
||||
Boolean representing if the trader was the taker or maker.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_price_amount_unadj %}
|
||||
|
||||
The price amount that the trade was executed at.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_price_amount %}
|
||||
|
||||
The price amount that the trade was executed at, decimal adjusted. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_amount_unadj %}
|
||||
|
||||
The total size of the trade in units of the asset being traded.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_amount %}
|
||||
|
||||
The total size of the trade in units of the asset being traded across one digest, decimal adjusted. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_amount_usd %}
|
||||
|
||||
The size of the trade in USD. Base Delta multiplied by the price amount.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_fee_amount_unadj %}
|
||||
|
||||
The fees on the trade.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_fee_amount %}
|
||||
|
||||
The fees on the trade, decimal adjusted. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_base_delta_amount_unadj %}
|
||||
|
||||
Represents the net change in the total quantity of orders at a particular price level, the sum of these across the same digest is equal to the amount. This is the first currency listed in the pair and acts as the reference point for the exchange rate, in this case the crypto asset trading against USDC.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_base_delta_amount %}
|
||||
|
||||
Represents the net change in the total quantity of orders at a particular price level, decimal adjusted. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract. The sum of these across the same digest is equal to the amount. This is the first currency listed in the pair and acts as the reference point for the exchange rate, in this case the crypto asset trading against USDC.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_quote_delta_amount_unadj %}
|
||||
|
||||
A positive value is an increase in spread and a negative value is a decrease in spread. Quote is currency used to express the value of the base currency. It's often the more well-known or stable currency in the pair. In this case, USDC.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_quote_delta_amount %}
|
||||
|
||||
The net change in the best bid and best ask prices in the order book, decimal adjusted. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract. A positive value is an increase in spread and a negative value is a decrease in spread. Quote is currency used to express the value of the base currency. It's often the more well-known or stable currency in the pair. In this case, USDC.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_mode %}
|
||||
|
||||
The type of liquidation, 0 being a LP position, 1 being a balance - ie a Borrow, and 2 being a perp position.
|
||||
|
||||
Only available in Vertex V1, live until March 8th 2024.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_health_group %}
|
||||
|
||||
The spot / perp product pair of health group i where health_groups[i][0] is the spot product_id and health_groups[i][1] is the perp product_id. Additionally, it is possible for a health group to only have either a spot or perp product, in which case, the product that doesn’t exist is set to 0.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_health_group_symbol %}
|
||||
|
||||
The token symbol represented by the specific health group. For example WBTC and BTC-PERP is BTC.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_amount_quote_unadj %}
|
||||
|
||||
To liquidate a position, there must be a payment (transfer) between the liquidator and the position holder. This done in the quote currency, USDC. Payments are signed as positive, meaning you received the USDC, or negative, meaning you paid. For perpetual liquidations, users should expect to see a (+) USDC payment. They will see a (-) USDC payment for borrowers since they need to pay the user for buying their borrow.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_amount_quote %}
|
||||
|
||||
To liquidate a position, there must be a payment (transfer) between the liquidator and the position holder. This done in the quote currency, USDC. Payments are signed as positive, meaning you received the USDC, or negative, meaning you paid. For perpetual liquidations, users should expect to see a (+) USDC payment. They will see a (-) USDC payment for borrowers since they need to pay the user for buying their borrow. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_insurance_cover_unadj %}
|
||||
|
||||
USDC from the insurance fund pulled into the insolvent account and used to pay liquidators to take on the underwater positions.
|
||||
|
||||
Only available in Vertex V1, live until March 8th 2024.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_insurance_cover %}
|
||||
|
||||
USDC from the insurance fund pulled into the insolvent account and used to pay liquidators to take on the underwater positions, decimal adjusted. All amounts and prices are adjusted 18 decimals points regardless of underlying asset contract.
|
||||
|
||||
Only available in Vertex V1, live until March 8th 2024.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_book_address %}
|
||||
|
||||
The contract address associated with each product, this is where all fill orders are published to the chain.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_product_type %}
|
||||
|
||||
The type of product, either spot or perpetual futures.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_product_id %}
|
||||
|
||||
The unique id of each product. Evens are perp products and odds are spot products.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_ticker_id %}
|
||||
|
||||
Identifier of a ticker with delimiter to separate base/target.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_name %}
|
||||
|
||||
The name of the product
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_version %}
|
||||
|
||||
The version of Vertex with version 2 on or after March 8th 2024.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_token_address %}
|
||||
|
||||
The underlying asset token address deposited or withdrawn from the clearinghouse contract.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_amount_usd_ch %}
|
||||
|
||||
The size of deposit or withdraw in USD.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_product_id_liq %}
|
||||
|
||||
The product to liquidate as well as the liquidation mode:
|
||||
Perp Liquidation: Any valid perp product_id with is_encode_spread set to false.
|
||||
Spot Liquidation: Any valid spot product_id with is_encode_spread set to false.
|
||||
Spread Liquidation: If there are perp and spot positions in different directions, liquidate both at the same time. is_encode_spread must be set to true.
|
||||
|
||||
If it is a spread liquidation this column will show the perp product_id, for both ids refer to the spread_product_ids array.
|
||||
|
||||
Only available in V2 Vertex liquidations, which went live March 8th 2024.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_is_encode_spread %}
|
||||
|
||||
Indicates whether product_id encodes both a spot and perp product_id for spread_liquidation.
|
||||
|
||||
Only available in V2 Vertex liquidations, which went live March 8th 2024.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_decoded_spread_product_ids %}
|
||||
|
||||
Array of product_ids that have been decoded from binary. Only available when is_encode_spread is true and the liquidation occurs on V2 Vertex, which went live March 8th 2024.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_first_trade_timestamp %}
|
||||
|
||||
The block timestamp of this subaccounts first trade.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_last_trade_timestamp %}
|
||||
|
||||
The block timestamp of this subaccounts most recent trade.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_account_age %}
|
||||
|
||||
The age of the account in days.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_trade_count %}
|
||||
|
||||
The total amount of trades executed by the account
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_trade_count_rank %}
|
||||
|
||||
The rank against all accounts based on trade count volume.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_trade_count_24h %}
|
||||
|
||||
The total amount of trades made in the last 24 hours.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_trade_count_rank_24h %}
|
||||
|
||||
The rank against all accounts based on trade count volume in the last 24 hours.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_perp_trade_count %}
|
||||
|
||||
The total amount of perpetual trades executed by the account
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_spot_trade_count %}
|
||||
|
||||
The total amount of spot trades executed by the account
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_long_count %}
|
||||
|
||||
The total amount of buys/longs on the account.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_short_count %}
|
||||
|
||||
The total amount of sell/shorts on the account.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_total_usd_volume %}
|
||||
|
||||
The total USD denominated volume of the account.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_total_usd_volume_24h %}
|
||||
|
||||
The total USD denominated volume of the account in the last 24 hours.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_total_usd_volume_rank_24h %}
|
||||
|
||||
The rank against all accounts based on the total USD denominated volume of the account in the last 24 hours.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_total_usd_volume_rank %}
|
||||
|
||||
The rank against all accounts based on total usd volume on the account.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_avg_usd_trade_size %}
|
||||
|
||||
The average trade size in USD.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_total_fee_amount %}
|
||||
|
||||
The total amount of trading fees paid by the account.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_total_base_delta_amount %}
|
||||
|
||||
The total base delta amount of the account.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_total_quote_delta_amount %}
|
||||
|
||||
The total quote delta amount of the account.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_total_liquidation_amount %}
|
||||
|
||||
The total liquidation amount of the account.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_total_liquidation_count %}
|
||||
|
||||
The total count of liquidation accounts on the account.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_orderbook_side %}
|
||||
|
||||
Designates the bid or ask side of the orderbook price.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_orderbook_volume %}
|
||||
|
||||
The quantity for each bid/ask order at the given price level.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_orderbook_price %}
|
||||
|
||||
The price level for each bid/ask order.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_orderbook_round_price_0_01 %}
|
||||
|
||||
The price level for each bid/ask order, rounded to nearest cent.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_orderbook_round_price_0_1 %}
|
||||
|
||||
The price level for each bid/ask order, rounded to nearest ten cents.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_orderbook_round_price_1 %}
|
||||
|
||||
The price level for each bid/ask order, rounded to nearest dollar.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_orderbook_round_price_10 %}
|
||||
|
||||
The price level for each bid/ask order, rounded to nearest 10 dollars.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_orderbook_round_price_100 %}
|
||||
|
||||
The price level for each bid/ask order, rounded to nearest 100 dollars.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_hour %}
|
||||
|
||||
The hour in which the stats table data was pull and inserted into the table.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_distinct_sequencer_batches %}
|
||||
|
||||
The amount of sequencer transactions that included this product in the last hour.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_trader_count %}
|
||||
|
||||
The distinct traders in the last hour, based on a distinct count of wallet addresses.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_subaccount_count %}
|
||||
|
||||
The distinct traders in the last hour, based on a distinct count of subaccount.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_total_trade_count %}
|
||||
|
||||
The total number of trades on Vertex in the last hour.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_contract_price %}
|
||||
|
||||
The price of the contract when the data was inserted into the table.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_base_volume_24h %}
|
||||
|
||||
The 24 hour trading volume for the pair (unit in base).
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_quote_volume_24h %}
|
||||
|
||||
The 24 hour trading volume for the pair (unit in quote).
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_funding_rate %}
|
||||
|
||||
Current 24hr funding rate. Can compute hourly funding rate dividing by 24.
|
||||
|
||||
A funding rate is a mechanism used to ensure that the price of a perp contract tracks the underlying asset's price as closely as possible.
|
||||
|
||||
Positive funding rates reflect the perpetual trading at a premium to the underlying asset’s price.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_index_price %}
|
||||
|
||||
Last calculated index price for underlying of contract.
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_last_price %}
|
||||
|
||||
Last transacted price of base currency based on given quote currency.
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs vertex_mark_price %}
|
||||
|
||||
The calculated fair value of the contract, independent of the last traded price on the specific exchange.
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_next_funding_rate %}
|
||||
|
||||
Timestamp of the next funding rate change, specific to hour the data was pulled from the API.
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_open_interest %}
|
||||
|
||||
The open interest of the contract for the hour that the data was pulled. Open interest (OI) refers to the total number of outstanding derivative contracts (e.g., futures or options) that are currently held by market participants and have not yet been settled
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_open_interest_usd %}
|
||||
|
||||
The open interest of the contract for the hour that the data was pulled, denominated in USD. Open interest (OI) refers to the total number of outstanding derivative contracts (e.g., futures or options) that are currently held by market participants and have not yet been settled
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_quote_currency %}
|
||||
|
||||
Symbol of the target asset.
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_stake_action %}
|
||||
|
||||
The staking action with the VRTX staking address
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_deposit_apr %}
|
||||
|
||||
The recorded deposit APR for the money market product in that hour.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_borrow_apr %}
|
||||
|
||||
The recorded borrow APR for the money market product in that hour.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_tvl %}
|
||||
|
||||
The sum total value locked for the money market product in that hour.
|
||||
|
||||
{% enddocs %}
|
||||
@ -1,69 +0,0 @@
|
||||
{% docs vertex_dim_products %}
|
||||
|
||||
All available Vertex products, these are automatically added as they are released on chain.
|
||||
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_ez_liquidations %}
|
||||
|
||||
All Vertex liquidations. Once an account’s maintenance margin reaches $0, the account is eligible for liquidation. Liquidation events happen one by one, with the riskiest positions being liquidated first. Liquidations are based on the oracle price.
|
||||
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_ez_perp_trades %}
|
||||
|
||||
Vertex perpetuals are derivative contracts on an underlying spot asset. On Vertex, all perpetual contracts trade against USDC.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_ez_spot_trades %}
|
||||
|
||||
Vertex’s spot markets allow you to buy or sell listed crypto assets paired with USD-denominated stablecoins.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_ez_clearing_house_events %}
|
||||
|
||||
Vertex’s on-chain clearinghouse operates as the hub combining perpetual and spot markets, collateral, and risk calculations into a single integrated system. The events in this table track when a wallet either deposits or withdraws from the clearinghouse contract.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_ez_account_stats %}
|
||||
|
||||
Subaccount level table showing aggregated total activity across the Vertex exchange.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_ez_market_stats %}
|
||||
|
||||
Orderbook level market stats based on a combination of on-chain data and data from Vertex's ticker V2 API which includes 24-hour pricing and volume information on each market pair available on Vertex.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_ez_market_depth %}
|
||||
|
||||
Liquidity data taken from Vertex's Orderbook API, showing amount of liquidity at each price level.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_ez_staking %}
|
||||
|
||||
All staking actions taken with the VRTX staking contract.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
{% docs vertex_ez_edge_trades %}
|
||||
|
||||
All edge trades paired with the associated trader/subaccount.
|
||||
|
||||
{% enddocs %}
|
||||
|
||||
|
||||
{% docs vertex_money_markets %}
|
||||
|
||||
Vertex integrates a decentralized money market directly into its DEX, enabling borrowing and lending of crypto assets using overcollateralized lending rules. Interest rates are dynamically adjusted based on supply and demand, incentivizing liquidity provision and balancing borrowing costs. The money market operates on-chain (e.g., on Arbitrum) and is managed through Vertex’s risk engine and clearinghouse, offering users automated borrowing via portfolio margin and passive yield opportunities on idle assets. This table tracks the money market products available on Vertex on an hourly basis.
|
||||
|
||||
|
||||
{% enddocs %}
|
||||
@ -1,29 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'VERTEX',
|
||||
'PURPOSE': 'CLOB, DEX, PRODUCTS'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
product_id,
|
||||
product_type,
|
||||
ticker_id,
|
||||
symbol,
|
||||
name,
|
||||
vertex_products_id AS dim_products_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__vertex_dim_products') }}
|
||||
ORDER BY product_id
|
||||
@ -1,28 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: vertex__dim_products
|
||||
description: '{{ doc("vertex_dim_products") }}'
|
||||
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
description: '{{ doc("sei_block_number") }}'
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: '{{ doc("sei_block_timestamp") }}'
|
||||
- name: TX_HASH
|
||||
description: '{{ doc("sei_logs_tx_hash") }}'
|
||||
- name: PRODUCT_ID
|
||||
description: '{{ doc("vertex_product_id") }}'
|
||||
- name: PRODUCT_TYPE
|
||||
description: '{{ doc("vertex_product_type") }}'
|
||||
- name: TICKER_ID
|
||||
description: '{{ doc("vertex_ticker_id") }}'
|
||||
- name: SYMBOL
|
||||
description: '{{ doc("vertex_symbol") }}'
|
||||
- name: NAME
|
||||
description: '{{ doc("vertex_name") }}'
|
||||
- name: DIM_PRODUCTS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
@ -1,57 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta ={
|
||||
'database_tags':{
|
||||
'table':{
|
||||
'PROTOCOL': 'VERTEX',
|
||||
'PURPOSE': 'CLOB, DEX, STATS'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
subaccount,
|
||||
trader,
|
||||
first_trade_timestamp,
|
||||
last_trade_timestamp,
|
||||
account_age,
|
||||
trade_count,
|
||||
DENSE_RANK() over (
|
||||
ORDER BY
|
||||
trade_count DESC
|
||||
) AS trade_count_rank,
|
||||
trade_count_24h,
|
||||
DENSE_RANK() over (
|
||||
ORDER BY
|
||||
trade_count_24h DESC
|
||||
) AS trade_count_rank_24h,
|
||||
perp_trade_count,
|
||||
spot_trade_count,
|
||||
long_count,
|
||||
short_count,
|
||||
total_usd_volume,
|
||||
DENSE_RANK() over (
|
||||
ORDER BY
|
||||
total_usd_volume DESC
|
||||
) AS total_usd_volume_rank,
|
||||
total_usd_volume_24h,
|
||||
DENSE_RANK() over (
|
||||
ORDER BY
|
||||
total_usd_volume_24h DESC
|
||||
) AS total_usd_volume_rank_24h,
|
||||
avg_usd_trade_size,
|
||||
total_fee_amount,
|
||||
total_base_delta_amount,
|
||||
total_quote_delta_amount,
|
||||
total_liquidation_amount,
|
||||
total_liquidation_amount_quote,
|
||||
total_liquidation_count,
|
||||
vertex_account_id as ez_account_stats_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__vertex_account_stats') }}
|
||||
ORDER BY total_usd_volume_rank DESC
|
||||
@ -1,60 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: vertex__ez_account_stats
|
||||
description: '{{ doc("vertex_ez_account_stats") }}'
|
||||
|
||||
columns:
|
||||
- name: SUBACCOUNT
|
||||
description: '{{ doc("vertex_subaccount") }}'
|
||||
- name: TRADER
|
||||
description: '{{ doc("vertex_trader") }}'
|
||||
- name: FIRST_TRADE_TIMESTAMP
|
||||
description: '{{ doc("vertex_first_trade_timestamp") }}'
|
||||
- name: LAST_TRADE_TIMESTAMP
|
||||
description: '{{ doc("vertex_last_trade_timestamp") }}'
|
||||
- name: ACCOUNT_AGE
|
||||
description: '{{ doc("vertex_account_age") }}'
|
||||
- name: TRADE_COUNT
|
||||
description: '{{ doc("vertex_trade_count") }}'
|
||||
- name: TRADE_COUNT_RANK
|
||||
description: '{{ doc("vertex_trade_count_rank") }}'
|
||||
- name: TRADE_COUNT_24H
|
||||
description: '{{ doc("vertex_trade_count_24h") }}'
|
||||
- name: TRADE_COUNT_RANK_24H
|
||||
description: '{{ doc("vertex_trade_count_rank_24h") }}'
|
||||
- name: PERP_TRADE_COUNT
|
||||
description: '{{ doc("vertex_perp_trade_count") }}'
|
||||
- name: SPOT_TRADE_COUNT
|
||||
description: '{{ doc("vertex_spot_trade_count") }}'
|
||||
- name: LONG_COUNT
|
||||
description: '{{ doc("vertex_long_count") }}'
|
||||
- name: SHORT_COUNT
|
||||
description: '{{ doc("vertex_short_count") }}'
|
||||
- name: TOTAL_USD_VOLUME
|
||||
description: '{{ doc("vertex_total_usd_volume") }}'
|
||||
- name: TOTAL_USD_VOLUME_RANK
|
||||
description: '{{ doc("vertex_total_usd_volume_rank") }}'
|
||||
- name: TOTAL_USD_VOLUME_24H
|
||||
description: '{{ doc("vertex_total_usd_volume_24h") }}'
|
||||
- name: TOTAL_USD_VOLUME_RANK_24H
|
||||
description: '{{ doc("vertex_total_usd_volume_rank_24h") }}'
|
||||
- name: AVG_USD_TRADE_SIZE
|
||||
description: '{{ doc("vertex_avg_usd_trade_size") }}'
|
||||
- name: TOTAL_FEE_AMOUNT
|
||||
description: '{{ doc("vertex_total_fee_amount") }}'
|
||||
- name: TOTAL_BASE_DELTA_AMOUNT
|
||||
description: '{{ doc("vertex_total_base_delta_amount") }}'
|
||||
- name: TOTAL_QUOTE_DELTA_AMOUNT
|
||||
description: '{{ doc("vertex_total_quote_delta_amount") }}'
|
||||
- name: TOTAL_LIQUIDATION_AMOUNT
|
||||
description: '{{ doc("vertex_total_liquidation_amount") }}'
|
||||
- name: TOTAL_LIQUIDATION_AMOUNT_QUOTE
|
||||
description: '{{ doc("vertex_amount_quote_unadj") }}'
|
||||
- name: TOTAL_LIQUIDATION_COUNT
|
||||
description: '{{ doc("vertex_total_liquidation_count") }}'
|
||||
- name: EZ_ACCOUNT_STATS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
@ -1,37 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'VERTEX',
|
||||
'PURPOSE': 'CLOB, DEX, CLEARINGHOUSE'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
contract_address,
|
||||
event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
modification_type,
|
||||
symbol,
|
||||
trader,
|
||||
subaccount,
|
||||
token_address,
|
||||
amount_unadj,
|
||||
amount,
|
||||
amount_usd,
|
||||
vertex_collateral_id AS ez_clearing_house_events_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__vertex_collateral') }}
|
||||
@ -1,46 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: vertex__ez_clearing_house_events
|
||||
description: '{{ doc("vertex_ez_clearing_house_events") }}'
|
||||
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
description: '{{ doc("sei_block_number") }}'
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: '{{ doc("sei_block_timestamp") }}'
|
||||
- name: TX_HASH
|
||||
description: '{{ doc("sei_logs_tx_hash") }}'
|
||||
- name: CONTRACT_ADDRESS
|
||||
description: '{{ doc("sei_logs_contract_address") }}'
|
||||
- name: EVENT_NAME
|
||||
description: '{{ doc("sei_event_name") }}'
|
||||
- name: EVENT_INDEX
|
||||
description: '{{ doc("sei_event_index") }}'
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
description: '{{ doc("sei_origin_sig") }}'
|
||||
- name: ORIGIN_FROM_ADDRESS
|
||||
description: '{{ doc("sei_origin_from") }}'
|
||||
- name: ORIGIN_TO_ADDRESS
|
||||
description: '{{ doc("sei_origin_to") }}'
|
||||
- name: SYMBOL
|
||||
description: '{{ doc("vertex_symbol") }}'
|
||||
- name: DIGEST
|
||||
description: '{{ doc("vertex_digest") }}'
|
||||
- name: TRADER
|
||||
description: '{{ doc("vertex_trader") }}'
|
||||
- name: SUBACCOUNT
|
||||
description: '{{ doc("vertex_subaccount") }}'
|
||||
- name: TOKEN_ADDRESS
|
||||
description: '{{ doc("vertex_token_address") }}'
|
||||
- name: AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_amount_unadj") }}'
|
||||
- name: AMOUNT
|
||||
description: '{{ doc("vertex_amount") }}'
|
||||
- name: AMOUNT_USD
|
||||
description: '{{ doc("vertex_amount_usd_ch") }}'
|
||||
- name: EZ_CLEARING_HOUSE_EVENTS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
@ -1,58 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'VERTEX',
|
||||
'PURPOSE': 'CLOB, DEX'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
edge_event_index,
|
||||
user_event_index,
|
||||
edge_digest,
|
||||
user_digest,
|
||||
trader,
|
||||
subaccount,
|
||||
symbol,
|
||||
edge_order_type,
|
||||
user_order_type,
|
||||
edge_trade_type,
|
||||
user_trade_type,
|
||||
edge_is_taker,
|
||||
user_is_taker,
|
||||
edge_price_amount_unadj,
|
||||
user_price_amount_unadj,
|
||||
edge_price_amount,
|
||||
user_price_amount,
|
||||
edge_amount_unadj,
|
||||
user_amount_unadj,
|
||||
edge_amount,
|
||||
user_amount,
|
||||
edge_amount_usd,
|
||||
user_amount_usd,
|
||||
edge_fee_amount_unadj,
|
||||
user_fee_amount_unadj,
|
||||
edge_fee_amount,
|
||||
user_fee_amount,
|
||||
edge_base_delta_amount_unadj,
|
||||
user_base_delta_amount_unadj,
|
||||
edge_base_delta_amount,
|
||||
user_base_delta_amount,
|
||||
edge_quote_delta_amount_unadj,
|
||||
user_quote_delta_amount_unadj,
|
||||
edge_quote_delta_amount,
|
||||
user_quote_delta_amount,
|
||||
vertex_edge_trade_id as ez_edge_trades_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
FROM
|
||||
{{ ref('silver__vertex_edge_trades') }}
|
||||
@ -1,88 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: vertex__ez_edge_trades
|
||||
description: '{{ doc("vertex_ez_edge_trades") }}'
|
||||
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
description: '{{ doc("sei_block_number") }}'
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: '{{ doc("sei_block_timestamp") }}'
|
||||
- name: TX_HASH
|
||||
description: '{{ doc("sei_logs_tx_hash") }}'
|
||||
- name: EDGE_EVENT_INDEX
|
||||
description: '{{ doc("sei_event_index") }}'
|
||||
- name: USER_EVENT_INDEX
|
||||
description: '{{ doc("sei_event_index") }}'
|
||||
- name: EDGE_DIGEST
|
||||
description: '{{ doc("vertex_digest") }}'
|
||||
- name: USER_DIGEST
|
||||
description: '{{ doc("vertex_digest") }}'
|
||||
- name: TRADER
|
||||
description: '{{ doc("vertex_trader") }}'
|
||||
- name: SUBACCOUNT
|
||||
description: '{{ doc("vertex_subaccount") }}'
|
||||
- name: SYMBOL
|
||||
description: '{{ doc("vertex_symbol") }}'
|
||||
- name: EDGE_ORDER_TYPE
|
||||
description: '{{ doc("vertex_order_type") }}'
|
||||
- name: USER_ORDER_TYPE
|
||||
description: '{{ doc("vertex_order_type") }}'
|
||||
- name: EDGE_TRADE_TYPE
|
||||
description: '{{ doc("vertex_trade_type") }}'
|
||||
- name: USER_TRADE_TYPE
|
||||
description: '{{ doc("vertex_trade_type") }}'
|
||||
- name: EDGE_IS_TAKER
|
||||
description: '{{ doc("vertex_is_taker") }}'
|
||||
- name: USER_IS_TAKER
|
||||
description: '{{ doc("vertex_is_taker") }}'
|
||||
- name: EDGE_PRICE_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_price_amount_unadj") }}'
|
||||
- name: USER_PRICE_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_price_amount_unadj") }}'
|
||||
- name: EDGE_PRICE_AMOUNT
|
||||
description: '{{ doc("vertex_price_amount") }}'
|
||||
- name: USER_PRICE_AMOUNT
|
||||
description: '{{ doc("vertex_price_amount") }}'
|
||||
- name: EDGE_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_amount_unadj") }}'
|
||||
- name: USER_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_amount_unadj") }}'
|
||||
- name: EDGE_AMOUNT
|
||||
description: '{{ doc("vertex_amount") }}'
|
||||
- name: USER_AMOUNT
|
||||
description: '{{ doc("vertex_amount") }}'
|
||||
- name: EDGE_AMOUNT_USD
|
||||
description: '{{ doc("vertex_amount_usd") }}'
|
||||
- name: USER_AMOUNT_USD
|
||||
description: '{{ doc("vertex_amount_usd") }}'
|
||||
- name: EDGE_FEE_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_fee_amount_unadj") }}'
|
||||
- name: USER_FEE_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_fee_amount_unadj") }}'
|
||||
- name: EDGE_FEE_AMOUNT
|
||||
description: '{{ doc("vertex_fee_amount") }}'
|
||||
- name: USER_FEE_AMOUNT
|
||||
description: '{{ doc("vertex_fee_amount") }}'
|
||||
- name: EDGE_BASE_DELTA_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_base_delta_amount_unadj") }}'
|
||||
- name: USER_BASE_DELTA_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_base_delta_amount_unadj") }}'
|
||||
- name: EDGE_BASE_DELTA_AMOUNT
|
||||
description: '{{ doc("vertex_base_delta_amount") }}'
|
||||
- name: USER_BASE_DELTA_AMOUNT
|
||||
description: '{{ doc("vertex_base_delta_amount") }}'
|
||||
- name: EDGE_QUOTE_DELTA_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_quote_delta_amount_unadj") }}'
|
||||
- name: USER_QUOTE_DELTA_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_quote_delta_amount_unadj") }}'
|
||||
- name: EDGE_QUOTE_DELTA_AMOUNT
|
||||
description: '{{ doc("vertex_quote_delta_amount") }}'
|
||||
- name: USER_QUOTE_DELTA_AMOUNT
|
||||
description: '{{ doc("vertex_quote_delta_amount") }}'
|
||||
- name: EZ_EDGE_TRADES_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
@ -1,41 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'VERTEX',
|
||||
'PURPOSE': 'CLOB, DEX, LIQUIDATION'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
contract_address,
|
||||
event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
digest,
|
||||
trader,
|
||||
subaccount,
|
||||
product_id,
|
||||
health_group,
|
||||
health_group_symbol,
|
||||
amount_unadj,
|
||||
amount,
|
||||
amount_quote_unadj,
|
||||
amount_quote,
|
||||
is_encoded_spread,
|
||||
spread_product_ids,
|
||||
vertex_liquidation_id AS ez_liquidations_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__vertex_liquidations') }}
|
||||
@ -1,54 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: vertex__ez_liquidations
|
||||
description: '{{ doc("vertex_ez_liquidations") }}'
|
||||
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
description: '{{ doc("sei_block_number") }}'
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: '{{ doc("sei_block_timestamp") }}'
|
||||
- name: TX_HASH
|
||||
description: '{{ doc("sei_logs_tx_hash") }}'
|
||||
- name: CONTRACT_ADDRESS
|
||||
description: '{{ doc("sei_logs_contract_address") }}'
|
||||
- name: EVENT_NAME
|
||||
description: '{{ doc("sei_event_name") }}'
|
||||
- name: EVENT_INDEX
|
||||
description: '{{ doc("sei_event_index") }}'
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
description: '{{ doc("sei_origin_sig") }}'
|
||||
- name: ORIGIN_FROM_ADDRESS
|
||||
description: '{{ doc("sei_origin_from") }}'
|
||||
- name: ORIGIN_TO_ADDRESS
|
||||
description: '{{ doc("sei_origin_to") }}'
|
||||
- name: DIGEST
|
||||
description: '{{ doc("vertex_digest") }}'
|
||||
- name: TRADER
|
||||
description: '{{ doc("vertex_trader") }}'
|
||||
- name: SUBACCOUNT
|
||||
description: '{{ doc("vertex_subaccount") }}'
|
||||
- name: PRODUCT_ID
|
||||
description: '{{ doc("vertex_product_id_liq") }}'
|
||||
- name: HEALTH_GROUP
|
||||
description: '{{ doc("vertex_health_group") }}'
|
||||
- name: HEALTH_GROUP_SYMBOL
|
||||
description: '{{ doc("vertex_health_group_symbol") }}'
|
||||
- name: AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_amount_unadj") }}'
|
||||
- name: AMOUNT
|
||||
description: '{{ doc("vertex_amount") }}'
|
||||
- name: AMOUNT_QUOTE_UNADJ
|
||||
description: '{{ doc("vertex_amount_quote_unadj") }}'
|
||||
- name: AMOUNT_QUOTE
|
||||
description: '{{ doc("vertex_amount_quote") }}'
|
||||
- name: IS_ENCODE_SPREAD
|
||||
description: '{{ doc("vertex_is_encode_spread") }}'
|
||||
- name: SPREAD_PRODUCT_IDS
|
||||
description: '{{ doc("vertex_decoded_spread_product_ids") }}'
|
||||
- name: EZ_LIQUIDATIONS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
@ -1,31 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'VERTEX',
|
||||
'PURPOSE': 'CLOB, DEX, STATS'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
hour,
|
||||
ticker_id,
|
||||
product_id,
|
||||
orderbook_side,
|
||||
volume,
|
||||
price,
|
||||
round_price_0_01,
|
||||
round_price_0_1,
|
||||
round_price_1,
|
||||
round_price_10,
|
||||
round_price_100,
|
||||
vertex_market_depth_id as ez_market_depth_stats_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__vertex_market_depth') }}
|
||||
@ -1,34 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: vertex__ez_market_depth_stats
|
||||
description: '{{ doc("vertex_ez_market_depth") }}'
|
||||
|
||||
columns:
|
||||
- name: HOUR
|
||||
description: '{{ doc("vertex_hour") }}'
|
||||
- name: TICKER_ID
|
||||
description: '{{ doc("vertex_ticker_id") }}'
|
||||
- name: PRODUCT_ID
|
||||
description: '{{ doc("vertex_product_id") }}'
|
||||
- name: ORDERBOOK_SIDE
|
||||
description: '{{ doc("vertex_orderbook_side") }}'
|
||||
- name: VOLUME
|
||||
description: '{{ doc("vertex_orderbook_volume") }}'
|
||||
- name: PRICE
|
||||
description: '{{ doc("vertex_orderbook_price") }}'
|
||||
- name: ROUND_PRICE_0_01
|
||||
description: '{{ doc("vertex_orderbook_round_price_0_01") }}'
|
||||
- name: ROUND_PRICE_0_1
|
||||
description: '{{ doc("vertex_orderbook_round_price_0_1") }}'
|
||||
- name: ROUND_PRICE_1
|
||||
description: '{{ doc("vertex_orderbook_round_price_1") }}'
|
||||
- name: ROUND_PRICE_10
|
||||
description: '{{ doc("vertex_orderbook_round_price_10") }}'
|
||||
- name: ROUND_PRICE_100
|
||||
description: '{{ doc("vertex_orderbook_round_price_100") }}'
|
||||
- name: EZ_MARKET_DEPTH_STATS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
@ -1,45 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'VERTEX',
|
||||
'PURPOSE': 'CLOB, DEX, STATS'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
hour,
|
||||
ticker_id,
|
||||
product_id,
|
||||
symbol,
|
||||
distinct_sequencer_batches,
|
||||
distinct_trader_count,
|
||||
distinct_subaccount_count,
|
||||
trade_count,
|
||||
amount_usd,
|
||||
fee_amount,
|
||||
base_delta_amount,
|
||||
quote_delta_amount,
|
||||
base_volume_24h,
|
||||
quote_volume_24h,
|
||||
funding_rate,
|
||||
index_price,
|
||||
last_price,
|
||||
mark_price,
|
||||
next_funding_rate_timestamp,
|
||||
open_interest,
|
||||
open_interest_usd,
|
||||
price_change_percent_24h,
|
||||
product_type,
|
||||
quote_currency,
|
||||
quote_volume,
|
||||
vertex_market_stats_id as ez_market_stats_id,
|
||||
_inserted_timestamp as inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__vertex_market_stats') }}
|
||||
@ -1,58 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: vertex__ez_market_stats
|
||||
description: '{{ doc("vertex_ez_market_stats") }}'
|
||||
|
||||
columns:
|
||||
- name: HOUR
|
||||
description: '{{ doc("vertex_hour") }}'
|
||||
- name: TICKER_ID
|
||||
description: '{{ doc("vertex_ticker_id") }}'
|
||||
- name: PRODUCT_ID
|
||||
description: '{{ doc("vertex_product_id") }}'
|
||||
- name: SYMBOL
|
||||
description: '{{ doc("vertex_symbol") }}'
|
||||
- name: DISTINCT_SEQUENCER_BATCHES
|
||||
description: '{{ doc("vertex_distinct_sequencer_batches") }}'
|
||||
- name: DISTINCT_TRADER_COUNT
|
||||
description: '{{ doc("vertex_trader_count") }}'
|
||||
- name: DISTINCT_SUBACCOUNT_COUNT
|
||||
description: '{{ doc("vertex_subaccount_count") }}'
|
||||
- name: TRADE_COUNT
|
||||
description: '{{ doc("vertex_total_trade_count") }}'
|
||||
- name: AMOUNT_USD
|
||||
description: '{{ doc("vertex_amount_usd") }}'
|
||||
- name: FEE_AMOUNT
|
||||
description: '{{ doc("vertex_fee_amount") }}'
|
||||
- name: BASE_DELTA_AMOUNT
|
||||
description: '{{ doc("vertex_base_delta_amount") }}'
|
||||
- name: QUOTE_DELTA_AMOUNT
|
||||
description: '{{ doc("vertex_quote_delta_amount") }}'
|
||||
- name: BASE_VOLUME_24H
|
||||
description: '{{ doc("vertex_base_volume_24h") }}'
|
||||
- name: QUOTE_VOLUME_24H
|
||||
description: '{{ doc("vertex_quote_volume_24h") }}'
|
||||
- name: FUNDING_RATE
|
||||
description: '{{ doc("vertex_funding_rate") }}'
|
||||
- name: INDEX_PRICE
|
||||
description: '{{ doc("vertex_index_price") }}'
|
||||
- name: LAST_PRICE
|
||||
description: '{{ doc("vertex_last_price") }}'
|
||||
- name: MARK_PRICE
|
||||
description: '{{ doc("vertex_mark_price") }}'
|
||||
- name: NEXT_FUNDING_RATE_TIMESTAMP
|
||||
description: '{{ doc("vertex_next_funding_rate") }}'
|
||||
- name: OPEN_INTEREST
|
||||
description: '{{ doc("vertex_open_interest") }}'
|
||||
- name: OPEN_INTEREST_USD
|
||||
description: '{{ doc("vertex_open_interest_usd") }}'
|
||||
- name: PRODUCT_TYPE
|
||||
description: '{{ doc("vertex_product_type") }}'
|
||||
- name: QUOTE_CURRENCY
|
||||
description: '{{ doc("vertex_quote_currency") }}'
|
||||
- name: EZ_MARKET_STATS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
@ -1,30 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = 'ez_money_markets_id',
|
||||
merge_exclude_columns = ["inserted_timestamp"],
|
||||
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(ticker_id,product_id,symbol), SUBSTRING(ticker_id,product_id,symbol)",
|
||||
tags = ['curated', 'gold_vertex']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
hour,
|
||||
ticker_id,
|
||||
symbol,
|
||||
product_id,
|
||||
deposit_apr,
|
||||
borrow_apr,
|
||||
tvl,
|
||||
vertex_money_markets_id as ez_money_markets_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__vertex_money_markets') }}
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
modified_timestamp > (
|
||||
SELECT
|
||||
MAX(modified_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
@ -1,26 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: vertex__ez_money_markets
|
||||
description: '{{ doc("vertex_money_markets") }}'
|
||||
|
||||
columns:
|
||||
- name: HOUR
|
||||
description: '{{ doc("vertex_hour") }}'
|
||||
- name: TICKER_ID
|
||||
description: '{{ doc("vertex_ticker_id") }}'
|
||||
- name: SYMBOL
|
||||
description: '{{ doc("vertex_symbol") }}'
|
||||
- name: PRODUCT_ID
|
||||
description: '{{ doc("vertex_product_id") }}'
|
||||
- name: DEPOSIT_APR
|
||||
description: '{{ doc("vertex_deposit_apr") }}'
|
||||
- name: BORROW_APR
|
||||
description: '{{ doc("vertex_borrow_apr") }}'
|
||||
- name: TVL
|
||||
description: '{{ doc("vertex_tvl") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
- name: VERTEX_MONEY_MARKETS_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
@ -1,50 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'VERTEX',
|
||||
'PURPOSE': 'CLOB, DEX, PERPS'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
contract_address,
|
||||
event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
symbol,
|
||||
digest,
|
||||
trader,
|
||||
subaccount,
|
||||
trade_type,
|
||||
order_type,
|
||||
market_reduce_flag,
|
||||
expiration,
|
||||
nonce,
|
||||
is_taker,
|
||||
price_amount_unadj,
|
||||
price_amount,
|
||||
amount_unadj,
|
||||
amount,
|
||||
amount_usd,
|
||||
fee_amount_unadj,
|
||||
fee_amount,
|
||||
base_delta_amount_unadj,
|
||||
base_delta_amount,
|
||||
quote_delta_amount_unadj,
|
||||
quote_delta_amount,
|
||||
vertex_perps_id AS ez_perp_trades_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__vertex_perps') }}
|
||||
@ -1,72 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: vertex__ez_perp_trades
|
||||
description: '{{ doc("vertex_ez_perp_trades") }}'
|
||||
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
description: '{{ doc("sei_block_number") }}'
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: '{{ doc("sei_block_timestamp") }}'
|
||||
- name: TX_HASH
|
||||
description: '{{ doc("sei_logs_tx_hash") }}'
|
||||
- name: CONTRACT_ADDRESS
|
||||
description: '{{ doc("sei_logs_contract_address") }}'
|
||||
- name: EVENT_NAME
|
||||
description: '{{ doc("sei_event_name") }}'
|
||||
- name: EVENT_INDEX
|
||||
description: '{{ doc("sei_event_index") }}'
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
description: '{{ doc("sei_origin_sig") }}'
|
||||
- name: ORIGIN_FROM_ADDRESS
|
||||
description: '{{ doc("sei_origin_from") }}'
|
||||
- name: ORIGIN_TO_ADDRESS
|
||||
description: '{{ doc("sei_origin_to") }}'
|
||||
- name: SYMBOL
|
||||
description: '{{ doc("vertex_symbol") }}'
|
||||
- name: DIGEST
|
||||
description: '{{ doc("vertex_digest") }}'
|
||||
- name: TRADER
|
||||
description: '{{ doc("vertex_trader") }}'
|
||||
- name: SUBACCOUNT
|
||||
description: '{{ doc("vertex_subaccount") }}'
|
||||
- name: TRADE_TYPE
|
||||
description: '{{ doc("vertex_trade_type") }}'
|
||||
- name: ORDER_TYPE
|
||||
description: '{{ doc("vertex_order_type") }}'
|
||||
- name: MARKET_REDUCE_FLAG
|
||||
description: '{{ doc("vertex_market_reduce_flag") }}'
|
||||
- name: EXPIRATION
|
||||
description: '{{ doc("vertex_expiration") }}'
|
||||
- name: NONCE
|
||||
description: '{{ doc("vertex_nonce") }}'
|
||||
- name: IS_TAKER
|
||||
description: '{{ doc("vertex_is_taker") }}'
|
||||
- name: PRICE_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_price_amount_unadj") }}'
|
||||
- name: PRICE_AMOUNT
|
||||
description: '{{ doc("vertex_price_amount") }}'
|
||||
- name: AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_amount_unadj") }}'
|
||||
- name: AMOUNT
|
||||
description: '{{ doc("vertex_amount") }}'
|
||||
- name: AMOUNT_USD
|
||||
description: '{{ doc("vertex_amount_usd") }}'
|
||||
- name: FEE_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_fee_amount_unadj") }}'
|
||||
- name: FEE_AMOUNT
|
||||
description: '{{ doc("vertex_fee_amount") }}'
|
||||
- name: BASE_DELTA_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_base_delta_amount_unadj") }}'
|
||||
- name: BASE_DELTA_AMOUNT
|
||||
description: '{{ doc("vertex_base_delta_amount") }}'
|
||||
- name: QUOTE_DELTA_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_quote_delta_amount_unadj") }}'
|
||||
- name: QUOTE_DELTA_AMOUNT
|
||||
description: '{{ doc("vertex_quote_delta_amount") }}'
|
||||
- name: EZ_PERP_TRADES_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
@ -1,50 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
persist_docs ={ "relation": true,
|
||||
"columns": true },
|
||||
meta={
|
||||
'database_tags':{
|
||||
'table': {
|
||||
'PROTOCOL': 'VERTEX',
|
||||
'PURPOSE': 'CLOB, DEX, SPOT'
|
||||
}
|
||||
}
|
||||
}
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
contract_address,
|
||||
event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
symbol,
|
||||
digest,
|
||||
trader,
|
||||
subaccount,
|
||||
trade_type,
|
||||
order_type,
|
||||
market_reduce_flag,
|
||||
expiration,
|
||||
nonce,
|
||||
is_taker,
|
||||
price_amount_unadj,
|
||||
price_amount,
|
||||
amount_unadj,
|
||||
amount,
|
||||
amount_usd,
|
||||
fee_amount_unadj,
|
||||
fee_amount,
|
||||
base_delta_amount_unadj,
|
||||
base_delta_amount,
|
||||
quote_delta_amount_unadj,
|
||||
quote_delta_amount,
|
||||
vertex_spot_id AS ez_spot_trades_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__vertex_spot') }}
|
||||
@ -1,72 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: vertex__ez_spot_trades
|
||||
description: '{{ doc("vertex_ez_spot_trades") }}'
|
||||
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
description: '{{ doc("sei_block_number") }}'
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: '{{ doc("sei_block_timestamp") }}'
|
||||
- name: TX_HASH
|
||||
description: '{{ doc("sei_logs_tx_hash") }}'
|
||||
- name: CONTRACT_ADDRESS
|
||||
description: '{{ doc("sei_logs_contract_address") }}'
|
||||
- name: EVENT_NAME
|
||||
description: '{{ doc("sei_event_name") }}'
|
||||
- name: EVENT_INDEX
|
||||
description: '{{ doc("sei_event_index") }}'
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
description: '{{ doc("sei_origin_sig") }}'
|
||||
- name: ORIGIN_FROM_ADDRESS
|
||||
description: '{{ doc("sei_origin_from") }}'
|
||||
- name: ORIGIN_TO_ADDRESS
|
||||
description: '{{ doc("sei_origin_to") }}'
|
||||
- name: SYMBOL
|
||||
description: '{{ doc("vertex_symbol") }}'
|
||||
- name: DIGEST
|
||||
description: '{{ doc("vertex_digest") }}'
|
||||
- name: TRADER
|
||||
description: '{{ doc("vertex_trader") }}'
|
||||
- name: SUBACCOUNT
|
||||
description: '{{ doc("vertex_subaccount") }}'
|
||||
- name: TRADE_TYPE
|
||||
description: '{{ doc("vertex_trade_type") }}'
|
||||
- name: ORDER_TYPE
|
||||
description: '{{ doc("vertex_order_type") }}'
|
||||
- name: MARKET_REDUCE_FLAG
|
||||
description: '{{ doc("vertex_market_reduce_flag") }}'
|
||||
- name: EXPIRATION
|
||||
description: '{{ doc("vertex_expiration") }}'
|
||||
- name: NONCE
|
||||
description: '{{ doc("vertex_nonce") }}'
|
||||
- name: IS_TAKER
|
||||
description: '{{ doc("vertex_is_taker") }}'
|
||||
- name: PRICE_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_price_amount_unadj") }}'
|
||||
- name: PRICE_AMOUNT
|
||||
description: '{{ doc("vertex_price_amount") }}'
|
||||
- name: AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_amount_unadj") }}'
|
||||
- name: AMOUNT
|
||||
description: '{{ doc("vertex_amount") }}'
|
||||
- name: AMOUNT_USD
|
||||
description: '{{ doc("vertex_amount_usd") }}'
|
||||
- name: FEE_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_fee_amount_unadj") }}'
|
||||
- name: FEE_AMOUNT
|
||||
description: '{{ doc("vertex_fee_amount") }}'
|
||||
- name: BASE_DELTA_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_base_delta_amount_unadj") }}'
|
||||
- name: BASE_DELTA_AMOUNT
|
||||
description: '{{ doc("vertex_base_delta_amount") }}'
|
||||
- name: QUOTE_DELTA_AMOUNT_UNADJ
|
||||
description: '{{ doc("vertex_quote_delta_amount_unadj") }}'
|
||||
- name: QUOTE_DELTA_AMOUNT
|
||||
description: '{{ doc("vertex_quote_delta_amount") }}'
|
||||
- name: EZ_SPOT_TRADES_ID
|
||||
description: '{{ doc("pk") }}'
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: '{{ doc("inserted_timestamp") }}'
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
@ -1,194 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'subaccount',
|
||||
tags = 'curated'
|
||||
) }}
|
||||
|
||||
WITH
|
||||
|
||||
{% if is_incremental() %}
|
||||
new_subaccount_actions AS (
|
||||
|
||||
SELECT
|
||||
DISTINCT(subaccount)
|
||||
FROM
|
||||
{{ ref('silver__vertex_perps') }}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
UNION
|
||||
SELECT
|
||||
DISTINCT(subaccount)
|
||||
FROM
|
||||
{{ ref('silver__vertex_liquidations') }}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
UNION
|
||||
SELECT
|
||||
DISTINCT(subaccount)
|
||||
FROM
|
||||
{{this}}
|
||||
WHERE
|
||||
total_usd_volume_24h > 0
|
||||
),
|
||||
{% endif %}
|
||||
|
||||
trades_union AS (
|
||||
SELECT
|
||||
subaccount,
|
||||
trader,
|
||||
digest,
|
||||
'perp' AS product_type,
|
||||
trade_type,
|
||||
block_timestamp,
|
||||
amount,
|
||||
amount_usd,
|
||||
fee_amount,
|
||||
base_delta_amount,
|
||||
quote_delta_amount,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__vertex_perps') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
subaccount IN (
|
||||
SELECT
|
||||
subaccount
|
||||
FROM
|
||||
new_subaccount_actions
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
liquidations AS (
|
||||
SELECT
|
||||
trader,
|
||||
subaccount,
|
||||
SUM(amount) AS total_liquidation_amount,
|
||||
SUM(amount_quote) AS total_liquidation_amount_quote,
|
||||
COUNT(*) AS liquidation_count
|
||||
FROM
|
||||
{{ ref('silver__vertex_liquidations') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
subaccount IN (
|
||||
SELECT
|
||||
subaccount
|
||||
FROM
|
||||
new_subaccount_actions
|
||||
)
|
||||
{% endif %}
|
||||
GROUP BY
|
||||
1,
|
||||
2
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
t.subaccount,
|
||||
t.trader,
|
||||
MIN(
|
||||
t.block_timestamp
|
||||
) AS first_trade_timestamp,
|
||||
MAX(
|
||||
t.block_timestamp
|
||||
) AS last_trade_timestamp,
|
||||
DATEDIFF(
|
||||
'day',
|
||||
first_trade_timestamp,
|
||||
last_trade_timestamp
|
||||
) AS account_age,
|
||||
COUNT(DISTINCT(digest)) AS trade_count,
|
||||
COUNT(DISTINCT(CASE
|
||||
WHEN t.block_timestamp >= SYSDATE() - INTERVAL '24 HOURS'
|
||||
THEN digest
|
||||
END)) AS trade_count_24h,
|
||||
SUM(
|
||||
CASE
|
||||
WHEN product_type = 'perp' THEN + 1
|
||||
ELSE 0
|
||||
END
|
||||
) AS perp_trade_count,
|
||||
SUM(
|
||||
CASE
|
||||
WHEN product_type = 'spot' THEN + 1
|
||||
ELSE 0
|
||||
END
|
||||
) AS spot_trade_count,
|
||||
SUM(
|
||||
CASE
|
||||
WHEN trade_type = 'buy/long' THEN + 1
|
||||
ELSE 0
|
||||
END
|
||||
) AS long_count,
|
||||
SUM(
|
||||
CASE
|
||||
WHEN trade_type = 'sell/short' THEN + 1
|
||||
ELSE 0
|
||||
END
|
||||
) AS short_count,
|
||||
SUM(amount_usd) AS total_usd_volume,
|
||||
SUM(
|
||||
CASE
|
||||
WHEN t.block_timestamp >= SYSDATE() - INTERVAL '24 HOURS' THEN amount_usd
|
||||
ELSE 0
|
||||
END
|
||||
) AS total_usd_volume_24h,
|
||||
AVG(amount_usd) AS avg_usd_trade_size,
|
||||
SUM(fee_amount) AS total_fee_amount,
|
||||
SUM(base_delta_amount) AS total_base_delta_amount,
|
||||
SUM(quote_delta_amount) AS total_quote_delta_amount,
|
||||
MAX(
|
||||
l.total_liquidation_amount
|
||||
) AS total_liquidation_amount,
|
||||
MAX(
|
||||
l.total_liquidation_amount_quote
|
||||
) AS total_liquidation_amount_quote,
|
||||
MAX(liquidation_count) AS total_liquidation_count,
|
||||
MAX(
|
||||
t._inserted_timestamp
|
||||
) AS _inserted_timestamp
|
||||
FROM
|
||||
trades_union t
|
||||
LEFT JOIN liquidations l
|
||||
ON t.subaccount = l.subaccount
|
||||
GROUP BY
|
||||
1,
|
||||
2
|
||||
)
|
||||
SELECT
|
||||
f.*,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['f.subaccount']
|
||||
) }} AS vertex_account_id,
|
||||
COALESCE(
|
||||
{% if is_incremental() %}
|
||||
a.inserted_timestamp,
|
||||
{% endif %}
|
||||
SYSDATE(),
|
||||
NULL
|
||||
) AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
FINAL f
|
||||
{% if is_incremental() %}
|
||||
LEFT JOIN
|
||||
{{this}} a
|
||||
ON
|
||||
a.subaccount = f.subaccount
|
||||
{% endif %}
|
||||
@ -1,112 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__vertex_account_stats
|
||||
columns:
|
||||
- name: SUBACCOUNT
|
||||
tests:
|
||||
- not_null
|
||||
- name: TRADER
|
||||
tests:
|
||||
- not_null
|
||||
- name: FIRST_TRADE_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: LAST_TRADE_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: ACCOUNT_AGE
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TRADE_COUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: PERP_TRADES
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: SPOT_TRADES
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: LONG_COUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: SHORT_COUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TOTAL_USD_VOLUME
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TOTAL_FEE_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TOTAL_BASE_DELTA_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TOTAL_QUOTE_DELTA_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TOTAL_LIQUIDATION_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TOTAL_LIQUIDATION_AMOUNT_QUOTE
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TOTAL_LIQUIDATION_AMOUNT_COUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
@ -1,131 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = '_log_id',
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['curated','reorg']
|
||||
) }}
|
||||
|
||||
WITH logs_pull AS (
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
contract_address,
|
||||
'ModifyCollateral' AS event_name,
|
||||
event_index,
|
||||
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
|
||||
LEFT(
|
||||
topics [1] :: STRING,
|
||||
42
|
||||
) AS trader,
|
||||
topics [1] :: STRING AS subaccount,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [0] :: STRING
|
||||
) :: INT AS amount,
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [1] :: STRING
|
||||
) :: INT AS product_id,
|
||||
concat(tx_hash, '-', event_index) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('core_evm__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xfe53084a731040f869d38b1dcd00fbbdbc14e10d7d739160559d77f5bc80cf05'
|
||||
AND contract_address = lower('0xaE1510367aA8d500bdF507E251147Ea50B22307F') --clearing house
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
product_id_join AS (
|
||||
SELECT
|
||||
l.block_number,
|
||||
l.block_timestamp,
|
||||
l.tx_hash,
|
||||
l.contract_address,
|
||||
event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
CASE
|
||||
WHEN amount < 0 THEN 'withdraw'
|
||||
WHEN amount > 0 THEN 'deposit'
|
||||
WHEN amount = 0 THEN 'no-change'
|
||||
END AS modification_type,
|
||||
trader,
|
||||
subaccount,
|
||||
l.product_id,
|
||||
p.symbol,
|
||||
CASE
|
||||
WHEN p.symbol = 'USDC' THEN '0x3894085ef7ff0f0aedf52e2a2704928d1ec074f1'
|
||||
WHEN p.symbol = 'WETH' THEN '0x160345fc359604fc6e70e3c5facbde5f7a9342d8'
|
||||
WHEN p.symbol = 'ETH' THEN '0x160345fc359604fc6e70e3c5facbde5f7a9342d8'
|
||||
WHEN p.symbol = 'WSEI' THEN '0xe30fedd158a2e3b13e9badaeabafc5516e95e8c7'
|
||||
END AS token_address,
|
||||
amount,
|
||||
l._log_id,
|
||||
l._inserted_timestamp
|
||||
FROM
|
||||
logs_pull l
|
||||
LEFT JOIN {{ ref('silver__vertex_dim_products') }}
|
||||
p
|
||||
ON l.product_id = p.product_id
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
A.contract_address,
|
||||
event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
modification_type,
|
||||
trader,
|
||||
subaccount,
|
||||
product_id,
|
||||
A.symbol,
|
||||
A.token_address,
|
||||
amount AS amount_unadj,
|
||||
amount / pow(10, 18) AS amount,
|
||||
(amount / pow(10, 18) * p.price) :: FLOAT AS amount_usd,
|
||||
A._log_id,
|
||||
A._inserted_timestamp
|
||||
FROM
|
||||
product_id_join A
|
||||
LEFT JOIN {{ ref('price__ez_prices_hourly') }}
|
||||
p
|
||||
ON A.token_address = p.token_address
|
||||
AND DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) = p.hour
|
||||
LEFT JOIN {{ ref('silver__contracts') }} C
|
||||
ON A.token_address = C.contract_address
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
{{ dbt_utils.generate_surrogate_key(['tx_hash','event_index']) }} AS vertex_collateral_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
FINAL qualify ROW_NUMBER() over(
|
||||
PARTITION BY _log_id
|
||||
ORDER BY
|
||||
_inserted_timestamp DESC
|
||||
) = 1
|
||||
@ -1,104 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__vertex_collateral
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _LOG_ID
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 3
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: CONTRACT_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: EVENT_NAME
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: EVENT_INDEX
|
||||
tests:
|
||||
- not_null
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
tests:
|
||||
- not_null
|
||||
- name: ORIGIN_FROM_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: ORIGIN_TO_ADDRESS
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- not_null
|
||||
- name: MODIFICATION_TYPE
|
||||
tests:
|
||||
- not_null
|
||||
- name: TRADER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: SUBACCOUNT
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: PRODUCT_ID
|
||||
tests:
|
||||
- not_null
|
||||
- name: SYMBOL
|
||||
tests:
|
||||
- not_null
|
||||
- name: TOKEN_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: AMOUNT_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: AMOUNT_USD
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: _LOG_ID
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
|
||||
@ -1,134 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'product_id',
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['curated','reorg']
|
||||
) }}
|
||||
|
||||
WITH logs_pull AS (
|
||||
|
||||
SELECT
|
||||
topics,
|
||||
contract_address,
|
||||
DATA,
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
modified_timestamp AS _inserted_timestamp,
|
||||
concat(tx_hash, '-', event_index) AS _log_id
|
||||
FROM
|
||||
{{ ref('core_evm__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x3286b0394bf1350245290b7226c92ed186bd716f28938e62dbb895298f018172'
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
new_prod AS (
|
||||
SELECT
|
||||
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [0] :: STRING
|
||||
) :: STRING AS product_id,
|
||||
tx_hash,
|
||||
block_number,
|
||||
block_timestamp,
|
||||
_inserted_timestamp,
|
||||
_log_id
|
||||
FROM
|
||||
logs_pull
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x3286b0394bf1350245290b7226c92ed186bd716f28938e62dbb895298f018172'
|
||||
),
|
||||
api_pull AS (
|
||||
SELECT
|
||||
PARSE_JSON(
|
||||
live.udf_api(
|
||||
'https://gateway.sei-prod.vertexprotocol.com/api/v2/assets'
|
||||
)
|
||||
) :data AS response
|
||||
),
|
||||
api_lateral_flatten AS (
|
||||
SELECT
|
||||
r.value
|
||||
FROM
|
||||
api_pull,
|
||||
LATERAL FLATTEN (response) AS r
|
||||
),
|
||||
product_metadata AS (
|
||||
SELECT
|
||||
VALUE :product_id AS product_id,
|
||||
VALUE :ticker_id AS ticker_id,
|
||||
VALUE :symbol AS symbol,
|
||||
VALUE :name AS NAME,
|
||||
VALUE :market_type AS market_type,
|
||||
VALUE :taker_fee AS taker_fee,
|
||||
VALUE :maker_fee AS maker_fee
|
||||
FROM
|
||||
api_lateral_flatten
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
l.block_number,
|
||||
l.block_timestamp,
|
||||
l.tx_hash,
|
||||
l.product_id,
|
||||
CASE
|
||||
WHEN l.product_id % 2 = 0 THEN 'perp'
|
||||
ELSE 'spot'
|
||||
END AS product_type,
|
||||
CASE
|
||||
WHEN l.product_id = 0 THEN 'USDC'
|
||||
ELSE p.ticker_id :: STRING
|
||||
END AS ticker_id,
|
||||
p.symbol :: STRING AS symbol,
|
||||
p.name :: STRING AS NAME,
|
||||
CASE
|
||||
WHEN l.product_id = 0 THEN NULL
|
||||
ELSE FLOOR((l.product_id - 1) / 2)
|
||||
END AS health_group,
|
||||
CASE
|
||||
WHEN SPLIT(
|
||||
p.symbol,
|
||||
'-'
|
||||
) [0] = 'WBTC' THEN 'BTC'
|
||||
WHEN SPLIT(
|
||||
p.symbol,
|
||||
'-'
|
||||
) [0] = 'WETH' THEN 'ETH'
|
||||
ELSE SPLIT(
|
||||
p.symbol,
|
||||
'-'
|
||||
) [0]
|
||||
END AS health_group_symbol,
|
||||
p.taker_fee,
|
||||
p.maker_fee,
|
||||
_inserted_timestamp,
|
||||
_log_id
|
||||
FROM
|
||||
new_prod l
|
||||
LEFT JOIN product_metadata p
|
||||
ON l.product_id = p.product_id
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['tx_hash','product_id']
|
||||
) }} AS vertex_products_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
FINAL qualify(ROW_NUMBER() over(PARTITION BY product_id
|
||||
ORDER BY
|
||||
_inserted_timestamp DESC)) = 1
|
||||
@ -1,42 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__vertex_dim_products
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- PRODUCT_ID
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: PRODUCT_TYPE
|
||||
tests:
|
||||
- not_null
|
||||
- name: TICKER_ID
|
||||
tests:
|
||||
- not_null
|
||||
- name: SYMBOL
|
||||
tests:
|
||||
- not_null
|
||||
- name: NAME
|
||||
tests:
|
||||
- not_null
|
||||
- name: _LOG_ID
|
||||
tests:
|
||||
- not_null
|
||||
@ -1,203 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = '_log_id',
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['curated','reorg']
|
||||
) }}
|
||||
|
||||
WITH perp_trades AS (
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
contract_address,
|
||||
event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
symbol,
|
||||
product_id,
|
||||
digest,
|
||||
trader,
|
||||
subaccount,
|
||||
trade_type,
|
||||
expiration_raw,
|
||||
exp_binary,
|
||||
order_type_raw,
|
||||
order_type,
|
||||
market_reduce_flag,
|
||||
expiration,
|
||||
nonce,
|
||||
is_taker,
|
||||
price_amount_unadj,
|
||||
price_amount,
|
||||
amount_unadj,
|
||||
amount,
|
||||
amount_usd,
|
||||
fee_amount_unadj,
|
||||
fee_amount,
|
||||
base_delta_amount_unadj,
|
||||
base_delta_amount,
|
||||
quote_delta_amount_unadj,
|
||||
quote_delta_amount,
|
||||
_log_id,
|
||||
_inserted_timestamp,
|
||||
vertex_perps_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
_invocation_id
|
||||
FROM
|
||||
{{ ref('silver__vertex_perps') }}
|
||||
p
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
edge_trades AS (
|
||||
SELECT
|
||||
event_index - 1 AS trader_event_before,
|
||||
event_index + 1 AS trader_event_after,*
|
||||
FROM
|
||||
perp_trades
|
||||
WHERE
|
||||
trader = '0x0000000000000000000000000000000000000000'
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
e.block_number,
|
||||
e.block_timestamp,
|
||||
e.tx_hash,
|
||||
e.event_index AS edge_event_index,
|
||||
e.trader_event_before AS user_event_index,
|
||||
e.digest AS edge_digest,
|
||||
p.digest AS user_digest,
|
||||
p.trader,
|
||||
p.subaccount,
|
||||
p.symbol,
|
||||
e.order_type AS edge_order_type,
|
||||
p.order_type AS user_order_type,
|
||||
e.is_taker AS edge_is_taker,
|
||||
p.is_taker AS user_is_taker,
|
||||
e.trade_type AS edge_trade_type,
|
||||
p.trade_type AS user_trade_type,
|
||||
e.price_amount_unadj AS edge_price_amount_unadj,
|
||||
p.price_amount_unadj AS user_price_amount_unadj,
|
||||
e.price_amount AS edge_price_amount,
|
||||
p.price_amount AS user_price_amount,
|
||||
e.amount_unadj AS edge_amount_unadj,
|
||||
p.amount_unadj AS user_amount_unadj,
|
||||
e.amount AS edge_amount,
|
||||
p.amount AS user_amount,
|
||||
e.amount_usd AS edge_amount_usd,
|
||||
p.amount_usd AS user_amount_usd,
|
||||
e.fee_amount_unadj AS edge_fee_amount_unadj,
|
||||
p.fee_amount_unadj AS user_fee_amount_unadj,
|
||||
e.fee_amount AS edge_fee_amount,
|
||||
p.fee_amount AS user_fee_amount,
|
||||
e.base_delta_amount_unadj AS edge_base_delta_amount_unadj,
|
||||
p.base_delta_amount_unadj AS user_base_delta_amount_unadj,
|
||||
e.base_delta_amount AS edge_base_delta_amount,
|
||||
p.base_delta_amount AS user_base_delta_amount,
|
||||
e.quote_delta_amount_unadj AS edge_quote_delta_amount_unadj,
|
||||
p.quote_delta_amount_unadj AS user_quote_delta_amount_unadj,
|
||||
e.quote_delta_amount AS edge_quote_delta_amount,
|
||||
p.quote_delta_amount AS user_quote_delta_amount,
|
||||
e._log_id,
|
||||
e._inserted_timestamp
|
||||
FROM
|
||||
edge_trades e
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
perp_trades
|
||||
WHERE
|
||||
trader <> '0x0000000000000000000000000000000000000000'
|
||||
) p
|
||||
ON e.tx_hash = p.tx_hash
|
||||
AND e.trader_event_before = p.event_index
|
||||
AND e.product_id = p.product_id
|
||||
WHERE
|
||||
user_digest IS NOT NULL
|
||||
UNION ALL
|
||||
SELECT
|
||||
e.block_number,
|
||||
e.block_timestamp,
|
||||
e.tx_hash,
|
||||
e.event_index AS edge_event_index,
|
||||
e.trader_event_after AS user_event_index,
|
||||
e.digest AS edge_digest,
|
||||
p.digest AS user_digest,
|
||||
p.trader,
|
||||
p.subaccount,
|
||||
p.symbol,
|
||||
e.order_type AS edge_order_type,
|
||||
p.order_type AS user_order_type,
|
||||
e.is_taker AS edge_is_taker,
|
||||
p.is_taker AS user_is_taker,
|
||||
e.trade_type AS edge_trade_type,
|
||||
p.trade_type AS user_trade_type,
|
||||
e.price_amount_unadj AS edge_price_amount_unadj,
|
||||
p.price_amount_unadj AS user_price_amount_unadj,
|
||||
e.price_amount AS edge_price_amount,
|
||||
p.price_amount AS user_price_amount,
|
||||
e.amount_unadj AS edge_amount_unadj,
|
||||
p.amount_unadj AS user_amount_unadj,
|
||||
e.amount AS edge_amount,
|
||||
p.amount AS user_amount,
|
||||
e.amount_usd AS edge_amount_usd,
|
||||
p.amount_usd AS user_amount_usd,
|
||||
e.fee_amount_unadj AS edge_fee_amount_unadj,
|
||||
p.fee_amount_unadj AS user_fee_amount_unadj,
|
||||
e.fee_amount AS edge_fee_amount,
|
||||
p.fee_amount AS user_fee_amount,
|
||||
e.base_delta_amount_unadj AS edge_base_delta_amount_unadj,
|
||||
p.base_delta_amount_unadj AS user_base_delta_amount_unadj,
|
||||
e.base_delta_amount AS edge_base_delta_amount,
|
||||
p.base_delta_amount AS user_base_delta_amount,
|
||||
e.quote_delta_amount_unadj AS edge_quote_delta_amount_unadj,
|
||||
p.quote_delta_amount_unadj AS user_quote_delta_amount_unadj,
|
||||
e.quote_delta_amount AS edge_quote_delta_amount,
|
||||
p.quote_delta_amount AS user_quote_delta_amount,
|
||||
e._log_id,
|
||||
e._inserted_timestamp
|
||||
FROM
|
||||
edge_trades e
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
perp_trades
|
||||
WHERE
|
||||
trader <> '0x0000000000000000000000000000000000000000'
|
||||
) p
|
||||
ON e.tx_hash = p.tx_hash
|
||||
AND e.trader_event_after = p.event_index
|
||||
AND e.product_id = p.product_id
|
||||
WHERE
|
||||
user_digest IS NOT NULL
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['tx_hash','edge_event_index']
|
||||
) }} AS vertex_edge_trade_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
FINAL qualify(ROW_NUMBER() over(PARTITION BY _log_id
|
||||
ORDER BY
|
||||
_inserted_timestamp DESC)) = 1
|
||||
@ -1,170 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__vertex_edge_trades
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _LOG_ID
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 14
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: EDGE_EVENT_INDEX
|
||||
tests:
|
||||
- not_null
|
||||
- name: USER_EVENT_INDEX
|
||||
tests:
|
||||
- not_null
|
||||
- name: TRADER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: SYMBOL
|
||||
tests:
|
||||
- not_null
|
||||
- name: EDGE_ORDER_TYPE
|
||||
tests:
|
||||
- not_null
|
||||
- name: USER_ORDER_TYPE
|
||||
tests:
|
||||
- not_null
|
||||
- name: EDGE_IS_TAKER
|
||||
tests:
|
||||
- not_null
|
||||
- name: USER_IS_TAKER
|
||||
tests:
|
||||
- not_null
|
||||
- name: EDGE_TRADE_TYPE
|
||||
tests:
|
||||
- not_null
|
||||
- name: USER_TRADE_TYPE
|
||||
tests:
|
||||
- not_null
|
||||
- name: EDGE_PRICE_AMOUNT_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: USER_PRICE_AMOUNT_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: EDGE_PRICE_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: USER_PRICE_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: EDGE_AMOUNT_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: USER_AMOUNT_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: EDGE_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: USER_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: EDGE_AMOUNT_USD
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: USER_AMOUNT_USD
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: EDGE_QUOTE_DELTA_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: USER_QUOTE_DELTA_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: EDGE_QUOTE_DELTA
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: USER_QUOTE_DELTA
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: EDGE_BASE_DELTA_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: USER_BASE_DELTA_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: EDGE_BASE_DELTA
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: USER_BASE_DELTA
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
@ -1,184 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = '_log_id',
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['curated','reorg']
|
||||
) }}
|
||||
|
||||
WITH health_groups AS (
|
||||
|
||||
SELECT
|
||||
product_id,
|
||||
health_group,
|
||||
health_group_symbol
|
||||
FROM
|
||||
{{ ref('silver__vertex_dim_products') }}
|
||||
GROUP BY
|
||||
ALL
|
||||
),
|
||||
logs AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
tx_status,
|
||||
contract_address,
|
||||
data,
|
||||
event_index,
|
||||
event_removed,
|
||||
topics,
|
||||
modified_timestamp as _inserted_timestamp,
|
||||
concat(tx_hash, '-', event_index) AS _log_id,
|
||||
fact_event_logs_id as logs_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('core_evm__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x494f937f5cc892f798248aa831acfb4ad7c4bf35edd8498c5fb431ce1e38b035'
|
||||
AND contract_address = LOWER('0xaE1510367aA8d500bdF507E251147Ea50B22307F')
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
logs_pull_v2 AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
contract_address,
|
||||
'Liquidation' AS event_name,
|
||||
event_index,
|
||||
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [0] :: STRING
|
||||
) :: INT AS product_id,
|
||||
topics [1] :: STRING AS digest,
|
||||
LEFT(
|
||||
topics [2] :: STRING,
|
||||
42
|
||||
) AS trader,
|
||||
topics [2] :: STRING AS subaccount,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [2] :: STRING
|
||||
) :: INT AS amount,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [3] :: STRING
|
||||
) :: INT AS amount_quote,
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [1] :: STRING
|
||||
) AS is_encoded_spread,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
logs
|
||||
),
|
||||
v2_vertex_decode AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
contract_address,
|
||||
event_name,
|
||||
event_index,
|
||||
is_encoded_spread,
|
||||
digest,
|
||||
trader,
|
||||
subaccount,
|
||||
amount,
|
||||
amount_quote,
|
||||
CASE
|
||||
WHEN is_encoded_spread = 1 THEN utils.udf_int_to_binary(product_id)
|
||||
ELSE NULL
|
||||
END AS bin_product_ids,
|
||||
CASE
|
||||
WHEN is_encoded_spread = 1 THEN ARRAY_CONSTRUCT(
|
||||
utils.udf_binary_to_int(SUBSTR(bin_product_ids, -16)),
|
||||
utils.udf_binary_to_int(
|
||||
SUBSTR(
|
||||
bin_product_ids,
|
||||
1,
|
||||
GREATEST(len(bin_product_ids) - 16, 1))
|
||||
)
|
||||
)
|
||||
ELSE NULL
|
||||
END AS decoded_spread_product_ids,
|
||||
CASE
|
||||
WHEN is_encoded_spread = 1 THEN decoded_spread_product_ids [0] :: STRING
|
||||
ELSE product_id
|
||||
END AS product_id,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
logs_pull_v2
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
contract_address,
|
||||
event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
digest,
|
||||
trader,
|
||||
subaccount,
|
||||
l.product_id,
|
||||
p.health_group,
|
||||
p.health_group_symbol,
|
||||
amount AS amount_unadj,
|
||||
amount / pow(
|
||||
10,
|
||||
18
|
||||
) AS amount,
|
||||
amount_quote AS amount_quote_unadj,
|
||||
amount_quote / pow(
|
||||
10,
|
||||
18
|
||||
) AS amount_quote,
|
||||
CASE
|
||||
WHEN is_encoded_spread = 1 THEN TRUE
|
||||
ELSE FALSE
|
||||
END AS is_encoded_spread,
|
||||
decoded_spread_product_ids AS spread_product_ids,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
v2_vertex_decode l
|
||||
LEFT JOIN health_groups p
|
||||
ON l.product_id = p.product_id
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
{{ dbt_utils.generate_surrogate_key(['tx_hash','event_index']) }} AS vertex_liquidation_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
FINAL qualify ROW_NUMBER() over(
|
||||
PARTITION BY _log_id
|
||||
ORDER BY
|
||||
_inserted_timestamp DESC
|
||||
) = 1
|
||||
@ -1,106 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__vertex_liquidations
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _LOG_ID
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 14
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: EVENT_INDEX
|
||||
tests:
|
||||
- not_null
|
||||
- name: CONTRACT_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: EVENT_NAME
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- not_null
|
||||
- name: DIGEST
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: TRADER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: SUBACCOUNT
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: PRODUCT_ID
|
||||
tests:
|
||||
- not_null
|
||||
- name: HEALTH_GROUP
|
||||
tests:
|
||||
- not_null
|
||||
- name: AMOUNT_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: AMOUNT_QUOTE_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: AMOUNT_QUOTE
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: _LOG_ID
|
||||
tests:
|
||||
- not_null
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
tests:
|
||||
- not_null
|
||||
- name: ORIGIN_FROM_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: ORIGIN_TO_ADDRESS
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
|
||||
@ -1,106 +0,0 @@
|
||||
-- depends_on: {{ ref('silver__vertex_dim_products') }}
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'merge',
|
||||
full_refresh = false,
|
||||
unique_key = ['product_id','hour','price'],
|
||||
cluster_by = ['hour::DATE'],
|
||||
tags = 'curated'
|
||||
) }}
|
||||
|
||||
WITH market_depth AS ({% for item in range(55) %}
|
||||
|
||||
SELECT
|
||||
t.ticker_id, t.product_id, DATE_TRUNC('hour', TRY_TO_TIMESTAMP(t.timestamp)) AS HOUR, 'asks' AS orderbook_side, A.value [0] :: FLOAT AS price, A.value [1] :: FLOAT AS volume, SYSDATE() AS _inserted_timestamp
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
response :ticker_id AS ticker_id, response :timestamp :: STRING AS TIMESTAMP, response :asks AS asks, response :bids AS bids, product_id
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
PARSE_JSON(live.udf_api(CONCAT('https://gateway.sei-prod.vertexprotocol.com/v2/orderbook?ticker_id=', ticker_id, '&depth=1000000'))) :data AS response, product_id
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
ROW_NUMBER() over (
|
||||
ORDER BY
|
||||
product_id) AS row_num, product_id, ticker_id
|
||||
FROM
|
||||
{{ ref('silver__vertex_dim_products') }}
|
||||
WHERE
|
||||
product_id > 0
|
||||
ORDER BY
|
||||
product_id)
|
||||
WHERE
|
||||
row_num = {{ item + 1 }})) t, LATERAL FLATTEN(input => t.asks) A
|
||||
UNION ALL
|
||||
SELECT
|
||||
t.ticker_id, t.product_id, DATE_TRUNC('hour', TRY_TO_TIMESTAMP(t.timestamp)) AS HOUR, 'bids' AS orderbook_side, A.value [0] :: FLOAT AS price, A.value [1] :: FLOAT AS volume, SYSDATE() AS _inserted_timestamp
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
response :ticker_id AS ticker_id, response :timestamp :: STRING AS TIMESTAMP, response :asks AS asks, response :bids AS bids, product_id
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
PARSE_JSON(live.udf_api(CONCAT('https://gateway.sei-prod.vertexprotocol.com/v2/orderbook?ticker_id=', ticker_id, '&depth=1000000'))) :data AS response, product_id
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
ROW_NUMBER() over (
|
||||
ORDER BY
|
||||
product_id) AS row_num, product_id, ticker_id
|
||||
FROM
|
||||
{{ ref('silver__vertex_dim_products') }}
|
||||
WHERE
|
||||
product_id > 0
|
||||
ORDER BY
|
||||
product_id)
|
||||
WHERE
|
||||
row_num = {{ item + 1 }})) t, LATERAL FLATTEN(input => t.bids) A {% if not loop.last %}
|
||||
UNION ALL
|
||||
{% endif %}
|
||||
{% endfor %}),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
ticker_id :: STRING AS ticker_id,
|
||||
product_id,
|
||||
HOUR,
|
||||
orderbook_side,
|
||||
price,
|
||||
ROUND(
|
||||
price,
|
||||
2
|
||||
) AS round_price_0_01,
|
||||
ROUND(
|
||||
price,
|
||||
1
|
||||
) AS round_price_0_1,
|
||||
ROUND(
|
||||
price,
|
||||
0
|
||||
) AS round_price_1,
|
||||
ROUND(
|
||||
price,
|
||||
-1
|
||||
) AS round_price_10,
|
||||
ROUND(
|
||||
price,
|
||||
-2
|
||||
) AS round_price_100,
|
||||
volume,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
market_depth
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['product_id','hour','price']
|
||||
) }} AS vertex_market_depth_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
FINAL
|
||||
@ -1,69 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__vertex_market_depth
|
||||
tests:
|
||||
- vertex_missing_products:
|
||||
filter: product_id <> 0 AND (product_type = 'perp' and taker_fee is NULL)
|
||||
columns:
|
||||
- name: TICKER_ID
|
||||
tests:
|
||||
- not_null
|
||||
- name: PRODUCT_ID
|
||||
tests:
|
||||
- not_null
|
||||
- name: HOUR
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: ORDERBOOK_SIDE
|
||||
tests:
|
||||
- not_null
|
||||
- name: PRICE
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: ROUND_PRICE_0_01
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: ROUND_PRICE_0_1
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: ROUND_PRICE_1
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: ROUND_PRICE_10
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: ROUND_PRICE_100
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: VOLUME
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
|
||||
@ -1,192 +0,0 @@
|
||||
-- depends_on: {{ ref('silver__vertex_dim_products') }}
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'merge',
|
||||
unique_key = ['ticker_id','hour'],
|
||||
cluster_by = ['HOUR::DATE'],
|
||||
tags = 'curated'
|
||||
) }}
|
||||
|
||||
WITH api_pull AS (
|
||||
|
||||
SELECT
|
||||
PARSE_JSON(
|
||||
live.udf_api(
|
||||
'https://archive.sei-prod.vertexprotocol.com/v2/contracts'
|
||||
)
|
||||
) :data AS response
|
||||
),
|
||||
market_stats AS (
|
||||
SELECT
|
||||
DATE_TRUNC('hour', SYSDATE()) AS HOUR,
|
||||
f.value :base_currency :: STRING AS base_currency,
|
||||
f.value :base_volume :: FLOAT AS base_volume,
|
||||
f.value :contract_price :: FLOAT AS contract_price,
|
||||
f.value :contract_price_currency :: STRING AS contract_price_currency,
|
||||
f.value :funding_rate :: FLOAT AS funding_rate,
|
||||
f.value :index_price :: FLOAT AS index_price,
|
||||
f.value :last_price :: FLOAT AS last_price,
|
||||
f.value :mark_price :: FLOAT AS mark_price,
|
||||
TRY_TO_TIMESTAMP(
|
||||
f.value :next_funding_rate_timestamp :: STRING
|
||||
) AS next_funding_rate_timestamp,
|
||||
f.value :open_interest :: FLOAT AS open_interest,
|
||||
f.value :open_interest_usd :: FLOAT AS open_interest_usd,
|
||||
f.value :price_change_percent_24h :: FLOAT AS price_change_percent_24h,
|
||||
f.value :product_type :: STRING AS product_type,
|
||||
f.value :quote_currency :: STRING AS quote_currency,
|
||||
f.value :quote_volume :: FLOAT AS quote_volume,
|
||||
f.key AS ticker_id,
|
||||
SYSDATE() AS inserted_timestamp
|
||||
FROM
|
||||
api_pull A,
|
||||
LATERAL FLATTEN(
|
||||
input => response
|
||||
) AS f
|
||||
),
|
||||
trade_snapshot AS (
|
||||
SELECT
|
||||
DATE_TRUNC(
|
||||
'hour',
|
||||
block_timestamp
|
||||
) AS HOUR,
|
||||
CONCAT(
|
||||
symbol,
|
||||
'_USDC'
|
||||
) AS ticker_id,
|
||||
symbol,
|
||||
product_id,
|
||||
COUNT(DISTINCT(tx_hash)) AS distinct_sequencer_batches,
|
||||
COUNT(DISTINCT(trader)) AS distinct_trader_count,
|
||||
COUNT(DISTINCT(subaccount)) AS distinct_subaccount_count,
|
||||
COUNT(DISTINCT(digest)) AS trade_count,
|
||||
SUM(amount_usd) AS amount_usd,
|
||||
SUM(fee_amount) AS fee_amount,
|
||||
SUM(base_delta_amount) AS base_delta_amount,
|
||||
SUM(quote_delta_amount) AS quote_delta_amount,
|
||||
MAX(_inserted_timestamp) AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__vertex_perps') }}
|
||||
p
|
||||
WHERE
|
||||
block_timestamp > '2024-10-01 00:00:00.000' --start of api pulls
|
||||
GROUP BY
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4
|
||||
),
|
||||
products AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
product_id,
|
||||
product_type,
|
||||
ticker_id,
|
||||
symbol,
|
||||
name,
|
||||
health_group,
|
||||
health_group_symbol,
|
||||
taker_fee,
|
||||
maker_fee,
|
||||
_inserted_timestamp,
|
||||
_log_id,
|
||||
vertex_products_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
_invocation_id
|
||||
FROM
|
||||
{{ ref('silver__vertex_dim_products') }}
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
s.hour,
|
||||
s.ticker_id,
|
||||
p.symbol,
|
||||
p.product_id,
|
||||
t.distinct_sequencer_batches,
|
||||
t.distinct_trader_count,
|
||||
t.distinct_subaccount_count,
|
||||
t.trade_count,
|
||||
t.amount_usd,
|
||||
t.fee_amount,
|
||||
t.base_delta_amount,
|
||||
t.quote_delta_amount,
|
||||
s.base_volume AS base_volume_24h,
|
||||
s.quote_volume AS quote_volume_24h,
|
||||
s.contract_price,
|
||||
s.contract_price_currency,
|
||||
s.funding_rate,
|
||||
s.index_price,
|
||||
s.last_price,
|
||||
s.mark_price,
|
||||
s.next_funding_rate_timestamp,
|
||||
s.open_interest,
|
||||
s.open_interest_usd,
|
||||
s.price_change_percent_24h,
|
||||
s.product_type,
|
||||
s.quote_currency,
|
||||
s.quote_volume,
|
||||
t._inserted_timestamp,
|
||||
FROM
|
||||
market_stats s
|
||||
LEFT JOIN trade_snapshot t
|
||||
ON t.ticker_id = s.ticker_id
|
||||
AND s.hour = t.hour
|
||||
LEFT JOIN products p
|
||||
ON s.ticker_id = p.ticker_id
|
||||
|
||||
{% if is_incremental() %}
|
||||
UNION ALL
|
||||
SELECT
|
||||
s.hour,
|
||||
s.ticker_id,
|
||||
p.symbol,
|
||||
p.product_id,
|
||||
t.distinct_sequencer_batches,
|
||||
t.distinct_trader_count,
|
||||
t.distinct_subaccount_count,
|
||||
t.trade_count,
|
||||
t.amount_usd,
|
||||
t.fee_amount,
|
||||
t.base_delta_amount,
|
||||
t.quote_delta_amount,
|
||||
s.base_volume_24h,
|
||||
s.quote_volume_24h,
|
||||
s.contract_price,
|
||||
s.contract_price_currency,
|
||||
s.funding_rate,
|
||||
s.index_price,
|
||||
s.last_price,
|
||||
s.mark_price,
|
||||
s.next_funding_rate_timestamp,
|
||||
s.open_interest,
|
||||
s.open_interest_usd,
|
||||
s.price_change_percent_24h,
|
||||
s.product_type,
|
||||
s.quote_currency,
|
||||
s.quote_volume,
|
||||
t._inserted_timestamp
|
||||
FROM
|
||||
{{ this }}
|
||||
s
|
||||
LEFT JOIN trade_snapshot t
|
||||
ON t.ticker_id = s.ticker_id
|
||||
AND s.hour = t.hour
|
||||
LEFT JOIN products p
|
||||
ON s.ticker_id = p.ticker_id
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['ticker_id','hour']
|
||||
) }} AS vertex_market_stats_id,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
FINAL
|
||||
WHERE FUNDING_RATE <> 0 qualify(ROW_NUMBER() over(PARTITION BY ticker_id, HOUR
|
||||
ORDER BY
|
||||
_inserted_timestamp DESC NULLS LAST)) = 1
|
||||
@ -1,142 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__vertex_market_stats
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- HOUR
|
||||
- TICKER_ID
|
||||
- vertex_missing_products:
|
||||
filter: product_type = 'perp' AND product_id <> 0
|
||||
columns:
|
||||
- name: HOUR
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TICKER_ID
|
||||
tests:
|
||||
- not_null
|
||||
- name: SYMBOL
|
||||
- not_null
|
||||
- name: PRODUCT_ID
|
||||
- not_null
|
||||
- name: DISTINCT_SEQUENCE
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: DISTINCT_TRADER_COUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: DISTINCT_SUBACCOUNT_COUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TRADE_COUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: AMOUNT_USD
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: FEE_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BASE_DELTA_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: QUOTE_DELTA_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BASE_VOLUME
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: CONTRACT_PRICE
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: CONTRACT_PRICE_CURRENCY
|
||||
tests:
|
||||
- not_null
|
||||
- name: FUNDING_RATE
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: INDEX_PRICE
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: LAST_PRICE
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: MARK_PRICE
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: NEXT_FUNDING_RATE_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- name: OPEN_INTEREST
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: OPEN_INTEREST_USD
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: PRODUCT_TYPE
|
||||
tests:
|
||||
- not_null
|
||||
- name: QUOTE_CURRENCY
|
||||
tests:
|
||||
- not_null
|
||||
- name: QUOTE_VOLUME
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
@ -1,55 +0,0 @@
|
||||
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'merge',
|
||||
unique_key = ['ticker_id','hour'],
|
||||
cluster_by = ['HOUR::DATE'],
|
||||
tags = 'curated'
|
||||
) }}
|
||||
|
||||
|
||||
WITH apr AS (
|
||||
SELECT
|
||||
PARSE_JSON(
|
||||
live.udf_api(
|
||||
'https://gateway.sei-prod.vertexprotocol.com/v2/apr'
|
||||
)
|
||||
):data AS response
|
||||
),
|
||||
flattened AS (
|
||||
SELECT
|
||||
DATE_TRUNC('hour', SYSDATE()) AS HOUR,
|
||||
CONCAT(
|
||||
f.value:symbol::string,
|
||||
'_USDC'
|
||||
) AS ticker_id,
|
||||
f.value:symbol::string AS symbol,
|
||||
f.value:product_id::string AS product_id,
|
||||
f.value:deposit_apr::float AS deposit_apr,
|
||||
f.value:borrow_apr::float AS borrow_apr,
|
||||
f.value:tvl::float AS tvl
|
||||
FROM
|
||||
apr A,
|
||||
LATERAL FLATTEN(
|
||||
input => response
|
||||
) AS f
|
||||
)
|
||||
SELECT
|
||||
HOUR,
|
||||
ticker_id,
|
||||
symbol,
|
||||
product_id,
|
||||
deposit_apr,
|
||||
borrow_apr,
|
||||
tvl,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['ticker_id','hour']
|
||||
) }} AS vertex_money_markets_id,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
flattened
|
||||
WHERE product_id not in ('121','125') qualify(ROW_NUMBER() over(PARTITION BY ticker_id, HOUR
|
||||
ORDER BY
|
||||
inserted_timestamp DESC )) = 1
|
||||
@ -1,44 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__vertex_money_markets
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- HOUR
|
||||
- TICKER_ID
|
||||
columns:
|
||||
- name: HOUR
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TICKER_ID
|
||||
tests:
|
||||
- not_null
|
||||
- name: SYMBOL
|
||||
- not_null
|
||||
- name: PRODUCT_ID
|
||||
- not_null
|
||||
- name: DEPOSIT_APR
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BORROW_APR
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: TVL
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
@ -1,242 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = '_log_id',
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['curated','reorg']
|
||||
) }}
|
||||
|
||||
WITH vertex_products AS (
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
product_id :: STRING AS product_id,
|
||||
product_type,
|
||||
ticker_id,
|
||||
symbol,
|
||||
NAME
|
||||
FROM
|
||||
{{ ref('silver__vertex_dim_products') }}
|
||||
WHERE
|
||||
product_type = 'perp'
|
||||
),
|
||||
logs AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
tx_status,
|
||||
contract_address,
|
||||
data,
|
||||
event_index,
|
||||
event_removed,
|
||||
topics,
|
||||
modified_timestamp as _inserted_timestamp,
|
||||
concat(tx_hash, '-', event_index) AS _log_id,
|
||||
fact_event_logs_id as logs_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('core_evm__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x7c57459d6f4f0fb2fc5b1e298c8c0eb238422944964aa1e249eaa78747f0cca9'
|
||||
AND contract_address = LOWER('0x56Ffa2fD437C3a718322ea701bEd40560745456e')
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
order_fill_decode_v2 AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
contract_address,
|
||||
'FillOrder' AS event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
|
||||
utils.udf_hex_to_int(
|
||||
topics [1] :: STRING
|
||||
) :: STRING AS product_id,
|
||||
topics [2] :: STRING AS digest,
|
||||
--unique hash of the order
|
||||
LEFT(
|
||||
topics [3] :: STRING,
|
||||
42
|
||||
) AS trader,
|
||||
topics [3] :: STRING AS subaccount,
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [0] :: STRING
|
||||
) :: INT AS pricex18,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [1] :: STRING
|
||||
) :: INT AS amount,
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [2] :: STRING
|
||||
) AS expiration,
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [3] :: STRING
|
||||
) :: INT AS nonce,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [4] :: STRING
|
||||
) :: INT AS isTaker,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [5] :: STRING
|
||||
) :: INT AS feeAmount,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [6] :: STRING
|
||||
) :: INT AS baseDelta,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [7] :: STRING
|
||||
) :: INT AS quoteDelta,
|
||||
l._log_id,
|
||||
l._inserted_timestamp
|
||||
FROM
|
||||
logs l
|
||||
),
|
||||
order_fill_format AS (
|
||||
SELECT
|
||||
l.block_number,
|
||||
l.block_timestamp,
|
||||
l.tx_hash,
|
||||
l.contract_address,
|
||||
event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
s.symbol,
|
||||
l.product_id,
|
||||
digest,
|
||||
trader,
|
||||
subaccount,
|
||||
expiration AS expiration_raw,
|
||||
utils.udf_int_to_binary(TRY_TO_NUMBER(expiration)) AS exp_binary,
|
||||
utils.udf_binary_to_int(SUBSTR(exp_binary, -2)) AS order_type,
|
||||
utils.udf_binary_to_int(SUBSTR(exp_binary, -3, 1)) AS market_reduce_flag,
|
||||
CASE
|
||||
WHEN len(expiration) < 11 THEN TRY_TO_TIMESTAMP(utils.udf_binary_to_int(exp_binary) :: STRING)
|
||||
ELSE TRY_TO_TIMESTAMP(
|
||||
utils.udf_binary_to_int(SUBSTR(exp_binary, 24)) :: STRING
|
||||
)
|
||||
END AS expiration,
|
||||
nonce,
|
||||
isTaker,
|
||||
feeAmount AS fee_amount_unadj,
|
||||
feeAmount / pow(
|
||||
10,
|
||||
18
|
||||
) AS fee_amount,
|
||||
pricex18 AS price_amount_unadj,
|
||||
pricex18 / pow(
|
||||
10,
|
||||
18
|
||||
) AS price_amount,
|
||||
amount AS amount_unadj,
|
||||
amount / pow(
|
||||
10,
|
||||
18
|
||||
) AS amount,
|
||||
baseDelta AS base_delta_unadj,
|
||||
baseDelta / pow(
|
||||
10,
|
||||
18
|
||||
) AS base_delta,
|
||||
quoteDelta AS quote_delta_unadj,
|
||||
quoteDelta / pow(
|
||||
10,
|
||||
18
|
||||
) AS quote_delta,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
order_fill_decode_v2 l
|
||||
INNER JOIN vertex_products s
|
||||
ON s.product_id = l.product_id
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
contract_address,
|
||||
event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
symbol,
|
||||
product_id,
|
||||
digest,
|
||||
trader,
|
||||
subaccount,
|
||||
CASE
|
||||
WHEN amount < 0 THEN 'sell/short'
|
||||
WHEN amount > 0 THEN 'buy/long'
|
||||
END AS trade_type,
|
||||
expiration_raw,
|
||||
exp_binary,
|
||||
order_type AS order_type_raw,
|
||||
CASE
|
||||
WHEN order_type = 0 THEN 'default'
|
||||
WHEN order_type = 1 THEN 'immediate-or-cancel'
|
||||
WHEN order_type = 2 THEN 'fill-or-kill'
|
||||
WHEN order_type = 3 THEN 'post-only'
|
||||
END AS order_type,
|
||||
market_reduce_flag,
|
||||
expiration,
|
||||
nonce,
|
||||
CASE
|
||||
WHEN isTaker = 1 THEN TRUE
|
||||
WHEN isTaker = 0 THEN FALSE
|
||||
END AS is_taker,
|
||||
price_amount_unadj,
|
||||
price_amount,
|
||||
amount_unadj,
|
||||
amount,
|
||||
CASE
|
||||
WHEN quote_delta < 0 THEN quote_delta * -1
|
||||
ELSE quote_delta
|
||||
END AS amount_usd,
|
||||
fee_amount_unadj,
|
||||
fee_amount,
|
||||
base_delta_unadj AS base_delta_amount_unadj,
|
||||
base_delta AS base_delta_amount,
|
||||
quote_delta_unadj AS quote_delta_amount_unadj,
|
||||
quote_delta AS quote_delta_amount,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
order_fill_format
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['tx_hash','event_index']
|
||||
) }} AS vertex_perps_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
FINAL qualify(ROW_NUMBER() over(PARTITION BY _log_id
|
||||
ORDER BY
|
||||
_inserted_timestamp DESC)) = 1
|
||||
@ -1,170 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__vertex_perps
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _LOG_ID
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 14
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: EVENT_INDEX
|
||||
tests:
|
||||
- not_null
|
||||
- name: CONTRACT_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: EVENT_NAME
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- not_null
|
||||
- name: SYMBOL
|
||||
tests:
|
||||
- not_null
|
||||
- name: DIGEST
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: TRADER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: SUBACCOUNT
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: TRADE_TYPE
|
||||
tests:
|
||||
- not_null
|
||||
- name: EXPIRATION_RAW
|
||||
tests:
|
||||
- not_null
|
||||
- name: EXPIRATION
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- not_null
|
||||
- name: NONCE
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: PRICE_AMOUNT_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: PRICE_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: AMOUNT_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: AMOUNT_USD
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: FEE_AMOUNT_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: FEE_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BASE_DELTA_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BASE_DELTA
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: QUOTE_DELTA_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: QUOTE_DELTA
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: PLATFORM
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: _LOG_ID
|
||||
tests:
|
||||
- not_null
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
tests:
|
||||
- not_null
|
||||
- name: ORIGIN_FROM_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: ORIGIN_TO_ADDRESS
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
|
||||
@ -1,244 +0,0 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = '_log_id',
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['curated','reorg']
|
||||
) }}
|
||||
|
||||
WITH vertex_products AS (
|
||||
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
product_id :: STRING AS product_id,
|
||||
product_type,
|
||||
ticker_id,
|
||||
symbol,
|
||||
NAME
|
||||
FROM
|
||||
{{ ref('silver__vertex_dim_products') }}
|
||||
WHERE
|
||||
product_type = 'spot'
|
||||
),
|
||||
logs AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
origin_function_signature,
|
||||
tx_status,
|
||||
contract_address,
|
||||
data,
|
||||
event_index,
|
||||
event_removed,
|
||||
topics,
|
||||
modified_timestamp as _inserted_timestamp,
|
||||
concat(tx_hash, '-', event_index) AS _log_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('core_evm__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x7c57459d6f4f0fb2fc5b1e298c8c0eb238422944964aa1e249eaa78747f0cca9'
|
||||
AND contract_address = LOWER('0x56Ffa2fD437C3a718322ea701bEd40560745456e')
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
order_fill_decode_v2 AS (
|
||||
SELECT
|
||||
l.block_number,
|
||||
l.block_timestamp,
|
||||
l.tx_hash,
|
||||
l.contract_address,
|
||||
'FillOrder' AS event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
|
||||
utils.udf_hex_to_int(
|
||||
topics [1] :: STRING
|
||||
) AS product_id,
|
||||
s.symbol,
|
||||
topics [2] :: STRING AS digest,
|
||||
--unique hash of the order
|
||||
LEFT(
|
||||
topics [3] :: STRING,
|
||||
42
|
||||
) AS trader,
|
||||
topics [3] :: STRING AS subaccount,
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [0] :: STRING
|
||||
) :: INT AS pricex18,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [1] :: STRING
|
||||
) :: INT AS amount,
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [2] :: STRING
|
||||
) AS expiration,
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [3] :: STRING
|
||||
) :: INT AS nonce,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [4] :: STRING
|
||||
) :: INT AS isTaker,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [5] :: STRING
|
||||
) :: INT AS feeAmount,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [6] :: STRING
|
||||
) :: INT AS baseDelta,
|
||||
utils.udf_hex_to_int(
|
||||
's2c',
|
||||
segmented_data [7] :: STRING
|
||||
) :: INT AS quoteDelta,
|
||||
l._log_id,
|
||||
l._inserted_timestamp
|
||||
FROM
|
||||
logs l
|
||||
INNER JOIN vertex_products s
|
||||
ON s.product_id = utils.udf_hex_to_int(
|
||||
topics [1] :: STRING
|
||||
)
|
||||
),
|
||||
order_fill_format AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
contract_address,
|
||||
event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
symbol,
|
||||
product_id,
|
||||
digest,
|
||||
trader,
|
||||
subaccount,
|
||||
expiration AS expiration_raw,
|
||||
UTILS.UDF_INT_TO_BINARY(TRY_TO_NUMBER(expiration)) AS exp_binary,
|
||||
utils.udf_binary_to_int(SUBSTR(exp_binary, -2)) AS order_type,
|
||||
utils.udf_binary_to_int(SUBSTR(exp_binary, -3, 1)) AS market_reduce_flag,
|
||||
CASE
|
||||
WHEN len(expiration) < 11 THEN TRY_TO_TIMESTAMP(utils.udf_binary_to_int(exp_binary) :: STRING)
|
||||
ELSE TRY_TO_TIMESTAMP(
|
||||
utils.udf_binary_to_int(SUBSTR(exp_binary, 24)) :: STRING
|
||||
)
|
||||
END AS expiration,
|
||||
nonce,
|
||||
isTaker,
|
||||
feeAmount AS fee_amount_unadj,
|
||||
feeAmount / pow(
|
||||
10,
|
||||
18
|
||||
) AS fee_amount,
|
||||
pricex18 AS price_amount_unadj,
|
||||
pricex18 / pow(
|
||||
10,
|
||||
18
|
||||
) AS price_amount,
|
||||
amount AS amount_unadj,
|
||||
amount / pow(
|
||||
10,
|
||||
18
|
||||
) AS amount,
|
||||
baseDelta AS base_delta_unadj,
|
||||
baseDelta / pow(
|
||||
10,
|
||||
18
|
||||
) AS base_delta,
|
||||
quoteDelta AS quote_delta_unadj,
|
||||
quoteDelta / pow(
|
||||
10,
|
||||
18
|
||||
) AS quote_delta,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
order_fill_decode_v2
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
contract_address,
|
||||
event_name,
|
||||
event_index,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
symbol,
|
||||
product_id,
|
||||
digest,
|
||||
trader,
|
||||
subaccount,
|
||||
CASE
|
||||
WHEN amount < 0 THEN 'sell/short'
|
||||
WHEN amount > 0 THEN 'buy/long'
|
||||
END AS trade_type,
|
||||
expiration_raw,
|
||||
exp_binary,
|
||||
order_type AS order_type_raw,
|
||||
CASE
|
||||
WHEN order_type = 0 THEN 'default'
|
||||
WHEN order_type = 1 THEN 'immediate-or-cancel'
|
||||
WHEN order_type = 2 THEN 'fill-or-kill'
|
||||
WHEN order_type = 3 THEN 'post-only'
|
||||
END AS order_type,
|
||||
market_reduce_flag,
|
||||
expiration,
|
||||
nonce,
|
||||
CASE
|
||||
WHEN isTaker = 1 THEN TRUE
|
||||
WHEN isTaker = 0 THEN FALSE
|
||||
END AS is_taker,
|
||||
price_amount_unadj,
|
||||
price_amount,
|
||||
amount_unadj,
|
||||
amount,
|
||||
CASE
|
||||
WHEN quote_delta < 0 THEN quote_delta * -1
|
||||
ELSE quote_delta
|
||||
END AS amount_usd,
|
||||
fee_amount_unadj,
|
||||
fee_amount,
|
||||
base_delta_unadj AS base_delta_amount_unadj,
|
||||
base_delta AS base_delta_amount,
|
||||
quote_delta_unadj AS quote_delta_amount_unadj,
|
||||
quote_delta AS quote_delta_amount,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
order_fill_format
|
||||
)
|
||||
SELECT
|
||||
*,
|
||||
{{ dbt_utils.generate_surrogate_key(
|
||||
['tx_hash','event_index']
|
||||
) }} AS vertex_spot_id,
|
||||
SYSDATE() AS inserted_timestamp,
|
||||
SYSDATE() AS modified_timestamp,
|
||||
'{{ invocation_id }}' AS _invocation_id
|
||||
FROM
|
||||
FINAL qualify(ROW_NUMBER() over(PARTITION BY _log_id
|
||||
ORDER BY
|
||||
_inserted_timestamp DESC)) = 1
|
||||
@ -1,172 +0,0 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__vertex_spot
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _LOG_ID
|
||||
- vertex_product_level_recency:
|
||||
filter: product_type = 'spot' AND product_id <> 0
|
||||
columns:
|
||||
- name: BLOCK_NUMBER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BLOCK_TIMESTAMP
|
||||
tests:
|
||||
- not_null
|
||||
# - dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
# datepart: day
|
||||
# interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- name: TX_HASH
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: EVENT_INDEX
|
||||
tests:
|
||||
- not_null
|
||||
- name: CONTRACT_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: EVENT_NAME
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- not_null
|
||||
- name: SYMBOL
|
||||
tests:
|
||||
- not_null
|
||||
- name: DIGEST
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: TRADER
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: SUBACCOUNT
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: TRADE_TYPE
|
||||
tests:
|
||||
- not_null
|
||||
- name: EXPIRATION_RAW
|
||||
tests:
|
||||
- not_null
|
||||
- name: EXPIRATION
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_LTZ
|
||||
- TIMESTAMP_NTZ
|
||||
- not_null
|
||||
- name: NONCE
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: PRICE_AMOUNT_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: PRICE_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: AMOUNT_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: AMOUNT_USD
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: FEE_AMOUNT_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: FEE_AMOUNT
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BASE_DELTA_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BASE_DELTA
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: QUOTE_DELTA_UNADJ
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: QUOTE_DELTA
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: PLATFORM
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- name: _LOG_ID
|
||||
tests:
|
||||
- not_null
|
||||
- name: ORIGIN_FUNCTION_SIGNATURE
|
||||
tests:
|
||||
- not_null
|
||||
- name: ORIGIN_FROM_ADDRESS
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
- name: ORIGIN_TO_ADDRESS
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: 0[xX][0-9a-fA-F]+
|
||||
|
||||
Loading…
Reference in New Issue
Block a user