Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh9200 committed Jun 23, 2024
1 parent 84a64c0 commit 425dc65
Show file tree
Hide file tree
Showing 22 changed files with 705 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"network": "arbitrum-one",

"DepositQueue": {
"address": "0xf25484650484de3d554fb0b7125e7696efa4ab99",
"startBlock": "185410811"
},
"ezETH": {
"address": "0x2416092f143378750bb29b79ed961ab195cceea5",
"startBlock": "185410162"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"network": "base",

"RestakeManager": {
"DepositQueue": {
"address": "0xf25484650484de3d554fb0b7125e7696efa4ab99",
"startBlock": "12682217"
},
"ezETH": {
"address": "0x2416092f143378750bb29b79ed961ab195cceea5",
"startBlock": "12682160"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"network": "blast-mainnet",

"DepositQueue": {
"address": "0xe65843850106421eab49dd43d19fa2d75fc19a75",
"startBlock": "1031132"
},
"ezETH": {
"address": "0x2416092f143378750bb29b79ed961ab195cceea5",
"startBlock": "722967"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"network": "bsc",

"RestakeManager": {
"DepositQueue": {
"address": "0xf25484650484de3d554fb0b7125e7696efa4ab99",
"startBlock": "36596596"
},
"ezETH": {
"address": "0x2416092f143378750bb29b79ed961ab195cceea5",
"startBlock": "36596546"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"network": "base",

"RestakeManager": {
"DepositQueue": {
"address": "0x4d7572040b84b41a6aa2efe4a93efff182388f88",
"startBlock": "5005667"
},
"ezETH": {
"address": "0x2416092f143378750bb29b79ed961ab195cceea5",
"startBlock": "4749150"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ dataSources:
abis:
- name: DepositQueue
file: ./abis/DepositQueue.json
- name: RestakeManager
file: ./abis/RestakeManager.json
- name: ERC20
file: ./abis/ERC20.json

Expand Down
6 changes: 3 additions & 3 deletions subgraphs/renzo/src/common/initializers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { SDK } from "../sdk/protocols/generic";
import * as constants from "../common/constants";
import { Pool } from "../sdk/protocols/generic/pool";
import { ProtocolConfig } from "../sdk/protocols/config";
import { ERC20 } from "../../generated/RestakeManager/ERC20";
import { ERC20 } from "../../generated/DepositQueue/ERC20";
import { Pricer, TokenInit, readValue } from "../common/utils";
import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts";
import { DepositQueue } from "../../generated/RestakeManager/DepositQueue";
import { RestakeManager } from "../../generated/RestakeManager/RestakeManager";
import { DepositQueue } from "../../generated/DepositQueue/DepositQueue";
import { RestakeManager } from "../../generated/DepositQueue/RestakeManager";

export function initializeSDKFromEvent(event: ethereum.Event): SDK {
const protocolConfig = new ProtocolConfig(
Expand Down
2 changes: 1 addition & 1 deletion subgraphs/renzo/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Token } from "../../generated/schema";
import * as constants from "../common/constants";
import { TokenPricer } from "../sdk/protocols/config";
import { bigIntToBigDecimal } from "../sdk/util/numbers";
import { ERC20 } from "../../generated/DepositQueue/ERC20";
import { getUsdPrice, getUsdPricePerToken } from "../prices";
import { ERC20 } from "../../generated/RestakeManager/ERC20";
import { Address, BigDecimal, BigInt, ethereum } from "@graphprotocol/graph-ts";
import { TokenParams, TokenInitializer } from "../sdk/protocols/generic/tokens";

Expand Down
52 changes: 3 additions & 49 deletions subgraphs/renzo/src/mappings/ezEthMappings.ts
Original file line number Diff line number Diff line change
@@ -1,58 +1,12 @@
import { Versions } from "../versions";
import { Token } from "../../generated/schema";
import { SDK } from "../sdk/protocols/generic";
import * as constants from "../common/constants";
import { ERC20 } from "../../generated/ezETH/ERC20";
import { Pool } from "../sdk/protocols/generic/pool";
import { bigIntToBigDecimal } from "../sdk/util/numbers";
import { getUsdPrice, getUsdPricePerToken } from "../prices";
import { ProtocolConfig } from "../sdk/protocols/config";
import { Pricer, TokenInit, readValue } from "../common/utils";
import { MintCall, BurnCall } from "../../generated/ezETH/ezETH";
import { ProtocolConfig, TokenPricer } from "../sdk/protocols/config";
import { Address, BigDecimal, BigInt, ethereum } from "@graphprotocol/graph-ts";
import { TokenInitializer, TokenParams } from "../sdk/protocols/generic/tokens";

export function readValue<T>(
callResult: ethereum.CallResult<T>,
defaultValue: T
): T {
return callResult.reverted ? defaultValue : callResult.value;
}

export class Pricer implements TokenPricer {
getTokenPrice(token: Token): BigDecimal {
const pricedToken = Address.fromBytes(token.id);

return getUsdPricePerToken(pricedToken).usdPrice;
}

getAmountValueUSD(token: Token, amount: BigInt): BigDecimal {
const pricedToken = Address.fromBytes(token.id);
const _amount = bigIntToBigDecimal(amount, token.decimals);

return getUsdPrice(pricedToken, _amount);
}
}

export class TokenInit implements TokenInitializer {
getTokenParams(address: Address): TokenParams {
const contract = ERC20.bind(address);
let default_name = "unknown";
let default_symbol = "UNKNOWN";
let default_decimals = constants.INT_ZERO as i32;

if (address == Address.fromString(constants.ETH_ADDRESS)) {
default_name = constants.ETH_NAME;
default_symbol = constants.ETH_SYMBOL;
default_decimals = constants.DEFAULT_DECIMALS as i32;
}

const name = readValue<string>(contract.try_name(), default_name);
const symbol = readValue<string>(contract.try_symbol(), default_symbol);
const decimals = readValue<i32>(contract.try_decimals(), default_decimals);

return new TokenParams(name, symbol, decimals);
}
}
import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts";

export function initializeSDKFromCall(call: ethereum.Call): SDK {
const protocolConfig = new ProtocolConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as utils from "../common/utils";
import * as constants from "../common/constants";
import { CustomPriceType, OracleContract } from "../common/types";
import { Address, BigDecimal, BigInt, ethereum } from "@graphprotocol/graph-ts";
import { CalculationsCurve as CalculationsCurveContract } from "../../../generated/RestakeManager/CalculationsCurve";
import { CalculationsCurve as CalculationsCurveContract } from "../../../generated/DepositQueue/CalculationsCurve";

export function getCalculationsCurveContract(
contract: OracleContract,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as utils from "../common/utils";
import * as constants from "../common/constants";
import { CustomPriceType, OracleContract } from "../common/types";
import { Address, BigDecimal, BigInt, ethereum } from "@graphprotocol/graph-ts";
import { CalculationsSushiSwap as CalculationsSushiContract } from "../../../generated/RestakeManager/CalculationsSushiSwap";
import { CalculationsSushiSwap as CalculationsSushiContract } from "../../../generated/DepositQueue/CalculationsSushiSwap";

export function getSushiSwapContract(
contract: OracleContract,
Expand Down
17 changes: 16 additions & 1 deletion subgraphs/renzo/src/prices/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
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";
import * as TEMPLATE from "../config/template";
import { _ERC20 } from "../../../generated/RestakeManager/_ERC20";
import { _ERC20 } from "../../../generated/DepositQueue/_ERC20";
import {
Address,
BigInt,
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/renzo/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;
}
}
Loading

0 comments on commit 425dc65

Please sign in to comment.