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

feat: Add scroll #242

Merged
merged 2 commits into from
Oct 18, 2023
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Currently, there are multiple subgraphs, but additional subgraphs can be added t
- Linea https://graph-query.linea.build/subgraphs/name/pancakeswap/exhange-v2
- Base https://api.studio.thegraph.com/query/45376/exchange-v2-base/version/latest
- Base testnet https://api.studio.thegraph.com/query/45376/exchange-v2-base-testnet/version/latest
- Scroll https://api.studio.thegraph.com/query/45376/exchange-v2-scroll/version/latest
- Scroll Sepolia https://api.studio.thegraph.com/query/45376/exchange-v2-scroll-sepolia/version/latest
- opBNB https://opbnb-mainnet-graph.nodereal.io/subgraphs/name/pancakeswap/exchange-v2

Expand Down Expand Up @@ -84,6 +85,7 @@ Currently, there are multiple subgraphs, but additional subgraphs can be added t
- Linea https://graph-query.linea.build/subgraphs/name/pancakeswap/exchange-v3-linea
- Base https://api.studio.thegraph.com/query/45376/exchange-v3-base/version/latest
- Base testnet https://api.studio.thegraph.com/query/45376/exchange-v3-base-testnet/version/latest
- Scroll https://api.studio.thegraph.com/query/45376/exchange-v3-scroll/version/latest
- Scroll Sepolia https://api.studio.thegraph.com/query/45376/exchange-v3-scroll-sepolia/version/latest
- opBNB https://opbnb-mainnet-graph.nodereal.io/subgraphs/name/pancakeswap/exchange-v3

Expand Down
1 change: 1 addition & 0 deletions config/arbitrum-goerli.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ module.exports = {
"0x179522635726710dd7d2035a81d856de4aa7836c", // USDC
"0xbe737d08fb505ad45e08a89ac7fda9791f025bf2", // ARB
],
minETHLocked: 5,
},
};
1 change: 1 addition & 0 deletions config/arbitrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module.exports = {
"0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f", // WBTC
"0xda10009cbd5d07dd0cecc66161fc93d7c9000da1", // DAI
],
minETHLocked: 5,
},
masterChefV3: {
masterChefAddress: "0x5e09acf80c0296740ec5d6f643005a4ef8daa694",
Expand Down
1 change: 1 addition & 0 deletions config/base-testnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ module.exports = {
WETH,
"0x853154e2A5604E5C74a2546E2871Ad44932eB92C", // USDC
],
minETHLocked: 5,
},
};
1 change: 1 addition & 0 deletions config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module.exports = {
"0x417ac0e078398c154edfadd9ef675d30be60af93", // crvUSD
"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", // USDC native
],
minETHLocked: 5,
},
masterChefV3: {
masterChefAddress: "0xc6a2db661d5a5690172d8eb0a7dea2d3008665a3",
Expand Down
1 change: 1 addition & 0 deletions config/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type NetworkConfig = {
whitelistAddresses: string[];
wNativeStablePair0: string;
wNativeStablePair1: string;
minETHLocked: number;
};
masterChefV3: {
startBlock: number;
Expand Down
1 change: 1 addition & 0 deletions config/opbnb.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ module.exports = {
wNativeStablePair0: "0x0000000000000000000000000000000000000000", // WETH-USDC
wNativeStablePair1: "0x706f7257e78b6f2404a1afb5c480645a6f5be91d", // WETH-USDT
whitelistAddresses: [WETH, USDT],
minETHLocked: 0,
},
};
1 change: 1 addition & 0 deletions config/polygon-zkevm-testnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module.exports = {
WETH,
"0x7379a261bC347BDD445484A91648Abf4A2BDEe5E", // USDT
],
minETHLocked: 0,
},
masterChefV3: {
masterChefAddress: "0xb66b07590b30d4e6e22e45ddc83b06bb018a7b44",
Expand Down
1 change: 1 addition & 0 deletions config/polygon-zkevm.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module.exports = {
"0xc5015b9d9161dca7e18e32f6f25c4ad850731fd4", // DAI
"0xea034fb02eb1808c2cc3adbc15f447b93cbe08e1", // WBTC
],
minETHLocked: 0,
},
masterChefV3: {
masterChefAddress: "0xe9c7f3196ab8c09f6616365e8873daeb207c0391",
Expand Down
41 changes: 41 additions & 0 deletions config/scroll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const WETH = "0x5300000000000000000000000000000000000004";
const USDC = "0x06efdbff2a14a7c8e15944d1f4a48f9f95f663a4";
const USDT = "0xf55bec9cafdbe8730f096aa55dad6d22d44099df";
const LUSD = "0xedeabc3a1e7d21fe835ffa6f83a710c70bb1a051";
const WBTC = "0x3c1bca5a656e69edcd0d4e36bebb3fcdaca60cf1";
const RETH = "0x53878b874283351d26d206fa512aece1bef6c0dd";
const STETH = "0xf610a9dfb7c89644979b4a0f27063e9e7d7cda32";
const DAI = "0xca77eb3fefe3725dc33bccb54edefc3d9f764f97";

/**
* @type import('./config').NetworkConfig
*/
module.exports = {
network: "scroll",
wNativeAddress: WETH,
v3: {
// WETH-USDC 500
wNativeStablePoolAddress: "0xb4ea03fd982685c68279cfe6dd05dd26521c35dd",
stableIsToken0: true,
factoryAddress: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865",
startBlock: 6581,
stableCoins: [
USDC, // USDC
USDT,
LUSD,
DAI,
],
whitelistAddresses: [WETH, USDT, USDT, LUSD, WBTC, RETH, STETH, DAI],
nonfungiblePositionManagerAddress: "0x46a15b0b27311cedf172ab29e4f4766fbe7f4364",
nonfungiblePositionManagerStartBlock: 6977,
minETHLocked: 0,
},
v2: {
factoryAddress: "0x02a84c1b3bbd7401a5f7fa98a384ebc70bb5749e",
startBlock: 3804,
wNativeStablePair0: "0xe948be21a0e98f050dd48d8ab954e7b6e26eefa3", // WETH-USDC
wNativeStablePair1: "0x42290c85a8ee259904416aa2d4802eda7308339e", // USDT-WETH
whitelistAddresses: [WETH, USDT, USDT, LUSD, WBTC, RETH, STETH, DAI],
minETHLocked: 1,
},
};
1 change: 1 addition & 0 deletions config/zksync-era.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = {
"0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4", // USDC
"0xbbeb516fb02a01611cbbe0453fe3c580d7281011", // WBTC
],
minETHLocked: 1,
},
masterChefV3: {
masterChefAddress: "0x4c615e78c5fca1ad31e4d66eb0d8688d84307463",
Expand Down
1 change: 1 addition & 0 deletions config/zksync-goerli.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ module.exports = {
WETH,
"0x0faf6df7054946141266420b43783387a78d82a9", // USDC
],
minETHLocked: 0,
},
};
2 changes: 1 addition & 1 deletion subgraphs/exchange-v2/mappings/pricing.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function getETHPriceInUSD(): BigDecimal {
let WHITELIST: string[] = "{{ v2.whitelistAddresses }}".split(",");

// minimum liquidity for price to get tracked
let MINIMUM_LIQUIDITY_THRESHOLD_ETH = BigDecimal.fromString("5");
let MINIMUM_LIQUIDITY_THRESHOLD_ETH = BigDecimal.fromString("{{ v2.minETHLocked }}");

/**
* Search through graph to find derived BNB per token.
Expand Down
10 changes: 5 additions & 5 deletions subgraphs/exchange-v2/mappings/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { Bundle, Pair, Token } from "../generated/schema";
import { ADDRESS_ZERO, factoryContract, ONE_BD, ZERO_BD } from "./utils";

// prettier-ignore
let WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
let WETH_ADDRESS = "0x5300000000000000000000000000000000000004";
// prettier-ignore
let WETH_USDT_PAIR = "0x706f7257e78b6f2404a1afb5c480645a6f5be91d";
let WETH_USDT_PAIR = "0x42290c85a8ee259904416aa2d4802eda7308339e";
// prettier-ignore
let WETH_USDC_PAIR = "0x0000000000000000000000000000000000000000";
let WETH_USDC_PAIR = "0xe948be21a0e98f050dd48d8ab954e7b6e26eefa3";

export function getETHPriceInUSD(): BigDecimal {
// fetch eth prices for each stablecoin
Expand All @@ -35,10 +35,10 @@ export function getETHPriceInUSD(): BigDecimal {

// token where amounts should contribute to tracked volume and liquidity
// prettier-ignore
let WHITELIST: string[] = "0x4200000000000000000000000000000000000006,0x9e5aac1ba1a2e6aed6b32689dfcf62a509ca96f3".split(",");
let WHITELIST: string[] = "0x5300000000000000000000000000000000000004,0xf55bec9cafdbe8730f096aa55dad6d22d44099df,0xf55bec9cafdbe8730f096aa55dad6d22d44099df,0xedeabc3a1e7d21fe835ffa6f83a710c70bb1a051,0x3c1bca5a656e69edcd0d4e36bebb3fcdaca60cf1,0x53878b874283351d26d206fa512aece1bef6c0dd,0xf610a9dfb7c89644979b4a0f27063e9e7d7cda32,0xca77eb3fefe3725dc33bccb54edefc3d9f764f97".split(",");

// minimum liquidity for price to get tracked
let MINIMUM_LIQUIDITY_THRESHOLD_ETH = BigDecimal.fromString("5");
let MINIMUM_LIQUIDITY_THRESHOLD_ETH = BigDecimal.fromString("1");

/**
* Search through graph to find derived BNB per token.
Expand Down
6 changes: 3 additions & 3 deletions subgraphs/exchange-v2/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ schema:
dataSources:
- kind: ethereum/contract
name: Factory
network: opbnb-mainnet
network: scroll
source:
address: "0x02a84c1b3bbd7401a5f7fa98a384ebc70bb5749e"
abi: Factory
startBlock: 1708914
startBlock: 3804
mapping:
kind: ethereum/events
apiVersion: 0.0.4
Expand All @@ -34,7 +34,7 @@ dataSources:
templates:
- kind: ethereum/contract
name: Pair
network: opbnb-mainnet
network: scroll
source:
abi: Pair
mapping:
Expand Down
10 changes: 5 additions & 5 deletions subgraphs/exchange-v3/template/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ features:
dataSources:
- kind: ethereum/contract
name: Factory
network: opbnb-mainnet
network: scroll
source:
address: "0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865"
abi: Factory
startBlock: 1721753
startBlock: 6581
mapping:
kind: ethereum/events
apiVersion: 0.0.4
Expand All @@ -37,11 +37,11 @@ dataSources:
handler: handlePoolCreated
- kind: ethereum/contract
name: NonfungiblePositionManager
network: opbnb-mainnet
network: scroll
source:
address: "0x46a15b0b27311cedf172ab29e4f4766fbe7f4364"
abi: NonfungiblePositionManager
startBlock: 1730685
startBlock: 6977
mapping:
kind: ethereum/events
apiVersion: 0.0.4
Expand Down Expand Up @@ -71,7 +71,7 @@ dataSources:
templates:
- kind: ethereum/contract
name: Pool
network: opbnb-mainnet
network: scroll
source:
abi: Pool
mapping:
Expand Down
12 changes: 6 additions & 6 deletions subgraphs/exchange-v3/template/utils/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import { BigDecimal, BigInt } from "@graphprotocol/graph-ts";
import { exponentToBigDecimal, safeDiv } from "./index";

// prettier-ignore
const WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
const WETH_ADDRESS = "0x5300000000000000000000000000000000000004";
// prettier-ignore
const USDC_WETH_03_POOL = "0xc4f981189558682f15f60513158b699354b30204";
const USDC_WETH_03_POOL = "0xb4ea03fd982685c68279cfe6dd05dd26521c35dd";

const STABLE_IS_TOKEN0 = "false" as string;
const STABLE_IS_TOKEN0 = "true" as string;

// token where amounts should contribute to tracked volume and liquidity
// usually tokens that many tokens are paired with s
// prettier-ignore
export let WHITELIST_TOKENS: string[] = "0x4200000000000000000000000000000000000006,0x9e5aac1ba1a2e6aed6b32689dfcf62a509ca96f3".split(",");
export let WHITELIST_TOKENS: string[] = "0x5300000000000000000000000000000000000004,0xf55bec9cafdbe8730f096aa55dad6d22d44099df,0xf55bec9cafdbe8730f096aa55dad6d22d44099df,0xedeabc3a1e7d21fe835ffa6f83a710c70bb1a051,0x3c1bca5a656e69edcd0d4e36bebb3fcdaca60cf1,0x53878b874283351d26d206fa512aece1bef6c0dd,0xf610a9dfb7c89644979b4a0f27063e9e7d7cda32,0xca77eb3fefe3725dc33bccb54edefc3d9f764f97".split(",");

// prettier-ignore
let STABLE_COINS: string[] = "0x9e5aac1ba1a2e6aed6b32689dfcf62a509ca96f3".split(",");
let STABLE_COINS: string[] = "0x06efdbff2a14a7c8e15944d1f4a48f9f95f663a4,0xf55bec9cafdbe8730f096aa55dad6d22d44099df,0xedeabc3a1e7d21fe835ffa6f83a710c70bb1a051,0xca77eb3fefe3725dc33bccb54edefc3d9f764f97".split(",");

let MINIMUM_ETH_LOCKED = BigDecimal.fromString("1");
let MINIMUM_ETH_LOCKED = BigDecimal.fromString("0");

let Q192 = 2 ** 192;
export function sqrtPriceX96ToTokenPrices(sqrtPriceX96: BigInt, token0: Token, token1: Token): BigDecimal[] {
Expand Down
Loading