Skip to content

Commit

Permalink
Merge branch 'v3-canary' into feat/precompute-nliq
Browse files Browse the repository at this point in the history
  • Loading branch information
franzns committed Feb 8, 2024
2 parents 33918d8 + a89614a commit fa8da9d
Show file tree
Hide file tree
Showing 27 changed files with 230 additions and 529 deletions.
8 changes: 4 additions & 4 deletions modules/content/github-content.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { prisma } from '../../prisma/prisma-client';
import { networkContext } from '../network/network-context.service';
import { ContentService, FeaturedPool, HomeScreenFeaturedPoolGroup, HomeScreenNewsItem } from './content-types';
import { chainIdToChain } from '../network/network-config';
import { LinearData } from '../pool/subgraph-mapper';

const POOLS_METADATA_URL = 'https://raw.githubusercontent.com/balancer/metadata/main/pools/featured.json';

Expand Down Expand Up @@ -116,8 +117,8 @@ export class GithubContentService implements ContentService {
symbol: true,
name: true,
type: true,
typeData: true,
tokens: { orderBy: { index: 'asc' } },
linearData: true,
},
});
const tokens = await prisma.prismaToken.findMany({
Expand Down Expand Up @@ -151,9 +152,8 @@ export class GithubContentService implements ContentService {
});
}

const wrappedLinearPoolToken = pools.find(
(pool) => pool.linearData && pool.tokens[pool.linearData.wrappedIndex]?.address === token.address,
);
const wrappedIndex = (pool?.typeData as LinearData).wrappedIndex;
const wrappedLinearPoolToken = pools.find((pool) => pool.tokens[wrappedIndex]?.address === token.address);

if (wrappedLinearPoolToken && !tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) {
types.push({
Expand Down
8 changes: 4 additions & 4 deletions modules/content/sanity-content.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import SanityClient from '@sanity/client';
import { env } from '../../app/env';
import { chainToIdMap } from '../network/network-config';
import { wrap } from 'module';
import { LinearData } from '../pool/subgraph-mapper';

interface SanityToken {
name: string;
Expand Down Expand Up @@ -185,9 +186,8 @@ export class SanityContentService implements ContentService {
});
}

const wrappedLinearPoolToken = pools.find(
(pool) => pool.linearData && pool.tokens[pool.linearData.wrappedIndex].address === token.address,
);
const wrappedIndex = (pool?.typeData as LinearData).wrappedIndex;
const wrappedLinearPoolToken = pools.find((pool) => pool.tokens[wrappedIndex]?.address === token.address);

if (wrappedLinearPoolToken && !tokenTypes.includes('LINEAR_WRAPPED_TOKEN')) {
types.push({
Expand Down Expand Up @@ -216,8 +216,8 @@ export class SanityContentService implements ContentService {
symbol: true,
name: true,
type: true,
typeData: true,
tokens: { orderBy: { index: 'asc' } },
linearData: true,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { prisma } from '../../../../../prisma/prisma-client';
import { TokenService } from '../../../../token/token.service';
import { networkContext } from '../../../../network/network-context.service';
import { liquidStakedBaseAprService } from '../liquid-staked-base-apr.service';
import { LinearData } from '../../../subgraph-mapper';

const BOO_TOKEN_ADDRESS = '0x841FAD6EAe12c286d1Fd18d1d525DFfA75C7EFFE'.toLowerCase();

Expand All @@ -23,7 +24,6 @@ export class SpookySwapAprService implements PoolAprService {
where: { chain: networkContext.chain, id: { in: pools.map((pool) => pool.id) } },
include: {
dynamicData: true,
linearData: true,
tokens: {
orderBy: { index: 'asc' },
include: {
Expand All @@ -38,14 +38,14 @@ export class SpookySwapAprService implements PoolAprService {

for (const pool of expandedSpookyPools) {
if (
!pool.linearData ||
!(pool.typeData as LinearData) ||
!pool.dynamicData ||
pool.tokens[pool.linearData.mainIndex].address !== this.booAddress
pool.tokens[(pool.typeData as LinearData).mainIndex].address !== this.booAddress
) {
continue;
}

const linearData = pool.linearData;
const linearData = pool.typeData as LinearData;
const wrappedToken = pool.tokens[linearData.wrappedIndex];
const tokenPrice = this.tokenService.getPriceForToken(tokenPrices, this.booAddress);
const wrappedTokens = parseFloat(wrappedToken.dynamicData?.balance || '0');
Expand Down
2 changes: 1 addition & 1 deletion modules/pool/lib/apr-data-sources/yb-tokens-apr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PoolAprService } from '../../pool-types';
import { PrismaPoolWithTokens } from '../../../../prisma/prisma-types';
import { prisma } from '../../../../prisma/prisma-client';
import { prismaBulkExecuteOperations } from '../../../../prisma/prisma-util';
import { Chain, PrismaPoolAprItemGroup, PrismaPoolAprType, PrismaPoolLinearData } from '@prisma/client';
import { Chain, PrismaPoolAprItemGroup, PrismaPoolAprType } from '@prisma/client';
import { YbAprHandlers, TokenApr } from './yb-apr-handlers';
import { tokenService } from '../../../token/token.service';
import { collectsYieldFee } from '../pool-utils';
Expand Down
16 changes: 0 additions & 16 deletions modules/pool/lib/pool-creator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,22 +250,6 @@ export class PoolCreatorService {
})),
});

// TODO: It's just a quick fix. Remove after merging json column replacement for tables
if (pool.poolType!.includes('Gyro')) {
await prisma.prismaPoolGyroData.upsert({
where: { poolId_chain: { poolId: pool.id, chain: this.chain } },
create: {
id: pool.id,
poolId: pool.id,
chain: this.chain,
...(poolWithoutTokens.gyroData!.update || {}),
},
update: {
...(poolWithoutTokens.gyroData!.update || {}),
},
});
}

await prisma.prismaPool.update({
data: poolWithoutTokens,
where: {
Expand Down
Loading

0 comments on commit fa8da9d

Please sign in to comment.