@xchainjs/xchain-thorchain-query 0.7.6 → 0.7.8

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
@@ -129,6 +129,7 @@ const AVAXChain = 'AVAX';
129
129
  const MAYAChain = 'MAYA';
130
130
  const BSCChain = 'BSC';
131
131
  const THORChain = 'THOR';
132
+ const THORCHAIN_DECIMAL = 8;
132
133
  const isAssetRuneNative = (asset) => assetToString(asset) === assetToString(AssetRuneNative);
133
134
 
134
135
  const getBaseAmountWithDiffDecimals = (inputAmount, outDecimals) => {
@@ -2195,6 +2196,46 @@ class ThorchainQuery {
2195
2196
  return inboundDetails[chain];
2196
2197
  });
2197
2198
  }
2199
+ /**
2200
+ * Get addresses swap history
2201
+ * @param {SwapHistoryParams} params Swap history params
2202
+ * @param {Address[]} params.addresses - List of addresses
2203
+ * @returns {SwapsHistory} Swap history
2204
+ */
2205
+ getSwapHistory({ addresses }) {
2206
+ return __awaiter(this, void 0, void 0, function* () {
2207
+ const actionsResume = yield this.thorchainCache.midgardQuery.midgardCache.midgard.getActions({
2208
+ address: addresses.join(','),
2209
+ type: 'swap',
2210
+ });
2211
+ const pools = yield this.thorchainCache.getPools();
2212
+ const getInboundCryptoAmount = (pools, asset, amount) => {
2213
+ const decimals = asset in pools ? pools[asset].thornodeDetails.decimals || THORCHAIN_DECIMAL : THORCHAIN_DECIMAL;
2214
+ return decimals === THORCHAIN_DECIMAL
2215
+ ? new CryptoAmount(baseAmount(amount), assetFromStringEx(asset))
2216
+ : getCryptoAmountWithNotation(new CryptoAmount(baseAmount(amount), assetFromStringEx(asset)), decimals);
2217
+ };
2218
+ return {
2219
+ count: actionsResume.count ? Number(actionsResume.count) : 0,
2220
+ swaps: actionsResume.actions.map((action) => {
2221
+ return {
2222
+ date: new Date(Number(action.date) / Math.pow(10, 6)),
2223
+ status: action.status,
2224
+ inboundTx: {
2225
+ hash: action.in[0].txID,
2226
+ address: action.in[0].address,
2227
+ amount: getInboundCryptoAmount(pools, action.in[0].coins[0].asset, action.in[0].coins[0].amount),
2228
+ },
2229
+ outboundTx: {
2230
+ hash: action.out[0].txID,
2231
+ address: action.out[0].address,
2232
+ amount: getInboundCryptoAmount(pools, action.out[0].coins[0].asset, action.out[0].coins[0].amount),
2233
+ },
2234
+ };
2235
+ }),
2236
+ };
2237
+ });
2238
+ }
2198
2239
  }
2199
2240
 
2200
2241
  /**
@@ -2749,5 +2790,5 @@ class TransactionStage {
2749
2790
  }
2750
2791
  }
2751
2792
 
2752
- export { AVAXChain, AddLpStatus, AddSaverStatus, AssetATOM, AssetAVAX, AssetBCH, AssetBNB, AssetBSC, AssetBTC, AssetDOGE, AssetETH, AssetLTC, AssetMAYA, AssetRuneNative, BCHChain, BNBChain, BSCChain, BTCChain, DOGEChain, DefaultChainAttributes, ETHChain, GAIAChain, InboundStatus, LTCChain, LiquidityPool, MAYAChain, RefundStatus, SwapStatus, THORChain, ThorchainCache, ThorchainQuery, Thornode, TransactionStage, TxType, WithdrawStatus, assetUSDC, calcNetworkFee, getCryptoAmountWithNotation, getLiquidityProtectionData, getLiquidityUnits, getPoolShare, getSlipOnLiquidity, isAssetRuneNative };
2793
+ export { AVAXChain, AddLpStatus, AddSaverStatus, AssetATOM, AssetAVAX, AssetBCH, AssetBNB, AssetBSC, AssetBTC, AssetDOGE, AssetETH, AssetLTC, AssetMAYA, AssetRuneNative, BCHChain, BNBChain, BSCChain, BTCChain, DOGEChain, DefaultChainAttributes, ETHChain, GAIAChain, InboundStatus, LTCChain, LiquidityPool, MAYAChain, RefundStatus, SwapStatus, THORCHAIN_DECIMAL, THORChain, ThorchainCache, ThorchainQuery, Thornode, TransactionStage, TxType, WithdrawStatus, assetUSDC, calcNetworkFee, getCryptoAmountWithNotation, getLiquidityProtectionData, getLiquidityUnits, getPoolShare, getSlipOnLiquidity, isAssetRuneNative };
2753
2794
  //# sourceMappingURL=index.esm.js.map