diff --git a/package-lock.json b/package-lock.json index 239694a7..9a697511 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.82", + "version": "0.20.83-rc5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@orionprotocol/sdk", - "version": "0.20.82", + "version": "0.20.83-rc5", "hasInstallScript": true, "license": "ISC", "dependencies": { @@ -27,7 +27,7 @@ "merge-anything": "^5.1.7", "neverthrow": "^6.0.0", "patch-package": "^8.0.0", - "simple-typed-fetch": "0.2.3", + "simple-typed-fetch": "0.2.5", "stream-browserify": "^3.0.0", "tiny-invariant": "^1.3.1", "ts-is-present": "^1.2.2", @@ -10399,9 +10399,9 @@ "dev": true }, "node_modules/simple-typed-fetch": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/simple-typed-fetch/-/simple-typed-fetch-0.2.3.tgz", - "integrity": "sha512-EXP2mVVsVf4A3+5QGevs8789ztnT6FozsYyMrIrUYhfqtX2V+X9xETHeGXffmgv7YQ0p+GrW7N+5x+b+pBW59Q==", + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/simple-typed-fetch/-/simple-typed-fetch-0.2.5.tgz", + "integrity": "sha512-T/KKUHKOZgaYVp3dbjE1wEK5cAGmG5N7FNAzP6ZGqLDhzBsRm3Gpt8bO/kowV6bt8duXDWiapYFQibW/8iHp6Q==", "dependencies": { "isomorphic-unfetch": "^4.0.2", "neverthrow": "^6.0.0", @@ -19333,9 +19333,9 @@ "dev": true }, "simple-typed-fetch": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/simple-typed-fetch/-/simple-typed-fetch-0.2.3.tgz", - "integrity": "sha512-EXP2mVVsVf4A3+5QGevs8789ztnT6FozsYyMrIrUYhfqtX2V+X9xETHeGXffmgv7YQ0p+GrW7N+5x+b+pBW59Q==", + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/simple-typed-fetch/-/simple-typed-fetch-0.2.5.tgz", + "integrity": "sha512-T/KKUHKOZgaYVp3dbjE1wEK5cAGmG5N7FNAzP6ZGqLDhzBsRm3Gpt8bO/kowV6bt8duXDWiapYFQibW/8iHp6Q==", "requires": { "isomorphic-unfetch": "^4.0.2", "neverthrow": "^6.0.0", diff --git a/package.json b/package.json index e2cb3dc7..96f6ba6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.82", + "version": "0.20.83-rc5", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", @@ -102,7 +102,7 @@ "merge-anything": "^5.1.7", "neverthrow": "^6.0.0", "patch-package": "^8.0.0", - "simple-typed-fetch": "0.2.3", + "simple-typed-fetch": "0.2.5", "stream-browserify": "^3.0.0", "tiny-invariant": "^1.3.1", "ts-is-present": "^1.2.2", diff --git a/src/services/BlockchainService/index.ts b/src/services/BlockchainService/index.ts index ceacbcbe..c368d15c 100644 --- a/src/services/BlockchainService/index.ts +++ b/src/services/BlockchainService/index.ts @@ -12,7 +12,7 @@ import { pairStatusSchema, pricesWithQuoteAssetSchema, referralDataSchema, - pmmSchema + pmmSchema, } from './schemas/index.js'; import type redeemOrderSchema from '../Aggregator/schemas/redeemOrderSchema.js'; import { sourceAtomicHistorySchema, targetAtomicHistorySchema } from './schemas/atomicHistorySchema.js'; @@ -64,6 +64,10 @@ type PlatformFees = { walletAddress?: string | undefined fromWidget?: string | undefined } +type DueLiabilityEstimateProps = { + asset: string + amount: number +} class BlockchainService { private readonly apiUrl: string; @@ -115,6 +119,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 +276,12 @@ class BlockchainService { { headers: this.basicAuthHeaders } ); + getDueLiabilityEstimate = ({ asset, amount }: DueLiabilityEstimateProps) => fetchWithValidation( + `${this.apiUrl}/api/due-liability-estimate/${asset}/${amount}`, + z.number().nonnegative(), + { headers: this.basicAuthHeaders } + ); + getGasPriceWei = () => fetchWithValidation( `${this.apiUrl}/api/gasPrice`, z.string(), diff --git a/src/services/BlockchainService/schemas/index.ts b/src/services/BlockchainService/schemas/index.ts index 886cb3a1..3533c761 100644 --- a/src/services/BlockchainService/schemas/index.ts +++ b/src/services/BlockchainService/schemas/index.ts @@ -15,4 +15,4 @@ 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 { referralDataSchema } from './referralDataSchema.js';