Skip to content

Commit

Permalink
Merge branch 'op-velodrome' of https://github.com/LamprosLabsDAO/spel…
Browse files Browse the repository at this point in the history
…lbook into op-velodrome
  • Loading branch information
Jason4276 committed Jan 7, 2025
2 parents bee9f36 + a2086f3 commit e8cbc0e
Show file tree
Hide file tree
Showing 33 changed files with 1,292 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{ config(
schema = 'aave_base'
, alias = 'interest_rates'
, post_hook='{{ expose_spells(blockchains = \'["base"]\',
spell_type = "project",
spell_name = "aave",
contributors = \'["mikeghen1","batwayne", "chuxin"]\') }}'
)
}}

SELECT *
FROM
(
SELECT
reserve,
symbol,
hour,
deposit_apy,
stable_borrow_apy,
variable_borrow_apy
FROM {{ ref('aave_v3_base_interest_rates') }}
/*
UNION ALL
< add new version as needed
*/
)
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,59 @@ models:
- &evt_index
name: evt_index
description: "Event index"

- name: aave_v3_base_interest_rates
meta:
blockchain: base
sector: lending
project: aave_v3
contributors: mikeghen1, batwayne, chuxin
config:
tags: ['base', 'aave_v3', 'interest', 'aave', 'lending']
description: "Hourly aave interest rates on base"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- reserve
- symbol
- hour
columns:
- &reserve
name: reserve
description: "Aave reserve contract address"
- *symbol
- &hour
name: hour
description: "Block timestamp truncated to hours"
- &deposit_apy
name: deposit_apy
description: "Hourly deposit interest rate value of the reserve"
- &stable_borrow_apy
name: stable_borrow_apy
description: "Hourly stable borrow interest rate value of the reserve"
- &variable_borrow_apy
name: variable_borrow_apy
description: "Hourly variable borrow interest rate value of the reserve"

- name: aave_base_interest_rates
meta:
blockchain: base
sector: lending
project: aave
contributors: mikeghen1, batwayne, chuxin
config:
tags: ['base', 'aave_v3', 'interest', 'aave', 'lending']
description: "Hourly aave interest rates on base"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- reserve
- symbol
- hour
columns:
- *reserve
- *symbol
- *hour
- *deposit_apy
- *stable_borrow_apy
- *variable_borrow_apy
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{ config(
schema = 'aave_v3_base'
, alias = 'interest_rates'
, materialized = 'incremental'
, file_format = 'delta'
, incremental_strategy = 'merge'
, unique_key = ['reserve', 'symbol', 'hour']
, post_hook='{{ expose_spells(blockchains = \'["base"]\',
spell_type = "project",
spell_name = "aave_v3",
contributors = \'["mikeghen1","batwayne", "chuxin"]\') }}'
)
}}

select
a.reserve,
t.symbol,
date_trunc('hour',a.evt_block_time) as hour,
avg(CAST(a.liquidityRate AS DOUBLE)) / 1e27 as deposit_apy,
avg(CAST(a.stableBorrowRate AS DOUBLE)) / 1e27 as stable_borrow_apy,
avg(CAST(a.variableBorrowRate AS DOUBLE)) / 1e27 as variable_borrow_apy
from {{ source('aave_v3_base', 'L2Pool_evt_ReserveDataUpdated') }} a
left join {{ source('tokens', 'erc20') }} t
on a.reserve = t.contract_address and t.blockchain = 'base'
{% if is_incremental() %}
WHERE {{ incremental_predicate('evt_block_time') }}
{% endif %}
group by 1,2,3
2 changes: 2 additions & 0 deletions dbt_subprojects/daily_spellbook/models/evms/evms_info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
, "ronin"
, "scroll"
, "sei"
, "sonic"
, "viction"
, "worldchain"
, "zksync"
Expand Down Expand Up @@ -95,4 +96,5 @@ FROM (
, (2020, 'ronin', 'Ronin', 'Layer 1', null, 'RON', 0xe514d9deb7966c8be0ca922de8a064264ea6bcd4, 'https://app.roninchain.com/', timestamp '2021-01-25 10:49', NULL, NULL, NULL, true)
, (14, 'flare', 'Flare', 'Layer 1', NULL, 'FLR', NULL, 'https://flare-explorer.flare.network/', timestamp '2022-07-13 15:32', NULL, NULL, NULL, true)
, (88, 'viction', 'Viction', 'Layer 1', NULL, 'VIC', 0xC054751BdBD24Ae713BA3Dc9Bd9434aBe2abc1ce, 'https://vicscan.xyz/', timestamp '2018-12-14 07:50:20', NULL, NULL, NULL, true)
, (146, 'sonic', 'Sonic', 'Layer 1', NULL, 'SONIC', NULL, 'https://sonicscan.org/', timestamp '2024-12-01 00:00', NULL, NULL, NULL, true)
) AS temp_table (chain_id, blockchain, name, chain_type, rollup_type, native_token_symbol, wrapped_native_token_address, explorer_link, first_block_time, codebase, data_availability, settlement, is_on_dune)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
with unit_test1
as (select case
when abs(variable_borrow_apy - 0.10808360395679557) / 0.10808360395679557 < 0.001
then true
else false
end as test
from {{ ref('aave_v3_base_interest_rates' )}}
where reserve = 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 -- USDC
and hour = TIMESTAMP '2025-01-02 20:00'),
unit_test2
as (select case
when abs(deposit_apy - 0.015712521763084) / 0.015712521763084 < 0.001
then true
else false
end as test
from {{ ref('aave_v3_base_interest_rates' )}}
where symbol = 'WETH' -- 0x4200000000000000000000000000000000000006
and hour = TIMESTAMP '2024-08-21 03:00')
select *
from (select *
from unit_test1
union
select *
from unit_test2)
where test = false
2 changes: 1 addition & 1 deletion dbt_subprojects/dex/models/trades/base/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ models:
blockchain: base
sector: dex
project: stablebase
contributors: principatel
contributors: principatel, hosuke
config:
tags: ["base", "dex", "trades", "stablebase"]
description: stablebase base trades
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
unique_key = ['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'evt_index']
) }}

-- Id mapping:
-- 0 USDbC https://basescan.org/token/0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca
-- 1 DAI https://basescan.org/token/0x50c5725949a6f0c72e6c4a641f24049a917db0cb
-- 2 axlUSDC https://basescan.org/token/0xeb466342c4d449bc9f53a865d5cb90586f405215

WITH token_swaps AS (
SELECT
evt_block_number AS block_number,
Expand All @@ -16,8 +21,16 @@ WITH token_swaps AS (
evt_tx_to AS taker,
tokensSold AS token_sold_amount_raw,
tokensBought AS token_bought_amount_raw,
CAST(soldId AS varbinary) AS token_sold_address,
CAST(boughtId AS varbinary) AS token_bought_address,
CASE soldId
WHEN 0 THEN 0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca
WHEN 1 THEN 0x50c5725949a6f0c72e6c4a641f24049a917db0cb
WHEN 2 THEN 0xeb466342c4d449bc9f53a865d5cb90586f405215
END AS token_sold_address,
CASE boughtId
WHEN 0 THEN 0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca
WHEN 1 THEN 0x50c5725949a6f0c72e6c4a641f24049a917db0cb
WHEN 2 THEN 0xeb466342c4d449bc9f53a865d5cb90586f405215
END AS token_bought_address,
contract_address AS project_contract_address,
evt_tx_hash AS tx_hash,
evt_index AS evt_index
Expand Down
1 change: 1 addition & 0 deletions dbt_subprojects/dex/models/trades/ethereum/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ models:
version:
- 2
- mmpool
- pcsx

- name: shibaswap_v1_ethereum_base_trades
meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,44 @@ dexs_macro AS (
}}
),

transfer as (
select * from {{ source('tokens', 'transfers') }}
where blockchain = 'ethereum'
and block_date >= date '2024-09-20'
and tx_hash in (select evt_tx_hash from {{ source('pancakeswap_ethereum', 'ExclusiveDutchOrderReactor_evt_Fill') }})
{% if is_incremental() %}
and {{ incremental_predicate('block_time') }}
{% endif %}
),

dexs_pcsx AS (
-- PancakeSwapX
SELECT
'pcsx' AS version,
a.evt_block_number AS block_number,
a.evt_block_time AS block_time,
a.swapper AS taker,
a.filler AS maker,
receive.amount_raw AS token_bought_amount_raw,
send.amount_raw AS token_sold_amount_raw,
receive.contract_address AS token_bought_address,
send.contract_address AS token_sold_address,
a.contract_address AS project_contract_address,
a.evt_tx_hash AS tx_hash,
a.evt_index

FROM {{ source('pancakeswap_ethereum', 'ExclusiveDutchOrderReactor_evt_Fill') }} a

LEFT JOIN transfer AS send
ON a.evt_tx_hash = send.tx_hash AND a.swapper = send."from"

LEFT JOIN transfer AS receive
on a.evt_tx_hash = receive.tx_hash AND a.swapper = receive."to"
{% if is_incremental() %}
WHERE {{ incremental_predicate('a.evt_block_time') }}
{% endif %}
),

dexs_mm AS (
-- PancakeSwap v2 MMPool
SELECT
Expand Down Expand Up @@ -129,3 +167,24 @@ SELECT
dexs_ss.tx_hash,
dexs_ss.evt_index
FROM dexs_ss
UNION ALL
SELECT
'ethereum' AS blockchain,
'pancakeswap' AS project,
dexs_pcsx.version,
CAST(date_trunc('month', dexs_pcsx.block_time) AS date) AS block_month,
CAST(date_trunc('day', dexs_pcsx.block_time) AS date) AS block_date,
dexs_pcsx.block_time,
dexs_pcsx.block_number,
dexs_pcsx.token_bought_amount_raw,
dexs_pcsx.token_sold_amount_raw,
dexs_pcsx.token_bought_address,
dexs_pcsx.token_sold_address,
dexs_pcsx.taker,
dexs_pcsx.maker,
dexs_pcsx.project_contract_address,
dexs_pcsx.tx_hash,
dexs_pcsx.evt_index
FROM dexs_pcsx
WHERE token_sold_amount_raw > 0
AND token_bought_amount_raw > 0
2 changes: 1 addition & 1 deletion dbt_subprojects/dex/models/trades/optimism/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ models:
blockchain: optimism
sector: dex
project: saddle_finance
contributors: princi
contributors: princi, hosuke
config:
tags: [ 'optimism', 'dex', 'trades', 'saddle_finance']
description: "saddle finance optimism base trades"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
)
}}

--exclude, until resolved at model level: , ref('saddle_finance_optimism_base_trades')

{% set base_models = [
ref('uniswap_v3_optimism_base_trades')
, ref('woofi_optimism_base_trades')
Expand Down Expand Up @@ -35,7 +37,6 @@
, ref('elk_finance_optimism_base_trades')
, ref('fraxswap_optimism_base_trades')
, ref('swaap_v2_optimism_base_trades')
, ref('saddle_finance_optimism_base_trades')
, ref('bridgers_optimism_base_trades')
] %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{ config(
tags=['prod_exclude'],
schema = 'saddle_finance_optimism',
alias = 'base_trades',
partition_by = ['block_month'],
Expand All @@ -8,6 +9,11 @@
unique_key = ['tx_hash', 'evt_index']
) }}

-- Id mapping:
-- 0 DAI https://optimistic.etherscan.io/token/0xda10009cbd5d07dd0cecc66161fc93d7c9000da1
-- 1 USDC.e https://optimistic.etherscan.io/token/0x7f5c764cbc14f9669b88837ca1490cca17c31607
-- 2 USDT https://optimistic.etherscan.io/token/0x94b008aa00579c1307b0ef2c499ad98a8ce58e58

WITH token_swaps AS (
SELECT
evt_block_number AS block_number,
Expand All @@ -16,8 +22,16 @@ WITH token_swaps AS (
evt_tx_to AS taker,
tokensSold AS token_sold_amount_raw,
tokensBought AS token_bought_amount_raw,
CAST(soldId AS varbinary) AS token_sold_address,
CAST(boughtId AS varbinary) AS token_bought_address,
CASE soldId
WHEN 0 THEN 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1
WHEN 1 THEN 0x7f5c764cbc14f9669b88837ca1490cca17c31607
WHEN 2 THEN 0x94b008aa00579c1307b0ef2c499ad98a8ce58e58
END AS token_sold_address,
CASE boughtId
WHEN 0 THEN 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1
WHEN 1 THEN 0x7f5c764cbc14f9669b88837ca1490cca17c31607
WHEN 2 THEN 0x94b008aa00579c1307b0ef2c499ad98a8ce58e58
END AS token_bought_address,
contract_address AS project_contract_address,
evt_tx_hash AS tx_hash,
evt_index AS evt_index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ ethereum,pancakeswap,3,2023-04-01,0x942d7e8064aa1925e484ad9e38b25b0eea8620aa2b85
ethereum,pancakeswap,stableswap,2024-09-03 00:00:00.000 UTC,0x76706147bb031c1dff5386142d866ec083578420885fb24160124a66800ef418,299,0x2260fac5e5542a773aa44fbcfedf7c193bc2c599,0xbdf245957992bfbc62b07e344128a1eec7b7ee3f,20668595,9967437,10000000
ethereum,pancakeswap,stableswap,2024-09-04 00:00:00.000 UTC,0x6639947fd9c9d5e07425f2500f3f50b13bb7b4bd92316d5392866e759aa7e97c,74,0xbdf245957992bfbc62b07e344128a1eec7b7ee3f,0x2260fac5e5542a773aa44fbcfedf7c193bc2c599,20680551,1251896,1177998
ethereum,pancakeswap,stableswap,2024-09-08 00:00:00.000 UTC,0x7e07e90e2230148bd1a5c49ccaa94a36408dc3df2f39c923c6c49b154d6c7ba4,72,0x2260fac5e5542a773aa44fbcfedf7c193bc2c599,0xbdf245957992bfbc62b07e344128a1eec7b7ee3f,20704016,13399197,13511099
ethereum,pancakeswap,pcsx,2024-12-12,0xa9f85566c718fa84dfe82dfc9638e8383271856e1c61f2ba11d3c4d23be6c8fc,226,0xdac17f958d2ee523a2206206994597c13d831ec7,0x2260fac5e5542a773aa44fbcfedf7c193bc2c599,21386209,20000000000,20072678
ethereum,pancakeswap,pcsx,2024-12-12,0xdd63f84eca7f3b7cdfc174ae93b80d1fded3bc145be5a63479eb30c525e07f51,430,0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee,0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce,21386418,1610345878716657319,220881632899203791230293346
ethereum,pancakeswap,pcsx,2024-12-12,0x96a89245d9f67ae8f23bdb4c54879e805b727403bbef6214d08fdcc771aa3f51,447,0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48,0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9,21386687,553168032,1521057740000000000
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
blockchain,project,version,block_month,block_date,block_time,block_number,token_sold_amount_raw,token_bought_amount_raw,token_sold_address,token_bought_address,maker,taker,project_contract_address,tx_hash,evt_index
optimism,saddle_finance,1,2022-08-01 00:00,2022-08-05 00:00,2022-08-05 19:11,17943155,74907384,74857799085655995549,0x0000000000000000000000000000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000000000000000000000000001,0xd131f1bcdd547e067af447dd3c36c99d6be9fdeb,0xf6c2e0adc659007ba7c48446f5a4e4e94dfe08b5,0xf6c2e0adc659007ba7c48446f5a4e4e94dfe08b5,0xbccdcd4ab61e5ad3384eb173156c3c0507d3bb3f2d2f5a406379e74aafbec38d,3
optimism,saddle_finance,1,2022-08-01 00:00,2022-08-05 00:00,2022-08-05 19:11,17943155,74907384,74857799085655995549,0xda10009cbd5d07dd0cecc66161fc93d7c9000da1,0x7f5c764cbc14f9669b88837ca1490cca17c31607,0xd131f1bcdd547e067af447dd3c36c99d6be9fdeb,0xf6c2e0adc659007ba7c48446f5a4e4e94dfe08b5,0xf6c2e0adc659007ba7c48446f5a4e4e94dfe08b5,0xbccdcd4ab61e5ad3384eb173156c3c0507d3bb3f2d2f5a406379e74aafbec38d,3
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
blockchain,project,version,block_month,block_date,block_time,block_number,token_sold_amount_raw,token_bought_amount_raw,token_sold_address,token_bought_address,maker,taker,project_contract_address,tx_hash,evt_index
base,stablebase,1,2023-08-01,2023-08-28,2023-08-28 19:18:00.000,3230470,129976172599579374396,135180385,0x0000000000000000000000000000000000000000000000000000000000000001,0x0000000000000000000000000000000000000000000000000000000000000000,0x19fbc29d72476365a62151ffdbf4764e54774a81,0x8c59cc9b958635710957e751a9b4e77cd771baf2,0x8c59cc9b958635710957e751a9b4e77cd771baf2,0xc2dec669877f4edfcb7debd2eb23288a0fba8cd57d6f3fb3e45e8b15a6458d43,31
base,stablebase,1,2023-08-01,2023-08-28,2023-08-28 19:18:00.000,3230470,129976172599579374396,135180385,0x50c5725949a6f0c72e6c4a641f24049a917db0cb,0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca,0x19fbc29d72476365a62151ffdbf4764e54774a81,0x8c59cc9b958635710957e751a9b4e77cd771baf2,0x8c59cc9b958635710957e751a9b4e77cd771baf2,0xc2dec669877f4edfcb7debd2eb23288a0fba8cd57d6f3fb3e45e8b15a6458d43,31
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ known_solver_metadata (address, environment, name) as (
(0x0AC9287C83C2386A6a0bb27F847Ce59a0034183C, 'barn', 'Laita'),
(0x172FaCC5d970df43462b0f3aDe670d8cB86DC816, 'barn', 'ApeOut_1Inch'),
(0xBB765c920f86e2A2654c4B82deB5BC2E092fF93b, 'barn', 'Portus'),
(0xDF580073E21fFd7968F317B5359B934Eb6d58804, 'barn', 'Barter'),
(0x36Fd8A0C24B08F7bb4af8d6eaA6245C3884fC682, 'prod', 'Barter'),
(0x1a72876ebE781E42aB2Ee4278B539688D8B80E2D, 'prod', 'ApeOut_1Inch'),
(0x6bf97aFe2D2C790999cDEd2a8523009eB8a0823f, 'prod', 'Portus'),
(0x69d7F96dFD091652f317D0734A5F2B492ACcbE07, 'prod', 'Baseline'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -793,5 +793,7 @@ FROM (VALUES
, ('bitcoin', '3CjxgnmNsu3kaFadzVea2FgECuHN7y2ENz', 'Bitcoin Suisse', 'Bitcoin Suisse 7', 'hildobby', date '2024-05-27')

, ('bitcoin', 'bc1qu2dq8w8lv8v3l7lr2c5tvx3yltv22r3nhkx7w0', 'eXch.sc', 'eXch.sc 1', 'hildobby', date '2024-09-06')

, ('bitcoin', 'bc1qlnkyrrupehgw5evu43erlgkhhagv0uj3yyhacvc65n3ud6qeas0sa958ps', 'Arkham', 'Arkham 1', 'hildobby', date '2024-12-13')

) AS x (blockchain, address, cex_name, distinct_name, added_by, added_date)
Loading

0 comments on commit e8cbc0e

Please sign in to comment.