From 8b916f4bfcbe41a984b5816bf24e5006e2931377 Mon Sep 17 00:00:00 2001 From: Austin <93135983+austinFlipside@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:25:42 -0500 Subject: [PATCH] upgrades (#227) * upgrades * 1k --- models/bronze/api_udf/bronze_api__contract_abis.sql | 7 ++++--- models/silver/core/silver__relevant_contracts.sql | 6 +----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/models/bronze/api_udf/bronze_api__contract_abis.sql b/models/bronze/api_udf/bronze_api__contract_abis.sql index 996aab03..4d9bae48 100644 --- a/models/bronze/api_udf/bronze_api__contract_abis.sql +++ b/models/bronze/api_udf/bronze_api__contract_abis.sql @@ -12,7 +12,7 @@ WITH base AS ( FROM {{ ref('silver__relevant_contracts') }} WHERE - total_interaction_count >= 100 + total_interaction_count >= 1000 {% if is_incremental() %} EXCEPT @@ -23,8 +23,9 @@ FROM WHERE abi_data :data :result :: STRING <> 'Max rate limit reached' {% endif %} +order by total_interaction_count desc LIMIT - 5 + 25 ), all_contracts AS ( SELECT contract_address @@ -46,7 +47,7 @@ row_nos AS ( FROM all_contracts ), -batched AS ({% for item in range(15) %} +batched AS ({% for item in range(30) %} SELECT rn.contract_address, live.udf_api('GET', CONCAT('https://api.basescan.org/api?module=contract&action=getabi&address=', rn.contract_address, '&apikey={key}'),{ 'User-Agent': 'FlipsideStreamline' },{}, 'Vault/prod/block_explorers/base_scan') AS abi_data, SYSDATE() AS _inserted_timestamp FROM diff --git a/models/silver/core/silver__relevant_contracts.sql b/models/silver/core/silver__relevant_contracts.sql index 36f33b16..85b5b2bc 100644 --- a/models/silver/core/silver__relevant_contracts.sql +++ b/models/silver/core/silver__relevant_contracts.sql @@ -29,11 +29,7 @@ GROUP BY ), function_calls AS ( SELECT - IFF( - TYPE = 'DELEGATECALL', - from_address, - to_address - ) AS contract_address, + to_address AS contract_address, COUNT(*) AS function_call_count, MAX(_inserted_timestamp) AS max_inserted_timestamp_traces, MAX(block_number) AS latest_call_block