Skip to content

Commit

Permalink
fix(#minor); convex-finance; upgrade pricelib, add override for tricr…
Browse files Browse the repository at this point in the history
…ypto pools (#2295)
  • Loading branch information
dhruv-chauhan authored Sep 15, 2023
1 parent fa12faa commit 04fc7cd
Show file tree
Hide file tree
Showing 69 changed files with 9,338 additions and 6,612 deletions.
2 changes: 1 addition & 1 deletion deployment/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@
"status": "prod",
"versions": {
"schema": "1.3.0",
"subgraph": "1.2.3",
"subgraph": "1.2.4",
"methodology": "1.0.0"
},
"files": {
Expand Down
2 changes: 1 addition & 1 deletion subgraphs/_reference_/src/prices/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const CHAIN_LINK_USD_ADDRESS = Address.fromString(
"0x0000000000000000000000000000000000000348"
);

export const PRICE_LIB_VERSION = "1.3.2";
export const PRICE_LIB_VERSION = "1.3.3";

export const INT_ZERO = 0 as i32;
export const INT_ONE = 1 as i32;
Expand Down
75 changes: 74 additions & 1 deletion subgraphs/_reference_/src/prices/config/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ export const CURVE_CALCULATIONS_ADDRESS = new OracleContract(
12370088
);

// Address Provider: https://etherscan.io/address/0x0000000022d53366457f9d5e68ec105046fc4383
export const CURVE_REGISTRY_ADDRESSES: OracleContract[] = [
new OracleContract("0x7d86446ddb609ed0f5f8684acf30380a356b2b4c", 11154794),
new OracleContract("0x8f942c20d02befc377d41445793068908e2250d0", 13986752),
new OracleContract("0x90e00ace148ca3b23ac1bc8c240c2a7dd9c2d7f5", 12195750), // Main Registry
new OracleContract("0x8f942c20d02befc377d41445793068908e2250d0", 13986752), // CryptoSwap Registry
new OracleContract("0xf98b45fa17de75fb1ad0e7afd971b0ca00e379fc", 15732062), // Meta Registry
];

///////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -95,6 +98,9 @@ export const HARDCODED_STABLES: Address[] = [
Address.fromString("0xbcca60bb61934080951369a648fb03df4f96263c"), // Aave interest bearing USDC
Address.fromString("0x6c5024cd4f8a59110119c56f8933403a539555eb"), // Aave interest bearing SUSD
Address.fromString("0xd71ecff9342a5ced620049e616c5035f1db98620"), // Synth sEUR
Address.fromString("0xfc2838a17d8e8b1d5456e0a351b0708a09211147"), // FRAX/USDP
Address.fromString("0x5ca135cb8527d76e932f34b5145575f9d8cbe08e"), // FPI
Address.fromString("0xf939e0a03fb07f59a73314e73794be0e57ac1b4e"), // crvUSD
];

///////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -169,6 +175,39 @@ class DelperOverride implements OracleConfig {
}
}

// https://github.com/messari/subgraphs/issues/2290
class CurveFactoryPoolOverride implements OracleConfig {
oracleCount(): number {
return constants.INT_ONE;
}
oracleOrder(): string[] {
return [
constants.OracleType.CURVE_ROUTER,
constants.OracleType.UNISWAP_FORKS_ROUTER,
constants.OracleType.CHAINLINK_FEED,
constants.OracleType.CURVE_CALCULATIONS,
constants.OracleType.SUSHI_CALCULATIONS,
constants.OracleType.YEARN_LENS_ORACLE,
];
}
}

class PreferUniswapOverride implements OracleConfig {
oracleCount(): number {
return constants.INT_ONE;
}
oracleOrder(): string[] {
return [
constants.OracleType.UNISWAP_FORKS_ROUTER,
constants.OracleType.CURVE_CALCULATIONS,
constants.OracleType.CHAINLINK_FEED,
constants.OracleType.SUSHI_CALCULATIONS,
constants.OracleType.CURVE_ROUTER,
constants.OracleType.YEARN_LENS_ORACLE,
];
}
}

///////////////////////////////////////////////////////////////////////////
///////////////////////////////// HELPERS /////////////////////////////////
///////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -286,6 +325,40 @@ export class config implements Configurations {
) {
return new DelperOverride();
}
if (
tokenAddr &&
[
Address.fromString("0xed4064f376cb8d68f770fb1ff088a3d0f3ff5c4d"), // crvCRVETH
Address.fromString("0xf985005a3793dba4cce241b3c19ddcd3fe069ff4"), // ALCXFRAXBP-f
Address.fromString("0x971add32ea87f10bd192671630be3be8a11b8623"), // cvxcrv-crv-f
Address.fromString("0x137469b55d1f15651ba46a89d0588e97dd0b6562"), // BADGERWBTC-f
Address.fromString("0x4647b6d835f3b393c7a955df51eefcf0db961606"), // KP3RETH-f
Address.fromString("0x6359b6d3e327c497453d4376561ee276c6933323"), // SDTETH-f
Address.fromString("0x2889302a794da87fbf1d6db415c1492194663d13"), // crvCRVUSDTBTCWSTETH
//
Address.fromString("0x7f86bf177dd4f3494b841a37e810a34dd56c829b"), // TricryptoUSDC
Address.fromString("0xf5f5b97624542d72a9e06f04804bf81baa15e2b4"), // TricryptoUSDT
Address.fromString("0x4ebdf703948ddcea3b11f675b4d1fba9d2414a14"), // TriCRV
Address.fromString("0xf3a43307dcafa93275993862aae628fcb50dc768"), // Factory Crypto Pool: cvxFxs/Fxs
Address.fromString("0xb79565c01b7ae53618d9b847b9443aaf4f9011e7"), // Factory Crypto Pool: LDO/ETH
Address.fromString("0x4704ab1fb693ce163f7c9d3a31b3ff4eaf797714"), // Factory Crypto Pool: FPI2Pool
Address.fromString("0x390f3595bca2df7d23783dfd126427cceb997bf4"), // Factory Plain Pool: crvUSD/USDT
Address.fromString("0x4dece678ceceb27446b35c672dc7d61f30bad69e"), // Factory Plain Pool: crvUSD/USDC
].includes(tokenAddr)
) {
return new CurveFactoryPoolOverride();
}
if (
tokenAddr &&
[
Address.fromString("0xdbdb4d16eda451d0503b854cf79d55697f90c8df"), // ALCX
Address.fromString("0x62b9c7356a2dc64a1969e19c23e4f579f9810aa7"), // cvxCRV
Address.fromString("0x1ceb5cb57c4d4e2b2433641b95dd330a33185a44"), // KP3R
Address.fromString("0x73968b9a57c6e53d41345fd57a6e6ae27d6cdb2f"), // SDT
].includes(tokenAddr)
) {
return new PreferUniswapOverride();
}
}

return null;
Expand Down
159 changes: 159 additions & 0 deletions subgraphs/convex-finance/abis/Prices/AaveOracle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
[
{
"inputs": [
{
"internalType": "contract IPoolAddressesProvider",
"name": "provider",
"type": "address"
},
{ "internalType": "address[]", "name": "assets", "type": "address[]" },
{ "internalType": "address[]", "name": "sources", "type": "address[]" },
{
"internalType": "address",
"name": "fallbackOracle",
"type": "address"
},
{ "internalType": "address", "name": "baseCurrency", "type": "address" },
{
"internalType": "uint256",
"name": "baseCurrencyUnit",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "asset",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "source",
"type": "address"
}
],
"name": "AssetSourceUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "baseCurrency",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "baseCurrencyUnit",
"type": "uint256"
}
],
"name": "BaseCurrencySet",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "fallbackOracle",
"type": "address"
}
],
"name": "FallbackOracleUpdated",
"type": "event"
},
{
"inputs": [],
"name": "ADDRESSES_PROVIDER",
"outputs": [
{
"internalType": "contract IPoolAddressesProvider",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "BASE_CURRENCY",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "BASE_CURRENCY_UNIT",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "asset", "type": "address" }
],
"name": "getAssetPrice",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address[]", "name": "assets", "type": "address[]" }
],
"name": "getAssetsPrices",
"outputs": [
{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getFallbackOracle",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "asset", "type": "address" }
],
"name": "getSourceOfAsset",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address[]", "name": "assets", "type": "address[]" },
{ "internalType": "address[]", "name": "sources", "type": "address[]" }
],
"name": "setAssetSources",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "fallbackOracle", "type": "address" }
],
"name": "setFallbackOracle",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
Loading

0 comments on commit 04fc7cd

Please sign in to comment.