Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update Event Models for GMX v2 #7511

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2134,6 +2134,10 @@ models:
description: The address of the callback contract associated with the withdrawal.
- name: market
description: The market associated with the withdrawal.
- name: long_token_swap_path
description: The swap path for the long token.
- name: short_token_swap_path
description: The swap path for the short token.
- name: market_token_amount
description: The amount of market tokens involved in the withdrawal.
- name: min_long_token_amount
Expand All @@ -2146,6 +2150,8 @@ models:
description: The execution fee for processing the withdrawal.
- name: callback_gas_limit
description: The gas limit for the callback associated with the withdrawal.
- name: withdrawal_type
description: The type of withdrawal created.
- name: should_unwrap_native_token
description: Indicates whether the native token should be unwrapped.
- name: key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,16 @@ WITH evt_data_1 AS (
MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver,
MAX(CASE WHEN key_name = 'callbackContract' THEN value END) AS callback_contract,
MAX(CASE WHEN key_name = 'market' THEN value END) AS market,
MAX(CASE WHEN key_name = 'longTokenSwapPath' THEN value END) AS long_token_swap_path,
MAX(CASE WHEN key_name = 'shortTokenSwapPath' THEN value END) AS short_token_swap_path,

MAX(CASE WHEN key_name = 'marketTokenAmount' THEN value END) AS market_token_amount,
MAX(CASE WHEN key_name = 'minLongTokenAmount' THEN value END) AS min_long_token_amount,
MAX(CASE WHEN key_name = 'minShortTokenAmount' THEN value END) AS min_short_token_amount,
MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time,
MAX(CASE WHEN key_name = 'executionFee' THEN value END) AS execution_fee,
MAX(CASE WHEN key_name = 'callbackGasLimit' THEN value END) AS callback_gas_limit,
MAX(CASE WHEN key_name = 'withdrawalType' THEN value END) AS withdrawal_type,

MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token,

Expand All @@ -178,13 +181,16 @@ WITH evt_data_1 AS (
from_hex(receiver) AS receiver,
from_hex(callback_contract) AS callback_contract,
from_hex(market) AS market,
long_token_swap_path,
short_token_swap_path,

TRY_CAST(market_token_amount AS DOUBLE) market_token_amount, -- index_token_decimals (market?)
TRY_CAST(min_long_token_amount AS DOUBLE) min_long_token_amount, -- long_token_decimals
TRY_CAST(min_short_token_amount AS DOUBLE) min_short_token_amount, -- short_token_decimals
TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time,
TRY_CAST(execution_fee AS DOUBLE) AS execution_fee, -- POWER(10, 18)
TRY_CAST(callback_gas_limit AS DOUBLE) AS callback_gas_limit, -- no decimals, keep as raw values
TRY_CAST(withdrawal_type AS INTEGER) AS withdrawal_type,

TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token,

Expand Down Expand Up @@ -212,6 +218,8 @@ WITH evt_data_1 AS (
receiver,
callback_contract,
ED.market,
long_token_swap_path,
short_token_swap_path,

market_token_amount / POWER(10, 18) AS market_token_amount,
min_long_token_amount / POWER(10, MD.long_token_decimals) AS min_long_token_amount,
Expand All @@ -222,6 +230,7 @@ WITH evt_data_1 AS (
END AS updated_at_time,
execution_fee / POWER(10, 18) AS execution_fee,
callback_gas_limit,
withdrawal_type,

should_unwrap_native_token,
"key"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,10 @@ models:
description: The address of the callback contract associated with the withdrawal.
- name: market
description: The market associated with the withdrawal.
- name: long_token_swap_path
description: The swap path for the long token.
- name: short_token_swap_path
description: The swap path for the short token.
- name: market_token_amount
description: The amount of market tokens involved in the withdrawal.
- name: min_long_token_amount
Expand All @@ -2147,6 +2151,8 @@ models:
description: The execution fee for processing the withdrawal.
- name: callback_gas_limit
description: The gas limit for the callback associated with the withdrawal.
- name: withdrawal_type
description: The type of withdrawal created.
- name: should_unwrap_native_token
description: Indicates whether the native token should be unwrapped.
- name: key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,16 @@ WITH evt_data_1 AS (
MAX(CASE WHEN key_name = 'receiver' THEN value END) AS receiver,
MAX(CASE WHEN key_name = 'callbackContract' THEN value END) AS callback_contract,
MAX(CASE WHEN key_name = 'market' THEN value END) AS market,
MAX(CASE WHEN key_name = 'longTokenSwapPath' THEN value END) AS long_token_swap_path,
MAX(CASE WHEN key_name = 'shortTokenSwapPath' THEN value END) AS short_token_swap_path,

MAX(CASE WHEN key_name = 'marketTokenAmount' THEN value END) AS market_token_amount,
MAX(CASE WHEN key_name = 'minLongTokenAmount' THEN value END) AS min_long_token_amount,
MAX(CASE WHEN key_name = 'minShortTokenAmount' THEN value END) AS min_short_token_amount,
MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time,
MAX(CASE WHEN key_name = 'executionFee' THEN value END) AS execution_fee,
MAX(CASE WHEN key_name = 'callbackGasLimit' THEN value END) AS callback_gas_limit,
MAX(CASE WHEN key_name = 'withdrawalType' THEN value END) AS withdrawal_type,

MAX(CASE WHEN key_name = 'shouldUnwrapNativeToken' THEN value END) AS should_unwrap_native_token,

Expand All @@ -178,13 +181,16 @@ WITH evt_data_1 AS (
from_hex(receiver) AS receiver,
from_hex(callback_contract) AS callback_contract,
from_hex(market) AS market,
long_token_swap_path,
short_token_swap_path,

TRY_CAST(market_token_amount AS DOUBLE) market_token_amount, -- index_token_decimals (market?)
TRY_CAST(min_long_token_amount AS DOUBLE) min_long_token_amount, -- long_token_decimals
TRY_CAST(min_short_token_amount AS DOUBLE) min_short_token_amount, -- short_token_decimals
TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time,
TRY_CAST(execution_fee AS DOUBLE) AS execution_fee, -- POWER(10, 18)
TRY_CAST(callback_gas_limit AS DOUBLE) AS callback_gas_limit, -- no decimals, keep as raw values
TRY_CAST(withdrawal_type AS INTEGER) AS withdrawal_type,

TRY_CAST(should_unwrap_native_token AS BOOLEAN) AS should_unwrap_native_token,

Expand Down Expand Up @@ -212,6 +218,8 @@ WITH evt_data_1 AS (
receiver,
callback_contract,
ED.market,
long_token_swap_path,
short_token_swap_path,

market_token_amount / POWER(10, 18) AS market_token_amount,
min_long_token_amount / POWER(10, MD.long_token_decimals) AS min_long_token_amount,
Expand All @@ -222,6 +230,7 @@ WITH evt_data_1 AS (
END AS updated_at_time,
execution_fee / POWER(10, 18) AS execution_fee,
callback_gas_limit,
withdrawal_type,

should_unwrap_native_token,
"key"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,10 @@ models:
description: The address of the callback contract associated with the withdrawal.
- name: market
description: The market associated with the withdrawal.
- name: long_token_swap_path
description: The swap path for the long token.
- name: short_token_swap_path
description: The swap path for the short token.
- name: market_token_amount
description: The amount of market tokens involved in the withdrawal.
- name: min_long_token_amount
Expand All @@ -2024,6 +2028,8 @@ models:
description: The execution fee for processing the withdrawal.
- name: callback_gas_limit
description: The gas limit for the callback associated with the withdrawal.
- name: withdrawal_type
description: The type of withdrawal created.
- name: should_unwrap_native_token
description: Indicates whether the native token should be unwrapped.
- name: key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ SELECT
receiver,
callback_contract,
market,
long_token_swap_path,
short_token_swap_path,
market_token_amount,
min_long_token_amount,
min_short_token_amount,
updated_at_time,
execution_fee,
callback_gas_limit,
withdrawal_type,
should_unwrap_native_token,
"key"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
)
}}

{%- set url_path = 'https://arbitrum-api.gmxinfra.io/tokens/dune' -%}
{%- set blockchain_name = 'arbitrum' -%}

SELECT
'{{ blockchain_name }}' AS blockchain,
'gmx_v2' AS project,
json_extract_scalar(token, '$.symbol') AS symbol,
from_hex(json_extract_scalar(token, '$.address')) AS contract_address,
CAST(json_extract_scalar(token, '$.decimals') AS INTEGER) AS decimals,
COALESCE(CAST(json_extract_scalar(token, '$.synthetic') AS BOOLEAN), false) AS synthetic,
CURRENT_TIMESTAMP AS last_update_utc
FROM
UNNEST(CAST(json_parse(http_get('{{ url_path }}')) AS ARRAY(JSON))) AS t(token)
blockchain
, project
, symbol
, contract_address
, decimals
, synthetic
, last_update_utc
FROM {{ source('gmx-io', 'result_gmx_v_2_erc_20_from_api', database='dune') }}
WHERE blockchain = '{{ blockchain_name }}'
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
)
}}

{%- set url_path = 'https://avalanche-api.gmxinfra.io/tokens/dune' -%}
{%- set blockchain_name = 'avalanche_c' -%}

SELECT
'{{ blockchain_name }}' AS blockchain,
'gmx_v2' AS project,
json_extract_scalar(token, '$.symbol') AS symbol,
from_hex(json_extract_scalar(token, '$.address')) AS contract_address,
CAST(json_extract_scalar(token, '$.decimals') AS INTEGER) AS decimals,
COALESCE(CAST(json_extract_scalar(token, '$.synthetic') AS BOOLEAN), false) AS synthetic,
CURRENT_TIMESTAMP AS last_update_utc
FROM
UNNEST(CAST(json_parse(http_get('{{ url_path }}')) AS ARRAY(JSON))) AS t(token)
blockchain
, project
, symbol
, contract_address
, decimals
, synthetic
, last_update_utc
FROM {{ source('gmx-io', 'result_gmx_v_2_erc_20_from_api', database='dune') }}
WHERE blockchain = '{{ blockchain_name }}'
3 changes: 3 additions & 0 deletions sources/_datasets/dune/sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ sources:
- name: dune
tables:
- name: result_blockchains
- name: "gmx-io"
tables:
- name: result_gmx_v_2_erc_20_from_api
Loading