Skip to content

Commit

Permalink
fix(#minor); hop-protocol; add Base config (#2310)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv-chauhan authored Aug 9, 2023
1 parent 0d33b93 commit 0dabd7a
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 24 deletions.
10 changes: 5 additions & 5 deletions deployment/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -7682,7 +7682,7 @@
"status": "prod",
"versions": {
"schema": "1.2.0",
"subgraph": "1.0.0",
"subgraph": "1.0.1",
"methodology": "1.0.0"
},
"services": {
Expand All @@ -7704,7 +7704,7 @@
"status": "prod",
"versions": {
"schema": "1.2.0",
"subgraph": "1.0.0",
"subgraph": "1.0.1",
"methodology": "1.0.0"
},
"services": {
Expand All @@ -7726,7 +7726,7 @@
"status": "prod",
"versions": {
"schema": "1.2.0",
"subgraph": "1.0.0",
"subgraph": "1.0.1",
"methodology": "1.0.0"
},
"services": {
Expand All @@ -7748,7 +7748,7 @@
"status": "prod",
"versions": {
"schema": "1.2.0",
"subgraph": "1.0.0",
"subgraph": "1.0.1",
"methodology": "1.0.0"
},
"services": {
Expand All @@ -7770,7 +7770,7 @@
"status": "prod",
"versions": {
"schema": "1.2.0",
"subgraph": "1.0.0",
"subgraph": "1.0.1",
"methodology": "1.0.0"
},
"services": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"isMainnet": false,
"subgraphName": "hop-arbitrum",
"deployment": "HOP_PROTOCOL_ARBITRUM",
"graftEnabled": true,
"subgraphId": "QmRkuASsskvysrucvDViRQHEbycKbk89r26BYfEufe7wgr",
"graftStartBlock": 51301700,
"graftEnabled": false,
"subgraphId": "",
"graftStartBlock": 0,
"amms": [
{
"dataSourceName": "HopL2Amm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ArbitrumNovaToken,
ArbitrumNovaAmm,
ArbitrumNovaHtoken,
BaseToken,
} from "../../../../../src/sdk/util/constants";
import { Network } from "../../../../../src/sdk/util/constants";
export class HopProtocolArbitrumConfigurations implements Configurations {
Expand Down Expand Up @@ -73,6 +74,8 @@ export class HopProtocolArbitrumConfigurations implements Configurations {
return this.getArbitrumNovaConfigFromTokenAddress(tokenAddress)[0];
else if (chainId == "1")
return this.getMainnetCrossTokenFromTokenAddress(tokenAddress);
else if (chainId == "8453")
return this.getBaseCrossTokenFromTokenAddress(tokenAddress);
else {
log.critical("Chain not found", []);
return "";
Expand Down Expand Up @@ -166,6 +169,15 @@ export class HopProtocolArbitrumConfigurations implements Configurations {
return "";
}

getBaseCrossTokenFromTokenAddress(tokenAddress: string): string {
if (tokenAddress == ArbitrumToken.USDC) return BaseToken.USDC;
if (tokenAddress == ArbitrumToken.ETH) return BaseToken.ETH;
else {
log.critical("BaseCrossToken not found for token: {}", [tokenAddress]);
}
return "";
}

getTokenAddressFromBridgeAddress(bridgeAddress: string): string[] {
if (bridgeAddress == ArbitrumBridge.USDC) {
return [ArbitrumToken.USDC, ArbitrumHtoken.USDC];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"network": "mainnet",
"isMainnet": true,
"graftEnabled": true,
"deployment": "HOP_PROTOCOL_ETHEREUM",
"subgraphId": "QmTP91LxyZ8hxThCSsdNF8YsA7yZReRApQyijsNnkCf9m6",
"graftStartBlock": 16423244,
"graftEnabled": false,
"subgraphId": "",
"graftStartBlock": 0,
"bridges": [
{
"dataSourceName": "Bridge",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
ArbitrumNovaHtoken,
ArbitrumNovaToken,
ArbitrumNovaAmm,
BaseToken,
BaseAmm,
} from "../../../../../src/sdk/util/constants";
import { Network } from "../../../../../src/sdk/util/constants";

Expand Down Expand Up @@ -189,6 +191,16 @@ export class HopProtocolEthereumConfigurations implements Configurations {
}
}

getBasePoolAddressFromBridgeAddress(bridgeAddress: string): string {
if (bridgeAddress == MainnetBridge.USDC) return BaseAmm.USDC;
if (bridgeAddress == MainnetBridge.ETH) return BaseAmm.ETH;
else {
log.critical("BasePoolAddress not found for bridge: {}", [bridgeAddress]);

return "";
}
}

getPoolAddressFromChainId(chainId: string, bridgeAddress: string): string {
if (chainId == "42161") {
return this.getArbitrumPoolAddressFromBridgeAddress(bridgeAddress); //Arbitrum
Expand All @@ -200,6 +212,8 @@ export class HopProtocolEthereumConfigurations implements Configurations {
return this.getPolygonPoolAddressFromBridgeAddress(bridgeAddress); //Polygon
} else if (chainId == "42170") {
return this.getArbitrumNovaPoolAddressFromBridgeAddress(bridgeAddress); //Arbitrum Nova
} else if (chainId == "8453") {
return this.getBasePoolAddressFromBridgeAddress(bridgeAddress); //Base
} else {
log.critical("Chain not found", []);
return "";
Expand All @@ -218,7 +232,13 @@ export class HopProtocolEthereumConfigurations implements Configurations {
}

getUsdcPools(): string[] {
return [PolygonAmm.USDC, XdaiAmm.USDC, ArbitrumAmm.USDC, OptimismAmm.USDC];
return [
PolygonAmm.USDC,
XdaiAmm.USDC,
ArbitrumAmm.USDC,
OptimismAmm.USDC,
BaseAmm.USDC,
];
}

getUsdcTokens(): string[] {
Expand All @@ -228,6 +248,7 @@ export class HopProtocolEthereumConfigurations implements Configurations {
ArbitrumToken.USDC,
OptimismToken.USDC,
MainnetToken.USDC,
BaseToken.USDC,
];
}
getDaiPools(): string[] {
Expand Down Expand Up @@ -263,6 +284,7 @@ export class HopProtocolEthereumConfigurations implements Configurations {
ArbitrumAmm.ETH,
PolygonAmm.ETH,
OptimismAmm.ETH,
BaseAmm.ETH,
];
}

Expand All @@ -274,6 +296,7 @@ export class HopProtocolEthereumConfigurations implements Configurations {
PolygonToken.ETH,
OptimismToken.ETH,
ArbitrumNovaToken.ETH,
BaseToken.ETH,
];
}

Expand Down Expand Up @@ -352,6 +375,8 @@ export class HopProtocolEthereumConfigurations implements Configurations {
return this.getArbitrumNovaConfigFromTokenAddress(tokenAddress)[0];
else if (chainId == "1")
return this.getMainnetCrossTokenFromTokenAddress(tokenAddress);
else if (chainId == "8453")
return this.getBaseCrossTokenFromTokenAddress(tokenAddress);
else {
log.critical("Chain not found", []);
return "";
Expand Down Expand Up @@ -405,6 +430,14 @@ export class HopProtocolEthereumConfigurations implements Configurations {
return "";
}
}
getBaseCrossTokenFromTokenAddress(tokenAddress: string): string {
if (tokenAddress == MainnetToken.USDC) return BaseToken.USDC;
if (tokenAddress == MainnetToken.ETH) return BaseToken.ETH;
else {
log.critical("BaseCrossToken not found for token: {}", [tokenAddress]);
return "";
}
}

getMainnetCrossTokenFromTokenAddress(tokenAddress: string): string {
log.critical("Mainnet cross token not found", []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
"isMainnet": false,
"subgraphName": "hop-optimism",
"deployment": "HOP_PROTOCOL_OPTIMISM",
"graftEnabled": true,
"subgraphId": "QmYSgs5XEqheZHtoQuYaTUPHAsZ2sG3UAm379EmwJrbw95",
"graftStartBlock": 106756936,

"graftEnabled": false,
"subgraphId": "",
"graftStartBlock": 0,
"amms": [
{
"dataSourceName": "HopL2Amm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ArbitrumNovaToken,
ArbitrumNovaHtoken,
ArbitrumNovaAmm,
BaseToken,
} from "../../../../../src/sdk/util/constants";
import { Network } from "../../../../../src/sdk/util/constants";
export class HopProtocolOptimismConfigurations implements Configurations {
Expand Down Expand Up @@ -107,6 +108,8 @@ export class HopProtocolOptimismConfigurations implements Configurations {
return this.getMainnetCrossTokenFromTokenAddress(tokenAddress);
else if (chainId == "42170")
return this.getArbitrumNovaConfigFromTokenAddress(tokenAddress)[0];
else if (chainId == "8453")
return this.getBaseCrossTokenFromTokenAddress(tokenAddress);
else {
log.critical("Chain not found", []);
return "";
Expand Down Expand Up @@ -182,6 +185,15 @@ export class HopProtocolOptimismConfigurations implements Configurations {
return "";
}

getBaseCrossTokenFromTokenAddress(tokenAddress: string): string {
if (tokenAddress == OptimismToken.USDC) return BaseToken.USDC;
if (tokenAddress == OptimismToken.ETH) return BaseToken.ETH;
else {
log.critical("BaseCrossToken not found for token: {}", [tokenAddress]);
}
return "";
}

getArbitrumNovaPoolAddressFromBridgeAddress(bridgeAddress: string): string {
return bridgeAddress;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"isMainnet": false,
"subgraphName": "hop-polygon",
"deployment": "HOP_PROTOCOL_POLYGON",
"graftEnabled": true,
"subgraphId": "QmQhux3MYTgebT8HpxJeW9VtvpytByGujQ4umNVm2K5sDY",
"graftStartBlock": 37748303,
"graftEnabled": false,
"subgraphId": "",
"graftStartBlock": 0,
"amms": [
{
"dataSourceName": "HopL2Amm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ArbitrumNovaToken,
ArbitrumNovaHtoken,
ArbitrumNovaAmm,
BaseToken,
} from "../../../../../src/sdk/util/constants";
import { Network } from "../../../../../src/sdk/util/constants";
export class HopProtocolPolygonConfigurations implements Configurations {
Expand Down Expand Up @@ -134,10 +135,12 @@ export class HopProtocolPolygonConfigurations implements Configurations {
return this.getXdaiCrossTokenFromTokenAddress(tokenAddress); //Xdai
} else if (chainId == "137") {
return this.getPolygonCrossTokenFromTokenAddress(tokenAddress); //Polygon
} else if (chainId == "42170")
} else if (chainId == "42170") {
return this.getArbitrumNovaConfigFromTokenAddress(tokenAddress)[0];
else if (chainId == "1") {
} else if (chainId == "1") {
return this.getMainnetCrossTokenFromTokenAddress(tokenAddress); //Mainnet
} else if (chainId == "8453") {
return this.getBaseCrossTokenFromTokenAddress(tokenAddress);
} else {
log.critical("Chain not found", []);
return "";
Expand Down Expand Up @@ -207,6 +210,15 @@ export class HopProtocolPolygonConfigurations implements Configurations {
return "";
}

getBaseCrossTokenFromTokenAddress(tokenAddress: string): string {
if (tokenAddress == PolygonToken.USDC) return BaseToken.USDC;
if (tokenAddress == PolygonToken.ETH) return BaseToken.ETH;
else {
log.critical("BaseCrossToken not found for token: {}", [tokenAddress]);
}
return "";
}

getTokenAddressFromPoolAddress(poolAddress: string): string[] {
if (poolAddress == PolygonAmm.USDC) {
return [PolygonToken.USDC, PolygonHtoken.USDC];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"isMainnet": false,
"subgraphName": "hop-xdai",
"deployment": "HOP_PROTOCOL_XDAI",
"graftEnabled": true,
"subgraphId": "QmPFJhkC1S3assspxHkzuQTuonZJuGDQ43wsoUKofcoAkg",
"graftStartBlock": 25850672,
"graftEnabled": false,
"subgraphId": "",
"graftStartBlock": 0,
"amms": [
{
"dataSourceName": "HopL2Amm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ArbitrumNovaToken,
ArbitrumNovaHtoken,
ArbitrumNovaAmm,
BaseToken,
} from "../../../../../src/sdk/util/constants";
import { Network } from "../../../../../src/sdk/util/constants";

Expand Down Expand Up @@ -68,6 +69,8 @@ export class HopProtocolxDaiConfigurations implements Configurations {
return this.getMainnetCrossTokenFromTokenAddress(tokenAddress);
else if (chainId == "42170")
return this.getArbitrumNovaConfigFromTokenAddress(tokenAddress)[0];
else if (chainId == "8453")
return this.getBaseCrossTokenFromTokenAddress(tokenAddress);
else {
log.critical("Chain not found", []);
return "";
Expand Down Expand Up @@ -155,6 +158,15 @@ export class HopProtocolxDaiConfigurations implements Configurations {
return "";
}

getBaseCrossTokenFromTokenAddress(tokenAddress: string): string {
if (tokenAddress == XdaiToken.USDC) return BaseToken.USDC;
if (tokenAddress == XdaiToken.ETH) return BaseToken.ETH;
else {
log.critical("BaseCrossToken not found for token: {}", [tokenAddress]);
}
return "";
}

getTokenAddressFromBridgeAddress(bridgeAddress: string): string[] {
if (bridgeAddress == XdaiBridge.USDC) {
return [XdaiToken.USDC, XdaiHtoken.USDC];
Expand Down
25 changes: 25 additions & 0 deletions subgraphs/hop-protocol/src/sdk/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ export const LP_FEE_TO_OFF = BigDecimal.fromString("3");

export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";

// source: https://github.com/hop-protocol/hop/blob/develop/packages/core/src/addresses/mainnet.ts

export namespace XdaiBridge {
export const USDC = "0x25d8039bb044dc227f741a9e381ca4ceae2e6ae8";
export const USDT = "0xfd5a186a7e8453eb867a360526c5d987a00acac2";
Expand Down Expand Up @@ -486,6 +488,27 @@ export namespace PolygonRewardToken {
export const ETH = "0xaa7b3a4a084e6461d486e53a03cf45004f0963b7";
}

export namespace BaseBridge {
export const USDC = "0x46ae9bab8cea96610807a275ebd36f8e916b5c61";
export const ETH = "0x3666f603cc164936c1b87e207f36beba4ac5f18a";
}
export namespace BaseAmm {
export const USDC = "0x022c5ce6f1add7423268d41e08df521d5527c2a0";
export const ETH = "0x0ce6c85cf43553de10fc56ceca0aef6ff0dd444d";
}
export namespace BaseToken {
export const USDC = "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca";
export const ETH = "0x4200000000000000000000000000000000000006";
}
export namespace BaseHToken {
export const USDC = "0x74fa978eaffa312bc92e76df40fcc1bfe7637aeb";
export const ETH = "0xc1985d7a3429cdc85e59e2e4fcc805b857e6ee2e";
}
export namespace BaseRewardToken {
export const USDC = "0x7ac115536fe3a185100b2c4de4cb328bf3a58ba6";
export const ETH = "0x12e59c59d282d2c00f3166915bed6dc2f5e2b5c7";
}

export const priceTokens = [
OptimismToken.USDC,
OptimismToken.USDT,
Expand Down Expand Up @@ -588,6 +611,8 @@ export const HOP_REWARDS = [
XdaiRewardToken.USDC_B,
XdaiRewardToken.ETH_B,
XdaiRewardToken.USDT_B,
BaseRewardToken.USDC,
BaseRewardToken.ETH,
];

export const SIX_DECIMAL_TOKENS = [
Expand Down

0 comments on commit 0dabd7a

Please sign in to comment.