Skip to content

Commit

Permalink
Merge branch 'shuriken-add-new-fee-wallet' of https://github.com/whal…
Browse files Browse the repository at this point in the history
…ehunting/spellbook into shuriken-add-new-fee-wallet
  • Loading branch information
clizzard7 committed Jan 22, 2025
2 parents 9debab0 + eb45427 commit b1977bb
Show file tree
Hide file tree
Showing 19 changed files with 411 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ cover_sales as (
from {{ source('nexusmutual_ethereum', 'Cover_call_buyCover') }} c
cross join unnest(c.poolAllocationRequests) as t(pool_allocation)
where c.call_success
and c.contract_address = 0xcafeac0fF5dA0A2777d915531bfA6B29d282Ee62 -- proxy
),

staking_product_premiums as (
Expand All @@ -64,7 +65,8 @@ staking_product_premiums as (
call_tx_hash as tx_hash
from {{ source('nexusmutual_ethereum', 'StakingProducts_call_getPremium') }}
where call_success
and contract_address = 0xcafea573fbd815b5f59e8049e71e554bde3477e4
--and contract_address = 0xcafea573fbd815b5f59e8049e71e554bde3477e4
and contract_address <> 0xcafea524e89514e131ee9f8462536793d49d8738
),

cover_premiums as (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ staking_pools_created as (
call_tx_hash as tx_hash_created
from {{ source('nexusmutual_ethereum', 'Cover_call_createStakingPool') }}
where call_success
and contract_address = 0xcafeac0fF5dA0A2777d915531bfA6B29d282Ee62
and contract_address = 0xcafeac0fF5dA0A2777d915531bfA6B29d282Ee62 -- proxy
union all
select
select
call_block_time as block_time_created,
output_0 as pool_id,
output_1 as pool_address,
Expand Down Expand Up @@ -94,7 +94,8 @@ staking_pool_products_updated as (
from {{ source('nexusmutual_ethereum', 'StakingProducts_call_setProducts') }} as p
cross join unnest(params) as t(json)
where p.call_success
and p.contract_address = 0xcafea573fBd815B5f59e8049E71E554bde3477E4
--and p.contract_address = 0xcafea573fBd815B5f59e8049E71E554bde3477E4
and p.contract_address <> 0xcafea524e89514e131ee9f8462536793d49d8738
and cast(json_query(t.json, 'lax $.setTargetWeight') as boolean) = true
) t
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ select
, coalesce(dst_amount, taking_amount) as taking_amount
, order_hash
, map_concat(flags, map_from_entries(array[
('first', row_number() over(partition by coalesce(order_hash, tx_hash) order by block_number, tx_index, call_trace_address) = 1)
('first', row_number() over(partition by coalesce(order_hash, tx_hash), tx_success and call_success order by block_number, tx_index, call_trace_address) = 1)
, ('direct', call_from = tx_from and call_to = tx_to) -- == cardinality(call_trace_address) = 0, but because of zksync trace structure we switched to this
])) as flags
, remains
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,39 @@ models:
- *project_contract_address
- *tx_hash
- *evt_index

- name: morpho_base_base_borrow
meta:
blockchain: base
sector: lending
project: Morpho
contributors: 0xDataWolf
config:
tags: ['lending', 'borrow', 'Morpho', 'base']
description: "Morpho borrow transactions on Base"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- transaction_type
- token_address
- tx_hash
- evt_index
- check_lending_base_borrow_seed:
seed_file: ref('morpho_base_base_borrow_seed')
columns:
- *blockchain
- *project
- *version
- *transaction_type
- *token_address
- *borrower
- *on_behalf_of
- *repayer
- *liquidator
- *amount
- *block_month
- *block_time
- *block_number
- *project_contract_address
- *tx_hash
- *evt_index
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
ref('seamlessprotocol_base_base_borrow'),
ref('moonwell_base_base_borrow'),
ref('sonne_finance_base_base_borrow'),
ref('granary_base_base_borrow')
ref('granary_base_base_borrow'),
ref('morpho_base_base_borrow')
]
%}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{{
config(
schema = 'morpho_base',
alias = 'base_borrow',
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['transaction_type', 'token_address', 'tx_hash', 'evt_index'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)
}}

WITH markets AS (
SELECT id
, from_hex(JSON_EXTRACT_SCALAR("marketParams", '$.loanToken')) AS loanToken
, from_hex(JSON_EXTRACT_SCALAR("marketParams", '$.collateralToken')) AS collateralToken
, from_hex(JSON_EXTRACT_SCALAR("marketParams", '$.oracle')) AS oracle
, JSON_EXTRACT_SCALAR("marketParams", '$.irm') AS irm
, JSON_EXTRACT_SCALAR("marketParams", '$.lltv') AS lltv
FROM {{ source('morpho_blue_base', 'MorphoBlue_evt_CreateMarket') }}
)

, base_borrow AS (
SELECT 'borrow' AS transaction_type
, 'variable' AS loan_type
, loanToken AS token_address
, caller AS borrower
, onBehalf AS on_behalf_of
, CAST(NULL AS varbinary) AS repayer
, CAST(NULL AS varbinary) AS liquidator
, CAST(assets AS double) AS amount
, contract_address
, evt_tx_hash
, evt_index
, evt_block_time
, evt_block_number
FROM {{ source('morpho_blue_base', 'MorphoBlue_evt_Borrow') }}
INNER JOIN markets USING (id)
{% if is_incremental() %}
WHERE {{ incremental_predicate('evt_block_time') }}
{% endif %}

UNION ALL

SELECT 'repay' AS transaction_type
, NULL AS loan_type
, loanToken AS token_address
, caller AS borrower
, onBehalf AS on_behalf_of
, caller AS repayer
, cast(null as varbinary) AS liquidator
, -1 * cast(assets AS double) AS amount
, contract_address
, evt_tx_hash
, evt_index
, evt_block_time
, evt_block_number
FROM {{ source('morpho_blue_base', 'MorphoBlue_evt_Repay') }}
INNER JOIN markets USING (id)
{% if is_incremental() %}
WHERE {{ incremental_predicate('evt_block_time') }}
{% endif %}

UNION ALL

select 'borrow_liquidation' AS transaction_type
, null AS loan_type
, loanToken AS token_address
, borrower
, borrower AS on_behalf_of
, caller AS repayer
, caller AS liquidator
, -1 * cast(repaidAssets AS double) AS amount
, contract_address
, evt_tx_hash
, evt_index
, evt_block_time
, evt_block_number
FROM {{ source('morpho_blue_base', 'MorphoBlue_evt_Liquidate') }}
INNER JOIN markets USING (id)
{% if is_incremental() %}
WHERE {{ incremental_predicate('evt_block_time') }}
{% endif %}
)

SELECT 'base' AS blockchain
, 'morpho' AS project
, '1' AS version
, transaction_type
, loan_type
, token_address
, borrower
, on_behalf_of
, repayer
, liquidator
, amount
, CAST(date_trunc('month', evt_block_time) AS date) AS block_month
, evt_block_time AS block_time
, evt_block_number AS block_number
, contract_address AS project_contract_address
, evt_tx_hash AS tx_hash
, evt_index
FROM base_borrow
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,35 @@ models:
- *block_number
- *tx_hash
- *evt_index

- name: morpho_base_base_flashloans
meta:
blockchain: base
sector: lending
project: morpho
contributors: 0xDataWolf
config:
tags: ['lending', 'flashloans', 'morpho', 'base']
description: "Morpho flashloans transactions on Base"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index
- check_lending_base_flashloans_seed:
seed_file: ref('morpho_base_base_flashloans_seed')
columns:
- *blockchain
- *project
- *version
- *recipient
- *amount
- *fee
- *token_address
- *project_contract_address
- *block_month
- *block_time
- *block_number
- *tx_hash
- *evt_index

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
ref('aave_v3_base_base_flashloans'),
ref('seamlessprotocol_base_base_flashloans'),
ref('granary_base_base_flashloans'),
ref('balancer_v2_base_base_flashloans')
ref('balancer_v2_base_base_flashloans'),
ref('morpho_base_base_flashloans')
]
%}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{
config(
schema = 'morpho_base',
alias = 'base_flashloans',
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['tx_hash', 'evt_index'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)
}}

SELECT 'base' AS blockchain
, 'morpho' AS project
, '1' AS version
, caller AS recipient
, assets AS amount
, CAST(0 AS UINT256) AS fee
, token AS token_address
, contract_address AS project_contract_address
, date_trunc('month', evt_block_time) AS block_month
, evt_block_time AS block_time
, evt_block_number AS block_number
, evt_tx_hash AS tx_hash
, evt_index
FROM {{ source('morpho_blue_base', 'MorphoBlue_evt_FlashLoan') }}
{% if is_incremental() %}
WHERE {{ incremental_predicate('evt_block_time') }}
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,39 @@ models:
- *project_contract_address
- *tx_hash
- *evt_index

- name: morpho_base_base_supply
meta:
blockchain: base
sector: lending
project: Morpho
contributors: 0xDataWolf
config:
tags: ['lending', 'supply', 'morpho', 'base']
description: "Morpho supply transactions on Base"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- transaction_type
- token_address
- tx_hash
- evt_index
- check_lending_base_supply_seed:
seed_file: ref('morpho_base_base_supply_seed')
columns:
- *blockchain
- *project
- *version
- *transaction_type
- *token_address
- *depositor
- *on_behalf_of
- *withdrawn_to
- *liquidator
- *amount
- *block_month
- *block_time
- *block_number
- *project_contract_address
- *tx_hash
- *evt_index
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
ref('seamlessprotocol_base_base_supply'),
ref('moonwell_base_base_supply'),
ref('sonne_finance_base_base_supply'),
ref('granary_base_base_supply')
ref('granary_base_base_supply'),
ref('morpho_base_base_supply')
]
%}

Expand Down
Loading

0 comments on commit b1977bb

Please sign in to comment.