Skip to content

Commit

Permalink
Merge branch 'main' into phoenix-dex-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhong5297 committed Jun 23, 2024
2 parents bdb7f41 + d8c7b37 commit 13c318a
Show file tree
Hide file tree
Showing 2,001 changed files with 10,992 additions and 12,306 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/commit_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: [ self-hosted, linux, spellbook-trino-ci ]
strategy:
matrix:
project: [ 'tokens', 'spellbook', 'daily_spellbook']
project: [ 'tokens', 'spellbook', 'daily_spellbook', 'nft', 'dex', 'solana']
max-parallel: 1

steps:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/dbt_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ jobs:
run: "./scripts/ensure_cluster.sh"

- name: dbt compile to create manifest to compare to
run: "dbt --warn-error compile $PROFILE --project-dir ${PROJECT_DIR}"
run: "dbt --warn-error compile --project-dir ${PROJECT_DIR}"

- name: check schemas
run: |
test=$(dbt --quiet --no-print ls $PROFILE --resource-type model --select state:modified,config.schema:no_schema --output path --state . --project-dir ${PROJECT_DIR})
[[ -z "$test" ]] && { echo "Success: All models have a custom schema"; exit 0; } || { echo "Found models without custom schema:"; echo "$test"; exit 1; }
run: "./scripts/check_schema.sh"

- name: dbt seed
run: "dbt seed $PROFILE --select @state:modified --exclude tag:prod_exclude tag:remove --state . --project-dir ${PROJECT_DIR}"
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/dex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: DBT DEX sector run

on:
workflow_dispatch:
pull_request:
paths:
- dex/**
- .github/workflows/dex.yml
- .github/workflows/dbt_run.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
dbt-run:
uses: ./.github/workflows/dbt_run.yml
with:
project: 'dex'
20 changes: 20 additions & 0 deletions .github/workflows/nft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: DBT NFT run

on:
workflow_dispatch:
pull_request:
paths:
- nft/**
- .github/workflows/nft.yml
- .github/workflows/dbt_run.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
dbt-run:
uses: ./.github/workflows/dbt_run.yml
with:
project: 'nft'

19 changes: 19 additions & 0 deletions .github/workflows/solana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: DBT Solana sector run

on:
workflow_dispatch:
pull_request:
paths:
- solana/**
- .github/workflows/solana.yml
- .github/workflows/dbt_run.yml

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
dbt-run:
uses: ./.github/workflows/dbt_run.yml
with:
project: 'solana'
2 changes: 2 additions & 0 deletions .github/workflows/spellbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- '.gitignore'
- 'tokens/**'
- 'daily_spellbook/**'
- 'nft/**'
- 'solana/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{ config(
schema = 'addresses_events_blast'
, alias = 'first_activity'
, materialized = 'incremental'
, file_format = 'delta'
, incremental_strategy = 'append'
, unique_key = ['address']
)
}}

SELECT 'blast' AS blockchain
, et."from" AS address
, MIN_BY(et."to", et.block_number) AS first_activity_to
, MIN(et.block_time) AS first_block_time
, MIN(et.block_number) AS first_block_number
, MIN_BY(et.hash, et.block_number) AS first_tx_hash
, MIN_BY(COALESCE(sig.function, CAST((bytearray_substring(et.data, 1, 4)) as VARCHAR)), et.block_number) as first_function
, MIN_BY(et.value/1e18, et.block_number) as first_{{native_symbol}}_transferred
FROM
{{ source('blast', 'transactions') }} et
LEFT JOIN (
SELECT
DISTINCT id,
split_part(signature,'(',1) as function
FROM
{{ source('abi', 'signatures') }}
where type = 'function_call'
AND id NOT IN (0x09779838, 0x00000000) -- for some weird reason these have duplicates functions
) sig
ON sig.id = bytearray_substring(et.data, 1, 4)
{% if is_incremental() %}
LEFT JOIN {{this}} ffb ON et."from" = ffb.address
WHERE ffb.address IS NULL
AND et.block_time >= date_trunc('day', now() - interval '7' day)
{% endif %}

GROUP BY et."from"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ config(
schema = 'addresses_events_blast'
, alias = 'first_funded_by'
, materialized = 'incremental'
, file_format = 'delta'
, incremental_strategy = 'append'
, unique_key = ['address']
)
}}


{{addresses_events_first_funded_by(
blockchain='blast'
)}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: 2

models:
- name: addresses_events_blast_first_funded_by
meta:
blockchain: blast
sector: addresses_events
project: addresses
contributors: hildobby, lgingerich
config:
tags: ['table', 'funded', 'addresses_events', 'blast']
description: "Table showing who first funded each blast address in ETH"
tests:
- check_seed:
seed_file: ref('first_funded_by_seed')
filter:
blockchain: blast
match_columns:
- blockchain
- address
check_columns:
- first_funded_by
- block_number
- tx_hash
columns:
- name: blockchain
description: "Blockchain"
- name: address
description: "Concerned blast address"
tests:
- unique
- name: first_funded_by
description: "Which blast address first funded the address with ETH"
- name: block_time
description: "The block time on which the address was first funded with ETH"
- name: block_number
description: "The block number on which the address was first funded with ETH"
- name: tx_hash
description: "The transaction hash on which the address was first funded with ETH"

- name: addresses_events_blast_first_activity
meta:
blockchain: blast
sector: addresses_events
project: addresses
contributors: hildobby
config:
tags: ['table', 'activity', 'addresses_events', 'blast']
description: "Table showing first activity of each blast Mainnet address"
tests:
- check_seed:
seed_file: ref('first_activity_seed')
filter:
blockchain: blast
match_columns:
- address
check_columns:
- first_activity_to
- first_block_number
- first_tx_hash
columns:
- name: blockchain
description: "Blockchain"
- name: address
description: "Concerned blast Mainnet address"
tests:
- unique
- name: first_activity_to
description: "First transaction activity to address"
- name: first_block_time
description: "The block time on which the address made it's first activity"
- name: first_block_number
description: "The block number on which the address made it's first activity"
- name: first_tx_hash
description: "The transaction hash on which the address made it's first activity"
- name: first_function
description: "first function called by address"
- name: first_eth_transferred
description: "ETH transferred in transaction"
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{ config(
schema = 'addresses_events_mantle'
, alias = 'first_activity'
, materialized = 'incremental'
, file_format = 'delta'
, incremental_strategy = 'append'
, unique_key = ['address']
)
}}

SELECT 'mantle' AS blockchain
, et."from" AS address
, MIN_BY(et."to", et.block_number) AS first_activity_to
, MIN(et.block_time) AS first_block_time
, MIN(et.block_number) AS first_block_number
, MIN_BY(et.hash, et.block_number) AS first_tx_hash
, MIN_BY(COALESCE(sig.function, CAST((bytearray_substring(et.data, 1, 4)) as VARCHAR)), et.block_number) as first_function
, MIN_BY(et.value/1e18, et.block_number) as first_{{native_symbol}}_transferred
FROM
{{ source('mantle', 'transactions') }} et
LEFT JOIN (
SELECT
DISTINCT id,
split_part(signature,'(',1) as function
FROM
{{ source('abi', 'signatures') }}
where type = 'function_call'
AND id NOT IN (0x09779838, 0x00000000) -- for some weird reason these have duplicates functions
) sig
ON sig.id = bytearray_substring(et.data, 1, 4)
{% if is_incremental() %}
LEFT JOIN {{this}} ffb ON et."from" = ffb.address
WHERE ffb.address IS NULL
AND et.block_time >= date_trunc('day', now() - interval '7' day)
{% endif %}

GROUP BY et."from"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ config(
schema = 'addresses_events_mantle'
, alias = 'first_funded_by'
, materialized = 'incremental'
, file_format = 'delta'
, incremental_strategy = 'append'
, unique_key = ['address']
)
}}


{{addresses_events_first_funded_by(
blockchain='mantle'
)}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: 2

models:
- name: addresses_events_mantle_first_funded_by
meta:
blockchain: mantle
sector: addresses_events
project: addresses
contributors: hildobby
config:
tags: ['table', 'funded', 'addresses_events', 'mantle']
description: "Table showing who first funded each Linea address in ETH"
tests:
- check_seed:
seed_file: ref('first_funded_by_seed')
filter:
blockchain: mantle
match_columns:
- blockchain
- address
check_columns:
- first_funded_by
- block_number
- tx_hash
columns:
- name: blockchain
description: "Blockchain"
- name: address
description: "Concerned mantle address"
tests:
- unique
- name: first_funded_by
description: "Which mantle address first funded the address with ETH"
- name: block_time
description: "The block time on which the address was first funded with ETH"
- name: block_number
description: "The block number on which the address was first funded with ETH"
- name: tx_hash
description: "The transaction hash on which the address was first funded with ETH"

- name: addresses_events_mantle_first_activity
meta:
blockchain: mantle
sector: addresses_events
project: addresses
contributors: hildobby
config:
tags: ['table', 'activity', 'addresses_events', 'mantle']
description: "Table showing first activity of each mantle Mainnet address"
tests:
- check_seed:
seed_file: ref('first_activity_seed')
filter:
blockchain: mantle
match_columns:
- address
check_columns:
- first_activity_to
- first_block_number
- first_tx_hash
columns:
- name: blockchain
description: "Blockchain"
- name: address
description: "Concerned mantle Mainnet address"
tests:
- unique
- name: first_activity_to
description: "First transaction activity to address"
- name: first_block_time
description: "The block time on which the address made it's first activity"
- name: first_block_number
description: "The block number on which the address made it's first activity"
- name: first_tx_hash
description: "The transaction hash on which the address made it's first activity"
- name: first_function
description: "first function called by address"
- name: first_eth_transferred
description: "ETH transferred in transaction"
20 changes: 0 additions & 20 deletions daily_spellbook/tests/generic/check_seed.sql

This file was deleted.

Loading

0 comments on commit 13c318a

Please sign in to comment.