diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml index d61b2d58e13..a234b79c6fb 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml @@ -152,12 +152,12 @@ models: data_tests: - not_null - name: updated_at_block - description: The block number at which the order was last updated. - data_tests: - - not_null + description: The block number at which the order was last updated. - &updated_at_time name: updated_at_time description: The timestamp when the order was last updated. + - name: valid_from_time + description: The time from which the order becomes valid for execution. - &is_long name: is_long description: A boolean indicating whether the position is long @@ -165,8 +165,8 @@ models: - not_null - name: should_unwrap_native_token description: Boolean indicating if the native token should be unwrapped. - - name: is_frozen - description: Boolean indicating if the order is frozen. + - name: auto_cancel + description: Boolean indicating whether the order will be automatically canceled under certain conditions. - &key name: key description: The unique identifier for the order, stored as a bytes32 value. @@ -604,31 +604,6 @@ models: description: The size of the trade in USD data_tests: - not_null - - &total_rebate_factor - name: total_rebate_factor - description: The total rebate factor for the position - data_tests: - - not_null - - &trader_discount_factor - name: trader_discount_factor - description: The discount factor applied to the trader - data_tests: - - not_null - - &total_rebate_amount - name: total_rebate_amount - description: The total amount of rebate given - data_tests: - - not_null - - &trader_discount_amount - name: trader_discount_amount - description: The amount of discount given to the trader - data_tests: - - not_null - - &affiliate_reward_amount - name: affiliate_reward_amount - description: The reward amount given to the affiliate - data_tests: - - not_null - &funding_fee_amount name: funding_fee_amount description: The amount of funding fee charged @@ -637,28 +612,18 @@ models: - &claimable_long_token_amount name: claimable_long_token_amount description: The amount of long tokens claimable - data_tests: - - not_null - &claimable_short_token_amount name: claimable_short_token_amount description: The amount of short tokens claimable - data_tests: - - not_null - &latest_funding_fee_amount_per_size name: latest_funding_fee_amount_per_size description: The latest funding fee amount per size - data_tests: - - not_null - &latest_long_token_claimable_funding_amount_per_size name: latest_long_token_claimable_funding_amount_per_size description: The latest claimable long token funding amount per size - data_tests: - - not_null - &latest_short_token_claimable_funding_amount_per_size name: latest_short_token_claimable_funding_amount_per_size description: The latest claimable short token funding amount per size - data_tests: - - not_null - &borrowing_fee_usd name: borrowing_fee_usd description: The borrowing fee amount in USD @@ -729,6 +694,61 @@ models: description: The total amount of UI fee collected data_tests: - not_null + - &referral_total_rebate_factor + name: referral_total_rebate_factor + description: The total rebate factor associated with referrals. + data_tests: + - not_null + - &referral_total_rebate_amount + name: referral_total_rebate_amount + description: The total rebate amount given for referrals. + data_tests: + - not_null + - &referral_trader_discount_factor + name: referral_trader_discount_factor + description: The discount factor applied to the trader through referrals. + data_tests: + - not_null + - &referral_adjusted_affiliate_reward_factor + name: referral_adjusted_affiliate_reward_factor + description: The adjusted affiliate reward factor based on referral criteria. + data_tests: + - not_null + - &referral_affiliate_reward_amount + name: referral_affiliate_reward_amount + description: The reward amount given to the affiliate for referrals. + data_tests: + - not_null + - &referral_trader_discount_amount + name: referral_trader_discount_amount + description: The discount amount given to the trader through referrals. + data_tests: + - not_null + - &pro_trader_discount_factor + name: pro_trader_discount_factor + description: The discount factor applied for pro traders. + data_tests: + - not_null + - &pro_trader_discount_amount + name: pro_trader_discount_amount + description: The discount amount given to pro traders. + data_tests: + - not_null + - &liquidation_fee_amount + name: liquidation_fee_amount + description: The amount of fees charged during liquidation. + data_tests: + - not_null + - &liquidation_fee_receiver_factor + name: liquidation_fee_receiver_factor + description: The factor used to calculate the liquidation fee allocated to the receiver. + data_tests: + - not_null + - &liquidation_fee_amount_for_fee_receiver + name: liquidation_fee_amount_for_fee_receiver + description: The amount of liquidation fee allocated to the fee receiver. + data_tests: + - not_null - &is_increase name: is_increase description: Indicates whether the position is increased (true) or decreased (false) @@ -785,11 +805,6 @@ models: - *collateral_token_price_min - *collateral_token_price_max - *trade_size_usd - - *total_rebate_factor - - *trader_discount_factor - - *total_rebate_amount - - *trader_discount_amount - - *affiliate_reward_amount - *funding_fee_amount - *claimable_long_token_amount - *claimable_short_token_amount @@ -810,6 +825,17 @@ models: - *total_cost_amount - *ui_fee_receiver_factor - *ui_fee_amount + - *referral_total_rebate_factor + - *referral_total_rebate_amount + - *referral_trader_discount_factor + - *referral_adjusted_affiliate_reward_factor + - *referral_affiliate_reward_amount + - *referral_trader_discount_amount + - *pro_trader_discount_factor + - *pro_trader_discount_amount + - *liquidation_fee_amount + - *liquidation_fee_receiver_factor + - *liquidation_fee_amount_for_fee_receiver - *is_increase - *order_key - *position_key @@ -898,7 +924,7 @@ models: data_tests: - not_null - name: market - description: The market in which the order was updated. + description: The market in which the order was updated data_tests: - not_null - name: account @@ -909,4 +935,8 @@ models: - *acceptable_price_raw - *acceptable_price - *min_output_amount_raw - - *updated_at_time \ No newline at end of file + - *updated_at_time + - name: valid_from_time + description: The time from which the order becomes valid for execution. + - name: auto_cancel + description: Boolean indicating whether the order will be automatically canceled under certain conditions. \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql index 4339e211083..37823907ffc 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql @@ -171,10 +171,11 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'updatedAtBlock' THEN value END) AS updated_at_block, MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'validFromTime' THEN value END) AS valid_from_time, MAX(CASE WHEN key_name = 'isLong' THEN value END) AS is_long, MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token, - MAX(CASE WHEN key_name = 'isFrozen' THEN value END) AS is_frozen, + MAX(CASE WHEN key_name = 'autoCancel' THEN value END) AS auto_cancel, MAX(CASE WHEN key_name = 'key' THEN value END) AS key FROM @@ -213,9 +214,10 @@ WITH evt_data_1 AS ( TRY_CAST(min_output_amount AS DOUBLE) AS min_output_amount, TRY_CAST(updated_at_block AS BIGINT) AS updated_at_block, TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(valid_from_time AS DOUBLE) AS valid_from_time, TRY_CAST(is_long AS BOOLEAN) AS is_long, TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token, - TRY_CAST(is_frozen AS BOOLEAN) AS is_frozen, + TRY_CAST(auto_cancel AS BOOLEAN) AS auto_cancel, from_hex(key) AS key FROM evt_data AS ED @@ -284,9 +286,14 @@ WITH evt_data_1 AS ( WHEN updated_at_time = 0 THEN NULL ELSE updated_at_time END AS updated_at_time, + valid_from_time, is_long, should_unwrap_native_token, - is_frozen, + + CASE + WHEN auto_cancel IS NULL THEN false + ELSE auto_cancel + END AS auto_cancel, key FROM event_data AS ED diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql index 4fe2a489b05..edb33308631 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql @@ -58,7 +58,8 @@ WITH evt_data_1 AS ( index, json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, - json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items FROM evt_data ) @@ -102,6 +103,19 @@ WITH evt_data_1 AS ( ) AS t(item) ) +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + , combined AS ( SELECT * FROM bytes32_items_parsed @@ -111,6 +125,9 @@ WITH evt_data_1 AS ( UNION ALL SELECT * FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed ) , evt_data_parsed AS ( @@ -123,7 +140,9 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'acceptablePrice' THEN value END) AS acceptable_price, MAX(CASE WHEN key_name = 'triggerPrice' THEN value END) AS trigger_price, MAX(CASE WHEN key_name = 'minOutputAmount' THEN value END) AS min_output_amount, - MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'validFromTime' THEN value END) AS valid_from_time, + MAX(CASE WHEN key_name = 'autoCancel' THEN value END) AS auto_cancel FROM combined GROUP BY tx_hash, index @@ -147,7 +166,9 @@ WITH evt_data_1 AS ( TRY_CAST(acceptable_price AS DOUBLE) AS acceptable_price, TRY_CAST(trigger_price AS DOUBLE) AS trigger_price, TRY_CAST(min_output_amount AS DOUBLE) AS min_output_amount, - TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(valid_from_time AS DOUBLE) AS valid_from_time, + TRY_CAST(auto_cancel AS BOOLEAN) AS auto_cancel FROM evt_data AS ED LEFT JOIN evt_data_parsed AS EDP @@ -186,7 +207,9 @@ WITH evt_data_1 AS ( CASE WHEN ED.updated_at_time = 0 THEN NULL ELSE ED.updated_at_time - END AS updated_at_time + END AS updated_at_time, + ED.valid_from_time, + ED.auto_cancel FROM event_data AS ED LEFT JOIN {{ ref('gmx_v2_arbitrum_order_created') }} AS OC diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_collected.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_collected.sql index fa7d065f5fa..7019c6c497d 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_collected.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_collected.sql @@ -135,19 +135,19 @@ WITH evt_data_1 AS ( tx_hash, index, + MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, + MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, + MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, MAX(CASE WHEN key_name = 'affiliate' THEN value END) AS affiliate, MAX(CASE WHEN key_name = 'trader' THEN value END) AS trader, MAX(CASE WHEN key_name = 'uiFeeReceiver' THEN value END) AS ui_fee_receiver, + MAX(CASE WHEN key_name = 'collateralTokenPrice.min' THEN value END) AS collateral_token_price_min, MAX(CASE WHEN key_name = 'collateralTokenPrice.max' THEN value END) AS collateral_token_price_max, MAX(CASE WHEN key_name = 'tradeSizeUsd' THEN value END) AS trade_size_usd, - MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, - MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, - MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, - MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, - MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, MAX(CASE WHEN key_name = 'fundingFeeAmount' THEN value END) AS funding_fee_amount, MAX(CASE WHEN key_name = 'claimableLongTokenAmount' THEN value END) AS claimable_long_token_amount, MAX(CASE WHEN key_name = 'claimableShortTokenAmount' THEN value END) AS claimable_short_token_amount, @@ -168,10 +168,28 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'totalCostAmount' THEN value END) AS total_cost_amount, MAX(CASE WHEN key_name = 'uiFeeReceiverFactor' THEN value END) AS ui_fee_receiver_factor, MAX(CASE WHEN key_name = 'uiFeeAmount' THEN value END) AS ui_fee_amount, - MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase, - MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, - MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, - MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code + + MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, + MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, + MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, + MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, + MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'referral.totalRebateFactor' THEN value END) AS referral_total_rebate_factor, + MAX(CASE WHEN key_name = 'referral.adjustedAffiliateRewardFactor' THEN value END) AS referral_adjusted_affiliate_reward_factor, + MAX(CASE WHEN key_name = 'referral.traderDiscountFactor' THEN value END) AS referral_trader_discount_factor, + MAX(CASE WHEN key_name = 'referral.totalRebateAmount' THEN value END) AS referral_total_rebate_amount, + MAX(CASE WHEN key_name = 'referral.traderDiscountAmount' THEN value END) AS referral_trader_discount_amount, + MAX(CASE WHEN key_name = 'referral.affiliateRewardAmount' THEN value END) AS referral_affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'pro.traderDiscountFactor' THEN value END) AS pro_trader_discount_factor, + MAX(CASE WHEN key_name = 'pro.traderDiscountAmount' THEN value END) AS pro_trader_discount_amount, + + MAX(CASE WHEN key_name = 'liquidationFeeAmount' THEN value END) AS liquidation_fee_amount, + MAX(CASE WHEN key_name = 'liquidationFeeReceiverFactor' THEN value END) AS liquidation_fee_receiver_factor, + MAX(CASE WHEN key_name = 'liquidationFeeAmountForFeeReceiver' THEN value END) AS liquidation_fee_amount_for_fee_receiver, + + MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase FROM combined @@ -190,19 +208,19 @@ WITH evt_data_1 AS ( event_name, msg_sender, + from_hex(order_key) AS order_key, + from_hex(position_key) AS position_key, + from_hex(referral_code) AS referral_code, + from_hex(market) AS market, from_hex(collateral_token) AS collateral_token, from_hex(affiliate) AS affiliate, from_hex(trader) AS trader, from_hex(ui_fee_receiver) AS ui_fee_receiver, + TRY_CAST(collateral_token_price_min AS DOUBLE) AS collateral_token_price_min, TRY_CAST(collateral_token_price_max AS DOUBLE) AS collateral_token_price_max, TRY_CAST(trade_size_usd AS DOUBLE) AS trade_size_usd, - TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, - TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, - TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, - TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, - TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, TRY_CAST(funding_fee_amount AS DOUBLE) AS funding_fee_amount, TRY_CAST(claimable_long_token_amount AS DOUBLE) AS claimable_long_token_amount, TRY_CAST(claimable_short_token_amount AS DOUBLE) AS claimable_short_token_amount, @@ -223,11 +241,29 @@ WITH evt_data_1 AS ( TRY_CAST(total_cost_amount AS DOUBLE) AS total_cost_amount, TRY_CAST(ui_fee_receiver_factor AS DOUBLE) AS ui_fee_receiver_factor, TRY_CAST(ui_fee_amount AS DOUBLE) AS ui_fee_amount, - TRY_CAST(is_increase AS BOOLEAN) AS is_increase, - from_hex(order_key) AS order_key, - from_hex(position_key) AS position_key, - from_hex(referral_code) AS referral_code - + + TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, + TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, + TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, + TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, + TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, + + TRY_CAST(referral_total_rebate_factor AS DOUBLE) AS referral_total_rebate_factor, + TRY_CAST(referral_adjusted_affiliate_reward_factor AS DOUBLE) AS referral_adjusted_affiliate_reward_factor, + TRY_CAST(referral_trader_discount_factor AS DOUBLE) AS referral_trader_discount_factor, + TRY_CAST(referral_total_rebate_amount AS DOUBLE) AS referral_total_rebate_amount, + TRY_CAST(referral_trader_discount_amount AS DOUBLE) AS referral_trader_discount_amount, + TRY_CAST(referral_affiliate_reward_amount AS DOUBLE) AS referral_affiliate_reward_amount, + + TRY_CAST(pro_trader_discount_factor AS DOUBLE) AS pro_trader_discount_factor, + TRY_CAST(pro_trader_discount_amount AS DOUBLE) AS pro_trader_discount_amount, + + TRY_CAST(liquidation_fee_amount AS DOUBLE) AS liquidation_fee_amount, + TRY_CAST(liquidation_fee_receiver_factor AS DOUBLE) AS liquidation_fee_receiver_factor, + TRY_CAST(liquidation_fee_amount_for_fee_receiver AS DOUBLE) AS liquidation_fee_amount_for_fee_receiver, + + TRY_CAST(is_increase AS BOOLEAN) AS is_increase + FROM evt_data AS ED LEFT JOIN evt_data_parsed AS EDP ON ED.tx_hash = EDP.tx_hash @@ -247,6 +283,10 @@ WITH evt_data_1 AS ( event_name, msg_sender, + order_key, + position_key, + referral_code, + ED.market AS market, ED.collateral_token, affiliate, @@ -255,12 +295,7 @@ WITH evt_data_1 AS ( collateral_token_price_min / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_min, collateral_token_price_max / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_max, - trade_size_usd / POWER(10, 30) AS trade_size_usd, - total_rebate_factor / POWER(10, 30) AS total_rebate_factor, - trader_discount_factor / POWER(10, 30) AS trader_discount_factor, - total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, - trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, - affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + trade_size_usd / POWER(10, 30) AS trade_size_usd, funding_fee_amount / POWER(10, collateral_token_decimals + 15) AS funding_fee_amount, claimable_long_token_amount / POWER(10, long_token_decimals + 15) AS claimable_long_token_amount, claimable_short_token_amount / POWER(10, short_token_decimals + 15) AS claimable_short_token_amount, @@ -281,11 +316,29 @@ WITH evt_data_1 AS ( total_cost_amount / POWER(10, collateral_token_decimals) AS total_cost_amount, ui_fee_receiver_factor / POWER(10, 30) AS ui_fee_receiver_factor, ui_fee_amount / POWER(10, collateral_token_decimals) AS ui_fee_amount, - is_increase, - order_key, - position_key, - referral_code + + total_rebate_factor / POWER(10, 30) AS total_rebate_factor, + trader_discount_factor / POWER(10, 30) AS trader_discount_factor, + total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, + trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, + affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + + referral_total_rebate_factor / POWER(10, 30) AS referral_total_rebate_factor, + referral_adjusted_affiliate_reward_factor / POWER(10, 30) AS referral_adjusted_affiliate_reward_factor, + referral_trader_discount_factor / POWER(10, 30) AS referral_trader_discount_factor, + referral_total_rebate_amount / POWER(10, collateral_token_decimals) AS referral_total_rebate_amount, + referral_trader_discount_amount / POWER(10, collateral_token_decimals) AS referral_trader_discount_amount, + referral_affiliate_reward_amount / POWER(10, collateral_token_decimals) AS referral_affiliate_reward_amount, + pro_trader_discount_factor / POWER(10, 30) AS pro_trader_discount_factor, + pro_trader_discount_amount / POWER(10, collateral_token_decimals) AS pro_trader_discount_amount, + + liquidation_fee_amount / POWER(10, collateral_token_decimals) AS liquidation_fee_amount, + liquidation_fee_receiver_factor / POWER(10, 30) AS liquidation_fee_receiver_factor, + liquidation_fee_amount_for_fee_receiver / POWER(10, collateral_token_decimals) AS liquidation_fee_amount_for_fee_receiver, + + is_increase + FROM event_data AS ED LEFT JOIN {{ ref('gmx_v2_arbitrum_markets_data') }} AS MD ON ED.market = MD.market @@ -293,10 +346,99 @@ WITH evt_data_1 AS ( ON ED.collateral_token = CTD.collateral_token ) +, full_data_2 AS ( + SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + order_key, + position_key, + referral_code, + + market, + collateral_token, + affiliate, + trader, + ui_fee_receiver, + + collateral_token_price_min, + collateral_token_price_max, + trade_size_usd, + funding_fee_amount, + claimable_long_token_amount, + claimable_short_token_amount, + latest_funding_fee_amount_per_size, + latest_long_token_claimable_funding_amount_per_size, + latest_short_token_claimable_funding_amount_per_size, + borrowing_fee_usd, + borrowing_fee_amount, + borrowing_fee_receiver_factor, + borrowing_fee_amount_for_fee_receiver, + position_fee_factor, + protocol_fee_amount, + position_fee_receiver_factor, + fee_receiver_amount, + fee_amount_for_pool, + position_fee_amount_for_pool, + position_fee_amount, + total_cost_amount, + ui_fee_receiver_factor, + ui_fee_amount, + + CASE + WHEN total_rebate_factor IS NOT NULL THEN total_rebate_factor + WHEN referral_total_rebate_factor IS NOT NULL THEN referral_total_rebate_factor + ELSE 0 + END AS referral_total_rebate_factor, + CASE + WHEN total_rebate_amount IS NOT NULL THEN total_rebate_amount + WHEN referral_total_rebate_amount IS NOT NULL THEN referral_total_rebate_amount + ELSE 0 + END AS referral_total_rebate_amount, + CASE + WHEN referral_trader_discount_factor IS NOT NULL THEN referral_trader_discount_factor + WHEN trader_discount_factor IS NOT NULL THEN trader_discount_factor * total_rebate_factor + ELSE 0 + END AS referral_trader_discount_factor, + CASE + WHEN referral_adjusted_affiliate_reward_factor IS NOT NULL THEN referral_adjusted_affiliate_reward_factor + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_adjusted_affiliate_reward_factor, + CASE + WHEN referral_affiliate_reward_amount IS NOT NULL THEN referral_affiliate_reward_amount + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_affiliate_reward_amount, + CASE + WHEN referral_trader_discount_amount IS NOT NULL THEN referral_trader_discount_amount + WHEN trader_discount_amount IS NOT NULL THEN trader_discount_amount + ELSE 0 + END AS referral_trader_discount_amount, + + COALESCE(pro_trader_discount_factor, 0) AS pro_trader_discount_factor, + COALESCE(pro_trader_discount_amount, 0) AS pro_trader_discount_amount, + + COALESCE(liquidation_fee_amount, 0) AS liquidation_fee_amount, + COALESCE(liquidation_fee_receiver_factor, 0) AS liquidation_fee_receiver_factor, + COALESCE(liquidation_fee_amount_for_fee_receiver, 0) AS liquidation_fee_amount_for_fee_receiver, + + is_increase + + FROM full_data +) + --can be removed once decoded tables are fully denormalized {{ add_tx_columns( - model_cte = 'full_data' + model_cte = 'full_data_2' , blockchain = blockchain_name , columns = ['from', 'to'] ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_info.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_info.sql index 4a7432cea9b..6665accfbd1 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_info.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_position_fees_info.sql @@ -135,19 +135,20 @@ WITH evt_data_1 AS ( tx_hash, index, + MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, + MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, + MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, MAX(CASE WHEN key_name = 'affiliate' THEN value END) AS affiliate, MAX(CASE WHEN key_name = 'trader' THEN value END) AS trader, MAX(CASE WHEN key_name = 'uiFeeReceiver' THEN value END) AS ui_fee_receiver, + MAX(CASE WHEN key_name = 'collateralTokenPrice.min' THEN value END) AS collateral_token_price_min, MAX(CASE WHEN key_name = 'collateralTokenPrice.max' THEN value END) AS collateral_token_price_max, MAX(CASE WHEN key_name = 'tradeSizeUsd' THEN value END) AS trade_size_usd, - MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, - MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, - MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, - MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, - MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, + MAX(CASE WHEN key_name = 'fundingFeeAmount' THEN value END) AS funding_fee_amount, MAX(CASE WHEN key_name = 'claimableLongTokenAmount' THEN value END) AS claimable_long_token_amount, MAX(CASE WHEN key_name = 'claimableShortTokenAmount' THEN value END) AS claimable_short_token_amount, @@ -168,10 +169,28 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'totalCostAmount' THEN value END) AS total_cost_amount, MAX(CASE WHEN key_name = 'uiFeeReceiverFactor' THEN value END) AS ui_fee_receiver_factor, MAX(CASE WHEN key_name = 'uiFeeAmount' THEN value END) AS ui_fee_amount, - MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase, - MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, - MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, - MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code + + MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, + MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, + MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, + MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, + MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'referral.totalRebateFactor' THEN value END) AS referral_total_rebate_factor, + MAX(CASE WHEN key_name = 'referral.adjustedAffiliateRewardFactor' THEN value END) AS referral_adjusted_affiliate_reward_factor, + MAX(CASE WHEN key_name = 'referral.traderDiscountFactor' THEN value END) AS referral_trader_discount_factor, + MAX(CASE WHEN key_name = 'referral.totalRebateAmount' THEN value END) AS referral_total_rebate_amount, + MAX(CASE WHEN key_name = 'referral.traderDiscountAmount' THEN value END) AS referral_trader_discount_amount, + MAX(CASE WHEN key_name = 'referral.affiliateRewardAmount' THEN value END) AS referral_affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'pro.traderDiscountFactor' THEN value END) AS pro_trader_discount_factor, + MAX(CASE WHEN key_name = 'pro.traderDiscountAmount' THEN value END) AS pro_trader_discount_amount, + + MAX(CASE WHEN key_name = 'liquidationFeeAmount' THEN value END) AS liquidation_fee_amount, + MAX(CASE WHEN key_name = 'liquidationFeeReceiverFactor' THEN value END) AS liquidation_fee_receiver_factor, + MAX(CASE WHEN key_name = 'liquidationFeeAmountForFeeReceiver' THEN value END) AS liquidation_fee_amount_for_fee_receiver, + + MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase FROM combined @@ -190,19 +209,19 @@ WITH evt_data_1 AS ( event_name, msg_sender, + from_hex(order_key) AS order_key, + from_hex(position_key) AS position_key, + from_hex(referral_code) AS referral_code, + from_hex(market) AS market, from_hex(collateral_token) AS collateral_token, from_hex(affiliate) AS affiliate, from_hex(trader) AS trader, from_hex(ui_fee_receiver) AS ui_fee_receiver, + TRY_CAST(collateral_token_price_min AS DOUBLE) AS collateral_token_price_min, TRY_CAST(collateral_token_price_max AS DOUBLE) AS collateral_token_price_max, TRY_CAST(trade_size_usd AS DOUBLE) AS trade_size_usd, - TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, - TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, - TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, - TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, - TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, TRY_CAST(funding_fee_amount AS DOUBLE) AS funding_fee_amount, TRY_CAST(claimable_long_token_amount AS DOUBLE) AS claimable_long_token_amount, TRY_CAST(claimable_short_token_amount AS DOUBLE) AS claimable_short_token_amount, @@ -223,11 +242,29 @@ WITH evt_data_1 AS ( TRY_CAST(total_cost_amount AS DOUBLE) AS total_cost_amount, TRY_CAST(ui_fee_receiver_factor AS DOUBLE) AS ui_fee_receiver_factor, TRY_CAST(ui_fee_amount AS DOUBLE) AS ui_fee_amount, - TRY_CAST(is_increase AS BOOLEAN) AS is_increase, - from_hex(order_key) AS order_key, - from_hex(position_key) AS position_key, - from_hex(referral_code) AS referral_code - + + TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, + TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, + TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, + TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, + TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, + + TRY_CAST(referral_total_rebate_factor AS DOUBLE) AS referral_total_rebate_factor, + TRY_CAST(referral_adjusted_affiliate_reward_factor AS DOUBLE) AS referral_adjusted_affiliate_reward_factor, + TRY_CAST(referral_trader_discount_factor AS DOUBLE) AS referral_trader_discount_factor, + TRY_CAST(referral_total_rebate_amount AS DOUBLE) AS referral_total_rebate_amount, + TRY_CAST(referral_trader_discount_amount AS DOUBLE) AS referral_trader_discount_amount, + TRY_CAST(referral_affiliate_reward_amount AS DOUBLE) AS referral_affiliate_reward_amount, + + TRY_CAST(pro_trader_discount_factor AS DOUBLE) AS pro_trader_discount_factor, + TRY_CAST(pro_trader_discount_amount AS DOUBLE) AS pro_trader_discount_amount, + + TRY_CAST(liquidation_fee_amount AS DOUBLE) AS liquidation_fee_amount, + TRY_CAST(liquidation_fee_receiver_factor AS DOUBLE) AS liquidation_fee_receiver_factor, + TRY_CAST(liquidation_fee_amount_for_fee_receiver AS DOUBLE) AS liquidation_fee_amount_for_fee_receiver, + + TRY_CAST(is_increase AS BOOLEAN) AS is_increase + FROM evt_data AS ED LEFT JOIN evt_data_parsed AS EDP ON ED.tx_hash = EDP.tx_hash @@ -247,6 +284,10 @@ WITH evt_data_1 AS ( event_name, msg_sender, + order_key, + position_key, + referral_code, + ED.market AS market, ED.collateral_token, affiliate, @@ -255,12 +296,7 @@ WITH evt_data_1 AS ( collateral_token_price_min / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_min, collateral_token_price_max / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_max, - trade_size_usd / POWER(10, 30) AS trade_size_usd, - total_rebate_factor / POWER(10, 30) AS total_rebate_factor, - trader_discount_factor / POWER(10, 30) AS trader_discount_factor, - total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, - trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, - affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + trade_size_usd / POWER(10, 30) AS trade_size_usd, funding_fee_amount / POWER(10, collateral_token_decimals + 15) AS funding_fee_amount, claimable_long_token_amount / POWER(10, long_token_decimals + 15) AS claimable_long_token_amount, claimable_short_token_amount / POWER(10, short_token_decimals + 15) AS claimable_short_token_amount, @@ -281,10 +317,28 @@ WITH evt_data_1 AS ( total_cost_amount / POWER(10, collateral_token_decimals) AS total_cost_amount, ui_fee_receiver_factor / POWER(10, 30) AS ui_fee_receiver_factor, ui_fee_amount / POWER(10, collateral_token_decimals) AS ui_fee_amount, - is_increase, - order_key, - position_key, - referral_code + + total_rebate_factor / POWER(10, 30) AS total_rebate_factor, + trader_discount_factor / POWER(10, 30) AS trader_discount_factor, + total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, + trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, + affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + + referral_total_rebate_factor / POWER(10, 30) AS referral_total_rebate_factor, + referral_adjusted_affiliate_reward_factor / POWER(10, 30) AS referral_adjusted_affiliate_reward_factor, + referral_trader_discount_factor / POWER(10, 30) AS referral_trader_discount_factor, + referral_total_rebate_amount / POWER(10, collateral_token_decimals) AS referral_total_rebate_amount, + referral_trader_discount_amount / POWER(10, collateral_token_decimals) AS referral_trader_discount_amount, + referral_affiliate_reward_amount / POWER(10, collateral_token_decimals) AS referral_affiliate_reward_amount, + + pro_trader_discount_factor / POWER(10, 30) AS pro_trader_discount_factor, + pro_trader_discount_amount / POWER(10, collateral_token_decimals) AS pro_trader_discount_amount, + + liquidation_fee_amount / POWER(10, collateral_token_decimals) AS liquidation_fee_amount, + liquidation_fee_receiver_factor / POWER(10, 30) AS liquidation_fee_receiver_factor, + liquidation_fee_amount_for_fee_receiver / POWER(10, collateral_token_decimals) AS liquidation_fee_amount_for_fee_receiver, + + is_increase FROM event_data AS ED LEFT JOIN {{ ref('gmx_v2_arbitrum_markets_data') }} AS MD @@ -293,10 +347,99 @@ WITH evt_data_1 AS ( ON ED.collateral_token = CTD.collateral_token ) +, full_data_2 AS ( + SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + order_key, + position_key, + referral_code, + + market, + collateral_token, + affiliate, + trader, + ui_fee_receiver, + + collateral_token_price_min, + collateral_token_price_max, + trade_size_usd, + funding_fee_amount, + claimable_long_token_amount, + claimable_short_token_amount, + latest_funding_fee_amount_per_size, + latest_long_token_claimable_funding_amount_per_size, + latest_short_token_claimable_funding_amount_per_size, + borrowing_fee_usd, + borrowing_fee_amount, + borrowing_fee_receiver_factor, + borrowing_fee_amount_for_fee_receiver, + position_fee_factor, + protocol_fee_amount, + position_fee_receiver_factor, + fee_receiver_amount, + fee_amount_for_pool, + position_fee_amount_for_pool, + position_fee_amount, + total_cost_amount, + ui_fee_receiver_factor, + ui_fee_amount, + + CASE + WHEN total_rebate_factor IS NOT NULL THEN total_rebate_factor + WHEN referral_total_rebate_factor IS NOT NULL THEN referral_total_rebate_factor + ELSE 0 + END AS referral_total_rebate_factor, + CASE + WHEN total_rebate_amount IS NOT NULL THEN total_rebate_amount + WHEN referral_total_rebate_amount IS NOT NULL THEN referral_total_rebate_amount + ELSE 0 + END AS referral_total_rebate_amount, + CASE + WHEN referral_trader_discount_factor IS NOT NULL THEN referral_trader_discount_factor + WHEN trader_discount_factor IS NOT NULL THEN trader_discount_factor * total_rebate_factor + ELSE 0 + END AS referral_trader_discount_factor, + CASE + WHEN referral_adjusted_affiliate_reward_factor IS NOT NULL THEN referral_adjusted_affiliate_reward_factor + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_adjusted_affiliate_reward_factor, + CASE + WHEN referral_affiliate_reward_amount IS NOT NULL THEN referral_affiliate_reward_amount + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_affiliate_reward_amount, + CASE + WHEN referral_trader_discount_amount IS NOT NULL THEN referral_trader_discount_amount + WHEN trader_discount_amount IS NOT NULL THEN trader_discount_amount + ELSE 0 + END AS referral_trader_discount_amount, + + COALESCE(pro_trader_discount_factor, 0) AS pro_trader_discount_factor, + COALESCE(pro_trader_discount_amount, 0) AS pro_trader_discount_amount, + + COALESCE(liquidation_fee_amount, 0) AS liquidation_fee_amount, + COALESCE(liquidation_fee_receiver_factor, 0) AS liquidation_fee_receiver_factor, + COALESCE(liquidation_fee_amount_for_fee_receiver, 0) AS liquidation_fee_amount_for_fee_receiver, + + is_increase + + FROM full_data +) + --can be removed once decoded tables are fully denormalized {{ add_tx_columns( - model_cte = 'full_data' + model_cte = 'full_data_2' , blockchain = blockchain_name , columns = ['from', 'to'] ) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml index d43cb91644a..ba40d0e98e5 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml @@ -153,11 +153,11 @@ models: - not_null - name: updated_at_block description: The block number at which the order was last updated. - data_tests: - - not_null - - &updated_at_time + - &updated_at_time name: updated_at_time description: The timestamp when the order was last updated. + - name: valid_from_time + description: The time from which the order becomes valid for execution. - &is_long name: is_long description: A boolean indicating whether the position is long @@ -165,8 +165,8 @@ models: - not_null - name: should_unwrap_native_token description: Boolean indicating if the native token should be unwrapped. - - name: is_frozen - description: Boolean indicating if the order is frozen. + - name: auto_cancel + description: Boolean indicating whether the order will be automatically canceled under certain conditions. - &key name: key description: The unique identifier for the order, stored as a bytes32 value. @@ -604,31 +604,6 @@ models: description: The size of the trade in USD data_tests: - not_null - - &total_rebate_factor - name: total_rebate_factor - description: The total rebate factor for the position - data_tests: - - not_null - - &trader_discount_factor - name: trader_discount_factor - description: The discount factor applied to the trader - data_tests: - - not_null - - &total_rebate_amount - name: total_rebate_amount - description: The total amount of rebate given - data_tests: - - not_null - - &trader_discount_amount - name: trader_discount_amount - description: The amount of discount given to the trader - data_tests: - - not_null - - &affiliate_reward_amount - name: affiliate_reward_amount - description: The reward amount given to the affiliate - data_tests: - - not_null - &funding_fee_amount name: funding_fee_amount description: The amount of funding fee charged @@ -637,28 +612,18 @@ models: - &claimable_long_token_amount name: claimable_long_token_amount description: The amount of long tokens claimable - data_tests: - - not_null - &claimable_short_token_amount name: claimable_short_token_amount description: The amount of short tokens claimable - data_tests: - - not_null - &latest_funding_fee_amount_per_size name: latest_funding_fee_amount_per_size description: The latest funding fee amount per size - data_tests: - - not_null - &latest_long_token_claimable_funding_amount_per_size name: latest_long_token_claimable_funding_amount_per_size description: The latest claimable long token funding amount per size - data_tests: - - not_null - &latest_short_token_claimable_funding_amount_per_size name: latest_short_token_claimable_funding_amount_per_size description: The latest claimable short token funding amount per size - data_tests: - - not_null - &borrowing_fee_usd name: borrowing_fee_usd description: The borrowing fee amount in USD @@ -729,6 +694,61 @@ models: description: The total amount of UI fee collected data_tests: - not_null + - &referral_total_rebate_factor + name: referral_total_rebate_factor + description: The total rebate factor associated with referrals. + data_tests: + - not_null + - &referral_total_rebate_amount + name: referral_total_rebate_amount + description: The total rebate amount given for referrals. + data_tests: + - not_null + - &referral_trader_discount_factor + name: referral_trader_discount_factor + description: The discount factor applied to the trader through referrals. + data_tests: + - not_null + - &referral_adjusted_affiliate_reward_factor + name: referral_adjusted_affiliate_reward_factor + description: The adjusted affiliate reward factor based on referral criteria. + data_tests: + - not_null + - &referral_affiliate_reward_amount + name: referral_affiliate_reward_amount + description: The reward amount given to the affiliate for referrals. + data_tests: + - not_null + - &referral_trader_discount_amount + name: referral_trader_discount_amount + description: The discount amount given to the trader through referrals. + data_tests: + - not_null + - &pro_trader_discount_factor + name: pro_trader_discount_factor + description: The discount factor applied for pro traders. + data_tests: + - not_null + - &pro_trader_discount_amount + name: pro_trader_discount_amount + description: The discount amount given to pro traders. + data_tests: + - not_null + - &liquidation_fee_amount + name: liquidation_fee_amount + description: The amount of fees charged during liquidation. + data_tests: + - not_null + - &liquidation_fee_receiver_factor + name: liquidation_fee_receiver_factor + description: The factor used to calculate the liquidation fee allocated to the receiver. + data_tests: + - not_null + - &liquidation_fee_amount_for_fee_receiver + name: liquidation_fee_amount_for_fee_receiver + description: The amount of liquidation fee allocated to the fee receiver. + data_tests: + - not_null - &is_increase name: is_increase description: Indicates whether the position is increased (true) or decreased (false) @@ -785,11 +805,6 @@ models: - *collateral_token_price_min - *collateral_token_price_max - *trade_size_usd - - *total_rebate_factor - - *trader_discount_factor - - *total_rebate_amount - - *trader_discount_amount - - *affiliate_reward_amount - *funding_fee_amount - *claimable_long_token_amount - *claimable_short_token_amount @@ -810,6 +825,17 @@ models: - *total_cost_amount - *ui_fee_receiver_factor - *ui_fee_amount + - *referral_total_rebate_factor + - *referral_total_rebate_amount + - *referral_trader_discount_factor + - *referral_adjusted_affiliate_reward_factor + - *referral_affiliate_reward_amount + - *referral_trader_discount_amount + - *pro_trader_discount_factor + - *pro_trader_discount_amount + - *liquidation_fee_amount + - *liquidation_fee_receiver_factor + - *liquidation_fee_amount_for_fee_receiver - *is_increase - *order_key - *position_key @@ -909,4 +935,8 @@ models: - *acceptable_price_raw - *acceptable_price - *min_output_amount_raw - - *updated_at_time \ No newline at end of file + - *updated_at_time + - name: valid_from_time + description: The time from which the order becomes valid for execution. + - name: auto_cancel + description: Boolean indicating whether the order will be automatically canceled under certain conditions. \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql index cec7a4baf06..ba428954368 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql @@ -171,10 +171,11 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'updatedAtBlock' THEN value END) AS updated_at_block, MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'validFromTime' THEN value END) AS valid_from_time, MAX(CASE WHEN key_name = 'isLong' THEN value END) AS is_long, MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token, - MAX(CASE WHEN key_name = 'isFrozen' THEN value END) AS is_frozen, + MAX(CASE WHEN key_name = 'autoCancel' THEN value END) AS auto_cancel, MAX(CASE WHEN key_name = 'key' THEN value END) AS key FROM @@ -213,9 +214,10 @@ WITH evt_data_1 AS ( TRY_CAST(min_output_amount AS DOUBLE) AS min_output_amount, TRY_CAST(updated_at_block AS BIGINT) AS updated_at_block, TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(valid_from_time AS DOUBLE) AS valid_from_time, TRY_CAST(is_long AS BOOLEAN) AS is_long, TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token, - TRY_CAST(is_frozen AS BOOLEAN) AS is_frozen, + TRY_CAST(auto_cancel AS BOOLEAN) AS auto_cancel, from_hex(key) AS key FROM evt_data AS ED @@ -272,7 +274,7 @@ WITH evt_data_1 AS ( END AS trigger_price, acceptable_price AS acceptable_price_raw, CASE - WHEN index_token_decimals IS NULL THEN NULL + WHEN index_token_decimals IS NULL THEN NULL ELSE acceptable_price / POWER(10, 30 - index_token_decimals) END AS acceptable_price, execution_fee / POWER(10, 18) AS execution_fee, @@ -284,9 +286,14 @@ WITH evt_data_1 AS ( WHEN updated_at_time = 0 THEN NULL ELSE updated_at_time END AS updated_at_time, + valid_from_time, is_long, should_unwrap_native_token, - is_frozen, + + CASE + WHEN auto_cancel IS NULL THEN false + ELSE auto_cancel + END AS auto_cancel, key FROM event_data AS ED diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql index 5f0b28869f7..0f56ec17a91 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql @@ -58,7 +58,8 @@ WITH evt_data_1 AS ( index, json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, - json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items, + json_query(data, 'lax $.boolItems' OMIT QUOTES) AS bool_items FROM evt_data ) @@ -102,6 +103,19 @@ WITH evt_data_1 AS ( ) AS t(item) ) +, bool_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bool_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + , combined AS ( SELECT * FROM bytes32_items_parsed @@ -111,6 +125,9 @@ WITH evt_data_1 AS ( UNION ALL SELECT * FROM uint_items_parsed + UNION ALL + SELECT * + FROM bool_items_parsed ) , evt_data_parsed AS ( @@ -123,7 +140,9 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'acceptablePrice' THEN value END) AS acceptable_price, MAX(CASE WHEN key_name = 'triggerPrice' THEN value END) AS trigger_price, MAX(CASE WHEN key_name = 'minOutputAmount' THEN value END) AS min_output_amount, - MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time, + MAX(CASE WHEN key_name = 'validFromTime' THEN value END) AS valid_from_time, + MAX(CASE WHEN key_name = 'autoCancel' THEN value END) AS auto_cancel FROM combined GROUP BY tx_hash, index @@ -147,7 +166,9 @@ WITH evt_data_1 AS ( TRY_CAST(acceptable_price AS DOUBLE) AS acceptable_price, TRY_CAST(trigger_price AS DOUBLE) AS trigger_price, TRY_CAST(min_output_amount AS DOUBLE) AS min_output_amount, - TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time, + TRY_CAST(valid_from_time AS DOUBLE) AS valid_from_time, + TRY_CAST(auto_cancel AS BOOLEAN) AS auto_cancel FROM evt_data AS ED LEFT JOIN evt_data_parsed AS EDP @@ -186,7 +207,9 @@ WITH evt_data_1 AS ( CASE WHEN ED.updated_at_time = 0 THEN NULL ELSE ED.updated_at_time - END AS updated_at_time + END AS updated_at_time, + ED.valid_from_time, + ED.auto_cancel FROM event_data AS ED LEFT JOIN {{ ref('gmx_v2_avalanche_c_order_created') }} AS OC diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_collected.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_collected.sql index 2241dfb0e56..5e19b65ebfd 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_collected.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_collected.sql @@ -135,19 +135,19 @@ WITH evt_data_1 AS ( tx_hash, index, + MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, + MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, + MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, MAX(CASE WHEN key_name = 'affiliate' THEN value END) AS affiliate, MAX(CASE WHEN key_name = 'trader' THEN value END) AS trader, MAX(CASE WHEN key_name = 'uiFeeReceiver' THEN value END) AS ui_fee_receiver, + MAX(CASE WHEN key_name = 'collateralTokenPrice.min' THEN value END) AS collateral_token_price_min, MAX(CASE WHEN key_name = 'collateralTokenPrice.max' THEN value END) AS collateral_token_price_max, MAX(CASE WHEN key_name = 'tradeSizeUsd' THEN value END) AS trade_size_usd, - MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, - MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, - MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, - MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, - MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, MAX(CASE WHEN key_name = 'fundingFeeAmount' THEN value END) AS funding_fee_amount, MAX(CASE WHEN key_name = 'claimableLongTokenAmount' THEN value END) AS claimable_long_token_amount, MAX(CASE WHEN key_name = 'claimableShortTokenAmount' THEN value END) AS claimable_short_token_amount, @@ -168,10 +168,28 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'totalCostAmount' THEN value END) AS total_cost_amount, MAX(CASE WHEN key_name = 'uiFeeReceiverFactor' THEN value END) AS ui_fee_receiver_factor, MAX(CASE WHEN key_name = 'uiFeeAmount' THEN value END) AS ui_fee_amount, - MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase, - MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, - MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, - MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code + + MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, + MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, + MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, + MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, + MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'referral.totalRebateFactor' THEN value END) AS referral_total_rebate_factor, + MAX(CASE WHEN key_name = 'referral.adjustedAffiliateRewardFactor' THEN value END) AS referral_adjusted_affiliate_reward_factor, + MAX(CASE WHEN key_name = 'referral.traderDiscountFactor' THEN value END) AS referral_trader_discount_factor, + MAX(CASE WHEN key_name = 'referral.totalRebateAmount' THEN value END) AS referral_total_rebate_amount, + MAX(CASE WHEN key_name = 'referral.traderDiscountAmount' THEN value END) AS referral_trader_discount_amount, + MAX(CASE WHEN key_name = 'referral.affiliateRewardAmount' THEN value END) AS referral_affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'pro.traderDiscountFactor' THEN value END) AS pro_trader_discount_factor, + MAX(CASE WHEN key_name = 'pro.traderDiscountAmount' THEN value END) AS pro_trader_discount_amount, + + MAX(CASE WHEN key_name = 'liquidationFeeAmount' THEN value END) AS liquidation_fee_amount, + MAX(CASE WHEN key_name = 'liquidationFeeReceiverFactor' THEN value END) AS liquidation_fee_receiver_factor, + MAX(CASE WHEN key_name = 'liquidationFeeAmountForFeeReceiver' THEN value END) AS liquidation_fee_amount_for_fee_receiver, + + MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase FROM combined @@ -190,19 +208,19 @@ WITH evt_data_1 AS ( event_name, msg_sender, + from_hex(order_key) AS order_key, + from_hex(position_key) AS position_key, + from_hex(referral_code) AS referral_code, + from_hex(market) AS market, from_hex(collateral_token) AS collateral_token, from_hex(affiliate) AS affiliate, from_hex(trader) AS trader, from_hex(ui_fee_receiver) AS ui_fee_receiver, + TRY_CAST(collateral_token_price_min AS DOUBLE) AS collateral_token_price_min, TRY_CAST(collateral_token_price_max AS DOUBLE) AS collateral_token_price_max, TRY_CAST(trade_size_usd AS DOUBLE) AS trade_size_usd, - TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, - TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, - TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, - TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, - TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, TRY_CAST(funding_fee_amount AS DOUBLE) AS funding_fee_amount, TRY_CAST(claimable_long_token_amount AS DOUBLE) AS claimable_long_token_amount, TRY_CAST(claimable_short_token_amount AS DOUBLE) AS claimable_short_token_amount, @@ -223,11 +241,29 @@ WITH evt_data_1 AS ( TRY_CAST(total_cost_amount AS DOUBLE) AS total_cost_amount, TRY_CAST(ui_fee_receiver_factor AS DOUBLE) AS ui_fee_receiver_factor, TRY_CAST(ui_fee_amount AS DOUBLE) AS ui_fee_amount, - TRY_CAST(is_increase AS BOOLEAN) AS is_increase, - from_hex(order_key) AS order_key, - from_hex(position_key) AS position_key, - from_hex(referral_code) AS referral_code - + + TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, + TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, + TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, + TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, + TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, + + TRY_CAST(referral_total_rebate_factor AS DOUBLE) AS referral_total_rebate_factor, + TRY_CAST(referral_adjusted_affiliate_reward_factor AS DOUBLE) AS referral_adjusted_affiliate_reward_factor, + TRY_CAST(referral_trader_discount_factor AS DOUBLE) AS referral_trader_discount_factor, + TRY_CAST(referral_total_rebate_amount AS DOUBLE) AS referral_total_rebate_amount, + TRY_CAST(referral_trader_discount_amount AS DOUBLE) AS referral_trader_discount_amount, + TRY_CAST(referral_affiliate_reward_amount AS DOUBLE) AS referral_affiliate_reward_amount, + + TRY_CAST(pro_trader_discount_factor AS DOUBLE) AS pro_trader_discount_factor, + TRY_CAST(pro_trader_discount_amount AS DOUBLE) AS pro_trader_discount_amount, + + TRY_CAST(liquidation_fee_amount AS DOUBLE) AS liquidation_fee_amount, + TRY_CAST(liquidation_fee_receiver_factor AS DOUBLE) AS liquidation_fee_receiver_factor, + TRY_CAST(liquidation_fee_amount_for_fee_receiver AS DOUBLE) AS liquidation_fee_amount_for_fee_receiver, + + TRY_CAST(is_increase AS BOOLEAN) AS is_increase + FROM evt_data AS ED LEFT JOIN evt_data_parsed AS EDP ON ED.tx_hash = EDP.tx_hash @@ -247,6 +283,10 @@ WITH evt_data_1 AS ( event_name, msg_sender, + order_key, + position_key, + referral_code, + ED.market AS market, ED.collateral_token, affiliate, @@ -255,12 +295,7 @@ WITH evt_data_1 AS ( collateral_token_price_min / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_min, collateral_token_price_max / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_max, - trade_size_usd / POWER(10, 30) AS trade_size_usd, - total_rebate_factor / POWER(10, 30) AS total_rebate_factor, - trader_discount_factor / POWER(10, 30) AS trader_discount_factor, - total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, - trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, - affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + trade_size_usd / POWER(10, 30) AS trade_size_usd, funding_fee_amount / POWER(10, collateral_token_decimals + 15) AS funding_fee_amount, claimable_long_token_amount / POWER(10, long_token_decimals + 15) AS claimable_long_token_amount, claimable_short_token_amount / POWER(10, short_token_decimals + 15) AS claimable_short_token_amount, @@ -281,11 +316,29 @@ WITH evt_data_1 AS ( total_cost_amount / POWER(10, collateral_token_decimals) AS total_cost_amount, ui_fee_receiver_factor / POWER(10, 30) AS ui_fee_receiver_factor, ui_fee_amount / POWER(10, collateral_token_decimals) AS ui_fee_amount, - is_increase, - order_key, - position_key, - referral_code + + total_rebate_factor / POWER(10, 30) AS total_rebate_factor, + trader_discount_factor / POWER(10, 30) AS trader_discount_factor, + total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, + trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, + affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + + referral_total_rebate_factor / POWER(10, 30) AS referral_total_rebate_factor, + referral_adjusted_affiliate_reward_factor / POWER(10, 30) AS referral_adjusted_affiliate_reward_factor, + referral_trader_discount_factor / POWER(10, 30) AS referral_trader_discount_factor, + referral_total_rebate_amount / POWER(10, collateral_token_decimals) AS referral_total_rebate_amount, + referral_trader_discount_amount / POWER(10, collateral_token_decimals) AS referral_trader_discount_amount, + referral_affiliate_reward_amount / POWER(10, collateral_token_decimals) AS referral_affiliate_reward_amount, + pro_trader_discount_factor / POWER(10, 30) AS pro_trader_discount_factor, + pro_trader_discount_amount / POWER(10, collateral_token_decimals) AS pro_trader_discount_amount, + + liquidation_fee_amount / POWER(10, collateral_token_decimals) AS liquidation_fee_amount, + liquidation_fee_receiver_factor / POWER(10, 30) AS liquidation_fee_receiver_factor, + liquidation_fee_amount_for_fee_receiver / POWER(10, collateral_token_decimals) AS liquidation_fee_amount_for_fee_receiver, + + is_increase + FROM event_data AS ED LEFT JOIN {{ ref('gmx_v2_avalanche_c_markets_data') }} AS MD ON ED.market = MD.market @@ -293,11 +346,100 @@ WITH evt_data_1 AS ( ON ED.collateral_token = CTD.collateral_token ) +, full_data_2 AS ( + SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + order_key, + position_key, + referral_code, + + market, + collateral_token, + affiliate, + trader, + ui_fee_receiver, + + collateral_token_price_min, + collateral_token_price_max, + trade_size_usd, + funding_fee_amount, + claimable_long_token_amount, + claimable_short_token_amount, + latest_funding_fee_amount_per_size, + latest_long_token_claimable_funding_amount_per_size, + latest_short_token_claimable_funding_amount_per_size, + borrowing_fee_usd, + borrowing_fee_amount, + borrowing_fee_receiver_factor, + borrowing_fee_amount_for_fee_receiver, + position_fee_factor, + protocol_fee_amount, + position_fee_receiver_factor, + fee_receiver_amount, + fee_amount_for_pool, + position_fee_amount_for_pool, + position_fee_amount, + total_cost_amount, + ui_fee_receiver_factor, + ui_fee_amount, + + CASE + WHEN total_rebate_factor IS NOT NULL THEN total_rebate_factor + WHEN referral_total_rebate_factor IS NOT NULL THEN referral_total_rebate_factor + ELSE 0 + END AS referral_total_rebate_factor, + CASE + WHEN total_rebate_amount IS NOT NULL THEN total_rebate_amount + WHEN referral_total_rebate_amount IS NOT NULL THEN referral_total_rebate_amount + ELSE 0 + END AS referral_total_rebate_amount, + CASE + WHEN referral_trader_discount_factor IS NOT NULL THEN referral_trader_discount_factor + WHEN trader_discount_factor IS NOT NULL THEN trader_discount_factor * total_rebate_factor + ELSE 0 + END AS referral_trader_discount_factor, + CASE + WHEN referral_adjusted_affiliate_reward_factor IS NOT NULL THEN referral_adjusted_affiliate_reward_factor + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_adjusted_affiliate_reward_factor, + CASE + WHEN referral_affiliate_reward_amount IS NOT NULL THEN referral_affiliate_reward_amount + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_affiliate_reward_amount, + CASE + WHEN referral_trader_discount_amount IS NOT NULL THEN referral_trader_discount_amount + WHEN trader_discount_amount IS NOT NULL THEN trader_discount_amount + ELSE 0 + END AS referral_trader_discount_amount, + + COALESCE(pro_trader_discount_factor, 0) AS pro_trader_discount_factor, + COALESCE(pro_trader_discount_amount, 0) AS pro_trader_discount_amount, + + COALESCE(liquidation_fee_amount, 0) AS liquidation_fee_amount, + COALESCE(liquidation_fee_receiver_factor, 0) AS liquidation_fee_receiver_factor, + COALESCE(liquidation_fee_amount_for_fee_receiver, 0) AS liquidation_fee_amount_for_fee_receiver, + + is_increase + + FROM full_data +) + --can be removed once decoded tables are fully denormalized {{ add_tx_columns( - model_cte = 'full_data' + model_cte = 'full_data_2' , blockchain = blockchain_name , columns = ['from', 'to'] ) -}} +}} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_info.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_info.sql index 0e71e6ccfdf..6dff079f071 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_info.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_position_fees_info.sql @@ -135,19 +135,20 @@ WITH evt_data_1 AS ( tx_hash, index, + MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, + MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, + MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code, + MAX(CASE WHEN key_name = 'market' THEN value END) AS market, MAX(CASE WHEN key_name = 'collateralToken' THEN value END) AS collateral_token, MAX(CASE WHEN key_name = 'affiliate' THEN value END) AS affiliate, MAX(CASE WHEN key_name = 'trader' THEN value END) AS trader, MAX(CASE WHEN key_name = 'uiFeeReceiver' THEN value END) AS ui_fee_receiver, + MAX(CASE WHEN key_name = 'collateralTokenPrice.min' THEN value END) AS collateral_token_price_min, MAX(CASE WHEN key_name = 'collateralTokenPrice.max' THEN value END) AS collateral_token_price_max, MAX(CASE WHEN key_name = 'tradeSizeUsd' THEN value END) AS trade_size_usd, - MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, - MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, - MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, - MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, - MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, + MAX(CASE WHEN key_name = 'fundingFeeAmount' THEN value END) AS funding_fee_amount, MAX(CASE WHEN key_name = 'claimableLongTokenAmount' THEN value END) AS claimable_long_token_amount, MAX(CASE WHEN key_name = 'claimableShortTokenAmount' THEN value END) AS claimable_short_token_amount, @@ -168,10 +169,28 @@ WITH evt_data_1 AS ( MAX(CASE WHEN key_name = 'totalCostAmount' THEN value END) AS total_cost_amount, MAX(CASE WHEN key_name = 'uiFeeReceiverFactor' THEN value END) AS ui_fee_receiver_factor, MAX(CASE WHEN key_name = 'uiFeeAmount' THEN value END) AS ui_fee_amount, - MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase, - MAX(CASE WHEN key_name = 'orderKey' THEN value END) AS order_key, - MAX(CASE WHEN key_name = 'positionKey' THEN value END) AS position_key, - MAX(CASE WHEN key_name = 'referralCode' THEN value END) AS referral_code + + MAX(CASE WHEN key_name = 'totalRebateFactor' THEN value END) AS total_rebate_factor, + MAX(CASE WHEN key_name = 'traderDiscountFactor' THEN value END) AS trader_discount_factor, + MAX(CASE WHEN key_name = 'totalRebateAmount' THEN value END) AS total_rebate_amount, + MAX(CASE WHEN key_name = 'traderDiscountAmount' THEN value END) AS trader_discount_amount, + MAX(CASE WHEN key_name = 'affiliateRewardAmount' THEN value END) AS affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'referral.totalRebateFactor' THEN value END) AS referral_total_rebate_factor, + MAX(CASE WHEN key_name = 'referral.adjustedAffiliateRewardFactor' THEN value END) AS referral_adjusted_affiliate_reward_factor, + MAX(CASE WHEN key_name = 'referral.traderDiscountFactor' THEN value END) AS referral_trader_discount_factor, + MAX(CASE WHEN key_name = 'referral.totalRebateAmount' THEN value END) AS referral_total_rebate_amount, + MAX(CASE WHEN key_name = 'referral.traderDiscountAmount' THEN value END) AS referral_trader_discount_amount, + MAX(CASE WHEN key_name = 'referral.affiliateRewardAmount' THEN value END) AS referral_affiliate_reward_amount, + + MAX(CASE WHEN key_name = 'pro.traderDiscountFactor' THEN value END) AS pro_trader_discount_factor, + MAX(CASE WHEN key_name = 'pro.traderDiscountAmount' THEN value END) AS pro_trader_discount_amount, + + MAX(CASE WHEN key_name = 'liquidationFeeAmount' THEN value END) AS liquidation_fee_amount, + MAX(CASE WHEN key_name = 'liquidationFeeReceiverFactor' THEN value END) AS liquidation_fee_receiver_factor, + MAX(CASE WHEN key_name = 'liquidationFeeAmountForFeeReceiver' THEN value END) AS liquidation_fee_amount_for_fee_receiver, + + MAX(CASE WHEN key_name = 'isIncrease' THEN value END) AS is_increase FROM combined @@ -190,19 +209,19 @@ WITH evt_data_1 AS ( event_name, msg_sender, + from_hex(order_key) AS order_key, + from_hex(position_key) AS position_key, + from_hex(referral_code) AS referral_code, + from_hex(market) AS market, from_hex(collateral_token) AS collateral_token, from_hex(affiliate) AS affiliate, from_hex(trader) AS trader, from_hex(ui_fee_receiver) AS ui_fee_receiver, + TRY_CAST(collateral_token_price_min AS DOUBLE) AS collateral_token_price_min, TRY_CAST(collateral_token_price_max AS DOUBLE) AS collateral_token_price_max, TRY_CAST(trade_size_usd AS DOUBLE) AS trade_size_usd, - TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, - TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, - TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, - TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, - TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, TRY_CAST(funding_fee_amount AS DOUBLE) AS funding_fee_amount, TRY_CAST(claimable_long_token_amount AS DOUBLE) AS claimable_long_token_amount, TRY_CAST(claimable_short_token_amount AS DOUBLE) AS claimable_short_token_amount, @@ -223,11 +242,29 @@ WITH evt_data_1 AS ( TRY_CAST(total_cost_amount AS DOUBLE) AS total_cost_amount, TRY_CAST(ui_fee_receiver_factor AS DOUBLE) AS ui_fee_receiver_factor, TRY_CAST(ui_fee_amount AS DOUBLE) AS ui_fee_amount, - TRY_CAST(is_increase AS BOOLEAN) AS is_increase, - from_hex(order_key) AS order_key, - from_hex(position_key) AS position_key, - from_hex(referral_code) AS referral_code - + + TRY_CAST(total_rebate_factor AS DOUBLE) AS total_rebate_factor, + TRY_CAST(trader_discount_factor AS DOUBLE) AS trader_discount_factor, + TRY_CAST(total_rebate_amount AS DOUBLE) AS total_rebate_amount, + TRY_CAST(trader_discount_amount AS DOUBLE) AS trader_discount_amount, + TRY_CAST(affiliate_reward_amount AS DOUBLE) AS affiliate_reward_amount, + + TRY_CAST(referral_total_rebate_factor AS DOUBLE) AS referral_total_rebate_factor, + TRY_CAST(referral_adjusted_affiliate_reward_factor AS DOUBLE) AS referral_adjusted_affiliate_reward_factor, + TRY_CAST(referral_trader_discount_factor AS DOUBLE) AS referral_trader_discount_factor, + TRY_CAST(referral_total_rebate_amount AS DOUBLE) AS referral_total_rebate_amount, + TRY_CAST(referral_trader_discount_amount AS DOUBLE) AS referral_trader_discount_amount, + TRY_CAST(referral_affiliate_reward_amount AS DOUBLE) AS referral_affiliate_reward_amount, + + TRY_CAST(pro_trader_discount_factor AS DOUBLE) AS pro_trader_discount_factor, + TRY_CAST(pro_trader_discount_amount AS DOUBLE) AS pro_trader_discount_amount, + + TRY_CAST(liquidation_fee_amount AS DOUBLE) AS liquidation_fee_amount, + TRY_CAST(liquidation_fee_receiver_factor AS DOUBLE) AS liquidation_fee_receiver_factor, + TRY_CAST(liquidation_fee_amount_for_fee_receiver AS DOUBLE) AS liquidation_fee_amount_for_fee_receiver, + + TRY_CAST(is_increase AS BOOLEAN) AS is_increase + FROM evt_data AS ED LEFT JOIN evt_data_parsed AS EDP ON ED.tx_hash = EDP.tx_hash @@ -247,6 +284,10 @@ WITH evt_data_1 AS ( event_name, msg_sender, + order_key, + position_key, + referral_code, + ED.market AS market, ED.collateral_token, affiliate, @@ -255,12 +296,7 @@ WITH evt_data_1 AS ( collateral_token_price_min / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_min, collateral_token_price_max / POWER(10, 30 - collateral_token_decimals) AS collateral_token_price_max, - trade_size_usd / POWER(10, 30) AS trade_size_usd, - total_rebate_factor / POWER(10, 30) AS total_rebate_factor, - trader_discount_factor / POWER(10, 30) AS trader_discount_factor, - total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, - trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, - affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + trade_size_usd / POWER(10, 30) AS trade_size_usd, funding_fee_amount / POWER(10, collateral_token_decimals + 15) AS funding_fee_amount, claimable_long_token_amount / POWER(10, long_token_decimals + 15) AS claimable_long_token_amount, claimable_short_token_amount / POWER(10, short_token_decimals + 15) AS claimable_short_token_amount, @@ -281,10 +317,28 @@ WITH evt_data_1 AS ( total_cost_amount / POWER(10, collateral_token_decimals) AS total_cost_amount, ui_fee_receiver_factor / POWER(10, 30) AS ui_fee_receiver_factor, ui_fee_amount / POWER(10, collateral_token_decimals) AS ui_fee_amount, - is_increase, - order_key, - position_key, - referral_code + + total_rebate_factor / POWER(10, 30) AS total_rebate_factor, + trader_discount_factor / POWER(10, 30) AS trader_discount_factor, + total_rebate_amount / POWER(10, collateral_token_decimals) AS total_rebate_amount, + trader_discount_amount / POWER(10, collateral_token_decimals) AS trader_discount_amount, + affiliate_reward_amount / POWER(10, collateral_token_decimals) AS affiliate_reward_amount, + + referral_total_rebate_factor / POWER(10, 30) AS referral_total_rebate_factor, + referral_adjusted_affiliate_reward_factor / POWER(10, 30) AS referral_adjusted_affiliate_reward_factor, + referral_trader_discount_factor / POWER(10, 30) AS referral_trader_discount_factor, + referral_total_rebate_amount / POWER(10, collateral_token_decimals) AS referral_total_rebate_amount, + referral_trader_discount_amount / POWER(10, collateral_token_decimals) AS referral_trader_discount_amount, + referral_affiliate_reward_amount / POWER(10, collateral_token_decimals) AS referral_affiliate_reward_amount, + + pro_trader_discount_factor / POWER(10, 30) AS pro_trader_discount_factor, + pro_trader_discount_amount / POWER(10, collateral_token_decimals) AS pro_trader_discount_amount, + + liquidation_fee_amount / POWER(10, collateral_token_decimals) AS liquidation_fee_amount, + liquidation_fee_receiver_factor / POWER(10, 30) AS liquidation_fee_receiver_factor, + liquidation_fee_amount_for_fee_receiver / POWER(10, collateral_token_decimals) AS liquidation_fee_amount_for_fee_receiver, + + is_increase FROM event_data AS ED LEFT JOIN {{ ref('gmx_v2_avalanche_c_markets_data') }} AS MD @@ -293,11 +347,100 @@ WITH evt_data_1 AS ( ON ED.collateral_token = CTD.collateral_token ) +, full_data_2 AS ( + SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + event_name, + msg_sender, + + order_key, + position_key, + referral_code, + + market, + collateral_token, + affiliate, + trader, + ui_fee_receiver, + + collateral_token_price_min, + collateral_token_price_max, + trade_size_usd, + funding_fee_amount, + claimable_long_token_amount, + claimable_short_token_amount, + latest_funding_fee_amount_per_size, + latest_long_token_claimable_funding_amount_per_size, + latest_short_token_claimable_funding_amount_per_size, + borrowing_fee_usd, + borrowing_fee_amount, + borrowing_fee_receiver_factor, + borrowing_fee_amount_for_fee_receiver, + position_fee_factor, + protocol_fee_amount, + position_fee_receiver_factor, + fee_receiver_amount, + fee_amount_for_pool, + position_fee_amount_for_pool, + position_fee_amount, + total_cost_amount, + ui_fee_receiver_factor, + ui_fee_amount, + + CASE + WHEN total_rebate_factor IS NOT NULL THEN total_rebate_factor + WHEN referral_total_rebate_factor IS NOT NULL THEN referral_total_rebate_factor + ELSE 0 + END AS referral_total_rebate_factor, + CASE + WHEN total_rebate_amount IS NOT NULL THEN total_rebate_amount + WHEN referral_total_rebate_amount IS NOT NULL THEN referral_total_rebate_amount + ELSE 0 + END AS referral_total_rebate_amount, + CASE + WHEN referral_trader_discount_factor IS NOT NULL THEN referral_trader_discount_factor + WHEN trader_discount_factor IS NOT NULL THEN trader_discount_factor * total_rebate_factor + ELSE 0 + END AS referral_trader_discount_factor, + CASE + WHEN referral_adjusted_affiliate_reward_factor IS NOT NULL THEN referral_adjusted_affiliate_reward_factor + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_adjusted_affiliate_reward_factor, + CASE + WHEN referral_affiliate_reward_amount IS NOT NULL THEN referral_affiliate_reward_amount + WHEN affiliate_reward_amount IS NOT NULL THEN affiliate_reward_amount + ELSE 0 + END AS referral_affiliate_reward_amount, + CASE + WHEN referral_trader_discount_amount IS NOT NULL THEN referral_trader_discount_amount + WHEN trader_discount_amount IS NOT NULL THEN trader_discount_amount + ELSE 0 + END AS referral_trader_discount_amount, + + COALESCE(pro_trader_discount_factor, 0) AS pro_trader_discount_factor, + COALESCE(pro_trader_discount_amount, 0) AS pro_trader_discount_amount, + + COALESCE(liquidation_fee_amount, 0) AS liquidation_fee_amount, + COALESCE(liquidation_fee_receiver_factor, 0) AS liquidation_fee_receiver_factor, + COALESCE(liquidation_fee_amount_for_fee_receiver, 0) AS liquidation_fee_amount_for_fee_receiver, + + is_increase + + FROM full_data +) + --can be removed once decoded tables are fully denormalized {{ add_tx_columns( - model_cte = 'full_data' + model_cte = 'full_data_2' , blockchain = blockchain_name , columns = ['from', 'to'] ) -}} +}} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml index bbe86ebd151..c772b056d86 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml @@ -153,11 +153,11 @@ models: - not_null - name: updated_at_block description: The block number at which the order was last updated. - data_tests: - - not_null - &updated_at_time name: updated_at_time description: The timestamp when the order was last updated. + - name: valid_from_time + description: The time from which the order becomes valid for execution. - &is_long name: is_long description: A boolean indicating whether the position is long @@ -165,8 +165,8 @@ models: - not_null - name: should_unwrap_native_token description: Boolean indicating if the native token should be unwrapped. - - name: is_frozen - description: Boolean indicating if the order is frozen. + - name: auto_cancel + description: Boolean indicating whether the order will be automatically canceled under certain conditions. - &key name: key description: The unique identifier for the order, stored as a bytes32 value. @@ -604,31 +604,6 @@ models: description: The size of the trade in USD data_tests: - not_null - - &total_rebate_factor - name: total_rebate_factor - description: The total rebate factor for the position - data_tests: - - not_null - - &trader_discount_factor - name: trader_discount_factor - description: The discount factor applied to the trader - data_tests: - - not_null - - &total_rebate_amount - name: total_rebate_amount - description: The total amount of rebate given - data_tests: - - not_null - - &trader_discount_amount - name: trader_discount_amount - description: The amount of discount given to the trader - data_tests: - - not_null - - &affiliate_reward_amount - name: affiliate_reward_amount - description: The reward amount given to the affiliate - data_tests: - - not_null - &funding_fee_amount name: funding_fee_amount description: The amount of funding fee charged @@ -637,28 +612,18 @@ models: - &claimable_long_token_amount name: claimable_long_token_amount description: The amount of long tokens claimable - data_tests: - - not_null - &claimable_short_token_amount name: claimable_short_token_amount description: The amount of short tokens claimable - data_tests: - - not_null - &latest_funding_fee_amount_per_size name: latest_funding_fee_amount_per_size description: The latest funding fee amount per size - data_tests: - - not_null - &latest_long_token_claimable_funding_amount_per_size name: latest_long_token_claimable_funding_amount_per_size description: The latest claimable long token funding amount per size - data_tests: - - not_null - &latest_short_token_claimable_funding_amount_per_size name: latest_short_token_claimable_funding_amount_per_size description: The latest claimable short token funding amount per size - data_tests: - - not_null - &borrowing_fee_usd name: borrowing_fee_usd description: The borrowing fee amount in USD @@ -729,6 +694,61 @@ models: description: The total amount of UI fee collected data_tests: - not_null + - &referral_total_rebate_factor + name: referral_total_rebate_factor + description: The total rebate factor associated with referrals. + data_tests: + - not_null + - &referral_total_rebate_amount + name: referral_total_rebate_amount + description: The total rebate amount given for referrals. + data_tests: + - not_null + - &referral_trader_discount_factor + name: referral_trader_discount_factor + description: The discount factor applied to the trader through referrals. + data_tests: + - not_null + - &referral_adjusted_affiliate_reward_factor + name: referral_adjusted_affiliate_reward_factor + description: The adjusted affiliate reward factor based on referral criteria. + data_tests: + - not_null + - &referral_affiliate_reward_amount + name: referral_affiliate_reward_amount + description: The reward amount given to the affiliate for referrals. + data_tests: + - not_null + - &referral_trader_discount_amount + name: referral_trader_discount_amount + description: The discount amount given to the trader through referrals. + data_tests: + - not_null + - &pro_trader_discount_factor + name: pro_trader_discount_factor + description: The discount factor applied for pro traders. + data_tests: + - not_null + - &pro_trader_discount_amount + name: pro_trader_discount_amount + description: The discount amount given to pro traders. + data_tests: + - not_null + - &liquidation_fee_amount + name: liquidation_fee_amount + description: The amount of fees charged during liquidation. + data_tests: + - not_null + - &liquidation_fee_receiver_factor + name: liquidation_fee_receiver_factor + description: The factor used to calculate the liquidation fee allocated to the receiver. + data_tests: + - not_null + - &liquidation_fee_amount_for_fee_receiver + name: liquidation_fee_amount_for_fee_receiver + description: The amount of liquidation fee allocated to the fee receiver. + data_tests: + - not_null - &is_increase name: is_increase description: Indicates whether the position is increased (true) or decreased (false) @@ -785,11 +805,6 @@ models: - *collateral_token_price_min - *collateral_token_price_max - *trade_size_usd - - *total_rebate_factor - - *trader_discount_factor - - *total_rebate_amount - - *trader_discount_amount - - *affiliate_reward_amount - *funding_fee_amount - *claimable_long_token_amount - *claimable_short_token_amount @@ -810,6 +825,17 @@ models: - *total_cost_amount - *ui_fee_receiver_factor - *ui_fee_amount + - *referral_total_rebate_factor + - *referral_total_rebate_amount + - *referral_trader_discount_factor + - *referral_adjusted_affiliate_reward_factor + - *referral_affiliate_reward_amount + - *referral_trader_discount_amount + - *pro_trader_discount_factor + - *pro_trader_discount_amount + - *liquidation_fee_amount + - *liquidation_fee_receiver_factor + - *liquidation_fee_amount_for_fee_receiver - *is_increase - *order_key - *position_key @@ -909,4 +935,8 @@ models: - *acceptable_price_raw - *acceptable_price - *min_output_amount_raw - - *updated_at_time \ No newline at end of file + - *updated_at_time + - name: valid_from_time + description: The time from which the order becomes valid for execution. + - name: auto_cancel + description: Boolean indicating whether the order will be automatically canceled under certain conditions. \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql index 9f95d34ebbd..11d0a609f05 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql @@ -46,9 +46,10 @@ SELECT min_output_amount_raw, updated_at_block, updated_at_time, + valid_from_time, is_long, should_unwrap_native_token, - is_frozen, + auto_cancel, key FROM {{ ref('gmx_v2_' ~ chain ~ '_order_created') }} {% if not loop.last %} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql index 9481e7bc1b6..c456c7dcc75 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql @@ -34,8 +34,9 @@ SELECT trigger_price, trigger_price_raw, min_output_amount_raw, - updated_at_time - + updated_at_time, + valid_from_time, + auto_cancel FROM {{ ref('gmx_v2_' ~ chain ~ '_order_updated') }} {% if not loop.last %} UNION ALL diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_collected.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_collected.sql index 78e89d3a511..c54fcae240e 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_collected.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_collected.sql @@ -34,11 +34,6 @@ SELECT collateral_token_price_min, collateral_token_price_max, trade_size_usd, - total_rebate_factor, - trader_discount_factor, - total_rebate_amount, - trader_discount_amount, - affiliate_reward_amount, funding_fee_amount, claimable_long_token_amount, claimable_short_token_amount, @@ -59,6 +54,17 @@ SELECT total_cost_amount, ui_fee_receiver_factor, ui_fee_amount, + referral_total_rebate_factor, + referral_total_rebate_amount, + referral_trader_discount_factor, + referral_adjusted_affiliate_reward_factor, + referral_affiliate_reward_amount, + referral_trader_discount_amount, + pro_trader_discount_factor, + pro_trader_discount_amount, + liquidation_fee_amount, + liquidation_fee_receiver_factor, + liquidation_fee_amount_for_fee_receiver, is_increase, order_key, position_key, diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_info.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_info.sql index 917113693ac..9ae7458454b 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_info.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_position_fees_info.sql @@ -34,11 +34,6 @@ SELECT collateral_token_price_min, collateral_token_price_max, trade_size_usd, - total_rebate_factor, - trader_discount_factor, - total_rebate_amount, - trader_discount_amount, - affiliate_reward_amount, funding_fee_amount, claimable_long_token_amount, claimable_short_token_amount, @@ -59,6 +54,17 @@ SELECT total_cost_amount, ui_fee_receiver_factor, ui_fee_amount, + referral_total_rebate_factor, + referral_total_rebate_amount, + referral_trader_discount_factor, + referral_adjusted_affiliate_reward_factor, + referral_affiliate_reward_amount, + referral_trader_discount_amount, + pro_trader_discount_factor, + pro_trader_discount_amount, + liquidation_fee_amount, + liquidation_fee_receiver_factor, + liquidation_fee_amount_for_fee_receiver, is_increase, order_key, position_key, @@ -67,4 +73,4 @@ FROM {{ ref('gmx_v2_' ~ chain ~ '_position_fees_info') }} {% if not loop.last %} UNION ALL {% endif %} -{%- endfor -%} \ No newline at end of file +{%- endfor -%}