Skip to content

Commit 1b9df4f

Browse files
committed
fix handling preferred gauge APRs
1 parent 97b769a commit 1b9df4f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

.changeset/purple-files-call.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'backend': patch
3+
---
4+
5+
fix handling preferred gauge APRs

modules/aprs/examples/integration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { AprService } from '../';
22
import { Chain } from '@prisma/client';
33

44
async function calculationExample(
5-
chain: Chain = 'MAINNET',
6-
poolId = '0x3de27efa2f1aa663ae5d458857e731c129069f29000200000000000000000588',
5+
chain: Chain = 'POLYGON',
6+
poolId = '0xe2f706ef1f7240b803aae877c9c762644bb808d80002000000000000000008c2',
77
) {
88
const service = new AprService();
99

modules/aprs/handlers/liquidity-gauge-apr/liquidity-gauge-apr-handler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export class LiquidityGaugeAprHandler implements AprHandler {
3131
const aprItems: Omit<PrismaPoolAprItem, 'createdAt' | 'updatedAt'>[] = [];
3232

3333
for (const pool of pools) {
34-
const gauge = pool.staking.find((s) => s.type === 'GAUGE')?.gauge;
34+
const gauges = pool.staking.filter((s) => s.type === 'GAUGE').map((s) => s.gauge);
35+
const gauge = gauges.sort((a, b) => (a?.status === 'PREFERRED' ? -1 : 1))[0];
3536

3637
if (!gauge || !gauge.rewards || !pool.dynamicData || pool.dynamicData.totalShares === '0') {
3738
continue;

0 commit comments

Comments
 (0)