-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support CoW AMM stats on all chains * remove chain parameter from daily rebalancing since it is not needed * fix lint * [CoW AMM] Make Uni reference pool queries chain agnostic * extract common subquery
- Loading branch information
Showing
3 changed files
with
79 additions
and
42 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
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
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,27 @@ | ||
-- Finds the uniswap v2 pool address given tokens specified in query parameters (regardless of order) | ||
with pools as ( | ||
select | ||
substr(data, 13, 20) as contract_address, | ||
substr(topic1, 13, 20) as token0, | ||
substr(topic2, 13, 20) as token1 | ||
from {{blockchain}}.logs | ||
where | ||
topic0 = 0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9 -- PairCreated | ||
-- topic1: 0x0...0<token0>, topic2: 0x0...0<token1> | ||
and ((substr(topic1, 13, 20) = {{token_a}} and substr(topic2, 13, 20) = {{token_b}}) or (substr(topic2, 13, 20) = {{token_a}} and substr(topic1, 13, 20) = {{token_b}})) | ||
) | ||
|
||
select | ||
tx_hash as evt_tx_hash, | ||
index as evt_index, | ||
block_time as evt_block_time, | ||
block_number as evt_block_number, | ||
varbinary_to_uint256(substr(data, 1, 32)) as reserve0, | ||
varbinary_to_uint256(substr(data, 33, 32)) as reserve1, | ||
pools.*, | ||
rank() over (partition by (logs.contract_address) order by block_time desc) as latest | ||
from {{blockchain}}.logs | ||
join pools | ||
on logs.contract_address = pools.contract_address | ||
where | ||
topic0 = 0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1 -- Sync |