Skip to content

Commit

Permalink
Merge pull request #542 from balancer/fix-managed-weights
Browse files Browse the repository at this point in the history
fix Managed pool tokens weights
  • Loading branch information
mendesfabio authored Dec 8, 2023
2 parents fffa74f + bbb69d3 commit 6962724
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
18 changes: 9 additions & 9 deletions networks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,16 @@ goerli:
polygon:
network: matic
graft:
# GyroEV2 startBlock
block: 41209677
# Dec-08-2023 03:23:50 PM +UTC
block: 50895000
# this will be the base of the unpruned deployment, so make sure it has not been pruned
# it should be possible to run time travel queries on it going back to the vault's startBlock
base: QmV7rtPzCPSkn3JfjVe7cRHxJxwZzdFC1tb6r9AFzcNPzv
base: QmNpJAfmVFM8hUzNvfn2GHoAbEqHjsvThwcAtjEEt7QjTF
graft_pruned:
# GyroEV2 startBlock
block: 41209677
# Dec-08-2023 03:23:50 PM +UTC
block: 50895000
# this will be the base of the pruned deployment, so it is ok if it is a pruned subgraph
base: QmV7rtPzCPSkn3JfjVe7cRHxJxwZzdFC1tb6r9AFzcNPzv
base: QmNpJAfmVFM8hUzNvfn2GHoAbEqHjsvThwcAtjEEt7QjTF
EventEmitter:
address: "0xcdcECFa416EE3022030E707dC3EA13a8997D74c8"
startBlock: 38152461
Expand Down Expand Up @@ -354,11 +354,11 @@ polygon:
arbitrum:
network: arbitrum-one
graft:
# GyroEV2 startBlock
block: 124858976
# Dec-08-2023 02:04:07 PM +UTC
block: 158100000
# always make sure the base subgraph has not been pruned
# it should be possible to run time travel queries on it going back to the vault's startBlock
base: Qma59fhnZU98BZ7T1duaMBdBXWB2AieadiBhaD2oMGmaJn
base: QmQ3C1UqrvqE6eDUcntbM4v2BqBhpJTbpcEoEjtjaTaoK5
EventEmitter:
address: "0x8f32D631093B5418d0546f77442c5fa66187E59D"
startBlock: 53475240
Expand Down
6 changes: 5 additions & 1 deletion src/mappings/helpers/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export namespace PoolType {
}

export function isVariableWeightPool(pool: Pool): boolean {
return pool.poolType == PoolType.LiquidityBootstrapping || pool.poolType == PoolType.Investment;
return (
pool.poolType == PoolType.LiquidityBootstrapping ||
pool.poolType == PoolType.Investment ||
pool.poolType == PoolType.Managed
);
}

export function hasVirtualSupply(pool: Pool): boolean {
Expand Down
14 changes: 11 additions & 3 deletions src/mappings/helpers/weighted.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address } from '@graphprotocol/graph-ts';
import { Address, Bytes } from '@graphprotocol/graph-ts';

import { Pool } from '../../types/schema';
import { WeightedPool } from '../../types/templates/WeightedPool/WeightedPool';
Expand All @@ -10,9 +10,17 @@ export function updatePoolWeights(poolId: string): void {
let pool = Pool.load(poolId);
if (pool == null) return;

let poolContract = WeightedPool.bind(changetype<Address>(pool.address));
const poolAddress = pool.address;
let poolContract = WeightedPool.bind(changetype<Address>(poolAddress));

let tokensList = new Array<Bytes>();
for (let i = 0; i < pool.tokensList.length; i++) {
let tokenAddress = pool.tokensList[i];
if (tokenAddress != poolAddress) {
tokensList.push(tokenAddress);
}
}

let tokensList = pool.tokensList;
let weightsCall = poolContract.try_getNormalizedWeights();
if (!weightsCall.reverted) {
let weights = weightsCall.value;
Expand Down

0 comments on commit 6962724

Please sign in to comment.