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(#patch); hop-protocol-xdai; add missing WMATIC_XDAI address #2438

Merged
merged 3 commits into from
Dec 12, 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: 1 addition & 1 deletion deployment/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -8392,7 +8392,7 @@
"status": "prod",
"versions": {
"schema": "1.2.0",
"subgraph": "1.1.0",
"subgraph": "1.1.1",
"methodology": "1.0.0"
},
"services": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export class HopProtocolxDaiConfigurations implements Configurations {
else if (tokenAddress == XdaiToken.ETH) return XdaiAmm.ETH;
else if (tokenAddress == XdaiToken.MATIC) return XdaiAmm.MATIC;
else {
log.critical("Token not found", []);
log.critical(
"[getPoolAddressFromTokenAddress] Pool not found for token: {}",
[tokenAddress]
);
return "";
}
}
Expand All @@ -52,7 +55,9 @@ export class HopProtocolxDaiConfigurations implements Configurations {
} else if (tokenAddress == RewardTokens.HOP) {
return ["HOP", "HOP Token", "18", ZERO_ADDRESS];
} else {
log.critical("Token not found", []);
log.critical("[getTokenDetails] Token details not found for token: {}", [
tokenAddress,
]);
return [];
}
}
Expand Down Expand Up @@ -112,7 +117,10 @@ export class HopProtocolxDaiConfigurations implements Configurations {
} else if (tokenAddress == XdaiToken.ETH) {
return ArbitrumToken.ETH;
} else {
log.critical("Token not found", []);
log.critical(
"[getArbitrumCrossTokenFromTokenAddress] ArbitrumCrossToken not found for token: {}",
[tokenAddress]
);
}
return "";
}
Expand All @@ -129,7 +137,10 @@ export class HopProtocolxDaiConfigurations implements Configurations {
} else if (tokenAddress == XdaiToken.ETH) {
return PolygonToken.ETH;
} else {
log.critical("Token not found", []);
log.critical(
"[getPolygonCrossTokenFromTokenAddress] PolygonCrossToken not found for token: {}",
[tokenAddress]
);
}
return "";
}
Expand All @@ -144,7 +155,10 @@ export class HopProtocolxDaiConfigurations implements Configurations {
} else if (tokenAddress == XdaiToken.ETH) {
return OptimismToken.ETH;
} else {
log.critical("Token not found", []);
log.critical(
"[getOptimismCrossTokenFromTokenAddress] OptimismCrossToken not found for token: {}",
[tokenAddress]
);
}
return "";
}
Expand All @@ -156,7 +170,10 @@ export class HopProtocolxDaiConfigurations implements Configurations {
else if (tokenAddress == XdaiToken.MATIC) return MainnetToken.MATIC;
else if (tokenAddress == XdaiToken.ETH) return MainnetToken.ETH;
else {
log.critical("Token not found", []);
log.critical(
"[getMainnetCrossTokenFromTokenAddress] MainnetCrossToken not found for token: {}",
[tokenAddress]
);
}
return "";
}
Expand All @@ -165,15 +182,21 @@ export class HopProtocolxDaiConfigurations implements Configurations {
if (tokenAddress == XdaiToken.USDC) return BaseToken.USDC;
if (tokenAddress == XdaiToken.ETH) return BaseToken.ETH;
else {
log.critical("Base CrossToken not found for token: {}", [tokenAddress]);
log.critical(
"[getBaseCrossTokenFromTokenAddress] BaseCrossToken not found for token: {}",
[tokenAddress]
);
}
return "";
}

getLineaCrossTokenFromTokenAddress(tokenAddress: string): string {
if (tokenAddress == XdaiToken.ETH) return LineaToken.ETH;
else {
log.critical("Linea CrossToken not found for token: {}", [tokenAddress]);
log.critical(
"[getLineaCrossTokenFromTokenAddress] LineaCrossToken not found for token: {}",
[tokenAddress]
);
}
return "";
}
Expand All @@ -190,7 +213,10 @@ export class HopProtocolxDaiConfigurations implements Configurations {
} else if (bridgeAddress == XdaiBridge.MATIC) {
return [XdaiToken.MATIC, XdaiHtoken.MATIC];
} else {
log.critical("Token not found", []);
log.critical(
"[getTokenAddressFromBridgeAddress] Token not found for bridge: {}",
[bridgeAddress]
);
return [""];
}
}
Expand All @@ -204,7 +230,10 @@ export class HopProtocolxDaiConfigurations implements Configurations {
else if (poolAddress == XdaiAmm.MATIC)
return [XdaiToken.MATIC, XdaiHtoken.MATIC];
else {
log.critical("Token not found", []);
log.critical(
"[getTokenAddressFromPoolAddress] Token not found for pool: {}",
[poolAddress]
);
return [""];
}
}
Expand Down
3 changes: 2 additions & 1 deletion subgraphs/hop-protocol/src/sdk/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,8 @@ export namespace RewardTokens {
export const rETH_OP = "0xc81d1f0eb955b0c020e5d5b264e1ff72c14d1401";
export const rETH_ARB = "0xb766039cc6db368759c1e56b79affe831d0cc507";
export const WETH = "0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1";
export const WMATIC = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270";
export const WMATIC_POLYGON = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270";
export const WMATIC_XDAI = "0x7122d7661c4564b7c6cd4878b06766489a6028a2";
}
export const GNO_REWARDS = [
XdaiRewardToken.DAI_A,
Expand Down
111 changes: 35 additions & 76 deletions subgraphs/hop-protocol/src/sdk/util/rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,15 @@ function getStartingBlockRate(): BigDecimal {
return BIGDECIMAL_ZERO;
}
}
export function updateWithdrawn(
pools: PoolManager,
hPools: PoolManager,

export function equalsIgnoreCase(a: string, b: string): boolean {
return a.replace("-", "_").toLowerCase() == b.replace("-", "_").toLowerCase();
}

function getTokenFromRewardToken(
tokens: TokenManager,
poolName: string,
poolSymbol: string,
hPoolName: string,
poolAddress: string,
rewardToken: string,
amount: BigInt
): void {
rewardToken: string
): Token | null {
let token: Token | null = null;
if (GNO_REWARDS.includes(rewardToken)) {
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.GNO));
Expand All @@ -338,24 +336,41 @@ export function updateWithdrawn(
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.HOP));
}
if (RPL_REWARDS.includes(rewardToken)) {
if (
dataSource.network().toUpperCase().replace("-", "_") ==
Network.ARBITRUM_ONE
)
if (equalsIgnoreCase(dataSource.network(), Network.ARBITRUM_ONE))
token = tokens.getOrCreateToken(
Address.fromString(RewardTokens.rETH_ARB)
);
if (
dataSource.network().toUpperCase().replace("-", "_") == Network.OPTIMISM
)
if (equalsIgnoreCase(dataSource.network(), Network.OPTIMISM))
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.rETH_OP));
}
if (WMATIC_REWARDS.includes(rewardToken)) {
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.WMATIC));
if (equalsIgnoreCase(dataSource.network(), Network.MATIC))
token = tokens.getOrCreateToken(
Address.fromString(RewardTokens.WMATIC_POLYGON)
);
if (equalsIgnoreCase(dataSource.network(), Network.XDAI))
token = tokens.getOrCreateToken(
Address.fromString(RewardTokens.WMATIC_XDAI)
);
}
if (WETH_REWARDS.includes(rewardToken)) {
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.WETH));
}
return token;
}

export function updateWithdrawn(
pools: PoolManager,
hPools: PoolManager,
tokens: TokenManager,
poolName: string,
poolSymbol: string,
hPoolName: string,
poolAddress: string,
rewardToken: string,
amount: BigInt
): void {
const token = getTokenFromRewardToken(tokens, rewardToken);
if (!token) return;

poolAddress =
Expand Down Expand Up @@ -387,35 +402,7 @@ export function updateStaked(
rewardToken: string,
amount: BigInt
): void {
let token: Token | null = null;
if (GNO_REWARDS.includes(rewardToken)) {
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.GNO));
}
if (OP_REWARDS.includes(rewardToken)) {
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.OP));
}
if (HOP_REWARDS.includes(rewardToken)) {
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.HOP));
}
if (RPL_REWARDS.includes(rewardToken)) {
if (
dataSource.network().toUpperCase().replace("-", "_") ==
Network.ARBITRUM_ONE
)
token = tokens.getOrCreateToken(
Address.fromString(RewardTokens.rETH_ARB)
);
if (
dataSource.network().toUpperCase().replace("-", "_") == Network.OPTIMISM
)
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.rETH_OP));
}
if (WMATIC_REWARDS.includes(rewardToken)) {
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.WMATIC));
}
if (WETH_REWARDS.includes(rewardToken)) {
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.WETH));
}
const token = getTokenFromRewardToken(tokens, rewardToken);
if (!token) return;

poolAddress =
Expand Down Expand Up @@ -447,35 +434,7 @@ export function updateRewardsPaid(
event: ethereum.Event
): void {
const rewardToken = event.address.toHexString();
let token: Token | null = null;
if (GNO_REWARDS.includes(rewardToken)) {
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.GNO));
}
if (OP_REWARDS.includes(rewardToken)) {
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.OP));
}
if (HOP_REWARDS.includes(rewardToken)) {
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.HOP));
}
if (RPL_REWARDS.includes(rewardToken)) {
if (
dataSource.network().toUpperCase().replace("-", "_") ==
Network.ARBITRUM_ONE
)
token = tokens.getOrCreateToken(
Address.fromString(RewardTokens.rETH_ARB)
);
if (
dataSource.network().toUpperCase().replace("-", "_") == Network.OPTIMISM
)
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.rETH_OP));
}
if (WMATIC_REWARDS.includes(rewardToken)) {
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.WMATIC));
}
if (WETH_REWARDS.includes(rewardToken)) {
token = tokens.getOrCreateToken(Address.fromString(RewardTokens.WETH));
}
const token = getTokenFromRewardToken(tokens, rewardToken);
if (!token) return;

poolAddress =
Expand Down
Loading