Skip to content

Commit

Permalink
Merge pull request #151 from Synthetixio/tlx-rebalanced
Browse files Browse the repository at this point in the history
TLX: add rebalanced model
  • Loading branch information
Tburm authored Dec 10, 2024
2 parents dfe3b18 + 28d7b0a commit 62b74d3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
select
id,
block_number,
block_timestamp as ts,
transaction_hash,
contract,
event_name,
token,
cast(
regexp_replace(token, '.*_(long|short)', '') as int
) as leverage,
{{ convert_wei('current_leverage') }} as current_leverage
from {{ ref('tlx_lt_rebalanced_optimism_mainnet') }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{ config(
materialized = 'incremental',
unique_key = 'id',
post_hook = [ "create index if not exists idx_id on {{ this }} (id)", "create index if not exists idx_block_number on {{ this }} (block_number)", "create index if not exists idx_block_timestamp on {{ this }} (block_timestamp)", "create index if not exists idx_token on {{ this }} (token)", "create index if not exists idx_contract on {{ this }} (contract)" ]
) }}

with events as (
{{ get_tlx_event_data('optimism', 'mainnet', 'rebalanced') }} -- noqa
)

select * -- noqa: ST06
from
events
where
{% if is_incremental() %}
block_number > (
select coalesce(max(t.block_number), 0) as b
from {{ this }} as t
)
{% else %}
true
{% endif %}
order by
id

0 comments on commit 62b74d3

Please sign in to comment.