mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-17 19:35:11 +03:00
Fix
This commit is contained in:
@@ -13,7 +13,7 @@ import { normalizeNumber } from '../../utils';
|
||||
import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency';
|
||||
import simpleFetch from '../../simpleFetch';
|
||||
|
||||
export interface DepositParams {
|
||||
export type DepositParams = {
|
||||
asset: string
|
||||
amount: BigNumber.Value
|
||||
signer: ethers.Signer
|
||||
|
||||
@@ -8,7 +8,7 @@ import { type OrionBlockchain } from '../../services/OrionBlockchain';
|
||||
import simpleFetch from '../../simpleFetch';
|
||||
import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency';
|
||||
|
||||
export interface GetSwapInfoParams {
|
||||
export type GetSwapInfoParams = {
|
||||
type: 'exactSpend' | 'exactReceive'
|
||||
assetIn: string
|
||||
assetOut: string
|
||||
@@ -115,7 +115,7 @@ export default async function getSwapInfo({
|
||||
};
|
||||
}
|
||||
|
||||
if (swapInfo.orderInfo != null) {
|
||||
if (swapInfo.orderInfo !== null) {
|
||||
const [baseAssetName] = swapInfo.orderInfo.assetPair.split('-');
|
||||
if (baseAssetName === undefined) throw new Error('Base asset name is undefined');
|
||||
const baseAssetAddress = assetToAddress[baseAssetName];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type OrionUnit from '..';
|
||||
import deposit, { type DepositParams } from './deposit';
|
||||
import getSwapInfo, { type GetSwapInfoParams } from './getSwapInfo';
|
||||
import swapMarket, { type Swap, type SwapMarketParams } from './swapMarket';
|
||||
import swapMarket, { type SwapMarketParams } from './swapMarket';
|
||||
import withdraw, { type WithdrawParams } from './withdraw';
|
||||
|
||||
type PureSwapMarketParams = Omit<SwapMarketParams, 'orionUnit'>
|
||||
@@ -16,7 +16,7 @@ export default class Exchange {
|
||||
this.orionUnit = orionUnit;
|
||||
}
|
||||
|
||||
public swapMarket(params: PureSwapMarketParams): Promise<Swap> {
|
||||
public swapMarket(params: PureSwapMarketParams) {
|
||||
return swapMarket({
|
||||
...params,
|
||||
orionUnit: this.orionUnit,
|
||||
|
||||
@@ -11,7 +11,7 @@ import { INTERNAL_ORION_PRECISION, NATIVE_CURRENCY_PRECISION, SWAP_THROUGH_ORION
|
||||
import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency';
|
||||
import simpleFetch from '../../simpleFetch';
|
||||
|
||||
export interface SwapMarketParams {
|
||||
export type SwapMarketParams = {
|
||||
type: 'exactSpend' | 'exactReceive'
|
||||
assetIn: string
|
||||
assetOut: string
|
||||
@@ -31,12 +31,12 @@ export interface SwapMarketParams {
|
||||
}
|
||||
}
|
||||
|
||||
interface AggregatorOrder {
|
||||
type AggregatorOrder = {
|
||||
through: 'aggregator'
|
||||
id: string
|
||||
}
|
||||
|
||||
interface PoolSwap {
|
||||
type PoolSwap = {
|
||||
through: 'orion_pool'
|
||||
txHash: string
|
||||
}
|
||||
@@ -54,7 +54,7 @@ export default async function swapMarket({
|
||||
orionUnit,
|
||||
options,
|
||||
}: SwapMarketParams): Promise<Swap> {
|
||||
if ((options?.developer) != null) options.logger?.('YOU SPECIFIED A DEVELOPER OPTIONS. BE CAREFUL!');
|
||||
if (options?.developer) options.logger?.('YOU SPECIFIED A DEVELOPER OPTIONS. BE CAREFUL!');
|
||||
if (amount === '') throw new Error('Amount can not be empty');
|
||||
if (assetIn === '') throw new Error('AssetIn can not be empty');
|
||||
if (assetOut === '') throw new Error('AssetOut can not be empty');
|
||||
@@ -183,7 +183,7 @@ export default async function swapMarket({
|
||||
|
||||
if (route === 'pool') {
|
||||
let factoryAddress: string | undefined;
|
||||
if ((factories != null) && firstSwapExchange !== undefined) {
|
||||
if (factories && firstSwapExchange !== undefined) {
|
||||
factoryAddress = factories[firstSwapExchange];
|
||||
if (factoryAddress !== undefined) options?.logger?.(`Factory address is ${factoryAddress}. Exchange is ${firstSwapExchange}`);
|
||||
}
|
||||
@@ -242,7 +242,7 @@ export default async function swapMarket({
|
||||
|
||||
let value = new BigNumber(0);
|
||||
const denormalizedAssetInExchangeBalance = balances[assetIn]?.exchange;
|
||||
if (denormalizedAssetInExchangeBalance == null) throw new Error(`Asset '${assetIn}' exchange balance is not found`);
|
||||
if (denormalizedAssetInExchangeBalance === undefined) throw new Error(`Asset '${assetIn}' exchange balance is not found`);
|
||||
if (assetIn === nativeCryptocurrency && amountSpendBN.gt(denormalizedAssetInExchangeBalance)) {
|
||||
value = amountSpendBN.minus(denormalizedAssetInExchangeBalance);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { normalizeNumber } from '../../utils';
|
||||
import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency';
|
||||
import simpleFetch from '../../simpleFetch';
|
||||
|
||||
export interface WithdrawParams {
|
||||
export type WithdrawParams = {
|
||||
asset: string
|
||||
amount: BigNumber.Value
|
||||
signer: ethers.Signer
|
||||
|
||||
@@ -11,14 +11,14 @@ import getNativeCryptocurrency from '../../utils/getNativeCryptocurrency';
|
||||
|
||||
const ADD_LIQUIDITY_SLIPPAGE = 0.05;
|
||||
|
||||
export interface AddLiquidityParams {
|
||||
export type AddLiquidityParams = {
|
||||
poolName: string
|
||||
amountAsset: string
|
||||
amount: BigNumber.Value
|
||||
signer: ethers.Signer
|
||||
}
|
||||
|
||||
export interface RemoveAllLiquidityParams {
|
||||
export type RemoveAllLiquidityParams = {
|
||||
poolName: string
|
||||
signer: ethers.Signer
|
||||
}
|
||||
@@ -90,7 +90,7 @@ export default class FarmingManager {
|
||||
|
||||
const poolsConfig = await simpleFetch(this.orionUnit.orionBlockchain.getPoolsConfig)();
|
||||
const pool = poolsConfig.pools[poolName];
|
||||
if (pool == null) throw new Error(`Pool ${poolName} not found`);
|
||||
if (pool === undefined) throw new Error(`Pool ${poolName} not found`);
|
||||
|
||||
const pairContract = IUniswapV2Pair__factory
|
||||
.connect(pool.lpTokenAddress, this.orionUnit.provider);
|
||||
@@ -183,7 +183,7 @@ export default class FarmingManager {
|
||||
|
||||
if (assetAIsNativeCurrency || assetBIsNativeCurrency) {
|
||||
const contractBalance = balances[nativeCryptocurrency]?.exchange;
|
||||
if (contractBalance == null) throw new Error(`No balance for '${nativeCryptocurrency}'`);
|
||||
if (contractBalance === undefined) throw new Error(`No balance for '${nativeCryptocurrency}'`);
|
||||
const nativeAssetAmount = assetBIsNativeCurrency ? assetBAmount : assetAAmount;
|
||||
|
||||
if (nativeAssetAmount.gt(contractBalance)) {
|
||||
@@ -242,7 +242,7 @@ export default class FarmingManager {
|
||||
|
||||
const poolsConfig = await simpleFetch(this.orionUnit.orionBlockchain.getPoolsConfig)();
|
||||
const pool = poolsConfig.pools[poolName];
|
||||
if (pool == null) throw new Error(`Pool ${poolName} not found`);
|
||||
if (pool === undefined) throw new Error(`Pool ${poolName} not found`);
|
||||
|
||||
const walletAddress = await signer.getAddress();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user