Skip to content

Commit

Permalink
nil pointer error
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Jun 20, 2023
1 parent bba673d commit 42a2e17
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions x/pool-incentives/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,41 +160,44 @@ func (q Querier) IncentivizedPools(ctx context.Context, _ *types.QueryIncentiviz
}
}

// Retrieve the migration records between balancer pools and concentrated liquidity pools.
// This comes from the superfluid keeper, since superfluid is the only pool incentives connected
// module that has access to the gamm modules store.
migrationRecords, err := q.superfluidKeeper.GetAllMigrationInfo(sdkCtx)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

// Iterate over all migration records.
for _, record := range migrationRecords.BalancerToConcentratedPoolLinks {
// If the cl pool is not in the list of incentivized pools, skip it.
_, incentivized := incentivizedPoolIDs[record.ClPoolId]
if !incentivized {
continue
// Only run the following if the above loop determined there were incentivized pools.
if len(incentivizedPoolIDs) > 0 {
// Retrieve the migration records between balancer pools and concentrated liquidity pools.
// This comes from the superfluid keeper, since superfluid is the only pool incentives connected
// module that has access to the gamm modules store.
migrationRecords, err := q.superfluidKeeper.GetAllMigrationInfo(sdkCtx)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

// Determine the duration of the incentivized pool.
duration := lockableDurations[0]
for _, pool := range incentivizedPools {
if pool.PoolId == record.ClPoolId {
duration = pool.LockableDuration
break
// Iterate over all migration records.
for _, record := range migrationRecords.BalancerToConcentratedPoolLinks {
// If the cl pool is not in the list of incentivized pools, skip it.
_, incentivized := incentivizedPoolIDs[record.ClPoolId]
if !incentivized {
continue
}
}

// Add the indirectly incentivized balancer pools to the list of incentivized pools.
gaugeId, err := q.Keeper.GetPoolGaugeId(sdkCtx, record.BalancerPoolId, duration)
if err == nil {
incentivizedPool := types.IncentivizedPool{
PoolId: record.BalancerPoolId,
LockableDuration: duration,
GaugeId: gaugeId,
// Determine the duration of the incentivized pool.
duration := lockableDurations[0]
for _, pool := range incentivizedPools {
if pool.PoolId == record.ClPoolId {
duration = pool.LockableDuration
break
}
}

incentivizedPools = append(incentivizedPools, incentivizedPool)
// Add the indirectly incentivized balancer pools to the list of incentivized pools.
gaugeId, err := q.Keeper.GetPoolGaugeId(sdkCtx, record.BalancerPoolId, duration)
if err == nil {
incentivizedPool := types.IncentivizedPool{
PoolId: record.BalancerPoolId,
LockableDuration: duration,
GaugeId: gaugeId,
}

incentivizedPools = append(incentivizedPools, incentivizedPool)
}
}
}

Expand Down

0 comments on commit 42a2e17

Please sign in to comment.