Skip to content

Commit 5dd8115

Browse files
committed
feat(release): updates to dex.trades, balancer, curve, 1inch, clipper, and LBPs
Signed-off-by: sam bacha <[email protected]>
1 parent 84c3dfd commit 5dd8115

17 files changed

+704
-304
lines changed

CHANGELOG.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.8.1
1+
v1.8.2

dune/balancer/view_swaps.sql

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
CREATE OR REPLACE VIEW balancer.view_swaps AS
22
SELECT
3-
block_time,
4-
token_a_symbol,
5-
token_b_symbol,
6-
token_a_amount,
7-
token_b_amount,
8-
trader_a,
9-
trader_b,
10-
token_a_amount_raw,
11-
token_b_amount_raw,
12-
usd_amount,
13-
token_a_address,
14-
token_b_address,
15-
exchange_contract_address AS contract_address,
16-
tx_hash,
17-
tx_from,
18-
trace_address,
19-
evt_index
20-
FROM
21-
dex.trades
22-
WHERE
23-
project = 'Balancer';
3+
block_time,
4+
token_a_symbol,
5+
token_b_symbol,
6+
token_a_amount,
7+
token_b_amount,
8+
trader_a,
9+
trader_b,
10+
token_a_amount_raw,
11+
token_b_amount_raw,
12+
usd_amount,
13+
token_a_address,
14+
token_b_address,
15+
exchange_contract_address AS contract_address,
16+
tx_hash,
17+
tx_from,
18+
trace_address,
19+
evt_index
20+
FROM dex.trades
21+
WHERE project = 'Balancer'

dune/curvefi/view_trades.sql

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ CREATE OR REPLACE VIEW curvefi.view_trades (
3636
evt_tx_hash AS tx_hash,
3737
NULL::integer[] AS trace_address,
3838
evt_index
39-
FROM curvefi."susd_v2_evt_TokenExchange"
39+
FROM curvefi."susd_swap_evt_TokenExchange"
4040

4141
UNION
4242

@@ -64,7 +64,7 @@ SELECT
6464
evt_tx_hash AS tx_hash,
6565
NULL::integer[] AS trace_address,
6666
evt_index
67-
FROM curvefi."susd_v2_evt_TokenExchangeUnderlying"
67+
FROM curvefi."susd_swap_evt_TokenExchangeUnderlying"
6868

6969
UNION
7070

@@ -208,7 +208,7 @@ SELECT
208208
evt_tx_hash AS tx_hash,
209209
NULL::integer[] AS trace_address,
210210
evt_index
211-
FROM curvefi."compound_v3_evt_TokenExchange"
211+
FROM curvefi."compound_swap_evt_TokenExchange"
212212

213213
UNION
214214

@@ -232,7 +232,7 @@ SELECT
232232
evt_tx_hash AS tx_hash,
233233
NULL::integer[] AS trace_address,
234234
evt_index
235-
FROM curvefi."compound_v3_evt_TokenExchangeUnderlying"
235+
FROM curvefi."compound_swap_evt_TokenExchangeUnderlying"
236236

237237
UNION
238238

@@ -258,7 +258,7 @@ SELECT
258258
evt_tx_hash AS tx_hash,
259259
NULL::integer[] AS trace_address,
260260
evt_index
261-
FROM curvefi."usdt_evt_TokenExchange"
261+
FROM curvefi."usdt_swap_evt_TokenExchange"
262262

263263
UNION
264264

@@ -284,7 +284,7 @@ SELECT
284284
evt_tx_hash AS tx_hash,
285285
NULL::integer[] AS trace_address,
286286
evt_index
287-
FROM curvefi."usdt_evt_TokenExchangeUnderlying"
287+
FROM curvefi."usdt_swap_evt_TokenExchangeUnderlying"
288288

289289
UNION
290290

@@ -312,7 +312,7 @@ SELECT
312312
evt_tx_hash AS tx_hash,
313313
NULL::integer[] AS trace_address,
314314
evt_index
315-
FROM curvefi."y_evt_TokenExchange"
315+
FROM curvefi."y_swap_evt_TokenExchange"
316316

317317
UNION
318318

@@ -340,7 +340,7 @@ SELECT
340340
evt_tx_hash AS tx_hash,
341341
NULL::integer[] AS trace_address,
342342
evt_index
343-
FROM curvefi."y_evt_TokenExchangeUnderlying"
343+
FROM curvefi."y_swap_evt_TokenExchangeUnderlying"
344344

345345
UNION
346346

@@ -368,7 +368,7 @@ SELECT
368368
evt_tx_hash AS tx_hash,
369369
NULL::integer[] AS trace_address,
370370
evt_index
371-
FROM curvefi."busd_evt_TokenExchange"
371+
FROM curvefi."busd_swap_evt_TokenExchange"
372372

373373
UNION
374374

@@ -396,7 +396,7 @@ SELECT
396396
evt_tx_hash AS tx_hash,
397397
NULL::integer[] AS trace_address,
398398
evt_index
399-
FROM curvefi."busd_evt_TokenExchangeUnderlying"
399+
FROM curvefi."busd_swap_evt_TokenExchangeUnderlying"
400400

401401
UNION
402402

@@ -424,7 +424,7 @@ SELECT
424424
evt_tx_hash AS tx_hash,
425425
NULL::integer[] AS trace_address,
426426
evt_index
427-
FROM curvefi."pax_evt_TokenExchange"
427+
FROM curvefi."pax_swap_evt_TokenExchange"
428428

429429
UNION
430430

@@ -452,7 +452,7 @@ SELECT
452452
evt_tx_hash AS tx_hash,
453453
NULL::integer[] AS trace_address,
454454
evt_index
455-
FROM curvefi."pax_evt_TokenExchangeUnderlying"
455+
FROM curvefi."pax_swap_evt_TokenExchangeUnderlying"
456456

457457
UNION
458458

@@ -478,7 +478,7 @@ SELECT
478478
evt_tx_hash AS tx_hash,
479479
NULL::integer[] AS trace_address,
480480
evt_index
481-
FROM curvefi."renbtc_evt_TokenExchange"
481+
FROM curvefi."ren_swap_evt_TokenExchange"
482482

483483
UNION
484484

@@ -506,7 +506,7 @@ SELECT
506506
evt_tx_hash AS tx_hash,
507507
NULL::integer[] AS trace_address,
508508
evt_index
509-
FROM curvefi."sbtc_evt_TokenExchange"
509+
FROM curvefi."sbtc_swap_evt_TokenExchange"
510510

511511
UNION
512512

@@ -532,7 +532,7 @@ SELECT
532532
evt_tx_hash AS tx_hash,
533533
NULL::integer[] AS trace_address,
534534
evt_index
535-
FROM curvefi."hbtc_evt_TokenExchange"
535+
FROM curvefi."hbtc_swap_evt_TokenExchange"
536536

537537
UNION
538538

@@ -558,7 +558,7 @@ SELECT
558558
evt_tx_hash AS tx_hash,
559559
NULL::integer[] AS trace_address,
560560
evt_index
561-
FROM curvefi."dai_usdc_usdt_evt_TokenExchange"
561+
FROM curvefi."threepool_swap_evt_TokenExchange"
562562

563563
UNION
564564

@@ -582,7 +582,7 @@ SELECT
582582
evt_tx_hash AS tx_hash,
583583
NULL::integer[] AS trace_address,
584584
evt_index
585-
FROM curvefi."steth_evt_TokenExchange"
585+
FROM curvefi."steth_swap_evt_TokenExchange"
586586

587587
UNION
588588

@@ -608,4 +608,4 @@ SELECT
608608
evt_tx_hash AS tx_hash,
609609
NULL::integer[] AS trace_address,
610610
evt_index
611-
FROM curvefi."tricrypto_evt_TokenExchange"
611+
FROM curvefi."tricrypto_swap_evt_TokenExchange"

dune/dex/trades/insert_1inch.sql

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,31 @@ WITH rows AS (
150150
FROM oneinch."LimitOrderProtocol_call_fillOrder" call
151151
LEFT JOIN ethereum.traces ts ON call_tx_hash = ts.tx_hash AND call_trace_address = ts.trace_address
152152
WHERE call_success
153+
154+
UNION ALL
155+
156+
-- 1inch Limit Order Protocol RFQ
157+
SELECT
158+
call_block_time as block_time,
159+
'1inch Limit Order Protocol' AS project,
160+
'RFQ v1' AS version,
161+
'DEX' AS category,
162+
ts."from" AS trader_a,
163+
decode(substring("order"::jsonb->>'makerAssetData' from 35 for 40), 'hex') AS trader_b,
164+
bytea2numeric(substring(tf2.input from 69 for 32)) AS token_a_amount_raw,
165+
bytea2numeric(substring(tf1.input from 69 for 32)) AS token_b_amount_raw,
166+
NULL::numeric AS usd_amount,
167+
decode(substring("order"::jsonb->>'takerAsset' from 3), 'hex') AS token_a_address,
168+
decode(substring("order"::jsonb->>'makerAsset' from 3), 'hex') AS token_b_address,
169+
contract_address AS exchange_contract_address,
170+
call_tx_hash,
171+
call_trace_address,
172+
NULL AS evt_index
173+
FROM oneinch."LimitOrderProtocol_call_fillOrderRFQ" call
174+
LEFT JOIN ethereum.traces ts ON call_tx_hash = ts.tx_hash AND ts.trace_address = call_trace_address
175+
LEFT JOIN ethereum.traces tf1 ON call_tx_hash = tf1.tx_hash AND tf1.trace_address = COALESCE(call_trace_address, '{}') || (ts.sub_traces-2)
176+
LEFT JOIN ethereum.traces tf2 ON call_tx_hash = tf2.tx_hash AND tf2.trace_address = COALESCE(call_trace_address, '{}') || (ts.sub_traces-1)
177+
WHERE call_success
153178
) dexs
154179
INNER JOIN ethereum.transactions tx
155180
ON dexs.tx_hash = tx.hash

dune/dex/trades/trades.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ CREATE INDEX IF NOT EXISTS dex_trades_block_time_idx ON dex.trades USING BRIN (b
3232
CREATE INDEX IF NOT EXISTS dex_trades_token_a_idx ON dex.trades (token_a_address);
3333
CREATE INDEX IF NOT EXISTS dex_trades_token_b_idx ON dex.trades (token_b_address);
3434
CREATE INDEX IF NOT EXISTS dex_trades_block_time_project_idx ON dex.trades (block_time, project);
35+
CREATE INDEX CONCURRENTLY IF NOT EXISTS dex_trades_usd_amount_idx ON dex.trades (usd_amount);

dune/nft/trades/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ This repo collects trade data of NFT marketplaces in a single table `nft.trades`
44

55
The goal is to enable a powerful new wave of Dune dashboards on NFTs, and inspire new contributors to add more marketplaces and NFT data.
66

7+
ERC721 and ERC1155 `transfer` data is integrated for every trade transaction to enable analysis of trades consisting of multiple NFTs.
8+
79
Known limitations:
810
- OpenSea and Rarible support non-ETH trades. Some of the tokens used for these transactions are not in Dune's `prices.usd`. In these cases, the `usd_amount` is `NULL`. At the time of writing (July 2021), for OpenSea and Rarible, the percentage of rows with missing USD values is 2% or less.
9-
- Some column data for less common trades such as bundle sales or multiple transfers in one transaction will be incorrect e.g. the column `nft_token_id`. On the tests we did, the `buyer` and `amount` fields were correct.
1011
- In some cases, there are rounding errors on the `original_amount` fields.
1112

1213

0 commit comments

Comments
 (0)