Slippage accounting is performed on a per settlement/transaction basis according to the following two primary components. The SQL source code can be found on GitHub or Dune Analytics
The token balance sheet represents a classified account of all incoming and outgoing token transfers relative to the settlement contract.
Classification categories are USER_{IN/OUT}
, AMM_{IN/OUT}
.
In all cases IN
represents settlement contract as recipient
and OUT
as sender
!
USER_{IN/OUT}
transfers are those emitted by the Settlement contract's Trade Event (withUSER_IN
adjusted for fees).AMM_{IN/OUT}
classification is assigned to all on-chain transfers that are NOT user transfers
Note that AMM_IN/OUT
also captures WETH
and sDAI
(un)wraps.
Token prices are taken as the hourly mean over Dune's prices.usd
table in combination with the "intrinsic" token prices provided in settlements.
SQL code for price table is here