@xchainjs/xchain-thorchain-query 0.1.18 → 0.2.0

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.esm.js CHANGED
@@ -9,7 +9,7 @@ import { MidgardApi, Configuration } from '@xchainjs/xchain-midgard';
9
9
  import axios from 'axios';
10
10
  import axiosRetry from 'axios-retry';
11
11
  import { AVAXChain, AssetAVAX } from '@xchainjs/xchain-avax';
12
- import { AssetBCH, BCHChain } from '@xchainjs/xchain-bitcoincash';
12
+ import { BCHChain, AssetBCH } from '@xchainjs/xchain-bitcoincash';
13
13
  import { DOGEChain, AssetDOGE } from '@xchainjs/xchain-doge';
14
14
  import { ETHChain, AssetETH } from '@xchainjs/xchain-ethereum';
15
15
  import { LTCChain, AssetLTC } from '@xchainjs/xchain-litecoin';
@@ -177,8 +177,9 @@ class CryptoAmount {
177
177
  * Represent a Liquidity Pool in Thorchain
178
178
  */
179
179
  class LiquidityPool {
180
- constructor(pool) {
180
+ constructor(pool, thornodeDetails) {
181
181
  this.pool = pool;
182
+ this.thornodeDetails = thornodeDetails;
182
183
  const asset = assetFromString(this.pool.asset);
183
184
  if (!asset)
184
185
  throw new Error(`could not parse ${this.pool.asset}`);
@@ -520,7 +521,7 @@ const calcNetworkFee = (asset, inbound) => {
520
521
  switch (asset.chain) {
521
522
  case BTCChain:
522
523
  return new CryptoAmount(baseAmount(inbound.gasRate.multipliedBy(inbound.outboundTxSize)), AssetBTC);
523
- case BTCChain:
524
+ case BCHChain:
524
525
  return new CryptoAmount(baseAmount(inbound.gasRate.multipliedBy(inbound.outboundTxSize)), AssetBCH);
525
526
  case LTCChain:
526
527
  return new CryptoAmount(baseAmount(inbound.gasRate.multipliedBy(inbound.outboundTxSize)), AssetLTC);
@@ -749,7 +750,7 @@ class Thornode {
749
750
  }
750
751
  /**
751
752
  *
752
- * @returns - thorchain pool
753
+ * @returns - thorchain pools
753
754
  */
754
755
  getPools() {
755
756
  return __awaiter(this, void 0, void 0, function* () {
@@ -765,6 +766,24 @@ class Thornode {
765
766
  throw new Error(`THORNode not responding`);
766
767
  });
767
768
  }
769
+ /**
770
+ *
771
+ * @returns - thorchain pool
772
+ */
773
+ getPool(asset) {
774
+ return __awaiter(this, void 0, void 0, function* () {
775
+ for (const api of this.poolsApi) {
776
+ try {
777
+ const pools = yield api.pool(asset);
778
+ return pools.data;
779
+ }
780
+ catch (e) {
781
+ //console.error(e)
782
+ }
783
+ }
784
+ throw new Error(`THORNode not responding`);
785
+ });
786
+ }
768
787
  /**
769
788
  *
770
789
  * @returns Thorchain constants
@@ -943,11 +962,11 @@ class Thornode {
943
962
  * @param height - block height
944
963
  * @returns quotes swap object response
945
964
  */
946
- getSwapQuote(fromAsset, toAsset, amount, destination, toleranceBps, affiliateBps, affiliate, height) {
965
+ getSwapQuote(fromAsset, toAsset, amount, destination, fromAddress, toleranceBps, affiliateBps, affiliate, height) {
947
966
  return __awaiter(this, void 0, void 0, function* () {
948
967
  for (const api of this.quoteApi) {
949
968
  try {
950
- const resp = (yield api.quoteswap(height, fromAsset, toAsset, amount, destination, toleranceBps, affiliateBps, affiliate)).data;
969
+ const resp = (yield api.quoteswap(height, fromAsset, toAsset, amount, destination, fromAddress, toleranceBps, affiliateBps, affiliate)).data;
951
970
  return resp;
952
971
  }
953
972
  catch (e) {
@@ -1088,14 +1107,14 @@ class ThorchainCache {
1088
1107
  */
1089
1108
  refereshPoolCache() {
1090
1109
  return __awaiter(this, void 0, void 0, function* () {
1091
- // const [thornodePools, midgardPools] = await Promise.all([this.thornode.getPools(), this.midgard.getPools()])
1092
- const midgardPools = yield this.midgard.getPools();
1110
+ const [thornodePools, midgardPools] = yield Promise.all([this.thornode.getPools(), this.midgard.getPools()]);
1093
1111
  const poolMap = {};
1094
1112
  if (midgardPools) {
1095
1113
  for (const pool of midgardPools) {
1096
- // const thornodePool = thornodePools.find((p) => p.asset === pool.asset)
1097
- // const decimals = thornodePool?.decimals ?? 8
1098
- const lp = new LiquidityPool(pool);
1114
+ const thornodePool = thornodePools.find((p) => p.asset === pool.asset);
1115
+ if (!thornodePool)
1116
+ throw Error(`Could not find thornode pool ${pool.asset}`);
1117
+ const lp = new LiquidityPool(pool, thornodePool);
1099
1118
  poolMap[`${lp.asset.chain}.${lp.asset.ticker}`] = lp;
1100
1119
  }
1101
1120
  this.poolCache = {
@@ -1702,6 +1721,18 @@ class ThorchainQuery {
1702
1721
  const destPool = yield this.thorchainCache.getPoolForAsset(destAsset);
1703
1722
  if (!destPool.isAvailable())
1704
1723
  errors.push(`destinationAsset ${destAsset.ticker} does not have a valid liquidity pool`);
1724
+ // check synth info on thornode pools
1725
+ try {
1726
+ const pools = yield this.thorchainCache.thornode.getPools();
1727
+ const destinationAssetPool = pools.find((pool) => pool.asset === `${destAsset.chain}.${destAsset.symbol}`);
1728
+ if (destinationAssetPool)
1729
+ if (destinationAssetPool.synth_mint_paused && destAsset.synth) {
1730
+ errors.push(`Synth supply is over cap on destinationAsset ${destAsset.ticker}, synth minting is paused`);
1731
+ }
1732
+ }
1733
+ catch (error) {
1734
+ errors.push(`Error: ${error} destination pool was not found for asset ${destAsset}`);
1735
+ }
1705
1736
  }
1706
1737
  if (sourceInboundDetails.haltedChain)
1707
1738
  errors.push(`source chain is halted`);
@@ -2270,6 +2301,7 @@ var TxType;
2270
2301
  TxType["WithdrawLP"] = "WithdrawLP";
2271
2302
  TxType["AddSaver"] = "AddSaver";
2272
2303
  TxType["WithdrawSaver"] = "WithdrawSaver";
2304
+ TxType["Refund"] = "Refund";
2273
2305
  TxType["Other"] = "Other";
2274
2306
  TxType["Unknown"] = "Unknown";
2275
2307
  })(TxType || (TxType = {}));
@@ -2299,6 +2331,12 @@ var WithdrawStatus;
2299
2331
  WithdrawStatus["Incomplete"] = "Incomplete";
2300
2332
  WithdrawStatus["Complete_Refunded"] = "Complete_Refunded";
2301
2333
  })(WithdrawStatus || (WithdrawStatus = {}));
2334
+ var RefundStatus;
2335
+ (function (RefundStatus) {
2336
+ RefundStatus["Complete"] = "Complete";
2337
+ RefundStatus["Incomplete"] = "Incomplete";
2338
+ RefundStatus["Complete_Refunded"] = "Complete_Refunded";
2339
+ })(RefundStatus || (RefundStatus = {}));
2302
2340
  var AddSaverStatus;
2303
2341
  (function (AddSaverStatus) {
2304
2342
  AddSaverStatus["Complete"] = "Complete";
@@ -2343,6 +2381,9 @@ class TransactionStage {
2343
2381
  case TxType.WithdrawSaver:
2344
2382
  yield this.checkWithdrawSaverProgress(txData, progress);
2345
2383
  break;
2384
+ case TxType.Refund:
2385
+ yield this.checkRefund(txData, progress);
2386
+ break;
2346
2387
  case TxType.Other:
2347
2388
  break;
2348
2389
  }
@@ -2429,7 +2470,9 @@ class TransactionStage {
2429
2470
  progress.txType = TxType.WithdrawSaver;
2430
2471
  if (operation.match(/withdraw|wd|-/gi) && parts[1].match(/[.]/))
2431
2472
  progress.txType = TxType.WithdrawLP;
2432
- if (operation.match(/out|refund/gi))
2473
+ if (operation.match(/refund/gi))
2474
+ progress.txType = TxType.Refund;
2475
+ if (operation.match(/out/gi))
2433
2476
  progress.txType = TxType.Other;
2434
2477
  const amount = yield this.getCryptoAmount(inboundAmount, assetIn);
2435
2478
  // find a date for when it should be competed
@@ -2560,6 +2603,42 @@ class TransactionStage {
2560
2603
  }
2561
2604
  });
2562
2605
  }
2606
+ checkRefund(txData, progress) {
2607
+ return __awaiter(this, void 0, void 0, function* () {
2608
+ if (progress.inboundObserved) {
2609
+ const lastBlockObj = yield this.thorchainCache.thornode.getLastBlock();
2610
+ // find the date in which the asset should be seen in the wallet
2611
+ const outboundHeight = txData.tx.status === 'done' ? txData.finalised_height : Number(`${txData.outbound_height}`);
2612
+ const expectedConfirmationDate = yield this.blockToDate(THORChain, txData, outboundHeight); // always pass in thorchain
2613
+ const amount = txData.tx.tx.coins[0].amount;
2614
+ const asset = assetFromStringEx(txData.tx.tx.coins[0].asset);
2615
+ const toAddress = `${txData.tx.tx.to_address}`;
2616
+ const currentHeight = lastBlockObj.find((obj) => obj.chain === asset.chain);
2617
+ console.log(currentHeight);
2618
+ const outboundBlock = Number(`${currentHeight === null || currentHeight === void 0 ? void 0 : currentHeight.last_observed_in}`);
2619
+ const finalisedHeight = Number(txData.finalised_height);
2620
+ const currentTCHeight = Number(`${currentHeight === null || currentHeight === void 0 ? void 0 : currentHeight.thorchain}`);
2621
+ const estimatedWaitTime = outboundBlock > currentTCHeight
2622
+ ? (outboundBlock - currentTCHeight) * this.chainAttributes[THORChain].avgBlockTimeInSecs +
2623
+ this.chainAttributes[asset.chain].avgBlockTimeInSecs
2624
+ : 0;
2625
+ // if the TC has process the block that the outbound tx was assigned to then its completed.
2626
+ const status = txData.tx.status === 'done' ? RefundStatus.Complete : RefundStatus.Incomplete;
2627
+ const refundAmount = yield this.getCryptoAmount(amount, asset);
2628
+ const refundInfo = {
2629
+ status,
2630
+ refundAmount,
2631
+ toAddress,
2632
+ expectedConfirmationDate,
2633
+ thorchainHeight: currentTCHeight,
2634
+ finalisedHeight,
2635
+ outboundBlock,
2636
+ estimatedWaitTime,
2637
+ };
2638
+ progress.refundInfo = refundInfo;
2639
+ }
2640
+ });
2641
+ }
2563
2642
  parseAddLpMemo(memo) {
2564
2643
  //ADD:POOL:PAIREDADDR:AFFILIATE:FEE
2565
2644
  const parts = memo.split(`:`);
@@ -2649,4 +2728,4 @@ class TransactionStage {
2649
2728
  }
2650
2729
  }
2651
2730
 
2652
- export { AddLpStatus, AddSaverStatus, CryptoAmount, InboundStatus, LiquidityPool, Midgard, SwapStatus, ThorchainCache, ThorchainQuery, Thornode, TransactionStage, TxType, WithdrawStatus, calcNetworkFee, getDoubleSwap, getLiquidityProtectionData, getLiquidityUnits, getPoolShare, getSingleSwap, getSlipOnLiquidity };
2731
+ export { AddLpStatus, AddSaverStatus, CryptoAmount, InboundStatus, LiquidityPool, Midgard, RefundStatus, SwapStatus, ThorchainCache, ThorchainQuery, Thornode, TransactionStage, TxType, WithdrawStatus, calcNetworkFee, getDoubleSwap, getLiquidityProtectionData, getLiquidityUnits, getPoolShare, getSingleSwap, getSlipOnLiquidity };
package/lib/index.js CHANGED
@@ -186,8 +186,9 @@ class CryptoAmount {
186
186
  * Represent a Liquidity Pool in Thorchain
187
187
  */
188
188
  class LiquidityPool {
189
- constructor(pool) {
189
+ constructor(pool, thornodeDetails) {
190
190
  this.pool = pool;
191
+ this.thornodeDetails = thornodeDetails;
191
192
  const asset = xchainUtil.assetFromString(this.pool.asset);
192
193
  if (!asset)
193
194
  throw new Error(`could not parse ${this.pool.asset}`);
@@ -529,7 +530,7 @@ const calcNetworkFee = (asset, inbound) => {
529
530
  switch (asset.chain) {
530
531
  case xchainBitcoin.BTCChain:
531
532
  return new CryptoAmount(xchainUtil.baseAmount(inbound.gasRate.multipliedBy(inbound.outboundTxSize)), xchainBitcoin.AssetBTC);
532
- case xchainBitcoin.BTCChain:
533
+ case xchainBitcoincash.BCHChain:
533
534
  return new CryptoAmount(xchainUtil.baseAmount(inbound.gasRate.multipliedBy(inbound.outboundTxSize)), xchainBitcoincash.AssetBCH);
534
535
  case xchainLitecoin.LTCChain:
535
536
  return new CryptoAmount(xchainUtil.baseAmount(inbound.gasRate.multipliedBy(inbound.outboundTxSize)), xchainLitecoin.AssetLTC);
@@ -758,7 +759,7 @@ class Thornode {
758
759
  }
759
760
  /**
760
761
  *
761
- * @returns - thorchain pool
762
+ * @returns - thorchain pools
762
763
  */
763
764
  getPools() {
764
765
  return __awaiter(this, void 0, void 0, function* () {
@@ -774,6 +775,24 @@ class Thornode {
774
775
  throw new Error(`THORNode not responding`);
775
776
  });
776
777
  }
778
+ /**
779
+ *
780
+ * @returns - thorchain pool
781
+ */
782
+ getPool(asset) {
783
+ return __awaiter(this, void 0, void 0, function* () {
784
+ for (const api of this.poolsApi) {
785
+ try {
786
+ const pools = yield api.pool(asset);
787
+ return pools.data;
788
+ }
789
+ catch (e) {
790
+ //console.error(e)
791
+ }
792
+ }
793
+ throw new Error(`THORNode not responding`);
794
+ });
795
+ }
777
796
  /**
778
797
  *
779
798
  * @returns Thorchain constants
@@ -952,11 +971,11 @@ class Thornode {
952
971
  * @param height - block height
953
972
  * @returns quotes swap object response
954
973
  */
955
- getSwapQuote(fromAsset, toAsset, amount, destination, toleranceBps, affiliateBps, affiliate, height) {
974
+ getSwapQuote(fromAsset, toAsset, amount, destination, fromAddress, toleranceBps, affiliateBps, affiliate, height) {
956
975
  return __awaiter(this, void 0, void 0, function* () {
957
976
  for (const api of this.quoteApi) {
958
977
  try {
959
- const resp = (yield api.quoteswap(height, fromAsset, toAsset, amount, destination, toleranceBps, affiliateBps, affiliate)).data;
978
+ const resp = (yield api.quoteswap(height, fromAsset, toAsset, amount, destination, fromAddress, toleranceBps, affiliateBps, affiliate)).data;
960
979
  return resp;
961
980
  }
962
981
  catch (e) {
@@ -1097,14 +1116,14 @@ class ThorchainCache {
1097
1116
  */
1098
1117
  refereshPoolCache() {
1099
1118
  return __awaiter(this, void 0, void 0, function* () {
1100
- // const [thornodePools, midgardPools] = await Promise.all([this.thornode.getPools(), this.midgard.getPools()])
1101
- const midgardPools = yield this.midgard.getPools();
1119
+ const [thornodePools, midgardPools] = yield Promise.all([this.thornode.getPools(), this.midgard.getPools()]);
1102
1120
  const poolMap = {};
1103
1121
  if (midgardPools) {
1104
1122
  for (const pool of midgardPools) {
1105
- // const thornodePool = thornodePools.find((p) => p.asset === pool.asset)
1106
- // const decimals = thornodePool?.decimals ?? 8
1107
- const lp = new LiquidityPool(pool);
1123
+ const thornodePool = thornodePools.find((p) => p.asset === pool.asset);
1124
+ if (!thornodePool)
1125
+ throw Error(`Could not find thornode pool ${pool.asset}`);
1126
+ const lp = new LiquidityPool(pool, thornodePool);
1108
1127
  poolMap[`${lp.asset.chain}.${lp.asset.ticker}`] = lp;
1109
1128
  }
1110
1129
  this.poolCache = {
@@ -1711,6 +1730,18 @@ class ThorchainQuery {
1711
1730
  const destPool = yield this.thorchainCache.getPoolForAsset(destAsset);
1712
1731
  if (!destPool.isAvailable())
1713
1732
  errors.push(`destinationAsset ${destAsset.ticker} does not have a valid liquidity pool`);
1733
+ // check synth info on thornode pools
1734
+ try {
1735
+ const pools = yield this.thorchainCache.thornode.getPools();
1736
+ const destinationAssetPool = pools.find((pool) => pool.asset === `${destAsset.chain}.${destAsset.symbol}`);
1737
+ if (destinationAssetPool)
1738
+ if (destinationAssetPool.synth_mint_paused && destAsset.synth) {
1739
+ errors.push(`Synth supply is over cap on destinationAsset ${destAsset.ticker}, synth minting is paused`);
1740
+ }
1741
+ }
1742
+ catch (error) {
1743
+ errors.push(`Error: ${error} destination pool was not found for asset ${destAsset}`);
1744
+ }
1714
1745
  }
1715
1746
  if (sourceInboundDetails.haltedChain)
1716
1747
  errors.push(`source chain is halted`);
@@ -2278,6 +2309,7 @@ class ThorchainQuery {
2278
2309
  TxType["WithdrawLP"] = "WithdrawLP";
2279
2310
  TxType["AddSaver"] = "AddSaver";
2280
2311
  TxType["WithdrawSaver"] = "WithdrawSaver";
2312
+ TxType["Refund"] = "Refund";
2281
2313
  TxType["Other"] = "Other";
2282
2314
  TxType["Unknown"] = "Unknown";
2283
2315
  })(exports.TxType || (exports.TxType = {}));
@@ -2303,6 +2335,11 @@ class ThorchainQuery {
2303
2335
  WithdrawStatus["Incomplete"] = "Incomplete";
2304
2336
  WithdrawStatus["Complete_Refunded"] = "Complete_Refunded";
2305
2337
  })(exports.WithdrawStatus || (exports.WithdrawStatus = {}));
2338
+ (function (RefundStatus) {
2339
+ RefundStatus["Complete"] = "Complete";
2340
+ RefundStatus["Incomplete"] = "Incomplete";
2341
+ RefundStatus["Complete_Refunded"] = "Complete_Refunded";
2342
+ })(exports.RefundStatus || (exports.RefundStatus = {}));
2306
2343
  (function (AddSaverStatus) {
2307
2344
  AddSaverStatus["Complete"] = "Complete";
2308
2345
  AddSaverStatus["Complete_Refunded"] = "Complete_Refunded";
@@ -2346,6 +2383,9 @@ class TransactionStage {
2346
2383
  case exports.TxType.WithdrawSaver:
2347
2384
  yield this.checkWithdrawSaverProgress(txData, progress);
2348
2385
  break;
2386
+ case exports.TxType.Refund:
2387
+ yield this.checkRefund(txData, progress);
2388
+ break;
2349
2389
  case exports.TxType.Other:
2350
2390
  break;
2351
2391
  }
@@ -2432,7 +2472,9 @@ class TransactionStage {
2432
2472
  progress.txType = exports.TxType.WithdrawSaver;
2433
2473
  if (operation.match(/withdraw|wd|-/gi) && parts[1].match(/[.]/))
2434
2474
  progress.txType = exports.TxType.WithdrawLP;
2435
- if (operation.match(/out|refund/gi))
2475
+ if (operation.match(/refund/gi))
2476
+ progress.txType = exports.TxType.Refund;
2477
+ if (operation.match(/out/gi))
2436
2478
  progress.txType = exports.TxType.Other;
2437
2479
  const amount = yield this.getCryptoAmount(inboundAmount, assetIn);
2438
2480
  // find a date for when it should be competed
@@ -2563,6 +2605,42 @@ class TransactionStage {
2563
2605
  }
2564
2606
  });
2565
2607
  }
2608
+ checkRefund(txData, progress) {
2609
+ return __awaiter(this, void 0, void 0, function* () {
2610
+ if (progress.inboundObserved) {
2611
+ const lastBlockObj = yield this.thorchainCache.thornode.getLastBlock();
2612
+ // find the date in which the asset should be seen in the wallet
2613
+ const outboundHeight = txData.tx.status === 'done' ? txData.finalised_height : Number(`${txData.outbound_height}`);
2614
+ const expectedConfirmationDate = yield this.blockToDate(xchainThorchain.THORChain, txData, outboundHeight); // always pass in thorchain
2615
+ const amount = txData.tx.tx.coins[0].amount;
2616
+ const asset = xchainUtil.assetFromStringEx(txData.tx.tx.coins[0].asset);
2617
+ const toAddress = `${txData.tx.tx.to_address}`;
2618
+ const currentHeight = lastBlockObj.find((obj) => obj.chain === asset.chain);
2619
+ console.log(currentHeight);
2620
+ const outboundBlock = Number(`${currentHeight === null || currentHeight === void 0 ? void 0 : currentHeight.last_observed_in}`);
2621
+ const finalisedHeight = Number(txData.finalised_height);
2622
+ const currentTCHeight = Number(`${currentHeight === null || currentHeight === void 0 ? void 0 : currentHeight.thorchain}`);
2623
+ const estimatedWaitTime = outboundBlock > currentTCHeight
2624
+ ? (outboundBlock - currentTCHeight) * this.chainAttributes[xchainThorchain.THORChain].avgBlockTimeInSecs +
2625
+ this.chainAttributes[asset.chain].avgBlockTimeInSecs
2626
+ : 0;
2627
+ // if the TC has process the block that the outbound tx was assigned to then its completed.
2628
+ const status = txData.tx.status === 'done' ? exports.RefundStatus.Complete : exports.RefundStatus.Incomplete;
2629
+ const refundAmount = yield this.getCryptoAmount(amount, asset);
2630
+ const refundInfo = {
2631
+ status,
2632
+ refundAmount,
2633
+ toAddress,
2634
+ expectedConfirmationDate,
2635
+ thorchainHeight: currentTCHeight,
2636
+ finalisedHeight,
2637
+ outboundBlock,
2638
+ estimatedWaitTime,
2639
+ };
2640
+ progress.refundInfo = refundInfo;
2641
+ }
2642
+ });
2643
+ }
2566
2644
  parseAddLpMemo(memo) {
2567
2645
  //ADD:POOL:PAIREDADDR:AFFILIATE:FEE
2568
2646
  const parts = memo.split(`:`);
@@ -1,4 +1,5 @@
1
1
  import { PoolDetail } from '@xchainjs/xchain-midgard/lib';
2
+ import { Pool } from '@xchainjs/xchain-thornode/lib';
2
3
  import { Asset, BaseAmount } from '@xchainjs/xchain-util';
3
4
  import { BigNumber } from 'bignumber.js';
4
5
  /**
@@ -6,12 +7,13 @@ import { BigNumber } from 'bignumber.js';
6
7
  */
7
8
  export declare class LiquidityPool {
8
9
  readonly pool: PoolDetail;
10
+ readonly thornodeDetails: Pool;
9
11
  readonly assetBalance: BaseAmount;
10
12
  readonly runeBalance: BaseAmount;
11
13
  readonly asset: Asset;
12
14
  readonly assetString: string;
13
15
  readonly runeToAssetRatio: BigNumber;
14
16
  readonly assetToRuneRatio: BigNumber;
15
- constructor(pool: PoolDetail);
17
+ constructor(pool: PoolDetail, thornodeDetails: Pool);
16
18
  isAvailable(): boolean;
17
19
  }
@@ -9,6 +9,7 @@ export declare enum TxType {
9
9
  WithdrawLP = "WithdrawLP",
10
10
  AddSaver = "AddSaver",
11
11
  WithdrawSaver = "WithdrawSaver",
12
+ Refund = "Refund",
12
13
  Other = "Other",
13
14
  Unknown = "Unknown"
14
15
  }
@@ -34,6 +35,11 @@ export declare enum WithdrawStatus {
34
35
  Incomplete = "Incomplete",
35
36
  Complete_Refunded = "Complete_Refunded"
36
37
  }
38
+ export declare enum RefundStatus {
39
+ Complete = "Complete",
40
+ Incomplete = "Incomplete",
41
+ Complete_Refunded = "Complete_Refunded"
42
+ }
37
43
  export declare enum AddSaverStatus {
38
44
  Complete = "Complete",
39
45
  Complete_Refunded = "Complete_Refunded",
@@ -76,6 +82,16 @@ export declare type WithdrawInfo = {
76
82
  outboundHeight: number;
77
83
  estimatedWaitTime: number;
78
84
  };
85
+ export declare type RefundInfo = {
86
+ status: RefundStatus;
87
+ refundAmount: CryptoAmount;
88
+ toAddress: string;
89
+ expectedConfirmationDate: Date;
90
+ finalisedHeight: number;
91
+ thorchainHeight: number;
92
+ outboundBlock: number;
93
+ estimatedWaitTime: number;
94
+ };
79
95
  export declare type AddSaverInfo = {
80
96
  status: AddSaverStatus;
81
97
  assetTx?: InboundTx;
@@ -99,6 +115,7 @@ export declare type TXProgress = {
99
115
  addSaverInfo?: AddSaverInfo;
100
116
  withdrawLpInfo?: WithdrawInfo;
101
117
  withdrawSaverInfo?: WithdrawSaverInfo;
118
+ refundInfo?: RefundInfo;
102
119
  };
103
120
  export declare class TransactionStage {
104
121
  readonly thorchainCache: ThorchainCache;
@@ -113,6 +130,7 @@ export declare class TransactionStage {
113
130
  private checkWithdrawLpProgress;
114
131
  private checkAddSaverProgress;
115
132
  private checkWithdrawSaverProgress;
133
+ private checkRefund;
116
134
  private parseAddLpMemo;
117
135
  private parseWithdrawLpMemo;
118
136
  /**
@@ -61,9 +61,14 @@ export declare class Thornode {
61
61
  getLastBlock(height?: number): Promise<LastBlock[]>;
62
62
  /**
63
63
  *
64
- * @returns - thorchain pool
64
+ * @returns - thorchain pools
65
65
  */
66
66
  getPools(): Promise<Pool[]>;
67
+ /**
68
+ *
69
+ * @returns - thorchain pool
70
+ */
71
+ getPool(asset: string): Promise<Pool>;
67
72
  /**
68
73
  *
69
74
  * @returns Thorchain constants
@@ -135,5 +140,5 @@ export declare class Thornode {
135
140
  * @param height - block height
136
141
  * @returns quotes swap object response
137
142
  */
138
- getSwapQuote(fromAsset: string, toAsset: string, amount: number, destination: string, toleranceBps: number, affiliateBps: number, affiliate: string, height?: number): Promise<QuoteSwapResponse>;
143
+ getSwapQuote(fromAsset: string, toAsset: string, amount: number, destination: string, fromAddress: string, toleranceBps: number, affiliateBps: number, affiliate: string, height?: number): Promise<QuoteSwapResponse>;
139
144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain-query",
3
- "version": "0.1.18",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "description": "Thorchain query module that is resposible for estimating swap calculations and add/remove liquidity for thorchain ",
6
6
  "keywords": [
@@ -33,18 +33,18 @@
33
33
  "postversion": "git push --follow-tags"
34
34
  },
35
35
  "devDependencies": {
36
- "@xchainjs/xchain-avax": "^0.1.3",
37
- "@xchainjs/xchain-binance": "^5.6.6",
38
- "@xchainjs/xchain-bitcoin": "^0.20.7",
39
- "@xchainjs/xchain-bitcoincash": "^0.15.6",
36
+ "@xchainjs/xchain-avax": "^0.1.4",
37
+ "@xchainjs/xchain-binance": "^5.6.7",
38
+ "@xchainjs/xchain-bitcoin": "^0.21.0",
39
+ "@xchainjs/xchain-bitcoincash": "^0.15.8",
40
40
  "@xchainjs/xchain-client": "^0.13.5",
41
- "@xchainjs/xchain-cosmos": "^0.20.6",
42
- "@xchainjs/xchain-doge": "^0.5.6",
43
- "@xchainjs/xchain-ethereum": "^0.27.6",
44
- "@xchainjs/xchain-litecoin": "^0.10.8",
45
- "@xchainjs/xchain-midgard": "^0.4.2",
46
- "@xchainjs/xchain-thorchain": "^0.27.7",
47
- "@xchainjs/xchain-thornode": "^0.2.0",
41
+ "@xchainjs/xchain-cosmos": "^0.20.8",
42
+ "@xchainjs/xchain-doge": "^0.5.9",
43
+ "@xchainjs/xchain-ethereum": "^0.27.7",
44
+ "@xchainjs/xchain-litecoin": "^0.11.0",
45
+ "@xchainjs/xchain-midgard": "^0.4.3",
46
+ "@xchainjs/xchain-thorchain": "^0.27.9",
47
+ "@xchainjs/xchain-thornode": "^0.2.1",
48
48
  "@xchainjs/xchain-util": "^0.12.0",
49
49
  "axios": "^0.25.0",
50
50
  "axios-retry": "^3.2.5",
@@ -52,18 +52,18 @@
52
52
  "rimraf": "~3.0.2"
53
53
  },
54
54
  "peerDependencies": {
55
- "@xchainjs/xchain-avax": "^0.1.3",
56
- "@xchainjs/xchain-binance": "^5.6.6",
57
- "@xchainjs/xchain-bitcoincash": "^0.15.6",
58
- "@xchainjs/xchain-cosmos": "^0.20.6",
59
- "@xchainjs/xchain-doge": "^0.5.6",
60
- "@xchainjs/xchain-ethereum": "^0.27.6",
61
- "@xchainjs/xchain-bitcoin": "^0.20.7",
62
- "@xchainjs/xchain-litecoin": "^0.10.8",
55
+ "@xchainjs/xchain-avax": "^0.1.4",
56
+ "@xchainjs/xchain-binance": "^5.6.7",
57
+ "@xchainjs/xchain-bitcoin": "^0.21.0",
58
+ "@xchainjs/xchain-bitcoincash": "^0.15.8",
63
59
  "@xchainjs/xchain-client": "^0.13.5",
64
- "@xchainjs/xchain-midgard": "^0.4.2",
65
- "@xchainjs/xchain-thorchain": "^0.27.7",
66
- "@xchainjs/xchain-thornode": "^0.2.0",
60
+ "@xchainjs/xchain-cosmos": "^0.20.8",
61
+ "@xchainjs/xchain-doge": "^0.5.9",
62
+ "@xchainjs/xchain-ethereum": "^0.27.7",
63
+ "@xchainjs/xchain-litecoin": "^0.11.0",
64
+ "@xchainjs/xchain-midgard": "^0.4.3",
65
+ "@xchainjs/xchain-thorchain": "^0.27.9",
66
+ "@xchainjs/xchain-thornode": "^0.2.1",
67
67
  "@xchainjs/xchain-util": "^0.12.0",
68
68
  "axios": "^0.25.0",
69
69
  "axios-retry": "^3.2.5",