@xchainjs/xchain-thorchain-query 0.6.5 → 0.6.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.esm.js +34 -2
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +34 -2
- package/lib/index.js.map +1 -1
- package/lib/thorchain-query.d.ts +6 -0
- package/lib/types.d.ts +2 -0
- package/package.json +3 -3
package/lib/index.esm.js
CHANGED
|
@@ -1161,6 +1161,11 @@ class ThorchainQuery {
|
|
|
1161
1161
|
quoteSwap({ fromAsset, destinationAsset, amount, destinationAddress, streamingInterval, streamingQuantity, fromAddress, toleranceBps, affiliateBps, affiliateAddress, height, }) {
|
|
1162
1162
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1163
1163
|
const errors = [];
|
|
1164
|
+
const validAssetDecimals = yield this.isValidAssetDecimals(fromAsset, amount);
|
|
1165
|
+
// validates swap, and pushes error if there is one
|
|
1166
|
+
if (validAssetDecimals) {
|
|
1167
|
+
errors.push(`${validAssetDecimals}`);
|
|
1168
|
+
}
|
|
1164
1169
|
const fromAssetString = assetToString(fromAsset);
|
|
1165
1170
|
const toAssetString = assetToString(destinationAsset);
|
|
1166
1171
|
const inputAmount = getBaseAmountWithDiffDecimals(amount, 8);
|
|
@@ -1239,6 +1244,27 @@ class ThorchainQuery {
|
|
|
1239
1244
|
return txDetails;
|
|
1240
1245
|
});
|
|
1241
1246
|
}
|
|
1247
|
+
/**
|
|
1248
|
+
*
|
|
1249
|
+
* @param params - quote swap params
|
|
1250
|
+
* @returns boolean
|
|
1251
|
+
*/
|
|
1252
|
+
isValidAssetDecimals(fromAsset, inputAmount) {
|
|
1253
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1254
|
+
if (isAssetRuneNative(fromAsset) || fromAsset.synth) {
|
|
1255
|
+
if (inputAmount.baseAmount.decimal !== 8) {
|
|
1256
|
+
return `input asset ${assetToString(fromAsset)} must have decimals of 8`;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
else {
|
|
1260
|
+
const nativeDecimals = yield this.thorchainCache.midgardQuery.getDecimalForAsset(fromAsset);
|
|
1261
|
+
if (nativeDecimals && nativeDecimals !== -1 && inputAmount.baseAmount.decimal !== nativeDecimals) {
|
|
1262
|
+
return `input asset ${assetToString(fromAsset)} must have decimals of ${nativeDecimals}`;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
return undefined; // Explicitly return undefined if no conditions are met
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1242
1268
|
/**
|
|
1243
1269
|
* Works out how long an outbound Tx will be held by THORChain before sending.
|
|
1244
1270
|
*
|
|
@@ -1728,6 +1754,8 @@ class ThorchainQuery {
|
|
|
1728
1754
|
expiry: new Date(0),
|
|
1729
1755
|
toAddress: '',
|
|
1730
1756
|
memo: '',
|
|
1757
|
+
inboundDelayBlocks: 0,
|
|
1758
|
+
inboundDelaySeconds: 0,
|
|
1731
1759
|
outBoundDelayBlocks: 0,
|
|
1732
1760
|
outBoundDelaySeconds: 0,
|
|
1733
1761
|
slipBasisPoints: -1,
|
|
@@ -1755,6 +1783,8 @@ class ThorchainQuery {
|
|
|
1755
1783
|
expiry: new Date(0),
|
|
1756
1784
|
toAddress: '',
|
|
1757
1785
|
memo: '',
|
|
1786
|
+
inboundDelayBlocks: 0,
|
|
1787
|
+
inboundDelaySeconds: 0,
|
|
1758
1788
|
outBoundDelayBlocks: 0,
|
|
1759
1789
|
outBoundDelaySeconds: 0,
|
|
1760
1790
|
slipBasisPoints: -1,
|
|
@@ -1776,8 +1806,10 @@ class ThorchainQuery {
|
|
|
1776
1806
|
expiry: new Date(withdrawQuote.expiry),
|
|
1777
1807
|
toAddress: withdrawQuote.inbound_address,
|
|
1778
1808
|
memo: withdrawQuote.memo,
|
|
1779
|
-
|
|
1780
|
-
|
|
1809
|
+
inboundDelayBlocks: withdrawQuote.inbound_confirmation_blocks || 0,
|
|
1810
|
+
inboundDelaySeconds: withdrawQuote.inbound_confirmation_seconds || 0,
|
|
1811
|
+
outBoundDelayBlocks: withdrawQuote.outbound_delay_blocks || 0,
|
|
1812
|
+
outBoundDelaySeconds: withdrawQuote.outbound_delay_seconds || 0,
|
|
1781
1813
|
slipBasisPoints: withdrawQuote.slippage_bps,
|
|
1782
1814
|
errors,
|
|
1783
1815
|
};
|