Skip to content

Commit

Permalink
Merge pull request #64 from balancer/add-avax-zkevm-root-gauges
Browse files Browse the repository at this point in the history
add Avalanche and zkEVM Root Gauges
  • Loading branch information
mendesfabio authored Jun 21, 2023
2 parents f43f480 + 067b13c commit 8db0cc9
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
56 changes: 56 additions & 0 deletions manifest.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,62 @@ dataSources:
- event: GaugeCreated(indexed address)
handler: handleRootGaugeCreated
{{/if}}
{{#if avalancheRootGaugeV2Factory}}
- kind: ethereum/contract
name: AvalancheRootGaugeV2Factory
# prettier-ignore
network: {{network}}
source:
address: '{{avalancheRootGaugeV2Factory.address}}'
abi: AvalancheRootGaugeV2Factory
# prettier-ignore
startBlock: {{ avalancheRootGaugeV2Factory.startBlock }}
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
file: ./src/gaugeFactory.ts
abis:
- name: LiquidityGauge
file: ./abis/LiquidityGaugeV2.json
- name: ArbitrumRootGauge
file: ./abis/ArbitrumRootGauge.json # required for binding
- name: AvalancheRootGaugeV2Factory
file: ./abis/OptimismRootGaugeV2Factory.json # has the same GaugeCreated event
entities:
- RootGauge
eventHandlers:
- event: GaugeCreated(indexed address)
handler: handleRootGaugeCreated
{{/if}}
{{#if polygonZkEVMRootGaugeV2Factory}}
- kind: ethereum/contract
name: PolygonZkEVMRootGaugeV2Factory
# prettier-ignore
network: {{network}}
source:
address: '{{polygonZkEVMRootGaugeV2Factory.address}}'
abi: PolygonZkEVMRootGaugeV2Factory
# prettier-ignore
startBlock: {{ polygonZkEVMRootGaugeV2Factory.startBlock }}
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
file: ./src/gaugeFactory.ts
abis:
- name: LiquidityGauge
file: ./abis/LiquidityGaugeV2.json
- name: ArbitrumRootGauge
file: ./abis/ArbitrumRootGauge.json # required for binding
- name: PolygonZkEVMRootGaugeV2Factory
file: ./abis/OptimismRootGaugeV2Factory.json # has the same GaugeCreated event
entities:
- RootGauge
eventHandlers:
- event: GaugeCreated(indexed address)
handler: handleRootGaugeCreated
{{/if}}
{{#if childChainGaugeFactory}}
- kind: ethereum/contract
name: ChildChainLiquidityGaugeFactory
Expand Down
6 changes: 6 additions & 0 deletions networks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ mainnet:
gnosisRootGaugeV2Factory:
address: "0x2a18B396829bc29F66a1E59fAdd7a0269A6605E8"
startBlock: 16687758
avalancheRootGaugeV2Factory:
address: "0x10f3e79911A490aa5B5D5CDA6F111029c4Eab5AC"
startBlock: 17396953
polygonZkEVMRootGaugeV2Factory:
address: "0x9bF951848288cCD87d06FaC426150262cD3447De"
startBlock: 17295833
authorizerAdaptorEntrypoint:
address: "0xf5dECDB1f3d1ee384908Fbe16D2F0348AE43a9eA"
startBlock: 16042168
Expand Down
2 changes: 2 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ enum Chain {
Gnosis
Polygon
Optimism
Avalanche
zkEVM
}

type RootGauge @entity {
Expand Down
6 changes: 6 additions & 0 deletions src/gaugeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import { getPoolEntity, getPoolId, isPoolRegistered } from './utils/misc';
import { RewardsOnlyGaugeCreated } from './types/ChildChainLiquidityGaugeFactory/ChildChainLiquidityGaugeFactory';
import {
isArbitrumFactory,
isAvalancheFactory,
isGnosisFactory,
isOptimismFactory,
isPolygonFactory,
isPolygonZkEVMFactory,
} from './utils/constants';
import { GaugeCreated as LiquidityGaugeCreated } from './types/GaugeV2Factory/GaugeV2Factory';
import { GaugeCreated as RootGaugeCreated } from './types/ArbitrumRootGaugeV2Factory/ArbitrumRootGaugeV2Factory';
Expand Down Expand Up @@ -181,6 +183,10 @@ export function handleRootGaugeCreated(event: RootGaugeCreated): void {
gauge.chain = 'Polygon';
} else if (isGnosisFactory(factoryAddress)) {
gauge.chain = 'Gnosis';
} else if (isAvalancheFactory(factoryAddress)) {
gauge.chain = 'Avalanche';
} else if (isPolygonZkEVMFactory(factoryAddress)) {
gauge.chain = 'zkEVM';
}

gauge.save();
Expand Down
14 changes: 14 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ export const OPTIMISM_ROOT_GAUGE_V2_FACTORY = Address.fromString(
export const POLYGON_ROOT_GAUGE_V2_FACTORY = Address.fromString(
'0xa98Bce70c92aD2ef3288dbcd659bC0d6b62f8F13',
);
export const AVALANCHE_ROOT_GAUGE_V2_FACTORY = Address.fromString(
'0x10f3e79911A490aa5B5D5CDA6F111029c4Eab5AC',
);
export const POLYGON_ZKEVM_ROOT_GAUGE_V2_FACTORY = Address.fromString(
'0x9bF951848288cCD87d06FaC426150262cD3447De',
);

export function isArbitrumFactory(factory: Address): boolean {
return [ARBITRUM_ROOT_GAUGE_FACTORY, ARBITRUM_ROOT_GAUGE_V2_FACTORY].includes(
Expand Down Expand Up @@ -107,3 +113,11 @@ export function isPolygonFactory(factory: Address): boolean {
export function isGnosisFactory(factory: Address): boolean {
return factory == GNOSIS_ROOT_GAUGE_V2_FACTORY;
}

export function isAvalancheFactory(factory: Address): boolean {
return factory == AVALANCHE_ROOT_GAUGE_V2_FACTORY;
}

export function isPolygonZkEVMFactory(factory: Address): boolean {
return factory == POLYGON_ZKEVM_ROOT_GAUGE_V2_FACTORY;
}

0 comments on commit 8db0cc9

Please sign in to comment.