diff --git a/package-lock.json b/package-lock.json index 239694a..fa15ecc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.82", + "version": "0.20.83-rc0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@orionprotocol/sdk", - "version": "0.20.82", + "version": "0.20.83-rc0", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index e2cb3dc..31e6b95 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.82", + "version": "0.20.83-rc0", "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 ceacbcb..0a040f8 100644 --- a/src/services/BlockchainService/index.ts +++ b/src/services/BlockchainService/index.ts @@ -20,6 +20,7 @@ import { makePartial } from '../../utils'; import type { networkCodes } from '../../constants/index.js'; import { fetchWithValidation } from 'simple-typed-fetch'; import type { BasicAuthCredentials } from '../../types.js'; +import { dueLiabilityEstimateSchema } from './schemas/dueLiabilityEstimateSchema'; type IAdminAuthHeaders = { auth: string @@ -64,6 +65,10 @@ type PlatformFees = { walletAddress?: string | undefined fromWidget?: string | undefined } +type DueLiabilityEstimateProps = { + asset: string + amount: number +} class BlockchainService { private readonly apiUrl: string; @@ -115,6 +120,7 @@ class BlockchainService { this.claimOrder = this.claimOrder.bind(this); this.getGasLimits = this.getGasLimits.bind(this); this.getExchangeContractWalletBalance = this.getExchangeContractWalletBalance.bind(this); + this.getDueLiabilityEstimate = this.getDueLiabilityEstimate.bind(this); } get basicAuthHeaders() { @@ -271,6 +277,12 @@ class BlockchainService { { headers: this.basicAuthHeaders } ); + getDueLiabilityEstimate = ({ asset, amount }: DueLiabilityEstimateProps) => fetchWithValidation( + `${this.apiUrl}/api/due-liability-esstimate/${asset}/${amount}`, + dueLiabilityEstimateSchema, + { headers: this.basicAuthHeaders } + ); + getGasPriceWei = () => fetchWithValidation( `${this.apiUrl}/api/gasPrice`, z.string(), diff --git a/src/services/BlockchainService/schemas/dueLiabilityEstimateSchema.ts b/src/services/BlockchainService/schemas/dueLiabilityEstimateSchema.ts new file mode 100644 index 0000000..1b86c7e --- /dev/null +++ b/src/services/BlockchainService/schemas/dueLiabilityEstimateSchema.ts @@ -0,0 +1,6 @@ +import { z } from 'zod'; + +export const dueLiabilityEstimateSchema = z.object({ + asset: z.string(), + amount: z.number().nonnegative(), +}); diff --git a/src/services/BlockchainService/schemas/index.ts b/src/services/BlockchainService/schemas/index.ts index 886cb3a..db3d1c6 100644 --- a/src/services/BlockchainService/schemas/index.ts +++ b/src/services/BlockchainService/schemas/index.ts @@ -1,18 +1,19 @@ -export * from './adminPoolSchema.js'; -export { default as adminPoolsListSchema } from './adminPoolsListSchema.js'; -export { default as addPoolSchema } from './addPoolSchema.js'; -export { default as atomicHistorySchema } from './atomicHistorySchema.js'; -export { default as checkRedeemOrderSchema } from './checkRedeemOrderSchema.js'; -export { default as historySchema } from './historySchema.js'; -export { default as IDOSchema } from './IDOSchema.js'; -export { default as infoSchema } from './infoSchema.js'; -export { default as poolsConfigSchema } from './poolsConfigSchema.js'; -export { default as poolsInfoSchema } from './poolsInfoSchema.js'; -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 poolsV3InfoSchema } from './poolsV3InfoSchema.js'; -export { default as pmmSchema } from './pmmSchema.js'; -export { pricesWithQuoteAssetSchema } from './pricesWithQuoteAssetSchema.js'; -export { referralDataSchema } from './referralDataSchema.js'; \ No newline at end of file +export * from './adminPoolSchema'; +export { default as adminPoolsListSchema } from './adminPoolsListSchema'; +export { default as addPoolSchema } from './addPoolSchema'; +export { default as atomicHistorySchema } from './atomicHistorySchema'; +export { default as checkRedeemOrderSchema } from './checkRedeemOrderSchema'; +export { default as historySchema } from './historySchema'; +export { default as IDOSchema } from './IDOSchema'; +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'; +export { default as poolsV3InfoSchema } from './poolsV3InfoSchema'; +export { default as pmmSchema } from './pmmSchema'; +export { pricesWithQuoteAssetSchema } from './pricesWithQuoteAssetSchema'; +export { referralDataSchema } from './referralDataSchema'; +export { dueLiabilityEstimateSchema } from './dueLiabilityEstimateSchema';