From 1cd9dabb3abc60f8e67dcddfad5a14395951eb5d Mon Sep 17 00:00:00 2001 From: franz Date: Mon, 30 Mar 2026 17:23:20 +0200 Subject: [PATCH 1/3] increase lag for xlayer --- config/xlayer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/xlayer.ts b/config/xlayer.ts index 3e12fcf4b..a721950e6 100644 --- a/config/xlayer.ts +++ b/config/xlayer.ts @@ -38,7 +38,7 @@ export default { }, rpcUrl: 'https://rpc.xlayer.tech', rpcMaxBlockRange: 100, - acceptableSGLag: 30, // ~1min + acceptableSGLag: 60, // ~1min protocolToken: 'bal', balancer: { v2: { From 52b29a6bc807301d64414a41fd9926aa16939224 Mon Sep 17 00:00:00 2001 From: franz Date: Tue, 31 Mar 2026 10:54:13 +0200 Subject: [PATCH 2/3] sync updates factory and version --- modules/actions/lbp/sync-data.ts | 34 +++++++++++++++++++++++++-- modules/controllers/lbp-controller.ts | 18 ++++++++++++-- tasks/index.ts | 3 +++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/modules/actions/lbp/sync-data.ts b/modules/actions/lbp/sync-data.ts index 186139300..6b867abb5 100644 --- a/modules/actions/lbp/sync-data.ts +++ b/modules/actions/lbp/sync-data.ts @@ -6,6 +6,7 @@ import { ViemClient } from '../../sources/types'; import { eventsRepository } from '../../repositories/events/events-repository'; import { lbpCallsV3 } from '../../sources/contracts/pool-type-dynamic-data/lbp-calls-v3'; import { prismaBulkExecuteOperations } from '../../../prisma/prisma-util'; +import { getPoolsSubgraphClient } from '../../sources/subgraphs'; /** * Fetches new weights and updates pool tokens @@ -14,6 +15,7 @@ export const syncData = async ( chain: Chain, client: ViemClient, vaultAddress: string, + poolsSubgraphClient: ReturnType, eventRepo = eventsRepository, ): Promise => { const [pools, tokens, dynamicDataMap] = await Promise.all([ @@ -23,7 +25,7 @@ export const syncData = async ( type: PrismaPoolType.LIQUIDITY_BOOTSTRAPPING, protocolVersion: 3, }, - select: { id: true, version: true, typeData: true }, + select: { id: true, version: true, typeData: true, factory: true }, }), prisma.prismaPoolToken .findMany({ @@ -68,6 +70,29 @@ export const syncData = async ( const updates = Object.keys(onchainData).flatMap((id) => onchainData[id].poolToken); + const subgraphPools = await poolsSubgraphClient.getAllPools({ + id_in: pools.map((pool) => pool.id), + }); + + // compare version and factory of subgraph pools and db pools and update the db if different. + const factoryVersionUpdates = subgraphPools + .filter((subgraphPool) => { + const dbPool = pools.find((pool) => pool.id === subgraphPool.id); + if (!dbPool) return false; + if (dbPool.version !== subgraphPool.factory.version) return true; + if (dbPool.factory !== subgraphPool.factory.id) return true; + return false; + }) + .map((pool) => + prisma.prismaPool.update({ + where: { id_chain: { id: pool.id, chain } }, + data: { + version: pool.factory.version, + factory: pool.factory.id, + }, + }), + ); + const operations = updates // Check if the weights are different .filter((update) => { @@ -131,7 +156,12 @@ export const syncData = async ( }), ); - await prismaBulkExecuteOperations([...operations, ...swapEnabledUpdates, ...holdersUpdates]); + await prismaBulkExecuteOperations([ + ...operations, + ...swapEnabledUpdates, + ...holdersUpdates, + ...factoryVersionUpdates, + ]); return; }; diff --git a/modules/controllers/lbp-controller.ts b/modules/controllers/lbp-controller.ts index 793850343..b3b301ff6 100644 --- a/modules/controllers/lbp-controller.ts +++ b/modules/controllers/lbp-controller.ts @@ -9,14 +9,28 @@ import { PoolWithMappedJsonFields } from '../../prisma/prisma-types'; import { LBPoolData, FixedLBPData } from '../pool/pool-data'; import { priceChartData } from '../pool/lbp/price-chart-data'; import { priceChartDataFixedLBP } from '../pool/lbp/fixed-lbp-price-chart-data'; +import { getPoolsSubgraphClient, getV3JoinedSubgraphClient, getVaultSubgraphClient } from '../sources/subgraphs'; export const LBPController = { async syncData(chain: Chain) { const client = getViemClient(chain); - const vaultAddress = config[chain].balancer.v3.vaultAddress; + + const { + subgraphs: { balancerV3, balancerPoolsV3 }, + balancer: { + v3: { vaultAddress }, + }, + } = config[chain]; + if (!vaultAddress) return; + // Guard against unconfigured chains + if (!balancerV3 || !balancerPoolsV3) { + throw new Error(`Chain not configured: ${chain}`); + } + + const poolsSubgraphClient = getPoolsSubgraphClient(balancerPoolsV3, chain); - await syncData(chain, client, vaultAddress); + await syncData(chain, client, vaultAddress, poolsSubgraphClient); }, async syncDataFixedLBP(chain: Chain) { const client = getViemClient(chain); diff --git a/tasks/index.ts b/tasks/index.ts index a869b3a8e..cff37e36b 100644 --- a/tasks/index.ts +++ b/tasks/index.ts @@ -177,6 +177,9 @@ async function run(job: string = process.argv[2], chainId: string = process.argv } else if (job === 'sync-lbps') { await LBPController.syncData(chain); return 'OK'; + } else if (job === 'reload-lbps') { + await LBPController.reloadLbps(chain); + return 'OK'; } else if (job === 'sync-token-yields') { await TokenYieldsController().fetchAndStoreAllYields(); return 'OK'; From a2fbe25d333ce0f00cd24bb33a991703a7ada7c1 Mon Sep 17 00:00:00 2001 From: franz Date: Tue, 31 Mar 2026 12:23:47 +0200 Subject: [PATCH 3/3] increase xlayer lag --- config/xlayer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/xlayer.ts b/config/xlayer.ts index a721950e6..29d2c7367 100644 --- a/config/xlayer.ts +++ b/config/xlayer.ts @@ -38,7 +38,7 @@ export default { }, rpcUrl: 'https://rpc.xlayer.tech', rpcMaxBlockRange: 100, - acceptableSGLag: 60, // ~1min + acceptableSGLag: 90, protocolToken: 'bal', balancer: { v2: {