Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing transfers for sDAI deposits and withdraws #327

Merged
merged 4 commits into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion queries/dune_v2/period_slippage.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- https://github.com/cowprotocol/solver-rewards/pull/322
-- https://github.com/cowprotocol/solver-rewards/pull/327
-- Query Here: https://dune.com/queries/3093726
with
batch_meta as (
Expand Down Expand Up @@ -125,6 +125,35 @@ batch_meta as (
-- ETH transfers to traders are already part of USER_OUT
and not contains(traders_out, to)
)
-- sDAI emits only one transfer event for deposits and withdrawals.
-- This reconstructs the missing transfer from event logs.
,sdai_deposit_withdrawal_transfers as (
-- withdraw events result in additional AMM_IN transfer
select
tx_hash,
0x9008d19f58aabd9ed0d60971565aa8510560ab41 as sender,
0x0000000000000000000000000000000000000000 as receiver,
contract_address as token,
cast(shares as int256) as amount_wei,
'AMM_IN' as transfer_type
from batch_meta bm
join maker_ethereum.SavingsDai_evt_Withdraw w
on w.evt_tx_hash= bm.tx_hash
where sender = 0x9008d19f58aabd9ed0d60971565aa8510560ab41
union all
-- deposit events result in additional AMM_OUT transfer
select
tx_hash,
0x0000000000000000000000000000000000000000 as sender,
0x9008d19f58aabd9ed0d60971565aa8510560ab41 as receiver,
contract_address as token,
cast(shares as int256) as amount_wei,
'AMM_OUT' as transfer_type
from batch_meta bm
join maker_ethereum.SavingsDai_evt_Deposit w
on w.evt_tx_hash= bm.tx_hash
where owner = 0x9008d19f58aabd9ed0d60971565aa8510560ab41
)
,pre_batch_transfers as (
select * from (
select * from user_in
Expand All @@ -134,6 +163,8 @@ batch_meta as (
select * from other_transfers
union all
select * from eth_transfers
union all
select * from sdai_deposit_withdrawal_transfers
) as _
order by tx_hash
)
Expand Down
Loading