-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
modules/pool/lib/apr-data-sources/fantom/beetswars-gauge-voting-apr.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { PoolAprService } from '../../../pool-types'; | ||
import { PrismaPoolWithTokens } from '../../../../../prisma/prisma-types'; | ||
import axios from 'axios'; | ||
import { prisma } from '../../../../../prisma/prisma-client'; | ||
import { networkContext } from '../../../../network/network-context.service'; | ||
import { PrismaPoolAprType } from '@prisma/client'; | ||
|
||
export class BeetswarsGaugeVotingAprService implements PoolAprService { | ||
private readonly FRESH_BEETS_POOL_ID = '0x9e4341acef4147196e99d648c5e43b3fc9d026780002000000000000000005ec'; | ||
|
||
public getAprServiceName(): string { | ||
return 'BeetswarsGaugeVotingAprService'; | ||
} | ||
|
||
public async updateAprForPools(pools: PrismaPoolWithTokens[]): Promise<void> { | ||
if (pools.map((pool) => pool.id).includes(this.FRESH_BEETS_POOL_ID)) { | ||
const response = await axios.get('https://www.beetswars.live/api/trpc/chart.chartdata'); | ||
|
||
const votingAprs: number[] = response.data.result.data.json.chartdata.votingApr; | ||
|
||
const minApr = 0; | ||
const maxApr = votingAprs[votingAprs.length - 1]; | ||
const itemId = `${this.FRESH_BEETS_POOL_ID}-voting-apr`; | ||
|
||
await prisma.prismaPoolAprItem.upsert({ | ||
where: { id_chain: { id: itemId, chain: networkContext.chain } }, | ||
update: { | ||
range: { | ||
update: { min: minApr, max: maxApr }, | ||
}, | ||
}, | ||
create: { | ||
id: itemId, | ||
chain: networkContext.chain, | ||
poolId: this.FRESH_BEETS_POOL_ID, | ||
title: 'Voting APR', | ||
apr: 0, | ||
range: { | ||
create: { | ||
id: `${itemId}-range`, | ||
min: minApr, | ||
max: maxApr, | ||
}, | ||
}, | ||
type: PrismaPoolAprType.VOTING, | ||
group: null, | ||
}, | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20230918081047_add_voting_apr_type/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterEnum | ||
ALTER TYPE "PrismaPoolAprType" ADD VALUE 'VOTING'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters