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

fix: Add ankr staked bnb hardcoded overrides #226

Merged
merged 1 commit into from
Dec 18, 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
23 changes: 15 additions & 8 deletions subgraphs/isolated-pools/src/operations/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, BigInt, Bytes } from '@graphprotocol/graph-ts';
import { Address, BigInt } from '@graphprotocol/graph-ts';

import { Comptroller as ComptrollerContract } from '../../generated/PoolRegistry/Comptroller';
import { PoolRegistry as PoolRegistryContract } from '../../generated/PoolRegistry/PoolRegistry';
Expand Down Expand Up @@ -33,8 +33,15 @@ import {
vagEURAddress,
vankrBNBDeFiAddress,
vankrBNBLiquidStakedBNBAddress,
vWETHLiquidStakedETHAddress,
vWETHCoreAddress,
} from '../constants/addresses';
import { getOrCreateMarketReward, getOrCreateToken } from './getOrCreate';
import {
getOrCreateMarketReward,
getOrCreateToken,
getOrCreateWrappedEthToken,
getOrCreateAnkrStakedBNBToken,
} from './getOrCreate';
import { getTokenPriceInCents, valueOrNotAvailableIntIfReverted } from '../utilities';
import {
getAccountId,
Expand Down Expand Up @@ -175,16 +182,12 @@ export function createMarket(
}

if (vTokenAddress.equals(vankrBNBLiquidStakedBNBAddress)) {
market.underlyingToken = getOrCreateToken(
Address.fromBytes(Bytes.fromHexString('0x5269b7558D3d5E113010Ef1cFF0901c367849CC9')),
).id;
market.underlyingToken = getOrCreateAnkrStakedBNBToken().id;
market.symbol = 'vankrBNB_LiquidStakedBNB';
}

if (vTokenAddress.equals(vankrBNBDeFiAddress)) {
market.underlyingToken = getOrCreateToken(
Address.fromBytes(Bytes.fromHexString('0x5269b7558D3d5E113010Ef1cFF0901c367849CC9')),
).id;
market.underlyingToken = getOrCreateAnkrStakedBNBToken().id;
market.symbol = 'vankrBNB_DeFi';
}

Expand All @@ -193,6 +196,10 @@ export function createMarket(
market.symbol = 'vslisBNB_LiquidStakedBNB';
}

if (vTokenAddress.equals(vWETHLiquidStakedETHAddress) || vTokenAddress.equals(vWETHCoreAddress)) {
market.underlyingToken = getOrCreateWrappedEthToken().id;
}

market.save();
return market;
}
Expand Down
23 changes: 17 additions & 6 deletions subgraphs/isolated-pools/src/operations/getOrCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
createPool,
createRewardDistributor,
} from './create';
import { vWETHLiquidStakedETHAddress, vWETHCoreAddress } from '../constants/addresses';
import { getMarketPosition, getMarket } from './get';

// BIFI was delisted before it was listed. Creation ignores this market.
Expand Down Expand Up @@ -146,7 +145,23 @@ export const getOrCreateRewardDistributor = (
return rewardsDistributor as RewardsDistributor;
};

function getOrCreateWrappedEthToken(): Token {
export function getOrCreateAnkrStakedBNBToken(): Token {
const underlyingTokenAddress = Address.fromBytes(
Bytes.fromHexString('0x5269b7558D3d5E113010Ef1cFF0901c367849CC9'),
);
let tokenEntity = Token.load(getTokenId(underlyingTokenAddress));
if (!tokenEntity) {
tokenEntity = new Token(getTokenId(underlyingTokenAddress));
tokenEntity.address = underlyingTokenAddress;
tokenEntity.name = 'Ankr Staked BNB';
tokenEntity.symbol = 'ankrBNB ';
tokenEntity.decimals = 18;
tokenEntity.save();
}
return tokenEntity;
}

export function getOrCreateWrappedEthToken(): Token {
const underlyingTokenAddress = Address.fromBytes(
Bytes.fromHexString('0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9'),
);
Expand All @@ -161,7 +176,6 @@ function getOrCreateWrappedEthToken(): Token {
}
return tokenEntity;
}

/**
* Creates and Token object with symbol and address
*
Expand All @@ -170,9 +184,6 @@ function getOrCreateWrappedEthToken(): Token {
*/
export function getOrCreateToken(asset: Address): Token {
let tokenEntity = Token.load(getTokenId(asset));
if (asset.equals(vWETHCoreAddress) || asset.equals(vWETHLiquidStakedETHAddress)) {
return getOrCreateWrappedEthToken();
}

if (!tokenEntity) {
const erc20 = BEP20.bind(asset);
Expand Down
Loading