@xchainjs/xchain-thorchain-query 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # `@xchainjs/xchain-thorchain-query`
2
2
 
3
- Thorchain-query module to query thorchain for estimation of swaps. Returns a TxDetail object with all the information needed to conduct a swap.
3
+ Thorchain-query module to query thorchain for estimation of swaps/ add and remove Liquidity and checking a transaction stage.
4
+ Returns a TxDetail object with all the information needed to conduct a swap, or add liquidity. This includes estimateAddSavers()
4
5
 
5
6
  ## Installation
6
7
 
@@ -41,11 +42,72 @@ Estimation example from a swap of 2 BTC to RUNE
41
42
  }
42
43
  ```
43
44
 
45
+ Estimation of add symetric liquidity
46
+ ```ts
47
+ {
48
+ rune: 'ᚱ 12,000',
49
+ asset: '⚡ 0',
50
+ slipPercent: '0.0747',
51
+ lpUnits: '154224962883',
52
+ runeToAssetRatio: '20064.69985077',
53
+ transactionFee: { assetFee: '⚡ 0', runeFee: 'ᚱ 0.02', totalFees: 'ᚱ 0.02' },
54
+ estimatedWaitSeconds: 6,
55
+ errors: [],
56
+ canAdd: true
57
+ }
58
+ ```
59
+
60
+ Estimation of remove Liquidity
61
+ ```ts
62
+ {
63
+ asset: { chain: 'BTC', symbol: 'BTC', ticker: 'BTC', synth: false },
64
+ percentage: 100,
65
+ assetAddress: 'bc1qufc5hvfvszphksqawadpc63ujarhjpn26je2jn',
66
+ runeAddress: ''
67
+ }
68
+ {
69
+ slipPercent: '0.0000',
70
+ runeAmount: 'ᚱ 1,664,891.55918601',
71
+ assetAmount: '₿ 83.01517361',
72
+ inbound: {
73
+ assetFee: '⚡ 10,000',
74
+ runeFee: 'ᚱ 0.02',
75
+ totalFees: 'ᚱ 2.02552681'
76
+ },
77
+ impermanentLossProtection: {
78
+ ILProtection: CryptoAmount { asset: [Object], baseAmount: [Object] },
79
+ totalDays: '346.62'
80
+ },
81
+ estimatedWaitSeconds: 8400
82
+ }
83
+ ```
84
+
85
+ Estimation of Add Saver
86
+ ```ts
87
+ {
88
+ assetAmount: '₿ 0.5',
89
+ estimatedDepositValue: '₿ 0.49937395',
90
+ fee: {
91
+ affiliateFee: '⚡ 0',
92
+ asset: { chain: 'BTC', symbol: 'BTC', ticker: 'BTC', synth: true },
93
+ outbound: '⚡ 0'
94
+ },
95
+ expiry: 2023-03-29T05:58:34.415Z,
96
+ toAddress: 'bc1qucjrczghvwl5d66klz6npv7tshkpwpzlw0zzj8',
97
+ memo: '+:BTC/BTC',
98
+ estimateWaitTime: 600,
99
+ saverCapFilledPercent: 266.3662135203711,
100
+ slipBasisPoints: 12,
101
+ canAdd: true,
102
+ errors: []
103
+ }
104
+ ```
105
+
44
106
  ## Documentation
45
107
 
46
108
  [`Overview `](https://dev.thorchain.org/thorchain-dev/xchainjs-integration-guide/query-package)
47
109
 
48
- For bash exmples, see example folder at the base of this repository xchainjs/xchainjs-lib.
110
+ For bash exmples, see example folder at the base of this repository xchainjs/xchainjs-lib/examples/liquidity.
49
111
 
50
112
  ### [`xchain-thorchain-query`](http://docs.xchainjs.org/xchain-thorchain-query/)
51
113
 
@@ -63,6 +125,8 @@ Get Network Values: https://replit.com/@thorchain/networkValues#index.ts\
63
125
 
64
126
  Estimate AddSaver() & WithdrawSaver() & getSaverPosition() https://replit.com/@thorchain/quoteDepositTS#index.ts
65
127
 
128
+ Check transaction Stage
129
+
66
130
  ### Setting Headers for Nine Realms endpoints
67
131
 
68
132
  If you plan on using the publically accessible endpoints provided by Nine Realms(listed below), ensure that you add a valid 'x-client-id' to all requests
@@ -71,7 +135,7 @@ If you plan on using the publically accessible endpoints provided by Nine Realms
71
135
  - https://haskoin.ninerealms.com (BTC/BCH/LTC)
72
136
  - https://thornode.ninerealms.com
73
137
 
74
- Example
138
+ ## Example
75
139
 
76
140
  ```typescript
77
141
  import cosmosclient from '@cosmos-client/core'
package/lib/index.esm.js CHANGED
@@ -1018,7 +1018,7 @@ class ThorchainCache {
1018
1018
  this.expireInboundDetailsCacheMillis = expireInboundDetailsCacheMillis;
1019
1019
  this.expireNetworkValuesCacheMillis = expireNetworkValuesCacheMillis;
1020
1020
  //initialize the cache
1021
- this.refereshPoolCache();
1021
+ this.refreshPoolCache();
1022
1022
  }
1023
1023
  /**
1024
1024
  * Gets the exchange rate of the from asset in terms on the to asset
@@ -1085,7 +1085,7 @@ class ThorchainCache {
1085
1085
  const millisSinceLastRefeshed = Date.now() - (((_a = this.poolCache) === null || _a === void 0 ? void 0 : _a.lastRefreshed) || 0);
1086
1086
  if (millisSinceLastRefeshed > this.expirePoolCacheMillis) {
1087
1087
  try {
1088
- yield this.refereshPoolCache();
1088
+ yield this.refreshPoolCache();
1089
1089
  }
1090
1090
  catch (e) {
1091
1091
  console.error(e);
@@ -1102,25 +1102,35 @@ class ThorchainCache {
1102
1102
  /**
1103
1103
  * Refreshes the Pool Cache
1104
1104
  *
1105
- * NOTE: do not call refereshPoolCache() directly, call getPools() instead
1105
+ * NOTE: do not call refreshPoolCache() directly, call getPools() instead
1106
1106
  * which will refresh the cache if it's expired
1107
1107
  */
1108
- refereshPoolCache() {
1109
- return __awaiter(this, void 0, void 0, function* () {
1110
- const [thornodePools, midgardPools] = yield Promise.all([this.thornode.getPools(), this.midgard.getPools()]);
1111
- const poolMap = {};
1112
- if (midgardPools) {
1113
- for (const pool of midgardPools) {
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);
1118
- poolMap[`${lp.asset.chain}.${lp.asset.ticker}`] = lp;
1108
+ refreshPoolCache() {
1109
+ return __awaiter(this, void 0, void 0, function* () {
1110
+ try {
1111
+ const [thornodePools, midgardPools] = yield Promise.all([this.thornode.getPools(), this.midgard.getPools()]);
1112
+ const poolMap = {};
1113
+ if (midgardPools) {
1114
+ for (const pool of midgardPools) {
1115
+ try {
1116
+ const thornodePool = thornodePools.find((p) => p.asset === pool.asset);
1117
+ if (!thornodePool)
1118
+ throw Error(`Could not find thornode pool ${pool.asset}`);
1119
+ const lp = new LiquidityPool(pool, thornodePool);
1120
+ poolMap[`${lp.asset.chain}.${lp.asset.ticker}`] = lp;
1121
+ }
1122
+ catch (error) {
1123
+ console.log(error);
1124
+ }
1125
+ }
1126
+ this.poolCache = {
1127
+ lastRefreshed: Date.now(),
1128
+ pools: poolMap,
1129
+ };
1119
1130
  }
1120
- this.poolCache = {
1121
- lastRefreshed: Date.now(),
1122
- pools: poolMap,
1123
- };
1131
+ }
1132
+ catch (error) {
1133
+ console.error('Error refreshing pool cache:', error);
1124
1134
  }
1125
1135
  });
1126
1136
  }
@@ -1549,7 +1559,7 @@ class ThorchainQuery {
1549
1559
  isValidSwap(params) {
1550
1560
  var _a, _b;
1551
1561
  return __awaiter(this, void 0, void 0, function* () {
1552
- if (isAssetRuneNative(params.input.asset)) {
1562
+ if (isAssetRuneNative(params.input.asset) || params.input.asset.synth) {
1553
1563
  if (params.input.baseAmount.decimal !== 8)
1554
1564
  throw Error(`input asset ${assetToString(params.input.asset)} must have decimals of 8`);
1555
1565
  }
@@ -1594,7 +1604,7 @@ class ThorchainQuery {
1594
1604
  ? params.input
1595
1605
  : yield this.thorchainCache.convert(params.input, params.input.asset);
1596
1606
  const inboundFeeInInboundGasAsset = calcNetworkFee(input.asset, sourceInboundDetails);
1597
- let outboundFeeInOutboundGasAsset = calcOutboundFee(params.destinationAsset, destinationInboundDetails).times(3);
1607
+ let outboundFeeInOutboundGasAsset = calcOutboundFee(params.destinationAsset, destinationInboundDetails);
1598
1608
  // Check outbound fee is equal too or greater than 1 USD * need to find a more permanent solution to this. referencing just 1 stable coin pool has problems
1599
1609
  if (params.destinationAsset.chain !== THORChain && !params.destinationAsset.synth) {
1600
1610
  const deepestUSDPOOL = yield this.thorchainCache.getDeepestUSDPool();
@@ -2169,7 +2179,9 @@ class ThorchainQuery {
2169
2179
  errors,
2170
2180
  };
2171
2181
  }
2172
- const depositQuote = yield this.thorchainCache.thornode.getSaversDepositQuote(`${addAmount.asset.chain}.${addAmount.asset.ticker}`, addAmount.baseAmount.amount().toNumber());
2182
+ // request param amount should always be in 1e8 which is why we pass in adjusted decimals if chain decimals != 8
2183
+ const newAddAmount = addAmount.baseAmount.decimal != 8 ? getBaseAmountWithDiffDecimals(addAmount, 8) : addAmount.baseAmount.amount();
2184
+ const depositQuote = yield this.thorchainCache.thornode.getSaversDepositQuote(assetToString(addAmount.asset), newAddAmount.toNumber());
2173
2185
  // Calculate transaction expiry time of the vault address
2174
2186
  const currentDatetime = new Date();
2175
2187
  const minutesToAdd = 15;
@@ -2181,14 +2193,14 @@ class ThorchainQuery {
2181
2193
  if (addAmount.baseAmount.lte(depositQuote.expected_amount_out))
2182
2194
  errors.push(`Amount being added to savers can't pay for fees`);
2183
2195
  const saverFees = {
2184
- affiliate: new CryptoAmount(baseAmount(depositQuote.fees.affiliate, +pool.nativeDecimal), addAmount.asset),
2196
+ affiliate: new CryptoAmount(baseAmount(depositQuote.fees.affiliate), addAmount.asset),
2185
2197
  asset: assetFromStringEx(depositQuote.fees.asset),
2186
- outbound: new CryptoAmount(baseAmount(depositQuote.fees.outbound, +pool.nativeDecimal), addAmount.asset),
2198
+ outbound: new CryptoAmount(baseAmount(depositQuote.fees.outbound), addAmount.asset),
2187
2199
  };
2188
2200
  const saverCap = 0.3 * +pool.assetDepth;
2189
2201
  const saverCapFilledPercent = (+pool.saversDepth / saverCap) * 100;
2190
2202
  const estimateAddSaver = {
2191
- assetAmount: addAmount,
2203
+ assetAmount: new CryptoAmount(baseAmount(depositQuote.expected_amount_out), addAmount.asset),
2192
2204
  estimatedDepositValue: new CryptoAmount(baseAmount(depositQuote.expected_amount_out), saverFees.asset),
2193
2205
  fee: saverFees,
2194
2206
  expiry: expiryDatetime,
@@ -2215,7 +2227,7 @@ class ThorchainQuery {
2215
2227
  const withdrawQuote = yield this.thorchainCache.thornode.getSaversWithdrawQuote(withdrawParams);
2216
2228
  if (!withdrawQuote.expected_amount_out)
2217
2229
  throw Error(`Could not quote withdrawal ${JSON.stringify(withdrawQuote)}`);
2218
- const pool = (yield this.thorchainCache.getPoolForAsset(withdrawParams.asset)).pool;
2230
+ // const pool = (await this.thorchainCache.getPoolForAsset(withdrawParams.asset)).pool
2219
2231
  // Calculate transaction expiry time of the vault address
2220
2232
  const currentDatetime = new Date();
2221
2233
  const minutesToAdd = 15;
@@ -2223,18 +2235,18 @@ class ThorchainQuery {
2223
2235
  const estimatedWait = +withdrawQuote.outbound_delay_seconds;
2224
2236
  const withdrawAsset = assetFromStringEx(withdrawQuote.fees.asset);
2225
2237
  const estimateWithdrawSaver = {
2226
- expectedAssetAmount: new CryptoAmount(baseAmount(withdrawQuote.expected_amount_out, +pool.nativeDecimal), withdrawParams.asset),
2238
+ expectedAssetAmount: new CryptoAmount(baseAmount(withdrawQuote.expected_amount_out), withdrawParams.asset),
2227
2239
  fee: {
2228
- affiliate: new CryptoAmount(baseAmount(withdrawQuote.fees.affiliate, +pool.nativeDecimal), withdrawAsset),
2240
+ affiliate: new CryptoAmount(baseAmount(withdrawQuote.fees.affiliate), withdrawAsset),
2229
2241
  asset: withdrawAsset,
2230
- outbound: new CryptoAmount(baseAmount(withdrawQuote.fees.outbound, +pool.nativeDecimal), withdrawAsset),
2242
+ outbound: new CryptoAmount(baseAmount(withdrawQuote.fees.outbound), withdrawAsset),
2231
2243
  },
2232
2244
  expiry: expiryDatetime,
2233
2245
  toAddress: withdrawQuote.inbound_address,
2234
2246
  memo: withdrawQuote.memo,
2235
2247
  estimatedWaitTime: estimatedWait,
2236
2248
  slipBasisPoints: withdrawQuote.slippage_bps,
2237
- dustAmount: new CryptoAmount(baseAmount(withdrawQuote.dust_amount, +pool.nativeDecimal), withdrawParams.asset),
2249
+ dustAmount: new CryptoAmount(baseAmount(withdrawQuote.dust_amount), withdrawParams.asset),
2238
2250
  };
2239
2251
  return estimateWithdrawSaver;
2240
2252
  });
@@ -2260,8 +2272,8 @@ class ThorchainQuery {
2260
2272
  const saverUnits = Number(pool.saversUnits);
2261
2273
  const assetDepth = Number(pool.saversDepth);
2262
2274
  const redeemableValue = (ownerUnits / saverUnits) * assetDepth;
2263
- const depositAmount = new CryptoAmount(baseAmount(savers.asset_deposit_value, +pool.nativeDecimal), params.asset);
2264
- const redeemableAssetAmount = new CryptoAmount(baseAmount(redeemableValue, +pool.nativeDecimal), params.asset);
2275
+ const depositAmount = new CryptoAmount(baseAmount(savers.asset_deposit_value), params.asset);
2276
+ const redeemableAssetAmount = new CryptoAmount(baseAmount(redeemableValue), params.asset);
2265
2277
  const saversAge = ((blockData === null || blockData === void 0 ? void 0 : blockData.thorchain) - lastAdded) / ((365 * 86400) / 6);
2266
2278
  const saverGrowth = redeemableAssetAmount.minus(depositAmount).div(depositAmount).times(100);
2267
2279
  const saversPos = {
package/lib/index.js CHANGED
@@ -1027,7 +1027,7 @@ class ThorchainCache {
1027
1027
  this.expireInboundDetailsCacheMillis = expireInboundDetailsCacheMillis;
1028
1028
  this.expireNetworkValuesCacheMillis = expireNetworkValuesCacheMillis;
1029
1029
  //initialize the cache
1030
- this.refereshPoolCache();
1030
+ this.refreshPoolCache();
1031
1031
  }
1032
1032
  /**
1033
1033
  * Gets the exchange rate of the from asset in terms on the to asset
@@ -1094,7 +1094,7 @@ class ThorchainCache {
1094
1094
  const millisSinceLastRefeshed = Date.now() - (((_a = this.poolCache) === null || _a === void 0 ? void 0 : _a.lastRefreshed) || 0);
1095
1095
  if (millisSinceLastRefeshed > this.expirePoolCacheMillis) {
1096
1096
  try {
1097
- yield this.refereshPoolCache();
1097
+ yield this.refreshPoolCache();
1098
1098
  }
1099
1099
  catch (e) {
1100
1100
  console.error(e);
@@ -1111,25 +1111,35 @@ class ThorchainCache {
1111
1111
  /**
1112
1112
  * Refreshes the Pool Cache
1113
1113
  *
1114
- * NOTE: do not call refereshPoolCache() directly, call getPools() instead
1114
+ * NOTE: do not call refreshPoolCache() directly, call getPools() instead
1115
1115
  * which will refresh the cache if it's expired
1116
1116
  */
1117
- refereshPoolCache() {
1118
- return __awaiter(this, void 0, void 0, function* () {
1119
- const [thornodePools, midgardPools] = yield Promise.all([this.thornode.getPools(), this.midgard.getPools()]);
1120
- const poolMap = {};
1121
- if (midgardPools) {
1122
- for (const pool of midgardPools) {
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);
1127
- poolMap[`${lp.asset.chain}.${lp.asset.ticker}`] = lp;
1117
+ refreshPoolCache() {
1118
+ return __awaiter(this, void 0, void 0, function* () {
1119
+ try {
1120
+ const [thornodePools, midgardPools] = yield Promise.all([this.thornode.getPools(), this.midgard.getPools()]);
1121
+ const poolMap = {};
1122
+ if (midgardPools) {
1123
+ for (const pool of midgardPools) {
1124
+ try {
1125
+ const thornodePool = thornodePools.find((p) => p.asset === pool.asset);
1126
+ if (!thornodePool)
1127
+ throw Error(`Could not find thornode pool ${pool.asset}`);
1128
+ const lp = new LiquidityPool(pool, thornodePool);
1129
+ poolMap[`${lp.asset.chain}.${lp.asset.ticker}`] = lp;
1130
+ }
1131
+ catch (error) {
1132
+ console.log(error);
1133
+ }
1134
+ }
1135
+ this.poolCache = {
1136
+ lastRefreshed: Date.now(),
1137
+ pools: poolMap,
1138
+ };
1128
1139
  }
1129
- this.poolCache = {
1130
- lastRefreshed: Date.now(),
1131
- pools: poolMap,
1132
- };
1140
+ }
1141
+ catch (error) {
1142
+ console.error('Error refreshing pool cache:', error);
1133
1143
  }
1134
1144
  });
1135
1145
  }
@@ -1558,7 +1568,7 @@ class ThorchainQuery {
1558
1568
  isValidSwap(params) {
1559
1569
  var _a, _b;
1560
1570
  return __awaiter(this, void 0, void 0, function* () {
1561
- if (xchainThorchain.isAssetRuneNative(params.input.asset)) {
1571
+ if (xchainThorchain.isAssetRuneNative(params.input.asset) || params.input.asset.synth) {
1562
1572
  if (params.input.baseAmount.decimal !== 8)
1563
1573
  throw Error(`input asset ${xchainUtil.assetToString(params.input.asset)} must have decimals of 8`);
1564
1574
  }
@@ -1603,7 +1613,7 @@ class ThorchainQuery {
1603
1613
  ? params.input
1604
1614
  : yield this.thorchainCache.convert(params.input, params.input.asset);
1605
1615
  const inboundFeeInInboundGasAsset = calcNetworkFee(input.asset, sourceInboundDetails);
1606
- let outboundFeeInOutboundGasAsset = calcOutboundFee(params.destinationAsset, destinationInboundDetails).times(3);
1616
+ let outboundFeeInOutboundGasAsset = calcOutboundFee(params.destinationAsset, destinationInboundDetails);
1607
1617
  // Check outbound fee is equal too or greater than 1 USD * need to find a more permanent solution to this. referencing just 1 stable coin pool has problems
1608
1618
  if (params.destinationAsset.chain !== xchainThorchain.THORChain && !params.destinationAsset.synth) {
1609
1619
  const deepestUSDPOOL = yield this.thorchainCache.getDeepestUSDPool();
@@ -2178,7 +2188,9 @@ class ThorchainQuery {
2178
2188
  errors,
2179
2189
  };
2180
2190
  }
2181
- const depositQuote = yield this.thorchainCache.thornode.getSaversDepositQuote(`${addAmount.asset.chain}.${addAmount.asset.ticker}`, addAmount.baseAmount.amount().toNumber());
2191
+ // request param amount should always be in 1e8 which is why we pass in adjusted decimals if chain decimals != 8
2192
+ const newAddAmount = addAmount.baseAmount.decimal != 8 ? getBaseAmountWithDiffDecimals(addAmount, 8) : addAmount.baseAmount.amount();
2193
+ const depositQuote = yield this.thorchainCache.thornode.getSaversDepositQuote(xchainUtil.assetToString(addAmount.asset), newAddAmount.toNumber());
2182
2194
  // Calculate transaction expiry time of the vault address
2183
2195
  const currentDatetime = new Date();
2184
2196
  const minutesToAdd = 15;
@@ -2190,14 +2202,14 @@ class ThorchainQuery {
2190
2202
  if (addAmount.baseAmount.lte(depositQuote.expected_amount_out))
2191
2203
  errors.push(`Amount being added to savers can't pay for fees`);
2192
2204
  const saverFees = {
2193
- affiliate: new CryptoAmount(xchainUtil.baseAmount(depositQuote.fees.affiliate, +pool.nativeDecimal), addAmount.asset),
2205
+ affiliate: new CryptoAmount(xchainUtil.baseAmount(depositQuote.fees.affiliate), addAmount.asset),
2194
2206
  asset: xchainUtil.assetFromStringEx(depositQuote.fees.asset),
2195
- outbound: new CryptoAmount(xchainUtil.baseAmount(depositQuote.fees.outbound, +pool.nativeDecimal), addAmount.asset),
2207
+ outbound: new CryptoAmount(xchainUtil.baseAmount(depositQuote.fees.outbound), addAmount.asset),
2196
2208
  };
2197
2209
  const saverCap = 0.3 * +pool.assetDepth;
2198
2210
  const saverCapFilledPercent = (+pool.saversDepth / saverCap) * 100;
2199
2211
  const estimateAddSaver = {
2200
- assetAmount: addAmount,
2212
+ assetAmount: new CryptoAmount(xchainUtil.baseAmount(depositQuote.expected_amount_out), addAmount.asset),
2201
2213
  estimatedDepositValue: new CryptoAmount(xchainUtil.baseAmount(depositQuote.expected_amount_out), saverFees.asset),
2202
2214
  fee: saverFees,
2203
2215
  expiry: expiryDatetime,
@@ -2224,7 +2236,7 @@ class ThorchainQuery {
2224
2236
  const withdrawQuote = yield this.thorchainCache.thornode.getSaversWithdrawQuote(withdrawParams);
2225
2237
  if (!withdrawQuote.expected_amount_out)
2226
2238
  throw Error(`Could not quote withdrawal ${JSON.stringify(withdrawQuote)}`);
2227
- const pool = (yield this.thorchainCache.getPoolForAsset(withdrawParams.asset)).pool;
2239
+ // const pool = (await this.thorchainCache.getPoolForAsset(withdrawParams.asset)).pool
2228
2240
  // Calculate transaction expiry time of the vault address
2229
2241
  const currentDatetime = new Date();
2230
2242
  const minutesToAdd = 15;
@@ -2232,18 +2244,18 @@ class ThorchainQuery {
2232
2244
  const estimatedWait = +withdrawQuote.outbound_delay_seconds;
2233
2245
  const withdrawAsset = xchainUtil.assetFromStringEx(withdrawQuote.fees.asset);
2234
2246
  const estimateWithdrawSaver = {
2235
- expectedAssetAmount: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.expected_amount_out, +pool.nativeDecimal), withdrawParams.asset),
2247
+ expectedAssetAmount: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.expected_amount_out), withdrawParams.asset),
2236
2248
  fee: {
2237
- affiliate: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.fees.affiliate, +pool.nativeDecimal), withdrawAsset),
2249
+ affiliate: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.fees.affiliate), withdrawAsset),
2238
2250
  asset: withdrawAsset,
2239
- outbound: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.fees.outbound, +pool.nativeDecimal), withdrawAsset),
2251
+ outbound: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.fees.outbound), withdrawAsset),
2240
2252
  },
2241
2253
  expiry: expiryDatetime,
2242
2254
  toAddress: withdrawQuote.inbound_address,
2243
2255
  memo: withdrawQuote.memo,
2244
2256
  estimatedWaitTime: estimatedWait,
2245
2257
  slipBasisPoints: withdrawQuote.slippage_bps,
2246
- dustAmount: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.dust_amount, +pool.nativeDecimal), withdrawParams.asset),
2258
+ dustAmount: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.dust_amount), withdrawParams.asset),
2247
2259
  };
2248
2260
  return estimateWithdrawSaver;
2249
2261
  });
@@ -2269,8 +2281,8 @@ class ThorchainQuery {
2269
2281
  const saverUnits = Number(pool.saversUnits);
2270
2282
  const assetDepth = Number(pool.saversDepth);
2271
2283
  const redeemableValue = (ownerUnits / saverUnits) * assetDepth;
2272
- const depositAmount = new CryptoAmount(xchainUtil.baseAmount(savers.asset_deposit_value, +pool.nativeDecimal), params.asset);
2273
- const redeemableAssetAmount = new CryptoAmount(xchainUtil.baseAmount(redeemableValue, +pool.nativeDecimal), params.asset);
2284
+ const depositAmount = new CryptoAmount(xchainUtil.baseAmount(savers.asset_deposit_value), params.asset);
2285
+ const redeemableAssetAmount = new CryptoAmount(xchainUtil.baseAmount(redeemableValue), params.asset);
2274
2286
  const saversAge = ((blockData === null || blockData === void 0 ? void 0 : blockData.thorchain) - lastAdded) / ((365 * 86400) / 6);
2275
2287
  const saverGrowth = redeemableAssetAmount.minus(depositAmount).div(depositAmount).times(100);
2276
2288
  const saversPos = {
@@ -52,10 +52,10 @@ export declare class ThorchainCache {
52
52
  /**
53
53
  * Refreshes the Pool Cache
54
54
  *
55
- * NOTE: do not call refereshPoolCache() directly, call getPools() instead
55
+ * NOTE: do not call refreshPoolCache() directly, call getPools() instead
56
56
  * which will refresh the cache if it's expired
57
57
  */
58
- private refereshPoolCache;
58
+ private refreshPoolCache;
59
59
  /**
60
60
  * Refreshes the InboundDetailCache Cache
61
61
  *
package/lib/types.d.ts CHANGED
@@ -42,6 +42,7 @@ export declare type EstimateSwapParams = {
42
42
  affiliateAddress?: Address;
43
43
  affiliateFeeBasisPoints?: number;
44
44
  interfaceID?: string;
45
+ feeOption?: FeeOption;
45
46
  };
46
47
  export declare type SwapOutput = {
47
48
  output: CryptoAmount;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain-query",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
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,15 +33,15 @@
33
33
  "postversion": "git push --follow-tags"
34
34
  },
35
35
  "devDependencies": {
36
- "@xchainjs/xchain-avax": "^0.1.4",
36
+ "@xchainjs/xchain-avax": "^0.1.5",
37
37
  "@xchainjs/xchain-binance": "^5.6.7",
38
- "@xchainjs/xchain-bitcoin": "^0.21.0",
39
- "@xchainjs/xchain-bitcoincash": "^0.15.8",
38
+ "@xchainjs/xchain-bitcoin": "^0.21.2",
39
+ "@xchainjs/xchain-bitcoincash": "^0.15.9",
40
40
  "@xchainjs/xchain-client": "^0.13.5",
41
41
  "@xchainjs/xchain-cosmos": "^0.20.8",
42
- "@xchainjs/xchain-doge": "^0.5.9",
42
+ "@xchainjs/xchain-doge": "^0.5.1",
43
43
  "@xchainjs/xchain-ethereum": "^0.27.7",
44
- "@xchainjs/xchain-litecoin": "^0.11.0",
44
+ "@xchainjs/xchain-litecoin": "^0.11.2",
45
45
  "@xchainjs/xchain-midgard": "^0.4.3",
46
46
  "@xchainjs/xchain-thorchain": "^0.27.9",
47
47
  "@xchainjs/xchain-thornode": "^0.2.1",
@@ -52,15 +52,15 @@
52
52
  "rimraf": "~3.0.2"
53
53
  },
54
54
  "peerDependencies": {
55
- "@xchainjs/xchain-avax": "^0.1.4",
55
+ "@xchainjs/xchain-avax": "^0.1.5",
56
56
  "@xchainjs/xchain-binance": "^5.6.7",
57
- "@xchainjs/xchain-bitcoin": "^0.21.0",
58
- "@xchainjs/xchain-bitcoincash": "^0.15.8",
57
+ "@xchainjs/xchain-bitcoin": "^0.21.2",
58
+ "@xchainjs/xchain-bitcoincash": "^0.15.9",
59
59
  "@xchainjs/xchain-client": "^0.13.5",
60
60
  "@xchainjs/xchain-cosmos": "^0.20.8",
61
- "@xchainjs/xchain-doge": "^0.5.9",
61
+ "@xchainjs/xchain-doge": "^0.5.11",
62
62
  "@xchainjs/xchain-ethereum": "^0.27.7",
63
- "@xchainjs/xchain-litecoin": "^0.11.0",
63
+ "@xchainjs/xchain-litecoin": "^0.11.2",
64
64
  "@xchainjs/xchain-midgard": "^0.4.3",
65
65
  "@xchainjs/xchain-thorchain": "^0.27.9",
66
66
  "@xchainjs/xchain-thornode": "^0.2.1",