diff --git a/CHANGELOG.md b/CHANGELOG.md index d72987798..3e2cc3ef7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # backend +## 1.56.1 + +### Patch Changes + +- 2a2ea8a: SOR - Fix unwrapRates scaling +- 4c84676: move pricing query to graphql +- f9a6468: pricing query cleanup +- 36aa8c9: add xlayer support + ## 1.56.0 ### Minor Changes diff --git a/apps/api/gql/generated-schema-ast.ts b/apps/api/gql/generated-schema-ast.ts index 44cac00ad..2951b63d5 100644 --- a/apps/api/gql/generated-schema-ast.ts +++ b/apps/api/gql/generated-schema-ast.ts @@ -115,6 +115,7 @@ export const schema = gql` POLYGON SEPOLIA SONIC + XLAYER ZKEVM } diff --git a/apps/api/gql/generated-schema.ts b/apps/api/gql/generated-schema.ts index 9db5a390d..366053810 100644 --- a/apps/api/gql/generated-schema.ts +++ b/apps/api/gql/generated-schema.ts @@ -109,6 +109,7 @@ export type GqlChain = | 'POLYGON' | 'SEPOLIA' | 'SONIC' + | 'XLAYER' | 'ZKEVM'; export interface GqlFeaturePoolGroupItemExternalLink { diff --git a/apps/api/gql/schema/__mocks__/types.ts b/apps/api/gql/schema/__mocks__/types.ts index f179b71a7..22378a0a1 100644 --- a/apps/api/gql/schema/__mocks__/types.ts +++ b/apps/api/gql/schema/__mocks__/types.ts @@ -100,6 +100,7 @@ export enum GqlChain { POLYGON = 'POLYGON', SEPOLIA = 'SEPOLIA', SONIC = 'SONIC', + XLAYER = 'XLAYER', ZKEVM = 'ZKEVM', } diff --git a/apps/api/gql/schema/base.gql b/apps/api/gql/schema/base.gql index 7b35e2cbd..aa4cf232d 100644 --- a/apps/api/gql/schema/base.gql +++ b/apps/api/gql/schema/base.gql @@ -17,4 +17,5 @@ enum GqlChain { FRAXTAL MODE SONIC + XLAYER } diff --git a/apps/api/rest-routes.ts b/apps/api/rest-routes.ts index 5aaeaa810..875b5f9cc 100644 --- a/apps/api/rest-routes.ts +++ b/apps/api/rest-routes.ts @@ -4,13 +4,6 @@ import { beetsGetCirculatingSupplySonic, beetsGetTotalSupplySonic, } from '../../modules/beets/lib/beets'; -import { latestTokenPrice } from '../../modules/token/latest-token-price'; -import config from '../../config'; -import { Chain } from '@prisma/client'; -import * as crypto from 'crypto'; - -const isHexAddress = (addr: any) => - typeof addr === 'string' && addr.length === 42 && addr.startsWith('0x') && /^[0-9a-f]{40}$/i.test(addr.slice(2)); export function loadRestRoutes(app: Express) { app.use('/health', (_, res) => res.sendStatus(200)); @@ -29,48 +22,4 @@ export function loadRestRoutes(app: Express) { res.send(result); }); }); - - app.get('/price', async (req, res) => { - res.type('application/json'); - - const chain = req.query.chain; - const tokens = req.query.tokens && (req.query.tokens as string).split(','); - - // Validate params - if (typeof chain !== 'string' || !(chain in config)) { - res.status(400).end(); - return; - } - - if (!Array.isArray(tokens) || tokens.length === 0 || !tokens.every(isHexAddress) || tokens.length > 8) { - res.status(400).end(); - return; - } - - const prices = await latestTokenPrice(chain as Chain, tokens as string[]); - - // Build response body - const responseBody = { prices }; - const bodyString = JSON.stringify(responseBody); - - // Generate strong ETag: MD5 hash of the body (fast for small JSON) - const etag = crypto.createHash('md5').update(bodyString).digest('hex'); - - // Set ETag header - res.set('ETag', `"${etag}"`); - - // Check for conditional request - const clientEtag = req.get('If-None-Match'); - if (clientEtag === `"${etag}"` || clientEtag === etag) { - // Handle quoted/unquoted client headers - res.status(304).end(); // Not modified: No body needed - return; - } - - // Set caching headers (unchanged) - res.set('Cache-Control', 'public, max-age=600, s-maxage=600, stale-while-revalidate=30, stale-if-error=86400'); - - // Send full response - res.send(responseBody); - }); } diff --git a/bun.lockb b/bun.lockb index 52c6a107a..8a04b0e9a 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/config/index.ts b/config/index.ts index 6628335ff..47768bd1a 100644 --- a/config/index.ts +++ b/config/index.ts @@ -14,6 +14,7 @@ import modeConfig from './mode'; import sonicConfig from './sonic'; import hyperevmConfig from './hyperevm'; import plasmaNetworkConfig from './plasma'; +import xlayerNetworkConfig from './xlayer'; export const DAYS_OF_HOURLY_PRICES = 100; export const BALANCES_SYNC_BLOCKS_MARGIN = 200; @@ -34,4 +35,5 @@ export default { [Chain.SONIC]: sonicConfig, [Chain.HYPEREVM]: hyperevmConfig, [Chain.PLASMA]: plasmaNetworkConfig, + [Chain.XLAYER]: xlayerNetworkConfig, }; diff --git a/config/plasma.ts b/config/plasma.ts index c825b45a4..4bb36e207 100644 --- a/config/plasma.ts +++ b/config/plasma.ts @@ -50,7 +50,7 @@ export default { v3: { vaultAddress: '0xba1333333333a1ba1108e8412f11850a5c319ba9', protocolFeeController: '0xcacc7e1efeea8bb3af6d5720d12c1876aa6ee76b', - routerAddress: '0xa8920455934da4d853faac1f94fe7bef72943ef1', + routerAddress: '0x9da18982a33fd0c7051b19f0d7c76f2d5e7e017c', defaultSwapFeePercentage: '0.5', defaultYieldFeePercentage: '0.1', }, diff --git a/config/sonic.ts b/config/sonic.ts index 5decc83ed..22c2cfaec 100644 --- a/config/sonic.ts +++ b/config/sonic.ts @@ -170,25 +170,6 @@ export default { { type: 'path', token: '0x871a101dcf22fe4fe37be7b654098c801cba1c88', path: '$.beefy-besonic' }, ], }, - { - url: 'https://api.goldsky.com/api/public/project_cmcccb4vz1nhh01x888di8lgk/subgraphs/mainstreet/0.0.1/gn', - body: JSON.stringify({ - query: `{ - smsUsdStats(id: "statsSmsUsd") { - apy - } - }`, - }), - headers: { 'Content-Type': 'application/json' }, - scale: 100, - extractors: [ - { - type: 'path', - token: '0xc7990369da608c2f4903715e3bd22f2970536c29', - path: '$.data.smsUsdStats.apy', - }, - ], - }, { url: 'https://yields.llama.fi/chart/104b3467-bba3-4923-851d-aa9e6ff47611', scale: 100, @@ -201,7 +182,7 @@ export default { ], }, { - url: 'https://api.originprotocol.com/api/v2/os/apr/trailing/7?146', + url: 'https://api.originprotocol.com/api/v2/os/apr/trailing/7', scale: 100, extractors: [{ type: 'path', token: '0x9f0df7799f6fdad409300080cff680f5a23df4b1', path: '$.apr' }], }, diff --git a/config/xlayer.ts b/config/xlayer.ts new file mode 100644 index 000000000..6c3251e0e --- /dev/null +++ b/config/xlayer.ts @@ -0,0 +1,70 @@ +import { AaveV3Plasma } from '@bgd-labs/aave-address-book'; +import { env } from '../apps/env'; +import { NetworkData } from '../modules/network/network-config-types'; + +export default { + chain: { + slug: 'xlayer', + id: 196, + nativeAssetAddress: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', + wrappedNativeAssetAddress: '0xe538905cf8410324e03a5a23c1c177a474d59b2b', + prismaId: 'XLAYER', + gqlId: 'XLAYER', + }, + subgraphs: { + startDate: '2025-10-30', + balancer: ``, + balancerV3: `https://gateway.thegraph.com/api/${env.THEGRAPH_API_KEY_BALANCER}/deployments/id/QmX8LawQrPRVywFnjwZG57MomECJRZDw4nNBvwdEHJ3dS3`, + balancerPoolsV3: `https://gateway.thegraph.com/api/${env.THEGRAPH_API_KEY_BALANCER}/deployments/id/QmQp8YimZAcJTYTv8EASHC4b83U773pWnU9vDxWheDMM78`, + gauge: ``, + }, + hooks: { + ['0xa523f47a933d5020b23629ddf689695aa94612dc']: 'STABLE_SURGE', + }, + eth: { + address: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', + addressFormatted: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', + symbol: 'OKB', + name: 'OKB', + }, + weth: { + address: '0xe538905cf8410324e03a5a23c1c177a474d59b2b', + addressFormatted: '0xe538905cf8410324e03A5A23C1c177a474D59b2b', + }, + coingecko: { + nativeAssetId: 'okb', + platformId: 'x-layer', + excludedTokenAddresses: [], + }, + rpcUrl: env.DRPC_API_KEY ? `https://lb.drpc.live/xlayer/${env.DRPC_API_KEY}` : 'https://rpc.xlayer.tech', + rpcMaxBlockRange: 1000, + acceptableSGLag: 30, // ~1min + protocolToken: 'bal', + balancer: { + v2: { + vaultAddress: '', + defaultSwapFeePercentage: '0.5', + defaultYieldFeePercentage: '0.5', + balancerQueriesAddress: '', + }, + v3: { + vaultAddress: '0xba1333333333a1ba1108e8412f11850a5c319ba9', + protocolFeeController: '0xcacc7e1efeea8bb3af6d5720d12c1876aa6ee76b', + routerAddress: '0xc3ccace87f6d3a81724075adcb5ddd85a8a1bb68', + defaultSwapFeePercentage: '0.5', + defaultYieldFeePercentage: '0.1', + }, + }, + aprHandlers: {}, + multicall: '0xca11bde05977b3631167028862be2a173976ca11', + multicall3: '0xca11bde05977b3631167028862be2a173976ca11', + avgBlockSpeed: 1, + monitoring: { + main: { + alarmTopicArn: 'arn:aws:sns:ca-central-1:118697801881:api_alarms', + }, + canary: { + alarmTopicArn: 'arn:aws:sns:eu-central-1:118697801881:api_alarms', + }, + }, +}; diff --git a/modules/network/chain-id-to-chain.ts b/modules/network/chain-id-to-chain.ts index ec0095a4a..ab29011e6 100644 --- a/modules/network/chain-id-to-chain.ts +++ b/modules/network/chain-id-to-chain.ts @@ -16,6 +16,7 @@ export const chainIdToChain: { [id: string]: Chain } = { '146': Chain.SONIC, '999': Chain.HYPEREVM, '9745': Chain.PLASMA, + '196': Chain.XLAYER, ...(env.DEPLOYMENT_ENV !== 'production' ? { '11155111': Chain.SEPOLIA } : {}), }; @@ -34,5 +35,6 @@ export const chainToChainId: { [chain: string]: string } = { SONIC: '146', HYPEREVM: '999', PLASMA: '9745', + XLAYER: '196', ...(env.DEPLOYMENT_ENV !== 'production' ? { SEPOLIA: '11155111' } : {}), }; diff --git a/modules/network/network-config.ts b/modules/network/network-config.ts index 7a80ae477..50fde8d84 100644 --- a/modules/network/network-config.ts +++ b/modules/network/network-config.ts @@ -15,6 +15,7 @@ import { modeNetworkConfig } from './mode'; import { sonicNetworkConfig } from './sonic'; import { hyperevmNetworkConfig } from './hyperevm'; import { plasmaNetworkConfig } from './plasma'; +import { xlayerNetworkConfig } from './xlayer'; export const AllNetworkConfigs: { [chainId: string]: NetworkConfig } = { '250': fantomNetworkConfig, @@ -32,6 +33,7 @@ export const AllNetworkConfigs: { [chainId: string]: NetworkConfig } = { '146': sonicNetworkConfig, '999': hyperevmNetworkConfig, '9745': plasmaNetworkConfig, + '196': xlayerNetworkConfig, }; export const AllNetworkConfigsKeyedOnChain: { [chain in Chain]: NetworkConfig } = { @@ -50,6 +52,7 @@ export const AllNetworkConfigsKeyedOnChain: { [chain in Chain]: NetworkConfig } SONIC: sonicNetworkConfig, HYPEREVM: hyperevmNetworkConfig, PLASMA: plasmaNetworkConfig, + XLAYER: xlayerNetworkConfig, }; export const BalancerChainIds = [ @@ -65,5 +68,6 @@ export const BalancerChainIds = [ '34443', '999', '9745', + '196', ]; export const BeethovenChainIds = ['250', '10', '146']; diff --git a/modules/network/xlayer.ts b/modules/network/xlayer.ts new file mode 100644 index 000000000..2a96b5d32 --- /dev/null +++ b/modules/network/xlayer.ts @@ -0,0 +1,76 @@ +import { ethers } from 'ethers'; +import { DeploymentEnv, NetworkConfig, NetworkData } from './network-config-types'; +import { every } from '../../apps/scheduler/intervals'; +import { env } from '../../apps/env'; +import { BalancerSubgraphService } from '../subgraphs/balancer-subgraph/balancer-subgraph.service'; +import config from '../../config'; + +const xlayerNetworkData: NetworkData = config.XLAYER; + +export const xlayerNetworkConfig: NetworkConfig = { + data: xlayerNetworkData, + provider: new ethers.providers.JsonRpcProvider({ url: xlayerNetworkData.rpcUrl, timeout: 60000 }), + userStakedBalanceServices: [], + services: { + balancerSubgraphService: new BalancerSubgraphService( + xlayerNetworkData.subgraphs.balancer, + xlayerNetworkData.chain.prismaId, + ), + }, + workerJobs: [ + { + name: 'update-liquidity-for-inactive-pools', + interval: every(10, 'minutes'), + }, + { + name: 'update-pool-apr', + interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(6, 'minutes') : every(2, 'minutes'), + }, + { + name: 'user-sync-wallet-balances-for-all-pools', + interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(5, 'minutes') : every(20, 'seconds'), + }, + { + name: 'update-fee-volume-yield-all-pools', + interval: every(10, 'minutes'), + }, + // V3 Jobs + { + name: 'add-pools-v3', + interval: every(30, 'seconds'), + }, + { + name: 'sync-pools-v3', + interval: every(30, 'seconds'), + }, + { + name: 'sync-join-exits-v3', + interval: every(1, 'minutes'), + }, + { + name: 'sync-swaps-v3', + interval: every(1, 'minutes'), + }, + { + name: 'sync-snapshots-v3', + interval: every(10, 'minutes'), + }, + { + name: 'forward-fill-snapshots-v3', + interval: every(1, 'hours'), + }, + + { + name: 'sync-hook-data', + interval: every(1, 'hours'), + }, + { + name: 'sync-erc4626-onchain-data', + interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(60, 'minutes') : every(20, 'minutes'), + }, + { + name: 'sync-lbps', + interval: every(1, 'minutes'), + }, + ], +}; diff --git a/modules/sor/utils/data.ts b/modules/sor/utils/data.ts index ac862b02d..b1a6eaab1 100644 --- a/modules/sor/utils/data.ts +++ b/modules/sor/utils/data.ts @@ -1,5 +1,5 @@ import { Cache } from 'memory-cache'; -import { Address, parseUnits } from 'viem'; +import { Address, parseEther, parseUnits } from 'viem'; import { Chain, PrismaPoolType, PrismaToken } from '@prisma/client'; import { prisma } from '../../../prisma/prisma-client'; @@ -253,7 +253,6 @@ export async function getBufferPoolsFromDBPools(pools: SORDbPool[], chain: Chain // check if underlying token exists in the database const underlyingToken = tokensMap[poolToken.token.underlyingTokenAddress]; if (underlyingToken) { - const unwrapRateDecimals = 18 - poolToken.token.decimals + underlyingToken.decimals; bufferPools.push({ poolId: pool.id, address: poolToken.address.toLowerCase() as Address, @@ -269,7 +268,7 @@ export async function getBufferPoolsFromDBPools(pools: SORDbPool[], chain: Chain balance: parseUnits(poolToken.token.bufferBalanceUnderlying, underlyingToken.decimals), }, poolType: 'Buffer', - unwrapRate: parseUnits(poolToken.token.unwrapRate, unwrapRateDecimals), + unwrapRate: parseEther(poolToken.token.unwrapRate), // the way we store rates already takes into account main/underlying decimals differences maxWithdraw: parseUnits(poolToken.token.maxWithdraw, poolToken.token.decimals), maxDeposit: parseUnits(poolToken.token.maxDeposit, poolToken.token.decimals), }); diff --git a/modules/sources/viem-client.ts b/modules/sources/viem-client.ts index 38ebbe684..e1eb8a764 100644 --- a/modules/sources/viem-client.ts +++ b/modules/sources/viem-client.ts @@ -14,6 +14,7 @@ import { mode, sonic, plasma, + xLayer, } from 'viem/chains'; import { Chain } from '@prisma/client'; import config from '../../config'; @@ -40,6 +41,7 @@ const chain2ViemChain = { [Chain.FRAXTAL]: fraxtal, [Chain.MODE]: mode, [Chain.SONIC]: sonic, + [Chain.XLAYER]: xLayer, [Chain.HYPEREVM]: defineChain({ id: 999, name: 'hyperevm', diff --git a/modules/subgraphs/balancer-subgraph/balancer-subgraph-queries.graphql b/modules/subgraphs/balancer-subgraph/balancer-subgraph-queries.graphql index 6b051ada9..7f15a9e3a 100644 --- a/modules/subgraphs/balancer-subgraph/balancer-subgraph-queries.graphql +++ b/modules/subgraphs/balancer-subgraph/balancer-subgraph-queries.graphql @@ -1,64 +1,3 @@ -query BalancerProtocolData( - $skip: Int - $first: Int - $orderBy: Balancer_orderBy - $orderDirection: OrderDirection - $where: Balancer_filter - $block: Block_height -) { - balancers( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - id - totalLiquidity - totalSwapVolume - totalSwapFee - poolCount - } -} - -query BalancerUser($id: ID!, $block: Block_height) { - user(id: $id, block: $block) { - ...BalancerUser - } -} - -query BalancerUsers( - $skip: Int - $first: Int - $orderBy: User_orderBy - $orderDirection: OrderDirection - $where: User_filter - $block: Block_height -) { - users( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerUser - } -} - -fragment BalancerUser on User { - id - sharesOwned(first: 1000) { - id - balance - poolId { - id - } - } -} - query BalancerPoolShares( $skip: Int $first: Int @@ -87,74 +26,6 @@ fragment BalancerPoolShare on PoolShare { } } -query BalancerTokenPrices( - $skip: Int - $first: Int - $orderBy: TokenPrice_orderBy - $orderDirection: OrderDirection - $where: TokenPrice_filter - $block: Block_height -) { - tokenPrices( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerTokenPrice - } -} - -fragment BalancerTokenPrice on TokenPrice { - id - poolId { - id - } - asset - amount - pricingAsset - price - block - timestamp -} - -query BalancerTokens( - $skip: Int - $first: Int - $orderBy: Token_orderBy - $orderDirection: OrderDirection - $where: Token_filter - $block: Block_height -) { - tokens( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerToken - } -} - -fragment BalancerToken on Token { - id - symbol - address - latestFXPrice - latestUSDPrice - totalVolumeNotional - totalVolumeUSD - totalSwapCount - latestPrice { - pricingAsset - price - } -} - fragment BalancerPool on Pool { id address @@ -258,34 +129,6 @@ query BalancerPool($id: ID!, $block: Block_height) { } } -query BalancerPoolHistoricalLiquidities( - $skip: Int - $first: Int - $orderBy: PoolHistoricalLiquidity_orderBy - $orderDirection: OrderDirection - $where: PoolHistoricalLiquidity_filter - $block: Block_height -) { - poolHistoricalLiquidities( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - id - poolId { - id - } - poolTotalShares - poolLiquidity - poolShareValue - pricingAsset - block - } -} - query BalancerPoolSnapshots( $skip: Int $first: Int @@ -321,32 +164,6 @@ fragment BalancerPoolSnapshot on PoolSnapshot { holdersCount } -query BalancerLatestPrices( - $skip: Int - $first: Int - $orderBy: LatestPrice_orderBy - $orderDirection: OrderDirection - $where: LatestPrice_filter - $block: Block_height -) { - latestPrices( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerLatestPrice - } -} - -query BalancerLatestPrice($id: ID!) { - latestPrice(id: $id) { - ...BalancerLatestPrice - } -} - query BalancerJoinExits( $skip: Int $first: Int @@ -367,17 +184,6 @@ query BalancerJoinExits( } } -fragment BalancerLatestPrice on LatestPrice { - id - asset - price - poolId { - id - } - pricingAsset - block -} - fragment BalancerJoinExit on JoinExit { amounts id @@ -393,62 +199,6 @@ fragment BalancerJoinExit on JoinExit { valueUSD } -query BalancerPortfolioData($id: ID!, $previousBlockNumber: Int!) { - user(id: $id) { - ...BalancerUser - } - previousUser: user(id: $id, block: { number: $previousBlockNumber }) { - ...BalancerUser - } -} - -query BalancerPortfolioPoolsData($previousBlockNumber: Int!) { - pools(first: 1000, where: { totalShares_gt: "0" }) { - ...BalancerPool - } - - previousPools: pools(first: 1000, where: { totalShares_gt: "0" }, block: { number: $previousBlockNumber }) { - ...BalancerPool - } -} - -query BalancerTradePairSnapshots( - $skip: Int - $first: Int - $orderBy: TradePairSnapshot_orderBy - $orderDirection: OrderDirection - $where: TradePairSnapshot_filter - $block: Block_height -) { - tradePairSnapshots( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerTradePairSnapshot - } -} - -fragment BalancerTradePairSnapshot on TradePairSnapshot { - id - totalSwapFee - totalSwapVolume - timestamp - pair { - token0 { - address - symbol - } - token1 { - address - symbol - } - } -} - query BalancerSwaps( $skip: Int $first: Int @@ -498,68 +248,6 @@ fragment BalancerSwap on Swap { block } -query BalancerAmpUpdates( - $skip: Int - $first: Int - $orderBy: AmpUpdate_orderBy - $orderDirection: OrderDirection - $where: AmpUpdate_filter - $block: Block_height -) { - ampUpdates( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerAmpUpdate - } -} - -fragment BalancerAmpUpdate on AmpUpdate { - id - poolId { - id - } - startAmp - endAmp - startTimestamp - endTimestamp -} - -query BalancerGradualWeightUpdates( - $skip: Int - $first: Int - $orderBy: GradualWeightUpdate_orderBy - $orderDirection: OrderDirection - $where: GradualWeightUpdate_filter - $block: Block_height -) { - gradualWeightUpdates( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerGradualWeightUpdate - } -} - -fragment BalancerGradualWeightUpdate on GradualWeightUpdate { - id - startTimestamp - endWeights - startWeights - endWeights - poolId { - id - } -} - query BalancerGetPoolsWithActiveUpdates($timestamp: BigInt!) { ampUpdates(where: { endTimestamp_gte: $timestamp }) { poolId { diff --git a/modules/subgraphs/balancer-subgraph/balancer-subgraph-types.ts b/modules/subgraphs/balancer-subgraph/balancer-subgraph-types.ts deleted file mode 100644 index 2231d57a0..000000000 --- a/modules/subgraphs/balancer-subgraph/balancer-subgraph-types.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface BalancerUserPoolShare { - id: string; - balance: string; - poolId: string; - poolAddress: string; - userAddress: string; -} diff --git a/modules/subgraphs/balancer-subgraph/generated/balancer-subgraph-types.ts b/modules/subgraphs/balancer-subgraph/generated/balancer-subgraph-types.ts index 72db09bfe..49a126fee 100644 --- a/modules/subgraphs/balancer-subgraph/generated/balancer-subgraph-types.ts +++ b/modules/subgraphs/balancer-subgraph/generated/balancer-subgraph-types.ts @@ -5388,6 +5388,7 @@ export type _Meta_ = { * will be null if the _meta field has a block constraint that asks for * a block number. It will be filled if the _meta field has no block constraint * and therefore asks for the latest block + * */ block: _Block_; /** The deployment ID */ @@ -5403,80 +5404,6 @@ export enum _SubgraphErrorPolicy_ { Deny = 'deny', } -export type BalancerProtocolDataQueryVariables = Exact<{ - skip?: InputMaybe; - first?: InputMaybe; - orderBy?: InputMaybe; - orderDirection?: InputMaybe; - where?: InputMaybe; - block?: InputMaybe; -}>; - -export type BalancerProtocolDataQuery = { - __typename?: 'Query'; - balancers: Array<{ - __typename?: 'Balancer'; - id: string; - totalLiquidity: string; - totalSwapVolume: string; - totalSwapFee: string; - poolCount: number; - }>; -}; - -export type BalancerUserQueryVariables = Exact<{ - id: Scalars['ID']; - block?: InputMaybe; -}>; - -export type BalancerUserQuery = { - __typename?: 'Query'; - user?: { - __typename?: 'User'; - id: string; - sharesOwned?: Array<{ - __typename?: 'PoolShare'; - id: string; - balance: string; - poolId: { __typename?: 'Pool'; id: string }; - }> | null; - } | null; -}; - -export type BalancerUsersQueryVariables = Exact<{ - skip?: InputMaybe; - first?: InputMaybe; - orderBy?: InputMaybe; - orderDirection?: InputMaybe; - where?: InputMaybe; - block?: InputMaybe; -}>; - -export type BalancerUsersQuery = { - __typename?: 'Query'; - users: Array<{ - __typename?: 'User'; - id: string; - sharesOwned?: Array<{ - __typename?: 'PoolShare'; - id: string; - balance: string; - poolId: { __typename?: 'Pool'; id: string }; - }> | null; - }>; -}; - -export type BalancerUserFragment = { - __typename?: 'User'; - id: string; - sharesOwned?: Array<{ - __typename?: 'PoolShare'; - id: string; - balance: string; - poolId: { __typename?: 'Pool'; id: string }; - }> | null; -}; - export type BalancerPoolSharesQueryVariables = Exact<{ skip?: InputMaybe; first?: InputMaybe; @@ -5503,80 +5430,6 @@ export type BalancerPoolShareFragment = { poolId: { __typename?: 'Pool'; id: string }; }; -export type BalancerTokenPricesQueryVariables = Exact<{ - skip?: InputMaybe; - first?: InputMaybe; - orderBy?: InputMaybe; - orderDirection?: InputMaybe; - where?: InputMaybe; - block?: InputMaybe; -}>; - -export type BalancerTokenPricesQuery = { - __typename?: 'Query'; - tokenPrices: Array<{ - __typename?: 'TokenPrice'; - id: string; - asset: string; - amount: string; - pricingAsset: string; - price: string; - block: string; - timestamp: number; - poolId: { __typename?: 'Pool'; id: string }; - }>; -}; - -export type BalancerTokenPriceFragment = { - __typename?: 'TokenPrice'; - id: string; - asset: string; - amount: string; - pricingAsset: string; - price: string; - block: string; - timestamp: number; - poolId: { __typename?: 'Pool'; id: string }; -}; - -export type BalancerTokensQueryVariables = Exact<{ - skip?: InputMaybe; - first?: InputMaybe; - orderBy?: InputMaybe; - orderDirection?: InputMaybe; - where?: InputMaybe; - block?: InputMaybe; -}>; - -export type BalancerTokensQuery = { - __typename?: 'Query'; - tokens: Array<{ - __typename?: 'Token'; - id: string; - symbol?: string | null; - address: string; - latestFXPrice?: string | null; - latestUSDPrice?: string | null; - totalVolumeNotional: string; - totalVolumeUSD: string; - totalSwapCount: string; - latestPrice?: { __typename?: 'LatestPrice'; pricingAsset: string; price: string } | null; - }>; -}; - -export type BalancerTokenFragment = { - __typename?: 'Token'; - id: string; - symbol?: string | null; - address: string; - latestFXPrice?: string | null; - latestUSDPrice?: string | null; - totalVolumeNotional: string; - totalVolumeUSD: string; - totalSwapCount: string; - latestPrice?: { __typename?: 'LatestPrice'; pricingAsset: string; price: string } | null; -}; - export type BalancerPoolFragment = { __typename?: 'Pool'; id: string; @@ -5822,29 +5675,6 @@ export type BalancerPoolQuery = { } | null; }; -export type BalancerPoolHistoricalLiquiditiesQueryVariables = Exact<{ - skip?: InputMaybe; - first?: InputMaybe; - orderBy?: InputMaybe; - orderDirection?: InputMaybe; - where?: InputMaybe; - block?: InputMaybe; -}>; - -export type BalancerPoolHistoricalLiquiditiesQuery = { - __typename?: 'Query'; - poolHistoricalLiquidities: Array<{ - __typename?: 'PoolHistoricalLiquidity'; - id: string; - poolTotalShares: string; - poolLiquidity: string; - poolShareValue: string; - pricingAsset: string; - block: string; - poolId: { __typename?: 'Pool'; id: string }; - }>; -}; - export type BalancerPoolSnapshotsQueryVariables = Exact<{ skip?: InputMaybe; first?: InputMaybe; @@ -5885,45 +5715,6 @@ export type BalancerPoolSnapshotFragment = { pool: { __typename?: 'Pool'; id: string }; }; -export type BalancerLatestPricesQueryVariables = Exact<{ - skip?: InputMaybe; - first?: InputMaybe; - orderBy?: InputMaybe; - orderDirection?: InputMaybe; - where?: InputMaybe; - block?: InputMaybe; -}>; - -export type BalancerLatestPricesQuery = { - __typename?: 'Query'; - latestPrices: Array<{ - __typename?: 'LatestPrice'; - id: string; - asset: string; - price: string; - pricingAsset: string; - block: string; - poolId: { __typename?: 'Pool'; id: string }; - }>; -}; - -export type BalancerLatestPriceQueryVariables = Exact<{ - id: Scalars['ID']; -}>; - -export type BalancerLatestPriceQuery = { - __typename?: 'Query'; - latestPrice?: { - __typename?: 'LatestPrice'; - id: string; - asset: string; - price: string; - pricingAsset: string; - block: string; - poolId: { __typename?: 'Pool'; id: string }; - } | null; -}; - export type BalancerJoinExitsQueryVariables = Exact<{ skip?: InputMaybe; first?: InputMaybe; @@ -5949,16 +5740,6 @@ export type BalancerJoinExitsQuery = { }>; }; -export type BalancerLatestPriceFragment = { - __typename?: 'LatestPrice'; - id: string; - asset: string; - price: string; - pricingAsset: string; - block: string; - poolId: { __typename?: 'Pool'; id: string }; -}; - export type BalancerJoinExitFragment = { __typename?: 'JoinExit'; amounts: Array; @@ -5972,421 +5753,134 @@ export type BalancerJoinExitFragment = { pool: { __typename?: 'Pool'; id: string; tokensList: Array }; }; -export type BalancerPortfolioDataQueryVariables = Exact<{ - id: Scalars['ID']; - previousBlockNumber: Scalars['Int']; +export type BalancerSwapsQueryVariables = Exact<{ + skip?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + where?: InputMaybe; + block?: InputMaybe; }>; -export type BalancerPortfolioDataQuery = { +export type BalancerSwapsQuery = { __typename?: 'Query'; - user?: { - __typename?: 'User'; + swaps: Array<{ + __typename?: 'Swap'; id: string; - sharesOwned?: Array<{ - __typename?: 'PoolShare'; + caller: string; + tokenIn: string; + tokenInSym: string; + tokenOut: string; + tokenOutSym: string; + tokenAmountIn: string; + tokenAmountOut: string; + timestamp: number; + tx: string; + valueUSD: string; + block?: string | null; + poolId: { + __typename?: 'Pool'; id: string; - balance: string; - poolId: { __typename?: 'Pool'; id: string }; - }> | null; - } | null; - previousUser?: { - __typename?: 'User'; + swapFee: string; + poolType?: string | null; + tokens?: Array<{ + __typename?: 'PoolToken'; + token: { __typename?: 'Token'; address: string; latestFXPrice?: string | null }; + }> | null; + }; + userAddress: { __typename?: 'User'; id: string }; + }>; +}; + +export type BalancerSwapFragment = { + __typename?: 'Swap'; + id: string; + caller: string; + tokenIn: string; + tokenInSym: string; + tokenOut: string; + tokenOutSym: string; + tokenAmountIn: string; + tokenAmountOut: string; + timestamp: number; + tx: string; + valueUSD: string; + block?: string | null; + poolId: { + __typename?: 'Pool'; id: string; - sharesOwned?: Array<{ - __typename?: 'PoolShare'; - id: string; - balance: string; - poolId: { __typename?: 'Pool'; id: string }; + swapFee: string; + poolType?: string | null; + tokens?: Array<{ + __typename?: 'PoolToken'; + token: { __typename?: 'Token'; address: string; latestFXPrice?: string | null }; }> | null; + }; + userAddress: { __typename?: 'User'; id: string }; +}; + +export type BalancerGetPoolsWithActiveUpdatesQueryVariables = Exact<{ + timestamp: Scalars['BigInt']; +}>; + +export type BalancerGetPoolsWithActiveUpdatesQuery = { + __typename?: 'Query'; + ampUpdates: Array<{ __typename?: 'AmpUpdate'; poolId: { __typename?: 'Pool'; id: string } }>; + gradualWeightUpdates: Array<{ __typename?: 'GradualWeightUpdate'; poolId: { __typename?: 'Pool'; id: string } }>; +}; + +export type BalancerGetMetaQueryVariables = Exact<{ [key: string]: never }>; + +export type BalancerGetMetaQuery = { + __typename?: 'Query'; + meta?: { + __typename?: '_Meta_'; + deployment: string; + hasIndexingErrors: boolean; + block: { __typename?: '_Block_'; number: number }; } | null; }; -export type BalancerPortfolioPoolsDataQueryVariables = Exact<{ - previousBlockNumber: Scalars['Int']; +export type PoolBalancesFragment = { + __typename?: 'Pool'; + id: string; + address: string; + totalShares: string; + tokens?: Array<{ + __typename?: 'PoolToken'; + address: string; + decimals: number; + balance: string; + priceRate: string; + }> | null; +}; + +export type PoolBalancesQueryVariables = Exact<{ + skip?: InputMaybe; + first?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + where?: InputMaybe; + block?: InputMaybe; }>; -export type BalancerPortfolioPoolsDataQuery = { +export type PoolBalancesQuery = { __typename?: 'Query'; pools: Array<{ __typename?: 'Pool'; id: string; address: string; - poolType?: string | null; - poolTypeVersion?: number | null; - symbol?: string | null; - name?: string | null; - swapFee: string; - totalWeight?: string | null; - totalSwapVolume: string; - totalSwapFee: string; - totalLiquidity: string; totalShares: string; - swapsCount: string; - holdersCount: string; - createTime: number; - swapEnabled: boolean; - tokensList: Array; - lowerTarget?: string | null; - upperTarget?: string | null; - mainIndex?: number | null; - wrappedIndex?: number | null; - factory?: string | null; - expiryTime?: string | null; - unitSeconds?: string | null; - principalToken?: string | null; - baseToken?: string | null; - owner?: string | null; - amp?: string | null; - alpha?: string | null; - beta?: string | null; - sqrtAlpha?: string | null; - sqrtBeta?: string | null; - root3Alpha?: string | null; - c?: string | null; - s?: string | null; - lambda?: string | null; - tauAlphaX?: string | null; - tauAlphaY?: string | null; - tauBetaX?: string | null; - tauBetaY?: string | null; - u?: string | null; - v?: string | null; - w?: string | null; - z?: string | null; - dSq?: string | null; - delta?: string | null; - epsilon?: string | null; - priceRateProviders?: Array<{ - __typename?: 'PriceRateProvider'; - address: string; - token: { __typename?: 'PoolToken'; address: string }; - }> | null; tokens?: Array<{ __typename?: 'PoolToken'; - id: string; - symbol: string; - name: string; - decimals: number; - address: string; - balance: string; - weight?: string | null; - priceRate: string; - isExemptFromYieldProtocolFee?: boolean | null; - index?: number | null; - token: { __typename?: 'Token'; latestFXPrice?: string | null }; - }> | null; - }>; - previousPools: Array<{ - __typename?: 'Pool'; - id: string; - address: string; - poolType?: string | null; - poolTypeVersion?: number | null; - symbol?: string | null; - name?: string | null; - swapFee: string; - totalWeight?: string | null; - totalSwapVolume: string; - totalSwapFee: string; - totalLiquidity: string; - totalShares: string; - swapsCount: string; - holdersCount: string; - createTime: number; - swapEnabled: boolean; - tokensList: Array; - lowerTarget?: string | null; - upperTarget?: string | null; - mainIndex?: number | null; - wrappedIndex?: number | null; - factory?: string | null; - expiryTime?: string | null; - unitSeconds?: string | null; - principalToken?: string | null; - baseToken?: string | null; - owner?: string | null; - amp?: string | null; - alpha?: string | null; - beta?: string | null; - sqrtAlpha?: string | null; - sqrtBeta?: string | null; - root3Alpha?: string | null; - c?: string | null; - s?: string | null; - lambda?: string | null; - tauAlphaX?: string | null; - tauAlphaY?: string | null; - tauBetaX?: string | null; - tauBetaY?: string | null; - u?: string | null; - v?: string | null; - w?: string | null; - z?: string | null; - dSq?: string | null; - delta?: string | null; - epsilon?: string | null; - priceRateProviders?: Array<{ - __typename?: 'PriceRateProvider'; address: string; - token: { __typename?: 'PoolToken'; address: string }; - }> | null; - tokens?: Array<{ - __typename?: 'PoolToken'; - id: string; - symbol: string; - name: string; decimals: number; - address: string; balance: string; - weight?: string | null; priceRate: string; - isExemptFromYieldProtocolFee?: boolean | null; - index?: number | null; - token: { __typename?: 'Token'; latestFXPrice?: string | null }; }> | null; }>; }; -export type BalancerTradePairSnapshotsQueryVariables = Exact<{ - skip?: InputMaybe; - first?: InputMaybe; - orderBy?: InputMaybe; - orderDirection?: InputMaybe; - where?: InputMaybe; - block?: InputMaybe; -}>; - -export type BalancerTradePairSnapshotsQuery = { - __typename?: 'Query'; - tradePairSnapshots: Array<{ - __typename?: 'TradePairSnapshot'; - id: string; - totalSwapFee: string; - totalSwapVolume: string; - timestamp: number; - pair: { - __typename?: 'TradePair'; - token0: { __typename?: 'Token'; address: string; symbol?: string | null }; - token1: { __typename?: 'Token'; address: string; symbol?: string | null }; - }; - }>; -}; - -export type BalancerTradePairSnapshotFragment = { - __typename?: 'TradePairSnapshot'; - id: string; - totalSwapFee: string; - totalSwapVolume: string; - timestamp: number; - pair: { - __typename?: 'TradePair'; - token0: { __typename?: 'Token'; address: string; symbol?: string | null }; - token1: { __typename?: 'Token'; address: string; symbol?: string | null }; - }; -}; - -export type BalancerSwapsQueryVariables = Exact<{ - skip?: InputMaybe; - first?: InputMaybe; - orderBy?: InputMaybe; - orderDirection?: InputMaybe; - where?: InputMaybe; - block?: InputMaybe; -}>; - -export type BalancerSwapsQuery = { - __typename?: 'Query'; - swaps: Array<{ - __typename?: 'Swap'; - id: string; - caller: string; - tokenIn: string; - tokenInSym: string; - tokenOut: string; - tokenOutSym: string; - tokenAmountIn: string; - tokenAmountOut: string; - timestamp: number; - tx: string; - valueUSD: string; - block?: string | null; - poolId: { - __typename?: 'Pool'; - id: string; - swapFee: string; - poolType?: string | null; - tokens?: Array<{ - __typename?: 'PoolToken'; - token: { __typename?: 'Token'; address: string; latestFXPrice?: string | null }; - }> | null; - }; - userAddress: { __typename?: 'User'; id: string }; - }>; -}; - -export type BalancerSwapFragment = { - __typename?: 'Swap'; - id: string; - caller: string; - tokenIn: string; - tokenInSym: string; - tokenOut: string; - tokenOutSym: string; - tokenAmountIn: string; - tokenAmountOut: string; - timestamp: number; - tx: string; - valueUSD: string; - block?: string | null; - poolId: { - __typename?: 'Pool'; - id: string; - swapFee: string; - poolType?: string | null; - tokens?: Array<{ - __typename?: 'PoolToken'; - token: { __typename?: 'Token'; address: string; latestFXPrice?: string | null }; - }> | null; - }; - userAddress: { __typename?: 'User'; id: string }; -}; - -export type BalancerAmpUpdatesQueryVariables = Exact<{ - skip?: InputMaybe; - first?: InputMaybe; - orderBy?: InputMaybe; - orderDirection?: InputMaybe; - where?: InputMaybe; - block?: InputMaybe; -}>; - -export type BalancerAmpUpdatesQuery = { - __typename?: 'Query'; - ampUpdates: Array<{ - __typename?: 'AmpUpdate'; - id: string; - startAmp: string; - endAmp: string; - startTimestamp: string; - endTimestamp: string; - poolId: { __typename?: 'Pool'; id: string }; - }>; -}; - -export type BalancerAmpUpdateFragment = { - __typename?: 'AmpUpdate'; - id: string; - startAmp: string; - endAmp: string; - startTimestamp: string; - endTimestamp: string; - poolId: { __typename?: 'Pool'; id: string }; -}; - -export type BalancerGradualWeightUpdatesQueryVariables = Exact<{ - skip?: InputMaybe; - first?: InputMaybe; - orderBy?: InputMaybe; - orderDirection?: InputMaybe; - where?: InputMaybe; - block?: InputMaybe; -}>; - -export type BalancerGradualWeightUpdatesQuery = { - __typename?: 'Query'; - gradualWeightUpdates: Array<{ - __typename?: 'GradualWeightUpdate'; - id: string; - startTimestamp: string; - endWeights: Array; - startWeights: Array; - poolId: { __typename?: 'Pool'; id: string }; - }>; -}; - -export type BalancerGradualWeightUpdateFragment = { - __typename?: 'GradualWeightUpdate'; - id: string; - startTimestamp: string; - endWeights: Array; - startWeights: Array; - poolId: { __typename?: 'Pool'; id: string }; -}; - -export type BalancerGetPoolsWithActiveUpdatesQueryVariables = Exact<{ - timestamp: Scalars['BigInt']; -}>; - -export type BalancerGetPoolsWithActiveUpdatesQuery = { - __typename?: 'Query'; - ampUpdates: Array<{ __typename?: 'AmpUpdate'; poolId: { __typename?: 'Pool'; id: string } }>; - gradualWeightUpdates: Array<{ __typename?: 'GradualWeightUpdate'; poolId: { __typename?: 'Pool'; id: string } }>; -}; - -export type BalancerGetMetaQueryVariables = Exact<{ [key: string]: never }>; - -export type BalancerGetMetaQuery = { - __typename?: 'Query'; - meta?: { - __typename?: '_Meta_'; - deployment: string; - hasIndexingErrors: boolean; - block: { __typename?: '_Block_'; number: number }; - } | null; -}; - -export type PoolBalancesFragment = { - __typename?: 'Pool'; - id: string; - address: string; - totalShares: string; - tokens?: Array<{ - __typename?: 'PoolToken'; - address: string; - decimals: number; - balance: string; - priceRate: string; - }> | null; -}; - -export type PoolBalancesQueryVariables = Exact<{ - skip?: InputMaybe; - first?: InputMaybe; - orderBy?: InputMaybe; - orderDirection?: InputMaybe; - where?: InputMaybe; - block?: InputMaybe; -}>; - -export type PoolBalancesQuery = { - __typename?: 'Query'; - pools: Array<{ - __typename?: 'Pool'; - id: string; - address: string; - totalShares: string; - tokens?: Array<{ - __typename?: 'PoolToken'; - address: string; - decimals: number; - balance: string; - priceRate: string; - }> | null; - }>; -}; - -export const BalancerUserFragmentDoc = gql` - fragment BalancerUser on User { - id - sharesOwned(first: 1000) { - id - balance - poolId { - id - } - } - } -`; export const BalancerPoolShareFragmentDoc = gql` fragment BalancerPoolShare on PoolShare { id @@ -6396,36 +5890,6 @@ export const BalancerPoolShareFragmentDoc = gql` } } `; -export const BalancerTokenPriceFragmentDoc = gql` - fragment BalancerTokenPrice on TokenPrice { - id - poolId { - id - } - asset - amount - pricingAsset - price - block - timestamp - } -`; -export const BalancerTokenFragmentDoc = gql` - fragment BalancerToken on Token { - id - symbol - address - latestFXPrice - latestUSDPrice - totalVolumeNotional - totalVolumeUSD - totalSwapCount - latestPrice { - pricingAsset - price - } - } -`; export const BalancerPoolTokenFragmentDoc = gql` fragment BalancerPoolToken on PoolToken { id @@ -6520,18 +5984,6 @@ export const BalancerPoolSnapshotFragmentDoc = gql` holdersCount } `; -export const BalancerLatestPriceFragmentDoc = gql` - fragment BalancerLatestPrice on LatestPrice { - id - asset - price - poolId { - id - } - pricingAsset - block - } -`; export const BalancerJoinExitFragmentDoc = gql` fragment BalancerJoinExit on JoinExit { amounts @@ -6548,24 +6000,6 @@ export const BalancerJoinExitFragmentDoc = gql` valueUSD } `; -export const BalancerTradePairSnapshotFragmentDoc = gql` - fragment BalancerTradePairSnapshot on TradePairSnapshot { - id - totalSwapFee - totalSwapVolume - timestamp - pair { - token0 { - address - symbol - } - token1 { - address - symbol - } - } - } -`; export const BalancerSwapFragmentDoc = gql` fragment BalancerSwap on Swap { id @@ -6590,103 +6024,24 @@ export const BalancerSwapFragmentDoc = gql` userAddress { id } - timestamp - tx - valueUSD - block - } -`; -export const BalancerAmpUpdateFragmentDoc = gql` - fragment BalancerAmpUpdate on AmpUpdate { - id - poolId { - id - } - startAmp - endAmp - startTimestamp - endTimestamp - } -`; -export const BalancerGradualWeightUpdateFragmentDoc = gql` - fragment BalancerGradualWeightUpdate on GradualWeightUpdate { - id - startTimestamp - endWeights - startWeights - endWeights - poolId { - id - } - } -`; -export const PoolBalancesFragmentDoc = gql` - fragment PoolBalances on Pool { - id - address - totalShares - tokens { - address - decimals - balance - priceRate - } - } -`; -export const BalancerProtocolDataDocument = gql` - query BalancerProtocolData( - $skip: Int - $first: Int - $orderBy: Balancer_orderBy - $orderDirection: OrderDirection - $where: Balancer_filter - $block: Block_height - ) { - balancers( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - id - totalLiquidity - totalSwapVolume - totalSwapFee - poolCount - } - } -`; -export const BalancerUserDocument = gql` - query BalancerUser($id: ID!, $block: Block_height) { - user(id: $id, block: $block) { - ...BalancerUser - } - } - ${BalancerUserFragmentDoc} -`; -export const BalancerUsersDocument = gql` - query BalancerUsers( - $skip: Int - $first: Int - $orderBy: User_orderBy - $orderDirection: OrderDirection - $where: User_filter - $block: Block_height - ) { - users( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerUser + timestamp + tx + valueUSD + block + } +`; +export const PoolBalancesFragmentDoc = gql` + fragment PoolBalances on Pool { + id + address + totalShares + tokens { + address + decimals + balance + priceRate } } - ${BalancerUserFragmentDoc} `; export const BalancerPoolSharesDocument = gql` query BalancerPoolShares( @@ -6710,50 +6065,6 @@ export const BalancerPoolSharesDocument = gql` } ${BalancerPoolShareFragmentDoc} `; -export const BalancerTokenPricesDocument = gql` - query BalancerTokenPrices( - $skip: Int - $first: Int - $orderBy: TokenPrice_orderBy - $orderDirection: OrderDirection - $where: TokenPrice_filter - $block: Block_height - ) { - tokenPrices( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerTokenPrice - } - } - ${BalancerTokenPriceFragmentDoc} -`; -export const BalancerTokensDocument = gql` - query BalancerTokens( - $skip: Int - $first: Int - $orderBy: Token_orderBy - $orderDirection: OrderDirection - $where: Token_filter - $block: Block_height - ) { - tokens( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerToken - } - } - ${BalancerTokenFragmentDoc} -`; export const BalancerPoolsDocument = gql` query BalancerPools( $skip: Int @@ -6784,35 +6095,6 @@ export const BalancerPoolDocument = gql` } ${BalancerPoolFragmentDoc} `; -export const BalancerPoolHistoricalLiquiditiesDocument = gql` - query BalancerPoolHistoricalLiquidities( - $skip: Int - $first: Int - $orderBy: PoolHistoricalLiquidity_orderBy - $orderDirection: OrderDirection - $where: PoolHistoricalLiquidity_filter - $block: Block_height - ) { - poolHistoricalLiquidities( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - id - poolId { - id - } - poolTotalShares - poolLiquidity - poolShareValue - pricingAsset - block - } - } -`; export const BalancerPoolSnapshotsDocument = gql` query BalancerPoolSnapshots( $skip: Int @@ -6835,36 +6117,6 @@ export const BalancerPoolSnapshotsDocument = gql` } ${BalancerPoolSnapshotFragmentDoc} `; -export const BalancerLatestPricesDocument = gql` - query BalancerLatestPrices( - $skip: Int - $first: Int - $orderBy: LatestPrice_orderBy - $orderDirection: OrderDirection - $where: LatestPrice_filter - $block: Block_height - ) { - latestPrices( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerLatestPrice - } - } - ${BalancerLatestPriceFragmentDoc} -`; -export const BalancerLatestPriceDocument = gql` - query BalancerLatestPrice($id: ID!) { - latestPrice(id: $id) { - ...BalancerLatestPrice - } - } - ${BalancerLatestPriceFragmentDoc} -`; export const BalancerJoinExitsDocument = gql` query BalancerJoinExits( $skip: Int @@ -6887,50 +6139,6 @@ export const BalancerJoinExitsDocument = gql` } ${BalancerJoinExitFragmentDoc} `; -export const BalancerPortfolioDataDocument = gql` - query BalancerPortfolioData($id: ID!, $previousBlockNumber: Int!) { - user(id: $id) { - ...BalancerUser - } - previousUser: user(id: $id, block: { number: $previousBlockNumber }) { - ...BalancerUser - } - } - ${BalancerUserFragmentDoc} -`; -export const BalancerPortfolioPoolsDataDocument = gql` - query BalancerPortfolioPoolsData($previousBlockNumber: Int!) { - pools(first: 1000, where: { totalShares_gt: "0" }) { - ...BalancerPool - } - previousPools: pools(first: 1000, where: { totalShares_gt: "0" }, block: { number: $previousBlockNumber }) { - ...BalancerPool - } - } - ${BalancerPoolFragmentDoc} -`; -export const BalancerTradePairSnapshotsDocument = gql` - query BalancerTradePairSnapshots( - $skip: Int - $first: Int - $orderBy: TradePairSnapshot_orderBy - $orderDirection: OrderDirection - $where: TradePairSnapshot_filter - $block: Block_height - ) { - tradePairSnapshots( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerTradePairSnapshot - } - } - ${BalancerTradePairSnapshotFragmentDoc} -`; export const BalancerSwapsDocument = gql` query BalancerSwaps( $skip: Int @@ -6953,50 +6161,6 @@ export const BalancerSwapsDocument = gql` } ${BalancerSwapFragmentDoc} `; -export const BalancerAmpUpdatesDocument = gql` - query BalancerAmpUpdates( - $skip: Int - $first: Int - $orderBy: AmpUpdate_orderBy - $orderDirection: OrderDirection - $where: AmpUpdate_filter - $block: Block_height - ) { - ampUpdates( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerAmpUpdate - } - } - ${BalancerAmpUpdateFragmentDoc} -`; -export const BalancerGradualWeightUpdatesDocument = gql` - query BalancerGradualWeightUpdates( - $skip: Int - $first: Int - $orderBy: GradualWeightUpdate_orderBy - $orderDirection: OrderDirection - $where: GradualWeightUpdate_filter - $block: Block_height - ) { - gradualWeightUpdates( - skip: $skip - first: $first - orderBy: $orderBy - orderDirection: $orderDirection - where: $where - block: $block - ) { - ...BalancerGradualWeightUpdate - } - } - ${BalancerGradualWeightUpdateFragmentDoc} -`; export const BalancerGetPoolsWithActiveUpdatesDocument = gql` query BalancerGetPoolsWithActiveUpdates($timestamp: BigInt!) { ampUpdates(where: { endTimestamp_gte: $timestamp }) { @@ -7055,48 +6219,6 @@ const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationTy export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) { return { - BalancerProtocolData( - variables?: BalancerProtocolDataQueryVariables, - requestHeaders?: Dom.RequestInit['headers'], - ): Promise { - return withWrapper( - (wrappedRequestHeaders) => - client.request(BalancerProtocolDataDocument, variables, { - ...requestHeaders, - ...wrappedRequestHeaders, - }), - 'BalancerProtocolData', - 'query', - ); - }, - BalancerUser( - variables: BalancerUserQueryVariables, - requestHeaders?: Dom.RequestInit['headers'], - ): Promise { - return withWrapper( - (wrappedRequestHeaders) => - client.request(BalancerUserDocument, variables, { - ...requestHeaders, - ...wrappedRequestHeaders, - }), - 'BalancerUser', - 'query', - ); - }, - BalancerUsers( - variables?: BalancerUsersQueryVariables, - requestHeaders?: Dom.RequestInit['headers'], - ): Promise { - return withWrapper( - (wrappedRequestHeaders) => - client.request(BalancerUsersDocument, variables, { - ...requestHeaders, - ...wrappedRequestHeaders, - }), - 'BalancerUsers', - 'query', - ); - }, BalancerPoolShares( variables?: BalancerPoolSharesQueryVariables, requestHeaders?: Dom.RequestInit['headers'], @@ -7111,34 +6233,6 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = 'query', ); }, - BalancerTokenPrices( - variables?: BalancerTokenPricesQueryVariables, - requestHeaders?: Dom.RequestInit['headers'], - ): Promise { - return withWrapper( - (wrappedRequestHeaders) => - client.request(BalancerTokenPricesDocument, variables, { - ...requestHeaders, - ...wrappedRequestHeaders, - }), - 'BalancerTokenPrices', - 'query', - ); - }, - BalancerTokens( - variables?: BalancerTokensQueryVariables, - requestHeaders?: Dom.RequestInit['headers'], - ): Promise { - return withWrapper( - (wrappedRequestHeaders) => - client.request(BalancerTokensDocument, variables, { - ...requestHeaders, - ...wrappedRequestHeaders, - }), - 'BalancerTokens', - 'query', - ); - }, BalancerPools( variables?: BalancerPoolsQueryVariables, requestHeaders?: Dom.RequestInit['headers'], @@ -7167,21 +6261,6 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = 'query', ); }, - BalancerPoolHistoricalLiquidities( - variables?: BalancerPoolHistoricalLiquiditiesQueryVariables, - requestHeaders?: Dom.RequestInit['headers'], - ): Promise { - return withWrapper( - (wrappedRequestHeaders) => - client.request( - BalancerPoolHistoricalLiquiditiesDocument, - variables, - { ...requestHeaders, ...wrappedRequestHeaders }, - ), - 'BalancerPoolHistoricalLiquidities', - 'query', - ); - }, BalancerPoolSnapshots( variables?: BalancerPoolSnapshotsQueryVariables, requestHeaders?: Dom.RequestInit['headers'], @@ -7196,34 +6275,6 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = 'query', ); }, - BalancerLatestPrices( - variables?: BalancerLatestPricesQueryVariables, - requestHeaders?: Dom.RequestInit['headers'], - ): Promise { - return withWrapper( - (wrappedRequestHeaders) => - client.request(BalancerLatestPricesDocument, variables, { - ...requestHeaders, - ...wrappedRequestHeaders, - }), - 'BalancerLatestPrices', - 'query', - ); - }, - BalancerLatestPrice( - variables: BalancerLatestPriceQueryVariables, - requestHeaders?: Dom.RequestInit['headers'], - ): Promise { - return withWrapper( - (wrappedRequestHeaders) => - client.request(BalancerLatestPriceDocument, variables, { - ...requestHeaders, - ...wrappedRequestHeaders, - }), - 'BalancerLatestPrice', - 'query', - ); - }, BalancerJoinExits( variables?: BalancerJoinExitsQueryVariables, requestHeaders?: Dom.RequestInit['headers'], @@ -7238,48 +6289,6 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = 'query', ); }, - BalancerPortfolioData( - variables: BalancerPortfolioDataQueryVariables, - requestHeaders?: Dom.RequestInit['headers'], - ): Promise { - return withWrapper( - (wrappedRequestHeaders) => - client.request(BalancerPortfolioDataDocument, variables, { - ...requestHeaders, - ...wrappedRequestHeaders, - }), - 'BalancerPortfolioData', - 'query', - ); - }, - BalancerPortfolioPoolsData( - variables: BalancerPortfolioPoolsDataQueryVariables, - requestHeaders?: Dom.RequestInit['headers'], - ): Promise { - return withWrapper( - (wrappedRequestHeaders) => - client.request(BalancerPortfolioPoolsDataDocument, variables, { - ...requestHeaders, - ...wrappedRequestHeaders, - }), - 'BalancerPortfolioPoolsData', - 'query', - ); - }, - BalancerTradePairSnapshots( - variables?: BalancerTradePairSnapshotsQueryVariables, - requestHeaders?: Dom.RequestInit['headers'], - ): Promise { - return withWrapper( - (wrappedRequestHeaders) => - client.request(BalancerTradePairSnapshotsDocument, variables, { - ...requestHeaders, - ...wrappedRequestHeaders, - }), - 'BalancerTradePairSnapshots', - 'query', - ); - }, BalancerSwaps( variables?: BalancerSwapsQueryVariables, requestHeaders?: Dom.RequestInit['headers'], @@ -7294,34 +6303,6 @@ export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = 'query', ); }, - BalancerAmpUpdates( - variables?: BalancerAmpUpdatesQueryVariables, - requestHeaders?: Dom.RequestInit['headers'], - ): Promise { - return withWrapper( - (wrappedRequestHeaders) => - client.request(BalancerAmpUpdatesDocument, variables, { - ...requestHeaders, - ...wrappedRequestHeaders, - }), - 'BalancerAmpUpdates', - 'query', - ); - }, - BalancerGradualWeightUpdates( - variables?: BalancerGradualWeightUpdatesQueryVariables, - requestHeaders?: Dom.RequestInit['headers'], - ): Promise { - return withWrapper( - (wrappedRequestHeaders) => - client.request(BalancerGradualWeightUpdatesDocument, variables, { - ...requestHeaders, - ...wrappedRequestHeaders, - }), - 'BalancerGradualWeightUpdates', - 'query', - ); - }, BalancerGetPoolsWithActiveUpdates( variables: BalancerGetPoolsWithActiveUpdatesQueryVariables, requestHeaders?: Dom.RequestInit['headers'], diff --git a/modules/token/latest-token-price.ts b/modules/token/latest-token-price.ts deleted file mode 100644 index bc42788cc..000000000 --- a/modules/token/latest-token-price.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { prisma } from '../../prisma/prisma-client'; -import { Chain } from '@prisma/client'; -import { CoingeckoDataService } from './lib/coingecko-data.service'; - -export const latestTokenPrice = async (chain: Chain, tokenAddresses: string[]) => { - const lowerCaseAddresses = tokenAddresses.map((a) => a.toLowerCase()); - const prices = await prisma.prismaTokenCurrentPrice - .findMany({ - where: { - chain, - tokenAddress: { - in: lowerCaseAddresses, - }, - }, - }) - .then((arr) => - arr.reduce( - (obj, item) => { - obj[item.tokenAddress] = item.price; - - return obj; - }, - {} as Record, - ), - ); - - const missingPrices = lowerCaseAddresses.filter((tokenAddress) => !prices[tokenAddress]); - - if (missingPrices.length > 0) { - const cg = new CoingeckoDataService(); - const coingeckoPrices = await cg.tokenPrice(chain, missingPrices); - - for (const token of Object.keys(coingeckoPrices)) { - const price = coingeckoPrices[token]; - - prices[token] = price.usd; - } - } - - return prices; -}; diff --git a/package.json b/package.json index 17533c0d4..245c9f4e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "backend", - "version": "1.56.0", + "version": "1.56.1", "description": "Backend service for Beethoven X and Balancer", "repository": "https://github.com/balancer/backend", "author": "Beethoven X", @@ -59,7 +59,7 @@ "prisma": "^6.3.0", "stellate": "2.7.1", "ts-dotenv": "^0.8.4", - "viem": "^2.37.6" + "viem": "^2.38.5" }, "devDependencies": { "@changesets/cli": "^2.27.12", diff --git a/prisma/migrations/20251031145514_add_xlayer/migration.sql b/prisma/migrations/20251031145514_add_xlayer/migration.sql new file mode 100644 index 000000000..57bf247db --- /dev/null +++ b/prisma/migrations/20251031145514_add_xlayer/migration.sql @@ -0,0 +1,2 @@ +-- AlterEnum +ALTER TYPE "Chain" ADD VALUE 'XLAYER'; \ No newline at end of file diff --git a/prisma/migrations/20251031145515_add_xlayer_partition/migration.sql b/prisma/migrations/20251031145515_add_xlayer_partition/migration.sql new file mode 100644 index 000000000..50c56f0a9 --- /dev/null +++ b/prisma/migrations/20251031145515_add_xlayer_partition/migration.sql @@ -0,0 +1,2 @@ +-- Events partition +CREATE TABLE events_xlayer PARTITION OF "PartitionedPoolEvent" FOR VALUES IN ('XLAYER'); \ No newline at end of file diff --git a/prisma/schema/base.prisma b/prisma/schema/base.prisma index 18f42c2c8..1b453a28e 100644 --- a/prisma/schema/base.prisma +++ b/prisma/schema/base.prisma @@ -28,6 +28,7 @@ enum Chain { FRAXTAL MODE SONIC + XLAYER } model PrismaLastBlockSynced {