@xchainjs/xchain-thorchain-query 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -5,4 +5,3 @@ export * from './liquidity-pool';
5
5
  export * from './chain-defaults';
6
6
  export * from './types';
7
7
  export * from './utils';
8
- export * from './chain-defaults';
package/lib/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { assetFromString, baseAmount, assetFromStringEx, assetToString, CryptoAmount, isSynthAsset, AssetCryptoAmount, eqAsset, CachedValue, isTradeAsset, isSecuredAsset, assetToBase, assetAmount, TRADE_ASSET_DELIMITER, SYNTH_ASSET_DELIMITER, SECURED_ASSET_DELIMITER, TOKEN_ASSET_DELIMITER } from '@xchainjs/xchain-util';
2
- import { BigNumber } from 'bignumber.js';
2
+ import BigNumber from 'bignumber.js';
3
3
  import { MidgardQuery } from '@xchainjs/xchain-midgard-query';
4
4
  import { Network } from '@xchainjs/xchain-client';
5
5
  import { TransactionsApi, Configuration, QueueApi, NetworkApi, PoolsApi, LiquidityProvidersApi, SaversApi, QuoteApi, MimirApi, ThornamesApi, TradeUnitApi, TradeUnitsApi, TradeAccountApi, TradeAccountsApi, RUNEPoolApi } from '@xchainjs/xchain-thornode';
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var xchainUtil = require('@xchainjs/xchain-util');
4
- var bignumber_js = require('bignumber.js');
4
+ var BigNumber = require('bignumber.js');
5
5
  var xchainMidgardQuery = require('@xchainjs/xchain-midgard-query');
6
6
  var xchainClient = require('@xchainjs/xchain-client');
7
7
  var xchainThornode = require('@xchainjs/xchain-thornode');
@@ -10,6 +10,7 @@ var axiosRetry = require('axios-retry');
10
10
 
11
11
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
12
 
13
+ var BigNumber__default = /*#__PURE__*/_interopDefault(BigNumber);
13
14
  var axios__default = /*#__PURE__*/_interopDefault(axios);
14
15
  var axiosRetry__default = /*#__PURE__*/_interopDefault(axiosRetry);
15
16
 
@@ -307,7 +308,7 @@ const calcOutboundFee = (asset, inbound) => {
307
308
  */
308
309
  const getLiquidityUnits = (liquidity, pool) => {
309
310
  const baseAmount8decimals = getBaseAmountWithDiffDecimals(liquidity.asset, 8);
310
- const P = new bignumber_js.BigNumber(pool.thornodeDetails.LP_units);
311
+ const P = new BigNumber__default.default(pool.thornodeDetails.LP_units);
311
312
  const r = liquidity.rune.baseAmount.amount();
312
313
  const a = baseAmount8decimals;
313
314
  const R = pool.runeBalance.amount();
@@ -382,7 +383,7 @@ const getLiquidityProtectionData = (depositValue, poolShare, block) => {
382
383
  const fractionOfFullILPProtection = (currentHeight - heightLastAdded) / blocksforfullprotection;
383
384
  const protectionProgress = Math.min(fractionOfFullILPProtection, 1); // percentage of entitlement, max 100%
384
385
  const result = coverage.times(protectionProgress); // impermanent loss protection result
385
- const maxILP = result.lt(0) ? new bignumber_js.BigNumber(0) : result; // max negative ILP to 0
386
+ const maxILP = result.lt(0) ? new BigNumber__default.default(0) : result; // max negative ILP to 0
386
387
  const ILProtection = {
387
388
  ILProtection: new xchainUtil.CryptoAmount(xchainUtil.baseAmount(maxILP), AssetRuneNative),
388
389
  totalDays: (fractionOfFullILPProtection * 100).toFixed(2),
@@ -969,7 +970,7 @@ class Thornode {
969
970
  }
970
971
 
971
972
  // Constants
972
- const SAME_ASSET_EXCHANGE_RATE = new bignumber_js.BigNumber(1);
973
+ const SAME_ASSET_EXCHANGE_RATE = new BigNumber__default.default(1);
973
974
  const TEN_MINUTES = 10 * 60 * 1000;
974
975
  // Default instances
975
976
  const defaultThornode = new Thornode();
@@ -1125,10 +1126,10 @@ class ThorchainCache {
1125
1126
  chain: chain,
1126
1127
  address: inbound.address,
1127
1128
  router: inbound.router,
1128
- gasRate: new bignumber_js.BigNumber(inbound.gas_rate),
1129
+ gasRate: new BigNumber__default.default(inbound.gas_rate),
1129
1130
  gasRateUnits: inbound.gas_rate_units,
1130
- outboundTxSize: new bignumber_js.BigNumber(inbound.outbound_tx_size),
1131
- outboundFee: new bignumber_js.BigNumber(inbound.outbound_fee),
1131
+ outboundTxSize: new BigNumber__default.default(inbound.outbound_tx_size),
1132
+ outboundFee: new BigNumber__default.default(inbound.outbound_fee),
1132
1133
  haltedChain: (inbound === null || inbound === void 0 ? void 0 : inbound.halted) || !!mimirDetails[`HALT${chain}CHAIN`] || !!mimirDetails['HALTCHAINGLOBAL'],
1133
1134
  haltedTrading: !!mimirDetails['HALTTRADING'] || !!mimirDetails[`HALT${chain}TRADING`],
1134
1135
  haltedLP: !!mimirDetails['PAUSELP'] || !!mimirDetails[`PAUSELP${chain}`],
@@ -1140,10 +1141,10 @@ class ThorchainCache {
1140
1141
  chain: THORChain,
1141
1142
  address: '',
1142
1143
  router: '',
1143
- gasRate: new bignumber_js.BigNumber(0),
1144
+ gasRate: new BigNumber__default.default(0),
1144
1145
  gasRateUnits: '',
1145
- outboundTxSize: new bignumber_js.BigNumber(0),
1146
- outboundFee: new bignumber_js.BigNumber(0),
1146
+ outboundTxSize: new BigNumber__default.default(0),
1147
+ outboundFee: new BigNumber__default.default(0),
1147
1148
  haltedChain: false,
1148
1149
  haltedTrading: !!mimirDetails['HALTTRADING'],
1149
1150
  haltedLP: false, //
@@ -1490,7 +1491,7 @@ class ThorchainQuery {
1490
1491
  // Create unit data
1491
1492
  const unitData = {
1492
1493
  liquidityUnits: lpUnits,
1493
- totalUnits: new bignumber_js.BigNumber(assetPool.thornodeDetails.LP_units),
1494
+ totalUnits: new BigNumber__default.default(assetPool.thornodeDetails.LP_units),
1494
1495
  };
1495
1496
  // Calculate pool share
1496
1497
  const poolShare = getPoolShare(unitData, assetPool);
@@ -1558,8 +1559,8 @@ class ThorchainQuery {
1558
1559
  throw Error(`Could not get block data`);
1559
1560
  // Pools total units & Lp's total units
1560
1561
  const unitData = {
1561
- totalUnits: new bignumber_js.BigNumber(poolAsset.thornodeDetails.LP_units),
1562
- liquidityUnits: new bignumber_js.BigNumber(liquidityProvider.units),
1562
+ totalUnits: new BigNumber__default.default(poolAsset.thornodeDetails.LP_units),
1563
+ liquidityUnits: new BigNumber__default.default(liquidityProvider.units),
1563
1564
  };
1564
1565
  const networkValues = yield this.thorchainCache.thornode.getNetworkValues();
1565
1566
  // Create block object
@@ -1634,8 +1635,8 @@ class ThorchainQuery {
1634
1635
  const assetPool = yield this.thorchainCache.getPoolForAsset(params.asset);
1635
1636
  // Calculate pool share
1636
1637
  const poolShare = getPoolShare({
1637
- liquidityUnits: new bignumber_js.BigNumber(memberDetail.position.units),
1638
- totalUnits: new bignumber_js.BigNumber(assetPool.thornodeDetails.LP_units),
1638
+ liquidityUnits: new BigNumber__default.default(memberDetail.position.units),
1639
+ totalUnits: new BigNumber__default.default(assetPool.thornodeDetails.LP_units),
1639
1640
  }, assetPool);
1640
1641
  // Calculate slip on liquidity removal
1641
1642
  const slip = getSlipOnLiquidity({
@@ -1,6 +1,6 @@
1
- import { Pool } from '@xchainjs/xchain-thornode/lib';
1
+ import { Pool } from '@xchainjs/xchain-thornode';
2
2
  import { Asset, BaseAmount, TokenAsset } from '@xchainjs/xchain-util';
3
- import { BigNumber } from 'bignumber.js';
3
+ import type BigNumber from 'bignumber.js';
4
4
  /**
5
5
  * Represents a Liquidity Pool in Thorchain
6
6
  */
@@ -1,6 +1,6 @@
1
1
  import { MidgardQuery } from '@xchainjs/xchain-midgard-query';
2
2
  import { Address, Asset, Chain, CryptoAmount, SecuredAsset, SynthAsset, TokenAsset, TradeAsset } from '@xchainjs/xchain-util';
3
- import { BigNumber } from 'bignumber.js';
3
+ import BigNumber from 'bignumber.js';
4
4
  import { LiquidityPool } from './liquidity-pool';
5
5
  import { InboundDetail } from './types';
6
6
  import { Thornode } from './utils/thornode';
package/lib/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { FeeOption, TxHash } from '@xchainjs/xchain-client';
2
2
  import { LiquidityProviderSummary } from '@xchainjs/xchain-thornode';
3
3
  import { Address, Asset, AssetCryptoAmount, BaseAmount, Chain, CryptoAmount, SecuredAsset, SynthAsset, TokenAsset, TradeAsset, TradeCryptoAmount } from '@xchainjs/xchain-util';
4
- import { BigNumber } from 'bignumber.js';
4
+ import type BigNumber from 'bignumber.js';
5
5
  export type CompatibleAsset = Asset | TokenAsset | SynthAsset | TradeAsset | SecuredAsset;
6
6
  /**
7
7
  * Represents the total fees associated with a swap.
@@ -1,4 +1,4 @@
1
- import { BigNumber } from 'bignumber.js';
1
+ import BigNumber from 'bignumber.js';
2
2
  import { LiquidityPool } from '../liquidity-pool';
3
3
  import { Block, ILProtectionData, LiquidityToAdd, PoolShareDetail, PostionDepositValue, UnitData } from '../types';
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { Asset, AssetCryptoAmount, Chain, CryptoAmount } from '@xchainjs/xchain-util';
2
- import { BigNumber } from 'bignumber.js';
2
+ import type BigNumber from 'bignumber.js';
3
3
  import { CompatibleAsset, InboundDetail } from '../types';
4
4
  export declare const getBaseAmountWithDiffDecimals: (inputAmount: CryptoAmount, outDecimals: number) => BigNumber;
5
5
  export declare const getCryptoAmountWithNotation: <T extends CompatibleAsset>(amount: CryptoAmount<T>, notation: number) => CryptoAmount<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain-query",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "license": "MIT",
5
5
  "description": "Thorchain query module that is responsible for estimating swap calculations and add/remove liquidity for thorchain ",
6
6
  "keywords": [
@@ -28,15 +28,15 @@
28
28
  "build": "yarn clean && rollup -c --bundleConfigAsCjs",
29
29
  "build:release": "yarn exec rm -rf release && yarn pack && yarn exec \"mkdir release && tar zxvf package.tgz --directory release && rm package.tgz\"",
30
30
  "test": "jest",
31
- "e2e": "jest --config jest.config.e2e.js",
31
+ "e2e": "jest --config jest.config.e2e.mjs",
32
32
  "lint": "eslint \"{src,__tests__}/**/*.ts\" --fix --max-warnings 0",
33
33
  "postversion": "git push --follow-tags"
34
34
  },
35
35
  "dependencies": {
36
- "@xchainjs/xchain-client": "2.0.2",
37
- "@xchainjs/xchain-midgard-query": "2.0.2",
38
- "@xchainjs/xchain-thornode": "1.0.2",
39
- "@xchainjs/xchain-util": "2.0.1",
36
+ "@xchainjs/xchain-client": "2.0.4",
37
+ "@xchainjs/xchain-midgard-query": "2.0.4",
38
+ "@xchainjs/xchain-thornode": "1.0.3",
39
+ "@xchainjs/xchain-util": "2.0.3",
40
40
  "axios": "1.8.4",
41
41
  "axios-retry": "3.2.5",
42
42
  "bignumber.js": "^9.0.0"