diff --git a/package.json b/package.json index 1946b41..036af11 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.18.1", + "version": "0.18.2", "description": "Orion Protocol SDK", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", diff --git a/src/Orion/bridge/getHistory.ts b/src/Orion/bridge/getHistory.ts index 3b04e8f..18f6c24 100644 --- a/src/Orion/bridge/getHistory.ts +++ b/src/Orion/bridge/getHistory.ts @@ -2,9 +2,11 @@ import { ethers } from 'ethers'; import type OrionUnit from '../../OrionUnit/index.js'; import type { SupportedChainId } from '../../types.js'; import { isValidChainId } from '../../utils/index.js'; -import { simpleFetch } from 'simple-typed-fetch'; +import stf from 'simple-typed-fetch'; import bsonObjectId from 'bson-objectid'; +const { simpleFetch } = stf; + const ObjectID = bsonObjectId.default const getHistory = async (units: OrionUnit[], address: string, limit = 1000) => { diff --git a/src/Orion/bridge/swap.ts b/src/Orion/bridge/swap.ts index 65ec975..ade37aa 100644 --- a/src/Orion/bridge/swap.ts +++ b/src/Orion/bridge/swap.ts @@ -17,7 +17,9 @@ import type { SupportedChainId } from '../../types.js'; import type Orion from '../index.js'; import type { z } from 'zod'; import type { placeAtomicSwapSchema } from '../../services/OrionAggregator/schemas/index.js'; -import { simpleFetch } from 'simple-typed-fetch'; +import stf from 'simple-typed-fetch'; + +const { simpleFetch } = stf; type Params = { assetName: string diff --git a/src/Orion/index.ts b/src/Orion/index.ts index aa2ebd2..cbfe4e0 100644 --- a/src/Orion/index.ts +++ b/src/Orion/index.ts @@ -1,4 +1,4 @@ -import type { BigNumber } from 'bignumber.js'; +import type { BigNumber } from 'bignumber.js'; import type { ethers } from 'ethers'; import { merge } from 'merge-anything'; import { chains, envs } from '../config/index.js'; @@ -9,7 +9,9 @@ import type { SupportedChainId, DeepPartial, VerboseOrionUnitConfig, KnownEnv } import { isValidChainId } from '../utils/index.js'; import swap from './bridge/swap.js'; import getHistory from './bridge/getHistory.js'; -import { simpleFetch } from 'simple-typed-fetch'; +import stf from 'simple-typed-fetch'; + +const { simpleFetch } = stf; type EnvConfig = { analyticsAPI: string diff --git a/src/OrionUnit/Exchange/deposit.ts b/src/OrionUnit/Exchange/deposit.ts index f2be122..ec88125 100644 --- a/src/OrionUnit/Exchange/deposit.ts +++ b/src/OrionUnit/Exchange/deposit.ts @@ -9,7 +9,9 @@ import { } from '../../constants/index.js'; import { denormalizeNumber, normalizeNumber } from '../../utils/index.js'; import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js'; -import { simpleFetch } from 'simple-typed-fetch'; +import stf from 'simple-typed-fetch'; + +const { simpleFetch } = stf; export type DepositParams = { asset: string diff --git a/src/OrionUnit/Exchange/getSwapInfo.ts b/src/OrionUnit/Exchange/getSwapInfo.ts index d173218..70bf5e0 100644 --- a/src/OrionUnit/Exchange/getSwapInfo.ts +++ b/src/OrionUnit/Exchange/getSwapInfo.ts @@ -1,12 +1,14 @@ import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; -import { simpleFetch } from 'simple-typed-fetch'; +import stf from 'simple-typed-fetch'; import { NATIVE_CURRENCY_PRECISION, SWAP_THROUGH_ORION_POOL_GAS_LIMIT } from '../../constants/index.js'; import type { OrionAggregator } from '../../services/OrionAggregator/index.js'; import type { OrionBlockchain } from '../../services/OrionBlockchain/index.js'; import { calculateFeeInFeeAsset, denormalizeNumber, getNativeCryptocurrency } from '../../utils/index.js'; +const { simpleFetch } = stf; + export type GetSwapInfoParams = { type: 'exactSpend' | 'exactReceive' assetIn: string diff --git a/src/OrionUnit/Exchange/swapLimit.ts b/src/OrionUnit/Exchange/swapLimit.ts index affff6d..202e73c 100644 --- a/src/OrionUnit/Exchange/swapLimit.ts +++ b/src/OrionUnit/Exchange/swapLimit.ts @@ -11,7 +11,9 @@ import { calculateFeeInFeeAsset, denormalizeNumber, normalizeNumber } from '../. import { signOrder } from '../../crypt/index.js'; import type orderSchema from '../../services/OrionAggregator/schemas/orderSchema.js'; import type { z } from 'zod'; -import { simpleFetch } from 'simple-typed-fetch'; +import stf from 'simple-typed-fetch'; + +const { simpleFetch } = stf; export type SwapLimitParams = { type: 'exactSpend' | 'exactReceive' diff --git a/src/OrionUnit/Exchange/swapMarket.ts b/src/OrionUnit/Exchange/swapMarket.ts index 7575708..81ed1cd 100644 --- a/src/OrionUnit/Exchange/swapMarket.ts +++ b/src/OrionUnit/Exchange/swapMarket.ts @@ -11,7 +11,9 @@ import { signOrder } from '../../crypt/index.js'; import type orderSchema from '../../services/OrionAggregator/schemas/orderSchema.js'; import type { z } from 'zod'; import type { SwapLimitParams } from './swapLimit.js'; -import { simpleFetch } from 'simple-typed-fetch'; +import stf from 'simple-typed-fetch'; + +const { simpleFetch } = stf; export type SwapMarketParams = Omit & { slippagePercent: BigNumber.Value diff --git a/src/OrionUnit/Exchange/withdraw.ts b/src/OrionUnit/Exchange/withdraw.ts index 0d913f9..dc46c5b 100644 --- a/src/OrionUnit/Exchange/withdraw.ts +++ b/src/OrionUnit/Exchange/withdraw.ts @@ -9,7 +9,9 @@ import { } from '../../constants/index.js'; import { denormalizeNumber, normalizeNumber } from '../../utils/index.js'; import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js'; -import { simpleFetch } from 'simple-typed-fetch'; +import stf from 'simple-typed-fetch'; + +const { simpleFetch } = stf; export type WithdrawParams = { asset: string diff --git a/src/OrionUnit/FarmingManager/index.ts b/src/OrionUnit/FarmingManager/index.ts index bcdf4c0..d591258 100644 --- a/src/OrionUnit/FarmingManager/index.ts +++ b/src/OrionUnit/FarmingManager/index.ts @@ -1,7 +1,7 @@ import { Exchange__factory, IUniswapV2Pair__factory, IUniswapV2Router__factory } from '@orionprotocol/contracts'; import { BigNumber } from 'bignumber.js'; import { ethers } from 'ethers'; -import { simpleFetch } from 'simple-typed-fetch'; +import stf from 'simple-typed-fetch'; import type OrionUnit from '../index.js'; import BalanceGuard from '../../BalanceGuard.js'; import { ADD_LIQUIDITY_GAS_LIMIT, INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION } from '../../constants/index.js'; @@ -9,6 +9,8 @@ import { denormalizeNumber, normalizeNumber } from '../../utils/index.js'; import getBalances from '../../utils/getBalances.js'; import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency.js'; +const { simpleFetch } = stf; + const ADD_LIQUIDITY_SLIPPAGE = 0.05; export type AddLiquidityParams = { diff --git a/src/__tests__/basic.test.ts b/src/__tests__/basic.test.ts index 7c69581..7882323 100644 --- a/src/__tests__/basic.test.ts +++ b/src/__tests__/basic.test.ts @@ -9,8 +9,8 @@ import { createHttpTerminator, } from 'http-terminator'; import { ethers } from 'ethers'; -import { simpleFetch } from 'simple-typed-fetch'; - +import stf from 'simple-typed-fetch'; +const { simpleFetch } = stf; jest.setTimeout(10000); const createServer = (externalHost: string) => { diff --git a/src/index.ts b/src/index.ts index 271c688..31b788d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ import { BigNumber } from 'bignumber.js'; -import { simpleFetch, fetchWithValidation } from 'simple-typed-fetch'; BigNumber.config({ EXPONENTIAL_AT: 1e+9 }); export * as config from './config/index.js'; @@ -10,4 +9,3 @@ export * as services from './services/index.js'; export * as crypt from './crypt/index.js'; export * from './constants/index.js'; export * from './types.js'; -export { simpleFetch, fetchWithValidation }; diff --git a/src/services/OrionAggregator/index.ts b/src/services/OrionAggregator/index.ts index dba6f9f..5bdb2b2 100644 --- a/src/services/OrionAggregator/index.ts +++ b/src/services/OrionAggregator/index.ts @@ -19,7 +19,9 @@ import httpToWS from '../../utils/httpToWS.js'; import { ethers } from 'ethers'; import orderSchema from './schemas/orderSchema.js'; import { exchanges } from '../../constants/index.js'; -import { fetchWithValidation } from 'simple-typed-fetch'; +import stf from 'simple-typed-fetch'; + +const { fetchWithValidation } = stf; class OrionAggregator { private readonly apiUrl: string; diff --git a/src/services/OrionBlockchain/index.ts b/src/services/OrionBlockchain/index.ts index a42ce49..64886e8 100644 --- a/src/services/OrionBlockchain/index.ts +++ b/src/services/OrionBlockchain/index.ts @@ -17,7 +17,9 @@ import type redeemOrderSchema from '../OrionAggregator/schemas/redeemOrderSchema import { sourceAtomicHistorySchema, targetAtomicHistorySchema } from './schemas/atomicHistorySchema.js'; import { makePartial } from '../../utils/index.js'; import type { networkCodes } from '../../constants/index.js'; -import { fetchWithValidation } from 'simple-typed-fetch'; +import stf from 'simple-typed-fetch'; + +const { fetchWithValidation } = stf; type IAdminAuthHeaders = { auth: string diff --git a/src/services/PriceFeed/index.ts b/src/services/PriceFeed/index.ts index a6d5345..0f3f5c3 100644 --- a/src/services/PriceFeed/index.ts +++ b/src/services/PriceFeed/index.ts @@ -1,9 +1,11 @@ -import { fetchWithValidation } from 'simple-typed-fetch'; +import stf from 'simple-typed-fetch'; import type { Exchange } from '../../types.js'; import { statisticsOverviewSchema, topPairsStatisticsSchema } from './schemas/index.js'; import candlesSchema from './schemas/candlesSchema.js'; import { PriceFeedWS } from './ws/index.js'; +const { fetchWithValidation } = stf; + class PriceFeed { private readonly apiUrl: string; diff --git a/src/services/ReferralSystem/index.ts b/src/services/ReferralSystem/index.ts index ea87bf3..ab163d2 100644 --- a/src/services/ReferralSystem/index.ts +++ b/src/services/ReferralSystem/index.ts @@ -1,4 +1,4 @@ -import { fetchWithValidation } from 'simple-typed-fetch'; +import stf from 'simple-typed-fetch'; import { errorSchema, miniStatsSchema, @@ -9,6 +9,8 @@ import { linkSchema, } from './schemas/index.js'; +const { fetchWithValidation } = stf; + type CreateLinkPayloadType = { referer: string link_option: number