feature: added new endpoint and scheme for pool v2 info

This commit is contained in:
Mikhail Gladchenko
2023-10-19 15:45:13 +01:00
parent 8a27a13a09
commit 4be3405dd8
4 changed files with 77 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.20.10-rc12",
"version": "0.20.10-rc13",
"description": "Orion Protocol SDK",
"main": "./lib/index.cjs",
"module": "./lib/index.js",

View File

@@ -5,6 +5,7 @@ import {
listNFTOrderResponseSchema,
listPoolV2ResponseSchema,
listPoolV3ResponseSchema,
PoolV2InfoResponseSchema,
testIncrementorSchema,
veORNInfoResponseSchema,
votingInfoResponseSchema
@@ -32,7 +33,7 @@ type ListNFTOrderPayload = BasePayload & {
};
type GetPoolInfoPayload = BasePayload & {
model: 'OrionV3Factory'
model: 'OrionV3Factory' | 'OrionV2Factory'
method: 'getPoolInfo'
params: [string, string, string]
};
@@ -86,6 +87,7 @@ class IntegratorService {
this.listNFTOrder = this.listNFTOrder.bind(this);
this.getPoolInfo = this.getPoolInfo.bind(this);
this.listPoolV2 = this.listPoolV2.bind(this);
this.poolV2Info = this.poolV2Info.bind(this);
this.listPoolV3 = this.listPoolV3.bind(this);
this.veORNInfo = this.veORNInfo.bind(this);
this.listAmount = this.listAmount.bind(this);
@@ -191,6 +193,17 @@ class IntegratorService {
});
};
readonly poolV2Info = (token0: string, token1: string, address: string) => {
return fetchWithValidation(this.apiUrl, PoolV2InfoResponseSchema, {
method: 'POST',
body: this.makeRPCPayload({
model: 'OrionV2Factory',
method: 'getPoolInfo',
params: [token0, token1, address],
}),
});
};
readonly listPoolV3 = (address?: string) => {
return fetchWithValidation(this.apiUrl, listPoolV3ResponseSchema, {
method: 'POST',

View File

@@ -2,6 +2,7 @@ export { default as environmentResponseSchema } from './environment-response-sch
export { default as listNFTOrderResponseSchema } from './list-nft-order-response-schema.js';
export { default as getPoolResponseSchema } from './get-pool-response-schema.js';
export { default as listPoolV2ResponseSchema } from './list-pool-v2-response-schema.js';
export { default as PoolV2InfoResponseSchema } from './pool-v2-info-schema';
export { default as listPoolV3ResponseSchema } from './list-pool-v3-response-schema.js';
export { default as veORNInfoResponseSchema } from './veORN-info-schema.js';
export { default as listAmountResponseSchema } from './list-amount-schema.js';

View File

@@ -0,0 +1,61 @@
import { z } from 'zod';
import { evmAddressSchema } from './util-schemas.js';
import basicPoolInfo from './basic-pool-info-schema';
import infoSchema from './info-schema.js';
const poolInfoSchema = z.object({
pair: z.string(),
name: z.string(),
token0: z.string(),
token1: z.string(),
name0: z.string(),
name1: z.string(),
token0Address: evmAddressSchema,
token1Address: evmAddressSchema,
token0Decimals: z.number().int().nonnegative().max(18),
token1Decimals: z.number().int().nonnegative().max(18),
WETH9: z.string(),
farmAddress: z.string(),
weight: z.number(),
liquidity0: z.number(),
liquidity1: z.number(),
token0Price: z.number(),
token1Price: z.number(),
totalLPSupply: z.number(),
totalLPStake: z.number(),
totalLPStakeInUSD: z.number(),
userLPStaked: z.number(),
userLPStakedInUSD: z.number(),
lpPriceInUSD: z.number(),
lpPriceInORN: z.number(),
userReward: z.number(),
userRewardToPool: z.number(),
weeklyReward: z.number(),
userAPR: z.number(),
lockMaxMultiplier: z.number(),
veornMaxMultiplier: z.number(),
veornBoostScaleFactor: z.number(),
lockTimeForMaxMultiplier: z.number(),
userBoost: z.number(),
userTimeDeposit: z.number(),
userLockTimeStart: z.number(),
userLockTimePeriod: z.number(),
userVeORN: z.number(),
userORN: z.number(),
boostTotalVeORN: z.number(),
boostCurrentPoolReward: z.number(),
boostTotalLiquidity: z.number(),
boostCurrentLiquidity: z.number(),
boostCurrentVeORN: z.number(),
boostTotalReward: z.number(),
type: z.string(),
...basicPoolInfo.shape,
});
const PoolV2InfoResponseSchema = z.object({
result: poolInfoSchema,
info: infoSchema,
});
export default PoolV2InfoResponseSchema;