Skip to content

Commit

Permalink
Add more networks support to price lib
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh9200 committed Jun 20, 2024
1 parent a5cfa6a commit dd15c21
Show file tree
Hide file tree
Showing 6 changed files with 662 additions and 0 deletions.
15 changes: 15 additions & 0 deletions subgraphs/_reference_/src/prices/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import * as BSC from "../config/bsc";
import * as BASE from "../config/base";
import * as MODE from "../config/mode";
import * as CELO from "../config/celo";
import * as FUSE from "../config/fuse";
import * as XDAI from "../config/gnosis";
import * as BLAST from "../config/blast";
import * as CRONOS from "../config/cronos";
import * as AURORA from "../config/aurora";
import * as FANTOM from "../config/fantom";
import * as SCROLL from "../config/scroll";
import * as POLYGON from "../config/polygon";
import * as MAINNET from "../config/mainnet";
import * as HARMONY from "../config/harmony";
import * as MOONBEAM from "../config/moonbeam";
import * as OPTIMISM from "../config/optimism";
import * as AVALANCHE from "../config/avalanche";
import * as ARBITRUM_ONE from "../config/arbitrum";
import * as ZKSYNC_ERA from "../config/zksync_era";
import * as POLYGON_ZKEVM from "../config/polygon_zkevm";

import { Configurations, CustomPriceType } from "./types";
import * as constants from "./constants";
Expand Down Expand Up @@ -108,6 +113,16 @@ export function getConfig(): Configurations {
return new FUSE.config();
} else if (network == BLAST.NETWORK_STRING) {
return new BLAST.config();
} else if (network == BASE.NETWORK_STRING) {
return new BASE.config();
} else if (network == MODE.NETWORK_STRING) {
return new MODE.config();
} else if (network == POLYGON_ZKEVM.NETWORK_STRING) {
return new POLYGON_ZKEVM.config();
} else if (network == SCROLL.NETWORK_STRING) {
return new SCROLL.config();
} else if (network == ZKSYNC_ERA.NETWORK_STRING) {
return new ZKSYNC_ERA.config();
}

return new TEMPLATE.config();
Expand Down
130 changes: 130 additions & 0 deletions subgraphs/_reference_/src/prices/config/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import * as constants from "../common/constants";
import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts";
import { Configurations, OracleConfig, OracleContract } from "../common/types";

export const NETWORK_STRING = "base";

///////////////////////////////////////////////////////////////////////////
///////////////////// CALCULATIONS/ORACLE CONTRACT ////////////////////////
///////////////////////////////////////////////////////////////////////////

export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract();
export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract();
export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract();
export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract();

///////////////////////////////////////////////////////////////////////////
///////////////////////////// CURVE CONTRACT //////////////////////////////
///////////////////////////////////////////////////////////////////////////

export const CURVE_CALCULATIONS_ADDRESS = new OracleContract();

export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [];

///////////////////////////////////////////////////////////////////////////
/////////////////////////// UNISWAP FORKS CONTRACT ////////////////////////
///////////////////////////////////////////////////////////////////////////

export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [
new OracleContract("0x8cfe327cec66d1c090dd72bd0ff11d690c33a2eb", 2910568),
new OracleContract("0x6bded42c6da8fbf0d2ba55b2fa120c5e0c8d7891", 2631217),
];

///////////////////////////////////////////////////////////////////////////
/////////////////////////// BLACKLISTED TOKENS ////////////////////////////
///////////////////////////////////////////////////////////////////////////

export const YEARN_LENS_BLACKLIST: Address[] = [];
export const AAVE_ORACLE_BLACKLIST: Address[] = [];
export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = [];
export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = [];

///////////////////////////////////////////////////////////////////////////
//////////////////////////// HARDCODED STABLES ////////////////////////////
///////////////////////////////////////////////////////////////////////////

export const HARDCODED_STABLES: Address[] = [];

///////////////////////////////////////////////////////////////////////////
///////////////////////////////// HELPERS /////////////////////////////////
///////////////////////////////////////////////////////////////////////////

export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6);

export const ETH_ADDRESS = constants.NULL.TYPE_ADDRESS;
export const WETH_ADDRESS = Address.fromString(
"0x4200000000000000000000000000000000000006"
);
export const USDC_ADDRESS = Address.fromString(
"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
);

export class config implements Configurations {
network(): string {
return NETWORK_STRING;
}

yearnLens(): OracleContract {
return YEARN_LENS_CONTRACT_ADDRESS;
}
chainLink(): OracleContract {
return CHAIN_LINK_CONTRACT_ADDRESS;
}
yearnLensBlacklist(): Address[] {
return YEARN_LENS_BLACKLIST;
}

aaveOracle(): OracleContract {
return AAVE_ORACLE_CONTRACT_ADDRESS;
}
aaveOracleBlacklist(): Address[] {
return AAVE_ORACLE_BLACKLIST;
}

curveCalculations(): OracleContract {
return CURVE_CALCULATIONS_ADDRESS;
}
curveCalculationsBlacklist(): Address[] {
return CURVE_CALCULATIONS_BLACKSLIST;
}

sushiCalculations(): OracleContract {
return SUSHISWAP_CALCULATIONS_ADDRESS;
}
sushiCalculationsBlacklist(): Address[] {
return SUSHI_CALCULATIONS_BLACKSLIST;
}

uniswapForks(): OracleContract[] {
return UNISWAP_FORKS_ROUTER_ADDRESSES;
}
curveRegistry(): OracleContract[] {
return CURVE_REGISTRY_ADDRESSES;
}

hardcodedStables(): Address[] {
return HARDCODED_STABLES;
}

ethAddress(): Address {
return ETH_ADDRESS;
}
wethAddress(): Address {
return WETH_ADDRESS;
}
usdcAddress(): Address {
return USDC_ADDRESS;
}

usdcTokenDecimals(): BigInt {
return USDC_TOKEN_DECIMALS;
}

getOracleOverride(
tokenAddr: Address | null,
block: ethereum.Block | null
): OracleConfig | null {
return null;
}
}
129 changes: 129 additions & 0 deletions subgraphs/_reference_/src/prices/config/mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import * as constants from "../common/constants";
import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts";
import { Configurations, OracleConfig, OracleContract } from "../common/types";

export const NETWORK_STRING = "mode-mainnet";

///////////////////////////////////////////////////////////////////////////
///////////////////// CALCULATIONS/ORACLE CONTRACT ////////////////////////
///////////////////////////////////////////////////////////////////////////

export const YEARN_LENS_CONTRACT_ADDRESS = new OracleContract();
export const CHAIN_LINK_CONTRACT_ADDRESS = new OracleContract();
export const AAVE_ORACLE_CONTRACT_ADDRESS = new OracleContract();
export const SUSHISWAP_CALCULATIONS_ADDRESS = new OracleContract();

///////////////////////////////////////////////////////////////////////////
///////////////////////////// CURVE CONTRACT //////////////////////////////
///////////////////////////////////////////////////////////////////////////

export const CURVE_CALCULATIONS_ADDRESS = new OracleContract();

export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [];

///////////////////////////////////////////////////////////////////////////
/////////////////////////// UNISWAP FORKS CONTRACT ////////////////////////
///////////////////////////////////////////////////////////////////////////

export const UNISWAP_FORKS_ROUTER_ADDRESSES: OracleContract[] = [
new OracleContract("0xc1e624c810d297fd70ef53b0e08f44fabe468591", 3325344),
];

///////////////////////////////////////////////////////////////////////////
/////////////////////////// BLACKLISTED TOKENS ////////////////////////////
///////////////////////////////////////////////////////////////////////////

export const YEARN_LENS_BLACKLIST: Address[] = [];
export const AAVE_ORACLE_BLACKLIST: Address[] = [];
export const CURVE_CALCULATIONS_BLACKSLIST: Address[] = [];
export const SUSHI_CALCULATIONS_BLACKSLIST: Address[] = [];

///////////////////////////////////////////////////////////////////////////
//////////////////////////// HARDCODED STABLES ////////////////////////////
///////////////////////////////////////////////////////////////////////////

export const HARDCODED_STABLES: Address[] = [];

///////////////////////////////////////////////////////////////////////////
///////////////////////////////// HELPERS /////////////////////////////////
///////////////////////////////////////////////////////////////////////////

export const USDC_TOKEN_DECIMALS = BigInt.fromI32(6);

export const ETH_ADDRESS = constants.NULL.TYPE_ADDRESS;
export const WETH_ADDRESS = Address.fromString(
"0x4200000000000000000000000000000000000006"
);
export const USDC_ADDRESS = Address.fromString(
"0xd988097fb8612cc24eec14542bc03424c656005f"
);

export class config implements Configurations {
network(): string {
return NETWORK_STRING;
}

yearnLens(): OracleContract {
return YEARN_LENS_CONTRACT_ADDRESS;
}
chainLink(): OracleContract {
return CHAIN_LINK_CONTRACT_ADDRESS;
}
yearnLensBlacklist(): Address[] {
return YEARN_LENS_BLACKLIST;
}

aaveOracle(): OracleContract {
return AAVE_ORACLE_CONTRACT_ADDRESS;
}
aaveOracleBlacklist(): Address[] {
return AAVE_ORACLE_BLACKLIST;
}

curveCalculations(): OracleContract {
return CURVE_CALCULATIONS_ADDRESS;
}
curveCalculationsBlacklist(): Address[] {
return CURVE_CALCULATIONS_BLACKSLIST;
}

sushiCalculations(): OracleContract {
return SUSHISWAP_CALCULATIONS_ADDRESS;
}
sushiCalculationsBlacklist(): Address[] {
return SUSHI_CALCULATIONS_BLACKSLIST;
}

uniswapForks(): OracleContract[] {
return UNISWAP_FORKS_ROUTER_ADDRESSES;
}
curveRegistry(): OracleContract[] {
return CURVE_REGISTRY_ADDRESSES;
}

hardcodedStables(): Address[] {
return HARDCODED_STABLES;
}

ethAddress(): Address {
return ETH_ADDRESS;
}
wethAddress(): Address {
return WETH_ADDRESS;
}
usdcAddress(): Address {
return USDC_ADDRESS;
}

usdcTokenDecimals(): BigInt {
return USDC_TOKEN_DECIMALS;
}

getOracleOverride(
tokenAddr: Address | null,
block: ethereum.Block | null
): OracleConfig | null {
return null;
}
}
Loading

0 comments on commit dd15c21

Please sign in to comment.