diff --git a/deployment/deployment.json b/deployment/deployment.json index db36e1b38a..ae553dd67e 100644 --- a/deployment/deployment.json +++ b/deployment/deployment.json @@ -1150,7 +1150,7 @@ "status": "prod", "versions": { "schema": "1.3.0", - "subgraph": "1.1.4", + "subgraph": "1.2.0", "methodology": "1.0.0" }, "files": { diff --git a/subgraphs/balancer-forks/protocols/balancer-v2/config/templates/balancer.v2.template.yaml b/subgraphs/balancer-forks/protocols/balancer-v2/config/templates/balancer.v2.template.yaml index 69796a5c51..7726cdb37f 100644 --- a/subgraphs/balancer-forks/protocols/balancer-v2/config/templates/balancer.v2.template.yaml +++ b/subgraphs/balancer-forks/protocols/balancer-v2/config/templates/balancer.v2.template.yaml @@ -162,7 +162,7 @@ dataSources: handler: handleNewGauge - event: RewardsOnlyGaugeCreated(indexed address,indexed address,address) handler: handleRewardsOnlyGaugeCreated - file: ./src/mappings/GaugeControllerMappings.ts + file: ./src/mappings/gaugeControllerMappings.ts {{#usesBalancerTokenAdmin}} - kind: ethereum/contract name: BalancerTokenAdmin diff --git a/subgraphs/balancer-forks/src/common/initializers.ts b/subgraphs/balancer-forks/src/common/initializers.ts index 327e887004..701f453187 100644 --- a/subgraphs/balancer-forks/src/common/initializers.ts +++ b/subgraphs/balancer-forks/src/common/initializers.ts @@ -394,7 +394,7 @@ export function getOrCreateLiquidityPool( ); pool._poolId = poolId.toHexString(); - const inputTokensInfo = utils.getPoolTokensInfo(poolId); + const inputTokensInfo = utils.getPoolTokensInfo(poolAddress, poolId); pool.inputTokens = inputTokensInfo.getInputTokens; pool.inputTokenBalances = inputTokensInfo.getBalances; pool.inputTokenWeights = utils.getPoolTokenWeights( diff --git a/subgraphs/balancer-forks/src/common/types.ts b/subgraphs/balancer-forks/src/common/types.ts index 6ef73fe404..a1621441f1 100644 --- a/subgraphs/balancer-forks/src/common/types.ts +++ b/subgraphs/balancer-forks/src/common/types.ts @@ -66,10 +66,16 @@ export class PoolFeesType { } export class PoolTokensType { + private _poolAddress: Address; private _tokens: Address[]; private _balances: BigInt[]; - constructor(tokens: Address[] = [], balances: BigInt[] = []) { + constructor( + poolAddress: Address = constants.NULL.TYPE_ADDRESS, + tokens: Address[] = [], + balances: BigInt[] = [] + ) { + this._poolAddress = poolAddress; this._tokens = tokens; this._balances = balances; } @@ -78,6 +84,10 @@ export class PoolTokensType { const inputTokens: string[] = []; for (let idx = 0; idx < this._tokens.length; idx++) { + if (this._tokens.at(idx) == this._poolAddress) { + continue; + } + inputTokens.push(this._tokens.at(idx).toHexString()); } diff --git a/subgraphs/balancer-forks/src/common/utils.ts b/subgraphs/balancer-forks/src/common/utils.ts index 792252d63e..e5f4121763 100644 --- a/subgraphs/balancer-forks/src/common/utils.ts +++ b/subgraphs/balancer-forks/src/common/utils.ts @@ -52,13 +52,17 @@ export function getTokenDecimals(tokenAddr: Address): BigDecimal { return constants.BIGINT_TEN.pow(decimals.toI32() as u8).toBigDecimal(); } -export function getPoolTokensInfo(poolId: Bytes): PoolTokensType { +export function getPoolTokensInfo( + poolAddress: Address, + poolId: Bytes +): PoolTokensType { const vaultContract = VaultContract.bind(constants.VAULT_ADDRESS); const poolTokens = vaultContract.try_getPoolTokens(poolId); if (poolTokens.reverted) return new PoolTokensType(); return new PoolTokensType( + poolAddress, poolTokens.value.getTokens(), poolTokens.value.getBalances() ); @@ -99,7 +103,7 @@ export function getPoolInputTokenBalances( poolId: Bytes ): BigInt[] { const poolContract = WeightedPoolContract.bind(poolAddress); - const poolTokensInfo = getPoolTokensInfo(poolId); + const poolTokensInfo = getPoolTokensInfo(poolAddress, poolId); const poolBalances = poolTokensInfo.getBalances; @@ -229,6 +233,10 @@ export function getPoolTVL( ): BigDecimal { let totalValueLockedUSD = constants.BIGDECIMAL_ZERO; + if (inputTokens.length != inputTokenBalances.length) { + return totalValueLockedUSD; + } + for (let idx = 0; idx < inputTokens.length; idx++) { const inputTokenBalance = inputTokenBalances[idx]; diff --git a/subgraphs/balancer-forks/src/modules/Rewards.ts b/subgraphs/balancer-forks/src/modules/Rewards.ts index 6dfdaa67e3..a37c3eb759 100644 --- a/subgraphs/balancer-forks/src/modules/Rewards.ts +++ b/subgraphs/balancer-forks/src/modules/Rewards.ts @@ -9,7 +9,7 @@ import * as constants from "../common/constants"; import { RewardsInfoType } from "../common/types"; import { getRewardsPerDay } from "../common/rewards"; import { log, BigInt, Address, ethereum } from "@graphprotocol/graph-ts"; -import { Gauge as LiquidityGaugeContract } from "../../generated/templates/gauge/Gauge"; +import { Gauge as LiquidityGaugeContract } from "../../generated/templates/Gauge/Gauge"; import { GaugeController as GaugeControllereContract } from "../../generated/GaugeController/GaugeController"; export function getRewardsData(gaugeAddress: Address): RewardsInfoType {