From e5ec15a87a7b49aa284d0217ee772fa3f2a64d80 Mon Sep 17 00:00:00 2001 From: Dmitry <35160421+TheJuze@users.noreply.github.com> Date: Thu, 16 Nov 2023 10:40:16 +0300 Subject: [PATCH] feat: governance improvements (#211) --- package-lock.json | 4 +-- package.json | 2 +- src/services/BlockchainService/index.ts | 34 ------------------- .../schemas/governanceChainsInfoSchema.ts | 7 ---- .../schemas/governanceContractsSchema.ts | 19 ----------- .../schemas/governancePoolSchema.ts | 18 ---------- .../schemas/governancePoolsSchema.ts | 28 --------------- .../BlockchainService/schemas/index.ts | 4 --- src/services/Indexer/index.ts | 2 +- .../schemas/environment-response-schema.ts | 12 +++---- .../Indexer/schemas/pool-v2-info-schema.ts | 2 +- 11 files changed, 11 insertions(+), 121 deletions(-) delete mode 100644 src/services/BlockchainService/schemas/governanceChainsInfoSchema.ts delete mode 100644 src/services/BlockchainService/schemas/governanceContractsSchema.ts delete mode 100644 src/services/BlockchainService/schemas/governancePoolSchema.ts delete mode 100644 src/services/BlockchainService/schemas/governancePoolsSchema.ts diff --git a/package-lock.json b/package-lock.json index aa9feb5..4d06cb4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.21", + "version": "0.20.22-rc3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@orionprotocol/sdk", - "version": "0.20.21", + "version": "0.20.22-rc3", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index 4fde2da..4abb0e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.21", + "version": "0.20.22-rc3", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/services/BlockchainService/index.ts b/src/services/BlockchainService/index.ts index 3056b93..eebec2f 100644 --- a/src/services/BlockchainService/index.ts +++ b/src/services/BlockchainService/index.ts @@ -18,12 +18,6 @@ import { makePartial } from '../../utils'; import type { networkCodes } from '../../constants/index.js'; import { fetchWithValidation } from 'simple-typed-fetch'; import type { BasicAuthCredentials } from '../../types.js'; -import { - governanceChainsInfoSchema, - governanceContractsSchema, - governancePoolSchema, - governancePoolsSchema -} from './schemas'; type IAdminAuthHeaders = { auth: string @@ -116,10 +110,6 @@ class BlockchainService { this.getBlockNumber = this.getBlockNumber.bind(this); this.getRedeemOrderBySecretHash = this.getRedeemOrderBySecretHash.bind(this); this.claimOrder = this.claimOrder.bind(this); - this.getGovernanceContracts = this.getGovernanceContracts.bind(this); - this.getGovernancePools = this.getGovernancePools.bind(this); - this.getGovernancePool = this.getGovernancePool.bind(this); - this.getGovernanceChainsInfo = this.getGovernanceChainsInfo.bind(this); } get basicAuthHeaders() { @@ -487,30 +477,6 @@ class BlockchainService { body: JSON.stringify(secretHashes), }, ); - - getGovernanceContracts = () => fetchWithValidation( - `${this.apiUrl}/api/governance/info`, - governanceContractsSchema, - { headers: this.basicAuthHeaders }, - ); - - getGovernancePools = () => fetchWithValidation( - `${this.apiUrl}/api/governance/pools`, - governancePoolsSchema, - { headers: this.basicAuthHeaders }, - ); - - getGovernancePool = (address: string) => fetchWithValidation( - `${this.apiUrl}/api/governance/pools/${address}`, - governancePoolSchema, - { headers: this.basicAuthHeaders }, - ); - - getGovernanceChainsInfo = () => fetchWithValidation( - `${this.apiUrl}/api/governance/chains-info`, - governanceChainsInfoSchema, - { headers: this.basicAuthHeaders }, - ); } export * as schemas from './schemas/index.js'; diff --git a/src/services/BlockchainService/schemas/governanceChainsInfoSchema.ts b/src/services/BlockchainService/schemas/governanceChainsInfoSchema.ts deleted file mode 100644 index 7a1b8b8..0000000 --- a/src/services/BlockchainService/schemas/governanceChainsInfoSchema.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { z } from 'zod'; - -const governanceChainsInfoSchema = z.object({ - isChainSupported: z.boolean(), -}); - -export default governanceChainsInfoSchema; diff --git a/src/services/BlockchainService/schemas/governanceContractsSchema.ts b/src/services/BlockchainService/schemas/governanceContractsSchema.ts deleted file mode 100644 index 9934b4d..0000000 --- a/src/services/BlockchainService/schemas/governanceContractsSchema.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { z } from 'zod'; - -const governanceContractsSchema = z.object({ - controllerAddress: z.string(), - veTOKENAddress: z.string(), - veTOKENYieldDistributorV4Address: z.string(), - time_total: z.string(), - absolute_ve_token_in_voting: z.string(), - info: z.record( - z.string(), - z.object({ - gaugeAddress: z.string(), - gaugeType: z.number(), - gaugeName: z.string(), - }) - ), -}); - -export default governanceContractsSchema; diff --git a/src/services/BlockchainService/schemas/governancePoolSchema.ts b/src/services/BlockchainService/schemas/governancePoolSchema.ts deleted file mode 100644 index dd613b6..0000000 --- a/src/services/BlockchainService/schemas/governancePoolSchema.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { z } from 'zod'; - -const governancePoolSchema = z.object({ - min_apr: z.string(), - max_apr: z.string(), - tvl: z.string(), - lp_supply: z.string(), - lp_staked: z.string(), - lp_staked_with_boost: z.string(), - lp_price_in_usd: z.string(), - reward_per_period: z.string(), - lock_time_for_max_multiplier: z.string(), - lock_max_multiplier: z.string(), - veorn_max_multiplier: z.string(), - veorn_boost_scale_factor: z.string(), -}); - -export default governancePoolSchema; diff --git a/src/services/BlockchainService/schemas/governancePoolsSchema.ts b/src/services/BlockchainService/schemas/governancePoolsSchema.ts deleted file mode 100644 index 8b3bcb3..0000000 --- a/src/services/BlockchainService/schemas/governancePoolsSchema.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { z } from 'zod'; - -const governancePoolsSchema = z.array( - z.object({ - slug: z.string(), - identifier: z.string(), - chain: z.string(), - platform: z.string(), - logo: z.string(), - pair: z.string(), - lp_address: z.string(), - lp_staked: z.string(), - lp_staked_with_boost: z.string(), - lp_supply: z.string(), - lp_price_in_usd: z.string(), - farm_address: z.string(), - pool_tokens: z.tuple([z.string(), z.string()]), - pool_rewards: z.array(z.string()), - tvl: z.string(), - min_apr: z.string(), - max_apr: z.string(), - reward_per_period: z.array(z.string()), - weight: z.string(), - liquidity: z.string(), - }) -); - -export default governancePoolsSchema; diff --git a/src/services/BlockchainService/schemas/index.ts b/src/services/BlockchainService/schemas/index.ts index 80b82f3..2abb10d 100644 --- a/src/services/BlockchainService/schemas/index.ts +++ b/src/services/BlockchainService/schemas/index.ts @@ -12,9 +12,5 @@ export { default as atomicSummarySchema } from './atomicSummarySchema.js'; export { default as poolsLpAndStakedSchema } from './poolsLpAndStakedSchema.js'; export { default as userVotesSchema } from './userVotesSchema.js'; export { default as userEarnedSchema } from './userEarnedSchema.js'; -export { default as governanceContractsSchema } from './governanceContractsSchema.js'; -export { default as governancePoolsSchema } from './governancePoolsSchema.js'; -export { default as governancePoolSchema } from './governancePoolSchema.js'; -export { default as governanceChainsInfoSchema } from './governanceChainsInfoSchema.js'; export { default as poolsV3InfoSchema } from './poolsV3InfoSchema.js'; export { pricesWithQuoteAssetSchema } from './pricesWithQuoteAssetSchema.js'; diff --git a/src/services/Indexer/index.ts b/src/services/Indexer/index.ts index 13f0b66..bcdfaca 100644 --- a/src/services/Indexer/index.ts +++ b/src/services/Indexer/index.ts @@ -208,7 +208,7 @@ class IndexerService { }); }; - readonly poolV2Info = (token0: string, token1: string, address: string) => { + readonly poolV2Info = (token0: string, token1: string, address: string | undefined) => { return fetchWithValidation(this.apiUrl, PoolV2InfoResponseSchema, { method: 'POST', body: this.makeRPCPayload({ diff --git a/src/services/Indexer/schemas/environment-response-schema.ts b/src/services/Indexer/schemas/environment-response-schema.ts index 80984b5..8479e05 100644 --- a/src/services/Indexer/schemas/environment-response-schema.ts +++ b/src/services/Indexer/schemas/environment-response-schema.ts @@ -6,16 +6,16 @@ const environmentResponseSchema = z.object({ result: z.object({ chainId: z.number().int().nonnegative(), nativeToken: z.string(), + ORN: evmAddressSchema, + WETH9: evmAddressSchema, OrionV3Factory: evmAddressSchema.optional(), - OrionV2Factory: evmAddressSchema, + OrionV2Factory: evmAddressSchema.optional(), OrionV3NFTManager: evmAddressSchema.optional(), SwapRouterV3: evmAddressSchema.optional(), OrionFarmV3: evmAddressSchema.optional(), - OrionFarmV2: evmAddressSchema, - OrionVoting: evmAddressSchema, - veORN: evmAddressSchema, - ORN: evmAddressSchema, - WETH9: evmAddressSchema, + OrionFarmV2: evmAddressSchema.optional(), + OrionVoting: evmAddressSchema.optional(), + veORN: evmAddressSchema.optional(), }), info: infoSchema, }); diff --git a/src/services/Indexer/schemas/pool-v2-info-schema.ts b/src/services/Indexer/schemas/pool-v2-info-schema.ts index 94c8d59..d5a369e 100644 --- a/src/services/Indexer/schemas/pool-v2-info-schema.ts +++ b/src/services/Indexer/schemas/pool-v2-info-schema.ts @@ -15,7 +15,7 @@ const poolInfoSchema = z.object({ token0Decimals: z.number().int().nonnegative().max(18), token1Decimals: z.number().int().nonnegative().max(18), WETH9: z.string(), - farmAddress: z.string(), + farmAddress: z.string().optional(), weight: z.number(), liquidity0: z.number(), liquidity1: z.number(),