Skip to content

Instantly share code, notes, and snippets.

View adamwhitakerwilson's full-sized avatar

Adam adamwhitakerwilson

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"data": {
"items": [
{
"block_signed_at": "2020-12-13T03:01:24Z",
"block_height": 11442032,
"tx_offset": 149,
"log_offset": 205,
"tx_hash": "0x2eff68707532aae5e50c1d104cc858bc9e9d41cf21f88c6c7893a5ad3ed65f97",
"raw_log_topics": [
@adamwhitakerwilson
adamwhitakerwilson / LOG_SWAPS
Last active February 13, 2021 22:36
Getting LOG_SWAP events from a balancer D2 fund to retrieve associated D1 fund addresses.
// Assuming you have a Balancer pool address, you can use this address to grab any topic hash using our topic calulator tool
// @ https://www.covalenthq.com/docs/tools/topic-calculator
// After copying the relevant topic hash, in this case I selected
// 0x908fb5ee8f16c6bc9bc3690973819f32a4d4b10188134543c88706e0e1d43378
// which is associated with LOG_SWAP events. We can now pass this information as parameters
// (in this case I used sender_address: 0x04df4fbb6a003d1db3dd83d6d3b9951455837fff
// and topic_hash: 0x908fb5ee8f16c6bc9bc3690973819f32a4d4b10188134543c88706e0e1d43378) into our
// Get log events by topic hash(es) endpoint which will return each decoded LOG_SWAP log event
// associated with the the balancer pool.
@adamwhitakerwilson
adamwhitakerwilson / Token_Transfers_D2_D1
Last active February 13, 2021 23:21
Getting token transfers associated with a D2 and a specific D1
// Now assume we have all D1s from D2s, we can gather every transfer event by using the Get ERC20 token transfers endpoint.
// By passing a D2 address into the 'address' parameter and a D1 address into the 'contract_address' parameter, we can
// get decoded token transfer events associated between these two contracts. Notice that the quotes are null, this is
// because we do not have historical or spot prices for the pool. For now these quotes will have to be calculated manually.
// At the moment I'm not sure where this quote rate would come from (maybe open sea?).
// We do have the deltas though.
// https://api.covalenthq.com/v1/1/address/0x04df4fbb6a003d1db3dd83d6d3b9951455837fff/transfers_v2/?contract-address=0x27ffed7e5926fb2795fc85aaab558243f280a8a2"
{
@adamwhitakerwilson
adamwhitakerwilson / balancer_balances
Last active February 13, 2021 23:41
Balancer D2 - Get current D1 fund balances
// Assume you know the address of the D2 fund, you can get D1 fund balances simply by passing the D2
// into the address parameter using the Get token balances for address endpoint.
// https://api.covalenthq.com/v1/1/address/0x04df4fbb6a003d1db3dd83d6d3b9951455837fff/balances_v2/?key=..
{
"data": {
"address": "0x04df4fbb6a003d1db3dd83d6d3b9951455837fff",
"updated_at": "2021-02-13T23:30:41.937410301Z",
"next_update_at": "2021-02-13T23:35:41.937411131Z",
// http://localhost:8000/v1/1/events/address/0xc0da01a04c3f3e0be433606045bb7017a7323e38/?starting-block=9601459&ending-block=10005000&group={_id:{year:{$year:block_signed_at},month:{$month:block_signed_at},day:{$dayOfMonth:block_signed_at}},totalTxOffset:{$sum:tx_offset},count:{$sum:1}}
{
"data": {
"updated_at": "2021-03-04T06:03:57.740141Z",
"items": [
{
"id": {
"year": 2020,
"month": 4,
"day": 27
//curl -X GET "https://api.covalenthq.com/v1/1/address/salnikov.eth/balances_v2/?nft=true" \
// -H "Accept: application/json" \
{
"data": {
"address": "0x3f46680099cf623163c96747a8addb85a1da1cd1",
"updated_at": "2021-03-17T19:37:55.492151839Z",
"next_update_at": "2021-03-17T19:42:55.492151962Z",
"quote_currency": "USD",
"chain_id": 1,
@adamwhitakerwilson
adamwhitakerwilson / p_41_vote_count_sum.json
Last active March 20, 2021 05:42
Compound Proposal #41 Vote counts + sum using Covalent | Primer
// https://api.covalenthq.com/v1/1/address/0xc0da01a04c3f3e0be433606045bb7017a7323e38/transactions_v2/?page-number=0&page-size=10000&primer=[{"$match":{"$and":[{"log_events.0.decoded.name":"VoteCast"},{"log_events.0.decoded.params.1.value":"41"},{"log_events.0.decoded.params.2.value":true}]}},{"$group":{"_id":{"month":{"$month":"block_signed_at"},"day":{"$dayOfMonth":"block_signed_at"},"year":{"$year":"block_signed_at"},"hour":{"$hourOfDay":"block_signed_at"}},"vote_count":{"$sum":1},"sum_of_votes":{"$sum":"log_events.0.decoded.params.3.value"}}}]
{
"data": {
"address": "0xc0da01a04c3f3e0be433606045bb7017a7323e38",
"updated_at": "2021-03-20T04:59:02.364135356Z",
"next_update_at": "2021-03-20T05:04:02.364137552Z",
"quote_currency": "USD",
"chain_id": 1,
"items": [
Covalent Tools
0xabefbc9fd2f806065b4f3c237d4b59d9a97bcac7
Get events
Found 5 log events.
Event name: Approval(indexed address owner, indexed address approved, indexed uint256 tokenId)
Topic hash: 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925
SELECT
@adamwhitakerwilson
adamwhitakerwilson / historical_by_amm_address.csv
Last active March 29, 2021 04:48
Get historical AMM prices by address and volume weighted average prices - WETH-ZERO Uniswap v2 Exchange
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 2.
date,exchange_contract_address,exchange_contract_name,exchange_contract_ticker_symbol,exchange_contract_decimals,total_supply,reserve_0,reserve_1,token_0_contract_address,token_0_contract_name,token_0_contract_ticker_symbol,token_0_contract_decimals,price_of_token0_in_token1,price_of_token0_in_token1_description,token_1_contract_address,token_1_contract_name,token_1_contract_ticker_symbol,token_1_contract_decimals,price_of_token1_in_token0,price_of_token1_in_token0_description,market_cap_quote,market_quote,quote_currency,token_0_quote_rate,token_1_quote_rate,token_0_quote,token_1_quote,rolling_volume_quote,current_volume_quote,current_open_quote,current_close_quote,average_price_quote,rolling_price_quote,volume_weighted_average_price_quote,supports_erc_0
"2021-02-03T23:57:31Z","0x40f0e70a7d565985b967bcdb0ba5801994fc2e80","Uniswap V2","WETH/ZERO WETH/ZERO WETH/ZERO WETH/ZERO WETH/ZERO UNI-V2",18,"19314720275953044221054","181585782711192370473","2757557096049956713798081","0xc02aaa39b223fe8d0a0e5c4f27ead9083c7