-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init morpho on base * fix base flashloans schema yml indentation * fix base lending supply yml file * add data source for base morpo * deduplicate morpho base data sources * fixed mopho typo * fix morpho typo again * correct seed file time formating * correct date format * correct seed files due to scientific notation instead of actual integer numbers --------- Co-authored-by: jeff-dude <[email protected]>
- Loading branch information
1 parent
c4c4123
commit 383642f
Showing
16 changed files
with
403 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
...hourly_spellbook/models/_sector/lending/borrow/base/platforms/morpho_base_base_borrow.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...pellbook/models/_sector/lending/flashloans/base/platforms/morpho_base_base_flashloans.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...hourly_spellbook/models/_sector/lending/supply/base/platforms/morpho_base_base_supply.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{{ | ||
config( | ||
schema = 'morpho_base', | ||
alias = 'base_supply', | ||
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') }} | ||
) | ||
|
||
SELECT 'base' AS blockchain | ||
, 'morpho' AS project | ||
, '1' AS version | ||
, 'deposit' AS transaction_type | ||
, loanToken AS token_address | ||
, caller AS depositor | ||
, onBehalf AS on_behalf_of | ||
, CAST(NULL AS varbinary) AS withdrawn_to | ||
, CAST(NULL AS varbinary) AS liquidator | ||
, CAST(assets AS double) AS 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 {{ source('morpho_blue_base', 'MorphoBlue_evt_Supply') }} | ||
INNER JOIN markets USING (id) | ||
{% if is_incremental() %} | ||
WHERE {{ incremental_predicate('evt_block_time') }} | ||
{% endif %} | ||
|
||
UNION ALL | ||
|
||
SELECT 'base' AS blockchain | ||
, 'morpho' AS project | ||
, '1' AS version | ||
, 'withdraw' AS transaction_type | ||
, loanToken AS token_address | ||
, CAST(NULL AS varbinary) AS depositor | ||
, onBehalf AS on_behalf_of | ||
, receiver AS withdrawn_to | ||
, CAST(NULL AS varbinary) AS liquidator | ||
, -1 * CAST(assets AS double) AS 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 {{ source('morpho_blue_base', 'MorphoBlue_evt_Withdraw') }} | ||
INNER JOIN markets USING (id) | ||
{% if is_incremental() %} | ||
WHERE {{ incremental_predicate('evt_block_time') }} | ||
{% endif %} | ||
|
||
UNION ALL | ||
|
||
SELECT 'base' AS blockchain | ||
, 'morpho' AS project | ||
, '1' AS version | ||
, 'deposit_liquidation' AS transaction_type | ||
, loanToken AS token_address | ||
, borrower AS depositor | ||
, CAST(NULL AS varbinary) AS on_behalf_of | ||
, caller AS withdrawn_to | ||
, caller AS liquidator | ||
, -1 * CAST(seizedAssets AS double) AS 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 {{ source('morpho_blue_base', 'MorphoBlue_evt_Liquidate') }} | ||
INNER JOIN markets USING (id) | ||
{% if is_incremental() %} | ||
WHERE {{ incremental_predicate('evt_block_time') }} | ||
{% endif %} |
Oops, something went wrong.