diff --git a/modules/sor/sorV2/lib/pools/stable/stablePool.ts b/modules/sor/sorV2/lib/pools/composableStable/composableStablePool.ts similarity index 95% rename from modules/sor/sorV2/lib/pools/stable/stablePool.ts rename to modules/sor/sorV2/lib/pools/composableStable/composableStablePool.ts index 0cf6249cb..272457f92 100644 --- a/modules/sor/sorV2/lib/pools/stable/stablePool.ts +++ b/modules/sor/sorV2/lib/pools/composableStable/composableStablePool.ts @@ -16,7 +16,7 @@ import { chainToIdMap } from '../../../../../network/network-config'; import { StableData } from '../../../../../pool/subgraph-mapper'; import { TokenPairData } from '../../../../../pool/lib/pool-on-chain-tokenpair-data'; -export class StablePoolToken extends TokenAmount { +export class ComposableStablePoolToken extends TokenAmount { public readonly rate: bigint; public readonly index: number; @@ -40,24 +40,24 @@ export class StablePoolToken extends TokenAmount { } } -export class StablePool implements BasePool { +export class ComposableStablePool implements BasePool { public readonly chain: Chain; public readonly id: Hex; public readonly address: string; - public readonly poolType: PoolType = PoolType.MetaStable; + public readonly poolType: PoolType = PoolType.ComposableStable; public readonly amp: bigint; public readonly swapFee: bigint; public readonly bptIndex: number; public readonly tokenPairs: TokenPairData[]; public totalShares: bigint; - public tokens: StablePoolToken[]; + public tokens: ComposableStablePoolToken[]; - private readonly tokenMap: Map; + private readonly tokenMap: Map; private readonly tokenIndexMap: Map; - static fromPrismaPool(pool: PrismaPoolWithDynamic): StablePool { - const poolTokens: StablePoolToken[] = []; + static fromPrismaPool(pool: PrismaPoolWithDynamic): ComposableStablePool { + const poolTokens: ComposableStablePoolToken[] = []; if (!pool.dynamicData) throw new Error('Stable pool has no dynamic data'); @@ -73,7 +73,7 @@ export class StablePool implements BasePool { const tokenAmount = TokenAmount.fromHumanAmount(token, `${parseFloat(poolToken.dynamicData.balance)}`); poolTokens.push( - new StablePoolToken( + new ComposableStablePoolToken( token, tokenAmount.amount, parseEther(poolToken.dynamicData.priceRate), @@ -85,7 +85,7 @@ export class StablePool implements BasePool { const totalShares = parseEther(pool.dynamicData.totalShares); const amp = parseUnits((pool.typeData as StableData).amp, 3); - return new StablePool( + return new ComposableStablePool( pool.id as Hex, pool.address, pool.chain, @@ -103,7 +103,7 @@ export class StablePool implements BasePool { chain: Chain, amp: bigint, swapFee: bigint, - tokens: StablePoolToken[], + tokens: ComposableStablePoolToken[], totalShares: bigint, tokenPairs: TokenPairData[], ) { diff --git a/modules/sor/sorV2/lib/pools/stable/stableMath.ts b/modules/sor/sorV2/lib/pools/composableStable/stableMath.ts similarity index 100% rename from modules/sor/sorV2/lib/pools/stable/stableMath.ts rename to modules/sor/sorV2/lib/pools/composableStable/stableMath.ts diff --git a/modules/sor/sorV2/lib/pools/metastable/metastablePool.ts b/modules/sor/sorV2/lib/pools/metastable/metastablePool.ts index 5b68cde4a..281f04a2e 100644 --- a/modules/sor/sorV2/lib/pools/metastable/metastablePool.ts +++ b/modules/sor/sorV2/lib/pools/metastable/metastablePool.ts @@ -1,8 +1,8 @@ import { Chain } from '@prisma/client'; import { Address, Hex, parseEther, parseUnits } from 'viem'; -import { StablePoolToken } from '../stable/stablePool'; +import { ComposableStablePoolToken } from '../composableStable/composableStablePool'; import { PrismaPoolWithDynamic } from '../../../../../../prisma/prisma-types'; -import { _calcInGivenOut, _calcOutGivenIn, _calculateInvariant } from '../stable/stableMath'; +import { _calcInGivenOut, _calcOutGivenIn, _calculateInvariant } from '../composableStable/stableMath'; import { MathSol, WAD } from '../../utils/math'; import { BasePool, PoolType, SwapKind, Token, TokenAmount } from '@balancer/sdk'; import { chainToIdMap } from '../../../../../network/network-config'; @@ -16,14 +16,14 @@ export class MetaStablePool implements BasePool { public readonly poolType: PoolType = PoolType.MetaStable; public readonly amp: bigint; public readonly swapFee: bigint; - public readonly tokens: StablePoolToken[]; + public readonly tokens: ComposableStablePoolToken[]; public readonly tokenPairs: TokenPairData[]; - private readonly tokenMap: Map; + private readonly tokenMap: Map; private readonly tokenIndexMap: Map; static fromPrismaPool(pool: PrismaPoolWithDynamic): MetaStablePool { - const poolTokens: StablePoolToken[] = []; + const poolTokens: ComposableStablePoolToken[] = []; if (!pool.dynamicData) throw new Error('Stable pool has no dynamic data'); @@ -39,7 +39,7 @@ export class MetaStablePool implements BasePool { const tokenAmount = TokenAmount.fromHumanAmount(token, `${parseFloat(poolToken.dynamicData.balance)}`); poolTokens.push( - new StablePoolToken( + new ComposableStablePoolToken( token, tokenAmount.amount, parseEther(poolToken.dynamicData.priceRate), @@ -67,7 +67,7 @@ export class MetaStablePool implements BasePool { chain: Chain, amp: bigint, swapFee: bigint, - tokens: StablePoolToken[], + tokens: ComposableStablePoolToken[], tokenPairs: TokenPairData[], ) { this.id = id; diff --git a/modules/sor/sorV2/lib/static.ts b/modules/sor/sorV2/lib/static.ts index 5817fbc93..ccb0f99a0 100644 --- a/modules/sor/sorV2/lib/static.ts +++ b/modules/sor/sorV2/lib/static.ts @@ -2,13 +2,13 @@ import { Router } from './router'; import { PrismaPoolWithDynamic } from '../../../../prisma/prisma-types'; import { checkInputs } from './utils/helpers'; import { WeightedPool } from './pools/weighted/weightedPool'; -import { StablePool } from './pools/stable/stablePool'; import { MetaStablePool } from './pools/metastable/metastablePool'; import { FxPool } from './pools/fx/fxPool'; import { Gyro2Pool } from './pools/gyro2/gyro2Pool'; import { Gyro3Pool } from './pools/gyro3/gyro3Pool'; import { GyroEPool } from './pools/gyroE/gyroEPool'; import { BasePool, Swap, SwapKind, SwapOptions, Token } from '@balancer/sdk'; +import { ComposableStablePool } from './pools/composableStable/composableStablePool'; export async function sorGetSwapsWithPools( tokenIn: Token, @@ -29,7 +29,7 @@ export async function sorGetSwapsWithPools( break; case 'COMPOSABLE_STABLE': case 'PHANTOM_STABLE': - basePools.push(StablePool.fromPrismaPool(prismaPool)); + basePools.push(ComposableStablePool.fromPrismaPool(prismaPool)); break; case 'META_STABLE': basePools.push(MetaStablePool.fromPrismaPool(prismaPool));