Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pricing revamp #180

Merged
merged 21 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions modules/actions/pool/update-on-chain-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,11 @@ export async function updateOnChainDataForPools(
balanceUSD:
poolToken.address === pool.address
? 0
: tokenService.getPriceForToken(tokenPricesForCurrentChain, poolToken.address) *
parseFloat(balance),
: tokenService.getPriceForToken(
tokenPricesForCurrentChain,
poolToken.address,
chain,
) * parseFloat(balance),
},
}),
);
Expand Down
2 changes: 1 addition & 1 deletion modules/beets/beets.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class BeetsService {

public async getBeetsPrice(): Promise<string> {
const tokenPrices = await tokenService.getTokenPrices();
return tokenService.getPriceForToken(tokenPrices, networkContext.data.beets!.address).toString();
return tokenService.getPriceForToken(tokenPrices, networkContext.data.beets!.address, 'FANTOM').toString();
}
}

Expand Down
12 changes: 0 additions & 12 deletions modules/coingecko/coingecko-types.ts

This file was deleted.

247 changes: 0 additions & 247 deletions modules/coingecko/coingecko.service.ts

This file was deleted.

8 changes: 8 additions & 0 deletions modules/common/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,11 @@ export function timestampRoundedUpToNearestHour(m: moment.Moment = moment()): nu

return roundUp.unix();
}

export function timestampTopOfTheHour(): number {
return moment().utc().endOf('hour').unix() + 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why +1? btw. is this fn used somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's to get the top of the hour timestamp. End of hour gives you 1s before that.

And no, not used anymore.

}

export function timestampEndOfDayMidnight(): number {
return moment().utc().endOf('day').unix() + 1;
}
10 changes: 6 additions & 4 deletions modules/datastudio/datastudio.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import { oneDayInSeconds, secondsPerDay } from '../common/time';
import { isComposableStablePool, isWeightedPoolV2 } from '../pool/lib/pool-utils';
import { networkContext } from '../network/network-context.service';
import { DeploymentEnv } from '../network/network-config-types';
import { Chain } from '@prisma/client';

export class DatastudioService {
constructor(private readonly secretsManager: SecretsManager, private readonly jwtClientHelper: GoogleJwtClient) {}

public async feedPoolData() {
public async feedPoolData(chain: Chain) {
const privateKey = await this.secretsManager.getSecret('backend-v3-datafeed-privatekey');
const jwtClient = await this.jwtClientHelper.getAuthorizedSheetsClient(privateKey);

Expand Down Expand Up @@ -89,7 +90,7 @@ export class DatastudioService {
dynamicData: {
totalLiquidity: { gte: 5000 },
},
chain: networkContext.chain,
chain: chain,
},
include: {
dynamicData: true,
Expand Down Expand Up @@ -265,7 +266,8 @@ export class DatastudioService {
}
const rewardsPerDay = parseFloat(rewarder.rewardPerSecond) * secondsPerDay;
const rewardsValuePerDay =
tokenService.getPriceForToken(tokenPrices, rewarder.tokenAddress) * rewardsPerDay;
tokenService.getPriceForToken(tokenPrices, rewarder.tokenAddress, chain) *
rewardsPerDay;
if (rewardsPerDay > 0) {
allEmissionDataRows.push([
endOfYesterday.format('DD MMM YYYY'),
Expand Down Expand Up @@ -309,7 +311,7 @@ export class DatastudioService {
}
const rewardsPerDay = parseFloat(reward.rewardPerSecond) * secondsPerDay;
const rewardsValuePerDay =
tokenService.getPriceForToken(tokenPrices, reward.tokenAddress) * rewardsPerDay;
tokenService.getPriceForToken(tokenPrices, reward.tokenAddress, chain) * rewardsPerDay;
if (rewardsPerDay > 0) {
allEmissionDataRows.push([
endOfYesterday.format('DD MMM YYYY'),
Expand Down
11 changes: 0 additions & 11 deletions modules/network/arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@ import { BoostedPoolAprService } from '../pool/lib/apr-data-sources/boosted-pool
import { SwapFeeAprService } from '../pool/lib/apr-data-sources/swap-fee-apr.service';
import { GaugeAprService } from '../pool/lib/apr-data-sources/ve-bal-gauge-apr.service';
import { GaugeStakingService } from '../pool/lib/staking/gauge-staking.service';
import { BptPriceHandlerService } from '../token/lib/token-price-handlers/bpt-price-handler.service';
import { LinearWrappedTokenPriceHandlerService } from '../token/lib/token-price-handlers/linear-wrapped-token-price-handler.service';
import { SwapsPriceHandlerService } from '../token/lib/token-price-handlers/swaps-price-handler.service';
import { UserSyncGaugeBalanceService } from '../user/lib/user-sync-gauge-balance.service';
import { every } from '../../worker/intervals';
import { GithubContentService } from '../content/github-content.service';
import { gaugeSubgraphService } from '../subgraphs/gauge-subgraph/gauge-subgraph.service';
import { CoingeckoPriceHandlerService } from '../token/lib/token-price-handlers/coingecko-price-handler.service';
import { coingeckoService } from '../coingecko/coingecko.service';
import { YbTokensAprService } from '../pool/lib/apr-data-sources/yb-tokens-apr.service';
import { env } from '../../app/env';
import { BalancerSubgraphService } from '../subgraphs/balancer-subgraph/balancer-subgraph.service';
Expand Down Expand Up @@ -227,12 +222,6 @@ export const arbitrumNetworkConfig: NetworkConfig = {
new GaugeAprService(tokenService, [arbitrumNetworkData.bal!.address]),
],
poolStakingServices: [new GaugeStakingService(gaugeSubgraphService, arbitrumNetworkData.bal!.address)],
tokenPriceHandlers: [
new CoingeckoPriceHandlerService(coingeckoService),
new BptPriceHandlerService(),
new LinearWrappedTokenPriceHandlerService(),
new SwapsPriceHandlerService(),
],
userStakedBalanceServices: [new UserSyncGaugeBalanceService()],
services: {
balancerSubgraphService: new BalancerSubgraphService(
Expand Down
11 changes: 0 additions & 11 deletions modules/network/avalanche.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@ import { BoostedPoolAprService } from '../pool/lib/apr-data-sources/boosted-pool
import { SwapFeeAprService } from '../pool/lib/apr-data-sources/swap-fee-apr.service';
import { GaugeAprService } from '../pool/lib/apr-data-sources/ve-bal-gauge-apr.service';
import { GaugeStakingService } from '../pool/lib/staking/gauge-staking.service';
import { BptPriceHandlerService } from '../token/lib/token-price-handlers/bpt-price-handler.service';
import { LinearWrappedTokenPriceHandlerService } from '../token/lib/token-price-handlers/linear-wrapped-token-price-handler.service';
import { SwapsPriceHandlerService } from '../token/lib/token-price-handlers/swaps-price-handler.service';
import { UserSyncGaugeBalanceService } from '../user/lib/user-sync-gauge-balance.service';
import { every } from '../../worker/intervals';
import { GithubContentService } from '../content/github-content.service';
import { gaugeSubgraphService } from '../subgraphs/gauge-subgraph/gauge-subgraph.service';
import { coingeckoService } from '../coingecko/coingecko.service';
import { CoingeckoPriceHandlerService } from '../token/lib/token-price-handlers/coingecko-price-handler.service';
import { env } from '../../app/env';
import { YbTokensAprService } from '../pool/lib/apr-data-sources/yb-tokens-apr.service';
import { BalancerSubgraphService } from '../subgraphs/balancer-subgraph/balancer-subgraph.service';
Expand Down Expand Up @@ -202,12 +197,6 @@ export const avalancheNetworkConfig: NetworkConfig = {
new GaugeAprService(tokenService, [avalancheNetworkData.bal!.address]),
],
poolStakingServices: [new GaugeStakingService(gaugeSubgraphService, avalancheNetworkData.bal!.address)],
tokenPriceHandlers: [
new CoingeckoPriceHandlerService(coingeckoService),
new BptPriceHandlerService(),
new LinearWrappedTokenPriceHandlerService(),
new SwapsPriceHandlerService(),
],
userStakedBalanceServices: [new UserSyncGaugeBalanceService()],
services: {
balancerSubgraphService: new BalancerSubgraphService(
Expand Down
Loading
Loading