From 7010c6f5b9019c05af341c39da902cadc9f7bdb9 Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Tue, 1 Oct 2024 15:33:04 +0100 Subject: [PATCH 01/14] added alchemy smart account addresses balances --- .../ethereum/alchemy_ethereum_balances.sql | 117 ++++++++++++++++++ .../ethereum/alchemy_ethereum_schema.yml | 33 +++++ 2 files changed, 150 insertions(+) create mode 100644 dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql create mode 100644 dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql new file mode 100644 index 00000000000..e915770d007 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql @@ -0,0 +1,117 @@ +{{ + config( + schema = 'alchemy_ethereum', + alias = 'balances', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['day', 'address', 'token_address', 'blockchain'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')] + ) +}} + +with +alchemy_addresses as ( +SELECT + blockchain, + block_time AS evt_block_time, + tx_hash AS evt_tx_hash, + sender AS address + from + ref('account_abstraction_erc4337_account_deployed') + WHERE factory IN ( + 0x000000e92d78d90000007f0082006fda09bd5f11, + 0x15ba39375ee2ab563e8873c8390be6f2e2f50232, + 0x62b31a01f937a88f0c5fbda7b8c913eb168e124a, + 0x9406cc6185a346906296840746125a0e44976454, + 0xcc0d56548ebb386da9c74c24742c08e341004e04, + 0xa07b27b3d5362dfa39e58caaba6b1df6af87c400, + 0x8b1b401e619f8150b5e67bbb92662daa0fedf1d3, + 0x000000000000dd366cc2e4432bb998e41dfd47c7, + 0x3fb7476ca9b424cff1156267eca49eb878db0b80, + 0x1c5e1a984d19d693613c9c2a6346dc5af73b20d2, + 0x7da65f5f89462271dc599a194e647efbce337db9, + 0xab784cc3cc0339013bd064c214e71d96beb435d9, + 0x5fb69a11142dbcc60affeef6081d5105f93fde27, + 0x88fd18233dd8804a175dd6ba96b4720566d55680, + 0x00000000f73cc02d061b54217866a2ce9c278661, + 0x000000f9ee1842bb72f6bbdd75e6d3d4e3e9594c, + 0x0000000000756d3e6464f5efe7e413a0af1c7474, + 0x6d757b0e09ac735ce5e8601e65491c618fb0094d, + 0xf7663424dd137d51287b199f372bbbdc136f77d0, + 0x50585668eaa39bbdb5f6a66cf0d7c0fa25c9c0a7, + 0x025bf89d9444314ef9a8fe9bf4f47137be1e0d18, + 0xe77f2c7d79b2743d39ad73dc47a8e9c6416ad3f3, + 0x089ff8e3e903bf9168e3e028240e27358f209103, + 0xc6d91648ba1a4556399f058fefd7eb74890472df, + 0x6739ecfdb523095f322f53f458a6f6bb9d4307cf, + 0x2bf9454c08bb13dc52a90ec2702454bdd39a0a32, + 0x6c7b28b78d59f15f8e273bd13e6554d585348783, + 0x213885c2a30bc0e2fd3e42895241488eca969fb4, + 0xdba8082d58f8898bf2adadd8e94a741f1e3f2a0c, + 0x4e2b2185042faeffc2b5d2e5c4b5c9f58f5eac35, + 0x33ddf684dcc6937ffe59d8405aa80c41fb518c5c, + 0x00004ec70002a32400f8ae005a26081065620d20, + 0xaee9762ce625e0a8f7b184670fb57c37bfe1d0f1, + 0x00000055c0b4fa41dde26a74435ff03692292fbd, + 0xa39a072e0330f940c10496546125b5e6a3b4b811, + 0x92e9512b53ebd703e6fb5cdbb08436c626956ef2, + 0x67df23f0c2a43bcc7727e5aa76112f286619ea0e, + 0x2ea0fd6f65f791c003eb17dd2bf8e126fbbc7afa, + 0x296363719922f3cbdde04f0ab4a46ce9191c4a08, + 0x20ff7a4753ae6c2aeeaae9fdbe172f2b2412e9c9, + 0x7c2ed23dfd82ba40161b485e165e2801daa64063, + 0x387e730ac93355095d4e3458c36a492db4e5968d, + 0x5fcd8f0d2585b95ad33ab15e502bcdfe3ec7438a, + 0x5de4839a76cf55d0c90e2061ef4386d962e15ae3, + 0x34b27be9e5945480b83a618941012e0953a2821f, + 0xe9750621f19f90e50f6030da2dab5d59ff413ca7, + 0x19b03a419124b77a7659a0fdab7903c6f40183e5, + 0xd28ac5e35ec57479d91c85db6a0889e999ff59de, + 0x8a8efcdccc48a25bb3b4a8e254cc69873a9e5c4d, + 0xc68b2ea1a70bb5ace45e94225acb83d661978fec, + 0x4e4946298614fc299b50c947289f4ad0572cb9ce, + 0xfef1c57185393f456eaeca363a0d3c12cd8df07b, + 0x10aee81389206d9b0e4d7d41d3e7fc6d83bdcf78, + 0x750fb9b4677160eb9a9740fd088c536407d34022, + 0xae0c37a4fca2ce9a4537f550afa90645874acab6, + 0x000000a56aaca3e9a4c479ea6b6cd0dbcb6634f5, + 0x000000893a26168158fbeadd9335be5bc96592e2, + 0x4a0bb243c3443b7507ae59f077f5bd96cd59a113, + 0x23ed703451291a9425d493ffe09cb31f61b3f25a, + 0x1754c5d08cb580e77aa5eff071be9019b28b4c4b, + 0xc2f576a7bb26d816b2c630d4feca649b26916ea1, + 0x52f6aedc6a07c6d66071f2d0e8a22b9a1dca2479, + 0xc5933e7f618ed520b251b1fb45d24a37332441b7, + 0x05433031f757a32c9c298935c7644d108ba1980c, + 0xdfdc32df5649db7f78a3366f0cf4adad04c3f59b, + 0x9d07c3502f6b3e181784d8d19653c3f17548c9e8, + 0x93ff202cc441341877e0703b26e169a00f64be97, + 0xf541edf82b6063603cd10e2b3f4fc2c548cd77be, + 0xc71eec16cf9e4925ea27e3dd6719fbd8a4d016e2, + 0xcad776fce9c3b3db6724aeb4c7fa2f5f3c088253, + 0x832faeeecfe62feeb6703cc17d354e6edcfe8e93, + 0x4e1dcf7ad4e460cfd30791ccc4f9c8a4f820ec67 +) +) + +,balances as ( + {{ + balances_incremental_subset_daily( + blockchain = 'ethereum', + address_list = 'alchemy_addresses', + start_date = '2023-04-13' + ) + }} +) + +select + blockchain, + day, + address, + sum(balance_usd) as balance_usd +from balances b +where b.token_address not in ( + 0xd74f5255d557944cf7dd0e45ff521520002d5748, --$9.8B were minted in a hack in 2023, all of which are stored in a Safe. Filtering out. + 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3 ) +group by 1, 2, 3 \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml new file mode 100644 index 00000000000..f4dc8c07479 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml @@ -0,0 +1,33 @@ +version: 2 + +models: + - name: alchemy_ethereum_balances + + meta: + blockchain: ethereum + sector: alchemy + project: alchemy + contributors: sofiat + + config: + tags: ['alchemy', 'balances'] + description: "Balances of alchemy smart account addresses" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - address + - token_address + columns: + - &blockchain + name: blockchain + description: "Blockchain for the token" + - &day + name: day + description: "Date on which the token balance is logged" + - &address + name: address + description: "Address for the token holder" + - &balance_usd + name: balance_usd + description: "USD value of balance for the user" \ No newline at end of file From 8762285146742ca9361e82f7c2c1252334ed58d1 Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Tue, 1 Oct 2024 16:15:52 +0100 Subject: [PATCH 02/14] fix syntax error --- .../models/alchemy/ethereum/alchemy_ethereum_balances.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql index e915770d007..2cfc50a5ce2 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql @@ -17,9 +17,9 @@ SELECT block_time AS evt_block_time, tx_hash AS evt_tx_hash, sender AS address - from +from ref('account_abstraction_erc4337_account_deployed') - WHERE factory IN ( +WHERE factory IN ( 0x000000e92d78d90000007f0082006fda09bd5f11, 0x15ba39375ee2ab563e8873c8390be6f2e2f50232, 0x62b31a01f937a88f0c5fbda7b8c913eb168e124a, @@ -110,8 +110,8 @@ select day, address, sum(balance_usd) as balance_usd -from balances b -where b.token_address not in ( +from balances +where token_address not in ( 0xd74f5255d557944cf7dd0e45ff521520002d5748, --$9.8B were minted in a hack in 2023, all of which are stored in a Safe. Filtering out. 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3 ) group by 1, 2, 3 \ No newline at end of file From 3a5cfda06feca5c8536696e7bb425c5ee0cb2116 Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Tue, 1 Oct 2024 16:28:13 +0100 Subject: [PATCH 03/14] fix syntax error --- .../models/alchemy/ethereum/alchemy_ethereum_schema.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml index f4dc8c07479..2ce3c6c582d 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml @@ -12,12 +12,6 @@ models: config: tags: ['alchemy', 'balances'] description: "Balances of alchemy smart account addresses" - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - address - - token_address columns: - &blockchain name: blockchain From 16f0071f3eba6a9602e9d87d1ca6b1cd0274f3c8 Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Wed, 2 Oct 2024 08:42:44 +0100 Subject: [PATCH 04/14] fixed compilaton error --- .../alchemy/alchemy_smart_account_address.sql | 92 +++++++++++++++++++ .../alchemy_smart_account_address_schema.yml | 27 ++++++ .../ethereum/alchemy_ethereum_balances.sql | 84 +---------------- 3 files changed, 122 insertions(+), 81 deletions(-) create mode 100644 dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address.sql create mode 100644 dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address_schema.yml diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address.sql b/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address.sql new file mode 100644 index 00000000000..b8edd84b57f --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address.sql @@ -0,0 +1,92 @@ +{{ + config( + schema = 'alchemy' + ,alias = 'smart_account_addresses' + ,materialized = 'table' + ,post_hook='{{ expose_spells(\'["arbitrum","ethereum","bnb","arbitrum","avalanche_c","celo","gnosis","zora","polygon","base","optimism" ]\', + "project", + "alchemy", + \'["sofiat"]\') }}' + ) +}} + +SELECT + blockchain, + block_time AS evt_block_time, + tx_hash AS evt_tx_hash, + sender AS address +from {{ ref('account_abstraction_erc4337_account_deployed') }} +WHERE factory IN ( + 0x000000e92d78d90000007f0082006fda09bd5f11, + 0x15ba39375ee2ab563e8873c8390be6f2e2f50232, + 0x62b31a01f937a88f0c5fbda7b8c913eb168e124a, + 0x9406cc6185a346906296840746125a0e44976454, + 0xcc0d56548ebb386da9c74c24742c08e341004e04, + 0xa07b27b3d5362dfa39e58caaba6b1df6af87c400, + 0x8b1b401e619f8150b5e67bbb92662daa0fedf1d3, + 0x000000000000dd366cc2e4432bb998e41dfd47c7, + 0x3fb7476ca9b424cff1156267eca49eb878db0b80, + 0x1c5e1a984d19d693613c9c2a6346dc5af73b20d2, + 0x7da65f5f89462271dc599a194e647efbce337db9, + 0xab784cc3cc0339013bd064c214e71d96beb435d9, + 0x5fb69a11142dbcc60affeef6081d5105f93fde27, + 0x88fd18233dd8804a175dd6ba96b4720566d55680, + 0x00000000f73cc02d061b54217866a2ce9c278661, + 0x000000f9ee1842bb72f6bbdd75e6d3d4e3e9594c, + 0x0000000000756d3e6464f5efe7e413a0af1c7474, + 0x6d757b0e09ac735ce5e8601e65491c618fb0094d, + 0xf7663424dd137d51287b199f372bbbdc136f77d0, + 0x50585668eaa39bbdb5f6a66cf0d7c0fa25c9c0a7, + 0x025bf89d9444314ef9a8fe9bf4f47137be1e0d18, + 0xe77f2c7d79b2743d39ad73dc47a8e9c6416ad3f3, + 0x089ff8e3e903bf9168e3e028240e27358f209103, + 0xc6d91648ba1a4556399f058fefd7eb74890472df, + 0x6739ecfdb523095f322f53f458a6f6bb9d4307cf, + 0x2bf9454c08bb13dc52a90ec2702454bdd39a0a32, + 0x6c7b28b78d59f15f8e273bd13e6554d585348783, + 0x213885c2a30bc0e2fd3e42895241488eca969fb4, + 0xdba8082d58f8898bf2adadd8e94a741f1e3f2a0c, + 0x4e2b2185042faeffc2b5d2e5c4b5c9f58f5eac35, + 0x33ddf684dcc6937ffe59d8405aa80c41fb518c5c, + 0x00004ec70002a32400f8ae005a26081065620d20, + 0xaee9762ce625e0a8f7b184670fb57c37bfe1d0f1, + 0x00000055c0b4fa41dde26a74435ff03692292fbd, + 0xa39a072e0330f940c10496546125b5e6a3b4b811, + 0x92e9512b53ebd703e6fb5cdbb08436c626956ef2, + 0x67df23f0c2a43bcc7727e5aa76112f286619ea0e, + 0x2ea0fd6f65f791c003eb17dd2bf8e126fbbc7afa, + 0x296363719922f3cbdde04f0ab4a46ce9191c4a08, + 0x20ff7a4753ae6c2aeeaae9fdbe172f2b2412e9c9, + 0x7c2ed23dfd82ba40161b485e165e2801daa64063, + 0x387e730ac93355095d4e3458c36a492db4e5968d, + 0x5fcd8f0d2585b95ad33ab15e502bcdfe3ec7438a, + 0x5de4839a76cf55d0c90e2061ef4386d962e15ae3, + 0x34b27be9e5945480b83a618941012e0953a2821f, + 0xe9750621f19f90e50f6030da2dab5d59ff413ca7, + 0x19b03a419124b77a7659a0fdab7903c6f40183e5, + 0xd28ac5e35ec57479d91c85db6a0889e999ff59de, + 0x8a8efcdccc48a25bb3b4a8e254cc69873a9e5c4d, + 0xc68b2ea1a70bb5ace45e94225acb83d661978fec, + 0x4e4946298614fc299b50c947289f4ad0572cb9ce, + 0xfef1c57185393f456eaeca363a0d3c12cd8df07b, + 0x10aee81389206d9b0e4d7d41d3e7fc6d83bdcf78, + 0x750fb9b4677160eb9a9740fd088c536407d34022, + 0xae0c37a4fca2ce9a4537f550afa90645874acab6, + 0x000000a56aaca3e9a4c479ea6b6cd0dbcb6634f5, + 0x000000893a26168158fbeadd9335be5bc96592e2, + 0x4a0bb243c3443b7507ae59f077f5bd96cd59a113, + 0x23ed703451291a9425d493ffe09cb31f61b3f25a, + 0x1754c5d08cb580e77aa5eff071be9019b28b4c4b, + 0xc2f576a7bb26d816b2c630d4feca649b26916ea1, + 0x52f6aedc6a07c6d66071f2d0e8a22b9a1dca2479, + 0xc5933e7f618ed520b251b1fb45d24a37332441b7, + 0x05433031f757a32c9c298935c7644d108ba1980c, + 0xdfdc32df5649db7f78a3366f0cf4adad04c3f59b, + 0x9d07c3502f6b3e181784d8d19653c3f17548c9e8, + 0x93ff202cc441341877e0703b26e169a00f64be97, + 0xf541edf82b6063603cd10e2b3f4fc2c548cd77be, + 0xc71eec16cf9e4925ea27e3dd6719fbd8a4d016e2, + 0xcad776fce9c3b3db6724aeb4c7fa2f5f3c088253, + 0x832faeeecfe62feeb6703cc17d354e6edcfe8e93, + 0x4e1dcf7ad4e460cfd30791ccc4f9c8a4f820ec67 +) \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address_schema.yml b/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address_schema.yml new file mode 100644 index 00000000000..6764fde4362 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address_schema.yml @@ -0,0 +1,27 @@ +version: 2 + +models: + - name: alchemy_smart_account_address + + meta: + blockchain: arbitrum,ethereum,bnb,arbitrum,avalanche_c,celo,gnosis,zora,polygon,base,optimism + sector: alchemy + project: alchemy + contributors: sofiat + + config: + tags: ['alchemy', 'addresses', 'smart_accounts'] + description: "addresses of alchemy smart accounts" + columns: + - &blockchain + name: blockchain + description: "Blockchain for which the address was created" + - &evt_block_time + name: day + description: "Date on which the address was created" + - &tx_hash + name: tx_hash + description: "The txhash for the created address" + - &address + name: address + description: "The address created" diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql index 2cfc50a5ce2..f14714b4c65 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql @@ -12,87 +12,9 @@ with alchemy_addresses as ( -SELECT - blockchain, - block_time AS evt_block_time, - tx_hash AS evt_tx_hash, - sender AS address -from - ref('account_abstraction_erc4337_account_deployed') -WHERE factory IN ( - 0x000000e92d78d90000007f0082006fda09bd5f11, - 0x15ba39375ee2ab563e8873c8390be6f2e2f50232, - 0x62b31a01f937a88f0c5fbda7b8c913eb168e124a, - 0x9406cc6185a346906296840746125a0e44976454, - 0xcc0d56548ebb386da9c74c24742c08e341004e04, - 0xa07b27b3d5362dfa39e58caaba6b1df6af87c400, - 0x8b1b401e619f8150b5e67bbb92662daa0fedf1d3, - 0x000000000000dd366cc2e4432bb998e41dfd47c7, - 0x3fb7476ca9b424cff1156267eca49eb878db0b80, - 0x1c5e1a984d19d693613c9c2a6346dc5af73b20d2, - 0x7da65f5f89462271dc599a194e647efbce337db9, - 0xab784cc3cc0339013bd064c214e71d96beb435d9, - 0x5fb69a11142dbcc60affeef6081d5105f93fde27, - 0x88fd18233dd8804a175dd6ba96b4720566d55680, - 0x00000000f73cc02d061b54217866a2ce9c278661, - 0x000000f9ee1842bb72f6bbdd75e6d3d4e3e9594c, - 0x0000000000756d3e6464f5efe7e413a0af1c7474, - 0x6d757b0e09ac735ce5e8601e65491c618fb0094d, - 0xf7663424dd137d51287b199f372bbbdc136f77d0, - 0x50585668eaa39bbdb5f6a66cf0d7c0fa25c9c0a7, - 0x025bf89d9444314ef9a8fe9bf4f47137be1e0d18, - 0xe77f2c7d79b2743d39ad73dc47a8e9c6416ad3f3, - 0x089ff8e3e903bf9168e3e028240e27358f209103, - 0xc6d91648ba1a4556399f058fefd7eb74890472df, - 0x6739ecfdb523095f322f53f458a6f6bb9d4307cf, - 0x2bf9454c08bb13dc52a90ec2702454bdd39a0a32, - 0x6c7b28b78d59f15f8e273bd13e6554d585348783, - 0x213885c2a30bc0e2fd3e42895241488eca969fb4, - 0xdba8082d58f8898bf2adadd8e94a741f1e3f2a0c, - 0x4e2b2185042faeffc2b5d2e5c4b5c9f58f5eac35, - 0x33ddf684dcc6937ffe59d8405aa80c41fb518c5c, - 0x00004ec70002a32400f8ae005a26081065620d20, - 0xaee9762ce625e0a8f7b184670fb57c37bfe1d0f1, - 0x00000055c0b4fa41dde26a74435ff03692292fbd, - 0xa39a072e0330f940c10496546125b5e6a3b4b811, - 0x92e9512b53ebd703e6fb5cdbb08436c626956ef2, - 0x67df23f0c2a43bcc7727e5aa76112f286619ea0e, - 0x2ea0fd6f65f791c003eb17dd2bf8e126fbbc7afa, - 0x296363719922f3cbdde04f0ab4a46ce9191c4a08, - 0x20ff7a4753ae6c2aeeaae9fdbe172f2b2412e9c9, - 0x7c2ed23dfd82ba40161b485e165e2801daa64063, - 0x387e730ac93355095d4e3458c36a492db4e5968d, - 0x5fcd8f0d2585b95ad33ab15e502bcdfe3ec7438a, - 0x5de4839a76cf55d0c90e2061ef4386d962e15ae3, - 0x34b27be9e5945480b83a618941012e0953a2821f, - 0xe9750621f19f90e50f6030da2dab5d59ff413ca7, - 0x19b03a419124b77a7659a0fdab7903c6f40183e5, - 0xd28ac5e35ec57479d91c85db6a0889e999ff59de, - 0x8a8efcdccc48a25bb3b4a8e254cc69873a9e5c4d, - 0xc68b2ea1a70bb5ace45e94225acb83d661978fec, - 0x4e4946298614fc299b50c947289f4ad0572cb9ce, - 0xfef1c57185393f456eaeca363a0d3c12cd8df07b, - 0x10aee81389206d9b0e4d7d41d3e7fc6d83bdcf78, - 0x750fb9b4677160eb9a9740fd088c536407d34022, - 0xae0c37a4fca2ce9a4537f550afa90645874acab6, - 0x000000a56aaca3e9a4c479ea6b6cd0dbcb6634f5, - 0x000000893a26168158fbeadd9335be5bc96592e2, - 0x4a0bb243c3443b7507ae59f077f5bd96cd59a113, - 0x23ed703451291a9425d493ffe09cb31f61b3f25a, - 0x1754c5d08cb580e77aa5eff071be9019b28b4c4b, - 0xc2f576a7bb26d816b2c630d4feca649b26916ea1, - 0x52f6aedc6a07c6d66071f2d0e8a22b9a1dca2479, - 0xc5933e7f618ed520b251b1fb45d24a37332441b7, - 0x05433031f757a32c9c298935c7644d108ba1980c, - 0xdfdc32df5649db7f78a3366f0cf4adad04c3f59b, - 0x9d07c3502f6b3e181784d8d19653c3f17548c9e8, - 0x93ff202cc441341877e0703b26e169a00f64be97, - 0xf541edf82b6063603cd10e2b3f4fc2c548cd77be, - 0xc71eec16cf9e4925ea27e3dd6719fbd8a4d016e2, - 0xcad776fce9c3b3db6724aeb4c7fa2f5f3c088253, - 0x832faeeecfe62feeb6703cc17d354e6edcfe8e93, - 0x4e1dcf7ad4e460cfd30791ccc4f9c8a4f820ec67 -) + select + address + from {{ref('alchemy_smart_account_addresses')}} ) ,balances as ( From a0ebca3794ec5d3e8083e283f6a55ba3bba3d204 Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Wed, 2 Oct 2024 20:53:31 +0100 Subject: [PATCH 05/14] fix compilation error --- ...address.sql => alchemy_smart_account_addresses.sql} | 2 +- ....yml => alchemy_smart_account_addresses_schema.yml} | 4 ++-- .../alchemy/ethereum/alchemy_ethereum_balances.sql | 10 ++-------- .../_subprojects_outputs/hourly_spellbook/_sources.yml | 4 ++++ 4 files changed, 9 insertions(+), 11 deletions(-) rename dbt_subprojects/daily_spellbook/models/alchemy/{alchemy_smart_account_address.sql => alchemy_smart_account_addresses.sql} (98%) rename dbt_subprojects/daily_spellbook/models/alchemy/{alchemy_smart_account_address_schema.yml => alchemy_smart_account_addresses_schema.yml} (81%) diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address.sql b/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses.sql similarity index 98% rename from dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address.sql rename to dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses.sql index b8edd84b57f..9b8d748fd37 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address.sql +++ b/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses.sql @@ -15,7 +15,7 @@ SELECT block_time AS evt_block_time, tx_hash AS evt_tx_hash, sender AS address -from {{ ref('account_abstraction_erc4337_account_deployed') }} +from {{ source ('account_abstraction_erc4337', 'account_deployed') }} WHERE factory IN ( 0x000000e92d78d90000007f0082006fda09bd5f11, 0x15ba39375ee2ab563e8873c8390be6f2e2f50232, diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address_schema.yml b/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses_schema.yml similarity index 81% rename from dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address_schema.yml rename to dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses_schema.yml index 6764fde4362..4d2272944bb 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_address_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses_schema.yml @@ -1,10 +1,10 @@ version: 2 models: - - name: alchemy_smart_account_address + - name: alchemy_smart_account_addresses meta: - blockchain: arbitrum,ethereum,bnb,arbitrum,avalanche_c,celo,gnosis,zora,polygon,base,optimism + blockchain: arbitrum, ethereum, bnb, avalanche_c, celo, gnosis, zora, polygon, base, optimism sector: alchemy project: alchemy contributors: sofiat diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql index f14714b4c65..ceb6515a7cc 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql @@ -11,17 +11,11 @@ }} with -alchemy_addresses as ( - select - address - from {{ref('alchemy_smart_account_addresses')}} -) - -,balances as ( +balances as ( {{ balances_incremental_subset_daily( blockchain = 'ethereum', - address_list = 'alchemy_addresses', + address_list = ref('alchemy_smart_account_addresses'), start_date = '2023-04-13' ) }} diff --git a/sources/_subprojects_outputs/hourly_spellbook/_sources.yml b/sources/_subprojects_outputs/hourly_spellbook/_sources.yml index eac5c639ba9..40d513b4040 100644 --- a/sources/_subprojects_outputs/hourly_spellbook/_sources.yml +++ b/sources/_subprojects_outputs/hourly_spellbook/_sources.yml @@ -50,3 +50,7 @@ sources: - name: jelly_swap_sei tables: - name: pools_metrics_daily + + - name: account_abstraction_erc4337 + tables: + - name: account_deployed \ No newline at end of file From 9264d4396ef947c0a3f61a45c937fb46101177fd Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Wed, 2 Oct 2024 21:05:34 +0100 Subject: [PATCH 06/14] fix syntax error --- .../models/alchemy/ethereum/alchemy_ethereum_balances.sql | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql index ceb6515a7cc..6062f87c0bb 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql @@ -22,12 +22,8 @@ balances as ( ) select - blockchain, - day, - address, - sum(balance_usd) as balance_usd + * from balances where token_address not in ( 0xd74f5255d557944cf7dd0e45ff521520002d5748, --$9.8B were minted in a hack in 2023, all of which are stored in a Safe. Filtering out. - 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3 ) -group by 1, 2, 3 \ No newline at end of file + 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3 ) \ No newline at end of file From a200be98c76e323aea25215a0cd128dd240dc0e6 Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Wed, 2 Oct 2024 21:37:07 +0100 Subject: [PATCH 07/14] added a filter --- .../models/alchemy/alchemy_smart_account_addresses.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses.sql b/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses.sql index 9b8d748fd37..97fb7dae7a7 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses.sql +++ b/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses.sql @@ -89,4 +89,5 @@ WHERE factory IN ( 0xcad776fce9c3b3db6724aeb4c7fa2f5f3c088253, 0x832faeeecfe62feeb6703cc17d354e6edcfe8e93, 0x4e1dcf7ad4e460cfd30791ccc4f9c8a4f820ec67 -) \ No newline at end of file +) +and blockchain = 'ethereum' \ No newline at end of file From 8b5e759ed0a7d8521e882d5ede01d4fa49fb32e8 Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Wed, 2 Oct 2024 21:49:33 +0100 Subject: [PATCH 08/14] fix syntax error --- .../alchemy/ethereum/alchemy_ethereum_balances.sql | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql index 6062f87c0bb..abcd1727f4d 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql @@ -11,11 +11,17 @@ }} with -balances as ( +alchemy_addresses as ( + select + address + from {{ref('alchemy_smart_account_addresses')}} +) + +,balances as ( {{ balances_incremental_subset_daily( blockchain = 'ethereum', - address_list = ref('alchemy_smart_account_addresses'), + address_list = 'alchemy_addresses', start_date = '2023-04-13' ) }} From c884f03b686b36d556dcc72803562af6b83edf5c Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Wed, 2 Oct 2024 21:52:09 +0100 Subject: [PATCH 09/14] fix syntax error --- .../models/alchemy/alchemy_smart_account_addresses.sql | 3 +-- .../models/alchemy/ethereum/alchemy_ethereum_balances.sql | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses.sql b/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses.sql index 97fb7dae7a7..9b8d748fd37 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses.sql +++ b/dbt_subprojects/daily_spellbook/models/alchemy/alchemy_smart_account_addresses.sql @@ -89,5 +89,4 @@ WHERE factory IN ( 0xcad776fce9c3b3db6724aeb4c7fa2f5f3c088253, 0x832faeeecfe62feeb6703cc17d354e6edcfe8e93, 0x4e1dcf7ad4e460cfd30791ccc4f9c8a4f820ec67 -) -and blockchain = 'ethereum' \ No newline at end of file +) \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql index abcd1727f4d..c82f3535f09 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql @@ -5,7 +5,7 @@ materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['day', 'address', 'token_address', 'blockchain'], + unique_key = ['day', 'address', 'token_address'], incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')] ) }} From fe4276fbb50c6bcd91bdbdbaeadb4eb82477ea55 Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Wed, 2 Oct 2024 22:09:02 +0100 Subject: [PATCH 10/14] fix syntax error --- .../ethereum/alchemy_ethereum_schema.yml | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml index 2ce3c6c582d..b9e1d913d60 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml @@ -16,12 +16,36 @@ models: - &blockchain name: blockchain description: "Blockchain for the token" + - &version + name: version + description: "Version of the token" - &day name: day description: "Date on which the token balance is logged" - &address name: address description: "Address for the token holder" + - &token_symbol + name: token_symbol + description: "Symbol for the token" + - &token_address + name: token_address + description: "Address for the token" + - &token_standard + name: token_standard + description: "Standard for the token" + - &token_id + name: token_id + description: "ID for the token" + - &balance + name: balance + description: "Balance for the user" - &balance_usd name: balance_usd - description: "USD value of balance for the user" \ No newline at end of file + description: "USD value of balance for the user" + - &last_updated + name: last_updated + description: "UTC timestamp when data was last updated" + - &next_update + name: next_update + description: "UTC timestamp when data is next updated" \ No newline at end of file From cc028a0c27740c842aeb187c4e1cd20e492854ca Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Wed, 2 Oct 2024 22:33:33 +0100 Subject: [PATCH 11/14] fix syntax error --- .../models/alchemy/ethereum/alchemy_ethereum_schema.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml index b9e1d913d60..0184b039b49 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml @@ -12,13 +12,16 @@ models: config: tags: ['alchemy', 'balances'] description: "Balances of alchemy smart account addresses" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - address + - token_address columns: - &blockchain name: blockchain description: "Blockchain for the token" - - &version - name: version - description: "Version of the token" - &day name: day description: "Date on which the token balance is logged" From f1cf5383be0565ab4650b4b1e7c29f80d691c6ec Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Wed, 2 Oct 2024 22:35:38 +0100 Subject: [PATCH 12/14] fix indentation error --- .../models/alchemy/ethereum/alchemy_ethereum_schema.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml index 0184b039b49..549f4fa4b91 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml @@ -12,7 +12,7 @@ models: config: tags: ['alchemy', 'balances'] description: "Balances of alchemy smart account addresses" - tests: + tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: - day From 34a10718823f6cc065ef8321c8044efbd6958b82 Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Wed, 2 Oct 2024 22:49:27 +0100 Subject: [PATCH 13/14] fix incremental error --- .../models/alchemy/ethereum/alchemy_ethereum_balances.sql | 2 +- .../models/alchemy/ethereum/alchemy_ethereum_schema.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql index c82f3535f09..b40b3773f44 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql @@ -5,7 +5,7 @@ materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['day', 'address', 'token_address'], + unique_key = ['day', 'address', 'token_address', 'token_id'], incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')] ) }} diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml index 549f4fa4b91..bfad2edeec9 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml @@ -18,6 +18,7 @@ models: - day - address - token_address + - token_id columns: - &blockchain name: blockchain From 9d29729227790adf138871582cdfd6ef29740a51 Mon Sep 17 00:00:00 2001 From: sophie-analytics Date: Wed, 2 Oct 2024 23:05:08 +0100 Subject: [PATCH 14/14] fix syntax error --- .../models/alchemy/ethereum/alchemy_ethereum_balances.sql | 5 +++-- .../models/alchemy/ethereum/alchemy_ethereum_schema.yml | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql index b40b3773f44..dfc23c098c0 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_balances.sql @@ -5,7 +5,7 @@ materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['day', 'address', 'token_address', 'token_id'], + unique_key = ['day', 'address', 'token_address', 'unique_key_id'], incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')] ) }} @@ -28,7 +28,8 @@ alchemy_addresses as ( ) select - * + *, + coalesce(token_id, uint256 '1') as unique_key_id ---using this to add a unique key to the table as erc20 has no token_id from balances where token_address not in ( 0xd74f5255d557944cf7dd0e45ff521520002d5748, --$9.8B were minted in a hack in 2023, all of which are stored in a Safe. Filtering out. diff --git a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml index bfad2edeec9..00b01dc3ab1 100644 --- a/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/alchemy/ethereum/alchemy_ethereum_schema.yml @@ -18,7 +18,7 @@ models: - day - address - token_address - - token_id + - unique_key_id columns: - &blockchain name: blockchain @@ -52,4 +52,7 @@ models: description: "UTC timestamp when data was last updated" - &next_update name: next_update - description: "UTC timestamp when data is next updated" \ No newline at end of file + description: "UTC timestamp when data is next updated" + - &unique_key_id + name: unique_key_id + description: " unique key to the table as erc20 has no token_id" \ No newline at end of file