@xchainjs/xchain-thorchain-query 0.2.0 → 0.2.1
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 +9 -9
- package/lib/index.js +9 -9
- package/package.json +1 -1
package/lib/index.esm.js
CHANGED
|
@@ -1549,7 +1549,7 @@ class ThorchainQuery {
|
|
|
1549
1549
|
isValidSwap(params) {
|
|
1550
1550
|
var _a, _b;
|
|
1551
1551
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1552
|
-
if (isAssetRuneNative(params.input.asset)) {
|
|
1552
|
+
if (isAssetRuneNative(params.input.asset) || params.input.asset.synth) {
|
|
1553
1553
|
if (params.input.baseAmount.decimal !== 8)
|
|
1554
1554
|
throw Error(`input asset ${assetToString(params.input.asset)} must have decimals of 8`);
|
|
1555
1555
|
}
|
|
@@ -1594,7 +1594,7 @@ class ThorchainQuery {
|
|
|
1594
1594
|
? params.input
|
|
1595
1595
|
: yield this.thorchainCache.convert(params.input, params.input.asset);
|
|
1596
1596
|
const inboundFeeInInboundGasAsset = calcNetworkFee(input.asset, sourceInboundDetails);
|
|
1597
|
-
let outboundFeeInOutboundGasAsset = calcOutboundFee(params.destinationAsset, destinationInboundDetails)
|
|
1597
|
+
let outboundFeeInOutboundGasAsset = calcOutboundFee(params.destinationAsset, destinationInboundDetails);
|
|
1598
1598
|
// 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
1599
|
if (params.destinationAsset.chain !== THORChain && !params.destinationAsset.synth) {
|
|
1600
1600
|
const deepestUSDPOOL = yield this.thorchainCache.getDeepestUSDPool();
|
|
@@ -2215,7 +2215,7 @@ class ThorchainQuery {
|
|
|
2215
2215
|
const withdrawQuote = yield this.thorchainCache.thornode.getSaversWithdrawQuote(withdrawParams);
|
|
2216
2216
|
if (!withdrawQuote.expected_amount_out)
|
|
2217
2217
|
throw Error(`Could not quote withdrawal ${JSON.stringify(withdrawQuote)}`);
|
|
2218
|
-
const pool = (
|
|
2218
|
+
// const pool = (await this.thorchainCache.getPoolForAsset(withdrawParams.asset)).pool
|
|
2219
2219
|
// Calculate transaction expiry time of the vault address
|
|
2220
2220
|
const currentDatetime = new Date();
|
|
2221
2221
|
const minutesToAdd = 15;
|
|
@@ -2223,18 +2223,18 @@ class ThorchainQuery {
|
|
|
2223
2223
|
const estimatedWait = +withdrawQuote.outbound_delay_seconds;
|
|
2224
2224
|
const withdrawAsset = assetFromStringEx(withdrawQuote.fees.asset);
|
|
2225
2225
|
const estimateWithdrawSaver = {
|
|
2226
|
-
expectedAssetAmount: new CryptoAmount(baseAmount(withdrawQuote.expected_amount_out
|
|
2226
|
+
expectedAssetAmount: new CryptoAmount(baseAmount(withdrawQuote.expected_amount_out), withdrawParams.asset),
|
|
2227
2227
|
fee: {
|
|
2228
|
-
affiliate: new CryptoAmount(baseAmount(withdrawQuote.fees.affiliate
|
|
2228
|
+
affiliate: new CryptoAmount(baseAmount(withdrawQuote.fees.affiliate), withdrawAsset),
|
|
2229
2229
|
asset: withdrawAsset,
|
|
2230
|
-
outbound: new CryptoAmount(baseAmount(withdrawQuote.fees.outbound
|
|
2230
|
+
outbound: new CryptoAmount(baseAmount(withdrawQuote.fees.outbound), withdrawAsset),
|
|
2231
2231
|
},
|
|
2232
2232
|
expiry: expiryDatetime,
|
|
2233
2233
|
toAddress: withdrawQuote.inbound_address,
|
|
2234
2234
|
memo: withdrawQuote.memo,
|
|
2235
2235
|
estimatedWaitTime: estimatedWait,
|
|
2236
2236
|
slipBasisPoints: withdrawQuote.slippage_bps,
|
|
2237
|
-
dustAmount: new CryptoAmount(baseAmount(withdrawQuote.dust_amount
|
|
2237
|
+
dustAmount: new CryptoAmount(baseAmount(withdrawQuote.dust_amount), withdrawParams.asset),
|
|
2238
2238
|
};
|
|
2239
2239
|
return estimateWithdrawSaver;
|
|
2240
2240
|
});
|
|
@@ -2260,8 +2260,8 @@ class ThorchainQuery {
|
|
|
2260
2260
|
const saverUnits = Number(pool.saversUnits);
|
|
2261
2261
|
const assetDepth = Number(pool.saversDepth);
|
|
2262
2262
|
const redeemableValue = (ownerUnits / saverUnits) * assetDepth;
|
|
2263
|
-
const depositAmount = new CryptoAmount(baseAmount(savers.asset_deposit_value
|
|
2264
|
-
const redeemableAssetAmount = new CryptoAmount(baseAmount(redeemableValue
|
|
2263
|
+
const depositAmount = new CryptoAmount(baseAmount(savers.asset_deposit_value), params.asset);
|
|
2264
|
+
const redeemableAssetAmount = new CryptoAmount(baseAmount(redeemableValue), params.asset);
|
|
2265
2265
|
const saversAge = ((blockData === null || blockData === void 0 ? void 0 : blockData.thorchain) - lastAdded) / ((365 * 86400) / 6);
|
|
2266
2266
|
const saverGrowth = redeemableAssetAmount.minus(depositAmount).div(depositAmount).times(100);
|
|
2267
2267
|
const saversPos = {
|
package/lib/index.js
CHANGED
|
@@ -1558,7 +1558,7 @@ class ThorchainQuery {
|
|
|
1558
1558
|
isValidSwap(params) {
|
|
1559
1559
|
var _a, _b;
|
|
1560
1560
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1561
|
-
if (xchainThorchain.isAssetRuneNative(params.input.asset)) {
|
|
1561
|
+
if (xchainThorchain.isAssetRuneNative(params.input.asset) || params.input.asset.synth) {
|
|
1562
1562
|
if (params.input.baseAmount.decimal !== 8)
|
|
1563
1563
|
throw Error(`input asset ${xchainUtil.assetToString(params.input.asset)} must have decimals of 8`);
|
|
1564
1564
|
}
|
|
@@ -1603,7 +1603,7 @@ class ThorchainQuery {
|
|
|
1603
1603
|
? params.input
|
|
1604
1604
|
: yield this.thorchainCache.convert(params.input, params.input.asset);
|
|
1605
1605
|
const inboundFeeInInboundGasAsset = calcNetworkFee(input.asset, sourceInboundDetails);
|
|
1606
|
-
let outboundFeeInOutboundGasAsset = calcOutboundFee(params.destinationAsset, destinationInboundDetails)
|
|
1606
|
+
let outboundFeeInOutboundGasAsset = calcOutboundFee(params.destinationAsset, destinationInboundDetails);
|
|
1607
1607
|
// 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
1608
|
if (params.destinationAsset.chain !== xchainThorchain.THORChain && !params.destinationAsset.synth) {
|
|
1609
1609
|
const deepestUSDPOOL = yield this.thorchainCache.getDeepestUSDPool();
|
|
@@ -2224,7 +2224,7 @@ class ThorchainQuery {
|
|
|
2224
2224
|
const withdrawQuote = yield this.thorchainCache.thornode.getSaversWithdrawQuote(withdrawParams);
|
|
2225
2225
|
if (!withdrawQuote.expected_amount_out)
|
|
2226
2226
|
throw Error(`Could not quote withdrawal ${JSON.stringify(withdrawQuote)}`);
|
|
2227
|
-
const pool = (
|
|
2227
|
+
// const pool = (await this.thorchainCache.getPoolForAsset(withdrawParams.asset)).pool
|
|
2228
2228
|
// Calculate transaction expiry time of the vault address
|
|
2229
2229
|
const currentDatetime = new Date();
|
|
2230
2230
|
const minutesToAdd = 15;
|
|
@@ -2232,18 +2232,18 @@ class ThorchainQuery {
|
|
|
2232
2232
|
const estimatedWait = +withdrawQuote.outbound_delay_seconds;
|
|
2233
2233
|
const withdrawAsset = xchainUtil.assetFromStringEx(withdrawQuote.fees.asset);
|
|
2234
2234
|
const estimateWithdrawSaver = {
|
|
2235
|
-
expectedAssetAmount: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.expected_amount_out
|
|
2235
|
+
expectedAssetAmount: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.expected_amount_out), withdrawParams.asset),
|
|
2236
2236
|
fee: {
|
|
2237
|
-
affiliate: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.fees.affiliate
|
|
2237
|
+
affiliate: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.fees.affiliate), withdrawAsset),
|
|
2238
2238
|
asset: withdrawAsset,
|
|
2239
|
-
outbound: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.fees.outbound
|
|
2239
|
+
outbound: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.fees.outbound), withdrawAsset),
|
|
2240
2240
|
},
|
|
2241
2241
|
expiry: expiryDatetime,
|
|
2242
2242
|
toAddress: withdrawQuote.inbound_address,
|
|
2243
2243
|
memo: withdrawQuote.memo,
|
|
2244
2244
|
estimatedWaitTime: estimatedWait,
|
|
2245
2245
|
slipBasisPoints: withdrawQuote.slippage_bps,
|
|
2246
|
-
dustAmount: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.dust_amount
|
|
2246
|
+
dustAmount: new CryptoAmount(xchainUtil.baseAmount(withdrawQuote.dust_amount), withdrawParams.asset),
|
|
2247
2247
|
};
|
|
2248
2248
|
return estimateWithdrawSaver;
|
|
2249
2249
|
});
|
|
@@ -2269,8 +2269,8 @@ class ThorchainQuery {
|
|
|
2269
2269
|
const saverUnits = Number(pool.saversUnits);
|
|
2270
2270
|
const assetDepth = Number(pool.saversDepth);
|
|
2271
2271
|
const redeemableValue = (ownerUnits / saverUnits) * assetDepth;
|
|
2272
|
-
const depositAmount = new CryptoAmount(xchainUtil.baseAmount(savers.asset_deposit_value
|
|
2273
|
-
const redeemableAssetAmount = new CryptoAmount(xchainUtil.baseAmount(redeemableValue
|
|
2272
|
+
const depositAmount = new CryptoAmount(xchainUtil.baseAmount(savers.asset_deposit_value), params.asset);
|
|
2273
|
+
const redeemableAssetAmount = new CryptoAmount(xchainUtil.baseAmount(redeemableValue), params.asset);
|
|
2274
2274
|
const saversAge = ((blockData === null || blockData === void 0 ? void 0 : blockData.thorchain) - lastAdded) / ((365 * 86400) / 6);
|
|
2275
2275
|
const saverGrowth = redeemableAssetAmount.minus(depositAmount).div(depositAmount).times(100);
|
|
2276
2276
|
const saversPos = {
|
package/package.json
CHANGED