Skip to content

Commit

Permalink
Nft performance 2 (#1449)
Browse files Browse the repository at this point in the history
* Add filter on sudoswap

* Add filter on x2y2

* Add filters on looksrare

* Add filters on magiceden

* Add filters on solana opensea
  • Loading branch information
aalan3 authored Aug 29, 2022
1 parent a6d758e commit 19534e8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
5 changes: 4 additions & 1 deletion models/looksrare/ethereum/looksrare_ethereum_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,17 @@ INNER JOIN {{ source('ethereum','transactions') }} tx ON tx_hash = tx.hash
AND tx.block_time > '2022-01-01'
{% endif %}
{% if is_incremental() %}
AND TRY_CAST(date_trunc('DAY', tx.block_time) AS date) = TRY_CAST(date_trunc('DAY', looks_rare.block_time) AS date)
AND tx.block_time >= date_trunc("day", now() - interval '1 week')
{% endif %}
LEFT JOIN erc_transfers erc ON erc.evt_tx_hash = tx_hash AND erc.token_id_erc = token_id
LEFT JOIN {{ ref('tokens_ethereum_nft') }} tokens ON tokens.contract_address = nft_contract_address
LEFT JOIN {{ ref('nft_ethereum_aggregators') }} agg ON agg.contract_address = tx.to
LEFT JOIN {{ source('prices', 'usd') }} p ON p.minute = date_trunc('minute', looks_rare.block_time)
AND p.contract_address = currency_contract
AND p.blockchain ='ethereum'
{% if is_incremental() %}
AND p.minute >= date_trunc("day", now() - interval '1 week')
{% endif %}
LEFT JOIN {{ ref('tokens_ethereum_erc20') }} erc20 ON erc20.contract_address = currency_contract
WHERE number_of_items >= 1
{% if is_incremental() %}
Expand Down
6 changes: 5 additions & 1 deletion models/magiceden/solana/magiceden_solana_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ SELECT
FROM {{ source('solana','transactions') }}
LEFT JOIN prices.usd p
ON p.minute = date_trunc('minute', block_time)
AND p.blockchain is NULL
AND p.symbol = 'SOL'
{% if is_incremental() %}
AND p.minute >= date_trunc("day", now() - interval '1 week')
{% endif %}
WHERE (
array_contains(account_keys, 'M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K') -- magic eden v2
OR array_contains(account_keys, 'CMZYPASGWeTz7RNGHaRJfCq2XQ5pYK6nDvVQxzkH51zb')
Expand All @@ -107,5 +111,5 @@ WHERE (
{% endif %}
{% if is_incremental() %}
-- this filter will only be applied on an incremental run
AND block_date >= (select max(block_date) from {{ this }})
AND block_date >= date_trunc("day", now() - interval '1 week')
{% endif %}
6 changes: 5 additions & 1 deletion models/opensea/solana/opensea_solana_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ SELECT
FROM {{ source('solana','transactions') }}
LEFT JOIN {{ source('prices', 'usd') }} p
ON p.minute = date_trunc('minute', block_time)
AND p.blockchain is null
AND p.symbol = 'SOL'
{% if is_incremental() %}
AND p.minute >= date_trunc("day", now() - interval '1 week')
{% endif %}
WHERE (array_contains(account_keys, '3o9d13qUvEuuauhFrVom1vuCzgNsJifeaBYDPquaT73Y')
OR array_contains(account_keys, 'pAHAKoTJsAAe2ZcvTZUxoYzuygVAFAmbYmJYdWT886r'))
{% if not is_incremental() %}
AND block_date > '2022-04-06'
AND block_slot > 128251864
{% endif %}
{% if is_incremental() %}
AND block_date >= (select max(block_date) from {{ this }})
AND block_date >= date_trunc("day", now() - interval '1 week')
{% endif %}
6 changes: 3 additions & 3 deletions models/sudoswap/ethereum/sudoswap_ethereum_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ WITH
AND tr.to != '0xb16c1342e617a5b6e4b631eb114483fdb289c0a4' --we don't want duplicates from protocol fee transfer to show up in table. This needs to be most up to date funding recipient in the future, but should just be pair address for now.
AND tr.to != asset_recip --we don't want duplicates where eth is transferred to asset recipient instead of pool in the case it isn't a trade pool
{% if is_incremental() %}
AND tr.block_time >= (select max(block_time) from {{ this }})
AND tr.block_time >= date_trunc("day", now() - interval '1 week')
{% endif %}
{% if not is_incremental() %}
AND tr.block_time >= '2022-4-1'
Expand Down Expand Up @@ -241,7 +241,7 @@ WITH
AND date_trunc('minute', pu.minute)=date_trunc('minute', sc.block_time)
AND symbol = 'WETH'
{% if is_incremental() %}
AND pu.minute >= (select max(block_time) from {{ this }})
AND pu.minute >= date_trunc("day", now() - interval '1 week')
{% endif %}
{% if not is_incremental() %}
AND pu.minute >= '2022-4-1'
Expand All @@ -250,7 +250,7 @@ WITH
LEFT JOIN {{ source('ethereum', 'transactions') }} tx
ON tx.hash=sc.tx_hash
{% if is_incremental() %}
AND tx.block_time >= (select max(block_time) from {{ this }})
AND tx.block_time >= date_trunc("day", now() - interval '1 week')
{% endif %}
{% if not is_incremental() %}
AND tx.block_time >= '2022-4-1'
Expand Down
5 changes: 4 additions & 1 deletion models/x2y2/ethereum/x2y2_ethereum_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,12 @@ LEFT JOIN {{ source('prices','usd') }} pu ON pu.blockchain='ethereum'
AND date_trunc('minute', pu.minute)=date_trunc('minute', txs.block_time)
AND (pu.contract_address=txs.currency_contract
OR (pu.contract_address='0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' AND txs.currency_contract='0x0000000000000000000000000000000000000000'))
{% if is_incremental() %}
AND pu.minute >= date_trunc("day", now() - interval '1 week')
{% endif %}
LEFT JOIN {{ source('ethereum','transactions') }} et ON et.hash=txs.tx_hash
{% if is_incremental() %}
AND TRY_CAST(date_trunc('DAY', et.block_time) AS date) = TRY_CAST(date_trunc('DAY', txs.block_time) AS date)
AND et.block_time >= date_trunc("day", now() - interval '1 week')
{% endif %}
LEFT JOIN {{ source('erc721_ethereum','evt_transfer') }} erct ON txs.project_contract_address=erct.contract_address
AND erct.evt_tx_hash=txs.tx_hash
Expand Down

0 comments on commit 19534e8

Please sign in to comment.