Skip to content

Instantly share code, notes, and snippets.

@alexkroeger
Created July 23, 2019 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexkroeger/24ef854678cc748f06cf3e25d1fb06cf to your computer and use it in GitHub Desktop.
Save alexkroeger/24ef854678cc748f06cf3e25d1fb06cf to your computer and use it in GitHub Desktop.
BigQuery Query to get dYdX tx failures due to getExchangeCost() reverts
WITH
wrapper_tx AS (
SELECT DISTINCT
t.transaction_hash
FROM `bigquery-public-data.crypto_ethereum.traces` t
LEFT JOIN `bigquery-public-data.crypto_ethereum.transactions` tx ON tx.hash = t.transaction_hash
WHERE
-- 0x V2 contracts
LOWER(t.to_address) IN ('0x080bf510fcbf18b91105470639e9561022937712','0x4f833a24e1f95d70f028921e27040ca56e09ab0b')
-- dYdX 0x exchange wrappers
AND t.from_address IN ('0x0122676358aee287246b2a84377c8ab664d013cb','0x6fbfa42bc2f8c6ce9076a924a5e1ea8c0f3647ca','0xb734d82dcc42e0ba1b4a5ed6f0ca28a288fd5291','0xa26d16a21805b14b2977555ffdea34e5e6fc43ba')
AND DATE(tx.block_timestamp) >= DATE_SUB(CURRENT_DATE, INTERVAL 90 DAY)
AND tx.receipt_status = 0
)
SELECT DISTINCT
t.transaction_hash
FROM `bigquery-public-data.crypto_ethereum.traces` t
JOIN wrapper_tx wtx ON wtx.transaction_hash = t.transaction_hash
WHERE
t.error IS NOT NULL
AND t.from_address = '0x1e0447b19bb6ecfdae1e4ae1694b0c3659614e4e'
AND t.to_address IN ('0x0122676358aee287246b2a84377c8ab664d013cb','0x6fbfa42bc2f8c6ce9076a924a5e1ea8c0f3647ca','0xb734d82dcc42e0ba1b4a5ed6f0ca28a288fd5291','0xa26d16a21805b14b2977555ffdea34e5e6fc43ba')
AND SUBSTR(t.input,0,10) = '0x3a8fdd7d'
--AND t.to_address != t.from_address;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment