diff --git a/package.json b/package.json index f479e9f..8dbdf50 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.10-rc17", + "version": "0.20.10-rc18", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/services/Integrator/index.ts b/src/services/Integrator/index.ts index e259aba..a36968f 100644 --- a/src/services/Integrator/index.ts +++ b/src/services/Integrator/index.ts @@ -14,6 +14,7 @@ import { fetchWithValidation } from 'simple-typed-fetch'; import { BigNumber } from 'bignumber.js'; import { DAY, WEEK_DAYS, YEAR } from '../../constants'; import { LOCK_START_TIME } from './constants'; +import listPoolResponseSchema from './schemas/list-pool-schema'; type BasePayload = { chainId: number @@ -86,6 +87,7 @@ class IntegratorService { this.getEnvironment = this.getEnvironment.bind(this); this.listNFTOrder = this.listNFTOrder.bind(this); this.getPoolInfo = this.getPoolInfo.bind(this); + this.getListPool = this.getListPool.bind(this); this.listPoolV2 = this.listPoolV2.bind(this); this.poolV2Info = this.poolV2Info.bind(this); this.listPoolV3 = this.listPoolV3.bind(this); @@ -167,6 +169,17 @@ class IntegratorService { }); }; + readonly getListPool = (userAddress?: string) => { + return fetchWithValidation(this.apiUrl, listPoolResponseSchema, { + method: 'POST', + body: this.makeRPCPayload({ + model: 'OrionVoting', + method: 'listPool', + params: [userAddress], + }), + }); + }; + readonly getPoolInfo = ( token0: string, token1: string, diff --git a/src/services/Integrator/schemas/list-pool-schema.ts b/src/services/Integrator/schemas/list-pool-schema.ts new file mode 100644 index 0000000..7d87dfa --- /dev/null +++ b/src/services/Integrator/schemas/list-pool-schema.ts @@ -0,0 +1,11 @@ +import { z } from 'zod'; +import infoSchema from './info-schema'; +import { listPoolV2Schema } from './list-pool-v2-response-schema'; +import { listPoolV3Schema } from './list-pool-v3-response-schema'; + +const listPoolResponseSchema = z.object({ + result: z.array(listPoolV2Schema.or(listPoolV3Schema)), + info: infoSchema, +}); + +export default listPoolResponseSchema; diff --git a/src/services/Integrator/schemas/list-pool-v2-response-schema.ts b/src/services/Integrator/schemas/list-pool-v2-response-schema.ts index f50af1d..8d128db 100644 --- a/src/services/Integrator/schemas/list-pool-v2-response-schema.ts +++ b/src/services/Integrator/schemas/list-pool-v2-response-schema.ts @@ -3,7 +3,7 @@ import { evmAddressSchema } from './util-schemas.js'; import basicPoolInfo from './basic-pool-info-schema.js'; import infoSchema from './info-schema.js'; -const poolOfListPoolSchema = z.object({ +export const listPoolV2Schema = z.object({ pair: z.string(), token0: z.string().nonempty(), token1: z.string().nonempty(), @@ -55,7 +55,7 @@ const poolOfListPoolSchema = z.object({ }); const listPoolV2ResponseSchema = z.object({ - result: z.array(poolOfListPoolSchema), + result: z.array(listPoolV2Schema), info: infoSchema, }); diff --git a/src/services/Integrator/schemas/list-pool-v3-response-schema.ts b/src/services/Integrator/schemas/list-pool-v3-response-schema.ts index 2bddfed..138ddfd 100644 --- a/src/services/Integrator/schemas/list-pool-v3-response-schema.ts +++ b/src/services/Integrator/schemas/list-pool-v3-response-schema.ts @@ -3,7 +3,7 @@ import { evmAddressSchema } from './util-schemas.js'; import basicPoolInfo from './basic-pool-info-schema.js'; import infoSchema from './info-schema.js'; -const poolOfListPoolSchema = z.object({ +export const listPoolV3Schema = z.object({ token0: z.string().nonempty(), token1: z.string().nonempty(), name: z.string(), @@ -23,7 +23,7 @@ const poolOfListPoolSchema = z.object({ }); const listPoolV3ResponseSchema = z.object({ - result: z.array(poolOfListPoolSchema), + result: z.array(listPoolV3Schema), info: infoSchema, });