From f09f5b15daf987806fea964bd184c8df751fc8ea Mon Sep 17 00:00:00 2001 From: gmbronco <83549293+gmbronco@users.noreply.github.com> Date: Thu, 11 Jan 2024 18:01:27 +0100 Subject: [PATCH] fix pool type mapping for StablePhantom --- modules/pool/subgraph-mapper.test.ts | 30 +++++++++++++++++++--------- modules/pool/subgraph-mapper.ts | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/modules/pool/subgraph-mapper.test.ts b/modules/pool/subgraph-mapper.test.ts index 76a5fe62c..8f8ccb388 100644 --- a/modules/pool/subgraph-mapper.test.ts +++ b/modules/pool/subgraph-mapper.test.ts @@ -1,7 +1,7 @@ -import { subgraphToPrisma } from './subgraph-mapper'; +import { subgraphToPrismaCreate } from './subgraph-mapper'; import { poolFactory, poolTokenFactory } from '../../test/factories'; -describe('subgraphToPrisma', () => { +describe('subgraphToPrismaCreate', () => { const weightedPool = poolFactory.build({ poolType: 'Weighted', }); @@ -11,6 +11,11 @@ describe('subgraphToPrisma', () => { amp: '0.1', }); + const oldStablePool = poolFactory.build({ + poolType: 'StablePhantom', + amp: '0.1', + }); + const linearPool = poolFactory.build({ poolType: 'Linear', wrappedIndex: 1, @@ -34,38 +39,45 @@ describe('subgraphToPrisma', () => { }); it('should return correct object for weighted pool', () => { - const result = subgraphToPrisma(weightedPool, 'MAINNET', 1, []); + const result = subgraphToPrismaCreate(weightedPool, 'MAINNET', 1, []); expect(result.data.type).toBe('WEIGHTED'); }); it('should return correct object for stable pool', () => { - const result = subgraphToPrisma(stablePool, 'MAINNET', 1, []); + const result = subgraphToPrismaCreate(stablePool, 'MAINNET', 1, []); expect(result.data.type).toBe('COMPOSABLE_STABLE'); expect(result.data.stableDynamicData?.create.amp).toBe(stablePool.amp); }); + it('should return correct object for old stable pool', () => { + const result = subgraphToPrismaCreate(oldStablePool, 'MAINNET', 1, []); + expect(result.data.type).toBe('COMPOSABLE_STABLE'); + expect(result.data.version).toBe(0); + expect(result.data.stableDynamicData?.create.amp).toBe(oldStablePool.amp); + }); + it('should return correct object for linear pool', () => { - const result = subgraphToPrisma(linearPool, 'MAINNET', 1, []); + const result = subgraphToPrismaCreate(linearPool, 'MAINNET', 1, []); expect(result.data.type).toBe('LINEAR'); expect(result.data.linearDynamicData?.create.upperTarget).toBe(linearPool.upperTarget); expect(result.data.linearData?.create.wrappedIndex).toBe(linearPool.wrappedIndex); }); it('should return correct object for element pool', () => { - const result = subgraphToPrisma(elementPool, 'MAINNET', 1, []); + const result = subgraphToPrismaCreate(elementPool, 'MAINNET', 1, []); expect(result.data.type).toBe('ELEMENT'); expect(result.data.elementData?.create.principalToken).toBe(elementPool.principalToken); }); it('should return correct object for gyro pool', () => { - const result = subgraphToPrisma(gyroPool, 'MAINNET', 1, []); + const result = subgraphToPrismaCreate(gyroPool, 'MAINNET', 1, []); expect(result.data.type).toBe('GYROE'); expect(result.data.gyroData?.create.alpha).toBe(gyroPool.alpha); expect(result.data.gyroData?.create.tauAlphaX).toBe(gyroPool.tauAlphaX); }); it('should return correct object for fx pool', () => { - const result = subgraphToPrisma(fxPool, 'MAINNET', 1, []); + const result = subgraphToPrismaCreate(fxPool, 'MAINNET', 1, []); expect(result.data.type).toBe('FX'); expect(result.data.data['alpha']).toBe(gyroPool.alpha); }); @@ -83,7 +95,7 @@ describe('subgraphToPrisma', () => { }); it('should recognise nested pools', () => { - const result = subgraphToPrisma(poolWithNestedPools, 'MAINNET', 1, nestedPools); + const result = subgraphToPrismaCreate(poolWithNestedPools, 'MAINNET', 1, nestedPools); expect(result.data.type).toBe('COMPOSABLE_STABLE'); expect(result.data.tokens.createMany.data[0].nestedPoolId).toBe(linearPool.id); }); diff --git a/modules/pool/subgraph-mapper.ts b/modules/pool/subgraph-mapper.ts index 776ca57d5..69b14381f 100644 --- a/modules/pool/subgraph-mapper.ts +++ b/modules/pool/subgraph-mapper.ts @@ -150,7 +150,7 @@ const subgraphMapper = ( nestedPools: { id: string; address: string }[], ) => { const type = mapSubgraphPoolTypeToPoolType(pool.poolType!); - const version = mapPoolTypeVersion(type, pool.poolTypeVersion!); + const version = mapPoolTypeVersion(pool.poolType!, pool.poolTypeVersion!); const base = { id: pool.id,