Fix pools schema

This commit is contained in:
Aleksandr Kraiz
2023-03-15 13:15:24 +04:00
parent ba410e13c1
commit d6dcbab128
3 changed files with 18 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@orionprotocol/sdk", "name": "@orionprotocol/sdk",
"version": "0.17.33", "version": "0.17.34",
"description": "Orion Protocol SDK", "description": "Orion Protocol SDK",
"main": "./lib/esm/index.js", "main": "./lib/esm/index.js",
"module": "./lib/esm/index.js", "module": "./lib/esm/index.js",

8
src/addressSchema.ts Normal file
View File

@@ -0,0 +1,8 @@
import { ethers } from 'ethers';
import { z } from 'zod';
const addressSchema = z.string().refine(ethers.utils.isAddress, (value) => ({
message: `Should be an address, got ${value}`,
}));
export default addressSchema;

View File

@@ -1,30 +1,30 @@
import { ethers } from 'ethers';
import { z } from 'zod'; import { z } from 'zod';
import addressSchema from '../../../addressSchema';
import { makePartial } from '../../../utils'; import { makePartial } from '../../../utils';
const poolsConfigSchema = z.object({ const poolsConfigSchema = z.object({
WETHAddress: z.string().optional(), WETHAddress: addressSchema.optional(),
factoryAddress: z.string(), factoryAddress: addressSchema,
governanceAddress: z.string(), governanceAddress: addressSchema.optional(),
routerAddress: z.string(), routerAddress: addressSchema,
votingAddress: z.string(), votingAddress: addressSchema.optional(),
factories: z.record( factories: z.record(
z.string(), z.string(),
z.string().refine(ethers.utils.isAddress, 'Factory should be an address'), addressSchema,
) )
.transform(makePartial) .transform(makePartial)
.optional(), .optional(),
pools: z.record( pools: z.record(
z.string(), z.string(),
z.object({ z.object({
lpTokenAddress: z.string(), lpTokenAddress: addressSchema,
minQty: z.number().optional(), minQty: z.number().optional(),
reverted: z.boolean().optional(), reverted: z.boolean().optional(),
rewardToken: z.string().nullable().optional(), rewardToken: z.string().nullable().optional(),
state: z.number().int().optional(), state: z.number().int().optional(),
rewardTokenDecimals: z.number().int().optional(), rewardTokenDecimals: z.number().int().optional(),
stakingRewardFinish: z.number().optional(), stakingRewardFinish: z.number().optional(),
stakingRewardAddress: z.string(), stakingRewardAddress: addressSchema,
vote_rewards_disabled: z.boolean().optional(), vote_rewards_disabled: z.boolean().optional(),
}), }),
).transform(makePartial), ).transform(makePartial),