-
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.
- Loading branch information
Showing
33 changed files
with
621 additions
and
78 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
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
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
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
21 changes: 21 additions & 0 deletions
21
dbt_subprojects/dex/models/trades/sonic/platforms/wagmi_sonic_base_trades.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,21 @@ | ||
{{ | ||
config( | ||
schema = 'wagmi_sonic', | ||
alias = 'base_trades', | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['tx_hash', 'evt_index'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{{ | ||
uniswap_compatible_v3_trades( | ||
blockchain = 'sonic', | ||
project = 'wagmi', | ||
version = '3', | ||
Pair_evt_Swap = source('wagmi_sonic', 'UniswapV3Pool_evt_Swap'), | ||
Factory_evt_PoolCreated = source('wagmi_sonic', 'UniswapV3Factory_evt_PoolCreated') | ||
) | ||
}} |
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
3 changes: 3 additions & 0 deletions
3
dbt_subprojects/dex/seeds/trades/wagmi_sonic_base_trades_seed.csv
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,3 @@ | ||
blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw | ||
sonic,wagmi,3,2025-01-21,0x8c447cc48a4488870ac0a5a39f42e764a50f159fa9fbadace10a2dca77640f1a,2,0x50c42deacd8fc9773493ed674b675be577f2634b,0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38,4847335,50421632945765830,271700000000000000000 | ||
sonic,wagmi,3,2025-01-21,0x38155f722ac19c89b6b9798d11467bcd9e2ec9ac463dbb09ad3e8b95d0e03cdd,8,0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38,0x50c42deacd8fc9773493ed674b675be577f2634b,4848299,2397204077986245906501,450000000000000000 |
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
Oops, something went wrong.