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

[swell] adding daily balances table of core swell assets #7194

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
43beb17
batman
darvinrio Nov 22, 2024
05d7934
sources for withdrawal
darvinrio Nov 22, 2024
932bcdb
updating descriptions
darvinrio Nov 23, 2024
8c93983
add unique test and comma fix
darvinrio Nov 23, 2024
e30afa0
code fixes
darvinrio Nov 23, 2024
0d2ad4c
attempt fix for incremental
darvinrio Nov 23, 2024
bf82c2d
another incremental fix attempt
darvinrio Nov 23, 2024
f3f2e35
fuck it we ball ?
darvinrio Nov 23, 2024
db077f1
dont think the previous incremental balled
darvinrio Nov 23, 2024
a1ad39f
adding seed
darvinrio Nov 23, 2024
4623ca8
trying to fix seed testing
darvinrio Nov 23, 2024
e909364
lets try this
darvinrio Nov 23, 2024
bf08089
Merge branch 'main' into swell/add-deposits
darvinrio Nov 23, 2024
ec763b4
decimal fixes
darvinrio Nov 26, 2024
b601620
adding core asset balances
darvinrio Nov 26, 2024
a3350ca
fix unique key
darvinrio Nov 26, 2024
260aaa3
update cex addresses (#7126)
hildobby Nov 25, 2024
4e9100c
Add sei to dex.atomic_arbitrages and sandwiches (#7171)
silointern Nov 25, 2024
b8f3dcf
zid selection update (#7178)
RantumBits Nov 25, 2024
538157e
zeroex - macro for v1 fills (#7161)
RantumBits Nov 25, 2024
cf705ff
zeroex - v2 macro model replacements (#7166)
RantumBits Nov 25, 2024
b8baac0
add zeroex_v2_mode trades (#7167)
RantumBits Nov 25, 2024
641bfbe
zeroex - macro for deduped fills (#7156)
RantumBits Nov 25, 2024
0a57292
autosniper bot (#7177)
clizzard7 Nov 25, 2024
4828248
revert 0x enhancements: v1 fills and deduped (#7186)
jeff-dude Nov 25, 2024
5c6b086
Revert 0x changes: downstream is broken (#7189)
jeff-dude Nov 25, 2024
4f8f211
add exclude tag to nft spells (#7196)
RantumBits Nov 26, 2024
bb58533
Dune index: cleanup models (#7173)
0xRobin Nov 28, 2024
1bb99fd
adding more rwa tokens and schema update (#7191)
darvinrio Nov 28, 2024
bf82c71
fix: cbBTC decimals (#7192)
tomfutago Nov 28, 2024
1f286b3
enable excluded boost model (#7193)
0xRobin Nov 28, 2024
9de2e41
feat: add bitfoot solana bot trades spellbook (#7202)
whalehunting Nov 28, 2024
7ac17e1
Update autosnipe_solana_bot_trades.sql (#7199)
clizzard7 Nov 28, 2024
7d7fe36
add sanctum router to solana dex trades (#7188)
senyor-kodi Nov 28, 2024
aff2cf5
feat: add banana gun evm bot trades spellbook (#7180)
whalehunting Nov 28, 2024
df8e779
Feat pepeboost evm trades spellbook (#7181)
clizzard7 Nov 28, 2024
35aa1cd
Add new addresses for Fractal and Quasilabs (#7185)
bram-vdberg Nov 28, 2024
7ddc761
feat: add morpho to tokens (#7200)
peyha Nov 28, 2024
793bfcf
add base cex addresses (#7201)
Synthquest Nov 28, 2024
db343e3
Lido accounting CSM/stonks update (#7190)
ppclunghe Nov 28, 2024
ee48fa9
exclude sanctum (#7206)
0xRobin Nov 28, 2024
6d41877
add Ronin to gas fees (#7228)
0xRobin Dec 3, 2024
ea444ad
[CoW Protocol] Add new Laita solver and rename FractalSolver to Fract…
bram-vdberg Dec 3, 2024
0993acb
Add akronswap dex to trades (#7226)
archie17277 Dec 3, 2024
f9a7d21
Add flashliquidity dex to trades (#7219)
archie17277 Dec 3, 2024
7fa49e5
add zkswap_finance_v3 to trades (#7212)
ZkSwapFinance Dec 3, 2024
812b3af
zereox - v2 macro replacements 2 (#7168)
RantumBits Dec 3, 2024
7740fd4
Update prices_base_tokens.sql (#7225)
JacobSharples Dec 3, 2024
9e7fc2e
add missing tokens to prices.usd and tokens.erc20 (#7220)
viniabussafi Dec 3, 2024
ddf9798
Add BRLA to prices.usd and tokens.erc20 on gnosis (#7230)
viniabussafi Dec 3, 2024
0cfd9e1
Update tokens_ethereum_erc20.sql (#7231)
viniabussafi Dec 3, 2024
924c646
Add Clark to tokens and prices for base (#7211)
timmaycastags Dec 3, 2024
0473a64
Init boba chain (#7209)
Hosuke Dec 3, 2024
a84e28a
1inch-U51: fixes to project.* lineage (#7184)
max-morrow Dec 3, 2024
71e038c
chore: add new chainswap deployer to spellbook (#6909)
whalehunting Dec 3, 2024
44c052b
add Ronin to metrics (#7227)
0xRobin Dec 3, 2024
87290bd
Fix multiple hyperlinks in README (#7205)
cxheng315 Dec 3, 2024
a7023ae
remove cast to varchar (#7232)
jeff-dude Dec 3, 2024
4fec731
feat: add flokibot evm bot trades spellbook (#7214)
whalehunting Dec 3, 2024
b421f8b
feat: add readyswap evm bot trades (#7216)
whalehunting Dec 3, 2024
b7fcee8
Revert "zereox - v2 macro replacements 2 (#7168)" (#7233)
jeff-dude Dec 3, 2024
e40430a
Init flare chain (#7222)
Hosuke Dec 4, 2024
e968576
Upgrade Event Models for GMX v2 Project (#7195)
AIDataMaster Dec 4, 2024
3f50381
Added Stablebase for Base (#7221)
PatelPrinci Dec 4, 2024
995cda7
Add Ronin to evms tables (#7241)
cxheng315 Dec 5, 2024
07eaf9e
update solver names (#7236)
harisang Dec 5, 2024
e579cd1
Add new solvers to Arbitrum and Ethereum (#7245)
bram-vdberg Dec 5, 2024
9b16e75
Added infusion dex on base chain (#7204)
Jason4276 Dec 5, 2024
ea6d73a
Add transfers into boba sources (#7244)
Hosuke Dec 5, 2024
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Welcome to [Spellbook](https://youtu.be/o7p0BNt7NHs). Cast a magical incantation
- Are you building something new? **Please make sure to open a Draft PR**, so we minimize duplicated work, and other wizards can help you if you need
- Don't know where to start? The docs below will guide you, but as a summary:
- Want to make an incremental improvement to one of our spells? (add a new project, fix a bug you found), simply open a PR with your changes.
- Follow the guide for [Submitting a PR](), [Setting up your dev environment]() and [Using dbt to write spells]() if you find yourself lost.
- Not sure how to start? Follow the walkthrough [here](https://dune.com/docs/spellbook/).
- Follow the guide for [Submitting a PR](#submitting-a-pr), [Setting up your dev environment](#setting-up-your-local-dev-environment) and [Using dbt to write spells](#how-to-use-dbt-to-create-spells) if you find yourself lost.
- Not sure how to start? Follow the walkthrough [here](#introduction).
- Make sure to open a draft PR if you will work on your spell for longer than a few days, to avoid duplicated work
- Do you want to get started building spells and you don't know what to build? Check [Issues]() to see what the community needs.
- Do you want to get started building spells and you don't know what to build? Check [Issues](https://github.com/duneanalytics/spellbook/issues) to see what the community needs.
- Check the Discussions section to see what problems the community is trying to solve (i.e. non-incremental changes) or propose your own!
- Have questions? Head over to #spellbook on our [discord](https://discord.com/channels/757637422384283659/999683200563564655) and the community will be happy to help out!
- Like with most OSS projects, your contributions to Spellbook are your own IP, you can find more details in the [Contributor License Agreement](CLA.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'bnb',
'gnosis',
'fantom',
'base',
'base',
'zksync',
]) }}
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@
{% set _taker_data = "4 + 32*4 + bytearray_to_bigint(substr(input, 4 + 32*13 + 24 + 1, 8))" %}
{% set _recipients = "bytearray_to_bigint(substr(input, " ~ _taker_data ~ " + 32*1 + 24 + 1, 8))" %}
{% set methods = methods + [{
"project": "Uniswap",
"project": "UniswapX",
"selector": "0x3f62192e",
"tag": "'UniswapXV1'",
"name": "execute",
Expand All @@ -501,7 +501,7 @@
{% set _taker_data = "4 + 32*5 + bytearray_to_bigint(substr(input, 4 + 32*14 + 24 + 1, 8))" %}
{% set _recipients = "bytearray_to_bigint(substr(input, " ~ _taker_data ~ " + 32*1 + 24 + 1, 8))" %}
{% set methods = methods + [{
"project": "Uniswap",
"project": "UniswapX",
"selector": "0x0d335884",
"tag": "'UniswapXV1'",
"name": "executeWithCallback",
Expand All @@ -528,7 +528,7 @@
{% set _taker_data = "bytearray_to_bigint(substr(input, " ~ _order_beginning ~ " + 32*12 + 24 + 1, 8))" %}
{% set _recipients = "bytearray_to_bigint(substr(input, " ~ _order_beginning ~ " + " ~ _taker_data ~ " + 32*4 + 24 + 1, 8))" %}
{% set methods = methods + [{
"project": "Uniswap",
"project": "UniswapX",
"selector": "0x0d7a16c3",
"tag": "'UniswapXV1'",
"name": "executeBatch",
Expand Down Expand Up @@ -557,7 +557,7 @@
{% set _taker_data = "bytearray_to_bigint(substr(input, " ~ _order_beginning ~ " + 32*12 + 24 + 1, 8))" %}
{% set _recipients = "bytearray_to_bigint(substr(input, " ~ _order_beginning ~ " + " ~ _taker_data ~ " + 32*4 + 24 + 1, 8))" %}
{% set methods = methods + [{
"project": "Uniswap",
"project": "UniswapX",
"selector": "0x13fb72c7",
"tag": "'UniswapXV1'",
"name": "executeBatchWithCallback",
Expand All @@ -584,7 +584,7 @@
{% set _taker_data = "4 + 32*1 + bytearray_to_bigint(substr(input, 4 + 32*10 + 24 + 1, 8))" %}
{% set _recipients = "bytearray_to_bigint(substr(input, " ~ _taker_data ~ " + 32*4 + 24 + 1, 8))" %}
{% set methods = methods + [{
"project": "Uniswap",
"project": "UniswapX",
"selector": "0x3f62192e",
"tag": "'UniswapXV2'",
"name": "execute",
Expand All @@ -610,7 +610,7 @@
{% set _taker_data = "4 + 32*2 + bytearray_to_bigint(substr(input, 4 + 32*11 + 24 + 1, 8))" %}
{% set _recipients = "bytearray_to_bigint(substr(input, " ~ _taker_data ~ " + 32*4 + 24 + 1, 8))" %}
{% set methods = methods + [{
"project": "Uniswap",
"project": "UniswapX",
"selector": "0x0d335884",
"tag": "'UniswapXV2'",
"name": "executeWithCallback",
Expand Down Expand Up @@ -638,7 +638,7 @@
{% set _taker_data = "bytearray_to_bigint(substr(input, " ~ _order_beginning ~ " + 32*9 + 24 + 1, 8))" %}
{% set _recipients = "bytearray_to_bigint(substr(input, " ~ _order_beginning ~ " + " ~ _taker_data ~ " + 32*4 + 24 + 1, 8))" %}
{% set methods = methods + [{
"project": "Uniswap",
"project": "UniswapX",
"selector": "0x13fb72c7",
"tag": "'UniswapXV2'",
"name": "executeBatchWithCallback",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ meta as (
block_number
, tx_hash
, call_trace_address
, project
, project as order_project
, order_hash
, maker
, taker
Expand All @@ -51,7 +51,7 @@ meta as (
block_number
, tx_hash
, call_trace_address
, '1inch' as project
, '1inch' as order_project
, coalesce(order_hash, concat(tx_hash, to_big_endian_32(cast(counter as int)))) as order_hash
, maker
, receiver as taker
Expand Down Expand Up @@ -81,7 +81,7 @@ meta as (
, tx_from
, tx_to
, call_trace_address
, project
, coalesce(order_project, project) as project
, tag
, flags
, call_selector
Expand Down Expand Up @@ -116,7 +116,7 @@ meta as (
and call_success
and (flags['cross_chain'] or not flags['cross_chain_method']) -- without cross-chain methods calls in non cross-chain protocols
)
left join orders using(block_number, tx_hash, call_trace_address, project)
left join orders using(block_number, tx_hash, call_trace_address)
join meta on true
where
reduce(call_trace_addresses, true, (r, x) -> if(r and x <> call_trace_address and slice(call_trace_address, 1, cardinality(x)) = x, false, r), r -> r) -- only not nested calls of the project in tx
Expand Down Expand Up @@ -314,11 +314,36 @@ meta as (
select
*
, map_from_entries(array[
('classic: direct', flags['direct'] and order_hash is null and not auction and not cross_chain_swap or second_side)
, ('classic: external', not flags['direct'] and order_hash is null and not auction and not cross_chain_swap)
, ('intent: intra-chain auction', auction and not cross_chain_swap)
, ('intent: intra-chain user limit order', order_hash is not null and not auction and not cross_chain_swap and not contracts_only)
, ('intent: intra-chain contracts only', contracts_only)
('intra-chain: classic: direct',
flags['direct']
and order_hash is null
and not auction
and not cross_chain_swap
and not contracts_only
or second_side
)
, ('intra-chain: classic: external',
not flags['direct']
and order_hash is null
and not auction
and not contracts_only
and not cross_chain_swap
)
, ('intra-chain: intents: auction',
auction
and not cross_chain_swap
)
, ('intra-chain: intents: user limit order',
order_hash is not null
and not auction
and not cross_chain_swap
and not contracts_only
and not second_side
)
, ('intra-chain: intents: contracts only',
contracts_only
and not second_side
)
, ('cross-chain', cross_chain_swap)
]) as modes
from (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% macro metrics_fees_evm(blockchain) %}

select
blockchain
, block_date
, sum(tx_fee_usd) as gas_fees_usd
from
{{ source('gas', 'fees') }}
where blockchain = '{{blockchain}}'
{% if is_incremental() %}
and
{{ incremental_predicate('block_date') }}
{% endif %}
group by
blockchain
,block_date

{% endmacro %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% macro metrics_transactions_evm(blockchain) %}

select
blockchain
, block_date
, approx_distinct(tx_hash) as tx_count --max 2% error, which is fine
from
{{ source('tokens', 'transfers') }}
where
blockchain = '{{ blockchain }}'
and amount_usd >=1
{% if is_incremental() %}
and {{ incremental_predicate('block_date') }}
{% endif %}
group by
blockchain
, block_date

{% endmacro %}
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{{ config(
schema = 'metrics'
, alias = 'net_transfers_daily'
, materialized = 'incremental'
, file_format = 'delta'
, incremental_strategy = 'merge'
, unique_key = ['blockchain', 'block_date']
, incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')]
)
}}
{% macro metrics_transfers_evm(blockchain) %}

with raw_transfers as (
select
Expand All @@ -19,7 +10,7 @@ with raw_transfers as (
from
{{ source('tokens', 'transfers') }}
where
1 = 1
blockchain = '{{blockchain}}'
{% if is_incremental() %}
and {{ incremental_predicate('block_date') }}
{% endif %}
Expand All @@ -40,7 +31,7 @@ with raw_transfers as (
from
{{ source('tokens', 'transfers') }}
where
1 = 1
blockchain = '{{blockchain}}'
{% if is_incremental() %}
and {{ incremental_predicate('block_date') }}
{% endif %}
Expand All @@ -60,6 +51,7 @@ with raw_transfers as (
inner join
{{ source('labels', 'owner_details') }} as od
on oa.owner_key = od.owner_key
where oa.blockchain = '{{blockchain}}'
), transfers_amount as (
select
t.blockchain
Expand Down Expand Up @@ -108,3 +100,5 @@ where
group by
blockchain
, block_date

{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ models:
- name: metrics_dune_index_daily
meta:
sector: metrics
contributors: jeff-dude
contributors: jeff-dude, 0xRob
config:
tags: ['metrics', 'dune', 'index', 'daily']
description: "Combine transactions, transfers and fees index values to get a daily dune index value"
Expand All @@ -13,10 +13,11 @@ models:
combination_of_columns:
- blockchain
- block_date

- name: metrics_dune_index_stats
meta:
sector: metrics
contributors: jeff-dude
config:
tags: ['metrics', 'dune', 'index', 'daily']
description: "View containing various time aggregations of the dune index"
tags: [ 'metrics', 'dune', 'index', 'daily' ]
description: "View containing various time aggregations of the dune index"
Original file line number Diff line number Diff line change
@@ -1,21 +1,71 @@
{{ config(
schema = 'metrics'
, alias = 'dune_index_daily'
, materialized = 'view'
, materialized = 'incremental'
, file_format = 'delta'
, incremental_strategy = 'merge'
, unique_key = ['blockchain', 'block_date']
, incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')]
)
}}

{% set baseline_date = '2018-01-01' %}
{% set start_date = '2015-08-21' %}

with
fees as (
select
blockchain
, block_date
, gas_fees_usd
, (gas_fees_usd / (select sum(gas_fees_usd) from {{ ref('metrics_gas_fees_daily') }} where block_date = date '{{ baseline_date }}')) * 10 as fees_index
from
{{ ref('metrics_gas_fees_daily') }}
where
block_date >= date '{{ start_date }}'
{% if is_incremental() %}
and {{ incremental_predicate('block_date') }}
{% endif %}
),
transactions as (
select
blockchain
, block_date
, tx_count
, (tx_count / cast((select sum(tx_count) from {{ ref('metrics_transactions_daily') }} where block_date = date '{{ baseline_date }}') as double)) * 10 as tx_index
from
{{ ref('metrics_transactions_daily') }}
where
block_date >= date '{{ start_date }}'
{% if is_incremental() %}
and {{ incremental_predicate('block_date') }}
{% endif %}
)
,transfers as (
select
blockchain
, block_date
, net_transfer_amount_usd
, (net_transfer_amount_usd / cast((select sum(net_transfer_amount_usd) from {{ ref('metrics_transfers_daily') }} where block_date = date '{{ baseline_date }}') as double)) * 10 as transfers_index
from
{{ ref('metrics_transfers_daily') }}
where
block_date >= date '{{ start_date }}'
{% if is_incremental() %}
and {{ incremental_predicate('block_date') }}
{% endif %}
)

select
blockchain
, block_date
, coalesce(f.fees_index,0) as fees_index
, coalesce(tr.transfers_index,0) as transfers_index
, coalesce(tx.tx_index,0) as tx_index
, coalesce(f.fees_index,0)*0.45 + coalesce(tr.transfers_index,0)*0.45 + coalesce(tx.tx_index,0)*0.10 as dune_index
from {{ ref('metrics_fees_index_daily') }} as f
left join
{{ ref('metrics_transfers_index_daily') }} as tr
using (blockchain, block_date)
left join
{{ ref('metrics_transactions_index_daily') }} as tx
using (blockchain, block_date)
, 0.45 * coalesce(fees_index,0) + 0.45 * coalesce(transfers_index,0) + 0.10 * coalesce(tx_index,0) as dune_index
, coalesce(fees_index,0) as fees_index
, coalesce(transfers_index,0) as transfers_index
, coalesce(tx_index,0) as tx_index
, gas_fees_usd
, tx_count
, net_transfer_amount_usd
from fees
left join transfers using (blockchain, block_date)
left join transactions using (blockchain, block_date)
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ from
inner join weekly_stats as w
on d.blockchain = w.blockchain
inner join monthly_stats as m
on d.blockchain = m.blockchain
on d.blockchain = m.blockchain
20 changes: 2 additions & 18 deletions dbt_subprojects/daily_spellbook/models/_metrics/fees/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,11 @@ models:
config:
tags: ['metrics', 'fees', 'gas', 'daily']
description: "Sum of total fees spent per day across all chains available in gas.fees and gas_solana.fees tables"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
- block_date

- name: metrics_gas_fees_stats
meta:
sector: metrics
contributors: jeff-dude
config:
tags: ['metrics', 'fees', 'gas']
description: "View of gas fees per blockchain aggregated to various levels. The goal is to output one row per chain with stats availble for use in counter visuals."
- name: metrics_fees_index_daily
meta:
sector: metrics
contributors: jeff-dude
config:
tags: ['metrics', 'fees', 'gas', 'index', 'daily']
description: "Each day, per chain, compare the adoption of activity based on total gas fees relative to the baseline expectation"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
- block_date
description: "View of gas fees per blockchain aggregated to various levels. The goal is to output one row per chain."
Loading
Loading