From c8a0373db225476e17b8a0cb4b894e20e61b35cf Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 22 Aug 2022 15:23:43 +0300 Subject: [PATCH] OP-2529 Add new pools routes (#23) * OP-2529 Add new pools routes * OP-2529 Add new pools routes --- package.json | 2 +- src/services/OrionBlockchain/index.ts | 21 +++++++++++++++++++ src/services/OrionBlockchain/schemas/index.ts | 3 +++ .../schemas/poolsLpAndStakedSchema.ts | 10 +++++++++ .../schemas/userEarnedSchema.ts | 7 +++++++ .../schemas/userVotesSchema.ts | 7 +++++++ 6 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/services/OrionBlockchain/schemas/poolsLpAndStakedSchema.ts create mode 100644 src/services/OrionBlockchain/schemas/userEarnedSchema.ts create mode 100644 src/services/OrionBlockchain/schemas/userVotesSchema.ts diff --git a/package.json b/package.json index 23181ce..f734bb9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/services/OrionBlockchain/index.ts b/src/services/OrionBlockchain/index.ts index c356d79..4e9811b 100644 --- a/src/services/OrionBlockchain/index.ts +++ b/src/services/OrionBlockchain/index.ts @@ -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, diff --git a/src/services/OrionBlockchain/schemas/index.ts b/src/services/OrionBlockchain/schemas/index.ts index d8a7af3..f2c1950 100644 --- a/src/services/OrionBlockchain/schemas/index.ts +++ b/src/services/OrionBlockchain/schemas/index.ts @@ -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'; diff --git a/src/services/OrionBlockchain/schemas/poolsLpAndStakedSchema.ts b/src/services/OrionBlockchain/schemas/poolsLpAndStakedSchema.ts new file mode 100644 index 0000000..169ec12 --- /dev/null +++ b/src/services/OrionBlockchain/schemas/poolsLpAndStakedSchema.ts @@ -0,0 +1,10 @@ +import { z } from 'zod'; + +const poolsLpAndStakedSchema = z.record( + z.object({ + unstakedLPBalance: z.string(), + stakedLPBalance: z.string(), + }), +); + +export default poolsLpAndStakedSchema; diff --git a/src/services/OrionBlockchain/schemas/userEarnedSchema.ts b/src/services/OrionBlockchain/schemas/userEarnedSchema.ts new file mode 100644 index 0000000..16bd78b --- /dev/null +++ b/src/services/OrionBlockchain/schemas/userEarnedSchema.ts @@ -0,0 +1,7 @@ +import { z } from 'zod'; + +const userEarnedSchema = z.record( + z.string(), +); + +export default userEarnedSchema; diff --git a/src/services/OrionBlockchain/schemas/userVotesSchema.ts b/src/services/OrionBlockchain/schemas/userVotesSchema.ts new file mode 100644 index 0000000..0eb798e --- /dev/null +++ b/src/services/OrionBlockchain/schemas/userVotesSchema.ts @@ -0,0 +1,7 @@ +import { z } from 'zod'; + +const userVotesSchema = z.record( + z.string(), +); + +export default userVotesSchema;