Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gmbronco committed Sep 22, 2023
1 parent 16219b6 commit d2de85d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
8 changes: 5 additions & 3 deletions modules/pool/lib/apr-data-sources/ve-bal-gauge-apr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class GaugeAprService implements PoolAprService {
return 'GaugeAprService';
}

public async updateAprForPools(pools: PrismaPoolWithTokens[]): Promise<void> {
public async updateAprForPools(pools: { id: string }[]): Promise<void> {
const operations: any[] = [];

// Get the data
Expand Down Expand Up @@ -114,11 +114,13 @@ export class GaugeAprService implements PoolAprService {
(networkContext.chain === 'MAINNET' || gauge.version === 2)
) {
let minApr = 0;
if (rewardPerYear > 0 && workingSupplyTvl > 0) {
if (networkContext.chain === 'MAINNET' && workingSupplyTvl > 0) {
minApr = rewardPerYear / workingSupplyTvl;
} else if (gaugeTvl > 0) {
minApr = rewardPerYear / gaugeTvl;
}

const aprRangeId = `${pool.id}-${symbol}-apr-range`;
const aprRangeId = `${itemData.id}-range`;

const rangeData = {
id: aprRangeId,
Expand Down
14 changes: 7 additions & 7 deletions modules/pool/lib/staking/gauge-staking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ export class GaugeStakingService implements PoolStakingService {
]);
}

async syncStakingForPools(): Promise<void> {
async syncStakingForPools(pools?: { id: string }[]): Promise<void> {
// Getting data from the DB and subgraph
const pools = await prisma.prismaPool.findMany({
const poolIds = (pools ?? await prisma.prismaPool.findMany({
select: { id: true },
where: { chain: networkContext.chain },
});
const poolIds = pools.map((pool) => pool.id);
})).map((pool) => pool.id);
const { pools: subgraphPoolsWithGauges } = await this.gaugeSubgraphService.getPoolsWithGauges(poolIds);

const subgraphGauges = subgraphPoolsWithGauges
Expand Down Expand Up @@ -158,14 +158,14 @@ export class GaugeStakingService implements PoolStakingService {
chain: networkContext.chain,
status: gauge.status,
version: gauge.version,
workingSupply: onchainRates.find(({ id }) => `${this.balAddress}-${gauge.id}` === id)
workingSupply: onchainRates.find(({ id }) => `${gauge.id}-${this.balAddress}` === id)
?.workingSupply,
totalSupply: onchainRates.find(({ id }) => id.includes(gauge.id))?.totalSupply,
},
update: {
status: gauge.status,
version: gauge.version,
workingSupply: onchainRates.find(({ id }) => `${this.balAddress}-${gauge.id}` === id)
workingSupply: onchainRates.find(({ id }) => `${gauge.id}-${this.balAddress}` === id)
?.workingSupply,
totalSupply: onchainRates.find(({ id }) => id.includes(gauge.id))?.totalSupply,
},
Expand Down Expand Up @@ -259,7 +259,7 @@ export class GaugeStakingService implements PoolStakingService {
// Format onchain rates for all the rewards
const onchainRates = [
...Object.keys(balData).map((gaugeAddress) => {
const id = `${gaugeAddress}-${this.balAddress}-`.toLowerCase();
const id = `${gaugeAddress}-${this.balAddress}`.toLowerCase();
const { rate, weight, workingSupply, totalSupply } = balData[gaugeAddress];
const rewardPerSecond = rate
? formatUnits(rate) // L2 V2 case
Expand Down

0 comments on commit d2de85d

Please sign in to comment.