Skip to content

Commit

Permalink
chore: disable auto-deploy & refresh db
Browse files Browse the repository at this point in the history
  • Loading branch information
tomfutago committed Dec 13, 2024
1 parent a8b3c5b commit 29c9cfb
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy_wm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Deploy Wallet Monitoring to GitHub Pages

on:
#workflow_dispatch: # temp disable / run manually
push:
branches: 'main'
#push:
# branches: 'main'

jobs:
build:
Expand Down
Binary file modified data/wallets.duckdb
Binary file not shown.
176 changes: 173 additions & 3 deletions monitor/pages/test.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,176 @@
## test

```test
with
```mapping
select * from wallets.wallet_positions
```
mapping_full as (
select plan, protocol, zapper_id, zapper_name, zerion_id, zerion_name
from wallets.src_plan_mapping
),
mapping_unique_procols as (
select distinct protocol, zapper_id, zapper_name, zerion_id, zerion_name
from wallets.src_plan_mapping
),
prices as (
select
block_date,
avg_eth_usd_price
from wallets.src_capital_pool
),
zerion_data_latest as (
select
zp.cover_id,
zp.chain_id as chain,
zp.address,
m.protocol,
max_by(zp.value, zp.inserted_at) as amount_usd,
max_by(zp.value / p.avg_eth_usd_price, zp.inserted_at) as amount_eth,
max_by(cast(zp.updated_at as timestamp), zp.inserted_at) as updated_at,
max(zp.inserted_at) as inserted_at
from wallets.src_zerion_data zp
inner join mapping_unique_procols m on zp.app_id = m.zerion_id
left join prices p on zp.updated_at::date = p.block_date::date
where zp.position_type <> 'wallet'
group by 1, 2, 3, 4
)
select * from zerion_data_latest
```

```plan_list
select
pc.plan,
pc.cnt_cover,
pc.cnt_wallet,
pc.usd_cover,
pc.eth_cover,
pw.usd_exposed,
pw.eth_exposed
from wallets.int_plan_cover_agg pc
left join wallets.int_plan_wallet_agg pw on pc.plan_id = pw.plan_id
order by pc.plan_id
```

```plan_protocol_list
select
pc.plan,
pw.protocol,
pc.cnt_cover,
pc.cnt_wallet,
pc.usd_cover,
pc.eth_cover,
pw.usd_exposed,
pw.eth_exposed
from wallets.int_plan_cover_agg pc
left join wallets.int_plan_protocol_wallet_agg pw on pc.plan_id = pw.plan_id
order by pc.plan_id
```

```plan_stack
with agg_wallet_positions as (
select
plan_id,
plan,
'Covered Amount' as total_type,
usd_cover as usd_total,
eth_cover as eth_total
from wallets.int_plan_cover_agg
union all
select
plan_id,
plan,
'Exposed Funds' as total_type,
usd_exposed as usd_total,
eth_exposed as eth_total
from wallets.int_plan_wallet_agg
)
select
plan,
total_type,
usd_total,
eth_total
from agg_wallet_positions
order by plan_id
```

<ButtonGroup name=plan title="Select Plan">
<ButtonGroupItem valueLabel="Entry Cover" value="Entry Cover" />
<ButtonGroupItem valueLabel="Essential Cover" value="Essential Cover" />
<ButtonGroupItem valueLabel="Elite Cover" value="Elite Cover" default />
</ButtonGroup>

```protocol_stack
with agg_wallet_positions as (
select
plan_id,
plan,
plan as protocol,
'Covered Amount' as total_type,
usd_cover as usd_total,
eth_cover as eth_total
from wallets.int_plan_cover_agg
union all
select
plan_id,
plan,
protocol,
'Exposed Funds' as total_type,
usd_exposed as usd_total,
eth_exposed as eth_total
from wallets.int_plan_protocol_wallet_agg
)
select
protocol,
total_type,
usd_total,
eth_total
from agg_wallet_positions
where plan = '${inputs.plan}'
order by 1
```

<Tabs>
<Tab label='USD'>
<BarChart
data={protocol_stack}
title='Totals'
x=total_type
y=usd_total
series=protocol
swapXY=true
/>
<BarChart
data={protocol_stack}
title='% Share'
x=total_type
y=usd_total
series=protocol
type=stacked100
swapXY=true
/>
</Tab>
<Tab label='ETH'>
<BarChart
data={protocol_stack}
title='Totals'
x=protocol
y=eth_total
series=total_type
swapXY=true
type=grouped
/>
<BarChart
data={protocol_stack}
title="% Share"
x=protocol
y=eth_total
series=total_type
type=stacked100
labels=true
swapXY=true
/>
</Tab>
</Tabs>
Binary file modified monitor/sources/wallets/wallets.duckdb
Binary file not shown.
8 changes: 4 additions & 4 deletions wallet_pipeline/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,16 @@ def loop_through_cover_wallets():
#pull_zapper_positions(api_key=zapper_api_key, cover_id=-1, address="0x036d6e8b88e21760f6759a31dabc8bdf3f026b98")

#clean_up_db(table_name="plan_mapping", drop_table=True, truncate_table=False)
duckdb_con.execute("CREATE TABLE plan_mapping AS FROM './data/plan_mapping.csv'")
#duckdb_con.execute("CREATE TABLE plan_mapping AS FROM './data/plan_mapping.csv'")

# refresh base Dune data (flush & fill)
#pull_capital_pool()
#pull_cover_wallets()
pull_capital_pool()
pull_cover_wallets()

# load wallets data
#clean_up_db(table_name="zerion_positions", drop_table=False, truncate_table=True)
#clean_up_db(table_name="zapper_positions", drop_table=False, truncate_table=True)
#loop_through_cover_wallets()
loop_through_cover_wallets()

# close duckdb connection
duckdb_con.close()

0 comments on commit 29c9cfb

Please sign in to comment.