OP-2529 Add new pools routes (#23)

* OP-2529 Add new pools routes

* OP-2529 Add new pools routes
This commit is contained in:
Dmitry
2022-08-22 15:23:43 +03:00
committed by GitHub
parent 8454366828
commit c8a0373db2
6 changed files with 49 additions and 1 deletions

View File

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

View File

@@ -6,6 +6,9 @@ import {
poolsConfigSchema, poolsInfoSchema, infoSchema, historySchema,
addPoolSchema, adminPoolsListSchema,
atomicSummarySchema,
poolsLpAndStakedSchema,
userVotesSchema,
userEarnedSchema,
} from './schemas';
import redeemOrderSchema from '../OrionAggregator/schemas/redeemOrderSchema';
import { sourceAtomicHistorySchema, targetAtomicHistorySchema } from './schemas/atomicHistorySchema';
@@ -62,6 +65,9 @@ class OrionBlockchain {
this.getInfo = this.getInfo.bind(this);
this.getPoolsConfig = this.getPoolsConfig.bind(this);
this.getPoolsInfo = this.getPoolsInfo.bind(this);
this.getPoolsLpAndStaked = this.getPoolsLpAndStaked.bind(this);
this.getUserVotes = this.getUserVotes.bind(this);
this.getUserEarned = this.getUserEarned.bind(this);
this.getHistory = this.getHistory.bind(this);
this.getPrices = this.getPrices.bind(this);
this.getTokensFee = this.getTokensFee.bind(this);
@@ -143,6 +149,21 @@ class OrionBlockchain {
poolsInfoSchema,
);
getPoolsLpAndStaked = (address: string) => fetchWithValidation(
`${this.apiUrl}/api/pools/user-lp/${address}`,
poolsLpAndStakedSchema,
);
getUserVotes = (address: string) => fetchWithValidation(
`${this.apiUrl}/api/pools/user-votes/${address}`,
userVotesSchema,
);
getUserEarned = (address: string) => fetchWithValidation(
`${this.apiUrl}/api/pools/user-earned/${address}`,
userEarnedSchema,
);
getHistory = (address: string) => fetchWithValidation(
`${this.apiUrl}/api/history/${address}`,
historySchema,

View File

@@ -8,3 +8,6 @@ export { default as infoSchema } from './infoSchema';
export { default as poolsConfigSchema } from './poolsConfigSchema';
export { default as poolsInfoSchema } from './poolsInfoSchema';
export { default as atomicSummarySchema } from './atomicSummarySchema';
export { default as poolsLpAndStakedSchema } from './poolsLpAndStakedSchema';
export { default as userVotesSchema } from './userVotesSchema';
export { default as userEarnedSchema } from './userEarnedSchema';

View File

@@ -0,0 +1,10 @@
import { z } from 'zod';
const poolsLpAndStakedSchema = z.record(
z.object({
unstakedLPBalance: z.string(),
stakedLPBalance: z.string(),
}),
);
export default poolsLpAndStakedSchema;

View File

@@ -0,0 +1,7 @@
import { z } from 'zod';
const userEarnedSchema = z.record(
z.string(),
);
export default userEarnedSchema;

View File

@@ -0,0 +1,7 @@
import { z } from 'zod';
const userVotesSchema = z.record(
z.string(),
);
export default userVotesSchema;