diff --git a/packages/core/src/data-centralization/types.ts b/packages/core/src/data-centralization/types.ts index 9258f8a75..f4ee82eb7 100644 --- a/packages/core/src/data-centralization/types.ts +++ b/packages/core/src/data-centralization/types.ts @@ -1,6 +1,6 @@ import mongoose from "mongoose"; -interface IPool { +export interface IPool { _id: mongoose.ObjectId poolAddress: string; owner: string; @@ -29,7 +29,7 @@ interface IPool { createdAt: Date }; -const PoolSchema = new mongoose.Schema({ +export const PoolSchema = new mongoose.Schema({ poolAddress: { type: String, required: true, @@ -141,8 +141,6 @@ const PoolSchema = new mongoose.Schema({ } }); -export const PoolModel = mongoose.models.Pool || mongoose.model('Pool', PoolSchema); - export type BaseInfo = { poolAddress: string; owner: string; diff --git a/packages/core/src/data-centralization/updatePoolInDB.ts b/packages/core/src/data-centralization/updatePoolInDB.ts index fbbd529ca..3e4f3c730 100644 --- a/packages/core/src/data-centralization/updatePoolInDB.ts +++ b/packages/core/src/data-centralization/updatePoolInDB.ts @@ -1,8 +1,9 @@ +import mongoose from 'mongoose'; import { formatEther } from 'ethers'; import { getPoolInfo } from "./getPoolInfo.js"; -import { PoolModel } from "./types.js"; import { getMaxStakeAmountPerLicense } from "./getMaxStakeAmountPerLicense.js"; import { getTierIndexByStakedAmount } from "./getTierIndexByStakedAmount.js"; +import { IPool, PoolSchema } from './types.js'; import { config } from "../config.js"; const POOL_SHARES_BASE = 10_000; @@ -15,6 +16,8 @@ export async function updatePoolInDB( poolAddress: string ): Promise { + const PoolModel = mongoose.models.Pool || mongoose.model('Pool', PoolSchema); + //Load poolInfo from blockchain const poolInfo = await getPoolInfo(poolAddress); const baseInfo = poolInfo.baseInfo;