-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(abstractions): dune-abstractions update
sync abstractions with dune-analytics repo
- Loading branch information
sam
committed
Mar 7, 2021
1 parent
2a040f7
commit 467b3d7
Showing
34 changed files
with
977 additions
and
788 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
# EditorConfig http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# All files | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
# Solidity Contracts | ||
[*.{sol,solidity}] | ||
indent_size = 4 | ||
|
||
# JavaScript, JSON, JSX, JavaScript Modules, TypeScript | ||
[*.{cjs,js,json,jsx,mjs,ts,tsx}] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
# Shell | ||
[*.{bash,sh,zsh}] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
# TOML | ||
[*.toml] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
# YAML | ||
[*.{yaml,yml}] | ||
indent_size = 2 | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
.DS_Store | ||
node_modules | ||
package-lock.json | ||
*.tgz | ||
*.zip | ||
*.tar.gz | ||
*.tar | ||
*.log | ||
|
||
.vscode/* | ||
!.vscode/settings.json.default | ||
tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @file Prettier configuration for Solidity | ||
* @version 1.0.3 | ||
* @summary base config adapted from AirBNB to minizmie diff churn | ||
* @overrides solidity settings from Solidity Documentation | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = { | ||
arrowParens: "always", | ||
bracketSpacing: true, | ||
endOfLine: "lf", | ||
printWidth: 100, | ||
singleQuote: true, | ||
tabWidth: 2, | ||
trailingComma: "all", | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
define npm_script_targets | ||
TARGETS := $(shell node -e 'for (var k in require("./package.json").scripts) {console.log(k.replace(/:/g, "-"));}') | ||
$$(TARGETS): | ||
npm run $(subst -,:,$(MAKECMDGOALS)) | ||
|
||
.PHONY: $$(TARGETS) | ||
endef | ||
|
||
$(eval $(call npm_script_targets)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
SELECT sum(amt*price) as borrow | ||
FROM | ||
( | ||
|
||
-- Aave v1 | ||
SELECT sum("_amount"/10^decimals) as amt | ||
,t.symbol as token | ||
,date(evt_block_time) as dt | ||
FROM aave."LendingPool_evt_Borrow" Borrow | ||
LEFT JOIN erc20."tokens" t ON Borrow."_reserve" = t.contract_address | ||
WHERE evt_block_time > now() - interval '30 days' | ||
GROUP BY 2,3 | ||
|
||
UNION ALL | ||
|
||
-- Aave v2 | ||
SELECT sum("amount"/10^decimals) as amt | ||
,t.symbol as token | ||
,date(evt_block_time) as dt | ||
FROM aave_v2."LendingPool_evt_Borrow" Borrow | ||
LEFT JOIN erc20."tokens" t ON Borrow."reserve" = t.contract_address | ||
WHERE evt_block_time > now() - interval '30 days' | ||
GROUP BY 2,3 | ||
|
||
)main | ||
|
||
LEFT JOIN | ||
|
||
|
||
(SELECT avg(price) AS price, | ||
date(MINUTE) AS dt, | ||
symbol | ||
FROM prices.usd | ||
WHERE symbol<>'ETH' | ||
AND MINUTE > now() - interval '30 days' | ||
GROUP BY 2, | ||
3 | ||
|
||
UNION SELECT avg(price) AS price, | ||
date(MINUTE) AS dt, | ||
symbol | ||
FROM prices.layer1_usd_eth | ||
WHERE symbol='ETH' | ||
AND MINUTE > now() - interval '30 days' | ||
GROUP BY 2, | ||
3)p | ||
|
||
ON main.dt = p.dt | ||
AND p.symbol = main.token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
SELECT sum(amt*price) as borrow | ||
FROM | ||
( | ||
|
||
-- Aave v1 | ||
SELECT sum("_amount"/10^decimals) as amt | ||
,t.symbol as token | ||
,date(evt_block_time) as dt | ||
FROM aave."LendingPool_evt_Borrow" Borrow | ||
LEFT JOIN erc20."tokens" t ON Borrow."_reserve" = t.contract_address | ||
WHERE evt_block_time > now() - interval '7 days' | ||
GROUP BY 2,3 | ||
|
||
UNION ALL | ||
|
||
-- Aave v2 | ||
SELECT sum("amount"/10^decimals) as amt | ||
,t.symbol as token | ||
,date(evt_block_time) as dt | ||
FROM aave_v2."LendingPool_evt_Borrow" Borrow | ||
LEFT JOIN erc20."tokens" t ON Borrow."reserve" = t.contract_address | ||
WHERE evt_block_time > now() - interval '7 days' | ||
GROUP BY 2,3 | ||
|
||
)main | ||
|
||
LEFT JOIN | ||
|
||
|
||
(SELECT avg(price) AS price, | ||
date(MINUTE) AS dt, | ||
symbol | ||
FROM prices.usd | ||
WHERE symbol<>'ETH' | ||
AND MINUTE > now() - interval '7 days' | ||
GROUP BY 2, | ||
3 | ||
|
||
UNION SELECT avg(price) AS price, | ||
date(MINUTE) AS dt, | ||
symbol | ||
FROM prices.layer1_usd_eth | ||
WHERE symbol='ETH' | ||
AND MINUTE > now() - interval '7 days' | ||
GROUP BY 2, | ||
3)p | ||
|
||
ON main.dt = p.dt | ||
AND p.symbol = main.token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
WITH fl AS | ||
( | ||
SELECT | ||
evt_block_time, | ||
t.symbol as token, | ||
sum("amount"/10^decimals) as amount | ||
FROM aave_v2."LendingPool_evt_FlashLoan" fl | ||
LEFT JOIN erc20."tokens" t ON fl."asset" = t.contract_address | ||
GROUP BY 1,2 | ||
) | ||
|
||
select dt, sum(USDamt) over ( | ||
ORDER BY dt ASC ROWS BETWEEN unbounded preceding AND CURRENT ROW) AS total_usd | ||
from | ||
(select dt,sum(USDamt) as USDamt | ||
from | ||
(select min(day) as dt, | ||
USDvalue as USDamt | ||
from | ||
(SELECT | ||
date_trunc('day',evt_block_time) as day, | ||
sum(amount*price) As USDvalue | ||
from fl | ||
LEFT JOIN | ||
(SELECT avg(price) AS price, | ||
date(MINUTE) AS dt, | ||
symbol | ||
FROM prices.usd | ||
WHERE symbol<>'ETH' | ||
GROUP BY 2, | ||
3 | ||
UNION SELECT avg(price) AS price, | ||
date(MINUTE) AS dt, | ||
symbol | ||
FROM prices.layer1_usd_eth | ||
WHERE symbol='ETH' | ||
GROUP BY 2, | ||
3)p | ||
ON date(evt_block_time) = p.dt | ||
AND p.symbol = fl.token | ||
group by 1) t1 | ||
group by 2) t2 | ||
group by 1)t3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
with transactions as | ||
( | ||
select tok.symbol | ||
, evt_block_time | ||
, sum("value"/10^v.decimals) as amt | ||
from erc20."ERC20_evt_Transfer" t | ||
inner join | ||
( | ||
select * from dune_user_generated."view_v2_atokens" | ||
union all | ||
select * from dune_user_generated."view_v1_atokens" | ||
) v | ||
on v. contract_address = t.contract_address | ||
left join erc20."tokens" tok on tok.contract_address = v.underlying_token_address | ||
--where evt_block_time > now() - interval '1 days' | ||
|
||
|
||
group by 1,2 | ||
order by 3 desc | ||
|
||
) | ||
|
||
, prices as | ||
( | ||
SELECT avg(price) AS price, | ||
date(MINUTE) AS dt, | ||
symbol | ||
FROM prices.usd | ||
WHERE symbol<>'ETH' | ||
--and minute > now() - interval '1 days' | ||
|
||
GROUP BY 2,3 | ||
|
||
UNION SELECT avg(price) AS price, | ||
date(MINUTE) AS dt, | ||
symbol | ||
FROM prices.layer1_usd_eth | ||
WHERE symbol='ETH' | ||
-- and minute > now() - interval '1 days' | ||
GROUP BY 2,3 | ||
) | ||
|
||
SELECT t.symbol | ||
, date_trunc('month', evt_block_time) as month | ||
, sum(amt*price) as "usd amount" | ||
from transactions t | ||
left join prices p on date(evt_block_time) = p.dt | ||
AND p.symbol = t.symbol | ||
group by 1,2 | ||
order by 3 desc | ||
|
||
|
||
|
||
|
||
--select * from erc20."tokens" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.