Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arbitrum Sepolia #48

Merged
merged 7 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ import:
dbt: build
docker compose run transformer dbt run --target base_mainnet --profiles-dir profiles --profile docker
docker compose run transformer dbt run --target base_sepolia --profiles-dir profiles --profile docker
docker compose run transformer dbt run --target arbitrum_sepolia --profiles-dir profiles --profile docker

dbt-mat: build
docker compose run transformer dbt run --target base_mainnet --profiles-dir profiles --profile docker --select config.materialized:table+
docker compose run transformer dbt run --target base_sepolia --profiles-dir profiles --profile docker --select config.materialized:table+
docker compose run transformer dbt run --target arbitrum_sepolia --profiles-dir profiles --profile docker --select config.materialized:table+
54 changes: 19 additions & 35 deletions dashboard/modules/base_mainnet/core_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ def fetch_data(filters):
db,
)

df_market_updated = pd.read_sql_query(
f"""
SELECT * FROM base_mainnet.fct_core_market_updated
WHERE ts >= '{start_date}' and ts <= '{end_date}'
ORDER BY ts
""",
db,
)

df_pnl = pd.read_sql_query(
f"""
SELECT *, concat(pool_id, '-', collateral_type) as "pool" FROM base_mainnet.fct_pool_pnl
Expand All @@ -75,6 +66,9 @@ def fetch_data(filters):
ts,
concat(pool_id, '-', collateral_type) as "pool",
hourly_pnl,
hourly_issuance,
cumulative_issuance,
cumulative_pnl,
apr_{resolution} as apr,
apr_{resolution}_pnl as apr_pnl,
apr_{resolution}_rewards as apr_rewards
Expand All @@ -92,8 +86,6 @@ def fetch_data(filters):
"collateral": df_collateral,
"debt": df_debt,
"account_delegation": df_account_delegation,
"market_updated": df_market_updated,
"pnl": df_pnl,
"apr": df_apr,
}

Expand All @@ -115,17 +107,24 @@ def make_charts(data, filters):
"Debt",
"collateral_type",
),
"net_issuance": chart_lines(
data["market_updated"],
"hourly_issuance": chart_bars(
data["apr"],
"ts",
["net_issuance"],
"Net Issuance",
"market_id",
["hourly_issuance"],
"Hourly Issuance",
"pool",
),
"issuance": chart_lines(
data["apr"],
"ts",
["cumulative_issuance"],
"Issuance",
"pool",
),
"pnl": chart_lines(
data["pnl"],
data["apr"],
"ts",
["market_pnl"],
["cumulative_pnl"],
"Pnl",
"pool",
),
Expand Down Expand Up @@ -174,12 +173,13 @@ def main():
col1, col2 = st.columns(2)
with col1:
st.plotly_chart(charts["collateral"], use_container_width=True)
st.plotly_chart(charts["net_issuance"], use_container_width=True)
st.plotly_chart(charts["hourly_pnl"], use_container_width=True)
st.plotly_chart(charts["hourly_issuance"], use_container_width=True)

with col2:
st.plotly_chart(charts["debt"], use_container_width=True)
st.plotly_chart(charts["pnl"], use_container_width=True)
st.plotly_chart(charts["issuance"], use_container_width=True)

st.markdown("## Top Delegators")
st.dataframe(
Expand All @@ -188,22 +188,6 @@ def main():
.head(25)
)

st.markdown("## Markets")

st.markdown("### sUSDC Market")
st.dataframe(
data["market_updated"][data["market_updated"]["market_id"] == 1]
.sort_values("ts", ascending=False)
.head(25)
)

st.markdown("### Perps Markets")
st.dataframe(
data["market_updated"][data["market_updated"]["market_id"] == 2]
.sort_values("ts", ascending=False)
.head(25)
)

## export
exports = [{"title": export, "df": data[export]} for export in data.keys()]
with st.expander("Exports"):
Expand Down
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ services:
env_file:
- ./indexers/base-sepolia/.env

arbitrum-sepolia-processor:
build:
context: ./indexers/arbitrum-sepolia
networks:
- data
depends_on:
- db
restart: always
environment:
DB_PASS: $PG_PASSWORD
env_file:
- ./indexers/arbitrum-sepolia/.env

optimism-mainnet-processor:
build:
context: ./indexers/optimism-mainnet
Expand All @@ -66,6 +79,7 @@ services:
PG_PASSWORD: $PG_PASSWORD
volumes:
- ./parquet-data:/parquet-data
- ./transformers/synthetix:/app/synthetix
networks:
- data

Expand All @@ -77,6 +91,7 @@ services:
volumes:
- ./extractors:/app
- ./parquet-data:/parquet-data
- ./extractors/src:/app/src

dashboard:
build:
Expand Down
2 changes: 2 additions & 0 deletions extractors/.env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# rpc endpoints
ETH_MAINNET_RPC=
OP_MAINNET_RPC=
BASE_MAINNET_RPC=
BASE_SEPOLIA_RPC=
ARBITRUM_SEPOLIA_RPC=

# settings
REQUESTS_PER_SECOND=25
34 changes: 33 additions & 1 deletion extractors/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
"min_block": "8M",
"requests_per_second": 25,
},
# arbitrum sepolia
{
"network_id": 421614,
"min_block": "41M",
},
]

for block_input in block_inputs:
Expand All @@ -29,7 +34,7 @@

# extract eth_call data
func_inputs = [
# base mainnet
# # base mainnet
{
"network_id": 8453,
"contract_name": "CoreProxy",
Expand Down Expand Up @@ -71,6 +76,33 @@
"min_block": "8M",
"requests_per_second": 25,
},
# arbitrum sepolia
{
"network_id": 421614,
"contract_name": "CoreProxy",
"function_name": "getVaultCollateral",
"inputs": [
(1, "0x980B62Da83eFf3D4576C647993b0c1D7faf17c73"), # WETH
(1, "0x7b356eEdABc1035834cd1f714658627fcb4820E3"), # ARB
(1, "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"), # USDC
(1, "0xda7b438d762110083602AbC497b1Ec8Bc6605eC9"), # DAI
],
"min_block": "41M",
"requests_per_second": 25,
},
{
"network_id": 421614,
"contract_name": "CoreProxy",
"function_name": "getVaultDebt",
"inputs": [
(1, "0x980B62Da83eFf3D4576C647993b0c1D7faf17c73"), # WETH
(1, "0x7b356eEdABc1035834cd1f714658627fcb4820E3"), # ARB
(1, "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"), # USDC
(1, "0xda7b438d762110083602AbC497b1Ec8Bc6605eC9"), # DAI
],
"min_block": "41M",
"requests_per_second": 25,
},
]

for func_input in func_inputs:
Expand Down
2 changes: 1 addition & 1 deletion extractors/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ duckdb
polars-lts-cpu
pandas
numpy
synthetix==0.1.8
synthetix==0.1.10
14 changes: 14 additions & 0 deletions extractors/src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,30 @@
10: {
"name": "optimism_mainnet",
"rpc": os.getenv("OP_MAINNET_RPC"),
"mainnet_rpc": os.getenv("ETH_MAINNET_RPC"),
"network_id": 10,
},
8453: {
"name": "base_mainnet",
"rpc": os.getenv("BASE_MAINNET_RPC"),
"mainnet_rpc": os.getenv("ETH_MAINNET_RPC"),
"network_id": 8453,
},
84532: {
"name": "base_sepolia",
"rpc": os.getenv("BASE_SEPOLIA_RPC"),
"mainnet_rpc": os.getenv("ETH_MAINNET_RPC"),
"network_id": 84532,
},
421614: {
"name": "arbitrum_sepolia",
"rpc": os.getenv("ARBITRUM_SEPOLIA_RPC"),
"mainnet_rpc": os.getenv("ETH_MAINNET_RPC"),
"network_id": 421614,
"cannon_config": {
"package": "synthetix-omnibus",
"version": "latest",
"preset": "main",
},
},
}
16 changes: 13 additions & 3 deletions extractors/src/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@


def get_synthetix(chain_config):
return Synthetix(
provider_rpc=chain_config["rpc"], network_id=chain_config["network_id"]
)
if "cannon_config" in chain_config:
return Synthetix(
provider_rpc=chain_config["rpc"],
network_id=chain_config["network_id"],
mainnet_rpc=chain_config["mainnet_rpc"],
cannon_config=chain_config["cannon_config"],
ipfs_gateway="https://ipfs.synthetix.io/ipfs/",
)
else:
return Synthetix(
provider_rpc=chain_config["rpc"],
network_id=chain_config["network_id"],
)


# generalize a function
Expand Down
5 changes: 5 additions & 0 deletions indexers/arbitrum-sepolia/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.git
/node_modules
/lib
/*Versions.json
.env
6 changes: 6 additions & 0 deletions indexers/arbitrum-sepolia/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DB_HOST=db
DB_PORT=5432
DB_NAME=base_mainnet
GQL_PORT=4350
# JSON-RPC node endpoint, both wss and https endpoints are accepted
RPC_ENDPOINT=
14 changes: 14 additions & 0 deletions indexers/arbitrum-sepolia/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:16

WORKDIR /app

COPY package*.json ./

RUN npm ci

COPY . .

RUN npm run generate:processor
RUN npm run build

CMD npm run generate:migration ; npm run start
Loading